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

function W_CW_GYSDZD_Main() {

    var self = this;
    var requestor = new PBWindow();
    var dp_2 = new DatePicker(requestor);
    var dp_1 = new DatePicker(requestor);
    var sle_bm = new SingleLineEdit(requestor);
    var sle_gys = new SingleLineEdit(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);
    var sle_sk = new SingleLineEdit(requestor);
    var sle_ck = new SingleLineEdit(requestor);
    var cb_Save = new CommandButton(requestor);
    var cb_Select = new CommandButton(requestor);
    var sle_formatname = new SingleLineEdit(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 (sle_sk == null) sle_sk = new SingleLineEdit(requestor);
        sle_sk.Attach(win.Control("sle_sk"));
        if (sle_ck == null) sle_ck = new SingleLineEdit(requestor);
        sle_ck.Attach(win.Control("sle_ck"));
        if (dp_2 == null) dp_2 = new DatePicker(requestor);
        dp_2.Attach(win.Control("dp_2"));
        if (dp_1 == null) dp_1 = new DatePicker(requestor);
        dp_1.Attach(win.Control("dp_1"));
        if (sle_bm == null) sle_bm = new SingleLineEdit(requestor);
        sle_bm.Attach(win.Control("sle_bm"));
        if (sle_gys == null) sle_gys = new SingleLineEdit(requestor);
        sle_gys.Attach(win.Control("sle_gys"));
        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 (sle_formatname == null) sle_formatname = new SingleLineEdit(requestor);
        sle_formatname.Attach(win.Control("sle_formatname"));

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

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

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

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

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

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

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

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

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

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

    


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

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

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

    }

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

        dp_2.Detach(); dp_2 = null;
        sle_sk.Detach(); sle_sk = null;
        sle_ck.Detach(); sle_ck = null;
        dp_1.Detach(); dp_1 = null;
        sle_bm.Detach(); sle_bm = null;
        sle_gys.Detach(); sle_gys = 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;
        sle_formatname.Detach(); sle_formatname = 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 curW_YW_LIST = new W_YW_LIST();
    var curBbmc = "rb_sp";
    var C_CheckValue = "";
    var curKhyeJqdBm = "0";
    var curKhdzdNew = "0";
    var curYhbh = "";
    var curCdbh = "";


    //报表名称
    var curBBMCNew = "";
    var curBBPZH = "";
    var curOptype = "0" //0 ：保存  1：修改 
    var cur_Open_Window = null;
    var ChildDWCheckValue = "";
    var curDw_format_hz = null; //格式汇总窗口
    var curDw_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 = "";
    curQxStr = "";
    var curW_GysJsd_Edit = new W_GysJsd_Edit();

    //#region PostOpen
    this.PostOpen = function () {


        sle_bm.SetEnabled(false);
        sle_gys.SetEnabled(false);
        curDw_format_hz = window.external.Control("dw_format_hz");
        curDw_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.ckfschanges) == "function")
            requestor.AttachEvent("cb_ck", "Clicked", self.ckfschanges);
        if (typeof (self.skfschanges) == "function")
            requestor.AttachEvent("cb_sk", "Clicked", self.skfschanges);
        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());
        dp_2.SetValue(UtcDateFormatToString(new Date().getVarDate()));
        dw_list.SetRowSelection("1");
        curKhyeJqdBm = GetGlobalParm("cw_jqdbm", "gys_jqdbm", "qybz");
        curKhdzdNew = GetGlobalParm("XTCS", "CW_NEW", "qybz");
        curCdbh = requestor.GetParm("curCdbh");
        curYhbh = requestor.GetParm("curYhbh");
        dw_format.RetrieveEx("cdbh='" + curCdbh + "' and yhbh='" + curYhbh + "' and bbmc='" + curBbmc + "'");
        //旧版财务
        if (curKhdzdNew == "0") {

            if (curKhyeJqdBm == "1") {
                dw_temp.SetDataObject("dw_cw_gysbmdzd_list");
            }
            else {
                dw_temp.SetDataObject("dw_cw_gysdzd_list");
            }
        } else {
            if (curKhyeJqdBm == "1") {
                dw_temp.SetDataObject("da_cw_new_gysbmdzd_list");
            }
            else {
                dw_temp.SetDataObject("da_cw_new_gysdzd_list");
            }
        }

        curFromYGSYE = requestor.GetParm("curFromYGSYE");

        if (curFromYGSYE.length > 0) {
            dp_1.SetValue(curFromYGSYE.split("@@@")[0]);
            dp_2.SetValue(curFromYGSYE.split("@@@")[1]);
            sle_gys.SetText("'" + curFromYGSYE.split("@@@")[2] + "'");
            if (curFromYGSYE.split("@@@")[3].length > 0) {
                sle_bm.SetText("'" + curFromYGSYE.split("@@@")[3] + "'");
            }

            self.Query();
        }
        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 = "";
        }

        // SetDecimalColumnFormat(dw_list,"")
    }
    //#endregion

    //#region Function 呼出数据窗口的函数群 
    this.Changebmbh = function (x, y, row, dwoName) {
        dwoName == "bmbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_CW_GYSDZD_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=cwcx"), curW_OPEN_BMDA_NEW, null);
    }

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

    this.skfschanges = function (x, y, row, dwoName) {
        dwoName == "skfs";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_CW_GYSDZD_Main, "skfs", "skmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_pub_list_qj_csb_skfs&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 ("skfs" == difBh)
            sle_sk.SetText(val);
        else if ("csbh" == difBh)
            sle_ck.SetText(val);
    }
    //#endregion

    //#region 执行查询
    this.Query = function () {
        dw_temp.RetrieveEx("1=1 " + self.GetSqlWhere(true))
        var curRowCount = dw_temp.RowCount();
        dw_list.SetFullState(dw_temp.GetFullState());
        DWSort(dw_format, dw_list);
        self.SetValue(C_CheckValue, curBbmc, curCdbh, curYhbh);

        requestor.ClipBoard(dw_list.Describe("DataWindow.syntax"))
        
    }
    //#endregion

    //#region 获取where 条件
    this.GetSqlWhere = function (flag) {
        var realSql = "";
        var beginDate = UtcDateFormatToString(dp_1.GetValue());
        var endDate = UtcDateFormatToString(dp_2.GetValue());
        var curYhbh = requestor.GetParm("curYhbh")
        var curBm = sle_bm.GetText();
        var curGys = sle_gys.GetText();
        var curck = sle_ck.GetText();
        var cursk = sle_sk.GetText();
        if (curKhdzdNew == "0") {
            realSql += " and (CONVERT(date,kdrq) between '" + beginDate + "' and '" + endDate + "')";
        }
        else {
            realSql += " and (CONVERT(date,rq) between '" + beginDate + "' and '" + endDate + "')";
        }

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

            curGys = self.DealWords(curGys);
            if (flag == true)
                realSql += " and gysbh in(" + curGys + ")";
            else
                realSql += " and gysbh in('" + curGys + "')";
        } else {
            realSql += "and gysbh in(select gysbh  from da_qx_gysda where yhbh = '" + curYhbh + "'and bz3 = '1')";
        }
        if (curck.length > 0) {

            curck = self.DealWords(curck);
            if (curKhdzdNew == "1") {
                realSql += " and ckfs in(select  csmc from da_qj_csb  where csfl='CG_CGFS' and csbh in (" + curck + "))";
            } else {
                realSql += " and ckfs in(select  csmc from da_qj_csb  where csfl='CG_CGFS' and csbh in(" + curck + "))";
            }
        }

        if (cursk.length > 0) {
            cursk = self.DealWords(cursk);
            if (curKhdzdNew == "1") {
                realSql += " and fkfs in(select  csmc from da_qj_csb  where csfl='skfs' and csbh in(" + cursk + "))";
            } else {
                realSql += " and fkfs in(select  csmc from da_qj_csb  where csfl='skfs' and csbh in(" + cursk + "))";
            }
        }
        //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;
    }

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

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

        return words;

    }
    //#endregion
    //#endregion

    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();
            }
            return 1;
        }
        var curPzh = "";
        var curLydh = "";
        var itemData = "";
        var itemLabel = "";
        var curRow = dw_list.GetRow();
        if (curRow > 0) {
            curPzh = dw_list.GetItemString(curRow, "pzh");
            curLydh = dw_list.GetItemString(curRow, "lydh");

            if (curLydh.length > 0 && curLydh.substring(0, 2) != "CB") {

                curPzh = curLydh;

            }

            if (curKhdzdNew == "1") {
                var ts_1 = window.external.Control("ts_1");
                if (curPzh.substring(0, 2) == "CR") {
                    itemData = "SJ006";
                    itemLabel = "采购入库单";
                } else if (curPzh.substring(0, 2) == "CT") {
                    itemData = "SJ090";
                    itemLabel = "采购退库单";
                } else if (curPzh.substring(0, 2) == "FK") {
                    itemData = "SJ560";
                    itemLabel = "进货付款单";
                } else if (curPzh.substring(0, 2) == "JF") {
                    itemData = "SJ561";
                    itemLabel = "进货费用单";
                } else if (curPzh.substring(0, 2) == "TJ") {
                    itemData = "SJ651";
                    itemLabel = "供应商调价单";
                } else if (curPzh.substring(0, 2) == "GJ") {


                    //#region 供应商结算单 模式不一样

                      
                        var curPzh = curPzh
                        curW_GysJsd_Edit.SetDataWindow("Edit", self, null, curPzh);
                        requestor.Open("/Service/LoadWindow.ashx?WinName=A8ERP.CaiWu.GysJsd.W_GysJsd_Edit&curParm1=EDIT&curPzh=" + curPzh + "&CURGNQXSTR=" + curQxStr, curW_GysJsd_Edit, null);
                    //#endregion

                    return;
                }
                ts_1.CloseItem(itemData);

                ts_1.Open(itemData, itemLabel, '', "/Service/OpenSheet.aspx?FunID=" + itemData + "&curDate=" + new Date().toLocaleTimeString() + "&Reload=Y&curDzdPzh=" + curPzh, true);
            } else {
                //window.parent.OpenSheet("SJ811", "订单管理", ddbh);
                requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.CaiWu.CaiWuTongJiFenXi.W_YW_LIST&curpzh=" + curPzh + "&curJqdbm=" + curKhyeJqdBm), curW_YW_LIST, null);
            }
        }
    }

    //#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 (curDw_format_hz.RowCount() > 0) {
            tempPzh = curDw_format_hz.GetItemString("1", "pzh");
        }
        //        if (tempPzh.length <= 0 || sle_formatname.GetText().length <= 0) {
        //            requestor.MessageBox("提示", "请先选择报表格式", ICON.StopSign);
        //            return;
        //        }
        curDw_format_mx.Reset();
        curDw_format_hz.Reset();
        sle_formatname.SetText("");
        self.TongJi();
    }
    this.ClearAndTJ = function (isTj) {
        curDw_format_hz.RetrieveEx("pzh='" + curBBPZH + "'");
        curDw_format_mx.RetrieveEx("pzh='" + curBBPZH + "'");
        curDw_format_mx.SetFilter("mrgxtj='1'");
        curDw_format_mx.Filter();
        xsmrgs = curDw_format_mx.RowCount();
        //界面控制
        evealStr = "";
        for (var i = 1; i <= curDw_format_mx.RowCount(); i++) {
            evealStr += curDw_format_mx.GetItemString(i, "col") + ".SetChecked(true);";
        }
        eval(evealStr);

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

    //#region 横向/纵向

    this.SetBbfl = function (bbfl) {
        if (bbfl == "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=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 () {

        curBbmc = "rb_sp";


    }
    //#endregion 

    //#region 提交
    this.ReportSave = function () {
        //self.PropertCheckStatus();
        var msg = ReportSaveEx(dw_list, curDw_format_hz, curDw_format_mx, curUserId, curCdbh, curBbmc, curBBPZH, curYhbh, curBBMCNew, "", "", isFirstSave);
        if (msg == "OK") {
            requestor.MessageBox("提示", "保存成功", ICON.Information);
            curDw_format_mx.ResetUpdate();
            curDw_format_mx.SetFilter("mrgxtj='1'");
            curCol = requestor.GetParm("curCol");
            curDw_format_mx.Filter();
            xsmrgs = curDw_format_mx.RowCount();
            curDw_format_mx.SetFilter("");
            curDw_format_mx.Filter();
            curDw_format_mx.SetFilter("mrgxtj='0'");
            curDw_format_mx.Filter();
            self.TongJi();
            return;
        }
        else {
            requestor.MessageBox("提示", msg, ICON.StopSign);
        }
    }
    //#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='86'");
    }
    //#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 () {
        curDw_format_mx.SetRedraw(false);
        curDw_format_mx.SetSort("col_x A");
        curDw_format_mx.Sort();
        for (var i = 1; i <= curDw_format_mx.RowCount(); i++) {
            var curCol = curDw_format_mx.GetItemString(i, "col");
            var curVisible = curDw_format_mx.GetItemString(i, "visible");
            dw_list.Modify(curCol + ".visible='0'");
            dw_list.Modify(curCol + ".visible='" + curVisible + "'");
            var curWidth = curDw_format_mx.GetItemNumber(i, "width");
            dw_list.Modify(curCol + ".width='" + curWidth + "'");
            var curColHz = curDw_format_mx.GetItemString(i, "col_hz");
            dw_list.Modify(curCol + "_t.Text='" + curColHz + "'");
            var curfont_face = curDw_format_mx.GetItemString(i, "font_face");
            dw_list.Modify(curCol + ".Font.Face='" + curfont_face + "'");

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

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

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

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

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

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

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

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

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

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

            var ls_bg_color = curDw_format_mx.GetItemString(i, "bg_color");
            dw_list.Modify(curCol + ".Background.Color='" + ls_bg_color + "'");
        }
        curDw_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);
        curDw_format_hz.RetrieveEx("pzh='" + curBBPZH + "'");
        curDw_format_mx.RetrieveEx("pzh='" + curBBPZH + "'");
    }
    //#endregion

    //#region  执行查询
    this.TongJi = function () {
        dw_list.SetRedraw(false);
        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();

        //self.A8erp_Report_Header_Row_Height(dw_list, true);
        //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.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

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

//W_CW_GYSDZD_Main.prototype = new W_CG_HZ_Base();