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

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var dw_list = new DataWindow(requestor);
    var tb_1 = new ToolStrip(requestor);

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

        if (requestor == null) requestor = new PBWindow();
        requestor.Attach(win);
        if (dw_list == null) dw_list = new DataWindow(requestor);
        dw_list.Attach(win.Control("dw_list"));
        if (tb_1 == null) tb_1 = new ToolStrip(requestor);
        tb_1.Attach(win.Control("tb_1"));

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

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

    }

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

        dw_list.Detach(); dw_list = null;
        tb_1.Detach(); tb_1 = null;
        requestor.Detach(); requestor = null;

        setTimeout(CollectGarbage, 100);
    }

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

    var curBmbh = "";
    var curGysbh = "";
    var curSpkh = "";
    var curPSelf = "";
    var curJjQx = "";
    this.SetDataWindow = function (bmbh, gysbh, spkh, pSelf, jjQx) {
        // isFlag=M 设置数据窗口为多选模式
        curBmbh = bmbh;
        curGysbh = gysbh;
        curSpkh = spkh;
        curPSelf = pSelf;
        curJjQx = jjQx;

    }
    this.PostOpen = function () {
        var reportSrv = new ReportSrv();

        var sql = " a.spkh='" + curSpkh + "' and a.bmbh='" + curBmbh + "' and a.gysbh='" + curGysbh + "'";
        dw_list.RetrieveEx(sql);

        if (reportSrv.Instance == null) {
            dw_list.GetReportSrv(reportSrv);
        }
        var cmfw = requestor.GetParm("cmfw");
        var cmz = requestor.GetParm("cmz");
        var cmfwattr = cmfw.split(",");
        var cmzattr = cmz.split("#");
        reportSrv.SetColumnVisible("jj", false);
        reportSrv.SetColumnVisible("zjje", false);
        for (var i = 1; i <= 35; i++) {
            reportSrv.SetColumnVisible("cm" + i, false);
        }

        for (var i = parseInt(cmfwattr[0]); i <= parseInt(cmfwattr[1]); i++) {
            reportSrv.SetColumnVisible("cm" + i, true);
            dw_list.Modify("cm" + i + "_t.text='" + cmzattr[i - 1] + "'");
            dw_list.Modify("cm" + i + ".width='50'");
        }
        if (curJjQx == "1") {
            reportSrv.SetColumnVisible("jj", true);
            reportSrv.SetColumnVisible("zjje", true);
        }
        reportSrv.UpdateRequestor();
        curPSelf.setFhjlDwList(dw_list);
    }
    this.Exit = function () {
        requestor.Close();
    }
    this.Print = function () {
        dw_list.Print();
    }

    this.Export = function () {
        dw_list.Export();
    }
 }