///<reference path="/Scripts/ExtPB_Net.js" />
///<reference path="/Scripts/MyExtPB.js" />
///<reference path="/Scripts/ExtPB_Dll_Pb_Http.js" />
///<reference path="/Scripts/MyExtPb_Input.js" />

function W_GYSFD_CG() {

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var gb_1 = new GroupBox(requestor);
    var cbx_hbzd = new CheckBox(requestor);
    var ddlb_2 = new DropDownListBox(requestor);
    var sle_formatname = new SingleLineEdit(requestor);
    var dp_2 = new DatePicker(requestor);
    var dp_1 = new DatePicker(requestor);
    var cb_bmbh = new CommandButton(requestor);
    var sle_bm = new SingleLineEdit(requestor);
    var sle_gysbh = new SingleLineEdit(requestor);
    var sle_ml = new SingleLineEdit(requestor);
    var dw_temp = new DataWindow(requestor);
    var dw_format = new DataWindow(requestor);
    var dw_list = new DataWindow(requestor);
    var dw_format_hz = new DataWindow(requestor);
    var dw_format_mx = new DataWindow(requestor);
    var tb_1 = new ToolStrip(requestor);
    var ContextMenuStrip1 = new ContextMenu(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 (gb_1 == null) gb_1 = new GroupBox(requestor);
        gb_1.Attach(win.Control("gb_1"));
        if (cbx_hbzd == null) cbx_hbzd = new CheckBox(requestor);
        cbx_hbzd.Attach(win.Control("cbx_hbzd"));
        if (ddlb_2 == null) ddlb_2 = new DropDownListBox(requestor);
        ddlb_2.Attach(win.Control("ddlb_2"));
        if (sle_formatname == null) sle_formatname = new SingleLineEdit(requestor);
        sle_formatname.Attach(win.Control("sle_formatname"));
        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 (cb_bmbh == null) cb_bmbh = new CommandButton(requestor);
        cb_bmbh.Attach(win.Control("cb_bmbh"));
        if (sle_bm == null) sle_bm = new SingleLineEdit(requestor);
        sle_bm.Attach(win.Control("sle_bm"));
        if (sle_gysbh == null) sle_gysbh = new SingleLineEdit(requestor);
        sle_gysbh.Attach(win.Control("sle_gysbh"));
        if (sle_ml == null) sle_ml = new SingleLineEdit(requestor);
        sle_ml.Attach(win.Control("sle_ml"));
        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 (dw_format_hz == null) dw_format_hz = new DataWindow(requestor);
        dw_format_hz.Attach(win.Control("dw_format_hz"));
        if (dw_format_mx == null) dw_format_mx = new DataWindow(requestor);
        dw_format_mx.Attach(win.Control("dw_format_mx"));
        if (tb_1 == null) tb_1 = new ToolStrip(requestor);
        tb_1.Attach(win.Control("tb_1"));
        if (ContextMenuStrip1 == null) ContextMenuStrip1 = new ContextMenu(requestor);
        ContextMenuStrip1.Attach(win.Control("ContextMenuStrip1"));

        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.SelectionChanged) == "function")
            win.AttachEvent("ddlb_2", "SelectionChanged", self.SelectionChanged);

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

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

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

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

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

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

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

    }

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

        gb_1.Detach(); gb_1 = null;
        cbx_hbzd.Detach(); cbx_hbzd = null;
        ddlb_2.Detach(); ddlb_2 = null;
        sle_formatname.Detach(); sle_formatname = null;
        dp_2.Detach(); dp_2 = null;
        dp_1.Detach(); dp_1 = null;
        cb_bmbh.Detach(); cb_bmbh = null;
        sle_bm.Detach(); sle_bm = null;
        sle_gysbh.Detach(); sle_gysbh = null;
        sle_ml.Detach(); sle_ml = null;
        dw_temp.Detach(); dw_temp = null;
        dw_format.Detach(); dw_format = null;
        dw_list.Detach(); dw_list = null;
        dw_format_hz.Detach(); dw_format_hz = null;
        dw_format_mx.Detach(); dw_format_mx = null;
        tb_1.Detach(); tb_1 = null;
        ContextMenuStrip1.Detach(); ContextMenuStrip1 = null;
        requestor.Detach(); requestor = 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;
    webReq = new WebRequestor();
    webReq.SetWebServiceUrl("/Service/ServiceForDwSyndax.ashx");

    var webReq_cg = new WebRequestor();
    webReq_cg.SetWebServiceUrl("/Service/ServiceCaiGouDingDan.ashx");


    var C_CheckValue = "";
    var curBbmc = "rb_sp";
    var curCdbh = "";
    var curYhbh = ""
    //#endregion

    //报表名称
    var curBBMCNew = "";
    var curBBPZH = "";
    var curOptype = "0" //0 ：保存  1：修改 
    var cur_Open_Window = null;
    var ChildDWCheckValue = "";
    var dw_format_hz = null; //格式汇总窗口
    var dw_format_mx = null; //格式明细窗口
    var Exel_FH_Flag = "1";
    var curW_Base_Report_Open_Mx_Ex = new W_Base_Report_Open_Mx_Ex();
    var curUserId = "";
    var curcbx_gs = 0;
    var xsmrgs = 0;
    var curPzh = "";
    var syntax = "";
    var evealStr = ""
    var lastSortName = "";
    var isFirstSave = "";
    var curW_KC_PIC = new W_KC_PIC();
    var curSelDays = "-1"
    var dw_format_hz = new DataWindow(requestor);
    var dw_format_mx = new DataWindow(requestor);

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

        finishSql = " SELECT   '' xz, a.pzh,a.kdrq ,a.bmbh ,bmmc,a.khbh ,khmc,SUM(ISNULL(a.sl,0))zjsl,CASE WHEN ISNULL(fdbz,'0') ='1' THEN '已分货' END fdbz  FROM( " +
             " SELECT * FROM dbo.yw_pf_pfddtz " +
			 " UNION ALL  " +
			 " SELECT * FROM dbo.yw_pf_pfddtz_ls) a " +
             " LEFT JOIN dbo.da_sp_spda b ON a.spkh = b.spkh " +
             " LEFT JOIN dbo.da_bmda c ON c.bmbh = a.bmbh " +
             " LEFT JOIN dbo.da_khda d ON d.khbh = a.khbh " +
             " LEFT JOIN dbo.da_gysda e ON e.gysbh = b.gysbh " +
             " WHERE " + self.GetSqlWhere() +
             " GROUP BY a.pzh ,a.kdrq ,a.bmbh ,bmmc,a.khbh ,khmc,fdbz";
        requestor.ClipBoard(finishSql);
        finishSql = finishSql.replace(/\%/g, "%25");
        finishSql = finishSql.replace(/\+/g, "%2B");
        finishSql = finishSql.replace(/\&/g, "%26");
        self.DrawDataWindow(finishSql);

    }

    //#endregion

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

    }



    this.Changegys = function (x, y, row, dwoName) {
        dwoName == "gysbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_GYSFD_CG, "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.Changeml = function (x, y, row, dwoName) {
        dwoName == "khbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_GYSFD_CG, "khbh", "khmc", "M", self)
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base." + curW_OPEN_BMDA_URL + "&treeDw=dw_da_khda_fl_tree&listDw=dw_pub_khda_list_all&treeRootLabel=客户分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple"), curW_OPEN_BMDA_NEW, null);

    }


    //选中后赋值

    this.SetSleValue = function (difBh, val) {
        if ("''" == val)
            val = "";

        if ("bmbh" == difBh)
            sle_bm.SetText(val);
        else if ("gysbh" == difBh)
            sle_gysbh.SetText(val);
        else if ("lbbh" == difBh)
            sle_splb.SetText(val);
        else if ("ppbm" == difBh)
            sle_jypp.SetText(val);
        else if ("jjbm" == difBh)
            sle_spjj.SetText(val);
        else if ("spkh" == difBh)
            sle_spkh.SetText(val);
        else if ("csbh" == difBh)
            sle_fs.SetText(val);
        else if ("khbh" == difBh)
            sle_ml.SetText(val);

        else if ("rkfs" == difBh)
            sle_pffs.SetText(val);
    }

    //#endregion

    //#region Function GetSqlWhere
    this.GetSqlWhere = function () {
        var realSql = " 1=1 ";
        var curYhbh = requestor.GetParm("curYhbh")
        var beginDate = UtcDateFormatToString(dp_1.GetValue());
        var endDate = UtcDateFormatToString(dp_2.GetValue());
        var curBm = sle_ml.GetText();
        var curGys = sle_gysbh.GetText();
        var curKh = sle_bm.GetText();
        var curPzh = sle_formatname.GetText(); ;


        realSql += " and (CONVERT(date,a.kdrq) between '" + beginDate + "' and '" + endDate + "')";





        if (curBm.length > 0) {

            var is_quotes = curBm.substring(0, 1);
            if (is_quotes == "'") {
                realSql += " and a.khbh in(" + curBm + ")";
            }
            else {
                var tempspkh = self.GetQuotes(curBm);
                realSql += " and a.khbh in(" + tempspkh + ")";
            }
        } else {
            realSql += "and a.khbh in(select khbh  from da_qx_khda where yhbh = '" + curYhbh + "'and bz3 = '1')"
        }

        if (curKh.length > 0) {

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

            realSql += " and a.bmbh  in(select bmbh  from da_qx_bmqxsz where yhbh = '" + curYhbh + "' and pfcx = '1')";
        }

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

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

        if (curPzh.length > 0) {

            realSql += " and a.pzh='" + curPzh + "'";

        }



        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

    this.PostOpen = function () {
        ddlb_2.SetEnabled(false);
        sle_bm.SetEnabled(false);
        sle_gysbh.SetEnabled(false);
        sle_ml.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.picpreview) == "function")
            requestor.AttachEvent("浏览图片ToolStripMenuItem", "Clicked", self.picpreview);

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

        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";
        }
        ywflag = requestor.GetParm("ywflag");
        curCdbh = requestor.GetParm("curCdbh");
        curYhbh = requestor.GetParm("curYhbh");


        //curSelDays = GetXiTongCanShu(curYhbh, curCdbh, "bzxx");
        //        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);
        }
        //        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 = "";
        //        }

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


        dp_1.SetValue(UtcDateFormatToString(new Date().getVarDate()))
        dp_2.SetValue(UtcDateFormatToString(new Date().getVarDate()))
    }





    //#region Function DrawDataWindow
    this.DrawDataWindow = function (parameter) {
        dw_list.SetRedraw(false);
        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();
            dw_list.SetRowSelection(1);
            var colCount = dw_list.Describe("DataWindow.Column.Count");
            self.SetItemName(colCount);
            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") + "'");
        } 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 "csmc":
                    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 "spkh":
                    ls_columntitle = "商品款式";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "ksmc":
                    ls_columntitle = "款式名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "jldw":
                    ls_columntitle = "单位";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;
                case "khbh":
                    ls_columntitle = "客户编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "khmc":
                    ls_columntitle = "客户名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "kdrq":
                    ls_columntitle = "日期";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    dw_list.Modify(ls_columnname + ".format = 'yyyy-MM-dd'");
                    break;
                case "pzh":
                    ls_columntitle = "凭证号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 800 + "'");
                    break;
                case "cgfs":
                    ls_columntitle = "采购方式";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "ckmc":
                    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 "ygmc":
                    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 "gysmc":
                    ls_columntitle = "供应商名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "zjsl":
                    ls_columntitle = "数量";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".edit.name='#####' " + ls_columnname + ".editmask.mask='#########0' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    dw_list.Modify(ls_columnname + ".format='#########0' ")
                    break;
                case "jjze":
                    ls_columntitle = "零售总额";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".format='#########0.00' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "lsjze":
                    ls_columntitle = "批发总额";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".format='#########0.00' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "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 "ysbh":
                    ls_columntitle = "色号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;
                case "ysmc":
                    ls_columntitle = "色名";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;
                case "bxbh":
                    ls_columntitle = "版型编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;
                case "bxmc":
                    ls_columntitle = "版型名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;
                case "cmdm":
                    ls_columntitle = "尺码";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 100 + "'");
                    break;
                case "spjj":
                    ls_columntitle = "季节编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;
                case "jjmc":
                    ls_columntitle = "季节名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;
                case "jypp":
                    ls_columntitle = "品牌编号";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;
                case "ppmc":
                    ls_columntitle = "品牌名称";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;
                case "spnf":
                    ls_columntitle = "商品年份";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");

                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;
                case "bqkc":
                    ls_columntitle = "库存";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".format='#########' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    break;
                case "fdbz":
                    ls_columntitle = "分单标记";
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 300 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    break;
                case "xh":
                    ls_columntitle = "序号"
                    break;

                case "xz":
                    ls_columntitle = "选择"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 250 + "'");
                    dw_list.Modify(ls_columnname + ".alignment = '2'");
                    dw_list.Modify(ls_columnname + ".font.Blod = 1");
                    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("bqkc.x");
        ls_jjzewidth = dw_list.Describe("bqkc.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='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')"
        ls_syntax = ls_syntax + "create compute(band=summary alignment='1' expression='sum(bqkc  for all)' border='0' color='128' x='" + ls_jjzex + "' y='8' height='52' 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')"
        ls_syntax = ls_syntax + "create compute(band=summary alignment='1' expression='sum(zjsl  for all)' border='0' color='128' x='" + ls_slx + "' y='8' height='52' width='" + ls_slwidth + "' name=sum_bqkc  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=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);
    }
    //#endregion

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

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

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

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

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

    //#region 格式保存#报表格式清空
    this.ReportClare = function () {
        var tempPzh = "";
        if (dw_format_hz.RowCount() > 0) {
            tempPzh = dw_format_hz.GetItemString(1, "pzh");
        }
        //        if (tempPzh.length <= 0 || sle_formatname.GetText().length <= 0) {
        //            requestor.MessageBox("提示", "请先选择报表格式", ICON.StopSign);
        //            return;
        //        }
        dw_format_mx.Reset();
        dw_format_hz.Reset();
        sle_formatname.SetText("");
        self.TongJi();
    }

    this.ClearAndTJ = function (isTj) {
        dw_format_hz.RetrieveEx("pzh='" + curBBPZH + "'");
        dw_format_mx.RetrieveEx("pzh='" + curBBPZH + "'");
        dw_format_mx.SetFilter("mrgxtj='1'");
        dw_format_mx.Filter();
        xsmrgs = dw_format_mx.RowCount();
        cbx_spkh.SetChecked(false);
        cbx_ys.SetChecked(false);
        cbx_bx.SetChecked(false);
        cbx_kh.SetChecked(false);
        cbx_cm.SetChecked(false);
        cbx_pp.SetChecked(false);
        cbx_jj.SetChecked(false);
        cbx_gys.SetChecked(false);
        cbx_splb.SetChecked(false);
        //界面控制
        var evealStr = "";
        for (var i = 1; i <= dw_format_mx.RowCount(); i++) {
            evealStr += dw_format_mx.GetItemString(i, "col") + ".SetChecked(true);";
        }
        eval(evealStr);

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

    //#region 横向/纵向

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

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

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

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

        if (rb_wfhkh.GetChecked()) {
            curBbmc = "rb_wfhkh";
        }
        if (rb_wfhsp.GetChecked()) {
            curBbmc = "rb_wfhsp";
        }

    }
    //#endregion 

    //#region 提交
    this.ReportSave = function () {
        self.PropertCheckStatus();
        var msg = ReportSaveEx(dw_list, dw_format_hz, dw_format_mx, curYhbh, curCdbh, curBbmc, curBBPZH, curYhbh, curBBMCNew, ChildDWCheckValue, "", 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_spkh.GetChecked()) {
            ChildDWCheckValue += "cbx_spkh,"
        }
        //颜色
        if (cbx_ys.GetChecked()) {
            ChildDWCheckValue += "cbx_ys,"
        }
        //版型
        if (cbx_bx.GetChecked()) {
            ChildDWCheckValue += "cbx_bx,"
        }
        //客户
        if (cbx_kh.GetChecked()) {
            ChildDWCheckValue += "cbx_kh,"
        }
        //尺码
        if (cbx_cm.GetChecked()) {
            ChildDWCheckValue += "cbx_cm,"
        }
        //品牌
        if (cbx_pp.GetChecked()) {
            ChildDWCheckValue += "cbx_pp,"
        }
        //批发方式
        if (cbx_jj.GetChecked()) {
            ChildDWCheckValue += "cbx_jj,"
        }
        //批发方式
        if (cbx_gys.GetChecked()) {
            ChildDWCheckValue += "cbx_gys,"
        }
        //类别
        if (cbx_splb.GetChecked()) {
            ChildDWCheckValue += "cbx_splb,"
        }
        //类别
        if (cbx_spnf.GetChecked()) {
            ChildDWCheckValue += "cbx_spnf,"
        }

    }
    //#endregion

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

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

    //#region 定义单据样式

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

    //#region FormatSave
    this.FormatSave = function () {
        dw_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 + ".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();
        self.Query(); //规格
//        if (Exel_FH_Flag == "1") {
//            dw_list.Modify("DataWindow.Sparse='spkh\tksmc\tjldw\tysbh\tysmc\tbxbh\tbxmc'");
//        }
        self.FormatSave();
        dw_list.SetSort("pzh,spkh,ksmc");
        dw_list.Sort();
        //给Title加颜色。。
        A8erp_Report.ReportDataWindowHeaderColor(dw_list);
        self.A8erp_Report_Style(dw_list);
        self.A8erp_Report_Header_Row_Height(dw_list, false);
        self.A8erp_Report_Detail_Row_Height(dw_list);
        //JS样式。
        dw_list.SetRedraw(true);


    }
    //#endregion

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

        ChildDWCheckValue = str1;
        curBbmc = str2;
        curCdbh = str3;
        curUserId = str4;
    }
    //#endregion
    var qbCheckStatus = "";
    //#region 双击标题排序
    this.DoubleClicked = function (x, y, row, dwcName) {

        if (dwcName.indexOf("_t") > -1) {

            if (dwcName == "xz_t") {
                if (qbCheckStatus == "√") {
                    for (var i = 1; i <= dw_list.RowCount(); i++) {
                        dw_list.SetItem(i, "xz", "");
                    }
                    qbCheckStatus = "";
                } else {
                    for (var i = 1; i <= dw_list.RowCount(); i++) {
                        dw_list.SetItem(i, "xz", "√");
                    }
                    qbCheckStatus = "√";
                }
            } else {
                var curColName = dwcName.split("_")[0];
                if (curColName == lastSortName) {
                    dw_list.SetSort(curColName + " A");
                    lastSortName = "";
                    dw_list.Sort();
                } else {
                    dw_list.SetSort(curColName + " D");
                    lastSortName = dwcName.split("_")[0];
                    dw_list.Sort();
                } 
            }
        } else {

        }
    }
    //#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.Mx_clicked = function (x, y, row, dowName) {
        if (row == 0) return;

            var xz = dw_list.GetItemString(row, "xz");
            if (xz != "√") {
                dw_list.SetItem(row, "xz", "√");
            } else {
                dw_list.SetItem(row, "xz", "");
            }
        

    }


    this.Fendan = function () {

        if (cbx_hbzd.GetChecked()) {
            var pzhStr = "";
            for (var i = 1; i <= dw_list.RowCount(); i++) {
                var xz = dw_list.GetItemString(i, "xz");
                var pzh = dw_list.GetItemString(i, "pzh");
                if (xz == "√") {
                    if (pzhStr.indexOf("'" + pzh + "',") > -1) continue;
                    pzhStr += "'" + pzh + "',";
                }
            }
            webReq_cg.Invoke("HeBingFenDan", "curPzhStr=" + pzhStr + "&Ywlx =PF" + "&Ywqx =CG&isHb=Y");
            if (webReq_cg.StatusCode() == 200) {
                requestor.MessageBox("提示", "已分单!", ICON.Information);
                requestor.Close();
            } else {
                requestor.MessageBox("提示", "转单分单,请联系管理员!/r/n" + webReq_cg.ResponseText(), ICON.StopSign);
            }

        } else {
            var pzhStr = "";
            var aa = 0;
            var cwpzh = "";
            for (var i = 1; i <= dw_list.RowCount(); i++) {
                var xz = dw_list.GetItemString(i, "xz");
                var pzh = dw_list.GetItemString(i, "pzh");
                if (xz == "√") {
                    if (pzhStr.indexOf("'" + pzh + "',") > -1) continue;
                    pzhStr += "'" + pzh + "',";
                    webReq_cg.Invoke("HeBingFenDan", "curPzhStr=" + pzh + "&Ywlx =PF" + "&Ywqx =CG&isHb=N");
                    if (webReq_cg.StatusCode() == 200) {

                    } else {
                        aa = i;
                        cwpzh = pzh;

                    }
                }
            }
            if (cwpzh.length > 0) {
                requestor.MessageBox("提示", "第" + aa + "行数据,凭证号【" + cwpzh + "】分单失败!", ICON.StopSign);
            } else {
                requestor.MessageBox("提示", "已分单!", ICON.Information);
            }
        }
    }
}
