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

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var cb_3 = new CommandButton(requestor);
    var sle_gys = new SingleLineEdit(requestor);
    var cbx_pftdh = new CheckBox(requestor);
    var cbx_pfcdh = new CheckBox(requestor);
    var cbx_bx = new CheckBox(requestor);
    var cbx_bzxx = new CheckBox(requestor);
    var cbx_dckh = new CheckBox(requestor);
    var cbx_rq = new CheckBox(requestor);
    var cbx_pzh = new CheckBox(requestor);
    var cbx_ys = new CheckBox(requestor);
    var cbx_kh = new CheckBox(requestor);
    var cbx_zzc = new CheckBox(requestor);
    var cbx_drkh = new CheckBox(requestor);
    var sle_pftpzh = new SingleLineEdit(requestor);
    var sle_pfcpzh = new SingleLineEdit(requestor);
    var sle_pzh = new SingleLineEdit(requestor);
    var sle_pfkh = new SingleLineEdit(requestor);
    var sle_jj = new SingleLineEdit(requestor);
    var sle_lb = new SingleLineEdit(requestor);
    var sle_kh = new SingleLineEdit(requestor);
    var sle_pp = new SingleLineEdit(requestor);
    var sle_zzck = new SingleLineEdit(requestor);
    var sle_bm = new SingleLineEdit(requestor);
    var dp_2 = new DatePicker(requestor);
    var dp_1 = new DatePicker(requestor);
    var sle_nf = new SingleLineEdit(requestor);
    var dw_list = new DataWindow(requestor);
    var ss_1 = new ToolStrip(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 (cb_3 == null) cb_3 = new CommandButton(requestor);
        cb_3.Attach(win.Control("cb_3"));
        if (sle_gys == null) sle_gys = new SingleLineEdit(requestor);
        sle_gys.Attach(win.Control("sle_gys"));
        if (cbx_pftdh == null) cbx_pftdh = new CheckBox(requestor);
        cbx_pftdh.Attach(win.Control("cbx_pftdh"));
        if (cbx_pfcdh == null) cbx_pfcdh = new CheckBox(requestor);
        cbx_pfcdh.Attach(win.Control("cbx_pfcdh"));
        if (cbx_bx == null) cbx_bx = new CheckBox(requestor);
        cbx_bx.Attach(win.Control("cbx_bx"));
        if (cbx_bzxx == null) cbx_bzxx = new CheckBox(requestor);
        cbx_bzxx.Attach(win.Control("cbx_bzxx"));
        if (cbx_dckh == null) cbx_dckh = new CheckBox(requestor);
        cbx_dckh.Attach(win.Control("cbx_dckh"));
        if (cbx_rq == null) cbx_rq = new CheckBox(requestor);
        cbx_rq.Attach(win.Control("cbx_rq"));
        if (cbx_pzh == null) cbx_pzh = new CheckBox(requestor);
        cbx_pzh.Attach(win.Control("cbx_pzh"));
        if (cbx_ys == null) cbx_ys = new CheckBox(requestor);
        cbx_ys.Attach(win.Control("cbx_ys"));
        if (cbx_kh == null) cbx_kh = new CheckBox(requestor);
        cbx_kh.Attach(win.Control("cbx_kh"));
        if (cbx_zzc == null) cbx_zzc = new CheckBox(requestor);
        cbx_zzc.Attach(win.Control("cbx_zzc"));
        if (cbx_drkh == null) cbx_drkh = new CheckBox(requestor);
        cbx_drkh.Attach(win.Control("cbx_drkh"));
        if (sle_pftpzh == null) sle_pftpzh = new SingleLineEdit(requestor);
        sle_pftpzh.Attach(win.Control("sle_pftpzh"));
        if (sle_pfcpzh == null) sle_pfcpzh = new SingleLineEdit(requestor);
        sle_pfcpzh.Attach(win.Control("sle_pfcpzh"));
        if (sle_pzh == null) sle_pzh = new SingleLineEdit(requestor);
        sle_pzh.Attach(win.Control("sle_pzh"));
        if (sle_pfkh == null) sle_pfkh = new SingleLineEdit(requestor);
        sle_pfkh.Attach(win.Control("sle_pfkh"));
        if (sle_jj == null) sle_jj = new SingleLineEdit(requestor);
        sle_jj.Attach(win.Control("sle_jj"));
        if (sle_lb == null) sle_lb = new SingleLineEdit(requestor);
        sle_lb.Attach(win.Control("sle_lb"));
        if (sle_kh == null) sle_kh = new SingleLineEdit(requestor);
        sle_kh.Attach(win.Control("sle_kh"));
        if (sle_pp == null) sle_pp = new SingleLineEdit(requestor);
        sle_pp.Attach(win.Control("sle_pp"));
        if (sle_zzck == null) sle_zzck = new SingleLineEdit(requestor);
        sle_zzck.Attach(win.Control("sle_zzck"));
        if (sle_bm == null) sle_bm = new SingleLineEdit(requestor);
        sle_bm.Attach(win.Control("sle_bm"));
        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_nf == null) sle_nf = new SingleLineEdit(requestor);
        sle_nf.Attach(win.Control("sle_nf"));
        if (dw_list == null) dw_list = new DataWindow(requestor);
        dw_list.Attach(win.Control("dw_list"));
        if (ss_1 == null) ss_1 = new ToolStrip(requestor);
        ss_1.Attach(win.Control("ss_1"));
        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.Changegys) == "function")
            win.AttachEvent("cb_3", "Clicked", self.Changegys);

        if (typeof (self.DagouPzh) == "function")
            win.AttachEvent("cbx_pftdh", "Clicked", self.DagouPzh);

        if (typeof (self.DagouPzh) == "function")
            win.AttachEvent("cbx_pfcdh", "Clicked", self.DagouPzh);

        if (typeof (self.DagouPzh) == "function")
            win.AttachEvent("cbx_bzxx", "Clicked", self.DagouPzh);

        if (typeof (self.dgPzh) == "function")
            win.AttachEvent("cbx_pzh", "Clicked", self.dgPzh);

        if (typeof (self.CheckedNF) == "function")
            win.AttachEvent("cb_checknf", "Clicked", self.CheckedNF);

        if (typeof (self.Changepfkh) == "function")
            win.AttachEvent("cb_9", "Clicked", self.Changepfkh);

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

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

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

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

        if (typeof (self.ChangebmbhZZC) == "function")
            win.AttachEvent("cb_8", "Clicked", self.ChangebmbhZZC);

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

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

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

        if (typeof (self.Export) == "function")
            win.AttachEvent("btn_2", "Clicked", self.Export);

        if (typeof (self.Print) == "function")
            win.AttachEvent("btn_3", "Clicked", self.Print);

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

        cb_3.Detach(); cb_3 = null;
        sle_gys.Detach(); sle_gys = null;
        cbx_pftdh.Detach(); cbx_pftdh = null;
        cbx_pfcdh.Detach(); cbx_pfcdh = null;
        cbx_bx.Detach(); cbx_bx = null;
        cbx_bzxx.Detach(); cbx_bzxx = null;
        cbx_dckh.Detach(); cbx_dckh = null;
        cbx_rq.Detach(); cbx_rq = null;
        cbx_pzh.Detach(); cbx_pzh = null;
        cbx_ys.Detach(); cbx_ys = null;
        cbx_kh.Detach(); cbx_kh = null;
        cbx_zzc.Detach(); cbx_zzc = null;
        cbx_drkh.Detach(); cbx_drkh = null;
        sle_pftpzh.Detach(); sle_pftpzh = null;
        sle_pfcpzh.Detach(); sle_pfcpzh = null;
        sle_pzh.Detach(); sle_pzh = null;
        sle_pfkh.Detach(); sle_pfkh = null;
        sle_jj.Detach(); sle_jj = null;
        sle_lb.Detach(); sle_lb = null;
        sle_kh.Detach(); sle_kh = null;
        sle_pp.Detach(); sle_pp = null;
        sle_zzck.Detach(); sle_zzck = null;
        sle_bm.Detach(); sle_bm = null;
        dp_2.Detach(); dp_2 = null;
        dp_1.Detach(); dp_1 = null;
        sle_nf.Detach(); sle_nf = null;
        dw_list.Detach(); dw_list = null;
        ss_1.Detach(); ss_1 = 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 OpenWindowQueryBase();

    var curW_OPEN_BMDA_NEW = new OpenWindowQueryNewBase();
    var curW_OPEN_BMDA_URL = "OpenWindowQueryNewBase";


    var curW_OPEN_SIMPLE_CHOSE = new OpenWindowSimpleChoseBase();
    var curW_Base_Report_Open_Mx = new W_Base_Report_Open_Mx();
    var curW_NFCheck = new W_NFCheck();
    var curcm = "";

    //#region 初始化
    this.PostOpen = function () {
        curcm = requestor.GetParm("curcm");

        sle_bm.SetEnabled(false); 
        sle_zzck.SetEnabled(false);
        sle_lb.SetEnabled(false);
        sle_nf.SetEnabled(false);
        sle_kh.SetEnabled(false);
        sle_pp.SetEnabled(false); sle_pfkh.SetEnabled(false); sle_jj.SetEnabled(false); sle_gys.SetEnabled(false); sle_pp.SetEnabled(false);
    }
 
    //#endregion

    this.Query = function () {
        requestor.ShowLoading("正在查询中......");
        var beginTime = UtcDateFormatToString(dp_1.GetValue());
        var endTime = UtcDateFormatToString(dp_2.GetValue());
        var curDckh = sle_bm.GetText();
        var curDrkh = sle_pfkh.GetText();
        var curZzck = sle_zzck.GetText();
        var curLb = sle_lb.GetText();

        var curSpkh = sle_kh.GetText();
        var curPp = sle_pp.GetText();
        var curJj = sle_jj.GetText();
        var curGys = sle_gys.GetText();
        var curNf = sle_nf.GetText();

        var curPzh = sle_pzh.GetText();
        var curPfcpzh = sle_pfcpzh.GetText();
        var curPftpzh = sle_pftpzh.GetText();

        var curSelectStr = new Array();
        var curGroupStr = new Array();
        if (cbx_pzh.GetChecked()) {
            curSelectStr.push("PZH");
            curGroupStr.push("PZH");
        }
        if (cbx_rq.GetChecked()) {
            curSelectStr.push("KDRQ");
            curGroupStr.push("KDRQ");
        }

        if (cbx_dckh.GetChecked()) {
            curSelectStr.push("DCKH,DCKHMC");
            curGroupStr.push("DCKH,DCKHMC");
        }
        if (cbx_drkh.GetChecked()) {
            curSelectStr.push("DRKH,DRKHMC");
            curGroupStr.push("DRKH,DRKHMC");
        }
        if (cbx_zzc.GetChecked()) {
            curSelectStr.push("ZZCK,ZZCKMC");
            curGroupStr.push("ZZCK,ZZCKMC");
        }
        if (cbx_kh.GetChecked()) {
            curSelectStr.push("SPKH,KSMC");
            curGroupStr.push("SPKH,KSMC");
        }
        if (cbx_ys.GetChecked()) {
            curSelectStr.push("YSBH,YSMC");
            curGroupStr.push("YSBH,YSMC");
        }
        if (cbx_bx.GetChecked()) {
            curSelectStr.push("BXBH,BXMC");
            curGroupStr.push("BXBH,BXMC");
        }


        curSelectStr.push("SUM(CM1) CM1,SUM(CM2) CM2,SUM(CM3) CM3,SUM(CM4) CM4,SUM(CM5) CM5,SUM(CM6) CM6,SUM(CM7) CM7,SUM(CM8) CM8,SUM(CM9) CM9,SUM(CM10) CM10,SUM(CM11) CM11,SUM(CM12) CM12,SUM(CM13) CM13,SUM(CM14) CM14,SUM(CM15) CM15,SUM(CM16) CM16,SUM(CM17) CM17,SUM(CM18) CM18,SUM(CM19) CM19,SUM(CM20) CM20,SUM(CM21) CM21,SUM(CM22) CM22,SUM(CM23) CM23,SUM(CM24) CM24,SUM(CM25) CM25,SUM(CM26) CM26,SUM(CM27) CM27,SUM(CM28) CM28,SUM(CM29) CM29,SUM(CM30) CM30,SUM(CM31) CM31,SUM(CM32) CM32,SUM(CM33) CM33,SUM(CM34) CM34,SUM(CM35) CM35,SUM(SL)SL,MAX(THJ)THJ,AVG(THZK)THZK,SUM(THJE)THJE,MAX(XSJ)XSJ,AVG(XSZK)XSZK,SUM(XSJE) XSJE,MAX(LSJ)LSJ,SUM(LSJJE) LSJJE,MAX(DPJ)DPJ,SUM(DPJJE) DPJJE");
        if (cbx_pzh.GetChecked()) {
            curSelectStr.push("JZR,JZRMC,MAX(JZSJ)JZSJ,PFDH,PTDH,BZXX");
            curGroupStr.push("JZR,JZRMC,PFDH,PTDH,BZXX");
        }

        if (!cbx_pzh.GetChecked() && !cbx_rq.GetChecked() && !cbx_dckh.GetChecked() && !cbx_drkh.GetChecked() && !cbx_zzc.GetChecked() && !cbx_kh.GetChecked() && !cbx_ys.GetChecked() && !cbx_bx.GetChecked()) {
            alert("请至少勾选一个维度查询。");
            return
        }

        dw_list.SetRedraw(false);
        var sql = " SELECT  ";
        // sql += " SELECT PZH,KDRQ,DCKH,DCKHMC,DRKH,DRKHMC,ZZCK,ZZCKMC,SPKH,KSMC,YSBH,YSMC,BXBH,BXMC,SUM(SL)SL,MAX(THJ)THJ,SUM(THJE)THJE,MAX(XSJ)XSJ,SUM(XSJE) XSJE,PFDH,PTDH,CRDH,CTDH,BZXX";
        sql += curSelectStr.join(",").toString();
        sql += " FROM(";
        sql += "       SELECT hz.pzh,CONVERT(DATE,hz.kdrq,120) kdrq,dckh,dcda.khmc dckhmc,drkh,drda.khmc drkhmc,zzck,zzda.bmmc zzckmc,mx.spkh,mx.ksmc,mx.ysbh,mx.ysmc,mx.bxbh,mx.bxmc,";
        sql += "       ISNULL(CM1, 0) CM1, ISNULL(CM2, 0) CM2, ISNULL(CM3, 0) CM3, ISNULL(CM4, 0) CM4, ISNULL(CM5, 0) CM5, ISNULL(CM6, 0) CM6, ISNULL(CM7, 0) CM7, ISNULL(CM8, 0) CM8, ISNULL(CM9, 0) CM9, ISNULL(CM10, 0) CM10, ISNULL(CM11, 0) CM11, ISNULL(CM12, 0) CM12, ISNULL(CM13, 0) CM13, ISNULL(CM14, 0) CM14, ISNULL(CM15, 0)  CM15, ISNULL(CM16, 0) CM16, ISNULL(CM17, 0) CM17, ISNULL(CM18, 0) CM18, ISNULL(CM19, 0) CM19, ISNULL(CM20, 0) CM20, ISNULL(CM21, 0) CM21, ISNULL(CM22, 0) CM22, ISNULL(CM23, 0) CM23, ISNULL(CM24, 0) CM24, ISNULL(CM25, 0) CM25, ISNULL(CM26, 0) CM26, ISNULL(CM27, 0)  CM27, ISNULL(CM28, 0) CM28, ISNULL(CM29, 0) CM29, ISNULL(CM30, 0)  CM30, ISNULL(CM31, 0) CM31, ISNULL(CM32, 0) CM32, ISNULL(CM33, 0)CM33, ISNULL(CM34, 0) CM34, ISNULL(CM35, 0) CM35,";
        sql += "       ISNULL(cm1 ,0)+isnull(cm2 ,0)+isnull(cm3 ,0)+isnull(cm4 ,0)+isnull(cm5 ,0)+isnull(cm6 ,0)+isnull(cm7 ,0)+isnull(cm8 ,0)+isnull(cm9 ,0)+isnull(cm10 ,0)+isnull(cm11 ,0)+isnull(cm12 ,0)+isnull(cm13 ,0)+isnull(cm14 ,0)+isnull(cm15 ,0)+isnull(cm16 ,0)+isnull(cm17 ,0)+isnull(cm18 ,0)+isnull(cm19 ,0)+isnull(cm20 ,0)+isnull(cm21 ,0)+isnull(cm22 ,0)+isnull(cm23 ,0)+isnull(cm24 ,0)+isnull(cm25 ,0)+isnull(cm26 ,0)+isnull(cm27 ,0)+isnull(cm28 ,0)+isnull(cm29 ,0)+isnull(cm30 ,0)+isnull(cm31 ,0)+isnull(cm32 ,0)+isnull(cm33 ,0)+isnull(cm34 ,0)+isnull(cm35 ,0) sl,";
        sql += "       thj,thzk, ( ISNULL(cm1 ,0)+isnull(cm2 ,0)+isnull(cm3 ,0)+isnull(cm4 ,0)+isnull(cm5 ,0)+isnull(cm6 ,0)+isnull(cm7 ,0)+isnull(cm8 ,0)+isnull(cm9 ,0)+isnull(cm10 ,0)+isnull(cm11 ,0)+isnull(cm12 ,0)+isnull(cm13 ,0)+isnull(cm14 ,0)+isnull(cm15 ,0)+isnull(cm16 ,0)+isnull(cm17 ,0)+isnull(cm18 ,0)+isnull(cm19 ,0)+isnull(cm20 ,0)+isnull(cm21 ,0)+isnull(cm22 ,0)+isnull(cm23 ,0)+isnull(cm24 ,0)+isnull(cm25 ,0)+isnull(cm26 ,0)+isnull(cm27 ,0)+isnull(cm28 ,0)+isnull(cm29 ,0)+isnull(cm30 ,0)+isnull(cm31 ,0)+isnull(cm32 ,0)+isnull(cm33 ,0)+isnull(cm34 ,0)+isnull(cm35 ,0))*thj thje,";
        sql += "       xsj,xszk, ( ISNULL(cm1 ,0)+isnull(cm2 ,0)+isnull(cm3 ,0)+isnull(cm4 ,0)+isnull(cm5 ,0)+isnull(cm6 ,0)+isnull(cm7 ,0)+isnull(cm8 ,0)+isnull(cm9 ,0)+isnull(cm10 ,0)+isnull(cm11 ,0)+isnull(cm12 ,0)+isnull(cm13 ,0)+isnull(cm14 ,0)+isnull(cm15 ,0)+isnull(cm16 ,0)+isnull(cm17 ,0)+isnull(cm18 ,0)+isnull(cm19 ,0)+isnull(cm20 ,0)+isnull(cm21 ,0)+isnull(cm22 ,0)+isnull(cm23 ,0)+isnull(cm24 ,0)+isnull(cm25 ,0)+isnull(cm26 ,0)+isnull(cm27 ,0)+isnull(cm28 ,0)+isnull(cm29 ,0)+isnull(cm30 ,0)+isnull(cm31 ,0)+isnull(cm32 ,0)+isnull(cm33 ,0)+isnull(cm34 ,0)+isnull(cm35 ,0))*xsj xsje,";
        sql += "       lsj, ( ISNULL(cm1 ,0)+isnull(cm2 ,0)+isnull(cm3 ,0)+isnull(cm4 ,0)+isnull(cm5 ,0)+isnull(cm6 ,0)+isnull(cm7 ,0)+isnull(cm8 ,0)+isnull(cm9 ,0)+isnull(cm10 ,0)+isnull(cm11 ,0)+isnull(cm12 ,0)+isnull(cm13 ,0)+isnull(cm14 ,0)+isnull(cm15 ,0)+isnull(cm16 ,0)+isnull(cm17 ,0)+isnull(cm18 ,0)+isnull(cm19 ,0)+isnull(cm20 ,0)+isnull(cm21 ,0)+isnull(cm22 ,0)+isnull(cm23 ,0)+isnull(cm24 ,0)+isnull(cm25 ,0)+isnull(cm26 ,0)+isnull(cm27 ,0)+isnull(cm28 ,0)+isnull(cm29 ,0)+isnull(cm30 ,0)+isnull(cm31 ,0)+isnull(cm32 ,0)+isnull(cm33 ,0)+isnull(cm34 ,0)+isnull(cm35 ,0))*lsj lsjje,";
        sql += "       dpj, ( ISNULL(cm1 ,0)+isnull(cm2 ,0)+isnull(cm3 ,0)+isnull(cm4 ,0)+isnull(cm5 ,0)+isnull(cm6 ,0)+isnull(cm7 ,0)+isnull(cm8 ,0)+isnull(cm9 ,0)+isnull(cm10 ,0)+isnull(cm11 ,0)+isnull(cm12 ,0)+isnull(cm13 ,0)+isnull(cm14 ,0)+isnull(cm15 ,0)+isnull(cm16 ,0)+isnull(cm17 ,0)+isnull(cm18 ,0)+isnull(cm19 ,0)+isnull(cm20 ,0)+isnull(cm21 ,0)+isnull(cm22 ,0)+isnull(cm23 ,0)+isnull(cm24 ,0)+isnull(cm25 ,0)+isnull(cm26 ,0)+isnull(cm27 ,0)+isnull(cm28 ,0)+isnull(cm29 ,0)+isnull(cm30 ,0)+isnull(cm31 ,0)+isnull(cm32 ,0)+isnull(cm33 ,0)+isnull(cm34 ,0)+isnull(cm35 ,0))*dpj dpjje,";

        sql += "       jzr,yhda.yhmc jzrmc,jzsj,pfdh,ptdh,hz.bzxx";
        sql += "       FROM  dbo.yw_db_khdbdhz hz   LEFT JOIN dbo.da_khda dcda ON hz.dckh=dcda.khbh ";
        sql += "        							LEFT JOIN dbo.da_khda drda ON hz.drkh=drda.khbh ";
        sql += "        							LEFT JOIN dbo.da_bmda zzda ON hz.zzck=zzda.bmbh";
        sql += "        							LEFT JOIN dbo.da_qx_yhda yhda ON hz.jzr=yhda.yhbh,";
        sql += "             dbo.yw_db_khdbdmx mx LEFT JOIN da_sp_spda spda ON mx.spkh=spda.spkh";
        sql += "       WHERE hz.pzh=mx.pzh";
        sql += "       AND   hz.jzbz='1'";
        sql += "       AND   CONVERT(DATE,KDRQ,120)  BETWEEN '" + beginTime + "' AND '" + endTime + "'";
        if (curDckh.length > 0) {
            sql += " AND dckh IN(" + curDckh + ")";
        }
        if (curDrkh.length > 0) {
            sql += " AND drkh IN(" + curDrkh + ")";
        }
        if (curZzck.length > 0) {
            sql += " AND zzck IN(" + curZzck + ")";
        }
        if (curLb.length > 0) {
            sql += " AND hplb IN(" + curLb + ")";
        }
        if (curSpkh.length > 0) {
            sql += " AND mx.spkh IN(" + curSpkh + ")";
        }
        if (curPp.length > 0) {
            sql += " AND spda.jypp IN(" + curPp + ")";
        }
        if (curJj.length > 0) {
            sql += " AND spda.spjj IN(" + curJj + ")";
        }
        if (curNf.length > 0) {
            sql += " AND spda.spnf IN(" + curNf + ")";
        }
        if (curGys.length > 0) {
            sql += " AND spda.gysbh IN(" + curGys + ")";
        }
        if (curPzh.length > 0) {
            sql += " AND hz.pzh='" + curPzh + "'";
        }
        if (curPfcpzh.length > 0) {
            sql += " AND hz.pfdh='" + curPfcpzh + "'";
        }
        if (curPftpzh.length > 0) {
            sql += " AND hz.ptdh='" + curPftpzh + "'";
        }
        sql += " )AAA";
        //        sql += "  GROUP BY PZH,KDRQ,DCKH,DCKHMC,DRKH,DRKHMC,ZZCK,ZZCKMC,SPKH,KSMC,YSBH,YSMC,BXBH,BXMC,PFDH,PTDH,CRDH,CTDH,BZXX";
        //        sql += "  ORDER BY KDRQ DESC";
        sql += " GROUP BY " + curGroupStr.join(",").toString(); ;
     //   requestor.ClipBoardNao(sql)
        sql = self.ChuLIJiaHeYin(sql);
        webReq.Invoke("GetSnataxAndDataFromSql", "sql=" + sql);
        try {
            if (webReq.StatusCode() == 200) {
                dw_list.SetFullState(webReq.ResponseText());
                var colCount = dw_list.Describe("DataWindow.Column.Count");
                self.Set_Width_DW(colCount);
                self.SetSummary();
                dw_list.SetRedraw(true);
                dw_list.SetRowSelection(1);

                Set35ColTitel_DHH(dw_list, false, curcm);
                A8erp_Report.ReportDataWindowHeaderColor(dw_list);
                dw_list.Modify("cm1.width='150' cm2.width='150' cm3.width='150' cm4.width='150' cm5.width='150' cm6.width='150' cm7.width='150' cm8.width='150' cm9.width='150' cm10.width='150' cm11.width='150' cm12.width='150' cm13.width='150' cm14.width='150' cm15.width='150' cm16.width='150' cm17.width='150' cm18.width='150' cm19.width='150' cm20.width='150' cm21.width='150' cm22.width='150' cm23.width='150' cm24.width='150' cm25.width='150' cm26.width='150' cm27.width='150' cm28.width='150' cm29.width='150' cm30.width='150' cm31.width='150' cm32.width='150' cm33.width='150' cm34.width='150' cm35.width='150'");
            } else {
                alert("sqlError!");
            }
            requestor.CloseLoading();
        } catch (err) {
            requestor.CloseLoading();
        }

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

    }

    //#region Function 呼出数据窗口的函数群 

    //
    //    //调入部门
    //    this.Changebmbh1 = function (x, y, row, dwoName) {
    //        dwoName == "bmbh";
    //        curW_OPEN_BMDA.SetDataWindow(W_ZXFXTJ, "bmbh", "bmmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
    //        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowQueryBase&treeDw=dw_da_bmda_fl_tree&listDw=dw_pub_list_bmda&treeRootLabel=部门分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple&curQxlx=all"), curW_OPEN_BMDA, null);
    //    }
    //    //调出部门
    //    this.Changebmbh2 = function (x, y, row, dwoName) {
    //        dwoName == "bmbh2";
    //        curW_OPEN_BMDA.SetDataWindow(W_ZXFXTJ, "bmbh", "bmmc", "M", self, "bmbh2", "bmmc2")  // 这个用来给子窗口Set当前数据窗口
    //        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowQueryBase&treeDw=dw_da_bmda_fl_tree&listDw=dw_pub_list_bmda&treeRootLabel=部门分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple&curQxlx=all"), curW_OPEN_BMDA, null);
    //    }
    //订货部门
    this.Changebmbh = function (x, y, row, dwoName) {
        dwoName = "bmbhDCKH";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_KeHuDiaoBoDan_TJ, "bmbh", "bmmc", "M", 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=pf"), curW_OPEN_BMDA_NEW, null);
    }
    this.ChangebmbhZZC = function (x, y, row, dwoName) {
        dwoName = "bmbhZZC";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_KeHuDiaoBoDan_TJ, "bmbh", "bmmc", "M", 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=pf"), curW_OPEN_BMDA_NEW, null);
    }
    this.Changepinpai = function (x, y, row, dwoName) {
        dwoName == "ppbm";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_KeHuDiaoBoDan_TJ, "ppbm", "ppmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_da_sp_ppda_list&selectStyle=multiple&flag=ywcx"), curW_OPEN_SIMPLE_CHOSE, null);
    }

    this.Changegys = function (x, y, row, dwoName) {
        dwoName == "gysbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_KeHuDiaoBoDan_TJ, "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.Changekh = function (x, y, row, dwoName) {
        dwoName == "spkh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_KeHuDiaoBoDan_TJ, "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.Changelb = function (x, y, row, dwoName) {
        dwoName == "lbbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_KeHuDiaoBoDan_TJ, "lbbh", "lbmc", "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_lbda_list&treeRootLabel=商品分类&treeData=lbbh&treeLabel=lbmc&treeParentData=flbbh&treeLeave=islast&selectStyle=multiple"), curW_OPEN_BMDA_NEW, null);
    }

    this.Changejj = function (x, y, row, dwoName) {
        dwoName == "jjbm";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_KeHuDiaoBoDan_TJ, "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.Changeml = function (x, y, row, dwoName) {
        dwoName == "mlbh";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_KeHuDiaoBoDan_TJ, "mlbh", "mlmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_da_sp_mlda_list&selectStyle=multiple"), curW_OPEN_SIMPLE_CHOSE, null);
    }
    //发货类型
    this.Changefhlx = function (x, y, row, dwoName) {

        dwoName == "dbfs";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_KeHuDiaoBoDan_TJ, "dbfs", "dbmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_pub_list_qj_csb_dbfs&selectStyle=multiple"), curW_OPEN_SIMPLE_CHOSE, null);
    }

//    //配发部门    
//    this.Changepfkh = function (x, y, row, dwoName) {
//        dwoName == "bmbh2";
//        curW_OPEN_BMDA_NEW.SetDataWindow(W_KeHuDiaoBoDan_TJ, "bmbh2", "bmmc2", "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_dhbm&treeRootLabel=部门分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple&curQxlx=pf"), curW_OPEN_BMDA_NEW, null);
//    }
    this.Changepfkh = function (x, y, row, dwoName) {
        dwoName == "khbh"
        curW_OPEN_BMDA_NEW.SetDataWindow(W_KeHuDiaoBoDan_TJ, "khbh", "khmc", "M", self)   // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base." + curW_OPEN_BMDA_URL + "&treeDw=dw_da_khda_fl_tree&listDw=dw_pub_khda_list_all&treeRootLabel=客户分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple"), curW_OPEN_BMDA_NEW, null);
    } 
    this.Changepfkh2 = function (x, y, row, dwoName) {
        dwoName = "khbh_dckh"
        curW_OPEN_BMDA_NEW.SetDataWindow(W_KeHuDiaoBoDan_TJ, "khbh", "khmc", "M", self,dwoName)   // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base." + curW_OPEN_BMDA_URL + "&treeDw=dw_da_khda_fl_tree&listDw=dw_pub_khda_list_all&treeRootLabel=客户分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple"), curW_OPEN_BMDA_NEW, null);
    }
    this.SetSleValue = function (difBh, val) {
        if ("''" == val)
            val = "";
        if ("bmbh" == difBh)
            sle_bm.SetText(val);
        else if ("gysbh" == difBh)
            sle_gys.SetText(val);
        else if ("lbbh" == difBh)
            sle_lb.SetText(val);
        else if ("ppbm" == difBh)
            sle_pp.SetText(val);
        else if ("jjbm" == difBh)
            sle_jj.SetText(val);
        else if ("spkh" == difBh)
            sle_kh.SetText(val);
        else if ("dbfs" == difBh)
            sle_fhlx.SetText(val);
        else if ("mlbh" == difBh)
            sle_ml.SetText(val);
        else if ("bmbh2" == difBh)
            sle_pfkh.SetText(val);
        else if ("rkfs" == difBh)
            sle_rkfs.SetText(val)
        else if ("ckfs" == difBh)
            sle_ckfs.SetText(val);
        else if ("bmbhZZC" == difBh)
            sle_zzck.SetText(val);
        else if ("bmbhDCKH" == difBh)
            sle_bm.SetText(val);
        else if ("khbh" == difBh)
            sle_pfkh.SetText(val);
        else if ("khbh_dckh" == difBh)
            sle_bm.SetText(val);
    }

    //#endregion

    //#region 处理sql的特殊字符
    this.ChuLIJiaHeYin = function (str) {
        str = str.replace(/\%/g, "%25");
        str = str.replace(/\+/g, "%2B");
        str = str.replace(/\&/g, "%26");
        return str;

    }
    //#endregion
    this.Set_Width_DW = function (colCount) {
        dw_list.Modify("DataWindow.header.Height=88");
        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');


            switch (ls_columnname) {
                case "jzr":
                    ls_columntitle = "记账人编号"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "jzrmc":
                    ls_columntitle = "记账人名称"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "jzsj":
                    ls_columntitle = "记账时间"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 550 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "kdrq":
                    ls_columntitle = "业务日期"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "kdrq":
                    ls_columntitle = "业务日期"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "zzck":
                    ls_columntitle = "中转仓编号"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "zzckmc":
                    ls_columntitle = "中转仓名称"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
            
                    break;
                case "dckh":
                    ls_columntitle = "调出客户"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "dckhmc":
                    ls_columntitle = "调出客户名称"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
            
                    break;
                case "drkh":
                    ls_columntitle = "调入客户"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "drkhmc":
                    ls_columntitle = "调入客户名称"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
          
                    break;
                case "jzsj":
                    ls_columntitle = "记账时间"

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

                    ls_columntitle = "调拨凭证号"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "ptdh":

                    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 "pfdh":

                    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 "crdh":

                    ls_columntitle = "采购入单号"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "ctdh":

                    ls_columntitle = "采购退单号"

                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    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 "bmmc":
                    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 = '" + 500 + "'");
                 
                    break;

                case "ksmc":
                    ls_columntitle = "款式名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    break;
                case "ysbh":
                    ls_columntitle = "颜色编号"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
             
                    break;

                case "ysmc":
                    ls_columntitle = "颜色名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "bxbh":
                    ls_columntitle = "版型编号"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
            
                    break;

                case "bxmc":
                    ls_columntitle = "版型名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "srsl":
                    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 = '" + 400 + "'");
                    dw_list.Modify(ls_columnname + ".format='###########0' ")

                    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 "thj":
                    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 "thje":
                    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 = '" + 500 + "'");
                    break;
                case "xsj":
                    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 "xsje":
                    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 = '" + 500 + "'");
                    break;
                case "bzxx":
                    ls_columntitle = "备注信息";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");

                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    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 "lsjje":
                    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 = '" + 500 + "'");
                    break;
                case "dpj":
                    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 "dpjje":
                    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 = '" + 500 + "'");
                    break;
                case "xszk":
                    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 "thzk":
                    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;
            }
            dw_list.Modify(ls_columnname + ".tabsequence='0' ");
 
        }
        dw_list.Modify("create compute(band=detail alignment='2' expression='getrow()'border='0' color='33554432' x='0' y='4' height='76' width='200' 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='200' 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 sl_x = dw_list.Describe("sl.x");
        var sl_width = dw_list.Describe("sl.width");


        var thje_x = dw_list.Describe("thje.x");
        var thje_width = dw_list.Describe("thje.width");



        var xsje_x = dw_list.Describe("xsje.x");
        var xsje_width = dw_list.Describe("xsje.width");


        var lsjje_x = dw_list.Describe("lsjje.x");
        var lsjje_width = dw_list.Describe("lsjje.width");

        var dpjje_x = dw_list.Describe("dpjje.x");
        var dpjje_width = dw_list.Describe("dpjje.width");

        dw_list.Modify("DataWindow.footer.Height=80");
        dw_list.Modify("DataWindow.summary.Height=0");
        var ls_syntax = "";
        ls_syntax = ls_syntax + " create compute(band=footer alignment='1' expression='sum(sl  for all)' border='0' color='128' x='" + sl_x + "' y='8' height='52' width='" + sl_width + "' 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=footer alignment='1' expression='sum(thje  for all)' border='0' color='128' x='" + thje_x + "' y='8' height='52' width='" + thje_width + "' 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=footer alignment='1' expression='sum(xsje  for all)' border='0' color='128' x='" + xsje_x + "' y='8' height='52' width='" + xsje_width + "' 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=footer alignment='1' expression='sum(lsjje  for all)' border='0' color='128' x='" + lsjje_x + "' y='8' height='52' width='" + lsjje_width + "' 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=footer alignment='1' expression='sum(dpjje  for all)' border='0' color='128' x='" + dpjje_x + "' y='8' height='52' width='" + dpjje_width + "' 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')"

        for(var r=1;r<=35;r++){
         var curX=dw_list.Describe("cm"+r+".x");
         var curWidth = dw_list.Describe("cm" + r + ".width");
           ls_syntax = ls_syntax + " create compute(band=footer alignment='1' expression='sum(cm"+r+"  for all)' border='0' color='128' x='" +curX + "' y='8' height='52' width='" + curWidth + "' 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='#')"
        }

        dw_list.Modify(ls_syntax);

    }
    //#endregion

    //#region 打印
    this.Print = function () {

        dw_list.PrintPreview();
    }
    //#endregion

    //#region 退出
    this.Exit = function () {

        setTimeout("window.close()", 100);
    }
    //#endregion

    //#region this.EvalJs

    this.EvalJs = function (jsScript) {
        eval(jsScript);
    }
    //#endregion

    this.CheckedNF = function () {
        curW_NFCheck.SetDataWindow(self)
        requestor.Open("/Service/LoadWindow.ashx?WinName=A8ERP.KuCun.TongJiFenXi.W_NFCheck", curW_NFCheck, null);
    }
    this.Export = function () {

        dw_list.Export();
    }

    var lastSortName = "";
    this.DoubleClicked = function (x, y, row, dwcName) {
        if (row == 0) {
            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();
                }
            }
        } else {

            //#region 反调单据
            var pzh = "";
            if (dwcName == "pfdh") {
                  pzh = dw_list.GetItemString(row, "pfdh");

            }else if (dwcName == "ptdh") {
                  pzh = dw_list.GetItemString(row, "ptdh");

            }


            if (pzh.length > 0) {
                //反调到原单据    
                var ywflag = pzh.substring(0, 2);
                if (ywflag == "CR") {
                    self.OpenSheet("SJ006", "采购入库单", pzh, "");
                } else if (ywflag == "CT") {
                    self.OpenSheet("SJ090", "采购退货单", pzh, "");
                } else if (ywflag == "DC") {
                    self.OpenSheet("SJ010", "仓库调拨出库单", pzh, "");
                } else if (ywflag == "DR") {
                    self.OpenSheet("SJ173", "仓库调拨入库单", pzh, "");
                } else if (ywflag == "PF") {
                    self.OpenSheet("SJ141", "批发出库单", pzh, "");
                } else if (ywflag == "PT") {
                    self.OpenSheet("SJ144", "批发退库单", pzh, "");
                } else if (ywflag == "LC") {
                    self.OpenSheet("SJ123", "连锁出库单", pzh, "");
                } else if (ywflag == "LT") {
                    self.OpenSheet("SJ126", "连锁退库单", pzh, "");
                }
            }
            //#endregion

        }
    }



    this.OpenSheet = function (itemData, itemLabel, hyh, gysbh) {

        var ts_1 = window.external.Control("ts_1");
        ts_1.CloseItem(itemData);
        ts_1.Open(itemData, itemLabel, '', encodeURI("/Service/OpenSheet.aspx?FunID=" + itemData + "&curDate=" + new Date().toLocaleTimeString() + "&Reload=Y&curFormPzh=" + hyh + "&curParam1=" + gysbh), true);


    }


    this.DagouPzh = function (b) {
        if (b) {
            cbx_pzh.SetChecked(true);
        }
    }
    this.dgPzh = function (b) {
        if (!b) {
            cbx_pfcdh.SetChecked(false);
            cbx_pftdh.SetChecked(false);
         
            cbx_bzxx.SetChecked(false);
        }
    }
}