///<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_LYJS_ABL() {

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var cbx_kh = new CheckBox(requestor);
    var cbx_gs = new CheckBox(requestor);
    var cbx_bm = new CheckBox(requestor);
    var cbx_pzh = new CheckBox(requestor);
    var cbx_rq = new CheckBox(requestor);
    var ddlb_1 = new DropDownListBox(requestor);
    var cb_5 = new CommandButton(requestor);
    var sle_gys = new SingleLineEdit(requestor);
    var cb_4 = new CommandButton(requestor);
    var sle_jj = new SingleLineEdit(requestor);
    var cb_3 = new CommandButton(requestor);
    var sle_pp = new SingleLineEdit(requestor);
    var cb_2 = new CommandButton(requestor);
    var dp_2 = new DatePicker(requestor);
    var dp_1 = new DatePicker(requestor);
    var sle_spkh = new SingleLineEdit(requestor);
    var sle_pzh = new SingleLineEdit(requestor);
    var sle_dpfc = new SingleLineEdit(requestor);
    var sle_bmfc = new SingleLineEdit(requestor);
    var rb_l = new RadioButton(requestor);
    var rb_f = new RadioButton(requestor);
    var cb_1 = new CommandButton(requestor);
    var rb_j = new RadioButton(requestor);
    var sle_bm = new SingleLineEdit(requestor);
    var rb_y = new RadioButton(requestor);
    var cb_6 = new CommandButton(requestor);
    var sle_gs = new SingleLineEdit(requestor);
    var dw_list = new DataWindow(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 (cbx_kh == null) cbx_kh = new CheckBox(requestor);
        cbx_kh.Attach(win.Control("cbx_kh"));
        if (cbx_gs == null) cbx_gs = new CheckBox(requestor);
        cbx_gs.Attach(win.Control("cbx_gs"));
        if (cbx_bm == null) cbx_bm = new CheckBox(requestor);
        cbx_bm.Attach(win.Control("cbx_bm"));
        if (cbx_pzh == null) cbx_pzh = new CheckBox(requestor);
        cbx_pzh.Attach(win.Control("cbx_pzh"));
        if (cbx_rq == null) cbx_rq = new CheckBox(requestor);
        cbx_rq.Attach(win.Control("cbx_rq"));
        if (ddlb_1 == null) ddlb_1 = new DropDownListBox(requestor);
        ddlb_1.Attach(win.Control("ddlb_1"));
        if (cb_5 == null) cb_5 = new CommandButton(requestor);
        cb_5.Attach(win.Control("cb_5"));
        if (sle_gys == null) sle_gys = new SingleLineEdit(requestor);
        sle_gys.Attach(win.Control("sle_gys"));
        if (cb_4 == null) cb_4 = new CommandButton(requestor);
        cb_4.Attach(win.Control("cb_4"));
        if (sle_jj == null) sle_jj = new SingleLineEdit(requestor);
        sle_jj.Attach(win.Control("sle_jj"));
        if (cb_3 == null) cb_3 = new CommandButton(requestor);
        cb_3.Attach(win.Control("cb_3"));
        if (sle_pp == null) sle_pp = new SingleLineEdit(requestor);
        sle_pp.Attach(win.Control("sle_pp"));
        if (cb_2 == null) cb_2 = new CommandButton(requestor);
        cb_2.Attach(win.Control("cb_2"));
        if (dp_2 == null) dp_2 = new DatePicker(requestor);
        dp_2.Attach(win.Control("dp_2"));
        if (dp_1 == null) dp_1 = new DatePicker(requestor);
        dp_1.Attach(win.Control("dp_1"));
        if (sle_spkh == null) sle_spkh = new SingleLineEdit(requestor);
        sle_spkh.Attach(win.Control("sle_spkh"));
        if (sle_pzh == null) sle_pzh = new SingleLineEdit(requestor);
        sle_pzh.Attach(win.Control("sle_pzh"));
        if (sle_dpfc == null) sle_dpfc = new SingleLineEdit(requestor);
        sle_dpfc.Attach(win.Control("sle_dpfc"));
        if (sle_bmfc == null) sle_bmfc = new SingleLineEdit(requestor);
        sle_bmfc.Attach(win.Control("sle_bmfc"));
        if (rb_l == null) rb_l = new RadioButton(requestor);
        rb_l.Attach(win.Control("rb_l"));
        if (rb_f == null) rb_f = new RadioButton(requestor);
        rb_f.Attach(win.Control("rb_f"));
        if (cb_1 == null) cb_1 = new CommandButton(requestor);
        cb_1.Attach(win.Control("cb_1"));
        if (rb_j == null) rb_j = new RadioButton(requestor);
        rb_j.Attach(win.Control("rb_j"));
        if (sle_bm == null) sle_bm = new SingleLineEdit(requestor);
        sle_bm.Attach(win.Control("sle_bm"));
        if (rb_y == null) rb_y = new RadioButton(requestor);
        rb_y.Attach(win.Control("rb_y"));
        if (cb_6 == null) cb_6 = new CommandButton(requestor);
        cb_6.Attach(win.Control("cb_6"));
        if (sle_gs == null) sle_gs = new SingleLineEdit(requestor);
        sle_gs.Attach(win.Control("sle_gs"));
        if (dw_list == null) dw_list = new DataWindow(requestor);
        dw_list.Attach(win.Control("dw_list"));
        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.Gxgs) == "function")
            win.AttachEvent("cbx_gs", "Clicked", self.Gxgs);

        if (typeof (self.ChangeGongYingShang) == "function")
            win.AttachEvent("cb_5", "Clicked", self.ChangeGongYingShang);

        if (typeof (self.ChangeJiJie) == "function")
            win.AttachEvent("cb_4", "Clicked", self.ChangeJiJie);

        if (typeof (self.ChangePinPai) == "function")
            win.AttachEvent("cb_3", "Clicked", self.ChangePinPai);

        if (typeof (self.ChangeSpkh) == "function")
            win.AttachEvent("cb_2", "Clicked", self.ChangeSpkh);

        if (typeof (self.fcblDp) == "function")
            win.AttachEvent("sle_dpfc", "Modified", self.fcblDp);

        if (typeof (self.fcblBm) == "function")
            win.AttachEvent("sle_bmfc", "Modified", self.fcblBm);

        if (typeof (self.khchanges) == "function")
            win.AttachEvent("cb_1", "Clicked", self.khchanges);

        if (typeof (self.khchangesGS) == "function")
            win.AttachEvent("cb_6", "Clicked", self.khchangesGS);

        if (typeof (self.DoubleClicked) == "function")
            win.AttachEvent("dw_list", "DoubleClicked", self.DoubleClicked);

        if (typeof (self.Qyery) == "function")
            win.AttachEvent("btn_1", "Clicked", self.Qyery);

        if (typeof (self.Exit) == "function")
            win.AttachEvent("btn_4", "Clicked", self.Exit);

    }

    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();

        cbx_kh.Detach(); cbx_kh = null;
        cbx_gs.Detach(); cbx_gs = null;
        cbx_bm.Detach(); cbx_bm = null;
        cbx_pzh.Detach(); cbx_pzh = null;
        cbx_rq.Detach(); cbx_rq = null;
        ddlb_1.Detach(); ddlb_1 = null;
        cb_5.Detach(); cb_5 = null;
        sle_gys.Detach(); sle_gys = null;
        cb_4.Detach(); cb_4 = null;
        sle_jj.Detach(); sle_jj = null;
        cb_3.Detach(); cb_3 = null;
        sle_pp.Detach(); sle_pp = null;
        cb_2.Detach(); cb_2 = null;
        dp_2.Detach(); dp_2 = null;
        dp_1.Detach(); dp_1 = null;
        sle_spkh.Detach(); sle_spkh = null;
        sle_pzh.Detach(); sle_pzh = null;
        sle_dpfc.Detach(); sle_dpfc = null;
        sle_bmfc.Detach(); sle_bmfc = null;
        rb_l.Detach(); rb_l = null;
        rb_f.Detach(); rb_f = null;
        cb_1.Detach(); cb_1 = null;
        rb_j.Detach(); rb_j = null;
        sle_bm.Detach(); sle_bm = null;
        rb_y.Detach(); rb_y = null;
        cb_6.Detach(); cb_6 = null;
        sle_gs.Detach(); sle_gs = null;
        dw_list.Detach(); dw_list = null;
        tb_1.Detach(); tb_1 = null;
        requestor.Detach(); requestor = null;

        setTimeout(CollectGarbage, 100);
    }

    //以上代码由设计器自动生成,请不要手工修改
    //ExtPB.Net JavaScript End  设计器查找标志,请不要删除或修改
    webReq = new WebRequestor();
    webReq.SetWebServiceUrl("/Service/ServiceForDwSyndax.ashx");
    var curW_OPEN_BMDA_NEW = new OpenWindowQueryNewBase();
    var curW_OPEN_BMDA_URL = "OpenWindowQueryNewBase";
    var curW_OPEN_SIMPLE_CHOSE = new OpenWindowSimpleChoseBase();

    this.PostOpen = function () {

     
    }
    this.Qyery = function () {
        self.fcblBm();
        var beginTime = UtcDateFormatToString(dp_1.GetValue());
        var endTime = UtcDateFormatToString(dp_2.GetValue());
        var curBmzb = sle_bmfc.GetText();
        var curDpzb = sle_dpfc.GetText();
        var orderSql = "";
        var groupSql = "";
        var SqlWhere = "  AND CONVERT(DATE,rq,120) BETWEEN '" + beginTime + "' AND '" + endTime + "' ";
        var gsbh = sle_gs.GetText();
        var khbh = sle_bm.GetText();
        var pzh = sle_pzh.GetText();
        var spkh = sle_spkh.GetText();
        var pp = sle_pp.GetText();
        var jj = sle_jj.GetText();
        var nf = ddlb_1.GetText();
        var gys = sle_gys.GetText();
        var curYjfl = 2 //默认是精确到  分 
        if (rb_y.GetChecked()) {
            curYjfl = 0; //元
        } else if (rb_j.GetChecked()) {
            curYjfl = 1; //角
        } else if (rb_f.GetChecked()) {
            curYjfl = 2; //分
        } else if (rb_l.GetChecked()) {
            curYjfl = 3; //厘
        }

        if (khbh != "") {
            SqlWhere += " and mx.bmbh in(" + khbh + ")";
        }
        if (pzh != "") {
            SqlWhere += " and mx.jyh like '%" + pzh + "%'";
        }
        if (spkh != "") {
            SqlWhere += " and da.spkh in(" + spkh + ")";
        }
        if (pp != "") {
            SqlWhere += " and da.jypp in(" + pp + ")";
        }
        if (jj != "") {
            SqlWhere += " and da.spjj in(" + jj + ")";
        }
        if (nf != "") {
            SqlWhere += " and da.spnf ='" + nf + "'";
        }
        if (gys != "") {
            SqlWhere += " and da.gysbh in(" + gys + ")";
        }

        dw_list.SetRedraw(false);
        var sql = "";
        if (cbx_gs.GetChecked()) {
            sql = " DECLARE @C_BMMC VARCHAR(30) ; ";

            sql += "SELECT   @C_BMMC = BMMC FROM DA_BMDA WHERE BMBH=" + gsbh;
        }

        sql += "SELECT  ";

        if (cbx_gs.GetChecked()) {
            sql += "" + gsbh + " gsbh,@C_BMMC gsmc,";
            //                    orderSql += " MX.bmbh DESC,"
            //                    if (groupSql.length > 0) {
            //                        groupSql += ","
            //                    }
            //                    groupSql += "MX.bmbh ,BM.bmmc "

        }


        if (cbx_bm.GetChecked()) {
            sql += " MX.bmbh bmbh,BM.bmmc bmmc,";
            orderSql += " MX.bmbh DESC,"
            if (groupSql.length > 0) {
                groupSql += ","
            }
            groupSql += "MX.bmbh ,BM.bmmc "

        }

        if (cbx_rq.GetChecked()) {
            sql += " CONVERT(DATE, rq, 120) RQ ,";
            orderSql += " CONVERT(DATE, rq, 120) DESC,"
            if (groupSql.length > 0) {
                groupSql += ","
            }
            groupSql += " CONVERT(DATE, rq, 120)";
        }
        if (cbx_pzh.GetChecked()) {
            sql += " jyh ,";
            orderSql += " jyh DESC,"
            if (groupSql.length > 0) {
                groupSql += ","
            }
            groupSql += "jyh "
        }

        if (cbx_kh.GetChecked()) {
            sql += " MX.spkh spkh,DA.ksmc ksmc,jldw,";
            orderSql += " MX.spkh DESC,"
            if (groupSql.length > 0) {
                groupSql += ","
            }
            groupSql += "MX.spkh ,DA.ksmc ,jldw"
        }
        if (orderSql != "") {
            orderSql = orderSql.substring(0, orderSql.length - 1);
        }
        sql += "  SUM(sl) SL , ";
        sql += "  MAX(lsj) LSJ , ";
        sql += "  SUM(lsj*sl) LSJE , ";
        sql += "  SUM(MX.LSJE) XSZE , ";
        sql += "  " + curBmzb + "  bmfczb,";
        sql += "  ROUND(CONVERT(DECIMAL(30,2),SUM(MX.LSJE)*" + curBmzb + ")," + curYjfl + ")  bmfc,";
        sql += "  " + curDpzb + "  dpfczb,";
        sql += "  (CONVERT(DECIMAL(30,2),SUM(MX.LSJE)))-(ROUND(CONVERT(DECIMAL(30,2),SUM(MX.LSJE)*" + curBmzb + ")," + curYjfl + "))  dpfc";
        sql += "  FROM  YW_POS_TZ MX ,dbo.da_sp_spda DA ,dbo.da_bmda BM  ";
        sql += "  WHERE MX.spkh = DA.spkh AND MX.bmbh = BM.bmbh   " + SqlWhere;
        if (groupSql != "") {
            sql += "  GROUP BY " + groupSql;
        }

        if (orderSql != "") {
            sql += " ORDER BY  " + orderSql;
        }

        // requestor.ClipBoardNao(sql)
        webReq.Invoke("GetSnataxAndDataFromSql", "sql=" + sql);
        if (webReq.StatusCode() == 200) {

            dw_list.SetFullState(webReq.ResponseText());
            var colCount = dw_list.Describe("DataWindow.Column.Count");

            self.Set_Width_DW(colCount);
            self.SetSummary();
            A8erp_Report.ReportDataWindowHeaderColor(dw_list);
            dw_list.SetRedraw(true);
            dw_list.SetRowSelection(1);
        } else {

            alert("error!");
        }

        if (cbx_gs.GetChecked()) {
            dw_list.Modify("gsbh.tabsequence='0' ");
            dw_list.Modify("gsmc.tabsequence='0' ");

            dw_list.Modify("bmbh.tabsequence='0' ");
            dw_list.Modify("bmmc.tabsequence='0' ");


            dw_list.Modify("rq.tabsequence='0' ");
            dw_list.Modify("jyh.tabsequence='0' ");
            dw_list.Modify("spkh.tabsequence='0' ");
            dw_list.Modify("ksmc.tabsequence='0' ");
            dw_list.Modify("jldw.tabsequence='0' ");
            dw_list.Modify("sl.tabsequence='0' ");
            dw_list.Modify("lsj.tabsequence='0' ");
            dw_list.Modify("lsje.tabsequence='0' ");
            dw_list.Modify("xsze.tabsequence='0' ");
            dw_list.Modify("bmfczb.tabsequence='0' ");
            dw_list.Modify("bmfc.tabsequence='0' ");
            dw_list.Modify("dpfczb.tabsequence='0' ");
            dw_list.Modify("dpfc.tabsequence='0' ");
    

        }
      //  requestor.ClipBoardNao(dw_list.Describe("datawindow.syntax"));

    }

    this.Set_Width_DW = function (colCount) {
        dw_list.Modify("DataWindow.header.Height=90");
        dw_list.Modify("DataWindow.detail.Height=90");

        var ls_columntitle = "";
        for (var li_loop1 = 1; li_loop1 <= colCount; li_loop1++) {

            var ls_columnname = dw_list.Describe('#' + String(li_loop1) + '.name');

            //alert("ls_columnname" + ls_columnname)
            switch (ls_columnname) {
                case "gsbh":
                    ls_columntitle = "公司编号"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '" + 0 + "'");
                    break;
                case "gsmc":
                    ls_columntitle = "公司名称"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '" + 0 + "'");
                    break;
                case "pzh":

                    ls_columntitle = "凭证号"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 800 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '" + 2 + "'");
                    break;
                case "bmfczb":
                    ls_columntitle = "公司占比"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '" + 2 + "' ");
                    dw_list.Modify(ls_columnname + "_t.color='128'");
                    break;
                case "dpfczb":
                    ls_columntitle = "店铺占比"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '" + 2 + "' '");
                    dw_list.Modify(ls_columnname + "_t.color='128'");
                    break;

                case "bmfc":
                    ls_columntitle = "公司分成金额"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '" + 1 + "'");
                    dw_list.Modify(ls_columnname + "_t.color='128'");
                    dw_list.Modify(ls_columnname + ".format='###########0.000' ")
                    break;
                case "dpfc":
                    ls_columntitle = "店铺分成金额"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '" + 1 + "'");
                    dw_list.Modify(ls_columnname + "_t.color='128'");
                    dw_list.Modify(ls_columnname + ".format='###########0.000' ")
                    break;

                case "jyh":
                    ls_columntitle = "凭证号"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 700 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '" + 2 + "'");

                    break;
                case "rq":
                    ls_columntitle = "日期"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 350 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '" + 2 + "'");
                    break;

                case "bmbh":
                    ls_columntitle = "店铺编号"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");

                    break;
                case "yw_pos_tz_bmbh":
                    ls_columntitle = "店铺编号"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");

                    break;
                case "jldw":
                    ls_columntitle = "单位"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 150 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '" + 2 + "'");
                    break;

                case "bmmc":
                    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 "yw_pos_tz_spkh":
                    ls_columntitle = "商品款式";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");

                    break;
                case "da_sp_spda_ksmc":
                    ls_columntitle = "款式名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");

                    break;

                case "spkh":
                    ls_columntitle = "商品款式";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");

                    break;
                case "ksmc":
                    ls_columntitle = "款式名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");

                    break;

                case "sl":
                    ls_columntitle = "数量";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".edit.name='#####' " + ls_columnname + ".editmask.mask='###########0' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    dw_list.Modify(ls_columnname + ".format='###########0' ")

                    break;
                case "lsj":
                    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 = '" + 400 + "'");
                    break;
                case "lsje":
                    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 = '" + 400 + "'");
                    break;
                case "danjia":
                    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 = '" + 400 + "'");
                    break;
                case "jsze":
                    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 = '" + 400 + "'");
                    break;
                case "xsze":
                    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 = '" + 400 + "'");
                    break;
             
            }

        }
        dw_list.Modify("create compute(band=detail alignment='2' expression='getrow()'border='0' color='33554432' x='0' y='4' height='76' width='183' format='[GENERAL]' html.valueishtml='0'  name=xh visible='1'  font.face='Tahoma' font.height='-9' font.weight='400'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='1073741824' background.transparency='0' background.gradient.color='8421504' background.gradient.transparency='0' background.gradient.angle='0' background.brushmode='0' background.gradient.repetition.mode='0' background.gradient.repetition.count='0' background.gradient.repetition.length='100' background.gradient.focus='0' background.gradient.scale='100' background.gradient.spread='100' tooltip.backcolor='134217752' tooltip.delay.initial='0' tooltip.delay.visible='32000' tooltip.enabled='0' tooltip.hasclosebutton='0' tooltip.icon='0' tooltip.isbubble='0' tooltip.maxwidth='0' tooltip.textcolor='134217751' tooltip.transparency='0' transparency='0' )")
        dw_list.Modify("create text(band=header alignment='2' text='序号' border='0' color='33554432' x='0' y='0' height='56' width='183' html.valueishtml='0'  name=xh_t visible='1'  font.face='Tahoma' font.height='-9' font.weight='400'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='536870912' background.transparency='0' background.gradient.color='8421504' background.gradient.transparency='0' background.gradient.angle='0' background.brushmode='0' background.gradient.repetition.mode='0' background.gradient.repetition.count='0' background.gradient.repetition.length='100' background.gradient.focus='0' background.gradient.scale='100' background.gradient.spread='100' tooltip.backcolor='134217752' tooltip.delay.initial='0' tooltip.delay.visible='32000' tooltip.enabled='0' tooltip.hasclosebutton='0' tooltip.icon='0' tooltip.isbubble='0' tooltip.maxwidth='0' tooltip.textcolor='134217751' tooltip.transparency='0' transparency='0' )");
    }

    //#region 合计列
    this.SetSummary = function () {

        var ls_slx = dw_list.Describe("sl.x")
        var ls_slwidth = dw_list.Describe("sl.width")

        var ls_lsjex = dw_list.Describe("lsje.x")
        var ls_lsjewidth = dw_list.Describe("lsje.width")


//        var ls_jsjelx = dw_list.Describe("jsze.x")
//        var ls_jsjewidth = dw_list.Describe("jsze.width")

//        var ls_cbjex = dw_list.Describe("cbje.x")
//        var ls_cbjewidth = dw_list.Describe("cbje.width")

//        var ls_mlx = dw_list.Describe("ml.x")
//        var ls_mlwidth = dw_list.Describe("ml.width")

        var ls_bmfcx = dw_list.Describe("bmfc.x")
        var ls_bmfcwidth = dw_list.Describe("bmfc.width")

        var ls_dpfcx = dw_list.Describe("dpfc.x")
        var ls_dpfcwidth = dw_list.Describe("dpfc.width")

        var ls_xszex = dw_list.Describe("xsze.x")
        var ls_xszewidth = dw_list.Describe("xsze.width")


        ls_syntax = dw_list.Modify("DataWindow.summary.Height=90");

        ls_syntax = ls_syntax + " create compute(band=summary alignment='1' expression='sum(sl  for all)' border='0' color='128' x='" + ls_slx + "' y='8' height='52' width='" + ls_slwidth + "' name=dj_sum  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')"

        ls_syntax = ls_syntax + " create compute(band=summary alignment='1' expression='sum(lsje  for all)' border='0' color='128' x='" + ls_lsjex + "' y='8' height='52' width='" + ls_lsjewidth + "' name=dj_sum  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(jsze  for all)' border='0' color='128' x='" + ls_jsjelx + "' y='8' height='52' width='" + ls_lsjewidth + "' name=dj_sum  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(cbje  for all)' border='0' color='128' x='" + ls_cbjex + "' y='8' height='52' width='" + ls_cbjewidth + "' name=dj_sum  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(ml  for all)' border='0' color='128' x='" + ls_mlx + "' y='8' height='52' width='" + ls_mlwidth + "' name=dj_sum  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(xsze  for all)' border='0' color='128' x='" + ls_xszex + "' y='8' height='52' width='" + ls_xszewidth + "' name=bmfc_sum  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(bmfc  for all)' border='0' color='128' x='" + ls_bmfcx + "' y='8' height='52' width='" + ls_bmfcwidth + "' name=bmfc_sum  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.000')"
        ls_syntax = ls_syntax + " create compute(band=summary alignment='1' expression='sum(dpfc  for all)' border='0' color='128' x='" + ls_dpfcx + "' y='8' height='52' width='" + ls_dpfcwidth + "' name=bmfc_sum  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.000')"

        dw_list.Modify(ls_syntax);

    }
    //#endregion
    var dwoName = "";
    this.khchanges = function (x, y, row, dwoName) {
        dwoName = "bmbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_LYJS_ABL, "bmbh", "bmmc", "N", 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);
    }  
    this.khchangesGS = function (x, y, row, dwoName) {
        dwoName = "gsbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_LYJS_ABL, "bmbh", "bmmc", "N", self, dwoName)  // 这个用来给子窗口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);
    }
    this.ChangeSpkh = function (x, y, row, dwoName) {
        dwoName = "spkh";

        curW_OPEN_BMDA_NEW.SetDataWindow(W_LYJS_ABL, "spkh", "ksmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base." + curW_OPEN_BMDA_URL + "&treeDw=dw_da_sp_lbda_tree&listDw=dw_da_sp_spda_1&treeRootLabel=商品分类&treeData=lbbh&treeLabel=lbmc&treeParentData=flbbh&treeLeave=islast&selectStyle=multiple&curQxlx=all"), curW_OPEN_BMDA_NEW, null);

    }
    this.ChangePinPai = function (x, y, row, dwoName) {
        dwoName = "ppbm";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_LYJS_ABL, "ppbm", "ppmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_sp_sppp_by_yhbh&selectStyle=multiple&flag=ywcx"), curW_OPEN_SIMPLE_CHOSE, null);
    }
    this.ChangeJiJie = function (x, y, row, dwoName) {
        dwoName = "jjbm";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_LYJS_ABL, "jjbm", "jjmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_da_sp_jjda_list&selectStyle=multiple"), curW_OPEN_SIMPLE_CHOSE, null);
    }
    this.ChangeGongYingShang = function (x, y, row, dwoName) {
        dwoName = "gysbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_LYJS_ABL, "gysbh", "gysmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base." + curW_OPEN_BMDA_URL + "&treeDw=dw_da_gysda_fl_tree&listDw=dw_pub_list_gysda&treeRootLabel=供应商分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple"), curW_OPEN_BMDA_NEW, null);
    }
    this.SetSleValue = function (difBh, val) {

        if ("''" == val)
            val = "";
        else if ("bmbh" == difBh)
            sle_bm.SetText(val);
        else if ("gysbh" == difBh)
            sle_gys.SetText(val);
        else if ("ppbm" == difBh)
            sle_pp.SetText(val);
        else if ("jjbm" == difBh)
            sle_jj.SetText(val);
        else if ("spkh" == difBh)
            sle_spkh.SetText(val);
        else if ("gsbh" == difBh)
            sle_gs.SetText(val);

    }
    this.Exit = function () {
        setTimeout("window.close();", 100);
    }


    //#region 分成设置


    this.fcblBm = function () {

        var txt = sle_bmfc.GetText();
        if (isNaN(txt)) {
            alert("请输入数字。");
            sle_bmfc.SetText("0.0");
        } else {
            if (new Number(txt) > 1) {
                alert("请输入小于1的数字");
                sle_bmfc.SetText("0.0");
            } else {
                sle_dpfc.SetText(1 - new Number(txt));
            }
        }
        
    }
    this.fcblDp = function (txt) {
        if (isNaN(txt)) {
            alert("请输入数字。")
            sle_dpfc.SetText("0.0");
        } else {
            if (new Number(txt) > 1) {
                alert("请输入小于1的数字");
                sle_dpfc.SetText("0.0");
            } else {
                sle_bmfc.SetText(1 - new Number(txt));            
            }
        }


    }
    //#endregion

    this.Gxgs = function (b) {

        if (b) {
            if (sle_gs.GetText().length < 1) {
                alert("勾选公司前，先设置公司查询条件。");
                cbx_gs.SetChecked(false);
            }
        }

    }

    var lastSortName = "";
    this.DoubleClicked = function (x, y, row, dwcName) {

        if (dwcName.indexOf("_t") > -1) {
            var curColName = dwcName.split("_")[0];

            if (curColName == lastSortName) {
                dw_list.SetSort(curColName + " A");
                lastSortName = "";
                dw_list.Sort();
            } else {
                dw_list.SetSort(curColName + " D");
                lastSortName = dwcName.split("_")[0];
                dw_list.Sort();
            }
        }
    }
     

}