///<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_XJShouRuPZ() {

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var tab_1 = new TabControl(requestor);
    var dw_hz = new DataWindow(requestor);
    var dw_mkfhjb = new DataWindow(requestor);
    var mle_1 = new MultiLineEdit(requestor);
    var dw_parameter = new DataWindow(requestor);
    var dw_xt_div_tree_no_parm = new DataWindow(requestor);
    var dw_3 = new DataWindow(requestor);
    var dw_proxy = new DataWindow(requestor);
    var dw_da_qx_mokuai = new DataWindow(requestor);
    var dw_sort = new DataWindow(requestor);
    var dw_print = new DataWindow(requestor);
    var dw_2 = new DataWindow(requestor);
    var dw_init = new DataWindow(requestor);
    var dw_1 = new DataWindow(requestor);
    var dw_mx = new DataWindow(requestor);
    var dw_mx_top = new DataWindow(requestor);
    var tb_1 = new ToolStrip(requestor);
    var ddlb_1 = new DropDownListBox(requestor);
    var ContextMenuStrip2 = 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 (tab_1 == null) tab_1 = new TabControl(requestor);
        tab_1.Attach(win.Control("tab_1"));
        if (dw_hz == null) dw_hz = new DataWindow(requestor);
        dw_hz.Attach(win.Control("dw_hz"));
        if (dw_mkfhjb == null) dw_mkfhjb = new DataWindow(requestor);
        dw_mkfhjb.Attach(win.Control("dw_mkfhjb"));
        if (mle_1 == null) mle_1 = new MultiLineEdit(requestor);
        mle_1.Attach(win.Control("mle_1"));
        if (dw_parameter == null) dw_parameter = new DataWindow(requestor);
        dw_parameter.Attach(win.Control("dw_parameter"));
        if (dw_xt_div_tree_no_parm == null) dw_xt_div_tree_no_parm = new DataWindow(requestor);
        dw_xt_div_tree_no_parm.Attach(win.Control("dw_xt_div_tree_no_parm"));
        if (dw_3 == null) dw_3 = new DataWindow(requestor);
        dw_3.Attach(win.Control("dw_3"));
        if (dw_proxy == null) dw_proxy = new DataWindow(requestor);
        dw_proxy.Attach(win.Control("dw_proxy"));
        if (dw_da_qx_mokuai == null) dw_da_qx_mokuai = new DataWindow(requestor);
        dw_da_qx_mokuai.Attach(win.Control("dw_da_qx_mokuai"));
        if (dw_sort == null) dw_sort = new DataWindow(requestor);
        dw_sort.Attach(win.Control("dw_sort"));
        if (dw_print == null) dw_print = new DataWindow(requestor);
        dw_print.Attach(win.Control("dw_print"));
        if (dw_2 == null) dw_2 = new DataWindow(requestor);
        dw_2.Attach(win.Control("dw_2"));
        if (dw_init == null) dw_init = new DataWindow(requestor);
        dw_init.Attach(win.Control("dw_init"));
        if (dw_1 == null) dw_1 = new DataWindow(requestor);
        dw_1.Attach(win.Control("dw_1"));
        if (dw_mx == null) dw_mx = new DataWindow(requestor);
        dw_mx.Attach(win.Control("dw_mx"));
        if (dw_mx_top == null) dw_mx_top = new DataWindow(requestor);
        dw_mx_top.Attach(win.Control("dw_mx_top"));
        if (tb_1 == null) tb_1 = new ToolStrip(requestor);
        tb_1.Attach(win.Control("tb_1"));
        if (ddlb_1 == null) ddlb_1 = new DropDownListBox(requestor);
        ddlb_1.Attach(win.Control("ddlb_1"));
        if (ContextMenuStrip2 == null) ContextMenuStrip2 = new ContextMenu(requestor);
        ContextMenuStrip2.Attach(win.Control("ContextMenuStrip2"));

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

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

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

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

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

        if (typeof (self.dw_mx_DropDown) == "function")
            win.AttachEvent("dw_mx", "DropDown", self.dw_mx_DropDown);

        if (typeof (self.dw_mx_editChanged) == "function")
            win.AttachEvent("dw_mx", "EditChanged", self.dw_mx_editChanged);

        if (typeof (self.GetFocusMx) == "function")
            win.AttachEvent("dw_mx", "GetFocus", self.GetFocusMx);

        if (typeof (self.dw_mx_itemChanged) == "function")
            win.AttachEvent("dw_mx", "ItemChanged", self.dw_mx_itemChanged);

        if (typeof (self.dw_mx_keyDown) == "function")
            win.AttachEvent("dw_mx", "KeyDown", self.dw_mx_keyDown);

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

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

        if (typeof (self.dw_mx_top_editChanged) == "function")
            win.AttachEvent("dw_mx_top", "EditChanged", self.dw_mx_top_editChanged);

        if (typeof (self.Top_itemChanged) == "function")
            win.AttachEvent("dw_mx_top", "ItemChanged", self.Top_itemChanged);

        if (typeof (self.dw_mx_top_keyDown) == "function")
            win.AttachEvent("dw_mx_top", "KeyDown", self.dw_mx_top_keyDown);

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

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

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

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

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

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

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

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

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

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

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

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

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

        if (typeof (self.Copy) == "function")
            win.AttachEvent("复制凭证号ToolStripMenuItem", "Clicked", self.Copy);

        if (typeof (self.CopyBzxx) == "function")
            win.AttachEvent("复制备注信息ToolStripMenuItem", "Clicked", self.CopyBzxx);

    }

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

        tab_1.Detach(); tab_1 = null;
        dw_hz.Detach(); dw_hz = null;
        dw_mkfhjb.Detach(); dw_mkfhjb = null;
        mle_1.Detach(); mle_1 = null;
        dw_parameter.Detach(); dw_parameter = null;
        dw_xt_div_tree_no_parm.Detach(); dw_xt_div_tree_no_parm = null;
        dw_3.Detach(); dw_3 = null;
        dw_proxy.Detach(); dw_proxy = null;
        dw_da_qx_mokuai.Detach(); dw_da_qx_mokuai = null;
        dw_sort.Detach(); dw_sort = null;
        dw_print.Detach(); dw_print = null;
        dw_2.Detach(); dw_2 = null;
        dw_init.Detach(); dw_init = null;
        dw_1.Detach(); dw_1 = null;
        dw_mx.Detach(); dw_mx = null;
        dw_mx_top.Detach(); dw_mx_top = null;
        tb_1.Detach(); tb_1 = null;
        ddlb_1.Detach(); ddlb_1 = null;
        ContextMenuStrip2.Detach(); ContextMenuStrip2 = null;
        requestor.Detach(); requestor = null;

        setTimeout(CollectGarbage, 100);
    }

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

    var editMode = "";
    var G_bEditFlag = false;
    var isAdd = false;
    var curYhbh = "";
    var curKmlb = "001";
    var curJqdbm = "";
    var FunctionID = "";
    var reCurBigMax = 0;
    var curRowCount = 0;
    var dwc = new DataWindowChild();
    var curW_OPEN = new OpenWindowQueryBase();
    var webReq = new WebRequestor();
    webReq.SetWebServiceUrl("/Service/ServiceCaiWu.ashx");
    var webReqTimestamp = new WebRequestor();
    webReqTimestamp.SetWebServiceUrl("/Service/GetPublicData.ashx");

    //#region postopen
    this.PostOpen = function () {
        if (dw_hz.RowCount() <= 0) {

        }
        else {
            self.SetEditMode("");
        }
        dw_mx_top.Modify("DataWindow.Readonly=yes");
        dw_mx.Modify("DataWindow.Readonly=yes");
        curYhbh = requestor.GetParm("curYhbh");
        FunctionID = requestor.GetParm("FunctionID");
        curJqdbm = requestor.GetParm("curJqdbm");

        mle_1.SetVisible(false);
        dw_1.SetVisible(false);
        self.SelectionChanged();
    }
    //#endregion

    //#region this.SetEditMode
    this.SetEditMode = function (newMode) {

        editMode = newMode;
        var bEditFlag = false;
        G_bEditFlag = false;
        if (editMode != "") {
            bEditFlag = true;
            G_bEditFlag = true;
        }
        dw_hz.SetEnabled(!bEditFlag);

        if (dw_hz.GetRow() > 1)
            tb_1.SetEnabled("btn_PriorRow", !bEditFlag);
        else
            tb_1.SetEnabled("btn_PriorRow", false);

        if (dw_hz.GetRow() < dw_hz.RowCount())
            tb_1.SetEnabled("btn_NextRow", !bEditFlag);
        else
            tb_1.SetEnabled("btn_NextRow", false);

        tb_1.SetEnabled("btn_Print", !bEditFlag);
        tb_1.SetEnabled("btn_Add", !bEditFlag);
        tb_1.SetEnabled("btn_Edit", !bEditFlag);
        tb_1.SetEnabled("btn_Delete", !bEditFlag);
        tb_1.SetEnabled("btn_Audit", !bEditFlag);

        tb_1.SetEnabled("btn_InsertRow", bEditFlag);
        tb_1.SetEnabled("btn_DeleteRow", bEditFlag);
        tb_1.SetEnabled("btn_Save", bEditFlag);
        tb_1.SetEnabled("btn_Cancel", bEditFlag);
      
        if (bEditFlag) {
            tab_1.SelectTab(2);
            dw_mx_top.Modify("DataWindow.Readonly=no");
            dw_mx.Modify("DataWindow.Readonly=no");
            dw_mx_top.SetFocus();
        }
        else {
            dw_mx_top.Modify("DataWindow.Readonly=yes");
            dw_mx.Modify("DataWindow.Readonly=yes");
        }
    }
    //#endregion     

    //#region this.Add
    this.Add = function () {
        if (editMode != "")
            return;
        dw_mx_top.Reset();
        dw_mx_top.ScrollToRow(dw_mx_top.InsertRow(0));

        var curAddMaxPzh = "";
        FunctionID = requestor.GetParm("FunctionID");
        curYhbh = requestor.GetParm("curYhbh");
        webReq.Invoke("GetXJPzh", "FunctionID=" + FunctionID);

        if (webReq.StatusCode() == 200) {
            curAddMaxPzh = webReq.ResponseText();
        } else {
            alert(webReq.ResponseText());
            return;
        }
        dw_mx_top.SetItem(1, "pzh", curAddMaxPzh);
        dw_mx_top.SetItem(1, "zdr", curYhbh);
        dw_mx_top.SetItem(1, "pzlx", "1");
        dw_mx.Reset();
        dw_mx.InsertRow(0);
        reCurBigMax = 1;
        self.SetEditMode("Add");
        isAdd = true;
        // 清空 审核章
        dw_mx_top.Modify("ysh_q_t.visible='0' ysh_t.visible='0' ysh_t.Text=''");

        //增加清除默认项目
        dw_mx_top.Modify("ydjlx_t.visible='0' ydjlx.visible='0' ydjlx.border='0' yljh_t.visible='0' yljh.visible='0' yljh.border='0' ");
    }
    //#endregion
    
    //#region this.Exit
    this.Exit = function () {
        if (self.CloseQuery() == 1)
            return;
        setTimeout("window.close();", 100);
    }
    //#endregion  

    //#region this.CloseQuery
    this.CloseQuery = function () {
        if (editMode == "")
            return;

        dw_mx.AcceptText();
        dw_mx_top.AcceptText();
        if ((dw_mx_top.ModifiedCount() + dw_mx.DeletedCount() + dw_mx.ModifiedCount()) > 0) {
            if (requestor.MessageBox("提示", "数据还没有保存,是否继续退出?", ICON.Question, BUTTON.YesNo) == 2)
                return 1;
        } else {
            if (dw_hz.GetRow() < 1) {
                return;
            }
//            var pzh = dw_hz.GetItemString(dw_hz.GetRow(), "pzh");
//            var flag = requestor.GetParm("flag");
//            if (flag == "KP") {
//                var sgdj = "_" + dw_hz.GetItemString(dw_hz.GetRow(), "sgdj");
//                pzh += sgdj;

//            }
//            webReqTimestamp.Invoke("YW_TIMESTAMP_REC", "curPzh=" + pzh + "&curFlag=SAVE_END&curLAST_SJC=XX");
//            if (webReqTimestamp.StatusCode() == 200) {
//                //alert("时间戳已统一");
//            }
//            else {
//                requestor.MessageBox("提示(时间戳)", webReqTimestamp.ResponseText(), ICON.StopSign);
//            }
        }

        //释放对象
        dwc.Detach(); dwc = null;
    }
    //#endregion  

    //#region this.Hz_RowFocusChanged  汇总行改变的时候
    this.Hz_RowFocusChanged = function (row) {
        if (row > 0) {
            var curShzt = dw_hz.GetItemString(row, "dqzt");
            var curJzbz = dw_hz.GetItemString(row, "jzbz");
            if (curShzt == "F") {
                tb_1.SetEnabled("btn_Audit", true);
                tb_1.SetEnabled("btn_UnAudit", false);
                tb_1.SetEnabled("btn_Tally", false);
                tb_1.SetEnabled("btn_Delete", true);
                tb_1.SetEnabled("btn_Edit", true);
            } else if (curShzt == "T") {
                tb_1.SetEnabled("btn_Audit", false);
                if (curJzbz == "1") {
                    tb_1.SetEnabled("btn_UnAudit", false);
                    tb_1.SetEnabled("btn_Tally", false);
                    tb_1.SetEnabled("btn_Delete", false);
                    tb_1.SetEnabled("btn_Edit", false);
                } else {
                    tb_1.SetEnabled("btn_UnAudit", true);
                    tb_1.SetEnabled("btn_Tally", true);
                    tb_1.SetEnabled("btn_Delete", false);
                    tb_1.SetEnabled("btn_Edit", false);
                }
            } else {
                tb_1.SetEnabled("btn_Audit", true);
                tb_1.SetEnabled("btn_UnAudit", true);
                tb_1.SetEnabled("btn_Tally", false);
                tb_1.SetEnabled("btn_Delete", true);
                tb_1.SetEnabled("btn_Edit", true);
            }

            tb_1.SetEnabled("btn_PriorRow", true);
            tb_1.SetEnabled("btn_NextRow", true);
            if (row <= 1) {
                tb_1.SetEnabled("btn_PriorRow", false);
            }
            if (row >= dw_hz.RowCount()) {
                tb_1.SetEnabled("btn_NextRow", false);
            }

            if (curShzt == "T") {
                var curRowNo = dw_mkfhjb.Find("fhjb='T'", 1, dw_mkfhjb.RowCount());  // 当前行
                tb_1.SetText("btn_Audit", dw_mkfhjb.GetItemString(curRowNo, "dygn"));
                dw_mx_top.Modify("ysh_q_t.visible='1' ysh_t.visible='1' ysh_t.Text='" + dw_mkfhjb.GetItemString(curRowNo, "fhmc") + "'");
            } else {
                var curRowNo = dw_mkfhjb.Find("fhjb='" + curShzt + "'", 1, dw_mkfhjb.RowCount());  // 当前行
                tb_1.SetText("btn_Audit", dw_mkfhjb.GetItemString(curRowNo, "dygn"));

                if (curShzt != "F") {
                    dw_mx_top.Modify("ysh_q_t.visible='1' ysh_t.visible='1' ysh_t.Text='" + dw_mkfhjb.GetItemString(curRowNo, "fhmc") + "'");
                } else {
                    dw_mx_top.Modify("ysh_q_t.visible='0' ysh_t.visible='0' ysh_t.Text=''");
                }
            }
            var pzlx = dw_hz.GetItemString(row, "pzlx");
            if (pzlx == "0") {
                dw_mx_top.Modify("ydjlx_t.visible='1' ydjlx.visible='1' ydjlx.border='4' yljh_t.visible='1' yljh.visible='1' yljh.border='4' yljh.tabsequence=70 ");
            } else {
                dw_mx_top.Modify("ydjlx_t.visible='0' ydjlx.visible='0' ydjlx.border='0' yljh_t.visible='0' yljh.visible='0' yljh.border='0' ");
            }
        }
    }
    //#endregion

    //#region this.dw_hz_DoubleClicked 
    this.dw_hz_DoubleClicked = function (x, y, row, dowName) {
//        if (row > 0) {
//            tab_1.SelectTab(2);
//            dw_mx.GetChild("skzh", dwc);
//            dwc.Retrieve(dw_hz.GetItemString(row, "bmbh"));
//        }
//        curRowCount = dw_mx.RowCount();
//        var curBigMaxMxdh = "";
//        if (curRowCount >= 1) {
//            curBigMaxMxdh = dw_mx.GetItemString(curRowCount, "mxdh");
//            reCurBigMax = new Number(curBigMaxMxdh.substring(curBigMaxMxdh.length - 6, curBigMaxMxdh.length)) + 1;

//        } else {
//            reCurBigMax = 1;
//        }
         if (row > 0) {
            tab_1.SelectTab(2);
            tb_1.SetEnabled("ddlb_1", false);
            tb_1.SetEnabled("btn_PriorRow", false);
            tb_1.SetEnabled("btn_NextRow", false);
            var curPzh = dw_hz.GetItemString(row, "pzh");
            dw_mx_top.Retrieve(curPzh);

            dw_mx.Retrieve(curPzh)
        }
        curRowCount = dw_mx.RowCount();
        var curBigMaxMxdh = "";
        if (curRowCount >= 1) {
            curBigMaxMxdh = dw_mx.GetItemString(curRowCount, "mxdh");
            reCurBigMax = new Number(curBigMaxMxdh.substring(curBigMaxMxdh.length - 3, curBigMaxMxdh.length)) + 1;

        } else {
            reCurBigMax = 1;
        }
    }
    //#endregion 

    this.Tab_1_Clicked = function (ind) {
        if (ind == "1") {
            tb_1.SetEnabled("ddlb_1", true);
            tb_1.SetEnabled("btn_PriorRow", true);
            tb_1.SetEnabled("btn_NextRow", true);
            if (dw_hz.GetRow() < 1) {
                return;
            }
            self.Hz_RowFocusChanged(dw_hz.GetRow());
        } else {
            tb_1.SetEnabled("ddlb_1", false);
            tb_1.SetEnabled("btn_PriorRow", false);
            tb_1.SetEnabled("btn_NextRow", false);
            var curRowCount = dw_hz.RowCount();
            if (curRowCount < 1) {
                dw_mx_top.ScrollToRow(dw_mx_top.InsertRow(0));
                return;
            }
            var curPzh = dw_hz.GetItemString(dw_hz.GetRow(), "pzh");
            dw_mx_top.Retrieve(curPzh);
            dw_mx.Retrieve(curPzh);
        }
    }

    //#region dw_mx_top_editChanged
    this.dw_mx_top_editChanged = function (row, dwoName, data) {

        if (dwoName == "bmbh") {
            dw_mx_top.GetChild(dwoName, dwc);

            if (data != "") {
                dwc.Retrieve(curYhbh, data);
            }
            else {
                dwc.Retrieve(curYhbh, "%");
            }
        }
        if (dwoName == "zdr") {
            dw_mx_top.GetChild(dwoName, dwc);
            if (data != "") {
                dwc.Retrieve("%" + data + "%",curYhbh,"cw");
            }
            else {
                dwc.Retrieve("%", curYhbh, "cw");
            }
        }
       
    }
    //#endregion

    //#region Top_itemChanged
    this.Top_itemChanged = function (row, dwoName, data) {
        if (dwoName == "bmbh") {
            dw_mx_top.GetChild(dwoName, dwc);
            var findRow = dwc.Find("bmbh='" + data + "' ", 1, dwc.RowCount());
            if (findRow <= 0) {
                requestor.MessageBox("提示", "未找到部门编号为[" + data + "]的记录，请检查!", ICON.StopSign);
                return 1;
            } else {
                dw_mx_top.SetItem(row, "bmmc", dwc.GetItemString(findRow, "bmmc"));
            }
            var MxRowCount = dw_mx.RowCount();
            if (MxRowCount > 0) {
                for (var i = 1; i <= MxRowCount; i++) {
                    dw_mx.SetItem(i, "skzh", "");
                    dw_mx.SetItem(i, "skfs", "");
                }
            }
            dw_mx.GetChild("skzh", dwc);
            dwc.Retrieve(data);
            curJqdbm = requestor.GetParm("curJqdbm");
            if (curJqdbm == "1") {
                if (dw_mx_top.GetItemString(row, "khbh") != "") {
                    dw_1.Retrieve(data, dw_mx_top.GetItemString(row, "khbh"), "1");
                    var nrow = dw_1.RowCount();
                    if (nrow > 0) {
                        dw_mx_top.SetItem(row, "sdye", dw_1.GetItemNumber(1, "ye"));
                    } else {
                        dw_mx_top.SetItem(row, "sdye", 0);
                    }
                }
            } else {
                dw_mx_top.SetItem(row, "khsdye", 0);
                dw_mx_top.SetItem(row, "khbdye", 0);
            }
            //            if (dw_mx_top.GetItemString(row, "khbh") != "") {
            //                dw_1.Retrieve(data, dw_mx_top.GetItemString(row, "khbh"));
            //                var nrow = dw_1.RowCount();
            //                if (nrow > 0) {
            //                    dw_mx_top.SetItem(row, "sdye", dw_1.GetItemNumber(1, "ye"));
            //                } else {
            //                    dw_mx_top.SetItem(row, "sdye", 0);
            //                }
            //            }
        } else if (dwoName == "khbh") {
            dw_mx_top.GetChild(dwoName, dwc);
            var findRow = dwc.Find("khbh='" + data + "' ", 1, dwc.RowCount());
            if (findRow > 0) {
                dw_mx_top.SetItem(row, "khmc", dwc.GetItemString(findRow, "khmc"));
            }
            curJqdbm = requestor.GetParm("curJqdbm");
            if (curJqdbm == "1") { //精确到部门
                if (dw_mx_top.GetItemString(row, "bmbh") != "") {
                    dw_1.Retrieve(dw_mx_top.GetItemString(row, "bmbh"), data, "1");
                    var nrow = dw_1.RowCount();
                    if (nrow > 0) {
                        dw_mx_top.SetItem(row, "sdye", dw_1.GetItemNumber(1, "ye"));
                    } else {
                        dw_mx_top.SetItem(row, "sdye", 0);
                    }
                }
            } else {
                dw_1.Retrieve("00", data, "0");
                var nrow = dw_1.RowCount();
                if (nrow > 0) {
                    dw_mx_top.SetItem(row, "khsdye", dw_1.GetItemNumber(1, "ye"));
                } else {
                    dw_mx_top.SetItem(row, "khsdye", 0);
                }
            }

        } else if (dwoName == "pzlx") {

            dw_mx_top.GetChild("khbh", dwc);
            if (data == "1") {
                curKmlb = "001";
                dw_mx_top.SetItem(1, "ydjlx", "");
                dw_mx_top.SetItem(1, "yljh", "");
                dwc.Retrieve("%", curYhbh);
                if (dwc.RowCount() > 0) {
                    dw_mx_top.SetItem(1, "khbh", dwc.GetItemString(1, "khbh"));
                    dw_mx_top.SetItem(1, "khmc", dwc.GetItemString(1, "khmc"));
                } else {
                    dw_mx_top.SetItem(1, "khbh", "");
                    dw_mx_top.SetItem(1, "khmc", "");
                }
                dw_mx_top.Modify("ydjlx_t.visible='0' ydjlx.visible='0' ydjlx.border='0' yljh_t.visible='0' yljh.visible='0' yljh.border='0'  ");
            } else {
                curKmlb = "006";
                dwc.Retrieve("", "");
                dw_mx_top.GetChild("yljh", dwc);
                dwc.Retrieve(dw_mx_top.GetItemString(row, "ydjlx"), "1");
                dw_mx_top.SetItem(1, "khbh", "");
                dw_mx_top.SetItem(1, "khmc", "");
                dw_mx_top.SetItem(row, "khsdye", 0);
                dw_mx_top.SetItem(row, "sdye", 0);
                dw_mx_top.SetItem(row, "khbdye", 0);
                dw_mx_top.SetItem(row, "bdye", 0);
                dw_mx_top.Modify("ydjlx_t.visible='1' ydjlx.visible='1' ydjlx.border='4' yljh_t.visible='1' yljh.visible='1' yljh.border='4' yljh.tabsequence=70");
            }
        } else if (dwoName == "ydjlx") {
            dw_mx_top.GetChild("yljh", dwc);
            dwc.Retrieve(data, "1");
        }
    }
    //#endregion

    //#region this.dw_mx_top_keyDown
    this.dw_mx_top_keyDown = function (keyCode, keyFlags) {
        if (keyCode == 13 && dw_mx_top.GetColumnName() == "xjzh") {
            if (dw_mx.GetItemString(1, "sfkm") != "") {
                dw_mx.ScrollToRow(dw_mx.InsertRow(0));
                dw_mx.SetColumn("sfkm");
                dw_mx.SetFocus();
            } else {
                dw_mx.ScrollToRow(1);
                dw_mx.SetColumn("sfkm");
                dw_mx.SetFocus();
            }
            return 1;
        }
    }
    //#endregion 

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

        var row = dw_mx.GetRow();
        if (row <= 0)
            return;

        var dwoName = dw_mx.GetColumnName();
        if (dwoName == "sfkm") {
            dw_mx.GetChild("sfkm", dwc);
            dwc.Retrieve(curKmlb);
            findRow = dwc.Find("kmbh='" + dw_mx.GetItemString(row, dwoName) + "'", 1, dwc.RowCount());
            if (findRow > 0) {
                if (findRow == 1)
                    dwc.SelectRow(1, true);
                else
                    dwc.ScrollToRow(findRow);
            }
        }
    }
    //#endregion

    //#region this.dw_mx_itemChanged
    this.dw_mx_itemChanged = function (row, dwoName, data) {
        if (dwoName == "skzh") {
            dw_mx.GetChild("skzh", dwc);
            if (data != "") {
                if (dw_mx_top.GetItemString(1, "pzlx") == "0" && data == "YETZ") {
                    dw_mx.SetItem(row, dwoName, "");
                    dw_mx.SetItem(row, "skfs", "");
                    dw_mx.AcceptText();
                    return 1;
                }
                dw_mx.SetItem(row, "skfs", dwc.GetItemString(dwc.GetSelectedRow(), "zhfl"));
            }
        }
    }
    //#endregion

    //#region this.dw_mx_keyDown 如果是在最后一行的金额列按回车，则自动增加一行

    this.dw_mx_keyDown = function (keyCode, keyFlags) {

        if ((keyCode == 13 || keyCode == 39) && dw_mx.GetColumnName() == "bzxx") {

                if (dw_mx.GetItemNumber(dw_mx.GetRow(), "je") == 0) {
                    requestor.MessageBox("提示", "请为当前行输入金额", 1);
                    dw_mx.SetColumn("je");
                    dw_mx.SetFocus();
                } else if (dw_mx.GetRow() == dw_mx.RowCount()) {
                   
                    dw_mx.ScrollToRow(dw_mx.InsertRow(0));
                  
                    dw_mx.SetColumn("sfkm");
                    dw_mx.SetFocus();
                }
            return 1;
        }
        else if (keyCode == 37) {
            dw_mx.SetColumn("sfkm");
            dw_mx.SetFocus();
            return 1;
        }

    }
        //#endregion

    //#region this.InsertRow
    this.InsertRow = function () {
        if (editMode == "") {
            return;
        }
        if (dw_mx_top.GetItemString(1, "bmbh") == "") {
            requestor.MessageBox("提示", "请选择部门！", ICON.Information);
            dw_mx_top.SetColumn("bmbh");
            dw_mx_top.SetFocus();
            return 1;
        } else if (dw_mx_top.GetItemString(1, "pzlx") == "1" && dw_mx_top.GetItemString(1, "khbh") == "") {
            requestor.MessageBox("提示", "请选择客户！", ICON.Information);
            dw_mx_top.SetColumn("khbh");
            dw_mx_top.SetFocus();
            return 1;
        }
        dw_mx.ScrollToRow(dw_mx.InsertRow(0));
        dw_mx.SetColumn("sfkm");
        dw_mx.SetFocus();
        dw_mx.ScrollFirstPage();
        dw_mx.ScrollToRow(dw_mx.RowCount());
    }
    //#endregion  

    //#region this.DeleteRow
        this.DeleteRow = function () {
            if (editMode == "")
                return;
            var row = dw_mx.GetRow();
            if (row <= 0)
                return;
            var status = dw_mx.GetItemStatus(row, 0, DWBUFFER.Primary);

            if (status == DWITEMSTATUS.DataModified || status == DWITEMSTATUS.NotModified) {
                if (requestor.MessageBox("提示", "是否确认删除当前明细记录?", ICON.Question, BUTTON.YesNo, 2) == 2) {
                    dw_mx.SetFocus();
                    return;
                }
            }

            dw_mx.DeleteRow(0);
            dw_mx.SetFocus();

        }
        //#endregion  

    //#region this.Cancel
        this.Cancel = function () {
            tab_1.SelectTab(1);
            self.SetEditMode("");
            dw_hz.RefreshDetails();
        }
    //#endregion  

    //#region  this.Edit
    this.Edit = function () {
        if (editMode != "")
            return;

        var row = dw_hz.GetRow();
        if (row <= 0)
            return;
        if (self.CheckJzbz()) {
            return;
        }
        dw_mx.Retrieve(dw_hz.GetItemString(row, "pzh"));
        dw_mx_top.Retrieve(dw_hz.GetItemString(row, "pzh"));
        dw_hz.ReSelectRow(row);
        dw_hz.RefreshDetails();
        dw_mx.GetChild("skzh", dwc);
        dwc.Retrieve(dw_hz.GetItemString(row, "bmbh"));
        self.SetEditMode("Edit");
        reCurBigMax = parseInt(dw_mx.GetItemString(dw_mx.RowCount(), "mxdh").split("_")[1]) + 1;
    }

       //#endregion  

    //#region this.Delete
        this.Delete = function () {
            if (editMode != "")
                return;

            var row = dw_hz.GetRow();
            if (row <= 0)
                return;
            if (self.CheckJzbz()) {
                return;
            }
            dw_hz.ReSelectRow(row);
            dw_hz.RefreshDetails();

            var curPzh = dw_hz.GetItemString(row, "pzh");

            if (requestor.MessageBox("提示", "是否确定需要删除凭证号为<" + curPzh + ">的订单?", ICON.Question, BUTTON.YesNo) == 2)
                return;

            webReq.Invoke("XJPZ_Delete", "curPzh=" + curPzh);

            if (webReq.StatusCode() == 200) {
                dw_hz.RowsDiscard(row, row, DWBUFFER.Primary);
                requestor.MessageBox("提示", "删除成功!", ICON.Information);
            }
            else {
                requestor.MessageBox("提示", webReq.ResponseText(), ICON.StopSign);
            }
        }

        //#endregion  

    //#region this.Save 保存。。
        this.Save = function () {
            dw_mx_top.AcceptText();
            dw_mx.AcceptText();
            if ((dw_mx_top.ModifiedCount() + dw_mx.DeletedCount() + dw_mx.ModifiedCount()) <= 0) {
                alert("没有数据需要保存!");
                return;
            }
            //检查是否已经记账
            if (!isAdd) {
                if (self.CheckJzbz()) {
                    return;
                }
            }
            dw_mx_top.SetItem(1, "bmbh", dw_mx_top.GetItemString(1, "bmbh"));
            for (var row = 1; row <= dw_mx.RowCount(); row++) {
                dw_mx.SetItem(row, "sfkm", dw_mx.GetItemString(row, "sfkm"));
            }

            //  更新行号 
            for (row = 1; row <= dw_mx.RowCount(); row++) {
                if (dw_mx.GetItemString(row, "skzh") == "" || dw_mx.GetItemString(row, "sfkm") == "" || dw_mx.GetItemNumber(row, "je") == 0) {
                    dw_mx.DeleteRow(row);
                    row--;
                }
            }

            var curPzh = dw_mx_top.GetItemString(1, "pzh");

            for (row = 1; row <= dw_mx.RowCount(); row++) {
                if (isAdd) {
                    dw_mx.SetItem(row, "pzh", curPzh);
                    dw_mx.SetItem(row, "mxdh", curPzh + "_" + self.formartStr(parseInt(row)));

                } else {
                    if (dw_mx.GetItemString(row, "pzh") == "") {
                        dw_mx.SetItem(row, "pzh", curPzh);
                        dw_mx.SetItem(row, "mxdh", curPzh + "_" + self.formartStr(parseInt(reCurBigMax++)));
                    }
                }

            }

            if (dw_mx.RowCount() == 0) {
                alert("无明细记录!");
                dw_mx.SetFocus();
                return;
            }
            //进行数据数据校验
            if (dw_mx_top.ModifiedCount() > 0 || dw_mx.GetItemString(dw_mx_top.GetRow(), "pzh") == "") {
                if (!dw_mx_top.CheckData("*", ""))
                    return;
            }

            if (dw_mx.ModifiedCount() > 0) {
                if (!dw_mx.CheckData("*", ""))
                    return;
            }
            var pzlx = dw_mx_top.GetItemString(dw_mx_top.GetRow(), "pzlx");
            if (pzlx == "1") {
                var khbh = dw_mx_top.GetItemString(dw_mx_top.GetRow(), "khbh");
                if (khbh == "") {
                    requestor.MessageBox("提示", "请选择客户！", ICON.Information);
                    return;
                }
                var bdqk = 0;
                for (var i = 1; i <= dw_mx.RowCount(); i++) {
                    var sfkm = dw_mx.GetItemString(i, "sfkm");

                    if (sfkm == "00006" || sfkm == "00004") {
                        bdqk = bdqk;
                    } else if (sfkm == "00007") {
                        bdqk = bdqk - dw_mx.GetItemNumber(i, "je");
                    } else {
                        bdqk = bdqk + dw_mx.GetItemNumber(i, "je");
                    }
                }
                //余额精确到部门
                dw_1.Retrieve(dw_mx_top.GetItemString(dw_mx_top.GetRow(), "bmbh"), dw_mx_top.GetItemString(dw_mx_top.GetRow(), "khbh"), "1");
                var nrow = dw_1.RowCount();
                if (nrow > 0) {
                    dw_mx_top.SetItem(dw_mx_top.GetRow(), "sdye", dw_1.GetItemNumber(1, "ye"));
                } else {
                    dw_mx_top.SetItem(dw_mx_top.GetRow(), "sdye", 0);
                }
                var ljqk = dw_mx_top.GetItemNumber(dw_mx_top.GetRow(), "sdye") + bdqk;
                dw_mx_top.SetItem(dw_mx_top.GetRow(), "bdye", parseFloat(ljqk));
                //余额不精确到部门
                dw_1.Retrieve("00", dw_mx_top.GetItemString(dw_mx_top.GetRow(), "khbh"), "0");
                nrow = dw_1.RowCount();
                if (nrow > 0) {
                    dw_mx_top.SetItem(dw_mx_top.GetRow(), "khsdye", dw_1.GetItemNumber(1, "ye"));
                } else {
                    dw_mx_top.SetItem(dw_mx_top.GetRow(), "khsdye", 0);
                }
                var ljqk = dw_mx_top.GetItemNumber(dw_mx_top.GetRow(), "khsdye") + bdqk;
                dw_mx_top.SetItem(dw_mx_top.GetRow(), "khbdye", parseFloat(ljqk));
            }

            var dw_mx_top_data = dw_mx_top.GetChanges();
            var dw_mx_data = dw_mx.GetChanges();
            if (dw_mx_top_data == "" && dw_mx_data == "")
                return;
            //#region 处理时间戳，【判断是否被占用】---------------begin--------------
            //        if (flag == "KP") {
            //            curPzh = curPzh + "_" + curSgdj;
            //        }
            //        webReqTimestamp.Invoke("YW_TIMESTAMP_REC", "curPzh=" + curPzh + "&curFlag=SAVE&curLAST_SJC=" + curSjc + "&times=" + new Date());
            //        if (webReqTimestamp.StatusCode() == 200) {
            //            var resmsg = webReqTimestamp.ResponseText();
            //            if (resmsg.split("#")[0] == "N") {
            //                requestor.MessageBox("提示", "此单据正在被其他人保存,您不能保存。");
            //                return;
            //            }
            //        }
            //        else {
            //            requestor.MessageBox("提示(时间戳)", webReqTimestamp.ResponseText(), ICON.StopSign);
            //        }
            //#endregion 处理时间戳，【判断是否被占用】---------------end----------------
            webReq.Invoke("XJShouRuPZ_Save", "dw_Master=" + dw_mx_top_data + "&dw_Detail=" + dw_mx_data + "&hzDwName=" + dw_mx_top.GetDataObject() + "&mxDwName=" + dw_mx.GetDataObject());

            if (webReq.StatusCode() == 200) {

                //服务器成功处理，返回单号
                var rPzh = webReq.ResponseText();
                dw_mx_top.SetItem(dw_mx_top.GetRow(), "pzh", rPzh);
                if (isAdd) {
                    for (row = 1; row <= dw_mx.RowCount(); row++) {
                        dw_mx.SetItem(row, "pzh", rPzh);
                        dw_mx.SetItem(row, "mxdh", rPzh + "_" + self.formartStr(row));
                    }
                    curBigMaxMxdh = dw_mx.GetItemString(dw_mx.RowCount(), "mxdh");
                    reCurBigMax = new Number(curBigMaxMxdh.substring(curBigMaxMxdh.length - 6, curBigMaxMxdh.length)) + 1;

                    isAdd = false;
                }
                dw_mx_top.ResetUpdate();
                dw_mx.ResetUpdate();
                //更新dw_hz,因为是分页的,直接复制会导致每页的记录数不一致了
                //所以采用刷新的记录的方式来更新列表 

                dw_hz.Refresh();

                //找到相应的记录
                var findRow = dw_hz.Find("pzh='" + rPzh + "' ", 1, dw_hz.RowCount());
                if (findRow > 0) {
                    dw_hz.ScrollToRow(findRow);
                } else {
                    self.Hz_RowFocusChanged(dw_hz.GetRow());
                }

                self.SetEditMode("");
                requestor.MessageBox("提示", "数据保存成功!", ICON.Information);
                //删除临时保存文件
                //self.DelFile();
                dw_mx_top.SetFocus();
                //#region  审核的问题  dw_mkfhjb 
                var curFhjb = dw_hz.GetItemString(dw_hz.GetRow(), "dqzt");
                var fhjbRow = dw_mkfhjb.Find("fhjb='" + curFhjb + "'", 1, dw_mkfhjb.RowCount());
                if (fhjbRow > 0) {
                    tb_1.SetText("btn_Audit", dw_mkfhjb.GetItemString(fhjbRow, "dygn"));
                }
                //#endregion           
            }
            else {
                requestor.MessageBox("提示", webReq.ResponseText(), ICON.StopSign);
                dw_mx_top.SetFocus();
            }
        }
    //#endregion 

    //#region this.formartStr  
    this.formartStr = function (n) {

        var curN = n + "";
        var leftLength = 3 - (curN.length);
        var ret = "";
        for (var i = 1; i <= leftLength; i++) {
            ret = ret + "0";
        }
        return (ret + curN);
    }
    //#endregion  

    //#region 审核
    this.Audit = function () {

        if (dw_hz.GetRow < 1) {
            alert("请先选择一笔数据进行审核");
            return;
        }
        var pzh = dw_hz.GetItemString(dw_hz.GetRow(), "pzh");

        if (pzh.length < 1) {
            alert("凭证号异常");
            return;
        }
        if (!confirm("您确定要审核凭证号为[" + pzh + "]的单据吗？")) {
            return;
        }

        if (self.CheckJzbz()) {
            return;
        }
        var nextZt = self.GetNextZt(dw_hz.GetItemString(dw_hz.GetRow(), "dqzt"));
        webReq.Invoke("XJPZ_Audit", "PZH=" + pzh + "&DJZT=" + nextZt);
        if (webReq.StatusCode() == 200) {

            requestor.MessageBox("提示", "审核成功!", ICON.Information);
            //dw_hz.SetItem(dw_hz.GetRow(), "dqzt", nextZt);
            //self.Hz_RowFocusChanged(dw_hz.GetRow());
            //#region 刷新汇总表
            dw_hz.SetRedraw(false);
            dw_hz.SetProcessing(true);

            //刷新
            self.SelectionChanged();
            //找到相应的记录
            var findRow = dw_hz.Find("pzh='" + pzh + "' ", 1, dw_hz.RowCount());
            if (findRow > 0) {
                dw_hz.ScrollToRow(findRow);
            } else {
                self.Hz_RowFocusChanged(dw_hz.GetRow());
            }
            dw_hz.SetProcessing(false);
            dw_hz.SetRedraw(true);
            //#endregion 

        } else {
            requestor.MessageBox("提示", webReq.ResponseText(), ICON.StopSign);
        }
    }
    //#endregion

    //#region 退审
    this.UnAudit = function () {
        var curRow = dw_hz.GetRow();
        if (curRow < 1) {
            alert("请先选择一笔数据进行退审");
            return;
        }
        var pzh = dw_hz.GetItemString(curRow, "pzh");

        if (pzh.length < 1) {
            alert("凭证号异常");
            return;
        }
        if (!confirm("您确定要退审凭证号为[" + pzh + "]的单据吗？")) {
            return;
        }
        if (self.CheckJzbz()) {
            return;
        }
        webReq.Invoke("XJPZ_UnAudit", "PZH=" + pzh + "&curFunId=SJ297");
        if (webReq.StatusCode() == 200) {

            requestor.MessageBox("提示", "退审成功!", ICON.Information);
            //dw_hz.SetItem(curRow, "dqzt", "F");
            //self.Hz_RowFocusChanged(curRow);
            //#region 刷新汇总表
            dw_hz.SetRedraw(false);
            dw_hz.SetProcessing(true);

            //刷新
            self.SelectionChanged();
            //找到相应的记录
            var findRow = dw_hz.Find("pzh='" + pzh + "' ", 1, dw_hz.RowCount());
            if (findRow > 0) {
                dw_hz.ScrollToRow(findRow);
            } else {
                self.Hz_RowFocusChanged(dw_hz.GetRow());
            }
            dw_hz.SetProcessing(false);
            dw_hz.SetRedraw(true);
            //#endregion 
        } else {
            requestor.MessageBox("提示", webReq.ResponseText(), ICON.StopSign);
        }
    }
    //#endregion  

    //#region GetNextZt
    this.GetNextZt = function (curZt) {
        if ("F" == curZt) {
            var nextRow = dw_mkfhjb.Find(" fhjb='1' ", 1, dw_mkfhjb.RowCount());
            if (nextRow > 0) {
                return "1";
            } else {
                return "T";
            }
        } else {
            var nextZt = parseInt(curZt) + 1;
            var nextRow = dw_mkfhjb.Find(" fhjb='" + nextZt + "' ", 1, dw_mkfhjb.RowCount());
            if (nextRow > 0) {
                return nextZt + "";
            } else {
                return "T";
            }
        }
    }
    //#endregion

    //#region 记账
    this.Tally = function () {

        if (dw_hz.GetRow < 1) {
            alert("请先选择一笔数据进行审核");
            return;
        }
        var pzh = dw_hz.GetItemString(dw_hz.GetRow(), "pzh");

        if (pzh.length < 1) {
            alert("凭证号异常");
            return;
        }
        if (!confirm("您确定要记账凭证号为[" + pzh + "]的单据吗？")) {
            return;
        }
        //#region 检查本单据是否已经记账
        if (self.CheckJzbz()) {
            return;
        }
        //#endregion
        webReq.Invoke("XJPZ_Tally", "curPzh=" + pzh);
        if (webReq.StatusCode() == 200) {
            requestor.MessageBox("提示", webReq.ResponseText(), ICON.Information);
            //#region 刷新汇总表
            dw_hz.SetRedraw(false);
            dw_hz.SetProcessing(true);

            //刷新
            self.SelectionChanged();
            //找到相应的记录
            var findRow = dw_hz.Find("pzh='" + pzh + "' ", 1, dw_hz.RowCount());
            if (findRow > 0) {
                dw_hz.ScrollToRow(findRow);
            } else {
                self.Hz_RowFocusChanged(dw_hz.GetRow());
            }
            dw_hz.SetProcessing(false);
            dw_hz.SetRedraw(true);
            //#endregion 
            dw_mx_top.Modify("ysh_q_t.visible='0' ysh_t.visible='0' ysh_t.Text=''");
            tb_1.SetEnabled("btn_Save", false);
            tb_1.SetEnabled("btn_Audit", false);
            tb_1.SetEnabled("btn_UnAudit", false);
            tb_1.SetEnabled("btn_Tally", false);
            tb_1.SetEnabled("btn_Delete", false);
            tb_1.SetEnabled("btn_Edit", false);
        } else {
            //alert(webReq.ResponseText());
            requestor.MessageBox("提示", webReq.ResponseText(), ICON.StopSign);
        }

    }
    //#endregion   

    //#region Top_DoubleClicked
    this.Top_DoubleClicked = function (x, y, row, dwoName) {
        if (dwoName == "bmbh") {
            curW_OPEN.SetDataWindow(dw_mx_top, "bmbh", "bmmc", "M", self)   // 这个用来给子窗口Set当前数据窗口
            requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowQueryBase&treeDw=dw_da_bmda_fl_tree&listDw=dw_pub_list_bmda&treeRootLabel=部门分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&curQxlx=cw"), curW_OPEN, null);
        }
        if (dwoName == "khbh") {
            var pzlx = dw_mx_top.GetItemString(row, "pzlx");
            if (pzlx == "0") {
                return;
            }
            curW_OPEN.SetDataWindow(dw_mx_top, "khbh", "khmc", "M", self)   // 这个用来给子窗口Set当前数据窗口
            requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowQueryBase&treeDw=dw_da_khda_fl_tree&listDw=dw_pub_khda_list_all&treeRootLabel=客户分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast"), curW_OPEN, null);
        }

    }
    //#endregion

    this.SetSleValue = function (dwoName, data) {
        dw_mx_top.SetItem(dw_mx_top.GetRow(), dwoName, data.substring(1, data.length - 1));
        self.Top_itemChanged(dw_mx_top.GetRow(), dwoName, data.substring(1, data.length - 1));
    }

    //#region GetFocusMx
    this.GetFocusMx = function () {
        if (dw_mx_top.GetItemString(1, "bmbh") == "") {
            //requestor.MessageBox("提示", "请选择部门！", ICON.Information);
            dw_mx_top.SetColumn("bmbh");
            dw_mx_top.SetFocus();
            return 1;
        } else if (dw_mx_top.GetItemString(1, "pzlx") == "1" && dw_mx_top.GetItemString(1, "khbh") == "") {
            //requestor.MessageBox("提示", "请选择客户！", ICON.Information);
            dw_mx_top.SetColumn("khbh");
            dw_mx_top.SetFocus();
            return 1;
        }
    }
    //#endregion

    //#region 打印
    this.Print = function () {
        var dwc = new DataWindowChild();
        dw_print.SetDataObject("dw_null");
        dw_proxy.SetDataObject("dw_null");
        var curVisibleNoModifyStr = "";
        var curZdyNoVisibleCol = "";
        var curVisibleStr = "";
        var curVisibleArrStr = "";
        var curAllColumnArr = new Array();
        var modifyArr = new Array();
        var curAllColumn = "";
        var curSlje = 0; //数量金额
        var curRmb = 0; //人民币
        var curDygs = "1";
//        dw_mx.Retrieve(dw_mx_top.GetItemString(dw_mx_top.GetRow(), "pzh"));
        var pzh = dw_hz.GetItemString(dw_hz.GetRow(), "pzh");
        dw_mx.Retrieve(pzh);   
        var curSjbh = requestor.GetParm("curFunctionId");
        var curUserId = requestor.GetParm("curUserId");
        dw_xt_div_tree_no_parm.Retrieve(curUserId);

        dw_proxy.SetFullState(dw_mx.GetFullState());
        //#region 1--begin 先取排过序，调整过宽度的数据窗口


        var findRow = dw_xt_div_tree_no_parm.Find(" cdbh ='" + curSjbh + "'", 0, dw_xt_div_tree_no_parm.RowCount());

        if (findRow > 0) {
            var curSjckmc = dw_xt_div_tree_no_parm.GetItemString(findRow, "sjckmc");
            var curMkCName = dw_xt_div_tree_no_parm.GetItemString(findRow, "cdmc");

            dw_da_qx_mokuai.RetrieveEx(" yhbh ='" + curUserId + "' and cdbh ='" + curSjbh + "'"); // 权限模块表，查出[当前]用户的[当前]模块

            //取不显示列的 modify 字符串【来自权限】
            if (dw_da_qx_mokuai.RowCount() > 0) {
                var curSortStr = dw_da_qx_mokuai.GetItemString(1, "zdypxdy" + curDygs); // 自定义排序
                //------------------------------------权限不显示列-------------begin------------------
                var curLzfc = dw_da_qx_mokuai.GetItemString(1, "lzfc"); // 不显示的列字符串                
                curVisibleNoModifyStr = curLzfc;
                //------------------------------------自定义不显示列-------------begin----------------
                var curZdyycl = dw_da_qx_mokuai.GetItemString(1, "zdyycldy" + curDygs); // 自定义不显示列     
                curZdyNoVisibleCol = curZdyycl;
                if (curLzfc.length > 0) {
                    curLzfc += "," + curZdyycl;
                } else {
                    curLzfc += curZdyycl;
                }
                //------------------------------------自定义不显示列-------------end------------------
                if (curLzfc.length > 0) {
                    var curVisibleArr = curLzfc.split(",");
                    for (var k = 0; k < curVisibleArr.length; k++) {
                        curVisibleStr += curVisibleArr[k] + ".Visible='0' "; // 不显示的列字符串设置为【不显示】
                        curVisibleStr += curVisibleArr[k] + ".Width='0' "; // 不显示的列字符串设置为【不显示】
                        if (curVisibleArrStr.length > 0) {
                            curVisibleArrStr += "," + curVisibleArr[k];
                        } else {
                            curVisibleArrStr += curVisibleArr[k];
                        }
                    }
                }
                //------------------------------------权限不显示列-------------end------------------
            }

            var colNewNameArr = new Array();
            // 初始化列对应的名称（取权限表里边自定义的列名称）
            var curGglm = dw_da_qx_mokuai.GetItemString(1, "gglm");

            if (curSjckmc != null && curSjckmc.length > 0) {
                dw_print.SetDataObject(curSjckmc); // 隐藏数据窗口  
                var colCount = dw_print.Describe("DataWindow.Column.Count");
                var modifyArr = new Array();
                for (var i = 1; i <= colCount; i++) {
                    if (dw_print.Describe("#" + i + ".Visible") == "1") {
                        var detailName = dw_print.Describe("#" + i + ".Name"); // PB对应字段名                           
                        var curNewName = self.isMyHave(curGglm, detailName) // 没有就返回-1，有就返回当前新的名称
                        if (curNewName != "-1") {
                            curAllColumnArr.push(detailName + "#" + curNewName);
                            modifyArr.push(detailName + "_t.Text='" + curNewName + "'");
                        } else {
                            curAllColumnArr.push(detailName + "#" + (dw_print.Describe(detailName + "_t.Text") == "!" ? detailName : dw_print.Describe(detailName + "_t.Text")) + "#" + dw_print.Describe(detailName + ".x"));
                            modifyArr.push(detailName + "_t.Text='" + (dw_print.Describe(detailName + "_t.Text") == "!" ? detailName : dw_print.Describe(detailName + "_t.Text")) + "'");
                        }
                    }
                }
                //#region  计算列
                var ls_objects = dw_print.Describe("DataWindow.Objects");
                var ls_objectsArr = ls_objects.split("\t");
                for (var w = 0; w < ls_objectsArr.length; w++) {
                    var ls_name = ls_objectsArr[w].substring(0, ls_objectsArr[w].length - 2);
                    var ls_type = dw_print.Describe(ls_name + ".type");
                    var ls_band = dw_print.Describe(ls_name + ".band");
                    if (ls_type == "compute" && ls_band == "detail") {

                        //#region 这里是计算列
                        if (dw_print.Describe(ls_name + ".visible") == "1") {
                            var detailName = dw_print.Describe(ls_name + ".Name"); // PB对应字段名      
                            var curNewName = self.isMyHave(curGglm, detailName) // 没有就返回-1，有就返回当前新的名称
                            if (curNewName != "-1") {
                                curAllColumnArr.push(detailName + "#" + curNewName + "#" + dw_print.Describe(detailName + ".x"));
                                modifyArr.push(detailName + "_t.Text='" + curNewName + "'");
                            } else {
                                curAllColumnArr.push(detailName + "#" + dw_print.Describe(detailName + "_t.Text") + "#" + dw_print.Describe(detailName + ".x"));
                                modifyArr.push(detailName + "_t.Text='" + dw_print.Describe(detailName + "_t.Text") + "'");
                            }

                        }
                        //#endregion
                    }
                }

                //#endregion 
                dw_print.Modify(modifyArr.join(" ").toString());     // 权限中修改列的名称  
            } else {
                alert("请为当前模块设置数据窗口名称");
                return;
            }
        }

        if (curVisibleStr.length > 0) {
            dw_print.Modify(curVisibleStr.toString());  // 不显示列【来自权限】。                      // 1.不显示的列
        }
        // 当前显示的所有列

        curAllColumn = self.getMyNewStr(curAllColumnArr, curVisibleNoModifyStr.toString());      //  2.当前所有列

        self.DoSort(curSortStr, false);
        //#endregion 1--end 


        var curAllModifyStr = "";
        var curAllModifyStrFreeDw = "";
        var curHeaderHeight = 600;
        var curDetailHeight = 88;
        var curSummaryHeight = 300;
        var curHengXiangOrShuXiang = 1//默认是横向。
        var curZhiZhang = 1//默认是纸张。
        var curZhiZhangDaXiao = 4//默认是纸张大小。

        dw_proxy.ShareData(dw_print);
        dw_print.SetRedraw(false);

        //#region 获取 dw_parameter，值 
        if (curSjbh != null && curSjbh != "") {
            dw_parameter.Retrieve(curSjbh, curUserId, curDygs);
            if (dw_parameter.RowCount() > 0) {
                if (dw_parameter.GetItemNumber(1, "header_val_" + curDygs) > 0) {
                    curHeaderHeight = dw_parameter.GetItemNumber(1, "header_val_" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "detail_val_" + curDygs) > 0) {
                    curDetailHeight = dw_parameter.GetItemNumber(1, "detail_val_" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "summary_val_" + curDygs) > 0) {
                    curSummaryHeight = dw_parameter.GetItemNumber(1, "summary_val_" + curDygs);
                }

                if (dw_parameter.GetItemNumber(1, "orien" + curDygs) > 0) {
                    curHengXiangOrShuXiang = dw_parameter.GetItemNumber(1, "orien" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "paper" + curDygs) > 0) {
                    curZhiZhang = dw_parameter.GetItemNumber(1, "paper" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "papersize" + curDygs) > 0) {
                    curZhiZhangDaXiao = dw_parameter.GetItemNumber(1, "papersize" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "cb_slje_" + curDygs) > 0) {
                    curSlje = dw_parameter.GetItemNumber(1, "cb_slje_" + curDygs);
                }
                if (dw_parameter.GetItemNumber(1, "cb_rmb_" + curDygs) > 0) {
                    curRmb = dw_parameter.GetItemNumber(1, "cb_rmb_" + curDygs);
                }

            }
        }
        //#endregion 

        //#region 初始化当前窗口 curAllColumn, curVisibleArrStr,
        if (curAllColumn.length > 0) {
            var curColumns = curAllColumn.split("@");
            dw_sort.Reset();
            for (var i = 0; i < curColumns.length; i++) {
                if (self.isHave(curVisibleArrStr, curColumns[i].split("#")[0])) {
                    // 打×的不显示出来
                    //alert(curColumns[i].split("#")[0] + ".visible='0'");
                    dw_print.Modify(curColumns[i].split("#")[0] + ".visible='0'");
                    dw_print.Modify(curColumns[i].split("#")[0] + ".width='0'");

                } else {

                    var rows = dw_sort.RowCount() + 1;
                    dw_sort.InsertRow(rows);
                    dw_sort.SetItem(rows, "flag1", curColumns[i].split("#")[0]);
                    dw_sort.SetItem(rows, "flag2", curColumns[i].split("#")[1]);
                    dw_sort.SetItem(rows, "pxbh", parseInt(dw_print.Describe(curColumns[i].split("#")[0] + ".x")))
                    // dw_sort.SetItem(rows, "pxbh", parseInt(curColumns[i].split("#")[2]));
                    dw_sort.SetItem(rows, "flag3", "√");

                    // 如果不是二维模式的时候把header中_t抬高
                    if (curDygs != "1") {
                        dw_print.Modify(curColumns[i].split("#")[0] + "_t.y='0'");
                    }
                    //把尺码1-35的Text清空
                    if (curColumns[i].split("#")[0].length > 2 && curColumns[i].split("#")[0].substring(0, 2).toUpperCase() == "CM" && !isNaN(curColumns[i].split("#")[0].substring(2, 5))) {
                        // 如果不是二维模式的时候把header第一行设置为空.

                        if (curDygs != "1") {
                            //本来这里应该要设置为空是最好的，但是我要在header.1区域取尺码标题，所有先把第一行的尺码标题字体设置为透明的。
                            //  dw_print.Modify(curColumns[i].split("#")[0] + "_t.Text=''");
                            dw_print.Modify(curColumns[i].split("#")[0] + "_t.color='553648127'");
                        }
                    }
                }
            }
        }
        dw_sort.SetSort("pxbh");
        dw_sort.Sort();
        //#endregion  

        //#region 画线 
        if (curDygs == "1") { // 二唯

        } else {              // 非二唯
            // 改变header高度
            dw_print.Modify("DataWindow.Header.Height='70'");

        }

        //第一条横线从这里开始。
        var curHxStart = parseInt(curHeaderHeight) - parseInt(dw_print.Describe("DataWindow.Header.Height"));
        //竖线-最左边
        var curXhLStart = dw_sort.GetItemNumber(1, "pxbh");
        //竖线-最右边
        var curXhREnd = parseInt(parseInt(dw_sort.GetItemNumber(dw_sort.RowCount(), "pxbh")) + parseInt(dw_print.Describe(dw_sort.GetItemString(dw_sort.RowCount(), "flag1") + ".width")));

        // Head宽度放大。背景颜色设为“透明”
        curAllModifyStr += "DataWindow.Header.Height='" + curHeaderHeight + "'\tDataWindow.Header.Color='553648127'\tDataWindow.detail.Height='" + curDetailHeight + "'\t DataWindow.summary.Height='" + curSummaryHeight + "'\t";

        // 这里把所有的header区域压下来。。。
        var ls_objects = dw_print.Describe("DataWindow.Objects");
        var ls_objectsArr = ls_objects.split("\t");
        for (var w = 0; w < ls_objectsArr.length; w++) {
            var ls_name = ls_objectsArr[w];
            var ls_name_hz = ls_name.substring(ls_name.length - 2, ls_name.length);
            if (ls_name.length > 2 && ls_name_hz == "_t") {
                var curT_y = dw_print.Describe(ls_name + ".y");
                dw_print.Modify(ls_name + ".y='" + parseInt(parseInt(curHxStart) + parseInt(curT_y)) + "'");
                if (curDygs == "1") { // 二维    
                    dw_print.Modify("cm" + parseInt(w + 1) + "_t.border='4'");
                } else {
                    dw_print.Modify(ls_name + ".border='0'");
                }
            }
        }


        //字段列 
        for (var i = 1; i <= dw_sort.RowCount(); i++) {
            var colName = dw_sort.GetItemString(i, "flag1");
            curAllModifyStr += colName + ".moveable='1'\t";
            curAllModifyStr += colName + "_t.moveable='1'\t";
            var curX = dw_sort.GetItemNumber(i, "pxbh") - 10;
            if (i == 1) {
                curX = curX + 9;
            }
            // ------------------------------画列的竖线--------------------begin--
            // Header
            curAllModifyStrFreeDw += " create line(band=header x1='" + curX + "' y1='" + curHxStart + "' x2='" + curX + "' y2='" + curHeaderHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
            // Detail
            curAllModifyStrFreeDw += " create line(band=detail x1='" + curX + "' y1='0'  x2='" + curX + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
            // summary
            curAllModifyStrFreeDw += " create line(band=summary x1='" + curX + "' y1='0'  x2='" + curX + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";

            // ------------------------------画列的竖线--------------------end---
            //            // 最后一列有画最右边的线
            if (i == dw_sort.RowCount()) {
                // Header
                curAllModifyStrFreeDw += " create line(band=header x1='" + curXhREnd + "' y1='" + curHxStart + "' x2='" + curXhREnd + "' y2='" + curHeaderHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
                // Detail
                curAllModifyStrFreeDw += " create line(band=detail x1='" + curXhREnd + "' y1='0'  x2='" + curXhREnd + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
                // summary
                curAllModifyStrFreeDw += " create line(band=summary x1='" + curXhREnd + "' y1='0'  x2='" + curXhREnd + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";

            }

        }
        //画横线。。。
        //最上边的线
        curAllModifyStrFreeDw += " create line(band=header x1='" + curXhLStart + "' y1='" + curHxStart + "' x2='" + curXhREnd + "' y2='" + curHxStart + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
        //数据区域的start线
        curAllModifyStrFreeDw += " create line(band=detail x1='" + curXhLStart + "' y1='0' x2='" + curXhREnd + "' y2='0' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
        //数据区域的end线
        curAllModifyStrFreeDw += " create line(band=detail x1='" + curXhLStart + "' y1='" + curDetailHeight + "' x2='" + curXhREnd + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
        //summaryStart线
        curAllModifyStrFreeDw += " create line(band=summary x1='" + curXhLStart + "' y1='0'  x2='" + curXhREnd + "' y2='0' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
        //summaryend线
        curAllModifyStrFreeDw += " create line(band=summary x1='" + curXhLStart + "' y1='" + curDetailHeight + "'  x2='" + curXhREnd + "' y2='" + curDetailHeight + "' pen.style='0' pen.width='5' pen.color='0'  background.mode='2' background.color='16777215' )\t";
        //结束线
        //    curAllModifyStrFreeDw += " create line(band=summary x1='" + curXhLStart + "' y1='" + curSummaryHeight + "'  x2='" + curXhREnd + "' y2='" + curSummaryHeight + "' pen.style='0' pen.width='10' pen.color='255'  background.mode='2' background.color='16777215' )\t";



        // 处理显示数据列名称
        curAllModifyStrFreeDw += " DataWindow.ShowDefinition='Yes'\t";

        // 设置标题
        var tit = requestor.GetParm("dw_yw_cg_top_title_value");
        var titX = 1400; // 设置标题
        var titYmX = 2800; //【页码】
        var titRqX = 2300; //【加入日期】 
        var titJjyrjX = 1500; //【" + GetErpProductTypeName() + "软件】
        var titBzX = 2800; //加入打印备注
        var titSlAndJeX = "2500"// 数量金额
        var titRmb = "2500"// 人民币大写
        curAllModifyStrFreeDw += " create text(band=header     alignment='2' text='" + tit + "' border='0'  name=my_title moveable=1 resizeable=1   color='0'  x='" + titX + "'  y='25' height='85' moveable=1 width='500'  font.face='黑体' font.height='-14' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='16777215')\t";
        //【页码】 
        curAllModifyStrFreeDw += " create text(band=header     alignment='0' text='页码' border='0' moveable=1 resizeable=1  name=my_ym  color='0' x='" + titYmX + "'  y='120' height='56' moveable=1 width='200'  font.face='黑体' font.height='-10' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='16777215')\t";
        //【数量金额】
        curAllModifyStrFreeDw += " create text(band=header  alignment='0' text='数量金额' border='0' moveable=1 resizeable=1  name=my_slje  color='0' x='" + titSlAndJeX + "' visible='" + curSlje + "' y='120' height='56' moveable=1 width='700'  font.face='黑体' font.height='-10' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='16777215')\t";
        //【人民币大写】
        curAllModifyStrFreeDw += " create text(band=summary  alignment='0' text='人民币大写' border='0' moveable=1 resizeable=1  name=my_rmb  color='0' x='" + titRmb + "'  y='60' visible='" + curRmb + "' height='56' moveable=1 width='700'  font.face='黑体' font.height='-10' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='16777215')\t";
        //【" + GetErpProductTypeName() + "软件】
        curAllModifyStrFreeDw += " create text(band=summary    alignment='1' text='【" + GetErpProductTypeName() + "软件】' name=my_jjyrj  border='0'moveable=1 resizeable=1  color='0' x='" + titJjyrjX + "' y='" + parseInt(curDetailHeight + 100) + "' height='56' width='400'  font.face='宋体' font.height='-9' font.weight='400'  font.family='0' font.pitch='2' font.charset='134' font.underline='0' background.mode='2' background.color='16777215')\t";
        //【加入日期】
        curAllModifyStrFreeDw += " create compute(band=summary alignment='1' expression='today()' border='0' color='0'   moveable=1 resizeable=1        x='" + titRqX + "'  y='" + parseInt(curDetailHeight + 100) + "' height='56' width='400' format='yyyy年mm月dd日'  name=my_rq  font.face='宋体' font.height='-9' font.weight='400'  font.family='0' font.pitch='2' font.charset='134' background.mode='2' background.color='16777215')\t";
        //加入打印备注
        curAllModifyStrFreeDw += " create text(band=summary    alignment='0' text='打印'  name=my_dy    border='0' color='0' moveable=1 resizeable=1       x='" + titBzX + "' y='" + parseInt(curDetailHeight + 100) + "' height='56' width='400'  font.face='宋体' font.height='-9' font.weight='400'  font.family='0' font.pitch='2' font.charset='134' font.underline='0' background.mode='2' background.color='16777215' )\t";
        //        //-------------------------------表头区域------------------end-------   
        dw_print.Modify(curAllModifyStr);

        //#region 如果visible的列就不显示。
        var colCount = dw_print.Describe("DataWindow.Column.Count");
        for (var k = 1; k <= colCount; k++) {
            var detailName = dw_print.Describe("#" + k + ".Name"); // PB对应字段名    
            if (dw_print.Describe(detailName + ".visible") == '0') {
                dw_print.Modify(detailName + ".Visible='0' " + detailName + ".Width='0'");
            } else {
                dw_print.Modify(detailName + "_t.background.mode='0'");
                dw_print.Modify(detailName + "_t.background.color='553648127'");
                dw_print.Modify(detailName + "_t.background.gradient.color ='553648127'");

                if (detailName.length > 2 && detailName.substring(0, 2).toUpperCase() == "CM" && !isNaN(detailName.substring(2, 5))) {
                    for (var i = 1; i < 10; i++) {
                        var ls_names = detailName + (i > 9 ? i : "0" + i);
                        dw_print.Modify(ls_names + "_t.background.mode='0' " + ls_names + "_t.background.color='553648127' " + ls_names + "_t.background.gradient.color ='553648127'");
                        if (curDygs == "1") {
                            dw_print.Modify(ls_names + "_t.border='4' ");
                        } else {
                            dw_print.Modify(ls_names + "_t.border='1' ");
                        }
                    }
                }
            }
        }
        //#region  计算列
        var ls_objects = dw_print.Describe("DataWindow.Objects");
        var ls_objectsArr = ls_objects.split("\t");
        for (var w = 0; w < ls_objectsArr.length; w++) {
            var ls_name = ls_objectsArr[w].substring(0, ls_objectsArr[w].length - 2);
            var ls_type = dw_print.Describe(ls_name + ".type");
            var ls_band = dw_print.Describe(ls_name + ".band");
            if (ls_type == "compute" && ls_band == "detail") {
                dw_print.Modify(ls_name + "_t.background.mode='0'");
                dw_print.Modify(ls_name + "_t.background.color='553648127'");
                dw_print.Modify(ls_name + "_t.background.gradient.color ='553648127'");
                if (dw_print.Describe(ls_name + ".visible") == '0') {
                    dw_print.Modify(ls_name + ".Visible='0' " + ls_name + ".Width='0'");
                } else {
                    dw_print.Modify(ls_name + "_t.background.mode='0'  " + ls_name + "_t.background.color='553648127'");
                }
            }
        }

        //#endregion
        ls_syntax = dw_print.Describe("DataWindow.Syntax");
        ls_syntax = ls_syntax.replace("processing=1", "processing=0");
        dw_print.Create(ls_syntax);
        dw_print.Modify(curAllModifyStrFreeDw);
        dw_proxy.ShareData(dw_print);
        dw_print.SetSort("mxdh");
        dw_print.Sort();
        for (var i = 1; i <= dw_print.RowCount(); i++) {
            dw_print.SetItem(i, "sfkm", dw_print.GetItemString(i, "kmmc"));
            dw_print.SetItem(i, "skzh", dw_print.GetItemString(i, "skzhmc"));
        }
        dw_print.SetRedraw(true);
        //#endregion 画线

        //#region 表头表尾取值
        dw_init.Retrieve(curUserId, curSjbh, curDygs); // 打印初始化      

        for (var i = 1; i <= dw_init.RowCount(); i++) {
            var curModifyTopButtonStr = "";
            var obj = dw_init.GetItemString(i, 'obj');
            var obj_typ = dw_init.GetItemString(i, 'obj_typ');
            if (obj_typ == "") {
                obj_typ = "text";
            }
            if (obj_typ && obj_typ.length < 3) {
                obj_typ = "text";
            }
            var band = dw_init.GetItemString(i, 'band_n');
            var xin = dw_init.GetItemString(i, 'xin');
            var pos_x = dw_init.GetItemString(i, 'pos_x');
            var pos_y = dw_init.GetItemString(i, 'pos_y');
            var pos_x2 = dw_init.GetItemString(i, 'pos_x2');
            var pos_y2 = dw_init.GetItemString(i, 'pos_y2');
            var pos_width = dw_init.GetItemString(i, 'pos_width');
            var pos_height = dw_init.GetItemString(i, 'pos_height');
            var font_face = dw_init.GetItemString(i, 'font_face');
            var font_height = dw_init.GetItemString(i, 'font_height');
            var font_weight = dw_init.GetItemString(i, 'font_weight');
            var font_italic = dw_init.GetItemString(i, 'font_italic');
            var font_underline = dw_init.GetItemString(i, 'font_underline');
            var dw_border = dw_init.GetItemString(i, 'dw_border');
            var pos_width = dw_init.GetItemString(i, 'pos_width');
            var pos_height = dw_init.GetItemString(i, 'pos_height');
            var dw_visible = dw_init.GetItemString(i, 'dw_visible');
            var pen_style = dw_init.GetItemString(i, 'pen_style');
            var pen_width = dw_init.GetItemString(i, 'pen_width');
            var pen_color = '0';
            var color1 = '0';
            var format1 = dw_init.GetItemString(i, 'format');
            var alignment1 = dw_init.GetItemString(i, 'alignment');
            var style1 = dw_init.GetItemString(i, 'style');
            var text1 = dw_init.GetItemString(i, 'text_n');

            if (xin == '0') {
                if (obj_typ == "line") {
                    if (pos_x.length > 0 && pos_x != "?") { curModifyTopButtonStr += obj + ".x1='" + pos_x + "'\t"; }
                    if (pos_y.length > 0 && pos_y != "?") { curModifyTopButtonStr += obj + ".y1='" + pos_y + "'\t"; }
                    if (pos_width.length > 0 && pos_width != "?") { curModifyTopButtonStr += obj + ".x2='" + pos_width + "'\t"; }
                    if (pos_height.length > 0 && pos_height != "?") { curModifyTopButtonStr += obj + ".y2='" + pos_height + "'\t"; }
                    if (pen_style > 0 && pen_style != "?") { curModifyTopButtonStr += obj + ".pen.style='" + pen_style + "'\t"; }
                    if (pen_width.length > 0 && pen_width != "?") { curModifyTopButtonStr += obj + ".pen.width='" + pen_width + "'\t"; }
                    if (pen_color.length > 0 && pen_color != "?") { curModifyTopButtonStr += obj + ".pen.color='" + pen_color + "'\t"; }
                } else if (obj_typ == "rectangle" || obj_typ == "roundrectangle" || obj_typ == "ellipse") {
                    if (pos_x.length > 0 && pos_x != "?") { curModifyTopButtonStr += obj + ".x='" + pos_x + "'\t"; }
                    if (pos_y.length > 0 && pos_y != "?") { curModifyTopButtonStr += obj + ".pen.y='" + pos_y + "'\t"; }
                    if (pen_width.length > 0 && pen_width != "?") { curModifyTopButtonStr += obj + ".pen.width='" + pen_width + "'\t"; }
                    if (pos_height.length > 0 && pos_height != "?") { curModifyTopButtonStr += obj + ".pos.height='" + pos_height + "'\t"; }
                    if (color1.length > 0 && color1 != "?") { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                } else if (obj_typ == "groupbox" || obj_typ == "button") {
                    if (pos_x.length > 0) { curModifyTopButtonStr += obj + ".x='" + pos_x + "'\t"; }
                    if (pos_y.length > 0) { curModifyTopButtonStr += obj + ".y='" + pos_y + "'\t"; }
                    if (pos_width.length > 0) { curModifyTopButtonStr += obj + ".width='" + pos_width + "'\t"; }
                    if (pos_height.length > 0) { curModifyTopButtonStr += obj + ".height='" + pos_height + "'\t"; }
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }
                    if (text1.length > 0) { curModifyTopButtonStr += obj + ".text='" + text1 + "'\t"; }
                } else if (obj_typ == "bitmap") {
                    if (pos_x.length > 0) { curModifyTopButtonStr += obj + ".x='" + pos_x + "'\t"; }
                    if (pos_y.length > 0) { curModifyTopButtonStr += obj + ".y='" + pos_y + "'\t"; }
                    if (pos_width.length > 0) { curModifyTopButtonStr += obj + ".width='" + pos_width + "'\t"; }
                    if (pos_height.length > 0) { curModifyTopButtonStr += obj + ".height='" + pos_height + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                } else if (obj_typ == "column" || obj_typ == "text" || obj_typ == "compute") {
                    if (pos_x.length > 0) { curModifyTopButtonStr += obj + ".x='" + pos_x + "'\t"; }
                    if (pos_y.length > 0) { curModifyTopButtonStr += obj + ".y='" + pos_y + "'\t"; }
                    if (pos_width.length > 0) { curModifyTopButtonStr += obj + ".width='" + pos_width + "'\t"; }
                    if (pos_height.length > 0) { curModifyTopButtonStr += obj + ".height='" + pos_height + "'\t"; }
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }
                    if (text1.length > 0) {
                        curModifyTopButtonStr += obj + ".text='" + text1 + "'\t";
                        dw_print.Modify(obj + ".text='" + text1 + "'");
                    }
                }
            } else if (xin == '1') {
                if (obj_typ == "line") {
                    curModifyTopButtonStr += ' create line(band=' + band + ' resizeable=1  moveable=1 x1="' + pos_x + '"   y1="' + pos_y + '"' + ' x2="' + pos_x2 + '"' + ' y2="' + pos_y2 + '"' + '  name=' + obj + ' visible="1"  resizeable=1  moveable=1 pen.style="0" pen.width="5" pen.color="0"  background.mode="2" background.color="1073741824" )\t';
                    //                    if (pen_style.length > 0) { curModifyTopButtonStr += obj + ".pen.style='" + pen_style + "'\t"; }
                    //                    if (pen_width.length > 0) { curModifyTopButtonStr += obj + ".pen.width='" + pen_width + "'\t"; }
                    //                    if (pen_color.length > 0) { curModifyTopButtonStr += obj + ".pen.color='" + pen_color + "'\t"; }
                } else if (obj_typ == "rectangle") {
                    curModifyTopButtonStr += 'create rectangle(band=background resizeable=1  moveable=1   x="' + pos_x + '"   y="' + pos_y + '"' + 'height="' + pos_height + '" width="' + pos_width + '"' + '   name=' + obj + ' visible="1" brush.hatch="6" brush.color="16777215" pen.style="0" pen.width="5" pen.color="33554432"  background.mode="2" background.color="33554432" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                } else if (obj_typ == "roundrectangle") {
                    curModifyTopButtonStr += 'create roundrectangle(band=background resizeable=1  moveable=1  ellipseheight="36" ellipsewidth="41" x="' + pos_x + '"   y="' + pos_y + '"' + 'height="' + pos_height + '" width="' + pos_width + '"' + '   name=' + obj + ' visible="1" brush.hatch="6" brush.color="16777215" pen.style="0" pen.width="5" pen.color="33554432"  background.mode="2" background.color="33554432" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                } else if (obj_typ == "ellipse") {
                    curModifyTopButtonStr += 'create ellipse(band=background resizeable=1  moveable=1   x="' + pos_x + '"   y="' + pos_y + '"' + 'height="' + pos_height + '" width="' + pos_width + '"' + '   name=' + obj + ' visible="1" brush.hatch="6" brush.color="16777215" pen.style="0" pen.width="5" pen.color="33554432"  background.mode="2" background.color="33554432" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color1='" + color1 + "'\t"; }
                } else if (obj_typ == "groupbox") {
                    curModifyTopButtonStr += 'create   groupbox(band=background border="2"  resizeable=1  moveable=1  text="' + text1 + '"     x="' + pos_x + '"   y="' + pos_y + '"' + 'height="' + pos_height + '" width="' + pos_width + '"     name=' + obj + ' visible="1" color="33554432" background.color="1073741824" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }
                } else if (obj_typ == "button") {
                    curModifyTopButtonStr += 'create button(band=' + band + ' text="' + left(text1, pos(text1, '|') - 1) + '" filename= "' + right(text1, len(text1) - pos(text1, '|') - 1) + '" action="0" border="1" color="33554432" x="' + pos_x + '" y="' + pos_y + '" height="' + pos_height + '" width="' + pos_width + '" vtextalign="0" htextalign="0"  name=' + obj + ' visible="1"  font.face="楷体_GB2312" font.height="-24" font.weight="700"  font.family="1" font.pitch="1" font.charset="134" background.mode="2" background.color="67108864" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }
                } else if (obj_typ == "bitmap") {
                    curModifyTopButtonStr += ' create bitmap(band=' + band + ' resizeable=1  moveable=1 filename="' + text1 + '" x="' + pos_x + '"   y="' + pos_y + '"' + 'height="' + pos_height + '" width="' + pos_width + '"   border="0"  name=' + obj + ' visible="1" )\t';
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                } else if (obj_typ == "text") {
                    curModifyTopButtonStr += ' create   text(band=' + band + '  alignment="0"   text="' + text1 + '"    moveable=1 resizeable=1   x="' + pos_x + '"   y="' + pos_y + '"' + ' height="' + pos_height + '" width="' + pos_width + '"     name=' + obj + ' visible="1" color="33554432" background.color="1073741824" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }

                } else if (obj_typ == "compute") {

                    curModifyTopButtonStr += ' create compute(band=' + band + ' alignment="0" expression="' + text1 + '"   moveable=1 resizeable=1    x="' + pos_x + '"   y="' + pos_y + '"' + ' height="' + pos_height + '" width="' + pos_width + '"     name=' + obj + ' visible="1" color="33554432" background.color="1073741824" )\t';
                    if (color1.length > 0) { curModifyTopButtonStr += obj + ".color='" + color1 + "'\t"; }
                    if (dw_border.length > 0) { curModifyTopButtonStr += obj + ".border='" + dw_border + "'\t"; }
                    if (font_face.length > 0) { curModifyTopButtonStr += obj + ".font.face='" + font_face + "'\t"; }
                    if (font_height.length > 0) { curModifyTopButtonStr += obj + ".font.height='" + font_height + "'\t"; }
                    if (font_weight.length > 0) { curModifyTopButtonStr += obj + ".font.weight='" + font_weight + "'\t"; }
                    if (font_italic.length > 0 && font_italic != "?") { curModifyTopButtonStr += obj + ".font.italic='" + font_italic + "'\t"; }
                    if (font_underline.length > 0 && font_underline != "?") { curModifyTopButtonStr += obj + ".font.underline='" + font_underline + "'\t"; }
                    if (alignment1.length > 0) { curModifyTopButtonStr += obj + ".alignment='" + alignment1 + "'\t"; }
                    if (format1.length > 0) { curModifyTopButtonStr += obj + ".format='" + format1 + "'\t"; }

                }
            }
            dw_print.Modify(curModifyTopButtonStr.toString());
        } // for end


        //#endregion 表头表尾取值      

        //#endregion 2-end

        //#region 方向
        dw_print.Modify("DataWindow.Print.Orientation='" + curHengXiangOrShuXiang + "'");
        //#endregion

        //#region 纸张
        var pap = -1;
        if (curZhiZhang == 1) {
            pap = 12;
        } else if (curZhiZhang == 2) {
            pap = 13;
        } else if (curZhiZhang == 3) {
            pap = 9;
        } else if (curZhiZhang == 4) {
            pap = 11;
        } else if (curZhiZhang == 5) {
            pap = 8;
        } else if (curZhiZhang == 6) {
            pap = 3;
        } else if (curZhiZhang == 7) {
            pap = 0;
        }

        dw_print.Modify("DataWindow.Print.Paper.Size='" + pap + "'");
        //#endregion

        //#region 纸张大小
        var pSize = "100%";
        if (curZhiZhangDaXiao == 1) {
            pSize = "25%";
        } else if (curZhiZhangDaXiao == 2) {
            pSize = "50%";
        } else if (curZhiZhangDaXiao == 3) {
            pSize = "75%";
        } else if (curZhiZhangDaXiao == 4) {
            pSize = "100%";
        } else if (curZhiZhangDaXiao == 5) {
            pSize = "125%";
        } else if (curZhiZhangDaXiao == 6) {
            pSize = "150%";
        } else if (curZhiZhangDaXiao == 7) {
            pSize = "200%";
        }

        dw_print.Modify("DataWindow.Print.Preview.Zoom='" + pSize + "'");
        //#endregion
        //        //处理数量金额
        //        if (curSlje > 0) {
        //            var totalSl = dw_mx.GetItemNumber(1, "sumzjsl");
        //            var totalJe = dw_mx.GetItemNumber(1, "sumjsje");
        //            var strA = "总数量:" + totalSl + ",总金额:" + totalJe;
        //            dw_print.Modify("my_slje.Text='" + strA + "'");
        //        }
        //        //处理人民币大写
        //        if (curSlje > 0) {
        //            var totalJe = dw_mx.GetItemNumber(1, "sumzjsl");
        //            var totalJsStr = totalJe.toString();
        //            if (totalJsStr.indexOf(".") < 0) {
        //                totalJsStr = totalJsStr + ".00";
        //            }
        //            var strB = GetNumConvertCurrency(totalJsStr);
        //            dw_print.Modify("my_rmb.Text='" + strB + "'");
        //        }
        dw_print.PrintPreview();

    }

    this.isMyHave = function (str1, str2) {
        var re = "-1";
        if (str1.length > 0 && str2.length > 0) {
            var str1s = str1.split("@");
            for (var i = 0; i < str1s.length; i++) {
                if (str1s[i].split("#")[0] == str2) {
                    return str1s[i].split("#")[1];
                    break;
                }
            }
        }
        return re;
    }
    // 排序和宽度。。
    this.DoSort = function (curSortStrs, isReturnStrBool) {
        if (curSortStrs == null || curSortStrs.length < 1) {
            return;
        }
        var curSortStringArr = curSortStrs.split(",");
        var curModifyStr = "";
        for (var i = 0; i < curSortStringArr.length; i++) {
            curModifyStr += curSortStringArr[i].split("#")[0] + ".x='" + curSortStringArr[i].split("#")[1] + "' ";
            curModifyStr += curSortStringArr[i].split("#")[0] + ".width='" + curSortStringArr[i].split("#")[2] + "' ";
        }
        if (isReturnStrBool) {
            return curModifyStr.toString();
        } else {
            dw_print.Modify(curModifyStr.toString());
        }

    }
    this.isHave = function (str1, str2) {
        var re = false;
        if (str1.length > 0 && str2.length > 0) {
            var str1s = str1.split(",");
            for (var i = 0; i < str1s.length; i++) {
                if (str1s[i] == str2) {
                    return true;
                    break;
                }
            }
        }
        return re;
    }
    this.getMyNewStr = function (allColArr, noVisibleColStr) {   //  所有列，不显示的列，返回：要显示的所有列

        var curShowcolArrs = "";
        for (var i = 0; i < allColArr.length; i++) {
            if (!self.isHave(noVisibleColStr, allColArr[i].split("#")[0])) {  // 要显示           
                if (curShowcolArrs.length > 0) {
                    curShowcolArrs += "@" + allColArr[i];
                } else {
                    curShowcolArrs += allColArr[i];
                }
            }
        }
        return curShowcolArrs;
    }


    //#endregion 

    this.SelectionChanged = function () {
        var djzt = ddlb_1.GetText();
        if (djzt == "未记账") {
            djzt = "%0%";
        } else if (djzt == "已记账") {
            djzt = "%1%";
        } else if (djzt == "全部") {
            djzt = "%";
        } else {
            djzt = "%" + djzt + "%";
        }
        dw_hz.Retrieve(curYhbh, djzt);
    }

    //#region 检查记账标志
    this.CheckJzbz = function () {
        var curTName = "";
        var curpzh = "";
        curpzh = dw_hz.GetItemString(dw_hz.GetRow(), "pzh");
        curTName = "cw_xjsrpz";

        webReqTimestamp.Invoke("YW_GTE_PZH", "curTName=" + curTName + "&curPzh=" + curpzh);
        if (webReqTimestamp.StatusCode() == 200) {
            var curjzbz = webReqTimestamp.ResponseText();
            if (curjzbz == "1") {
                requestor.MessageBox("提示", "该记录已经记账！不能修改！！", ICON.StopSign);
                //#region 刷新汇总表
                dw_hz.SetRedraw(false);
                dw_hz.SetProcessing(true);

                //刷新
                self.SelectionChanged();
                //找到相应的记录
                var findRow = dw_hz.Find("pzh='" + curpzh + "' ", 1, dw_hz.RowCount());
                if (findRow > 0) {
                    dw_hz.ScrollToRow(findRow);
                } else {
                    self.Hz_RowFocusChanged(dw_hz.GetRow());
                }
                dw_hz.SetProcessing(false);
                dw_hz.SetRedraw(true);
                //#endregion 

                dw_mx_top.Modify("ysh_q_t.visible='0' ysh_t.visible='0' ysh_t.Text=''");
                tb_1.SetEnabled("btn_Save", false);
                tb_1.SetEnabled("btn_Audit", false);
                tb_1.SetEnabled("btn_UnAudit", false);
                tb_1.SetEnabled("btn_Tally", false);
                tb_1.SetEnabled("btn_Delete", false);
                tb_1.SetEnabled("btn_Edit", false);
                return true;
            } else {
                return false;
            }
        } else {
            requestor.MessageBox("获取记账标志失败", webReqTimestamp.ResponseText(), ICON.StopSign);
            return true;
        }

    }
    //#endregion


    this.Copy = function () {

        var curPzh = dw_mx_top.GetItemString(dw_mx_top.GetRow(), "pzh");
        requestor.ClipBoardNao(curPzh);
        requestor.MessageBox("提示", "凭证号【" + curPzh + "】已复制到剪贴板", ICON.None);
    }


    //#region 复制备注信息

    this.CopyBzxx = function () {

        var curBzxx = dw_mx_top.GetItemString(dw_mx_top.GetRow(), "bzxx");
        requestor.ClipBoard(curBzxx);
        requestor.MessageBox("提示", "备注信息【" + curBzxx + "】已复制到剪贴板", ICON.None);
    }
    //#endregion
  }