///<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_JQCM_CGDD.prototype = new W_CG_HZ_Base( ); 

function W_JQCM_CGDD() {

    var self = this;
    var requestor = new PBWindow();
    var cbx_bzxx = new CheckBox(requestor);
    var cbx_gys = new CheckBox(requestor);
    var cbx_pzh = new CheckBox(requestor);
    var rb_zx = new RadioButton(requestor);
    var rb_hx = new RadioButton(requestor);
    var cbx_lb = new CheckBox(requestor);
    var cbx_fs = new CheckBox(requestor);
    var cbx_bm = new CheckBox(requestor);
    var cbx_rq = new CheckBox(requestor);
    var sle_pzh = new SingleLineEdit(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 sle_pp = new SingleLineEdit(requestor);
    var sle_bm = new SingleLineEdit(requestor);
    var dp_2 = new DatePicker(requestor);
    var dp_1 = new DatePicker(requestor);
    var dw_list = new DataWindow(requestor);
    var dw_temp = new DataWindow(requestor);
    var dw_format = new DataWindow(requestor);
    var dw_1 = new DataWindow(requestor);
    var tb_1 = new ToolStrip(requestor);
    var sle_spbh = new SingleLineEdit(requestor);
    var ddlb_sex = new DropDownListBox(requestor);
    var ddlb_nf = new DropDownListBox(requestor);
    var cb_3 = new CommandButton(requestor);
    var sle_formatname = new SingleLineEdit(requestor);
    var ContextMenuStrip1 = new ContextMenu(requestor);

    var cbx_hbzxx = new CheckBox(requestor);

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

        if (requestor == null) requestor = new PBWindow();
        requestor.Attach(win);
        if (cbx_bzxx == null) cbx_bzxx = new CheckBox(requestor);
        cbx_bzxx.Attach(win.Control("cbx_bzxx"));
        if (cbx_gys == null) cbx_gys = new CheckBox(requestor);
        cbx_gys.Attach(win.Control("cbx_gys"));
        if (cbx_pzh == null) cbx_pzh = new CheckBox(requestor);
        cbx_pzh.Attach(win.Control("cbx_pzh"));
        if (rb_zx == null) rb_zx = new RadioButton(requestor);
        rb_zx.Attach(win.Control("rb_zx"));
        if (rb_hx == null) rb_hx = new RadioButton(requestor);
        rb_hx.Attach(win.Control("rb_hx"));
        if (cbx_lb == null) cbx_lb = new CheckBox(requestor);
        cbx_lb.Attach(win.Control("cbx_lb"));


        if (cbx_hbzxx == null) cbx_hbzxx = new CheckBox(requestor);
        cbx_hbzxx.Attach(win.Control("cbx_hbzxx"));
      

        if (cbx_fs == null) cbx_fs = new CheckBox(requestor);
        cbx_fs.Attach(win.Control("cbx_fs"));
        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 (sle_pzh == null) sle_pzh = new SingleLineEdit(requestor);
        sle_pzh.Attach(win.Control("sle_pzh"));
        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 (sle_pp == null) sle_pp = new SingleLineEdit(requestor);
        sle_pp.Attach(win.Control("sle_pp"));
        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 (dw_list == null) dw_list = new DataWindow(requestor);
        dw_list.Attach(win.Control("dw_list"));
        if (dw_1 == null) dw_1 = new DataWindow(requestor);
        dw_1.Attach(win.Control("dw_1"));
        if (tb_1 == null) tb_1 = new ToolStrip(requestor);
        tb_1.Attach(win.Control("tb_1"));
        if (dw_format == null) dw_format = new DataWindow(requestor);
        dw_format.Attach(win.Control("dw_format"));

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

        if (ddlb_nf == null) ddlb_nf = new DropDownListBox(requestor);
        ddlb_nf.Attach(win.Control("ddlb_nf"));
        if (ddlb_sex == null) ddlb_sex = new DropDownListBox(requestor);
        ddlb_sex.Attach(win.Control("ddlb_sex"));

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

        if (cb_3 == null) cb_3 = new CheckBox(requestor);
        cb_3.Attach(win.Control("cb_3"));
        if (sle_formatname == null) sle_formatname = new SingleLineEdit(requestor);
        sle_formatname.Attach(win.Control("sle_formatname"));
        if (ContextMenuStrip1 == null) ContextMenuStrip1 = new ContextMenu(requestor);
        ContextMenuStrip1.Attach(win.Control("ContextMenuStrip1"));

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

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

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

      

        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.FilterChanges) == "function")
            win.AttachEvent("sle_bm", "EditChanged", self.FilterChanges);

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

      


       
    }

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

        cbx_bzxx.Detach(); cbx_bzxx = null;
        cbx_gys.Detach(); cbx_gys = null;
        cbx_pzh.Detach(); cbx_pzh = null;
        rb_zx.Detach(); rb_zx = null;
        rb_hx.Detach(); rb_hx = null;
        cbx_lb.Detach(); cbx_lb = null;
        cbx_fs.Detach(); cbx_fs = null;
        cbx_bm.Detach(); cbx_bm = null;
        cbx_rq.Detach(); cbx_rq = null;
        sle_pzh.Detach(); sle_pzh = 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;
        sle_pp.Detach(); sle_pp = null;
        sle_bm.Detach(); sle_bm = null;
        dp_2.Detach(); dp_2 = null;
        dp_1.Detach(); dp_1 = null;
        dw_list.Detach(); dw_list = null;
        dw_1.Detach(); dw_1 = null;
        tb_1.Detach(); tb_1 = null;
        requestor.Detach(); requestor = null;
        dw_format.Detach(); dw_format = null
        dw_temp.Detach(); dw_temp = null
        ddlb_nf.Detach(); ddlb_nf = null;
        ddlb_sex.Detach(); ddlb_sex = null;
        sle_spbh.Detach(); sle_spbh = null;
        cb_3.Detach(); cb_3 = null;
        dw_format_hz.Detach(); dw_format_hz = null;
        dw_format_mx.Detach(); dw_format_mx = null;
        cbx_hbzxx.Detach(); cbx_hbzxx = null;
        sle_formatname.Detach(); sle_formatname = null;
        ContextMenuStrip1.Detach(); ContextMenuStrip1 = null;
        setTimeout(CollectGarbage, 100);
    }

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


    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 curOtherWidht = 1080;
    var curOtherHeight = 760;
    var ywflag = "";
    var curOpenWindowDoubleRowsChooseBase = new OpenWindowDoubleRowsChooseBase();
    var gRowCount = 0;
    var ColorRow = 1;
    webReq = new WebRequestor();
    webReq.SetWebServiceUrl("/Service/ServiceForDwSyndax.ashx");
    var curW_KC_PIC = new W_KC_PIC();
    webReq_Print = new WebRequestor();
    webReq_Print.SetWebServiceUrl("/Service/Ajax_XT.ashx");
    var curYhmc = "";

    var curYhbh = "";
    var curCdbh = "";
    var C_CheckValue = "";
    var curBbmc = "rb_hx";
    var curJgtx = "";
    var ExistGYS = "";
    var curSFQY_CGYW_JJZE_SHURU = "0";
    var curjjze = "";
    //报表名称
    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 curSelDays = "";
    var cbx_rkfs = 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);
    //#endregion

    //#region Function Query
    this.Query = function () {

        var dynamicShowStr = "";
        var dynamicShowString = "";

        var dynamicShowStr1 = "";
        var dynamicShowString1 = "";

        var dynamicShowStrEnd = "";
        var dynamicShowStringEnd = "";
        var curSql = ""
        var curRows = "";
        var curCols = "";
        var curValues = "";
        var curColTypes = "";
        var sy = "";
        var finishSql = "";
        C_CheckValue = "";

        dw_temp.Reset();
        if (cbx_lb.GetChecked()) {
            if (rb_hx.GetChecked()) {
                dynamicShowStr += "hplb,lbmc,";
                dynamicShowString += "hplb,lbmc, ";
            }
            else {
                dynamicShowStr += "b.hplb as  lbbh,d.lbmc as lbmc,";
                dynamicShowString += "b.hplb,d.lbmc, ";
            }
            C_CheckValue += "cbx_lb,"
        }
        if (cbx_bm.GetChecked()) {
            if (rb_hx.GetChecked()) {
                dynamicShowStr1 += " bmbh,bmmc, ";
                dynamicShowString1 += " ,bmbh,bmmc";
            }
            else {
                dynamicShowStr1 += " a.bmbh as bmbh ,c.bmmc as bmmc,";
                dynamicShowString1 += " ,a.bmbh,c.bmmc";
            }
            C_CheckValue += "cbx_bm,"
        }

        if (cbx_rq.GetChecked()) {
            if (rb_hx.GetChecked()) {
                dynamicShowStr1 += " convert(varchar(10),kdrq,23) as rq,";
                dynamicShowString1 += " ,convert(varchar(10),kdrq,23)";
            }
            else {
                dynamicShowStr1 += " convert(varchar(10),a.kdrq,23) as rq,";
                dynamicShowString1 += " ,convert(varchar(10),a.kdrq,23)";
            }
            C_CheckValue += "cbx_rq,"
        }
        if (cbx_pzh.GetChecked()) {
            if (rb_hx.GetChecked()) {
                dynamicShowStr1 += " pzh,";
                dynamicShowString1 += " ,pzh";
            }
            else {
                dynamicShowStr1 += " a.pzh pzh,";
                dynamicShowString1 += " ,a.pzh";
            }
            C_CheckValue += "cbx_pzh,"
        }
        if (cbx_gys.GetChecked()) {
            if (rb_hx.GetChecked()) {

                dynamicShowStr1 += "gysbh ,gysmc,";
                dynamicShowString1 += ",gysbh,gysmc";
            }
            else {
                dynamicShowStr1 += "a.gysbh gysbh ,e.gysmc gysmc,";
                dynamicShowString1 += ",a.gysbh,e.gysmc";
            }
            C_CheckValue += "cbx_gys,"
        }

        if (cbx_fs.GetChecked()) {
            if (rb_hx.GetChecked()) {

                dynamicShowStrEnd += " ,cgfsmc";
                dynamicShowStringEnd += ",cgfsmc";
            }
            else {
                dynamicShowStrEnd += " ,f.csmc   cgfs";
                dynamicShowStringEnd += ",f.csmc";
            }
            C_CheckValue += "cbx_fs,"
        }

        if (cbx_bzxx.GetChecked()) {
            if (rb_hx.GetChecked()) {
                dynamicShowStrEnd += ",bzxx";
                dynamicShowStringEnd += ",bzxx";
            }
            else {
                dynamicShowStrEnd += ",a.bzxx   bzxx";
                dynamicShowStringEnd += ",a.bzxx";
            }
            C_CheckValue += "cbx_bzxx,"
        }

        if (cbx_hbzxx.GetChecked()) {
            if (rb_hx.GetChecked()) {
                dynamicShowStrEnd += ",hbzxx";
                dynamicShowStringEnd += ",hbzxx";
            }
            else {
                dynamicShowStrEnd += ",a.hbzxx   hbzxx";
                dynamicShowStringEnd += ",a.hbzxx";
            }
            C_CheckValue += "cbx_hbzxx,"
        }

        if (cbx_rkfs.GetChecked()) {
            if (rb_hx.GetChecked()) {
                dynamicShowStrEnd += " ,rklxmc";
                dynamicShowStringEnd += ",rklxmc";
            }
            else {
                dynamicShowStrEnd += " ,k.rklxmc rklxmc";
                dynamicShowStringEnd += ",k.rklxmc";
            }
           
            C_CheckValue += "cbx_rkfs,"
        }
        if (rb_zx.GetChecked()) {
            curBbmc = rb_zx.GetName();

            if (ywflag == "CZ") {
                finishSql = "select " + dynamicShowStr +
                               "a.spkh,b.ksmc,b.jldw,a.ysbh,m.ysmc ysmc ,dbo.F_GET_CMBT_BY_CMDM(b.cmzbm,a.cmbh) cmdm,a.bxbh,g.bxmc," + dynamicShowStr1 + "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_cgtzdtz_ls   UNION ALL   SELECT * FROM dbo.yw_cg_cgtzdtz) 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 dbo.da_sp_bxda g ON a.bxbh=g.bxbh " +
                               " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
                              " where a.djlx='1'   " +
                               self.GetSqlWhere() + " group by  " + dynamicShowString + "a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmbh,b.cmzbm,a.bxbh,g.bxmc,m.ysmc" + dynamicShowString1 + dynamicShowStringEnd
            }

            if (ywflag == "CD") {
                finishSql = "select " + dynamicShowStr +
                               "a.spkh,b.ksmc,b.jldw,a.ysbh,m.ysmc ysmc ,dbo.F_GET_CMBT_BY_CMDM(b.cmzbm,a.cmbh) cmdm,a.bxbh,g.bxmc," + dynamicShowStr1 +
                               "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_cgtzdtz_ls   UNION ALL   SELECT * FROM dbo.yw_cg_cgtzdtz) 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 dbo.da_sp_bxda g ON a.bxbh=g.bxbh " +
                               " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
                              " where a.djlx='2'   " +
                               self.GetSqlWhere() + " group by  " + dynamicShowString + "a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmbh,b.cmzbm,a.bxbh,g.bxmc,m.ysmc" + dynamicShowString1 + dynamicShowStringEnd
            }
            if (ywflag == "CG") {
                finishSql = "select " + dynamicShowStr +
                               "a.spkh,b.ksmc,b.jldw,a.ysbh,m.ysmc ysmc ,dbo.F_GET_CMBT_BY_CMDM(b.cmzbm,a.cmbh) cmdm,a.bxbh,g.bxmc," + dynamicShowStr1 +
                               "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_DDFS') f on a.cgfs=f.csbh  " +
                               " LEFT JOIN dbo.da_sp_bxda g ON a.bxbh=g.bxbh " +
                               " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
                              " where a.djlx='1'   " +
                               self.GetSqlWhere() + " group by  " + dynamicShowString + "a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmbh,b.cmzbm,a.bxbh,g.bxmc,m.ysmc" + dynamicShowString1 + dynamicShowStringEnd
            }
            else if (ywflag == "CS") {
                finishSql = "select " + dynamicShowStr +
                               "a.spkh,b.ksmc,b.jldw,a.ysbh,m.ysmc ysmc ,dbo.F_GET_CMBT_BY_CMDM(b.cmzbm,a.cmbh) cmdm,a.bxbh,g.bxmc," + dynamicShowStr1 +
                               "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 dbo.da_sp_bxda g ON a.bxbh=g.bxbh " +
                              " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
                              " where a.djlx='2'   " +
                               self.GetSqlWhere() + " group by  " + dynamicShowString + "a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmbh,b.cmzbm,a.bxbh,g.bxmc,m.ysmc" + dynamicShowString1 + dynamicShowStringEnd
            }

            else if (ywflag == "CR") {
                var curjjze = "";
                if (curSFQY_CGYW_JJZE_SHURU == "0") {
                    curjjze = " SUM(CASE djlx WHEN 1 THEN a.sl*a.jj WHEN 2 THEN -a.sl*a.jj END) jjze "
                }
                else {
                    curjjze = "SUM(CASE djlx WHEN 1 THEN a.hjjze WHEN 2 THEN -a.hjjze END) jjze "
                }
                finishSql = "select " + dynamicShowStr +
                               "a.spkh,b.ksmc,b.jldw,a.ysbh,m.ysmc ysmc ,dbo.F_GET_CMBT_BY_CMDM(b.cmzbm,a.cmbh) cmdm, a.bxbh,g.bxmc," + dynamicShowStr1 +
                               "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," + curjjze + 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 dbo.da_sp_bxda g ON a.bxbh=g.bxbh " +
                              " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
                               " left join(SELECT csbh rklxbh,csmc rklxmc FROM dbo.da_qj_csb WHERE csfl='RKLX') k on a.rkfs=k.rklxbh "+
                " where 1=1  " +
                              self.GetSqlWhere() + " group by  " + dynamicShowString + "a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmbh,b.cmzbm, a.bxbh,g.bxmc,m.ysmc" + dynamicShowString1 + dynamicShowStringEnd
            }
            else if (ywflag == "CT") {
                var curjjze = "";
                if (curSFQY_CGYW_JJZE_SHURU == "0") {
                    curjjze = "sum(a.sl*a.jj) jjze "
                }
                else {
                    curjjze = "sum(a.hjjze) jjze "
                }
                finishSql = "select " + dynamicShowStr +
                               "a.spkh,b.ksmc,b.jldw,a.ysbh,m.ysmc ysmc ,dbo.F_GET_CMBT_BY_CMDM(b.cmzbm,a.cmbh) cmdm,a.bxbh,g.bxmc," + dynamicShowStr1 +
                               "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," + curjjze + 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 dbo.da_sp_bxda g ON a.bxbh=g.bxbh " +
                              " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
                             " left join(SELECT csbh rklxbh,csmc rklxmc FROM dbo.da_qj_csb WHERE csfl='RKLX') k on a.rkfs=k.rklxbh "+
                " where a.djlx='2'   " +
                               self.GetSqlWhere() + " group by  " + dynamicShowString + "a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmbh,b.cmzbm,a.bxbh,g.bxmc,m.ysmc" + dynamicShowString1 + dynamicShowStringEnd
            }
            requestor.ClipBoard(finishSql)
            finishSql = finishSql.replace(/\%/g, "%25");
            finishSql = finishSql.replace(/\+/g, "%2B");
            finishSql = finishSql.replace(/\&/g, "%26");
            self.DrawDataWindow(finishSql);
        }

        else if (rb_hx.GetChecked()) {
            curBbmc = rb_hx.GetName();

            if (ywflag == "CZ") {
                finishSql = "select " + dynamicShowStr +
            " spkh,ksmc,jldw,cmzbh,ysbh,ysmc ,bxbh,bxmc," + dynamicShowStr1 +
            " sum(isnull(cm1,0)) cm1,sum(isnull(cm2,0)) cm2,sum(isnull(cm3,0)) cm3,sum(isnull(cm4,0)) cm4,sum(isnull(cm5,0)) cm5,sum(isnull(cm6,0)) cm6,sum(isnull(cm7,0)) cm7,sum(isnull(cm8,0)) cm8," +
            " sum(isnull(cm9,0)) cm9,sum(isnull(cm10,0)) cm10,sum(isnull(cm11,0)) cm11,sum(isnull(cm12,0)) cm12,sum(isnull(cm13,0)) cm13," +
            " sum(isnull(cm14,0)) cm14,sum(isnull(cm15,0)) cm15,sum(isnull(cm16,0)) cm16,sum(isnull(cm17,0)) cm17,sum(isnull(cm18,0)) cm18," +
            " sum(isnull(cm19,0)) cm19,sum(isnull(cm20,0)) cm20,sum(isnull(cm21,0)) cm21,sum(isnull(cm22,0)) cm22,sum(isnull(cm23,0)) cm23," +
            " sum(isnull(cm24,0)) cm24,sum(isnull(cm25,0)) cm25,sum(isnull(cm26,0)) cm26,sum(isnull(cm27,0)) cm27,sum(isnull(cm28,0)) cm28," +
            " sum(isnull(cm29,0)) cm29,sum(isnull(cm30,0))cm30,sum(isnull(cm31,0))cm31,sum(isnull(cm32,0))cm32,sum(isnull(cm33,0)) cm33," +
            " sum(isnull(cm34,0))cm34,sum(isnull(cm35,0)) cm35," +
            " sum(zjsl) as zjsl, (SUM(jjze)/case when SUM(zjsl)=0 then 1 else sum(zjsl) end ) jj , sum(jjze) as jjze,max(lsj) lsj,sum(lsjze) as lsjze,max(dpj) dpj,sum(dpjze) as dpjze  " + dynamicShowStrEnd +
            " from( " +
            " select  distinct g.mxdh,a.pzh,a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmzbh,a.bxbh,h.bxmc,m.ysmc," +
            " g.cm1,g.cm2,g.cm3,g.cm4,g.cm5,g.cm6,g.cm7,g.cm8," +
            " g.cm9,g.cm10,g.cm11,g.cm12,g.cm13,g.cm14,g.cm15,g.cm16, " +
            " g.cm17,g.cm18,g.cm19,g.cm20,g.cm21,g.cm22,g.cm23,g.cm24, " +
            " g.cm25,g.cm26,g.cm27,g.cm28,g.cm29,g.cm30,g.cm31,g.cm32, " +
            " g.cm33,g.cm34,g.cm35,  " +
            " 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) zjsl," +
            " a.lsj 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))*ISNULL(a.lsj,0) lsjze, " +

            " a.dpj 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))*ISNULL(a.dpj,0) dpjze, " +

            " a.jj jj, " +
            " (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))*ISNULL(a.jj,0) jjze, " +
            " a.kdrq,a.bmbh,c.bmmc,b.jypp,a.gysbh ,e.gysmc,b.spxb,b.hplb,d.lbmc,b.spjj,b.spml,a.cgfs,f.csmc cgfsmc,b.spnf,a.bzxx,a.hbzxx " +
            " from (SELECT * FROM dbo.yw_cg_cgtzdtz_ls   UNION ALL   SELECT * FROM dbo.yw_cg_cgtzdtz) 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   (select * from yw_cg_tzdmx union all select * from yw_cg_tzdmx_ls)  g on a.pzh=g.pzh and a.mxdh=g.mxdh " +
            " left join da_sp_bxda  h on h.bxbh=a.bxbh " +
            " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh" +
            " where a.djlx='1'  " + self.GetSqlWhere() +
            " ) as hzb " +
            " group by  " + dynamicShowString + " spkh,ksmc,jldw,cmzbh,ysbh,yslsh,bxbh,bxmc,ysmc" + dynamicShowString1 + dynamicShowStringEnd

            }
            if (ywflag == "CD") {
                finishSql = "select " + dynamicShowStr +
            " spkh,ksmc,jldw,cmzbh,ysbh,ysmc ,bxbh,bxmc," + dynamicShowStr1 +
            " sum(isnull(cm1,0)) cm1,sum(isnull(cm2,0)) cm2,sum(isnull(cm3,0)) cm3,sum(isnull(cm4,0)) cm4,sum(isnull(cm5,0)) cm5,sum(isnull(cm6,0)) cm6,sum(isnull(cm7,0)) cm7,sum(isnull(cm8,0)) cm8," +
            " sum(isnull(cm9,0)) cm9,sum(isnull(cm10,0)) cm10,sum(isnull(cm11,0)) cm11,sum(isnull(cm12,0)) cm12,sum(isnull(cm13,0)) cm13," +
            " sum(isnull(cm14,0)) cm14,sum(isnull(cm15,0)) cm15,sum(isnull(cm16,0)) cm16,sum(isnull(cm17,0)) cm17,sum(isnull(cm18,0)) cm18," +
            " sum(isnull(cm19,0)) cm19,sum(isnull(cm20,0)) cm20,sum(isnull(cm21,0)) cm21,sum(isnull(cm22,0)) cm22,sum(isnull(cm23,0)) cm23," +
            " sum(isnull(cm24,0)) cm24,sum(isnull(cm25,0)) cm25,sum(isnull(cm26,0)) cm26,sum(isnull(cm27,0)) cm27,sum(isnull(cm28,0)) cm28," +
            " sum(isnull(cm29,0)) cm29,sum(isnull(cm30,0))cm30,sum(isnull(cm31,0))cm31,sum(isnull(cm32,0))cm32,sum(isnull(cm33,0)) cm33," +
            " sum(isnull(cm34,0))cm34,sum(isnull(cm35,0)) cm35," +
            " sum(zjsl) as zjsl,(SUM(jjze)/case when SUM(zjsl)=0 then 1 else sum(zjsl) end ) jj, sum(jjze) as jjze,max(lsj) lsj,sum(lsjze) as lsjze,max(dpj) dpj,sum(dpjze) as dpjze  " + dynamicShowStrEnd +
            " from( " +
            " select  distinct g.mxdh,a.pzh,a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmzbh,a.bxbh,h.bxmc,m.ysmc," +
            " g.cm1,g.cm2,g.cm3,g.cm4,g.cm5,g.cm6,g.cm7,g.cm8," +
            " g.cm9,g.cm10,g.cm11,g.cm12,g.cm13,g.cm14,g.cm15,g.cm16, " +
            " g.cm17,g.cm18,g.cm19,g.cm20,g.cm21,g.cm22,g.cm23,g.cm24, " +
            " g.cm25,g.cm26,g.cm27,g.cm28,g.cm29,g.cm30,g.cm31,g.cm32, " +
            " g.cm33,g.cm34,g.cm35,  " +
            " 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) zjsl," +
            " a.lsj 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))*ISNULL(a.lsj,0) lsjze, " +
            " a.dpj 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))*ISNULL(a.dpj,0) dpjze, " +

            " a.jj jj, " +
            " (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))*ISNULL(a.jj,0) jjze, " +
            " a.kdrq,a.bmbh,c.bmmc,b.jypp,a.gysbh ,e.gysmc,b.spxb,b.hplb,d.lbmc,b.spjj,b.spml,a.cgfs,f.csmc cgfsmc,b.spnf,a.bzxx,a.hbzxx " +
            " from (SELECT * FROM dbo.yw_cg_cgtzdtz_ls   UNION ALL   SELECT * FROM dbo.yw_cg_cgtzdtz) 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   (select * from yw_cg_tzdmx union all select * from yw_cg_tzdmx_ls)  g on a.pzh=g.pzh and a.mxdh=g.mxdh " +
            " left join da_sp_bxda  h on h.bxbh=a.bxbh " +
            " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
            " where a.djlx='2'  " + self.GetSqlWhere() +
            " ) as hzb " +
            " group by  " + dynamicShowString + " spkh,ksmc,jldw,cmzbh,ysbh,yslsh,bxbh,bxmc,ysmc" + dynamicShowString1 + dynamicShowStringEnd

            }
            else if (ywflag == "CG") {
                finishSql = "select " + dynamicShowStr +
            " spkh,ksmc,jldw,cmzbh,ysbh,ysmc ,bxbh,bxmc," + dynamicShowStr1 +
            " sum(isnull(cm1,0)) cm1,sum(isnull(cm2,0)) cm2,sum(isnull(cm3,0)) cm3,sum(isnull(cm4,0)) cm4,sum(isnull(cm5,0)) cm5,sum(isnull(cm6,0)) cm6,sum(isnull(cm7,0)) cm7,sum(isnull(cm8,0)) cm8," +
            " sum(isnull(cm9,0)) cm9,sum(isnull(cm10,0)) cm10,sum(isnull(cm11,0)) cm11,sum(isnull(cm12,0)) cm12,sum(isnull(cm13,0)) cm13," +
            " sum(isnull(cm14,0)) cm14,sum(isnull(cm15,0)) cm15,sum(isnull(cm16,0)) cm16,sum(isnull(cm17,0)) cm17,sum(isnull(cm18,0)) cm18," +
            " sum(isnull(cm19,0)) cm19,sum(isnull(cm20,0)) cm20,sum(isnull(cm21,0)) cm21,sum(isnull(cm22,0)) cm22,sum(isnull(cm23,0)) cm23," +
            " sum(isnull(cm24,0)) cm24,sum(isnull(cm25,0)) cm25,sum(isnull(cm26,0)) cm26,sum(isnull(cm27,0)) cm27,sum(isnull(cm28,0)) cm28," +
            " sum(isnull(cm29,0)) cm29,sum(isnull(cm30,0))cm30,sum(isnull(cm31,0))cm31,sum(isnull(cm32,0))cm32,sum(isnull(cm33,0)) cm33," +
            " sum(isnull(cm34,0))cm34,sum(isnull(cm35,0)) cm35," +
            " sum(zjsl) as zjsl, (SUM(jjze)/case when SUM(zjsl)=0 then 1 else sum(zjsl) end ) jj, sum(jjze) as jjze,max(lsj) lsj,sum(lsjze) as lsjze,max(dpj) dpj,sum(dpjze) as dpjze  " + dynamicShowStrEnd +
            " from( " +
            " select  distinct g.mxdh,a.pzh,a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmzbh,a.bxbh,h.bxmc,m.ysmc," +
            " g.cm1,g.cm2,g.cm3,g.cm4,g.cm5,g.cm6,g.cm7,g.cm8," +
            " g.cm9,g.cm10,g.cm11,g.cm12,g.cm13,g.cm14,g.cm15,g.cm16, " +
            " g.cm17,g.cm18,g.cm19,g.cm20,g.cm21,g.cm22,g.cm23,g.cm24, " +
            " g.cm25,g.cm26,g.cm27,g.cm28,g.cm29,g.cm30,g.cm31,g.cm32, " +
            " g.cm33,g.cm34,g.cm35,  " +
            " 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) zjsl," +
            " a.lsj 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))*ISNULL(a.lsj,0) lsjze, " +

            " a.dpj 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))*ISNULL(a.dpj,0) dpjze, " +

            " a.jj jj, " +
            " (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))*ISNULL(a.jj,0) jjze, " +
            " a.kdrq,a.bmbh,c.bmmc,b.jypp,a.gysbh ,e.gysmc,b.spxb,b.hplb,d.lbmc,b.spjj,b.spml,a.cgfs,f.csmc cgfsmc,b.spnf,a.bzxx,a.hbzxx " +
            " 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_DDFS') f on a.cgfs=f.csbh " +
            " left join   (select * from yw_cg_ddmx union all select * from yw_cg_ddmx_ls)  g on a.pzh=g.pzh and a.mxdh=g.mxdh " +
            " left join da_sp_bxda  h on h.bxbh=a.bxbh " +
            " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
            " where a.djlx='1'  " + self.GetSqlWhere() +
            " ) as hzb " +
            " group by  " + dynamicShowString + " spkh,ksmc,jldw,cmzbh,ysbh,yslsh,bxbh,bxmc,ysmc" + dynamicShowString1 + dynamicShowStringEnd
            }
            else if (ywflag == "CS") {

                finishSql = "select " + dynamicShowStr +
            " spkh,ksmc,jldw,cmzbh,ysbh,ysmc ,bxbh,bxmc," + dynamicShowStr1 +
            " sum(isnull(cm1,0)) cm1,sum(isnull(cm2,0)) cm2,sum(isnull(cm3,0)) cm3,sum(isnull(cm4,0)) cm4,sum(isnull(cm5,0)) cm5,sum(isnull(cm6,0)) cm6,sum(isnull(cm7,0)) cm7,sum(isnull(cm8,0)) cm8," +
            " sum(isnull(cm9,0)) cm9,sum(isnull(cm10,0)) cm10,sum(isnull(cm11,0)) cm11,sum(isnull(cm12,0)) cm12,sum(isnull(cm13,0)) cm13," +
            " sum(isnull(cm14,0)) cm14,sum(isnull(cm15,0)) cm15,sum(isnull(cm16,0)) cm16,sum(isnull(cm17,0)) cm17,sum(isnull(cm18,0)) cm18," +
            " sum(isnull(cm19,0)) cm19,sum(isnull(cm20,0)) cm20,sum(isnull(cm21,0)) cm21,sum(isnull(cm22,0)) cm22,sum(isnull(cm23,0)) cm23," +
            " sum(isnull(cm24,0)) cm24,sum(isnull(cm25,0)) cm25,sum(isnull(cm26,0)) cm26,sum(isnull(cm27,0)) cm27,sum(isnull(cm28,0)) cm28," +
            " sum(isnull(cm29,0)) cm29,sum(isnull(cm30,0))cm30,sum(isnull(cm31,0))cm31,sum(isnull(cm32,0))cm32,sum(isnull(cm33,0)) cm33," +
            " sum(isnull(cm34,0))cm34,sum(isnull(cm35,0)) cm35," +
            " sum(zjsl) as zjsl, (SUM(jjze)/case when SUM(zjsl)=0 then 1 else sum(zjsl) end ) jj, sum(jjze) as jjze,max(lsj) lsj,sum(lsjze) as lsjze,max(dpj) dpj,sum(dpjze) as dpjze  " + dynamicShowStrEnd +
            " from( " +
            " select  distinct g.mxdh,a.pzh,a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmzbh,a.bxbh,h.bxmc,m.ysmc," +
            " g.cm1,g.cm2,g.cm3,g.cm4,g.cm5,g.cm6,g.cm7,g.cm8," +
            " g.cm9,g.cm10,g.cm11,g.cm12,g.cm13,g.cm14,g.cm15,g.cm16, " +
            " g.cm17,g.cm18,g.cm19,g.cm20,g.cm21,g.cm22,g.cm23,g.cm24, " +
            " g.cm25,g.cm26,g.cm27,g.cm28,g.cm29,g.cm30,g.cm31,g.cm32, " +
            " g.cm33,g.cm34,g.cm35,  " +
            " 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) zjsl," +
            " a.lsj 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))*ISNULL(a.lsj,0) lsjze, " +

            " a.dpj 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))*ISNULL(a.dpj,0) dpjze, " +


            " a.jj jj, " +
            " (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))*ISNULL(a.jj,0) jjze, " +
            " a.kdrq,a.bmbh,c.bmmc,b.jypp,b.gysbh ,e.gysmc,b.spxb,b.hplb,d.lbmc,b.spjj,b.spml,a.cgfs,f.csmc cgfsmc,b.spnf,a.bzxx,a.hbzxx " +
            " 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   yw_cg_ddmx  g on a.pzh=g.pzh and a.mxdh=g.mxdh " +
            " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
            " left join da_sp_bxda  h on h.bxbh=a.bxbh " +
            " where a.djlx='2'   " + self.GetSqlWhere() +
            " ) as hzb " +
            " group by  " + dynamicShowString + " spkh,ksmc,jldw,cmzbh,ysbh,yslsh,bxbh,bxmc,ysmc" + dynamicShowString1 + dynamicShowStringEnd
            }
            else if (ywflag == "CR") {
                var curjjze = "";
                if (curSFQY_CGYW_JJZE_SHURU == "0") {
                    curjjze = "sum(sl*jj) hjjze "
                }
                else {
                    curjjze = "SUM(hjjze) hjjze "
                }
                finishSql = "select " + dynamicShowStr +
            " spkh,ksmc,jldw,ysbh,ysmc ,cmzbh,bxbh,bxmc," + dynamicShowStr1 +
            " sum(isnull(cm1,0)) cm1,sum(isnull(cm2,0)) cm2,sum(isnull(cm3,0)) cm3,sum(isnull(cm4,0)) cm4,sum(isnull(cm5,0)) cm5,sum(isnull(cm6,0)) cm6,sum(isnull(cm7,0)) cm7,sum(isnull(cm8,0)) cm8," +
            " sum(isnull(cm9,0)) cm9,sum(isnull(cm10,0)) cm10,sum(isnull(cm11,0)) cm11,sum(isnull(cm12,0)) cm12,sum(isnull(cm13,0)) cm13," +
            " sum(isnull(cm14,0)) cm14,sum(isnull(cm15,0)) cm15,sum(isnull(cm16,0)) cm16,sum(isnull(cm17,0)) cm17,sum(isnull(cm18,0)) cm18," +
            " sum(isnull(cm19,0)) cm19,sum(isnull(cm20,0)) cm20,sum(isnull(cm21,0)) cm21,sum(isnull(cm22,0)) cm22,sum(isnull(cm23,0)) cm23," +
            " sum(isnull(cm24,0)) cm24,sum(isnull(cm25,0)) cm25,sum(isnull(cm26,0)) cm26,sum(isnull(cm27,0)) cm27,sum(isnull(cm28,0)) cm28," +
            " sum(isnull(cm29,0)) cm29,sum(isnull(cm30,0))cm30,sum(isnull(cm31,0))cm31,sum(isnull(cm32,0))cm32,sum(isnull(cm33,0)) cm33," +
            " sum(isnull(cm34,0))cm34,sum(isnull(cm35,0)) cm35," +

            " sum(zjsl) as zjsl, (SUM(jjze)/case when SUM(zjsl)=0 then 1 else sum(zjsl) end ) jj, sum(jjze) as jjze,max(lsj) lsj,sum(lsjze) as lsjze,max(dpj) dpj,sum(dpjze) as dpjze  " + dynamicShowStrEnd +
            " from( " +
                "    SELECT   g.mxdh ,a.pzh ,a.spkh ,   b.ksmc , b.jldw, a.ysbh ,a.yslsh ,a.cmzbh ,a.bxbh,h.bxmc,m.ysmc," +
                 "        (CASE djlx WHEN 1 THEN g.cm1 WHEN 2 THEN -g.cm1 END) cm1 ," +
                 "        (CASE djlx WHEN 1 THEN g.cm2 WHEN 2 THEN -g.cm2 END) cm2 ," +
                 "      (CASE djlx WHEN 1 THEN g.cm3 WHEN 2 THEN -g.cm3 END) cm3 ," +
                 "        (CASE djlx WHEN 1 THEN g.cm4 WHEN 2 THEN -g.cm4 END) cm4 ," +
                 "       (CASE djlx WHEN 1 THEN g.cm5 WHEN 2 THEN -g.cm5 END) cm5 ," +
                 "      (CASE djlx WHEN 1 THEN g.cm6 WHEN 2 THEN -g.cm6 END) cm6 ," +
                 "       (CASE djlx WHEN 1 THEN g.cm7 WHEN 2 THEN -g.cm7 END) cm7 ," +
                 "      (CASE djlx WHEN 1 THEN g.cm8 WHEN 2 THEN -g.cm8 END) cm8 ," +
                 "      (CASE djlx WHEN 1 THEN g.cm9 WHEN 2 THEN -g.cm9 END) cm9 ," +
                 "      (CASE djlx WHEN 1 THEN g.cm10 WHEN 2 THEN -g.cm10 END) cm10 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm11 WHEN 2 THEN -g.cm11 END) cm11 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm12 WHEN 2 THEN -g.cm12 END) cm12 ," +
                  "       (CASE djlx WHEN 1 THEN g.cm13 WHEN 2 THEN -g.cm13 END) cm13 ," +
                    "     (CASE djlx WHEN 1 THEN g.cm14 WHEN 2 THEN -g.cm14 END) cm14 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm15 WHEN 2 THEN -g.cm15 END) cm15 ," +
                    "     (CASE djlx WHEN 1 THEN g.cm16 WHEN 2 THEN -g.cm16 END) cm16 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm17 WHEN 2 THEN -g.cm17 END) cm17 ," +
                    "     (CASE djlx WHEN 1 THEN g.cm18 WHEN 2 THEN -g.cm18 END) cm18 ," +
                    "     (CASE djlx WHEN 1 THEN g.cm19 WHEN 2 THEN -g.cm19 END) cm19 ," +
                    "     (CASE djlx WHEN 1 THEN g.cm20 WHEN 2 THEN -g.cm20 END) cm20 ," +
                     "    (CASE djlx WHEN 1 THEN g.cm21 WHEN 2 THEN -g.cm21 END) cm21 ," +
                    "     (CASE djlx WHEN 1 THEN g.cm22 WHEN 2 THEN -g.cm22 END) cm22 ," +
                    "     (CASE djlx WHEN 1 THEN g.cm23 WHEN 2 THEN -g.cm23 END) cm23 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm24 WHEN 2 THEN -g.cm24 END) cm24 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm25 WHEN 2 THEN -g.cm25 END) cm25 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm26 WHEN 2 THEN -g.cm26 END) cm26 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm27 WHEN 2 THEN -g.cm27 END) cm27 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm28 WHEN 2 THEN -g.cm28 END) cm28 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm29 WHEN 2 THEN -g.cm29 END) cm29 ," +
                  "       (CASE djlx WHEN 1 THEN g.cm30 WHEN 2 THEN -g.cm30 END) cm30," +
                   "      (CASE djlx WHEN 1 THEN g.cm31 WHEN 2 THEN -g.cm31 END) cm31 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm32 WHEN 2 THEN -g.cm32 END) cm32, " +
                   "      (CASE djlx WHEN 1 THEN g.cm33 WHEN 2 THEN -g.cm33 END) cm33 ," +
                   "      (CASE djlx WHEN 1 THEN g.cm34 WHEN 2 THEN -g.cm34 END) cm34," +
                  "       (CASE djlx WHEN 1 THEN g.cm35 WHEN 2 THEN -g.cm35 END) cm35," +

                    "     (CASE  djlx WHEN 1 THEN " +

                 "       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) " +
                  "       WHEN  2 THEN " +
                  "       -(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)) END)" +
                  "       zjsl ," +
                   "      a.lsj lsj ," +
                   "      (CASE  djlx WHEN 1 THEN" +
                     "     ( 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) ) * ISNULL(a.lsj, 0) " +
                    "        WHEN 2 THEN " +
                     "        -( 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) ) * ISNULL(a.lsj, 0) END)" +
                    "       lsjze ," +
                    "      a.dpj dpj ," +
                     "      (CASE  djlx WHEN 1 THEN" +
                     "     ( 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) ) * ISNULL(a.dpj, 0) " +
                    "        WHEN 2 THEN " +
                     "        -( 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) ) * ISNULL(a.dpj, 0) END)" +
                    "       dpjze ," +
                    "     a.jj jj , CASE djlx WHEN 1 THEN a.hjjze WHEN 2 THEN -a.hjjze END jjze," +

                     "  a.kdrq , a.bmbh ,c.bmmc , b.jypp , a.gysbh , e.gysmc ,b.spxb , b.hplb ,d.lbmc ,  b.spjj ,b.spml , a.cgfs ,f.csmc cgfsmc , b.spnf , a.bzxx, a.djlx,a.hbzxx,k.rklxmc " +
                     " FROM  (SELECT pzh,spkh,ysbh,yslsh,cmzbh,bxbh,SUM(sl)sl,mxdh,cgfs,gysbh,bmbh,kdrq,djlx,jj,lsj,dpj," + curjjze + " ,bzxx,hbzxx from " +
                    " (SELECT * FROM dbo.yw_cg_cgrkdtz   UNION ALL   SELECT * FROM dbo.yw_cg_cgrkdtz_ls) AS yw_cg_cgrkdtz " +
            " GROUP by pzh,spkh,ysbh,yslsh,cmzbh,bxbh,mxdh,cgfs,gysbh,bmbh,kdrq,djlx,bzxx,jj,lsj,dpj,hbzxx) 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   (SELECT * FROM yw_cg_rkdmx  UNION ALL SELECT * FROM yw_cg_rkdmx_LS) g on a.pzh=g.pzh and a.mxdh=g.mxdh " +
            " left join da_sp_bxda  h on h.bxbh=a.bxbh " +
            " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
             " left join(SELECT csbh rklxbh,csmc rklxmc FROM dbo.da_qj_csb WHERE csfl='RKLX') k on g.rkfs=k.rklxbh " +
            "where 1=1  " + self.GetSqlWhere() +
            ") as hzb " +
            "group by  " + dynamicShowString + " spkh,ksmc,jldw,ysbh,yslsh,cmzbh,bxbh,bxmc,ysmc" + dynamicShowString1 + dynamicShowStringEnd
            }
            else if (ywflag == "CT") {
                var curjjze = "";
                if (curSFQY_CGYW_JJZE_SHURU == "0") {
                    curjjze = "sum(sl*jj) hjjze "
                }
                else {
                    curjjze = "SUM(hjjze) hjjze "
                }
                finishSql = "select " + dynamicShowStr +
            "spkh,ksmc,jldw,cmzbh,ysbh,ysmc ,bxbh,bxmc," + dynamicShowStr1 +
            "sum(isnull(cm1,0)) cm1,sum(isnull(cm2,0)) cm2,sum(isnull(cm3,0)) cm3,sum(isnull(cm4,0)) cm4,sum(isnull(cm5,0)) cm5,sum(isnull(cm6,0)) cm6,sum(isnull(cm7,0)) cm7,sum(isnull(cm8,0)) cm8," +
            "sum(isnull(cm9,0)) cm9,sum(isnull(cm10,0)) cm10,sum(isnull(cm11,0)) cm11,sum(isnull(cm12,0)) cm12,sum(isnull(cm13,0)) cm13," +
            "sum(isnull(cm14,0)) cm14,sum(isnull(cm15,0)) cm15,sum(isnull(cm16,0)) cm16,sum(isnull(cm17,0)) cm17,sum(isnull(cm18,0)) cm18," +
            "sum(isnull(cm19,0)) cm19,sum(isnull(cm20,0)) cm20,sum(isnull(cm21,0)) cm21,sum(isnull(cm22,0)) cm22,sum(isnull(cm23,0)) cm23," +
            "sum(isnull(cm24,0)) cm24,sum(isnull(cm25,0)) cm25,sum(isnull(cm26,0)) cm26,sum(isnull(cm27,0)) cm27,sum(isnull(cm28,0)) cm28," +
            "sum(isnull(cm29,0)) cm29,sum(isnull(cm30,0))cm30,sum(isnull(cm31,0))cm31,sum(isnull(cm32,0))cm32,sum(isnull(cm33,0)) cm33," +
            "sum(isnull(cm34,0))cm34,sum(isnull(cm35,0)) cm35," +

            "sum(zjsl) as zjsl, (SUM(jjze)/case when SUM(zjsl)=0 then 1 else sum(zjsl) end ) jj, sum(jjze) as jjze,max(lsj) lsj,sum(lsjze) as lsjze,max(dpj) dpj,sum(dpjze) as dpjze  " + dynamicShowStrEnd +
            " from( " +
            "select  distinct g.mxdh,a.pzh,a.spkh,b.ksmc,b.jldw,a.ysbh,a.yslsh,a.cmzbh,a.bxbh,h.bxmc,m.ysmc," +
            "g.cm1,g.cm2,g.cm3,g.cm4,g.cm5,g.cm6,g.cm7,g.cm8," +
            "g.cm9,g.cm10,g.cm11,g.cm12,g.cm13,g.cm14,g.cm15,g.cm16, " +
            "g.cm17,g.cm18,g.cm19,g.cm20,g.cm21,g.cm22,g.cm23,g.cm24, " +
            "g.cm25,g.cm26,g.cm27,g.cm28,g.cm29,g.cm30,g.cm31,g.cm32, " +
            "g.cm33,g.cm34,g.cm35,  " +
            "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) zjsl," +
            "a.lsj 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))*ISNULL(a.lsj,0) lsjze, " +
            "a.dpj 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))*ISNULL(a.dpj,0) dpjze, " +

            "a.jj jj,a.hjjze jjze, " +


            "a.kdrq,a.bmbh,c.bmmc,b.jypp,a.gysbh ,e.gysmc,b.spxb,b.hplb,d.lbmc,b.spjj,b.spml,a.cgfs,f.csmc cgfsmc,b.spnf,a.bzxx,a.hbzxx,k.rklxmc " +
             " FROM  (SELECT pzh,spkh,ysbh,yslsh,cmzbh,bxbh,SUM(sl)sl,mxdh,cgfs,gysbh,bmbh,kdrq,djlx,jj,lsj,dpj," + curjjze + " ,bzxx,hbzxx from " +
                    " (SELECT * FROM dbo.yw_cg_cgrkdtz   UNION ALL   SELECT * FROM dbo.yw_cg_cgrkdtz_ls) AS yw_cg_cgrkdtz " +
            " GROUP by pzh,spkh,ysbh,yslsh,cmzbh,bxbh,mxdh,cgfs,gysbh,bmbh,kdrq,djlx,bzxx,jj,lsj,dpj,hbzxx) 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  (SELECT * FROM yw_cg_rkdmx UNION ALL SELECT * FROM yw_cg_rkdmx_LS) g on a.pzh=g.pzh and a.mxdh=g.mxdh " +
            " left join da_sp_bxda  h on h.bxbh=a.bxbh " +
            " LEFT JOIN dbo.da_sp_ysda m ON m.ysbh = a.ysbh AND m.yslsh = a.yslsh " +
             " left join(SELECT csbh rklxbh,csmc rklxmc FROM dbo.da_qj_csb WHERE csfl='RKLX') k on g.rkfs=k.rklxbh " +
            "where a.djlx='2'  " + self.GetSqlWhere() +
            ") as hzb " +
            "group by  " + dynamicShowString + " spkh,ksmc,jldw,cmzbh,ysbh,yslsh,bxbh,bxmc,ysmc" + dynamicShowString1 + dynamicShowStringEnd
            }
            requestor.ClipBoard(finishSql)
            finishSql = finishSql.replace(/\%/g, "%25");
            finishSql = finishSql.replace(/\+/g, "%2B");
            finishSql = finishSql.replace(/\&/g, "%26");

            self.DrawDataWindow(finishSql);

        }

        DWSort(dw_format, dw_list);
        self.ControlPrice(jgtxlist, "jj");
        self.ControlPrice(jgtxlist, "lsj");
        self.ControlPrice(jgtxlist, "dpj");
        //#endregion
        dw_list.Modify(" create text(band=header alignment='2' text='序号' border='0' color='33554432' x='0' y='0' height='52' width='183' html.valueishtml='0'  name=xh_t visible='1'  font.face='Tahoma' font.height='-9' font.weight='400'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='536870912' background.transparency='0' background.gradient.color='8421504' background.gradient.transparency='0' background.gradient.angle='0' background.brushmode='0' background.gradient.repetition.mode='0' background.gradient.repetition.count='0' background.gradient.repetition.length='100' background.gradient.focus='0' background.gradient.scale='100' background.gradient.spread='100' tooltip.backcolor='134217752' tooltip.delay.initial='0' tooltip.delay.visible='32000' tooltip.enabled='0' tooltip.hasclosebutton='0' tooltip.icon='0' tooltip.isbubble='0' tooltip.maxwidth='0' tooltip.textcolor='134217751' tooltip.transparency='0' transparency='0' )")
        dw_list.Modify("xh_t.y='" + dw_list.Describe("zjsl_t.y") + "'");

        self.SetValue(C_CheckValue, curBbmc, curCdbh, curYhbh);
    }
    //#endregion

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

    //选中后赋值

    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

    //#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 + "')";
        }
        //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 (curSex.length > 0) {
            realSql += " and b.spxb ='" + curSex + "'";

        }
        if (curNF.length > 0) {
            if (curNF != "--") {
                realSql += " and  b.spnf in (" + curNF + ")";
            }
        }
        //        if (curspbh.length > 0) {

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

        return realSql;

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

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

        var temChar = words.toString().charAt(0);
        if (!(temChar == "'"))
            words = "'" + words + "'";
        return words;
    }
    //#endregion

    //#region 表头颜色
    this.RowFocusChanged = function () {
        if (rb_hx.GetChecked()) {
            for (var i = 1; i < 36; i++) {
                var str = "";
                if (ColorRow == "1") {
                    str = "cm" + i;
                }
                else {
                    str = "cm" + i + "0" + (parseInt(ColorRow) - 1);
                }
                dw_list.Modify(str + "_t.color='33554432'" + str + "_t.Font.Weight='400'");

            }
            var row = dw_list.GetRow();
            if (row < 1) {
                return;
            }
            var cmzbh = dw_list.GetItemString(row, "cmzbh");
            var spkh = dw_list.GetItemString(row, "spkh");
            dw_1.Retrieve(cmzbh, spkh);
            //alert([spkh, cmzbh]);
            var modifyColor = dw_1.GetItemString(1, "colorchange").split("#")[0].toString();

            for (var i = 1; i < 36; i++) {

                var str = "";
                if (modifyColor == "1") {
                    str = "cm" + i;
                }
                else {
                    str = "cm" + i + "0" + (parseInt(modifyColor) - 1);
                }
                dw_list.Modify(str + "_t.color='16711680'" + str + "_t.Font.Weight='700'");

            }
            ColorRow = modifyColor;
        }
    }
    //#endregion

    //#region PostOpen(初始化)
    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.TongJi) == "function")
            requestor.AttachEvent("btn_Query", "Clicked", self.TongJi);
        if (typeof (self.Print) == "function")
            requestor.AttachEvent("btn_Print", "Clicked", self.Print);

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

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

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

        if (typeof (self.SelectGS) == "function")
            requestor.AttachEvent("cb_Select", "Clicked", self.SelectGS);

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

        if (typeof (self.DoubleClicked) == "function")
            requestor.AttachEvent("dw_List", "DoubleClicked", self.DoubleClicked);

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

        if (typeof (self.RightKey) == "function")
            requestor.AttachEvent("xxxxxxaToolStripMenuItem", "Clicked", self.RightKey);
        if (cbx_rkfs == null) {
            cbx_rkfs = new CheckBox(requestor);
            cbx_rkfs.Attach(requestor.Control("cbx_rkfs"));
        }

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

        //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");
        curCdbh = requestor.GetParm("curCdbh");
        curYhbh = requestor.GetParm("curYhbh");
        curYhmc = requestor.GetParm("curYhmc");
        jgtxlist = requestor.GetParm("curjgqx");
        curQDID = requestor.GetParm("curQDID");
        curSFQY_CGYW_JJZE_SHURU = GetGlobalParm("XTCS", "SFQY_CGYW_JJZE_SHURU", "qybz");
        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");

        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 = "";
        }

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

    //#region Function DrawDataWindow
    this.DrawDataWindow = function (parameter) {
        webReq.Invoke("GetSnataxAndDataFromSql", "sql=" + parameter);
        //mle_1.SetText(parameter);
        if (webReq.StatusCode() == 200) {
            dw_temp.SetFullState(webReq.ResponseText());
            //dw_temp.Refresh();
            dw_list.SetFullState(dw_temp.GetFullState());
            if (rb_hx.GetChecked()) {
                var curcm = dw_list.GetStringData1();
                Set35ColTitel_DHH(dw_list, false, curcm);
                dw_list.SetRedraw(false);
            }
            dw_list.SetRowSelection(1);
            gRowCount = dw_list.RowCount();
            var colCount = dw_list.Describe("DataWindow.Column.Count");
         
            self.SetItemName(colCount);

        } else {
            alert("error!");
        }
//        dw_list.SetRedraw(true)
    }
    //#endregion 

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

        var ls_columntitle = "";
        for (var li_loop1 = 1; li_loop1 <= colCount; li_loop1++) {
            var ls_columnname = dw_list.Describe('#' + String(li_loop1) + '.name');
            switch (ls_columnname) {
                case "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 "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 "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 "rq":
                    ls_columntitle = "日期";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "jldw":
                    ls_columntitle = "单位";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    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 "cmbh":
                    ls_columntitle = "尺码";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 100 + "'");
                    break;
                case "cmdm":
                    ls_columntitle = "尺码";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;
                case "cmzbh":
                    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 "cgfsmc":
                    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 "hplb":
                    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 "cgy":
                    ls_columntitle = "采购人";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "bzxx":
                    ls_columntitle = "备注";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "hbzxx":
                    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.00' ")
                    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 "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 "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 "rklxmc":
                    ls_columntitle = "入库方式";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;

            }
        }
        
        self.SetSummary();

    }

    this.SetSummary = function () {
        var ls_bqkcx = "";
        var ls_lswidth = "";
        var ls_syntax = '';
        var ls_bqkcwidth = "";
        var ls_bqrkwidth = "";
        ls_spmcx = dw_list.Describe("lbmc.x");
        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 compute(band=summary alignment='1' expression='sum(lsjze  for all)' border='0' color='128' x='" + ls_lszjex + "' y='8' height='60' width='" + ls_lszjewidth + "' name=compute_1  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='60' width='" + ls_jjzewidth + "' name=compute_1  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='60' width='" + ls_slwidth + "' name=compute_1  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 text(band=summary alignment='1'  text='(" + gRowCount + "行)合计:' border='0' color='128' x='" + ls_spmcx + "'  y='0' height='60' width='" + ls_slwidth + "' html.valueishtml='0'   name=t_1 visible='1'  font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='1073741824')"
        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')"

        ls_syntax = ls_syntax + "create compute(band=detail alignment='2' expression='getrow()' border='0' color='33554432' x='0' y='8' height='72' width='215' 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.Modify(ls_syntax);
        if (rb_hx.GetChecked()) {
            var tempcmx = "";
            var tempcmy = "";
            var tempcmwidth = "";
            var temp_syntax = "";
            for (var i = 1; i < 35; i++) {
                tempcmx = dw_list.Describe("cm" + i + ".x");
                tempcmy = dw_list.Describe("cm" + i + ".y");
                tempcmwidth = dw_list.Describe("cm" + i + ".width");
                temp_syntax += " create compute(band=summary alignment='1' expression='sum(cm" + i + " for all)'border='0' color='128' x='" + tempcmx + "' y='8' height='60' width='" + tempcmwidth + "' format='######' html.valueishtml='0'  name=sum_cm" + i + " visible='1'  font.face='Tahoma' font.height='-10' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='1' 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(temp_syntax);
            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='#########'");
            dw_list.Modify(" cm1.width='120' cm2.width='120' cm3.width='120' cm4.width='120' cm5.width='120' cm6.width='120' cm7.width='120' cm8.width='120' cm9.width='120' cm10.width='120' cm11.width='120' cm12.width='120' cm13.width='120' cm14.width='120' cm15.width='120' cm16.width='120' cm17.width='120' cm18.width='120' cm19.width='120' cm20.width='120' cm21.width='120' cm22.width='120' cm23.width='120' cm24.width='120' cm25.width='120' cm26.width='120' cm27.width='120' cm28.width='120' cm29.width='120' cm30.width='120' cm31.width='120' cm32.width='120' cm33.width='120' cm34.width='120' cm35.width='120'");
         }
        
    }
    //#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'");
                //dw_list.Modify("grand_sum_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 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 ywflag = requestor.GetParm("ywflag");
        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) {
        isFirstSave = "";
        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=KC" + "&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_bm.SetChecked(false);
        cbx_gys.SetChecked(false);
        cbx_lb.SetChecked(false);
        cbx_pzh.SetChecked(false);
        cbx_fs.SetChecked(false);
        cbx_bzxx.SetChecked(false);
        cbx_hbzxx.SetChecked(false);
        //界面控制
        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_hx") {
            rb_hx.SetChecked(true);
        }
        else if (bbfl == "rb_zx") {
            rb_zx.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=CG" + "&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_hx.GetChecked()) {
            curBbmc = "rb_hx";
        }
        if (rb_zx.GetChecked()) {
            curBbmc = "rb_zx";
        }

    }
    //#endregion 

    //#region 提交
    this.ReportSave = function () {
        self.PropertCheckStatus();
        var msg = ReportSaveEx(dw_list, dw_format_hz, dw_format_mx, curUserId, 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_bm.GetChecked()) {
            ChildDWCheckValue += "cbx_bm,"
        }
        //供应商
        if (cbx_gys.GetChecked()) {
            ChildDWCheckValue += "cbx_gys,"
        }
        //凭证号
        if (cbx_pzh.GetChecked()) {
            ChildDWCheckValue += "cbx_pzh,"
        }
        //类别
        if (cbx_lb.GetChecked()) {
            ChildDWCheckValue += "cbx_lb,"
        }
        //方式
        if (cbx_fs.GetChecked()) {
            ChildDWCheckValue += "cbx_fs,"
        }
        //备注
        if (cbx_bzxx.GetChecked()) {
            ChildDWCheckValue += "cbx_bzxx,"
        }
        //行备注
        if (cbx_hbzxx.GetChecked()) {
            ChildDWCheckValue += "cbx_hbzxx,"
        }
    }
    //#endregion

    //#region 定义title高度
    this.A8erp_Report_Header_Row_Height = function (curDw_List, curSingleFlag) {
        if (curSingleFlag) {
            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_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);
        //#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_hx.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();
        }
        if (rb_zx.GetChecked()) {
            self.Query(); // 纵向
           
            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();
          
            self.A8erp_Report_Header_Row_Height(dw_list, true);
            
        }

        //JS样式。
        //给Title加颜色。。
        A8erp_Report.ReportDataWindowHeaderColor(dw_list);
        self.A8erp_Report_Style(dw_list);
        self.A8erp_Report_Detail_Row_Height(dw_list);
        //requestor.ClipBoard(dw_list.Describe("datawindow.syntax"))
        dw_list.SetRedraw(true);
    }
    //#endregion

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

        ChildDWCheckValue = str1;
        curBbmc = str2;
        curCdbh = str3;
        curUserId = str4;
    }
    //#endregion

    //#region 双击标题排序
    this.DoubleClicked = function (x, y, row, dwcName) {

        if (dwcName.indexOf("_t") > -1) {
            var curColName = dwcName.split("_")[0];
            if (curColName == lastSortName) {
                dw_list.SetSort(curColName + " A");
                lastSortName = "";
                dw_list.Sort();
            } else {
                dw_list.SetSort(curColName + " D");
                lastSortName = dwcName.split("_")[0];
                dw_list.Sort();
            }
        }
    }
    //#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 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);
    }

}

