///<reference path="/Scripts/ExtPB_Net.js" />
///<reference path="/Scripts/MyExtPB.js" />
///<reference path="/Scripts/ExtPB_Dll_Pb_Http.js" />
///<reference path="/Scripts/MyExtPb_Input.js" />

function W_CWJYZKFX() {

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var dw_format = new DataWindow(requestor);
    var dw_temp = new DataWindow(requestor);
    var dw_list = new DataWindow(requestor);
    var sle_bm = new SingleLineEdit(requestor);
    var rb_hz = new RadioButton(requestor);
    var rb_mx = new RadioButton(requestor);
    var rb_bm = new RadioButton(requestor);
    var dp_end = new DatePicker(requestor);
    var dp_beg = new DatePicker(requestor);
    var tb_1 = new ToolStrip(requestor);

    if (typeof (this.bind) == "function") var baseBind = this.bind;
    this.bind = function (win) {
        self.Instance = win;
        if (typeof (baseBind) == "function") baseBind(win);

        if (requestor == null) requestor = new PBWindow();
        requestor.Attach(win);
        if (dw_format == null) dw_format = new DataWindow(requestor);
        dw_format.Attach(win.Control("dw_format"));
        if (dw_temp == null) dw_temp = new DataWindow(requestor);
        dw_temp.Attach(win.Control("dw_temp"));
        if (dw_list == null) dw_list = new DataWindow(requestor);
        dw_list.Attach(win.Control("dw_list"));
        if (sle_bm == null) sle_bm = new SingleLineEdit(requestor);
        sle_bm.Attach(win.Control("sle_bm"));
        if (rb_hz == null) rb_hz = new RadioButton(requestor);
        rb_hz.Attach(win.Control("rb_hz"));
        if (rb_mx == null) rb_mx = new RadioButton(requestor);
        rb_mx.Attach(win.Control("rb_mx"));
        if (rb_bm == null) rb_bm = new RadioButton(requestor);
        rb_bm.Attach(win.Control("rb_bm"));
        if (dp_end == null) dp_end = new DatePicker(requestor);
        dp_end.Attach(win.Control("dp_end"));
        if (dp_beg == null) dp_beg = new DatePicker(requestor);
        dp_beg.Attach(win.Control("dp_beg"));
        if (tb_1 == null) tb_1 = new ToolStrip(requestor);
        tb_1.Attach(win.Control("tb_1"));

        if (typeof (self.PostOpen) == "function")
            win.AttachEvent("window", "PostOpen", self.PostOpen);

        if (typeof (self.Changebmbh) == "function")
            win.AttachEvent("btnDepartMent", "Clicked", self.Changebmbh);

        if (typeof (self.Static) == "function")
            win.AttachEvent("btn_Query", "Clicked", self.Static);

        if (typeof (self.CloseQuery) == "function")
            win.AttachEvent("btnClose", "Clicked", self.CloseQuery);

    }

    if (typeof (this.unbind) == "function") var baseUnBind = this.unbind;
    this.unbind = function () {
        self.Instance = null;
        if (typeof (this.Release) == "function") this.Release();
        if (typeof (baseUnBind) == "function") baseUnBind();

        dw_format.Detach(); dw_format = null;
        dw_temp.Detach(); dw_temp = null;
        dw_list.Detach(); dw_list = null;
        sle_bm.Detach(); sle_bm = null;
        rb_hz.Detach(); rb_hz = null;
        rb_mx.Detach(); rb_mx = null;
        rb_bm.Detach(); rb_bm = null;
        dp_end.Detach(); dp_end = null;
        dp_beg.Detach(); dp_beg = null;
        tb_1.Detach(); tb_1 = null;
        requestor.Detach(); requestor = null;

        setTimeout(CollectGarbage, 100);
    }

    //以上代码由设计器自动生成,请不要手工修改
    //ExtPB.Net JavaScript End  设计器查找标志,请不要删除或修改


    var curYhbh = "";
    var curBbmc = "rb_sp";
    var curCdbh = "";
    webReq = new WebRequestor();
    webReq.SetWebServiceUrl("/Service/ServiceForDwSyndax.ashx");
    var curW_OPEN_BMDA = new OpenWindowQueryBase();

    var curW_OPEN_BMDA_NEW = new OpenWindowQueryNewBase();
    var curW_OPEN_BMDA_URL = "OpenWindowQueryNewBase";
    var curSelDays = ""; //默认该模块可查询天数
    
    this.PostOpen = function () {
        rb_hz.SetChecked(true);
        curYhbh = requestor.GetParm("curYhbh");
        curCdbh = requestor.GetParm("curCdbh");
        curSelDays = GetXiTongCanShu(curYhbh, curCdbh, "bzxx");
    }
    //退出操作
    this.CloseQuery = function () {
        setTimeout("window.close()", 100); 
    }
    //统计
    this.Static = function () {
        var type = "0";
        if (rb_bm.GetChecked()) {
            type = "2";
        }
        else if (rb_hz.GetChecked())
        { type = "1"; }
        else if (rb_mx.GetChecked())
        { type = "3"; }

        if (type != 0) {

            var beginDate = UtcDateFormatToString(dp_beg.GetValue());

            if (curSelDays != "-1") {
                beginDate = compareDate(curSelDays, beginDate);
            }

            var endDate = UtcDateFormatToString(dp_end.GetValue());
            dw_temp.Reset();

            //汇总
            if (type == "1") {
                dw_list.SetDataObject("da_cw_jyzk_hz");
                var curBm = "";
                if (sle_bm.GetText().length > 0) {
                    curBm = sle_bm.GetText();
                    curBm = curBm.replace(new RegExp(/'/g), '');
                    dw_list.Retrieve("Y", curBm, beginDate, endDate, curYhbh);
                }
                else {
                    dw_list.Retrieve("N", curBm, beginDate, endDate, curYhbh)
                }

                //                var realSql = " (convert(date,base.kdrq,120) between '" + beginDate + "' and'" + endDate + "') and bmqx.cwcx='1' and bmqx.yhbh='" + curYhbh + "'";
                //                var curBm = sle_bm.GetText();
                //                if (curBm.length > 0) {
                //                    curBm = self.DealWords(curBm);

                //                    realSql += " and base.bmbh  in(" + curBm + ")";
                //                }
                //                realSql += "  group by lx1,lx2,lx3,xh order by xh";
                //                dw_list.RetrieveEx(realSql);
                if (dw_list.RowCount() > 0) {
                    var khys = 0;
                    var mlsl = 0;
                    var mlje = 0;
                    var lrsl = 0;
                    var lrje = 0;
                    for (var i = 1; i <= dw_list.RowCount(); i++) {
                        if (dw_list.GetItemString(i, "lx1") == "收入") {

                            lrsl = lrsl + dw_list.GetItemNumber(i, "sl");
                            mlsl = mlsl + dw_list.GetItemNumber(i, "sl");
                            lrje = lrje + dw_list.GetItemNumber(i, "je");
                            mlje = mlje + dw_list.GetItemNumber(i, "je");
                            khys = khys + dw_list.GetItemNumber(i, "je");

                        }
                        if (dw_list.GetItemString(i, "lx1") == "其它收入") {

                            lrsl = lrsl + dw_list.GetItemNumber(i, "sl");
                            lrje = lrje + dw_list.GetItemNumber(i, "je");

                        }
                        if (dw_list.GetItemString(i, "lx1") == "成本") {


                            lrje = lrje - dw_list.GetItemNumber(i, "je");
                            mlje = mlje - dw_list.GetItemNumber(i, "je");
                        }

                        if (dw_list.GetItemString(i, "lx1") == "费用") {


                            lrje = lrje - dw_list.GetItemNumber(i, "je");
                            //                                                                            mlje = mlje + dw_list.GetItemNumber(i, "je");
                        }
                    }
                    //                    var rowkhys = dw_list.InsertRow(0);
                    var rowml = dw_list.InsertRow(0);
                    var rowlr = dw_list.InsertRow(0);
                    var rowbz = dw_list.InsertRow(0);
                    dw_list.SetItem(rowml, "lx1", "毛利");
                    dw_list.SetItem(rowml, "lx2", "");
                    dw_list.SetItem(rowml, "lx3", "");
                    dw_list.SetItem(rowml, "sl", "");
                    dw_list.SetItem(rowml, "je", mlje);
                    dw_list.SetItem(rowlr, "lx1", "利润");
                    dw_list.SetItem(rowlr, "lx2", "");
                    dw_list.SetItem(rowlr, "lx3", "");
                    dw_list.SetItem(rowlr, "sl", "");
                    dw_list.SetItem(rowlr, "je", lrje);
                    //                    dw_list.SetItem(rowkhys, "lx1", "客户本期应收款");
                    //                    dw_list.SetItem(rowkhys, "lx2", "");
                    //                    dw_list.SetItem(rowkhys, "lx3", "");
                    //                    dw_list.SetItem(rowkhys, "sl", "");
                    //                    dw_list.SetItem(rowkhys, "je", khys);

                    dw_list.SetItem(rowbz, "lx1", "备注");
                    //                    dw_list.SetItem(rowbz, "lx2", "毛利：收入(销售收入)-成本；");
                    //                    dw_list.SetItem(rowbz, "lx3", "利润：收入+其它收入-成本-费用");
                    dw_list.SetItem(rowbz, "lx2", "毛利：收入(销售收入)-成本");
                    dw_list.SetItem(rowbz, "lx3", "利润：收入-成本-费用");


                }
            }
            else if (type == "2") {
                dw_list.SetDataObject("da_cw_jyzk_bm");
                var realSql = " (convert(date,base.kdrq,120) between '" + beginDate + "' and'" + endDate + "') and bmqx.cwcx='1'  and bmqx.yhbh='" + curYhbh + "'";
                var curBm = sle_bm.GetText();
                if (curBm.length > 0) {
                    curBm = self.DealWords(curBm);
                    realSql += " and base.bmbh  in(" + curBm + ")";
                }
                realSql += "  group by base.bmbh";
                dw_list.RetrieveEx(realSql);
                requestor.ClipBoard(realSql);
            }

            else if (type == "3") {
                dw_list.SetDataObject("da_cw_jyzk_mx");
                var realSql = " (convert(date,base.kdrq,120) between '" + beginDate + "' and'" + endDate + "') and bmqx.cwcx='1'  and bmqx.yhbh='" + curYhbh + "'";
                var curBm = sle_bm.GetText();
                if (curBm.length > 0) {
                    curBm = self.DealWords(curBm);
                    realSql += " and base.bmbh  in(" + curBm + ")";
                }
                realSql += "  group by lx1,lx2,lx3,base.bmbh,base.khbh,xh order by xh";
                dw_list.RetrieveEx(realSql);

            }
        }
        else {

            dw_list.Reset();
        }
    }

    //#region  报表格式保存
    this.ReportSave = function () {
        dw_format.Reset();
        var curChildDWCheckValue = ChildDWCheckValue;
        if (curChildDWCheckValue.length > 1) {
            curChildDWCheckValue = curChildDWCheckValue.substring(0, curChildDWCheckValue.length - 1);

            var tempValue = curChildDWCheckValue.split(",");

            for (var i = 0; i < tempValue.length; i++) {

                var curRows = dw_format.InsertRow(0);
                dw_format.SetItem(curRows, 'cdbh', curCdbh);
                dw_format.SetItem(curRows, 'yhbh', curUserId);
                dw_format.SetItem(curRows, 'col', tempValue[i]);
                dw_format.SetItem(curRows, 'mrgxtj', "1");
                dw_format.SetItem(curRows, 'bbmc', curBbmc);
            }
        }

        var curGouCol = "";
        if (curUserId == "" || curBbmc == "") {
            requestor.MessageBox("提示", "请查询后再保存格式", ICON.Information);
            return;
        }
        var curColNames = "";

        //#region 列
        var colCount = dw_list.Describe("DataWindow.Column.Count");
        for (var k = 1; k <= colCount; k++) {
            var ls_col = dw_list.Describe("#" + k + ".Name"); // PB对应字段名  
            var li_row = dw_format.InsertRow(0);
            dw_format.SetItem(li_row, 'cdbh', curCdbh);
            dw_format.SetItem(li_row, 'bbmc', curBbmc);
            dw_format.SetItem(li_row, 'yhbh', curUserId);
            dw_format.SetItem(li_row, 'col', ls_col);
            dw_format.SetItem(li_row, 'col_hz', dw_list.Describe(ls_col + "_t.text"));
            dw_format.SetItem(li_row, 'col_x', parseInt(dw_list.Describe(ls_col + ".x")));
            dw_format.SetItem(li_row, 'width', parseInt(dw_list.Describe(ls_col + ".width")));
            dw_format.SetItem(li_row, 'visible', dw_list.Describe(ls_col + ".visible"));
            dw_format.SetItem(li_row, 'col_type', dw_list.Describe(ls_col + ".Coltype"));
            dw_format.SetItem(li_row, 'obj_type', dw_list.Describe(ls_col + ".type"));
            dw_format.SetItem(li_row, 'font_face', dw_list.Describe(ls_col + ".Font.Face"));
            dw_format.SetItem(li_row, 'font_height', dw_list.Describe(ls_col + ".Font.Height"));
            dw_format.SetItem(li_row, 'font_weight', dw_list.Describe(ls_col + ".Font.Weight"));
            var ls_font_italic = dw_list.Describe(ls_col + ".Font.Italic");
            if (ls_font_italic == '?') {
                ls_font_italic = '0'
            }
            dw_format.SetItem(li_row, 'font_italic', ls_font_italic)

            var ls_font_underline = dw_list.Describe(ls_col + ".Font.Underline")

            if (ls_font_underline == '?') {
                ls_font_underline = '0'
            }
            dw_format.SetItem(li_row, 'font_underline', ls_font_underline)

            ls_col_border = dw_list.Describe(ls_col + ".Border")
            dw_format.SetItem(li_row, 'col_border', ls_col_border)

            ls_color = dw_list.Describe(ls_col + ".Color")
            dw_format.SetItem(li_row, 'color', ls_color)

            ls_format = dw_list.Describe(ls_col + ".Format")
            dw_format.SetItem(li_row, 'format', ls_format)

            ls_alignment = dw_list.Describe(ls_col + ".Alignment")

            dw_format.SetItem(li_row, 'alignment', ls_alignment);

            li_tabsequence = parseInt(dw_list.Describe(ls_col + ".TabSequence"))
            dw_format.SetItem(li_row, 'tabsequence', li_tabsequence);

            ls_bg_mode = dw_list.Describe(ls_col + ".Background.Mode")
            dw_format.SetItem(li_row, 'bg_mode', ls_bg_mode)

            ls_bg_color = dw_list.Describe(ls_col + ".Background.Color")
            dw_format.SetItem(li_row, 'bg_color', ls_bg_color);


        }
        //#endregion

        //#region  计算列
        var ls_objects = dw_list.Describe("DataWindow.Objects");
        var ls_objectsArr = ls_objects.split("\t");

        for (var w = 0; w < ls_objectsArr.length; w++) {
            var ls_name = ls_objectsArr[w];
            var ls_type = dw_list.Describe(ls_name + ".type");
            var ls_band = dw_list.Describe(ls_name + ".band");
            if (ls_type == "compute" && ls_band == "detail") {
                var ls_col = ls_name;
                var li_row = dw_format.InsertRow(0);
                dw_format.SetItem(li_row, 'cdbh', curCdbh);
                dw_format.SetItem(li_row, 'bbmc', curBbmc);
                dw_format.SetItem(li_row, 'yhbh', curUserId);
                dw_format.SetItem(li_row, 'col', ls_col);

                dw_format.SetItem(li_row, 'col_hz', dw_list.Describe(ls_col + "_t.text"))

                dw_format.SetItem(li_row, 'col_x', parseInt(dw_list.Describe(ls_col + ".x")))

                dw_format.SetItem(li_row, 'width', parseInt(dw_list.Describe(ls_col + ".width")))


                dw_format.SetItem(li_row, 'visible', dw_list.Describe(ls_col + ".visible"))


                dw_format.SetItem(li_row, 'col_type', dw_list.Describe(ls_col + ".Coltype"))


                dw_format.SetItem(li_row, 'obj_type', dw_list.Describe(ls_col + ".type"))


                dw_format.SetItem(li_row, 'font_face', dw_list.Describe(ls_col + ".Font.Face"))


                dw_format.SetItem(li_row, 'font_height', dw_list.Describe(ls_col + ".Font.Height"))


                dw_format.SetItem(li_row, 'font_weight', dw_list.Describe(ls_col + ".Font.Weight"))

                var ls_font_italic = dw_list.Describe(ls_col + ".Font.Italic");
                if (ls_font_italic == '?') {
                    ls_font_italic = '0'
                }
                dw_format.SetItem(li_row, 'font_italic', ls_font_italic)

                var ls_font_underline = dw_list.Describe(ls_col + ".Font.Underline")

                if (ls_font_underline == '?') {
                    ls_font_underline = '0'
                }
                dw_format.SetItem(li_row, 'font_underline', ls_font_underline)

                ls_col_border = dw_list.Describe(ls_col + ".Border")
                dw_format.SetItem(li_row, 'col_border', ls_col_border)

                ls_color = dw_list.Describe(ls_col + ".Color")
                dw_format.SetItem(li_row, 'color', ls_color)

                ls_format = dw_list.Describe(ls_col + ".Format")
                dw_format.SetItem(li_row, 'format', ls_format)

                ls_alignment = dw_list.Describe(ls_col + ".Alignment")

                dw_format.SetItem(li_row, 'alignment', ls_alignment);

                li_tabsequence = parseInt(dw_list.Describe(ls_col + ".TabSequence"))
                dw_format.SetItem(li_row, 'tabsequence', li_tabsequence);

                ls_bg_mode = dw_list.Describe(ls_col + ".Background.Mode")
                dw_format.SetItem(li_row, 'bg_mode', ls_bg_mode)

                ls_bg_color = dw_list.Describe(ls_col + ".Background.Color")
                dw_format.SetItem(li_row, 'bg_color', ls_bg_color);

                ls_expression = dw_list.Describe(ls_col + ".Expression");
                dw_format.SetItem(li_row, 'expression', ls_expression);
            }
        }
        //#endregion

        //#region 保存

        var dwChanges = dw_format.GetChanges();
        if (dwChanges == "") {
            requestor.MessageBox("提示", "没有格式变更，不需要保存", ICON.Information);
            return;
        }
        $.ajax({
            type: "POST",
            url: "/Service/Ajax_XT.ashx",
            async: false,
            data: { curFlag: "report_format", dwObjects: dw_format.GetDataObject(), dwChanges: dwChanges, curYhbh: curUserId, curCdbh: curCdbh, curBbmc: curBbmc },
            success: function (msg) {
                if (msg == "OK") {
                    requestor.MessageBox("提示", "保存成功", ICON.Information);

                    dw_format.ResetUpdate();

                    return;
                }
                else {
                    requestor.MessageBox("提示", "出错了", ICON.StopSign);
                }
            },
            error: function (req) {
                requestor.MessageBox("提示", req.responseText, ICON.StopSign);
            }
        });
        //#endregion 
    }
    //#endregion  
    this.SetValue = function (str1, str2, str3, str4) {

        ChildDWCheckValue = str1;
        curBbmc = str2;
        curCdbh = str3;
        curUserId = str4;
    }



    //#region 格式保存#报表格式操作
    this.ReportOp = function () {
        curW_Base_Report_Open_Mx.SetDataWindow(self, curUserId, curCdbh, curBbmc, "curParent.TongJi();");
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.Base.W_Base_Report_Open_Mx"), curW_Base_Report_Open_Mx, null);
    }
    //#endregion  

    //#region 格式保存#报表格式清空
    this.ReportClare = function () {

        for (var i = dw_format.RowCount(); i > 0; i--) {
            dw_format.DeleteRow(i)
        }

        var dwChanges = dw_format.GetChanges();
        if (dwChanges == "") {
            requestor.MessageBox("提示", "没有格式变更，不需要保存", ICON.Information);
            return;
        }
        $.ajax({
            type: "POST",
            url: "/Service/Ajax_XT.ashx",
            async: false,
            data: { curFlag: "report_format_delete", dwObjects: dw_format.GetDataObject(), dwChanges: dwChanges, curYhbh: curUserId, curCdbh: curCdbh, curBbmc: curBbmc },
            success: function (msg) {
                if (msg == "OK") {
                    requestor.MessageBox("提示", "清除成功", ICON.Information);
                    dw_format.ResetUpdate();
                    self.TongJi();
                    return;
                }
                else {
                    requestor.MessageBox("提示", "出错了", ICON.StopSign);
                }
            },
            error: function (req) {
                requestor.MessageBox("提示", req.responseText, ICON.StopSign);
            }
        });

    }
    //#endregion
    this.Changebmbh = function (x, y, row, dwoName) {
        dwoName == "bmbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_CWJYZKFX, "bmbh", "bmmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base." + curW_OPEN_BMDA_URL + "&treeDw=dw_da_bmda_fl_tree&listDw=dw_pub_list_bmda&treeRootLabel=部门分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple&curQxlx=cwcx"), curW_OPEN_BMDA_NEW, null);
    }
    //#region 选中后赋值

    this.SetSleValue = function (difBh, val) {
        if ("''" == val)
            val = "";
        if ("bmbh" == difBh)
            sle_bm.SetText(val);
    }

    //#region 获取where 条件
    this.GetSqlWhere = function (flag) {
        var realSql = "";
        var curYhbh = requestor.GetParm("curYhbh")
        var curBm = sle_bm.GetText();
        //        var curGys = sle_gys.GetText();
        //        var curkh = sle_kh.GetText();
        //        var curkm = sle_km.GetText();
        var beginDate = UtcDateFormatToString(dp_beg.GetValue());
        var endDate = UtcDateFormatToString(dp_end.GetValue());

        //        realSql += " and (CONVERT(date,a.rq) between ''" + beginDate + "'' and ''" + endDate + "'')";
        realSql += " and (CONVERT(date,a.rq) between '" + beginDate + "' and '" + endDate + "')";

        //        if (curkh.length > 0) {

        //            curkh = self.DealWords(curkh);
        //            if (flag == true)
        //                realSql += " and a.khbh in(" + curkh + ")";
        //            else
        //                realSql += " and a.khbh in('" + curkh + "')";
        //        }
        if (curBm.length > 0) {
            curBm = self.DealWords(curBm);
            if (flag == true)
                realSql += " and a.bmbh  in(" + curBm + ")";
            //            else
            //                realSql += "and  a.bmbh  in('" + curBm + "')";
        } else {
            realSql += "and a.bmbh in(select bmbh  from da_qx_bmqxsz where yhbh = '" + curYhbh + "'and tjfx = '1')"
        }
        //        if (curGys.length > 0) {
        //            curGys = self.DealWords(curGys);
        //            if (flag == true)
        //                realSql += " and a.gysbh in(" + curGys + ")";
        //            else
        //                realSql += " and a.gysbh in('" + curGys + "')";
        //        }
        //        if (curkm.length > 0) {
        //            curkm = self.DealWords(curkm);
        //            if (flag == true) {
        //                if (curKhdzdNew == "0") {
        //                    realSql += " and b.sfkm in(" + curkm + ")";
        //                } else {
        //                    realSql += " and km in(" + curkm + ")";
        //                }
        //            }
        //            else {
        //                if (curKhdzdNew == "0") {
        //                    realSql += " and b.sfkm in('" + curkm + "')";
        //                } else {
        //                    realSql += " and km in('" + curkm + "')";
        //                }
        //            }
        //        }

        return realSql;


    }
    //#endregion

    //#region Function DealWords
    this.DealWords = function (words) {
        if (!(words.charAt(0) == "'"))
            words = "'" + words + "'";
        return words;

    }
    //#endregion

    //#region Function DrawDataWindow
    this.DrawDataWindow = function (parameter) {
        webReq.Invoke("dealDwSyndax", "sql=" + parameter);
        if (webReq.StatusCode() == 200) {
            requestor.Clipbord(webReq.ResponseText());
            dw_temp.Create(webReq.ResponseText());
            dw_temp.Refresh();
            dw_list.SetFullState(dw_temp.GetFullState());
            dw_list.SetRowSelection(1);
            gRowCount = dw_list.RowCount();
            var colCount = dw_list.Describe("DataWindow.Column.Count");
            self.SetItemName(colCount);

            SetDecimalColumnFormat(dw_list, "")
        } else {
            alert("error!");
        }
    }
    //#endregion 

    //#region 设置标题名称
    this.SetItemName = function (colCount) {

        var ls_columntitle = "";
        for (var li_loop1 = 1; li_loop1 <= colCount; li_loop1++) {
            var ls_columnname = dw_list.Describe('#' + String(li_loop1) + '.name');
            switch (ls_columnname) {
                case "cw_xjzcpz_tz_bmbh":
                    ls_columntitle = "部门编号"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "bmbh":
                    ls_columntitle = "部门编号"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "da_bmda_bmmc":
                    ls_columntitle = "部门名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "bmmc":
                    ls_columntitle = "部门名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;

                case "cw_xjzcpz_sfkm_skzh":
                    ls_columntitle = "账户名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "cw_xianjin_yinhang_zh_zhmc":
                    ls_columntitle = "账户名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "xjzh":
                    ls_columntitle = "账户编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "zhmc":
                    ls_columntitle = "账户名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "rq":
                    ls_columntitle = "日期";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "kdrq":
                    ls_columntitle = "日期";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "cw_xjzcpz_sfkm_sfkm":
                    ls_columntitle = "科目编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "da_cy_kmda_kmmc":
                    ls_columntitle = "科目名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "km":
                    ls_columntitle = "科目编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "kmmc":
                    ls_columntitle = "科目名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "cw_xjzcpz_tz_gysbh":
                    ls_columntitle = "供应商编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "da_gysda_gysmc":
                    ls_columntitle = "供应商名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "gysbh":
                    ls_columntitle = "供应商编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "gysmc":
                    ls_columntitle = "供应商名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "cw_xjzcpz_tz_pzh":
                    ls_columntitle = "凭证号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    break;
                case "pzh":
                    ls_columntitle = "凭证号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    break;
                case "cw_xjzcpz_tz_rq":
                    ls_columntitle = "日期";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "cw_xjzcpz_tz_zdr":
                    ls_columntitle = "制单人";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "zdr":
                    ls_columntitle = "制单人";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;

                case "hj":
                    ls_columntitle = "金额";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    //dw_list.Modify(ls_columnname + ".format='0.00' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "sr":
                    ls_columntitle = "收入";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    //dw_list.Modify(ls_columnname + ".format='0.00' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "zc":
                    ls_columntitle = "支出";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    //dw_list.Modify(ls_columnname + ".format='0.00' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;

                case "khbh":
                    ls_columntitle = "客户编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "khmc":
                    ls_columntitle = "客户名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");

                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "bz":
                    ls_columntitle = "备注";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
            }
        }
        self.SetSummary();
    }

    this.SetSummary = function () {

        var ls_syntax = '';
        ls_syntax = dw_list.Modify("DataWindow.summary.Height=90");
        ls_syntax = dw_list.Modify("DataWindow.header.Height=76");
        dw_list.Modify("create compute(band=detail alignment='2' expression='getrow()' border='0' color='33554432' x='0' y='0' height='72' width='150' format='[GENERAL]' html.valueishtml='0' name=xh  visible='1'  font.face='Arial' font.height='-9' font.weight='400'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='1073741824')");

        var ls_slx = dw_list.Describe("xh.x");
        var ls_slwidth = dw_list.Describe("xh.width");
        dw_list.Modify("create text(band=header alignment='2'  text='序号' border='0' color='33554432' x='" + ls_slx + "'  y='0' height='76' width='" + ls_slwidth + "' html.valueishtml='0'   name=xh_t visible='1'  font.face='Arial' font.height='-9' font.weight='400'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='1073741824')");

        var ls_slx = dw_list.Describe("km.x");
        var ls_slwidth = dw_list.Describe("km.width");
        ls_syntax = ls_syntax + "create text(band=summary alignment='1'  text='(" + dw_list.RowCount() + "行)合计:' border='0' color='128' x='" + ls_slx + "'  y='0' height='60' width='" + ls_slwidth + "' html.valueishtml='0'   name=t_1 visible='1'  font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='1073741824')"

        var ls_lszsrx = dw_list.Describe("sr.x");
        var ls_lszsrwidth = dw_list.Describe("sr.width")
        var ls_lszzcx = dw_list.Describe("zc.x");
        var ls_lszzcwidth = dw_list.Describe("zc.width")
        var ls_lszhjx = dw_list.Describe("hj.x");
        var ls_lszhjwidth = dw_list.Describe("hj.width")
        ls_syntax = ls_syntax + "create compute(band=summary alignment='1' expression='sum(sr  for all)' border='0' color='128' x='" + ls_lszsrx + "' y='8' height='52' width='" + ls_lszsrwidth
        + "' name=compute_2  visible='1' font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='1' background.color='536870912'  format='#########0.00')"
        ls_syntax = ls_syntax + "create compute(band=summary alignment='1' expression='sum(zc  for all)' border='0' color='128' x='" + ls_lszzcx + "' y='8' height='52' width='" + ls_lszzcwidth
        + "' name=compute_3  visible='1' font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='1' background.color='536870912'  format='#########0.00')"
        ls_syntax = ls_syntax + "create compute(band=summary alignment='1' expression='sum(hj  for all)' border='0' color='128' x='" + ls_lszhjx + "' y='8' height='52' width='" + ls_lszhjwidth
        + "' name=compute_4  visible='1' font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='1' background.color='536870912'  format='#########0.00')"
        dw_list.Modify(ls_syntax);
    }
    //#endregion

}