///<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" />
///<reference  path="/CaiGou/CaiGouTongJiFenxi/W_CG_HZ_Base.win.js" /> 

//注意,需要在对象定义后面，手工增加以下代码实现对象继承
// W_HZTJ.prototype = new W_CG_HZ_Base( ); 

function W_HZTJ() {

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var cbx_ys = new CheckBox(requestor);
    var cbx_bx = new CheckBox(requestor)
    var ddlb_nf = new DropDownListBox(requestor);
    var sle_pzh = new SingleLineEdit(requestor);
    var cb_8 = new CommandButton(requestor);
    var cb_7 = new CommandButton(requestor);
    var cb_6 = new CommandButton(requestor);
    var cb_5 = new CommandButton(requestor);
    var cb_4 = new CommandButton(requestor);
    var cb_3 = new CommandButton(requestor);
    var sle_fs = new SingleLineEdit(requestor);
    var sle_ml = new SingleLineEdit(requestor);
    var sle_jj = new SingleLineEdit(requestor);
    var sle_lb = new SingleLineEdit(requestor);
    var sle_kh = new SingleLineEdit(requestor);
    var sle_gys = new SingleLineEdit(requestor);
    var cb_2 = new CommandButton(requestor);
    var sle_pp = new SingleLineEdit(requestor);
    var cb_1 = new CommandButton(requestor);
    var sle_bm = new SingleLineEdit(requestor);
    var dp_2 = new DatePicker(requestor);
    var dp_1 = new DatePicker(requestor);
    var cbx_ks = new CheckBox(requestor);
    var cbx_fs = new CheckBox(requestor);
    var cbx_lb = new CheckBox(requestor);
    var cbx_gys = new CheckBox(requestor);
    var cbx_bm = new CheckBox(requestor);
    var cbx_rq = new CheckBox(requestor);
    var cbx_pzh = new CheckBox(requestor);
    var rb_sl = new RadioButton(requestor);
    var rb_je = new RadioButton(requestor);
    var ddlb_2 = new DropDownListBox(requestor);
    var rb_tb = new RadioButton(requestor);
    var rb_sp = new RadioButton(requestor);
    var ddlb_sex = new DropDownListBox(requestor);
    var sle_formatname = new SingleLineEdit(requestor);
    var cb_Select = new CommandButton(requestor);
    var cb_Save = new CommandButton(requestor);
    var dw_temp = new DataWindow(requestor);
    var dw_format = new DataWindow(requestor);
    var dw_list = new DataWindow(requestor);
    var flash_1 = new Flash(requestor);
    var mle_1 = new MultiLineEdit(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_bx == null) cbx_bx = new CheckBox(requestor);
        cbx_bx.Attach(win.Control("cbx_bx"));

        if (cbx_ys == null) cbx_ys = new CheckBox(requestor);
        cbx_ys.Attach(win.Control("cbx_ys"));
        if (ddlb_nf == null) ddlb_nf = new DropDownListBox(requestor);
        ddlb_nf.Attach(win.Control("ddlb_nf"));
        if (sle_pzh == null) sle_pzh = new SingleLineEdit(requestor);
        sle_pzh.Attach(win.Control("sle_pzh"));
        if (cb_8 == null) cb_8 = new CommandButton(requestor);
        cb_8.Attach(win.Control("cb_8"));
        if (cb_7 == null) cb_7 = new CommandButton(requestor);
        cb_7.Attach(win.Control("cb_7"));
        if (cb_6 == null) cb_6 = new CommandButton(requestor);
        cb_6.Attach(win.Control("cb_6"));
        if (cb_5 == null) cb_5 = new CommandButton(requestor);
        cb_5.Attach(win.Control("cb_5"));
        if (cb_4 == null) cb_4 = new CommandButton(requestor);
        cb_4.Attach(win.Control("cb_4"));
        if (cb_3 == null) cb_3 = new CommandButton(requestor);
        cb_3.Attach(win.Control("cb_3"));
        if (sle_fs == null) sle_fs = new SingleLineEdit(requestor);
        sle_fs.Attach(win.Control("sle_fs"));
        if (sle_ml == null) sle_ml = new SingleLineEdit(requestor);
        sle_ml.Attach(win.Control("sle_ml"));
        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_gys == null) sle_gys = new SingleLineEdit(requestor);
        sle_gys.Attach(win.Control("sle_gys"));
        if (cb_2 == null) cb_2 = new CommandButton(requestor);
        cb_2.Attach(win.Control("cb_2"));
        if (sle_pp == null) sle_pp = new SingleLineEdit(requestor);
        sle_pp.Attach(win.Control("sle_pp"));
        if (cb_1 == null) cb_1 = new CommandButton(requestor);
        cb_1.Attach(win.Control("cb_1"));
        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 (cbx_ks == null) cbx_ks = new CheckBox(requestor);
        cbx_ks.Attach(win.Control("cbx_ks"));
        if (cbx_fs == null) cbx_fs = new CheckBox(requestor);
        cbx_fs.Attach(win.Control("cbx_fs"));
        if (cbx_lb == null) cbx_lb = new CheckBox(requestor);
        cbx_lb.Attach(win.Control("cbx_lb"));
        if (cbx_gys == null) cbx_gys = new CheckBox(requestor);
        cbx_gys.Attach(win.Control("cbx_gys"));
        if (cbx_bm == null) cbx_bm = new CheckBox(requestor);
        cbx_bm.Attach(win.Control("cbx_bm"));
        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 (rb_sl == null) rb_sl = new RadioButton(requestor);
        rb_sl.Attach(win.Control("rb_sl"));
        if (rb_je == null) rb_je = new RadioButton(requestor);
        rb_je.Attach(win.Control("rb_je"));
        if (ddlb_2 == null) ddlb_2 = new DropDownListBox(requestor);
        ddlb_2.Attach(win.Control("ddlb_2"));
        if (rb_tb == null) rb_tb = new RadioButton(requestor);
        rb_tb.Attach(win.Control("rb_tb"));
        if (rb_sp == null) rb_sp = new RadioButton(requestor);
        rb_sp.Attach(win.Control("rb_sp"));
        if (ddlb_sex == null) ddlb_sex = new DropDownListBox(requestor);
        ddlb_sex.Attach(win.Control("ddlb_sex"));
        if (sle_formatname == null) sle_formatname = new SingleLineEdit(requestor);
        sle_formatname.Attach(win.Control("sle_formatname"));
        if (cb_Select == null) cb_Select = new CommandButton(requestor);
        cb_Select.Attach(win.Control("cb_Select"));
        if (cb_Save == null) cb_Save = new CommandButton(requestor);
        cb_Save.Attach(win.Control("cb_Save"));
        if (dw_temp == null) dw_temp = new DataWindow(requestor);
        dw_temp.Attach(win.Control("dw_temp"));
        if (dw_format == null) dw_format = new DataWindow(requestor);
        dw_format.Attach(win.Control("dw_format"));
        if (dw_list == null) dw_list = new DataWindow(requestor);
        dw_list.Attach(win.Control("dw_list"));
        if (flash_1 == null) flash_1 = new Flash(requestor);
        flash_1.Attach(win.Control("flash_1"));
        if (mle_1 == null) mle_1 = new MultiLineEdit(requestor);
        mle_1.Attach(win.Control("mle_1"));
        if (tb_1 == null) tb_1 = new ToolStrip(requestor);
        tb_1.Attach(win.Control("tb_1"));


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

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

        if (typeof (self.setcbx) == "function")
            win.AttachEvent("cbx_ys", "Clicked", self.setcbx);

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

        if (typeof (self.Changeml) == "function")
            win.AttachEvent("cb_7", "Clicked", self.Changeml);

        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.Changegys) == "function")
            win.AttachEvent("cb_3", "Clicked", self.Changegys);

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

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

        if (typeof (self.setcbx) == "function")
            win.AttachEvent("cbx_ks", "Clicked", self.setcbx);

        if (typeof (self.setcbx) == "function")
            win.AttachEvent("cbx_fs", "Clicked", self.setcbx);

        if (typeof (self.setcbx) == "function")
            win.AttachEvent("cbx_lb", "Clicked", self.setcbx);

        if (typeof (self.setcbx) == "function")
            win.AttachEvent("cbx_gys", "Clicked", self.setcbx);

     
        if (typeof (self.setcbx) == "function")
            win.AttachEvent("cbx_bm", "Clicked", self.setcbx);

        if (typeof (self.setcbx) == "function")
            win.AttachEvent("cbx_rq", "Clicked", self.setcbx);

     
        

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

        if (typeof (self.setcbx) == "function")
            win.AttachEvent("cbx_bx", "Clicked", self.setcbx);

        if (typeof (self.UpdateChart) == "function")
            win.AttachEvent("ddlb_2", "SelectionChanged", self.UpdateChart);

        if (typeof (self.sp) == "function")
            win.AttachEvent("rb_tb", "Clicked", self.sp);

        if (typeof (self.sp) == "function")
            win.AttachEvent("rb_sp", "Clicked", self.sp);

        if (typeof (self.TongJi) == "function")
            win.AttachEvent("btn_Query", "Clicked", self.TongJi);
        if (typeof (self.SelectGS) == "function")
            win.AttachEvent("cb_Select", "Clicked", self.SelectGS);

        if (typeof (self.SaveGS) == "function")
            win.AttachEvent("cb_Save", "Clicked", self.SaveGS);

        if (typeof (self.ReportOp) == "function")
            win.AttachEvent("列格式保存ToolStripMenuItem", "Clicked", self.ReportOp);

        if (typeof (self.ReportClare) == "function")
            win.AttachEvent("清空当前窗口所有格式ToolStripMenuItem", "Clicked", self.ReportClare);

        if (typeof (self.picpreview) == "function")
            win.AttachEvent("浏览图片ToolStripMenuItem", "Clicked", self.picpreview);

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

        if (typeof (self.RightKey) == "function")
            win.AttachEvent("xxxxxxaToolStripMenuItem", "Clicked", self.RightKey);

        if (typeof (self.Exit) == "function")
            win.AttachEvent("btn_Exit", "Clicked", self.Exit);
        if (typeof (self.DoubleClickedSort) == "function")
            win.AttachEvent("dw_list", "DoubleClicked", self.DoubleClickedSort);
        if (typeof (self.Print) == "function")
            win.AttachEvent("btn_Print", "Clicked", self.Print);
    }

    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_ys.Detach(); cbx_ys = null;
        ddlb_nf.Detach(); ddlb_nf = null;
        sle_pzh.Detach(); sle_pzh = null;
        cb_8.Detach(); cb_8 = null;
        cb_7.Detach(); cb_7 = null;
        cb_6.Detach(); cb_6 = null;
        cb_5.Detach(); cb_5 = null;
        cb_4.Detach(); cb_4 = null;
        cb_3.Detach(); cb_3 = null;
        sle_fs.Detach(); sle_fs = null;
        sle_ml.Detach(); sle_ml = null;
        sle_jj.Detach(); sle_jj = null;
        sle_lb.Detach(); sle_lb = null;
        sle_kh.Detach(); sle_kh = null;
        sle_gys.Detach(); sle_gys = null;
        cb_2.Detach(); cb_2 = null;
        sle_pp.Detach(); sle_pp = null;
        cb_1.Detach(); cb_1 = null;
        sle_bm.Detach(); sle_bm = null;
        dp_2.Detach(); dp_2 = null;
        dp_1.Detach(); dp_1 = null;
        cbx_ks.Detach(); cbx_ks = null;
        cbx_fs.Detach(); cbx_fs = null;
        cbx_lb.Detach(); cbx_lb = null;
        cbx_gys.Detach(); cbx_gys = null;
        cbx_bm.Detach(); cbx_bm = null;
        cbx_rq.Detach(); cbx_rq = null;
        cbx_pzh.Detach(); cbx_pzh = null;

        cbx_bx.Detach(); cbx_bx = null;
        rb_sl.Detach(); rb_sl = null;
        rb_je.Detach(); rb_je = null;
        ddlb_2.Detach(); ddlb_2 = null;
        rb_tb.Detach(); rb_tb = null;
        rb_sp.Detach(); rb_sp = null;
        ddlb_sex.Detach(); ddlb_sex = null;
        sle_formatname.Detach(); sle_formatname = null;
        cb_Select.Detach(); cb_Select = null;
        cb_Save.Detach(); cb_Save = null;
        dw_temp.Detach(); dw_temp = null;
        dw_format.Detach(); dw_format = null;
        dw_list.Detach(); dw_list = null;
        dw_format_hz.Detach(); dw_format_hz = null;
        dw_format_mx.Detach(); dw_format_mx = null;
        flash_1.Detach(); flash_1 = null;
        mle_1.Detach(); mle_1 = null;
        tb_1.Detach(); tb_1 = null;
        requestor.Detach(); requestor = null;

        setTimeout(CollectGarbage, 100);
    }

    //以上代码由设计器自动生成,请不要手工修改
    //ExtPB.Net JavaScript End  设计器查找标志,请不要删除或修改
    //#region 变量声明板块
    var curW_OPEN_BMDA = new OpenWindowQueryBase();
    var curW_OPEN_SIMPLE_CHOSE = new OpenWindowSimpleChoseBase();

    var curW_OPEN_BMDA_NEW = new OpenWindowQueryNewBase();
    var curW_OPEN_BMDA_URL = "OpenWindowQueryNewBase";
    
    
    var gRowCount = "0"
    var curOtherWidht = 1080;
    var curOtherHeight = 760;
    var listvar = "bmmc";
    var curOpenWindowDoubleRowsChooseBase = new OpenWindowDoubleRowsChooseBase();
    webReq = new WebRequestor();
    webReq.SetWebServiceUrl("/Service/ServiceForDwSyndax.ashx");

    webReq_Print = new WebRequestor();
    webReq_Print.SetWebServiceUrl("/Service/Ajax_XT.ashx");
    var curYhmc = "";

    var ywflag = "";
    var curYhbh = "";
    var curCdbh = "";
    var curYhbh = "";
    var curBbmc = "rb_sp";
    var C_CheckValue = "";
    var curJgtx = "";
    var ExistGYS = "";
    //报表名称
    var curBBMCNew = "";
    var curBBPZH = "";
    var curOptype = "0" //0 ：保存  1：修改 
    var cur_Open_Window = null;
    var ChildDWCheckValue = "";
    var dw_format_hz = null; //格式汇总窗口
    var dw_format_mx = null; //格式明细窗口
    var Exel_FH_Flag = "1";
    var curW_Base_Report_Open_Mx_Ex = new W_Base_Report_Open_Mx_Ex();
    var curUserId = "";
    var curcbx_gs = 0;
    var xsmrgs = 0;
    var curPzh = "";
    var syntax = "";
    var evealStr = "";
    var lastSortName = "";
    var isFirstSave = "";
    var curW_KC_PIC = new W_KC_PIC();
    var curSelDays = ""; //默认该模块可查询天数
    var cursjcd = "";
    var cbx_rkfs = null;
    var cbx_fjsx1 = null;
    var cbx_fjsx2 = null;
    var cbx_fjsx3= null;
    var cbx_fjsx4 = null; var cbx_fjsx5 = null;
    var dw_format_hz = new DataWindow(requestor);
    var dw_format_mx = new DataWindow(requestor);

    var curW_NFCheck = new W_NFCheck();

    var sle_nf = new SingleLineEdit(requestor); 
    var curW_NFCheck = new W_NFCheck();
    //#endregion

    //#region 水平
    this.sp = function (bchecked, obj) {
        if (rb_tb.GetChecked()) {
            cbx_bm.SetChecked(false);
            cbx_fs.SetChecked(false);
            cbx_ks.SetChecked(false);
            cbx_bx.SetChecked(false);
            cbx_gys.SetChecked(false);
            cbx_rq.SetChecked(false);
            cbx_pzh.SetChecked(false);
            cbx_ys.SetChecked(false);
            cbx_lb.SetChecked(false);
            cbx_bx.SetChecked(false);
            rb_je.SetEnabled(true);
            rb_sl.SetEnabled(true);
            cbx_rkfs.SetChecked(false); 
            cbx_fjsx1.SetChecked(false); 
            cbx_fjsx2.SetChecked(false); 
            cbx_fjsx3.SetChecked(false);
            cbx_fjsx4.SetChecked(false);
            cb_Save.SetEnabled(false);
            cb_Select.SetEnabled(false);

        }
        if (rb_sp.GetChecked()) {
            var tempbbmc = obj.Name;
            cbx_pzh.SetChecked(false)
            cbx_bm.SetChecked(false);
            cbx_bx.SetChecked(false);
            cbx_lb.SetChecked(false);
            cbx_fs.SetChecked(false);
            cbx_ks.SetChecked(false);
            cbx_rkfs.SetChecked(false);
            cbx_fjsx1.SetChecked(false);
            cbx_fjsx2.SetChecked(false);
            cbx_fjsx3.SetChecked(false);
            cbx_fjsx4.SetChecked(false);
            cbx_gys.SetChecked(false);
            cbx_ys.SetChecked(false);
            cbx_bx.SetChecked(false);
            cbx_rq.SetChecked(false);
            rb_je.SetEnabled(false);
            rb_sl.SetEnabled(false);
            cb_Save.SetEnabled(true);
            cb_Select.SetEnabled(true);
            if (tempbbmc.length > 1) {
                var v_CheckBoxState = GetCheckBoxValue(dw_format, curYhbh, curCdbh, tempbbmc)
                if (v_CheckBoxState.length > 1) {
                    window.eval(v_CheckBoxState);
                }
            }
        }
    }
    //#endregion
    this.setcbx = function (flag, dwoName) {
        if (!rb_tb.GetChecked()) {
            return;
        }
        cbx_bm.SetChecked(false);
        cbx_fs.SetChecked(false);
        cbx_ks.SetChecked(false);
        cbx_gys.SetChecked(false);
        cbx_rq.SetChecked(false);
        cbx_pzh.SetChecked(false)
        cbx_lb.SetChecked(false);
        cbx_ys.SetChecked(false);
        cbx_bx.SetChecked(false);
        cbx_rkfs.SetChecked(false);
        cbx_fjsx1.SetChecked(false);
        cbx_fjsx2.SetChecked(false);
        cbx_fjsx3.SetChecked(false);
        cbx_fjsx4.SetChecked(false);
       
        listvar = eval(dwoName.name + ".GetText()")
        //alert("listvar1" + listvar)
        eval(dwoName.name + ".SetChecked(true)");
      
    }
    //#region Function Query
    this.Query = function () {
        requestor.ShowLoading("正在查询中......请勿关闭程序。");

        C_CheckValue = "";
        dw_temp.Reset();
        dw_format.SetRedraw(false); 

        if (!cbx_rq.GetChecked() && !cbx_bm.GetChecked() && !cbx_gys.GetChecked() && !cbx_fs.GetChecked() && !cbx_ks.GetChecked() && !cbx_lb.GetChecked() && !cbx_pzh.GetChecked() && !cbx_ys.GetChecked() && !cbx_bx.GetChecked() && !cbx_rkfs.GetChecked() && !cbx_fjsx1.GetChecked() && !cbx_fjsx2.GetChecked() && !cbx_fjsx3.GetChecked() && !cbx_fjsx4.GetChecked()) {

            cbx_bm.SetChecked(true);
            listvar = "bmmc";
        }
    
        var finishSql = "";
        var dynamicShowStr = "";
        var dynamicShowString = "";
        var dynamicShowStrEnd = "";
        var dynamicShowStringEnd = "";


        if (cbx_lb.GetChecked()) {
            dynamicShowStr += "b.hplb lbbh ,d.lbmc lbmc,";
            dynamicShowString += "b.hplb,d.lbmc,";
            C_CheckValue += "cbx_lb,"
        }
        if (cbx_ks.GetChecked()) {
            dynamicShowStr += "a.spkh spkh,b.ksmc ksmc,b.jldw jldw,";
            dynamicShowString += "a.spkh,b.ksmc,b.jldw,";
            C_CheckValue += "cbx_ks,"

        }

        if (cbx_ys.GetChecked()) {
            dynamicShowStr += "a.ysbh,g.ysmc,";
            dynamicShowString += "a.ysbh,g.ysmc,";
            C_CheckValue += "cbx_ys,"

        }
        if (cbx_bx.GetChecked()) {
            dynamicShowStr += "a.bxbh,h.bxmc,";
            dynamicShowString += "a.bxbh,h.bxmc,";
            C_CheckValue += "cbx_bx,"
        }
        if (cbx_bm.GetChecked()) {
            dynamicShowStr += " a.bmbh as bmbh ,c.bmmc as bmmc,";
            dynamicShowString += " a.bmbh,c.bmmc,";
            C_CheckValue += "cbx_bm,"
        }
        if (cbx_pzh.GetChecked()) {
            dynamicShowStr += " a.pzh pzh,";
            dynamicShowString += " a.pzh,";
            C_CheckValue += "cbx_pzh,"
            if (ywflag == "CR" || ywflag == "CT") {
                dynamicShowStr += " r.ygmc jzr,";
                dynamicShowString += " r.ygmc,";
            }
        }
        if (cbx_rq.GetChecked()) {
            dynamicShowStr += " convert(varchar(10),a.kdrq,23) as rq,";
            dynamicShowString += " a.kdrq,";
            C_CheckValue += "cbx_rq,"
        }
        if (cbx_fs.GetChecked()) {
            dynamicShowStrEnd += " ,f.csmc   cgfs";
            dynamicShowStringEnd += ",f.csmc";
            C_CheckValue += "cbx_fs,"
        }
        if (cbx_gys.GetChecked()) {
            dynamicShowStr += "a.gysbh gysbh ,e.gysmc gysmc,";
            dynamicShowString += "a.gysbh,e.gysmc,";
            C_CheckValue += "cbx_gys,"
        }

        if (cbx_rkfs.GetChecked()) {

            dynamicShowStrEnd += " ,k.rklxmc rklxmc";
            dynamicShowStringEnd += ",k.rklxmc";
            C_CheckValue += "cbx_rkfs,"
        }
     
        if (cbx_fjsx1.GetChecked()) {
            dynamicShowStrEnd += " ,fjsx1.mc fjsx1mc";
            dynamicShowStringEnd += ",fjsx1.mc";         
            C_CheckValue += "cbx_fjsx1,"
        }
    
        if (cbx_fjsx2.GetChecked()) {
            dynamicShowStrEnd += " ,fjsx2.mc fjsx2mc";
            dynamicShowStringEnd += ",fjsx2.mc";  
            C_CheckValue += "cbx_fjsx2,"
        }
        if (cbx_fjsx3.GetChecked()) {
            dynamicShowStrEnd += " ,fjsx3.mc fjsx3mc";
            dynamicShowStringEnd += ",fjsx3.mc";  
            C_CheckValue += "cbx_fjsx3,"
        }
        if (cbx_fjsx4.GetChecked()) {
            dynamicShowStrEnd += " ,fjsx4.mc fjsx4mc";
            dynamicShowStringEnd += ",fjsx4.mc";
            C_CheckValue += "cbx_fjsx4,"
        }
      
        if (ywflag == "CG") {
          
            finishSql = " select " + dynamicShowStr +
                      " SUM(a.sl) zjsl,sum(a.sl*a.lsj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) lsj,sum(a.sl*a.lsj) lsjze,sum(a.sl*a.dpj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) dpj,sum(a.sl*a.dpj) dpjze,sum(a.sl*a.jj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) jj,sum(a.sl*a.jj) jjze  " + dynamicShowStrEnd + " from (SELECT * FROM dbo.yw_cg_cgddtz_ls   UNION ALL   SELECT * FROM dbo.yw_cg_cgddtz) a " +
                      " left join  da_sp_spda  b on a.spkh=b.spkh  " +
                      " left join  da_bmda c  on a.bmbh= c.bmbh  " +
                      " left join  da_sp_lbda d on d.lbbh=b.hplb " +
                      " left join  da_gysda e on a.gysbh=e.gysbh " +
                      " left join  (select * from da_qj_csb where  csfl='CG_DDFS') f on a.cgfs=f.csbh " +
                      " left join  da_sp_ysda g on g.yslsh=a.yslsh " +
                      " left join  da_sp_bxda h on h.bxbh=a.bxbh " +
                      " left join  (select bh,mc FROM dbo.da_sp_spfjsx WHERE lbdm='01') fjsx1 on fjsx1.bh=b.spsx1 " +
                      " left join  (select bh,mc FROM dbo.da_sp_spfjsx WHERE lbdm='02') fjsx2 on fjsx2.bh=b.spsx2 " +
                      " left join  (select bh,mc FROM dbo.da_sp_spfjsx WHERE lbdm='03') fjsx3 on fjsx3.bh=b.spsx3 " +
                      " left join  (select bh,mc FROM dbo.da_sp_spfjsx WHERE lbdm='04') fjsx4 on fjsx4.bh=b.spsx4 " +
                      " where  a.djlx='1' " + self.GetSqlWhere()

        
            if (dynamicShowString.length == 0) {

                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
                finishSql += " order by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
            }
            else {
                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
                finishSql += " order by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
            }
          
        }
        else if (ywflag == "CS") {
            finishSql = " select " + dynamicShowStr +
                        " SUM(a.sl) zjsl,sum(a.sl*a.lsj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) lsj,sum(a.sl*a.lsj) lsjze,sum(a.sl*a.dpj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) dpj,sum(a.sl*a.dpj) dpjze,sum(a.sl*a.jj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) jj,sum(a.sl*a.jj) jjze  " + dynamicShowStrEnd + " from (SELECT * FROM dbo.yw_cg_cgddtz_ls   UNION ALL   SELECT * FROM dbo.yw_cg_cgddtz) a " +
                        " left join  da_sp_spda  b on a.spkh=b.spkh  " +
                        " left join  da_bmda c  on a.bmbh= c.bmbh  " +
                        " left join  da_sp_lbda d on d.lbbh=b.hplb " +
                        " left join  da_gysda e on e.gysbh=a.gysbh " +
                        " left join  (select * from da_qj_csb where  csfl='CG_CGFS') f on a.cgfs=f.csbh  " +
                        " left join  da_sp_ysda g on g.yslsh=a.yslsh " +
                        " left join  da_sp_bxda h on h.bxbh=a.bxbh " +
                        " where substring(a.pzh,1,2)='CS'  " + self.GetSqlWhere()
            if (dynamicShowString.length == 0) {
                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
            }
            else {
                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
            }
        }
        else if (ywflag == "CR") {
            finishSql =" select " + dynamicShowStr +
                       " SUM(CASE djlx WHEN 1 THEN a.sl WHEN 2 THEN -a.sl END) zjsl, SUM(CASE djlx WHEN 1 THEN a.sl*a.lsj WHEN 2 THEN -a.sl*a.lsj END)/CASE WHEN SUM(CASE djlx WHEN 1 THEN a.sl WHEN 2 THEN -a.sl END)=0  THEN  1 ELSE  SUM(CASE djlx WHEN 1 THEN a.sl WHEN 2 THEN -a.sl END) END lsj,SUM(CASE djlx WHEN 1 THEN a.sl*a.lsj WHEN 2 THEN -a.sl*a.lsj END) lsjze," +
                       " SUM(CASE djlx WHEN 1 THEN a.sl*a.dpj WHEN 2 THEN -a.sl*a.dpj END)/CASE WHEN SUM(CASE djlx WHEN 1 THEN a.sl WHEN 2 THEN -a.sl END)=0  THEN  1 ELSE  SUM(CASE djlx WHEN 1 THEN a.sl WHEN 2 THEN -a.sl END) END dpj," +
                       " SUM(CASE djlx WHEN 1 THEN a.sl*a.dpj WHEN 2 THEN -a.sl*a.dpj END) dpjze," +
                       " SUM(CASE djlx WHEN 1 THEN a.hjjze WHEN 2 THEN -a.hjjze END) /CASE WHEN SUM(CASE djlx WHEN 1 THEN a.sl WHEN 2 THEN -a.sl END)=0  THEN  1 ELSE  SUM(CASE djlx WHEN 1 THEN a.sl WHEN 2 THEN -a.sl END) END jj,SUM(CASE djlx WHEN 1 THEN a.hjjze WHEN 2 THEN -a.hjjze END) jjze  " + dynamicShowStrEnd + " from (SELECT * FROM  dbo.yw_cg_cgrkdtz  UNION ALL  SELECT * FROM  dbo.yw_cg_cgrkdtz_ls)  a " +
                       " left join  da_sp_spda  b on a.spkh=b.spkh  " +
                       " left join  da_bmda c  on a.bmbh= c.bmbh  " +
                       " left join  da_sp_lbda d on d.lbbh=b.hplb " +
                       " left join  da_gysda e on e.gysbh=a.gysbh " +
                       " left join  (select * from da_qj_csb where  csfl='CG_CGFS') f on a.cgfs=f.csbh  " +
                       " left join  da_sp_ysda g on g.yslsh=a.yslsh " +
                       " left join  da_sp_bxda h on h.bxbh=a.bxbh " +
                       " left join(SELECT csbh rklxbh,csmc rklxmc FROM dbo.da_qj_csb WHERE csfl='RKLX') k on a.rkfs=k.rklxbh " +
                       " LEFT JOIN ( SELECT  ygbh ,                            ygmc                    FROM    da_ygda  ) R ON ygbh = a.jzr " +
            " where 1=1 " + self.GetSqlWhere()
            if (dynamicShowString.length == 0) {

                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
                finishSql += " order by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
            }
            else {
                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
                finishSql += " order by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
            }
        }
        else if (ywflag == "CT") {
            finishSql = " select " + dynamicShowStr +
                        " SUM(a.sl)  zjsl, sum(a.sl*a.lsj)/CASE WHEN SUM(a.sl)=0 THEN 1 else SUM(a.sl) END lsj,sum(a.sl*a.lsj) lsjze,sum(a.sl*a.dpj)/CASE WHEN SUM(a.sl)=0 THEN 1 else SUM(a.sl) END dpj,sum(a.sl*a.dpj) dpjze,sum(hjjze)/CASE WHEN SUM(a.sl)=0 THEN 1 else SUM(a.sl) END jj,sum(hjjze) jjze " + dynamicShowStrEnd + " from (SELECT * FROM  dbo.yw_cg_cgrkdtz  UNION ALL  SELECT * FROM  dbo.yw_cg_cgrkdtz_ls)  a " +
                        " left join  da_sp_spda  b on a.spkh=b.spkh  " +
                        " left join  da_bmda c  on a.bmbh= c.bmbh  " +
                        " left join  da_sp_lbda d on d.lbbh=b.hplb " +
                        " left join  da_gysda e on e.gysbh=a.gysbh " +
                        " left join  (select * from da_qj_csb where  csfl='CG_CGFS') f on a.cgfs=f.csbh  " +
                        " left join  da_sp_ysda g on g.yslsh=a.yslsh " +
                        " left join  da_sp_bxda h on h.bxbh=a.bxbh " +
                        " left join(SELECT csbh rklxbh,csmc rklxmc FROM dbo.da_qj_csb WHERE csfl='RKLX') k on a.rkfs=k.rklxbh " +
                        " LEFT JOIN ( SELECT  ygbh ,                            ygmc                    FROM    da_ygda  ) R ON ygbh = a.jzr " +
            " where  substring(a.pzh,1,2)='CT' " + self.GetSqlWhere()
            if (dynamicShowString.length == 0) {
                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
                finishSql += " order by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
            }
            else {
                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
                finishSql += " order by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
            }
        }

        else if (ywflag == "CZ") {
            finishSql =" select " + dynamicShowStr +
                       " SUM(a.sl) zjsl, sum(a.sl*a.lsj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) lsj,sum(a.sl*a.lsj) lsjze,sum(a.sl*a.dpj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) dpj,sum(a.sl*a.dpj) dpjze,sum(a.sl*a.jj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) jj,sum(a.sl*a.jj) jjze  " + dynamicShowStrEnd + " from  yw_cg_tzd_ew  a " +
                       " left join  da_sp_spda  b on a.spkh=b.spkh  " +
                       " left join  da_bmda c  on a.bmbh= c.bmbh  " +
                       " left join  da_sp_lbda d on d.lbbh=b.hplb " +
                       " left join  da_gysda e on e.gysbh=a.gysbh " +
                       " left join  (select * from da_qj_csb where  csfl='CG_CGFS') f on a.cgfs=f.csbh  " +
                       " left join  da_sp_ysda g on g.yslsh=a.yslsh " +
                       " left join  da_sp_bxda h on h.bxbh=a.bxbh " +
                       " where  a.djlx='1'and a.jzbz='1'  " + self.GetSqlWhere()
            if (dynamicShowString.length == 0) {
                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
                finishSql += " order by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
            }
            else {
                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
                finishSql += " order by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
            }
        }
        else if (ywflag == "CD") {
            finishSql =" select " + dynamicShowStr +
                       " SUM(a.sl) zjsl, sum(a.sl*a.lsj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) lsj,sum(a.sl*a.lsj) lsjze,sum(a.sl*a.dpj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) dpj,sum(a.sl*a.dpj) dpjze,sum(a.sl*a.jj)/(CASE WHEN SUM(a.sl)=0  THEN 1 ELSE  SUM(a.sl) END) jj,sum(a.sl*a.jj) jjze  " + dynamicShowStrEnd + " from  yw_cg_tzd_ew  a " +
                       " left join  da_sp_spda  b on a.spkh=b.spkh  " +
                       " left join  da_bmda c  on a.bmbh= c.bmbh  " +
                       " left join  da_sp_lbda d on d.lbbh=b.hplb " +
                       " left join  da_gysda e on e.gysbh=a.gysbh " +
                       " left join  (select * from da_qj_csb where  csfl='CG_CGFS') f on a.cgfs=f.csbh " +
                       " left join  da_sp_ysda g on g.yslsh=a.yslsh " +
                       " left join  da_sp_bxda h on h.bxbh=a.bxbh " +
                       " where  a.djlx='2' and a.jzbz='1'" + self.GetSqlWhere()
            if (dynamicShowString.length == 0) {
                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
                finishSql += " order by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd.substring(1, dynamicShowStringEnd.length);
            }
            else {
                finishSql += " group by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
                finishSql += " order by " + dynamicShowString.substring(0, dynamicShowString.length - 1) + dynamicShowStringEnd;
            }
        }
    
        requestor.ClipBoardNao(finishSql);
        finishSql = finishSql.replace(/\+/g, "%2B");
        finishSql = finishSql.replace(/\&/g, "%26");
        finishSql = finishSql.replace(/\%/g, "%25");
        dw_list.SetRedraw(false);
        webReq.Invoke("GetSnataxAndDataFromSql", "sql=" + finishSql);
        if (webReq.StatusCode() == 200) {

            syntax = webReq.ResponseText();
            dw_temp.SetFullState(syntax);
            //            dw_temp.Refresh();
            dw_temp.Modify("create compute(band=detail alignment='2' expression='getrow()' border='0' color='33554432' x='0' y='0' height='76' width='100' 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')");
            dw_list.SetFullState(dw_temp.GetFullState());
            var colCount = dw_list.Describe("DataWindow.Column.Count");
            gRowCount = dw_list.RowCount();
            self.Set_Width_DW(colCount);
            dw_list.SetRowSelection(1);

            if (rb_tb.GetChecked()) {
                dw_list.SetVisible(false);
                flash_1.SetVisible(true);
                self.UpdateChart();

            }
            if (rb_sp.GetChecked()) {
                curBbmc = rb_sp.GetName();
                dw_list.SetVisible(true);
                //dw_temp.SetVisible(true)
                flash_1.SetVisible(false);

                // DWSort(dw_format, dw_list);
                //#endregion
                //requestor.ClipBoard(dw_temp.Describe("datawindow.syntax"));

                dw_list.Modify(" create text(band=header alignment='2' text='序号' border='0' color='33554432' x='0' y='0' height='52' width='100' html.valueishtml='0'  name=hx_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' )")
                dw_list.Modify("hx_t.y='" + dw_list.Describe("zjsl_t.y") + "' hx_t.width='100'");
                dw_list.Modify("DataWindow.header.Height=76");
                self.SetValue(C_CheckValue, curBbmc, curCdbh, curYhbh);
            }

        } else {

            alert("error!");
        }
        //#region 格式保存#处理format
        //排序

        DWSort(dw_format, dw_list);

        //控制价格

        self.ControlPrice(jgtxlist, "jj");
        self.ControlPrice(jgtxlist, "lsj");
        self.ControlPrice(jgtxlist, "dpj");
        requestor.CloseLoading();
        //#endregion
        dw_list.SetRedraw(true);
    }
    //#endregion
    this.TBSelect = function () {
       
        if (ddlb_2.GetText().length > 0) {
            return ddlb_2.GetText().split("#")[1];
        }
        else {
            return "MSColumn3DLineDY";
        }
    }
    this.UpdateChart = function () {
        var type_list = "";
        if (rb_je.GetChecked()) {
            type_list = "lsjze";
        }
        if (rb_sl.GetChecked()) {
            type_list = "zjsl";
        }

        var GraphType = self.TBSelect();

        
        if (listvar == "类别") {
            listvar = "lbmc";
        }
        if (listvar == "款式") {
            listvar = "spkh";
        }
        if (listvar == "部门") {
            listvar = "bmmc";
        }
        if (listvar == "凭证号") {
            listvar = "pzh";
        }
        if (listvar == "日期") {
            listvar = "rq";
        }
        if (listvar == "采购方式") {
            listvar = "cgfs";
        }
        if (listvar == "订单方式") {
            listvar = "cgfs";
        }
        if (listvar == "供应商") {
            listvar = "gysmc";
        }
        if (listvar == "颜色") {
            listvar = "ysbh";
        }
        if (listvar == "版型") {
            listvar = "bxbh";
        }

        flash_1.Rewind();
        var xml = "";
        var strCat = "";
        var strAmtDS = "";
        var strQtyDS = "";
        if (GraphType == "MSColumn3DLineDY") {
            xml = "<chart caption='总数量，总金额图'  palette='2' animation='0' formatNumberScale='0' PYAXisName='总数量' SYAxisName='总金额' numberPrefix='$' labeldisplay='STAGGER' seriesNameInToolTip='0' showValues='0' plotSpacePercent='0'>";
            strCat = "<categories>";
            strAmtDS = "<dataset seriesname='总数量'>";
            strQtyDS = "<dataset seriesName='总金额' parentYAxis='S'>";
        }
        else {
            xml = "<graph showNames='1'  decimalPrecision='0' caption='总数量图'  palette='2' animation='0' formatNumberScale='0' >";
        }
        for (var row = 1; row <= dw_list.RowCount(); row++) {
            if (GraphType == "MSColumn3DLineDY") {
                strCat += "<category label='" + dw_list.GetItemString(row, listvar) + "' />";
                strAmtDS += "<set value='" + dw_list.GetItemNumber(row, "zjsl") + "' />";
                strQtyDS += "<set value='" + dw_list.GetItemNumber(row, "lsjze") + "' />";
            }
            else {
                xml += "<set name='" + dw_list.GetItemString(row, listvar) + "' value='" + dw_list.GetItemNumber(row, type_list) + "' />";
            }
        }
        if (GraphType == "MSColumn3DLineDY") {
            strCat += "</categories>";
            strAmtDS += "</dataset>";
            strQtyDS += "</dataset>";
            xml += strCat + strAmtDS + strQtyDS;
            xml += "<styles><definition><style type='font' name='CaptionFont' size='15' color='336699' /><style type='font' name='SubCaptionFont' bold='0' /></definition><application><apply toObject='caption' styles='CaptionFont' /><apply toObject='SubCaption' styles='SubCaptionFont' /></application></styles>";
            xml += "</chart>";
        }
        else {
            xml += "</graph>";
        }
        flash_1.LoadMovie("/FusionCharts/" + GraphType + ".swf");
        flash_1.SetFlashVars("dataXML=" + xml);
        xml = "";
        strCat = "";
        strAmtDS = "";
        strQtyDS = "";
    }

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

    this.Changebmbh = function (x, y, row, dwoName) {
        dwoName == "bmbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_CG_HZ_Base, "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=cgcx"), curW_OPEN_BMDA_NEW, null);
    }

    this.Changepinpai = function (x, y, row, dwoName) {
        dwoName == "ppbm";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_CG_HZ_Base, "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.Changegys = function (x, y, row, dwoName) {
        dwoName == "gysbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_CG_HZ_Base, "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_CG_HZ_Base, "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_CG_HZ_Base, "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_CG_HZ_Base, "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_CG_HZ_Base, "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.Changetzfs = function (x, y, row, dwoName) {
        dwoName == "csbh";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_CG_HZ_Base, "csbh", "csmc", "M", self)  // 这个用来给子窗口Set当前数据窗口

        if (ywflag == "CS" || ywflag == "CT" || ywflag == "CR" || ywflag == "CZ" || ywflag == "CD") {
            requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_da_qj_csb_cgfs_list&selectStyle=multiple"), curW_OPEN_SIMPLE_CHOSE, null);
        }
        else if (ywflag == "CG") {
            requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_pub_list_qj_csb_ddfs&selectStyle=multiple"), curW_OPEN_SIMPLE_CHOSE, null);
        }
    }
    //#endregion

    //#region 选中后赋值

    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 ("csbh" == difBh)
            sle_fs.SetText(val);
        else if ("mlbh" == difBh)
            sle_ml.SetText(val);
    }

    //#endregion


    this.PostOpen = function () {

        sle_bm.SetEnabled(false);
        sle_gys.SetEnabled(false);
        if (dw_format_hz == null) dw_format_hz = new DataWindow(requestor);
        dw_format_hz.Attach(requestor.Control("dw_format_hz"));

        if (dw_format_mx == null) dw_format_mx = new DataWindow(requestor);
        dw_format_mx.Attach(requestor.Control("dw_format_mx"));


        //        if (typeof (self.Exit) == "function")
        //            requestor.AttachEvent("btn_Exit", "Clicked", self.Exit);


        if (cbx_rkfs == null) {
            cbx_rkfs = new CheckBox(requestor);
            cbx_rkfs.Attach(requestor.Control("cbx_rkfs"));
        }
        if (cbx_fjsx1 == null) {
            cbx_fjsx1 = new CheckBox(requestor);
            cbx_fjsx1.Attach(requestor.Control("cbx_fjsx1"));
        }

   
        if (cbx_fjsx2 == null) {
            cbx_fjsx2 = new CheckBox(requestor);
            cbx_fjsx2.Attach(requestor.Control("cbx_fjsx2"));

        }
      
        if (cbx_fjsx3== null) {    
            cbx_fjsx3=new CheckBox(requestor);
            cbx_fjsx3.Attach(requestor.Control("cbx_fjsx3"));
            
        }  
        if (cbx_fjsx4 == null) {
            cbx_fjsx4 = new CheckBox(requestor);
            cbx_fjsx4.Attach(requestor.Control("cbx_fjsx4"));
            
        }

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

        if (sle_nf == null) sle_nf = new SingleLineEdit(requestor);
        sle_nf.Attach(requestor.Control("sle_nf"));

        var webReq_common = null;
        webReq_common = new WebRequestor();
        webReq_common.SetWebServiceUrl("/Service/ServiceForDwSyndax.ashx");

        webReq_common.Invoke("GetXbDa", "flag=TJ");
        if (webReq_common.StatusCode() == 200) {
            ddlb_sex.Reset()

            var xbmc = webReq_common.ResponseText()
            if (xbmc.length > 0) {
                for (var i = 0; i < xbmc.split(",").length; i++) {
                    ddlb_sex.AddItem(xbmc.split(",")[i])
                }
            }
            //   alert(webReq_common.ResponseText())
        }

        //        dw_format_hz = window.external.Control("dw_format_hz");
        //        dw_format_mx = window.external.Control("dw_format");
        Exel_FH_Flag = GetGlobalParm("Excel_FH_Flag", "Excel_FH_Flag", "qybz");
        if (Exel_FH_Flag.length < 1) {
            Exel_FH_Flag = "1";
        }
        ywflag = requestor.GetParm("ywflag");
        curYhbh = requestor.GetParm("curYhbh");
        curCdbh = requestor.GetParm("curCdbh");
        curUserId = requestor.GetParm("curYhbh");
        curYhmc = requestor.GetParm("curYhmc"); //curYhmc
        jgtxlist = requestor.GetParm("curjgqx");
        curQDID = requestor.GetParm("curQDID");
        ddlb_2.SetText("3D饼状图#Pie3D");
        rb_sp.SetChecked(true);
        rb_sl.SetEnabled(false);
        rb_je.SetEnabled(false);
        dp_1.SetValue(UtcDateFormatToString(new Date().getVarDate()));
        dp_2.SetValue(UtcDateFormatToString(new Date().getVarDate()));
        var v_CheckBoxState = GetCheckBoxValue(dw_format, curYhbh, curCdbh, curBbmc);
        if (v_CheckBoxState.length > 1)
        { window.eval(v_CheckBoxState); }

        curJgtx = requestor.GetParm("curjgqx");
        ExistGYS = ExistJG(curJgtx, "gysbh");
        // 供应商
        if (ExistGYS == "N") {
            cbx_gys.SetEnabled(false);
            cbx_gys.SetChecked(false);
            cb_3.SetEnabled(false);

        }
        else {
            cbx_gys.SetEnabled(true);
            cb_3.SetEnabled(true);
        }
        curSelDays = requestor.GetParm("seldays");
        cursjcd = GetYHMKQX();
        //alert("cursjcd=" + cursjcd)
        curPzh = requestor.GetParm("pzh");
        curBbmc = requestor.GetParm("bbmc");
        curBbfl = requestor.GetParm("bbfl");
        var context = curPzh + "#" + curBbmc + "#" + curBbfl;
        self.SetBBMC(context, "1");
        if (curOptype == "1" && curBBMCNew.length > 0) {
            sle_formatname.SetText(curBBMCNew);
            self.ClearAndTJ(true);
        } else {
            sle_formatname.SetText("");
            curBBPZH = "";
        } 
   
    }
    //#region Function GetSqlWhere
    this.GetSqlWhere = function () {
        var realSql = "";
        // var curYhbh = requestor.GetParm("curYhbh")
        var beginDate = UtcDateFormatToString(dp_1.GetValue());
        var endDate = UtcDateFormatToString(dp_2.GetValue());
        var curPzh = sle_pzh.GetText();
        var curKh = sle_kh.GetText();
        var curBm = sle_bm.GetText();
        var curPp = sle_pp.GetText();
        var curGys = sle_gys.GetText();
        var curLb = sle_lb.GetText();
        var curJj = sle_jj.GetText();
        var curFs = sle_fs.GetText();
        var curMl = sle_ml.GetText();
        var curSex = ddlb_sex.GetText();
        //var curspbh = sle_spbh.GetText();
        var curNF = sle_nf.GetText();
        var tempBeginDate = "";
        if (curSelDays != "-1") {

            tempBeginDate = compareDate(curSelDays, beginDate);
            realSql += " and (CONVERT(date,a.kdrq) between '" + tempBeginDate + "' and '" + endDate + "')";
        }
        else {
            realSql += " and (CONVERT(date,a.kdrq) between '" + beginDate + "' and '" + endDate + "')";
        }
        if (curKh.length > 0) {

            var is_quotes = curKh.substring(0, 1);
            if (is_quotes == "%") {

                realSql += " and a.spkh like('" + curKh + "%')";
            }
            else {
                var curflag = curKh.substr(curKh.length - 1, 1);

                if (curflag == "," || curflag == "，") {
                    curKh = curKh.substring(0, curKh.length - 1);
                    var tempspkh = self.GetQuotes(curKh);
                    realSql += " and a.spkh in(" + tempspkh + ")";
                }
                else {
                    if (is_quotes == "'") {
                        realSql += " and a.spkh in(" + curKh + ")";
                    }
                    else {
                        realSql += " and a.spkh like('" + curKh + "%')";
                    }
                }
            }
        }

        if (curBm.length > 0) {
            var is_quotes = curBm.substring(0, 1);
            if (is_quotes == "'") {
                realSql += " and a.bmbh in(" + curBm + ")";
            }
            else {
                var tempspkh = self.GetQuotes(curBm);
                realSql += " and a.bmbh in(" + tempspkh + ")";
            }
        } else {
            realSql += "and a.bmbh in(select bmbh  from da_qx_bmqxsz where yhbh = '" + curYhbh + "'and cgcx = '1')"
        }

        if (curPp.length > 0) {

            var is_quotes = curPp.substring(0, 1);
            if (is_quotes == "'") {
                realSql += " and jypp in(" + curPp + ")";
            } else {
                var tempspkh = self.GetQuotes(curPp);
                realSql += " and jypp in(" + tempspkh + ")";

            }
        }

        if (curGys.length > 0) {

            var is_quotes = curGys.substring(0, 1);
            if (is_quotes == "'") {
                realSql += " and a.gysbh in(" + curGys + ")";
            }
            else {
                var tempspkh = self.GetQuotes(curGys);
                realSql += " and a.gysbh in(" + tempspkh + ")";

            }
        } else {

            realSql += "and a.gysbh in(select gysbh  from da_qx_gysda where yhbh = '" + curYhbh + "'and bz3 = '1')"
        }

        if (curLb.length > 0) {

            var is_quotes = curLb.substring(0, 1);
            if (is_quotes == "'") {
                realSql += " and b.hplb in(" + curLb + ")";
            }
            else {
                var tempspkh = self.GetQuotes(curLb);
                realSql += " and b.hplb in(" + tempspkh + ")";

            }
        }

        if (curJj.length > 0) {

            var is_quotes = curJj.substring(0, 1);
            if (is_quotes == "'") {
                realSql += " and b.spjj in(" + curJj + ")";
            } else {
                var tempspkh = self.GetQuotes(curJj);
                realSql += " and b.spjj in(" + tempspkh + ")";
            }
        }

        if (curFs.length > 0) {

            var is_quotes = curFs.substring(0, 1);
            if (is_quotes == "'") {
                realSql += " and a.cgfs in(" + curFs + ")";
            } else {
                var tempspkh = self.GetQuotes(curFs);
                realSql += " and a.cgfs in(" + tempspkh + ")";
            }
        }

        if (curMl.length > 0) {

            var is_quotes = curMl.substring(0, 1);
            if (is_quotes == "'") {
                realSql += " and b.spml in(" + curMl + ")";
            } else {
                var tempspkh = self.GetQuotes(curMl);
                realSql += " and b.spml in(" + tempspkh + ")";
            }
        }
        if (curPzh.length > 0) {

            var is_quotes = curPzh.substring(0, 1);
            if (is_quotes == "'") {
                realSql += " and a.pzh in(" + curPzh + ")";
            } else {
                var tempspkh = self.GetQuotes(curPzh);
                realSql += " and a.pzh in(" + tempspkh + ")";
            }
        }
        //        if (curspbh.length > 0) {

        //            var is_quotes = curspbh.substring(0, 1);
        //            if (is_quotes == "'") {
        //                realSql += " and a.spbh in(" + curspbh + ")";
        //            } else {
        //                var tempspkh = self.GetQuotes(curspbh);
        //                realSql += " and a.spbh in(" + tempspkh + ")";
        //            }

        //        }
        if (curSex.length > 0) {
            realSql += " and b.spxb ='" + curSex + "'";

        }
        if (curNF.length > 0) {
                realSql += " and  b.spnf in (" + curNF + ")";
        }
        return realSql;
    }
    //#endregion

    //#region Function DealWords
    this.DealWords = function (words) {

        if (!(words.charAt(0) == "'"))
            words = "'" + words + "'";

        return words;

    }
    //#endregion

    //#region 处理引号的问题
    this.GetQuotes = function (curValue) {
        var temp1 = curValue.split(",")
        var ret_Value = "";
        for (var i = 0; i < temp1.length; i++) {
            if (ret_Value.length > 0) {
                ret_Value += "'" + temp1[i] + "',";
            }
            else {
                ret_Value = "'" + temp1[i] + "',"
            }
        }
        return ret_Value.substr(0, ret_Value.length - 1);
    }
    //#endregionS

    //#region dw 宽度调整
    this.Set_Width_DW = 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 "xh":
                    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 "bmmc":
                    ls_columntitle = "部门名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "jzr":
                    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 "jldw":
                    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 "pzh":
                    ls_columntitle = "凭证号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    break;
                case "cgfs":
                    if (ywflag == "CT" || ywflag == "CR") {
                        ls_columntitle = "采购方式";
                    }
                    else if (ywflag == "CG" || ywflag == "CS") {
                        ls_columntitle = "订单方式";
                    }
                    else if (ywflag == "CZ" || ywflag == "CD") {
                        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 = '" + 400 + "'");
                    break;
                case "lbbh":
                    ls_columntitle = "类别编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "lbmc":
                    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 "zjsl":
                    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 "jjze":
                    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 "lsjze":
                    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 "dpjze":
                    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 "jj":
                    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 "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 "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 "ysbh":
                    ls_columntitle = "颜色编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "ysmc":
                    ls_columntitle = "颜色名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "bxbh":
                    ls_columntitle = "版型编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "bxmc":
                    ls_columntitle = "版型名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;

                case "rklxmc":
                    ls_columntitle = "入库方式";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;

                case "fjsx1mc":
                    ls_columntitle = cbx_fjsx1.GetText();
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 350 + "'");
                    break;
                case "fjsx2mc":
                    ls_columntitle = cbx_fjsx2.GetText();
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 350 + "'");
                    break;
                case "fjsx3mc":
                    ls_columntitle = cbx_fjsx3.GetText();
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 350 + "'");
                    break;
                case "fjsx4mc":
                    ls_columntitle = cbx_fjsx4.GetText();
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 350 + "'");
                    break;

            }
        }
        self.SetSummary();
    }
    //#endregion 
    
    //#region 合计列
    this.SetSummary = function () {
        var ls_bqkcx = "";
        var ls_lswidth = "";
        var ls_syntax = '';
        var ls_bqkcwidth = "";
        var ls_bqrkwidth = "";

        var ls_bmbhx = dw_list.Describe("bmbh.x");
        var ls_bmbhy = dw_list.Describe("bmbh.y");
        var ls_bmbhwidth = dw_list.Describe("bmbh.width");

        ls_slx = dw_list.Describe("zjsl.x");
        ls_slwidth = dw_list.Describe("zjsl.width")
        ls_lszjex = dw_list.Describe("lsjze.x");
        ls_lszjewidth = dw_list.Describe("lsjze.width")
        ls_jjzex = dw_list.Describe("jjze.x");
        ls_jjzewidth = dw_list.Describe("jjze.width")

        ls_dpjzex = dw_list.Describe("dpjze.x");
        ls_dpjzewidth = dw_list.Describe("dpjze.width")

        ls_syntax = dw_list.Modify("DataWindow.summary.Height=90");
        ls_syntax = ls_syntax + " create text(band=summary alignment='1'  text='合计:' border='0' color='128' x='" + ls_bmbhx + "'  y='8' height='53' width='" + ls_bmbhwidth + "' html.valueishtml='0'   name=hj 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')"
        ls_syntax = ls_syntax + " create compute(band=summary alignment='1' expression='sum(lsjze  for all)' border='0' color='128' x='" + ls_lszjex + "' y='8' height='52' width='" + ls_lszjewidth + "' name=sum_lsjze  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(jjze  for all)' border='0' color='128' x='" + ls_jjzex + "' y='8' height='52' width='" + ls_jjzewidth + "' name=sum_jjze  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(zjsl  for all)' border='0' color='128' x='" + ls_slx + "' y='8' height='52' width='" + ls_slwidth + "' name=sum_zjsl  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='#####')"
        ls_syntax = ls_syntax + " create compute(band=summary alignment='1' expression='sum(dpjze  for all)' border='0' color='128' x='" + ls_dpjzex + "' y='8' height='52' width='" + ls_dpjzewidth + "' name=sum_dpjze  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 

    //#region exit
    this.Exit = function () {
        setTimeout("window.close()", 100);
    }
    //#endregion

    this.ControlPrice = function (str1, str2) {
        //alert([str1, str2])
        var s = str1.indexOf(str2);

        if (s > -1) {

        }
        else {
            if (str2 == "jj") {
                dw_list.Modify("jj.visible='0'");
                dw_list.Modify("jjze.visible='0'");
            }
            else if (str2 == "lsj") {
                dw_list.Modify("lsj.visible='0'");
                dw_list.Modify("lsjze.visible='0'");
            }
            else if (str2 == "dpj") {
                dw_list.Modify("dpj.visible='0'");
                dw_list.Modify("dpjze.visible='0'");
            }
        }
    }

    //#region 打印处理
    this.Print = function () {
        var curHeadString_rq = "";
        var curHeadString = "";
        var curFootString = "";
        var ywflag = requestor.GetParm("ywflag");
        var rq1 = UtcDateFormatToString(dp_1.GetValue())
        var rq2 = UtcDateFormatToString(dp_2.GetValue())
        if (rq1 == rq2) {
            curHeadString_rq = "日期：" + rq1
        } else {
            curHeadString_rq = "日期：" + rq1 + "到" + rq2 + "之间"
        }

        //#region 条件显示
        var bmmc = sle_bm.GetText();
        var curHeadStringBM = Report_Print(bmmc, "BM"); 

        var gysmc = sle_gys.GetText();
        var curHeadStringGYS = Report_Print(gysmc, "GYS"); 
        
        var ppmc = sle_pp.GetText();
        var curFootStringPP = Report_Print(ppmc, "PP"); 
        
        var khmc = sle_kh.GetText();
        var curFootStringKH = Report_Print(khmc, "KH"); 
        
        var fsmc = sle_fs.GetText();
        var curFootStringFS = Report_Print(fsmc, "CGFS"); 
        
        var lbmc = sle_lb.GetText();
        var curFootStringLB = Report_Print(lbmc, "LB"); 
        
        var jjmc = sle_jj.GetText();
        var curFootStringJJ = Report_Print(jjmc, "JJ");
        
        var mlmc = sle_ml.GetText();
        var curFootStringML = Report_Print(mlmc, "ML");

        //#endregion

        var curTitleName = ""
        if (ywflag == "CG") {
            curTitleName = "采购订单【汇总分析】";
        } else if (ywflag == "CR") {
            curTitleName = "采购入库单【汇总分析】";
        } else if (ywflag == "CS") {
            curTitleName = "采购退货申请单【汇总分析】";
        } else if (ywflag == "CT") {
            curTitleName = "采购退货【汇总分析】";
        } else if (ywflag == "CZ") {
            curTitleName = "采购通知单【汇总分析】";
        } else if (ywflag == "CD") {
            curTitleName = "采购退货通知单【汇总分析】";
        }
        curFootString = "制单人：" + curYhmc + "&&&【" + GetErpProductTypeName() + "】" + UtcDateTimeFormatToString(new Date().getVarDate()) +
                    "&&&" + curFootStringPP + "," + curFootStringKH + "," + curFootStringFS + "," + curFootStringLB +
                    "," + curFootStringJJ + "," + curFootStringML

        curHeadString = curHeadString_rq + "&&&" + curHeadStringBM + "&&&" + curHeadStringGYS; 
        A8erp_Report.NaoErpReportPrint(dw_list, curTitleName, curHeadString, curFootString);
    }
    //#endregion

    //#region 设置报表名称和凭证号

    this.SetBBMC = function (context, optype) {
        if (context.length > 0) {
            curBBPZH = context.split("#")[0];
            curBBMCNew = context.split("#")[1];
            isFirstSave = context.split("#")[2];
            if (optype == "1") {
                curBbmc = context.split("#")[2];
                self.SetBbfl(curBbmc);
            }
        }
        curOptype = optype;
    }
    //#endregion

    //#region 报表格式选择
    this.SelectGS = function () {
        self.SelectBBFL();
        cur_Open_Window = new W_Base_BB_List();
        cur_Open_Window.SetParentWindow(self);
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.KuCun.TongJiFenXi.Base.W_Base_BB_List" + "&opFlag=PF" + "&FunID=" + curCdbh + "&bbfl=" + curBbmc + "&dataObject=dw_pub_all_report_format_hz"), cur_Open_Window, null);

        if (curOptype == "1" && curBBMCNew.length > 0) {
            sle_formatname.SetText(curBBMCNew);
            self.ClearAndTJ(true);
        } else {
            sle_formatname.SetText("");
            curBBPZH = "";
        }
        //刷新
    }
    //#endregion

    //#region 格式保存#报表格式清空
    this.ReportClare = function () {
        var tempPzh = "";
        if (dw_format_hz.RowCount() > 0) {
            tempPzh = dw_format_hz.GetItemString(1, "pzh");
        }
//        if (tempPzh.length <= 0 || sle_formatname.GetText().length <= 0) {
//            requestor.MessageBox("提示", "请先选择报表格式", ICON.StopSign);
//            return;
//        }
        dw_format_mx.Reset();
        dw_format_hz.Reset();
        sle_formatname.SetText("");
        self.TongJi();
    }
    this.ClearAndTJ = function (isTj) {
        dw_format_hz.RetrieveEx("pzh='" + curBBPZH + "'");
        dw_format_mx.RetrieveEx("pzh='" + curBBPZH + "'");
        dw_format_mx.SetFilter("mrgxtj='1'");
        dw_format_mx.Filter();
        xsmrgs = dw_format_mx.RowCount();
        cbx_rq.SetChecked(false);
        cbx_pzh.SetChecked(false);
        cbx_bm.SetChecked(false);
        cbx_ks.SetChecked(false);
        cbx_lb.SetChecked(false);
        cbx_gys.SetChecked(false);
        cbx_fs.SetChecked(false);
        cbx_bx.SetChecked(false);
        cbx_ys.SetChecked(false);
        cbx_fjsx1.SetChecked(false);
        cbx_fjsx2.SetChecked(false);
        cbx_fjsx3.SetChecked(false);
        cbx_fjsx4.SetChecked(false);

        //界面控制
        var evealStr = "";
        for (var i = 1; i <= dw_format_mx.RowCount(); i++) {
            evealStr += dw_format_mx.GetItemString(i, "col") + ".SetChecked(true);";
        }
        eval(evealStr);

        dw_format_mx.SetFilter("");
        dw_format_mx.Filter();
        dw_format_mx.SetFilter("mrgxtj='0'");
        dw_format_mx.Filter();
        if (isTj == true) {
            //self.TongJi();
            if (dw_format_mx.RowCount() <= 0) {
                sle_formatname.SetText("");
            }
        }
    }
    //#endregion

    //#region 横向/纵向

    this.SetBbfl = function (bbfl) {
        if (bbfl == "rb_sp") {
            rb_sp.SetChecked(true);
        }
    }
    //#endregion

    //#region 保存
    this.SaveGS = function () {
        self.SelectBBFL();

        //curBBMCNew = "";
        if (curBbmc.length > 0) {
            cur_Open_Window = new W_Base_SaveOP();
            cur_Open_Window.SetParentWindow(self, curCdbh);
            requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.KuCun.TongJiFenXi.Base.W_Base_SaveOP" + "&opFlag=PF" + "&Bbfl=" + curBbmc + "&dataObject=dw_kctjfx_top"), cur_Open_Window, null);
        }
        if (curBBMCNew.length <= 0 || curOptype != 0) {
            return;
        }
        sle_formatname.SetText(curBBMCNew);
        self.ReportSave();
    }
    //#endregion

    //#region 获取报表分类
    this.SelectBBFL = function () {

        if (rb_sp.GetChecked()) {
            curBbmc = "rb_sp";
        }

    }
    //#endregion 

    //#region 提交
    this.ReportSave = function () {
        self.PropertCheckStatus();
        var msg = ReportSaveEx(dw_list, dw_format_hz, dw_format_mx, curYhbh, curCdbh, curBbmc, curBBPZH, curYhbh, curBBMCNew, ChildDWCheckValue, jgtxlist, isFirstSave);
        if (msg == "OK") {
            requestor.MessageBox("提示", "保存成功", ICON.Information);
            dw_format_mx.ResetUpdate();
            dw_format_mx.SetFilter("mrgxtj='1'");
            curCol = requestor.GetParm("curCol");
            dw_format_mx.Filter();
            xsmrgs = dw_format_mx.RowCount();
            dw_format_mx.SetFilter("");
            dw_format_mx.Filter();
            dw_format_mx.SetFilter("mrgxtj='0'");
            dw_format_mx.Filter();
            self.TongJi();
            return;
        }
        else {
            requestor.MessageBox("提示", msg, ICON.StopSign);
        }
    }
    //#endregion

    //#region 获取被选中复选框
    this.PropertCheckStatus = function () {
        ChildDWCheckValue = "";
        //日期
        if (cbx_rq.GetChecked()) {
            ChildDWCheckValue += "cbx_rq,"
        }
        //凭证号
        if (cbx_pzh.GetChecked()) {
            ChildDWCheckValue += "cbx_pzh,"
        }
        //部门
        if (cbx_bm.GetChecked()) {
            ChildDWCheckValue += "cbx_bm,"
        }
        //款式
        if (cbx_ks.GetChecked()) {
            ChildDWCheckValue += "cbx_ks,"
        }
        //类别
        if (cbx_lb.GetChecked()) {
            ChildDWCheckValue += "cbx_lb,"
        }
        //供应商
        if (cbx_gys.GetChecked()) {
            ChildDWCheckValue += "cbx_gys,"
        }
        //方式
        if (cbx_fs.GetChecked()) {
            ChildDWCheckValue += "cbx_fs,"
        }
        //方式
        if (cbx_bx.GetChecked()) {
            ChildDWCheckValue += "cbx_bx,"
        }
        if (cbx_ys.GetChecked()) {
            ChildDWCheckValue += "cbx_ys,"
        }
        if (cbx_fjsx1.GetChecked()) {
            ChildDWCheckValue += "cbx_fjsx1,"
        }
        if (cbx_fjsx2.GetChecked()) {
            ChildDWCheckValue += "cbx_fjsx2,"
        }
        if (cbx_fjsx3.GetChecked()) {
            ChildDWCheckValue += "cbx_fjsx3,"
        }
        if (cbx_fjsx4.GetChecked()) {
            ChildDWCheckValue += "cbx_fjsx4,"
        }
    }
    //#endregion

    //#region 定义title高度
    this.A8erp_Report_Header_Row_Height = function (curDw_List) {
        curDw_List.Modify("datawindow.header.height='76'");
    }
    //#endregion

    //#region 定义Detail高度
    this.A8erp_Report_Detail_Row_Height = function (curDw_List) {
        curDw_List.Modify("datawindow.detail.height='76'");
    }
    //#endregion

    //#region 定义单据样式

    this.A8erp_Report_Style = function (curDw_List) {//67108864    15780518
        curDw_List.Modify("datawindow.detail.color='67108864' datawindow.detail.gradient.color='16777215' datawindow.detail.brushmode='1' ")
    }
    //#endregion

    //#region FormatSave
    this.FormatSave = function () {
        dw_list.SetRedraw(false);
        dw_format_mx.SetRedraw(false);

        //        if (curcbx_gs != xsmrgs) {
        //            dw_list.Modify("cm1.Format='###' cm2.Format='###' cm3.Format='###' cm4.Format='###' cm5.Format='###' cm6.Format='###' cm7.Format='###' cm8.Format='###' cm9.Format='###' cm10.Format='###' cm11.Format='###' cm12.Format='###' cm13.Format='###' cm14.Format='###' cm15.Format='###' cm16.Format='###' cm17.Format='###' cm18.Format='###' cm19.Format='###' cm20.Format='###' cm21.Format='###' cm22.Format='###' cm23.Format='###' cm24.Format='###' cm25.Format='###' cm26.Format='###' cm27.Format='###' cm28.Format='###' cm29.Format='###' cm30.Format='###' cm31.Format='###' cm32.Format='###' cm33.Format='###' cm34.Format='###' cm35.Format='###'");
        //            if (Exel_FH_Flag == "1") {
        //                dw_list.Modify("DataWindow.Sparse='spkh\tksmc\tjldw\tysbh\tysmc\tbxbh\tbxmc'");
        //            }
        //            return
        //        }
        dw_format_mx.SetSort("col_x A");
        dw_format_mx.Sort();
        for (var i = 1; i <= dw_format_mx.RowCount(); i++) {
            var curCol = dw_format_mx.GetItemString(i, "col");

            var curVisible = dw_format_mx.GetItemString(i, "visible");
            dw_list.Modify(curCol + ".visible='0'");
            dw_list.Modify(curCol + ".visible='" + curVisible + "'");

            var curWidth = dw_format_mx.GetItemNumber(i, "width");
            dw_list.Modify(curCol + ".width='" + curWidth + "'");

            var curColHz = dw_format_mx.GetItemString(i, "col_hz");
            dw_list.Modify(curCol + "_t.Text='" + curColHz + "'");

            var curfont_face = dw_format_mx.GetItemString(i, "font_face");
            dw_list.Modify(curCol + ".Font.Face='" + curfont_face + "'");

            var curfont_height = dw_format_mx.GetItemString(i, "font_height");
            dw_list.Modify(curCol + ".Font.Height='" + curfont_height + "'");

            var curfont_weight = dw_format_mx.GetItemString(i, "font_weight");
            dw_list.Modify(curCol + ".Font.Weight='" + curfont_weight + "'");

            var curfont_italic = dw_format_mx.GetItemString(i, "font_italic");
            dw_list.Modify(curCol + ".Font.Italic='" + curfont_italic + "'");

            var curfont_underline = dw_format_mx.GetItemString(i, "font_underline");
            dw_list.Modify(curCol + ".Font.Underline='" + curfont_underline + "'");

            var curCol_border = dw_format_mx.GetItemString(i, "col_border");
            dw_list.Modify(curCol + ".Border='" + curCol_border + "'");

            var ls_color = dw_format_mx.GetItemString(i, "color");
            dw_list.Modify(curCol + ".Color='" + curCol_border + "'");

            var ls_format = dw_format_mx.GetItemString(i, "format");
            dw_list.Modify(curCol + ".Format='" + ls_format + "'");

            var ls_alignment = dw_format_mx.GetItemString(i, "alignment");
            dw_list.Modify(curCol + ".Alignment='" + ls_alignment + "'");

            var ls_alignment = dw_format_mx.GetItemString(i, "tabsequence");
            dw_list.Modify(curCol + ".TabSequence='" + ls_alignment + "'");

            var li_bg_mode = dw_format_mx.GetItemString(i, "bg_mode");
            dw_list.Modify(curCol + ".Background.Mode='" + li_bg_mode + "'");

            var ls_bg_color = dw_format_mx.GetItemString(i, "bg_color");
            dw_list.Modify(curCol + ".Background.Color='" + ls_bg_color + "'");
        }
        dw_format_mx.SetRedraw(true);
        dw_list.SetRedraw(true);

        //#endregion
    }

    //#endregion

    //#region 格式保存#报表列格式操作
    this.ReportOp = function () {
        if (curBBPZH.length <= 0 || sle_formatname.GetText().length <= 0) {
            requestor.MessageBox("提示", "请先选择报表格式", ICON.StopSign);
            return;
        }
        curW_Base_Report_Open_Mx_Ex.SetDataWindow(self, curUserId, curCdbh, curBbmc, curBBPZH, "curParent.ClearAndTJ(true);");
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.Base.W_Base_Report_Open_Mx_Ex"), curW_Base_Report_Open_Mx_Ex, null);
        dw_format_hz.RetrieveEx("pzh='" + curBBPZH + "'");
        dw_format_mx.RetrieveEx("pzh='" + curBBPZH + "'");
    }
    //#endregion

    //#region  执行查询
    this.TongJi = function () {
        dw_list.SetRedraw(false);
        curcbx_gs = 0;
        //self.GetTableYM();
        if (rb_sp.GetChecked()) {
            self.Query(); //规格
            // dw_list.Modify("cm1.Format='###' cm2.Format='###' cm3.Format='###' cm4.Format='###' cm5.Format='###' cm6.Format='###' cm7.Format='###' cm8.Format='###' cm9.Format='###' cm10.Format='###' cm11.Format='###' cm12.Format='###' cm13.Format='###' cm14.Format='###' cm15.Format='###' cm16.Format='###' cm17.Format='###' cm18.Format='###' cm19.Format='###' cm20.Format='###' cm21.Format='###' cm22.Format='###' cm23.Format='###' cm24.Format='###' cm25.Format='###' cm26.Format='###' cm27.Format='###' cm28.Format='###' cm29.Format='###' cm30.Format='###' cm31.Format='###' cm32.Format='###' cm33.Format='###' cm34.Format='###' cm35.Format='###'");
            if (Exel_FH_Flag == "1") {
                dw_list.Modify("DataWindow.Sparse='spkh\tksmc\tjldw\tysbh\tysmc\tbxbh\tbxmc'");
            }
            self.FormatSave();
            dw_list.SetSort("spkh,ksmc,v.ysbh,v.ysmc,v.bxbh,v.bxmc");
            dw_list.Sort();
            //给Title加颜色。。
            dw_list.SetRedraw(true);
            A8erp_Report.ReportDataWindowHeaderColor(dw_list);
            self.A8erp_Report_Style(dw_list);
            self.A8erp_Report_Header_Row_Height(dw_list, false);
            self.A8erp_Report_Detail_Row_Height(dw_list);
            //JS样式。
        }
        if (rb_tb.GetChecked()) {
            self.Query(); // 款式
            dw_list.SetSort("spkh,ksmc,v.ysbh,v.ysmc,v.bxbh,v.bxmc");
            dw_list.Sort();
        }
        

        //requestor.ClipBoard(dw_list.Describe("datawindow.syntax"))

    }
    //#endregion

    //#region SetValue
    this.SetValue = function (str1, str2, str3, str4) {

        ChildDWCheckValue = str1;
        curBbmc = str2;
        curCdbh = str3;
        curUserId = str4;
    }
    //#endregion
    //#region 双击标题排序
    this.DoubleClickedSort = 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();
            }
        }
    }
    //#endregion
    

    //#region 图片预览
    this.picpreview = function () {
        var cloumCount = 0;
        var cloumName = "";
        cloumCount = parseInt(dw_list.Describe("datawindow.column.count"));
        for (var i = 1; i <= cloumCount; i++) {
            cloumName += dw_list.Describe("#" + String(i) + ".name")
        }
        if (cloumName.indexOf("spkh") > -1) {
            var curRow = dw_list.GetRow();
            //图片的跳转
            if (curRow > 0) {
                var curspkh = dw_list.GetItemString(curRow, "spkh")
                var picuploadflag = 0;
                curW_KC_PIC.SetDataWindow(dw_list, curspkh, self, picuploadflag, "");
                requestor.Open("/Service/LoadWindow.ashx?WinName= A8ERP.KuCun.TongJiFenXi.W_KC_PIC&curSpkh=" + curspkh, curW_KC_PIC);
            }
        } else {
            requestor.MessageBox("提示", "请选择款号条件统计后再预览图片!", ICON.Information);
        }


    }
    //#endregion


    //#region 右键保存
    this.RightKey = function () {
        if (sle_formatname.GetText().toString().length > 0) {
            self.ReportSave();
        }
        else {
            requestor.MessageBox("提示", "请选择格式后再保存!", ICON.Information);
        }
    }
    //#endregion

    
    //#region  双击pzh
    this.DoubleClicked = function (x, y, row, dwoname) {
        if (dwoname.indexOf("_t") < 0) {
            if (dwoname == "pzh") {

                //获取pzh
                var curpzh = "";
                var ywflag = "";
                var curRow = dw_list.GetRow();
                if (curRow > 0) {
                    curpzh = dw_list.GetItemString(curRow, "pzh");
                    ywflag = curpzh.substring(0, 2)
                    //反调到原单据    
                    if (ywflag == "CR") {
                        self.OpenSheet("SJ006", "采购入库单", curpzh, "");

                    }
                    if (ywflag == "CT") {
                        self.OpenSheet("SJ090", "采购退货单", curpzh, "");
                    }

                }
            } 
        }
    }
    //#endregion

    //#region 跟踪单据


    this.OpenSheet = function (itemData, itemLabel, hyh, gysbh) {
        var tempitemData = itemData.substring(2, 5);

        var s = cursjcd.indexOf(tempitemData);
 
        if (s > -1) {
            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);
        }
        else{
            alert("您无此权限，请联系管理员！！")
        }

    }
    //#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);
    }
}
