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

function W_CW_KMZC_Main() {

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var cbx_zy = new CheckBox(requestor);
    var cbx_hbzxx = new CheckBox(requestor);
    var cbx_zdr = new CheckBox(requestor);
    var cbx_rq = new CheckBox(requestor);
    var cbx_pzh = new CheckBox(requestor);
    var cbx_kh = new CheckBox(requestor);
    var cbx_zh = new CheckBox(requestor);
    var cbx_bz = new CheckBox(requestor);
    var dp_1 = new DatePicker(requestor);
    var dp_2 = new DatePicker(requestor);
    var sle_gys = new SingleLineEdit(requestor);
    var sle_bm = new SingleLineEdit(requestor);
    var sle_zh = new SingleLineEdit(requestor);
    var cbx_bm = new CheckBox(requestor);
  
    var dw_temp = new DataWindow(requestor);
    var dw_format = new DataWindow(requestor);
    var dw_list = new DataWindow(requestor);
    var tb_1 = new ToolStrip(requestor);


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

        if (requestor == null) requestor = new PBWindow();
        requestor.Attach(win);
        if (cbx_zy == null) cbx_zy = new CheckBox(requestor);
        cbx_zy.Attach(win.Control("cbx_zy"));
        if (cbx_hbzxx == null) cbx_hbzxx = new CheckBox(requestor);
        cbx_hbzxx.Attach(win.Control("cbx_hbzxx"));
        if (cbx_zdr == null) cbx_zdr = new CheckBox(requestor);
        cbx_zdr.Attach(win.Control("cbx_zdr"));
        if (cbx_rq == null) cbx_rq = new CheckBox(requestor);
        cbx_rq.Attach(win.Control("cbx_rq"));
        if (cbx_pzh == null) cbx_pzh = new CheckBox(requestor);
        cbx_pzh.Attach(win.Control("cbx_pzh"));
        if (cbx_kh == null) cbx_kh = new CheckBox(requestor);
        cbx_kh.Attach(win.Control("cbx_kh"));
        if (cbx_zh == null) cbx_zh = new CheckBox(requestor);
        cbx_zh.Attach(win.Control("cbx_zh"));
        if (cbx_bz == null) cbx_bz = new CheckBox(requestor);
        cbx_bz.Attach(win.Control("cbx_bz"));
        if (dp_1 == null) dp_1 = new DatePicker(requestor);
        dp_1.Attach(win.Control("dp_1"));
        if (dp_2 == null) dp_2 = new DatePicker(requestor);
        dp_2.Attach(win.Control("dp_2"));
        if (sle_gys == null) sle_gys = new SingleLineEdit(requestor);
        sle_gys.Attach(win.Control("sle_gys"));
        if (sle_bm == null) sle_bm = new SingleLineEdit(requestor);
        sle_bm.Attach(win.Control("sle_bm"));
        if (sle_zh == null) sle_zh = new SingleLineEdit(requestor);
        sle_zh.Attach(win.Control("sle_zh"));
        if (cbx_bm == null) cbx_bm = new CheckBox(requestor);
        cbx_bm.Attach(win.Control("cbx_bm"));
        if (sle_formatname == null) sle_formatname = new SingleLineEdit(requestor);
        sle_formatname.Attach(win.Control("sle_formatname"));
        if (dw_temp == null) dw_temp = new DataWindow(requestor);
        dw_temp.Attach(win.Control("dw_temp"));
        if (dw_format == null) dw_format = new DataWindow(requestor);
        dw_format.Attach(win.Control("dw_format"));
        if (dw_list == null) dw_list = new DataWindow(requestor);
        dw_list.Attach(win.Control("dw_list"));
        if (tb_1 == null) tb_1 = new ToolStrip(requestor);
        tb_1.Attach(win.Control("tb_1"));

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

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

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

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

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

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

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

    }

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

        cbx_zy.Detach(); cbx_zy = null;
        cbx_hbzxx.Detach(); cbx_hbzxx = null;
        cbx_zdr.Detach(); cbx_zdr = null;
        cbx_rq.Detach(); cbx_rq = null;
        cbx_pzh.Detach(); cbx_pzh = null;
        cbx_kh.Detach(); cbx_kh = null;
        cbx_zh.Detach(); cbx_zh = null;
        cbx_bz.Detach(); cbx_bz = null;
        dp_1.Detach(); dp_1 = null;
        dp_2.Detach(); dp_2 = null;
        sle_gys.Detach(); sle_gys = null;
        sle_bm.Detach(); sle_bm = null;
        sle_zh.Detach(); sle_zh = null;
        cbx_bm.Detach(); cbx_bm = null;
        dw_format_hz.Detach(); dw_format_hz = null;
        dw_format_mx.Detach(); dw_format_mx = null;
        dw_temp.Detach(); dw_temp = null;
        dw_format.Detach(); dw_format = null;
        dw_list.Detach(); dw_list = null;
        tb_1.Detach(); tb_1 = null;
        requestor.Detach(); requestor = null;

        setTimeout(CollectGarbage, 100);
    }

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

    var curW_OPEN_BMDA = new OpenWindowQueryBase();

    var curW_OPEN_BMDA_NEW = new OpenWindowQueryNewBase();
    var curW_OPEN_BMDA_URL = "OpenWindowQueryNewBase";
    
    
    var curW_OPEN_SIMPLE_CHOSE = new OpenWindowSimpleChoseBase();
    var curOpenWindowTypeRecursion = new OpenWindowTypeRecursion();
    var curW_YW_LIST = new W_YW_LIST()
    webReq = new WebRequestor();
    webReq.SetWebServiceUrl("/Service/ServiceForDwSyndax.ashx");
    var curYhbh = "";
    var curCdbh = "";
    var C_CheckValue = "";
    var curKhyeJqdBm = "0";
    var curKhdzdNew = "0";
    var curBbmc = "rb_sp";

    //报表名称
    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 jgtxlist = "";

    var sle_formatname = new SingleLineEdit(requestor);
    var cb_Save = new CommandButton(requestor);
    var cb_Select = new CommandButton(requestor);
    var ContextMenuStrip1 = new ContextMenu(requestor);
    var curSelDays = ""; //默认该模块可查询天数
    var dw_format_hz = new DataWindow(requestor);
    var dw_format_mx = new DataWindow(requestor);
    //#region PostOpen
    this.PostOpen = function () {
        sle_bm.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 (sle_formatname == null) 
        sle_formatname = new SingleLineEdit(requestor);
        sle_formatname.Attach(requestor.Control("sle_formatname"));
        if (cb_Save == null) cb_Save = new CommandButton(requestor);
        cb_Save.Attach(requestor.Control("cb_Save"));
        if (cb_Select == null) cb_Select = new CommandButton(requestor);
        cb_Select.Attach(requestor.Control("cb_Select"));
        if (ContextMenuStrip1 == null) ContextMenuStrip1 = new ContextMenu(requestor);
        ContextMenuStrip1.Attach(requestor.Control("ContextMenuStrip1"));


        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.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.TongJi) == "function")
            requestor.AttachEvent("btn_Query", "Clicked", self.TongJi);

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

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


//        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";
        }
        if (typeof (self.BillCheck) == "function")
            requestor.AttachEvent("cbx_pzh", "Clicked", self.BillCheck);
        if (typeof (self.BZCheck) == "function")
            requestor.AttachEvent("cbx_bz", "Clicked", self.BZCheck);
        curCdbh = requestor.GetParm("curCdbh");
        curYhbh = requestor.GetParm("curYhbh");
        curSelDays = GetXiTongCanShu(curYhbh, curCdbh, "bzxx");
        curKhyeJqdBm = GetGlobalParm("cw_jqdbm", "jqdbm", "qybz");
        curKhdzdNew = GetGlobalParm("XTCS", "CW_NEW", "qybz");
        curBbmc = "rb_sp";
        dw_list.SetClickHeaderSort(false);
        dw_format.RetrieveEx("cdbh='" + curCdbh + "' and yhbh='" + curYhbh + "' and bbmc='" + curBbmc + "'");
        dw_format.SetFilter("mrgxtj='1'");
        dw_format.Filter();
        var evealStr = "";
        //alert(dw_format.RowCount())
        for (var i = 1; i <= dw_format.RowCount(); i++) {
            evealStr += dw_format.GetItemString(i, "col") + ".SetChecked(true);";
        }
        window.eval(evealStr);
        dw_format.SetFilter("");
        dw_format.Filter();
        dw_format.SetFilter("mrgxtj='0'");
        dw_format.Filter();
        var myDate = new Date();
        var nian = myDate.getFullYear().toString();
        var yue = myDate.getMonth();
        var ri = "01";
        var objDate = new Date(nian, yue, ri);
        dp_1.SetValue(objDate.getVarDate())
        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 = "";
        }
      
    }
    //#endregion
    this.BZCheck = function () {
        if (cbx_bz.GetChecked())
        { cbx_pzh.SetChecked(true); }
        else {
            cbx_pzh.SetChecked(false);
        }
    }

    this.BillCheck = function () {
        if (cbx_pzh.GetChecked()) {
            cbx_bz.SetChecked(true);
        }
        else {
            cbx_bz.SetChecked(false);
        }
    }

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

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


    this.Changegys = function (x, y, row, dwoName) {
        dwoName == "gysbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_CW_KMZC_Main, "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.Changezhanghu = function (x, y, row, dwoName) {
        //        dwoName == "kmbh";
        //        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_CW_KMZC_Main, "kmbh", "kmmc", "M", self)   // 这个用来给子窗口Set当前数据窗口
        //        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_cw_km_list&selectStyle=multiple"), curW_OPEN_SIMPLE_CHOSE, null);
        curOpenWindowTypeRecursion.SetDataWindow(self)   // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowTypeRecursion"), curOpenWindowTypeRecursion, null);

    }
    //#endregion

    //#region 选中后赋值

    this.SetSleValue = function (difBh, val) {

        if ("''" == val)
            val = "";
        if ("bmbh" == difBh)
            sle_bm.SetText(val);
        else if ("gysbh" == difBh)
            sle_gys.SetText(val);
        else if ("kmbh" == difBh)
            sle_zh.SetText(val);

    }

    //#endregion

    //#region 执行查询
    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_bm.GetChecked()) {
            dynamicShowStr += " a.bmbh as bmbh ,c.bmmc as bmmc,";
            dynamicShowString += " ,a.bmbh,c.bmmc";
            C_CheckValue += "cbx_bm,"
        }
        if (cbx_kh.GetChecked()) {
            dynamicShowStr += "a.gysbh as  gysbh,e.gysmc as gysmc,";
            dynamicShowString += ",a.gysbh,e.gysmc ";
            C_CheckValue += "cbx_kh,"
        }

        if (cbx_zh.GetChecked()) {
            if (curKhdzdNew == "0") {
                dynamicShowStr1 += " b.zczh as skzh,d.zhmc as zhmc,";
                dynamicShowString1 += ",b.zczh,d.zhmc";
            } else {
                dynamicShowStr1 += " a.xjzh as xjzh,d.zhmc as zhmc,";
                dynamicShowString1 += ",a.xjzh,d.zhmc";
            }
            C_CheckValue += "cbx_zh,"
        }
        if (cbx_pzh.GetChecked() || cbx_bz.GetChecked()) {
            if (curKhdzdNew == "0") {
                dynamicShowStr1 += " a.pzh pzh,a.bzxx bz,";
                dynamicShowString1 += " ,a.pzh,a.bzxx";
                C_CheckValue += "cbx_pzh,"
                C_CheckValue += "cbx_bz,"
            }
            else {

                dynamicShowStr1 += " a.pzh pzh,a.bz bz,";
                dynamicShowString1 += " ,a.pzh,a.bz";
                C_CheckValue += "cbx_pzh,"
                C_CheckValue += "cbx_bz,"
            }
        }

        if (cbx_rq.GetChecked()) {
            if (curKhdzdNew == "0") {
                dynamicShowStr1 += "CONVERT(date,a.rq) rq,";
                dynamicShowString1 += ",a.rq";
            } else {
                dynamicShowStr1 += "CONVERT(date,a.kdrq) kdrq,";
                dynamicShowString1 += ",a.kdrq";
            }
            C_CheckValue += "cbx_rq,"
        }

        if (cbx_zdr.GetChecked()) {
            dynamicShowStrEnd += ",a.zdr    zdr,a.zdrmc   zdrmc";
            dynamicShowStringEnd += ",a.zdr ,a.zdrmc";
            C_CheckValue += "cbx_zdr,"
        }
        if (cbx_hbzxx.GetChecked()) {
            dynamicShowStrEnd += ",a.hbzxx    hbzxx";
            dynamicShowStringEnd += ",a.hbzxx ";
            C_CheckValue += "cbx_hbzxx,"
        }
        if (cbx_zy.GetChecked()) {
            dynamicShowStrEnd += ",a.zy    zy";
            dynamicShowStringEnd += ",a.zy ";
            C_CheckValue += "cbx_zy,"
        }
        if (curKhdzdNew == "0") {
            finishSql = "select b.sfkm,f.kmmc," + dynamicShowStr + dynamicShowStr1 + "sum(isnull(a.je,0)) je" + dynamicShowStrEnd + "  from cw_xjzcpz_tz a " +
                                "left join cw_xjzcpz_sfkm b on a.pzh=b.pzh and a.mxdh=b.mxdh " +
                                "left join da_bmda c on a.bmbh=c.bmbh " +
                                "LEFT JOIN cw_xianjin_yinhang_zh d ON d.zhbh = b.zczh " +
                                "LEFT JOIN dbo.da_gysda e ON e.gysbh = a.gysbh " +
                                "left join da_cy_kmda f on f.kmbh=b.sfkm " +
                                "where  1=1 " + self.GetSqlWhere(true) + " group by  b.sfkm,f.kmmc " + dynamicShowString + dynamicShowString1 + dynamicShowStringEnd;
        } else {
            finishSql = "select km,kmmc," + dynamicShowStr + dynamicShowStr1 + "sum(isnull(a.je,0)) je " + dynamicShowStrEnd +
                        " from(select hz.pzh,bmbh,'' gysbh,kdrq,zdr,ISNULL(dbo.F_GET_NAME_BY_BH(zdr,'da_ygda'),'') zdrmc,xjzh,mx.km,mx.je,hz.bzxx bz,mx.bzxx hbzxx,mx.zy,hz.jzbz  from cw_new_xjzcpz  hz LEFT JOIN cw_new_xjzcpz_mx mx ON mx.pzh = hz.pzh " +
	                    "     union all " +
	                    "      select hz.pzh,bmbh,gysbh,rq,zdr,ISNULL(dbo.F_GET_NAME_BY_BH(zdr,'da_ygda'),'') zdrmc,fyzh,mx.sfkm,mx.je,bzxx bz,'' hbzxx,''zy,hz.jzbz from cw_new_jhfyd   hz LEFT JOIN cw_new_jhfyd_mx mx ON mx.pzh = hz.pzh" +
                        "     )a left join da_bmda c on a.bmbh=c.bmbh " +
                        "     left join cw_xianjin_yinhang_zh d on d.zhbh=a.xjzh" +
                        "     left join da_gysda  e on  e.gysbh=a.gysbh " +
                        "     left join da_cy_kmda f on f.kmbh=a.km " +
                        "where 1=1 and a.jzbz ='1' and km<>'' " + self.GetSqlWhere(true) + " group by  km,kmmc " + dynamicShowString + dynamicShowString1 + dynamicShowStringEnd;

        }

        requestor.ClipBoard(finishSql);
        finishSql = finishSql.replace(/\+/g, "%2B");
        finishSql = finishSql.replace(/\&/g, "%26");
        self.DrawDataWindow(finishSql);
        DWSort(dw_format, dw_list);
        //#endregion
        self.SetValue(C_CheckValue, curBbmc, curCdbh, curYhbh);

    }
    //#endregion

    //#region 获取where 条件
    this.GetSqlWhere = function (flag) {
        var realSql = "";
        var curYhbh = requestor.GetParm("curYhbh")
        var curBm = sle_bm.GetText();
        var curGys = sle_gys.GetText();
        var curzh = sle_zh.GetText();
        var beginDate = UtcDateFormatToString(dp_1.GetValue());
        var endDate = UtcDateFormatToString(dp_2.GetValue());
        if (curSelDays != "-1") {
            beginDate = compareDate(curSelDays, beginDate);
        }

        if (flag == true) {
            if (curKhdzdNew == "0") {
                realSql += " and (CONVERT(date,a.rq) between '" + beginDate + "' and '" + endDate + "')";
            } else {
                realSql += " and (CONVERT(date,a.kdrq) between '" + beginDate + "' and '" + endDate + "')";
            }
        }
        else {
            if (curKhdzdNew == "0") {
                realSql += " and (CONVERT(date,a.rq) between ''" + beginDate + "'' and ''" + endDate + "'')";
            } else {
                realSql += " and (CONVERT(date,a.kdrq) between ''" + beginDate + "'' and ''" + endDate + "'')";
            }
        }

        if (curBm.length > 0) {
            curBm = self.DealWords(curBm);
            if (flag == true)
                realSql += " and a.bmbh  in(" + curBm + ")";
            else
                realSql += "and  a.bmbh  in('" + curBm + "')";
        } else {
            realSql += "and a.bmbh in(select bmbh  from da_qx_bmqxsz where yhbh = '" + curYhbh + "'and tjfx = '1')"
        }
        if (curGys.length > 0) {

            curGys = self.DealWords(curGys);
            if (flag == true)
                realSql += " and a.gysbh in(" + curGys + ")";
            else
                realSql += " and a.gysbh in('" + curGys + "')";
        }
        if (curzh.length > 0) {
            curzh = self.DealWords(curzh);
            if (flag == true) {
                if (curKhdzdNew == "0") {
                    realSql += " and b.sfkm in(" + curzh + ")";
                } else {
                    realSql += " and km in(" + curzh + ")";
                }
            }
            else {
                if (curKhdzdNew == "0") {
                    realSql += " and b.sfkm in('" + curzh + "')";
                } else {
                    realSql += " and km in('" + curzh + "')";
                }
            }
        }

        //realSql += " and  CAST(CONVERT(VARCHAR(10),DATEADD(DAY,  CAST([DBO].[F_GET_DJ_CXTS]('" + curYhbh + "','CWKHYETJ') AS INT) ,a.zdrq),120) AS DATETIME) >= GETDATE()";
        //alert(realSql);
        return realSql;


    }
    //#endregion

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

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

        return words;

    }
    //#endregion

    //#region Function DrawDataWindow
    this.DrawDataWindow = function (parameter) {
        syntax = "";
        webReq.Invoke("GetSnataxAndDataFromSql", "sql=" + parameter + "&flag=Grid");
        if (webReq.StatusCode() == 200) {
            syntax = webReq.ResponseText();
            dw_temp.SetFullState(syntax);
            dw_list.SetFullState(dw_temp.GetFullState());
            dw_list.SetRowSelection(0);
            gRowCount = dw_list.RowCount();
            var colCount = dw_list.Describe("DataWindow.Column.Count");
            self.SetItemName(colCount);
        } else {
            alert("error!");
        }
        dw_list.Modify(" create text(band=header alignment='2' text='序号' border='0' color='33554432' x='0' y='0' height='76' 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("sl_t.y") + "'");

    }
    //#endregion 

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

        var ls_columntitle = "";
        for (var li_loop1 = 1; li_loop1 <= colCount; li_loop1++) {
            var ls_columnname = dw_list.Describe('#' + String(li_loop1) + '.name');
            switch (ls_columnname) {
                case "cw_xjzcpz_tz_bmbh":
                    ls_columntitle = "部门编号"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "bmbh":
                    ls_columntitle = "部门编号"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "da_bmda_bmmc":
                    ls_columntitle = "部门名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "bmmc":
                    ls_columntitle = "部门名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "cw_xjzcpz_sfkm_skzh":
                    ls_columntitle = "账户名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "cw_xianjin_yinhang_zh_zhmc":
                    ls_columntitle = "账户名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "xjzh":
                    ls_columntitle = "账户编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "zhmc":
                    ls_columntitle = "账户名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "rq":
                    ls_columntitle = "日期";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "kdrq":
                    ls_columntitle = "日期";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "cw_xjzcpz_sfkm_sfkm":
                    ls_columntitle = "科目编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "da_cy_kmda_kmmc":
                    ls_columntitle = "科目名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "km":
                    ls_columntitle = "科目编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "kmmc":
                    ls_columntitle = "科目名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "cw_xjzcpz_tz_gysbh":
                    ls_columntitle = "供应商编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "da_gysda_gysmc":
                    ls_columntitle = "供应商名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "gysbh":
                    ls_columntitle = "供应商编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "gysmc":
                    ls_columntitle = "供应商名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "cw_xjzcpz_tz_pzh":
                    ls_columntitle = "凭证号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    break;
                case "pzh":
                    ls_columntitle = "凭证号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 500 + "'");
                    break;
                case "cw_xjzcpz_tz_rq":
                    ls_columntitle = "日期";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "cw_xjzcpz_tz_zdr":
                    ls_columntitle = "制单人";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "zdr":
                    ls_columntitle = "制单人";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;

                case "je":
                    ls_columntitle = "金额";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".format='#########0.00' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "bz":
                    ls_columntitle = "备注";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "cw_xjzcpz_tz_bz":
                    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 "zy":
                    ls_columntitle = "摘要";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break
                case "zdrmc":
                    ls_columntitle = "制单人名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break
            }
        }
        self.SetSummary();
    }

    this.SetSummary = function () {

        var ls_syntax = '';

        var ls_slx = dw_list.Describe("ls_slwidth.x");
        var ls_slwidth = dw_list.Describe("ls_slwidth.width")
        var ls_lszjex = dw_list.Describe("je.x");
        var ls_lszjewidth = dw_list.Describe("je.width")
        ls_syntax = dw_list.Modify("DataWindow.summary.Height=90");
        ls_syntax = dw_list.Modify("DataWindow.header.Height=76");
        ls_syntax = ls_syntax + "create text(band=summary alignment='1'  text='(" + gRowCount + "行)合计:' border='0' color='128' x='" + ls_slx + "'  y='0' height='60' width='" + ls_slwidth + "' html.valueishtml='0'   name=t_1 visible='1'  font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='1073741824')"
        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')";
        ls_syntax = ls_syntax + "create compute(band=summary alignment='1' expression='sum(je  for all)' border='0' color='128' x='" + ls_lszjex + "' y='8' height='52' 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')"
        dw_list.Modify(ls_syntax);
    }
    //#endregion

    this.DoubleClicked = function (x, y, row, col) {
        if (row > 0) {

            //alert([x, y, row, col])
            if (col == "cw_xjzcpz_tz_pzh") {
                //反调业务
                var curpzh = dw_list.GetItemString(row, "cw_xjzcpz_tz_pzh");
                if (curpzh != "") {
                    requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.CaiWu.CaiWuTongJiFenXi.W_YW_LIST&curpzh=" + curpzh + "&curJqdbm=0"), curW_YW_LIST, null);
                }
            }

        }
    }

    this.Print = function () {
        dw_list.PrintPreview();
    }
    this.BZCheck = function () {
        if (cbx_bz.GetChecked())
        { cbx_pzh.SetChecked(true); }
        else {
            cbx_pzh.SetChecked(false);
        }
    }

    this.BillCheck = function () {
        if (cbx_pzh.GetChecked()) {
            cbx_bz.SetChecked(true);
        }
        else {
            cbx_bz.SetChecked(false);
        }
    }

    //#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];
            }
        }
        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_bm.SetChecked(false);
        cbx_zh.SetChecked(false);
        cbx_kh.SetChecked(false);
        cbx_pzh.SetChecked(false);
        cbx_rq.SetChecked(false);
        cbx_zdr.SetChecked(false);
        cbx_bz.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.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.SelectBBFL = function () {
        curBbmc = "rb_sp";


    }
    //#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=HY" + "&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.PropertCheckStatus = function () {
        ChildDWCheckValue = "";
        //部门
        if (cbx_bm.GetChecked()) {
            ChildDWCheckValue += "cbx_bm,"
        }
        if (cbx_zh.GetChecked()) {
            ChildDWCheckValue += "cbx_zh,"
        }
        if (cbx_kh.GetChecked()) {
            ChildDWCheckValue += "cbx_kh,"
        }
        if (cbx_pzh.GetChecked()) {
            ChildDWCheckValue += "cbx_pzh,"
        }
        if (cbx_rq.GetChecked()) {
            ChildDWCheckValue += "cbx_rq,"
        }
        if (cbx_zdr.GetChecked()) {
            ChildDWCheckValue += "cbx_zdr,"
        }
        if (cbx_bz.GetChecked()) {
            ChildDWCheckValue += "cbx_bz,"
        }

        if (cbx_zy.GetChecked()) {
            ChildDWCheckValue += "cbx_zy,"
        }

        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);
        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 + ".alignment='" + 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  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.TongJi = function () {
        dw_list.SetRedraw(false);
        curcbx_gs = 0;
        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();
        A8erp_Report.ReportDataWindowHeaderColor(dw_list);
        self.A8erp_Report_Style(dw_list);
        self.A8erp_Report_Header_Row_Height(dw_list, true);
        self.A8erp_Report_Detail_Row_Height(dw_list);
        //JS样式。
        dw_list.SetRedraw(true);
    }
    //#endregion

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


//CW_TJFX_Base
//W_CW_KMZC_Main.prototype = new W_CG_HZ_Base();