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

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

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

        if (requestor == null) requestor = new PBWindow();
        requestor.Attach(win);
        if (sle_pzh == null) sle_pzh = new SingleLineEdit(requestor);
        sle_pzh.Attach(win.Control("sle_pzh"));
        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.DoubleClicked) == "function")
            win.AttachEvent("dw_list", "DoubleClicked", self.DoubleClicked);

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

        if (typeof (self.Export) == "function")
            win.AttachEvent("btn_2", "Clicked", self.Export);

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

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

        setTimeout(CollectGarbage, 100);
    }

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

    this.Query = function () {
        dw_list.SetFilter(" 1=1 ");
        dw_list.Filter(); 
        var curPzh = sle_pzh.GetText();
        var curFilter = " ";
        if (curPzh.length > 0) {
            curFilter = " 1=1 and jyh='" + curPzh + "' ";
        }

        dw_list.SetFilter(curFilter);
        dw_list.Filter();
    }
    var curW_YW_LIST = null;
    this.DoubleClicked = function (x, y, row, dwcName) {
        if (dwcName.indexOf("_t") > -1) {
            var curColName = dwcName.split("_")[0];
            if (curColName == lastSortName) {
                dw_list.SetSort(curColName + " A");
                lastSortName = "";
                dw_list.Sort();
            } else {
                dw_list.SetSort(curColName + " D");
                lastSortName = dwcName.split("_")[0];
                dw_list.Sort();
            }
        } else {

            //判断是否存在数据行


            var curPzh = "";
            var curDjlx = "零售业务-现金";
            var curRow = dw_list.GetRow();
            if (curRow <= 0) {
                return;
            }
            if (curRow > 0) {
                curPzh = dw_list.GetItemString(curRow, "jyh");
            }
            var varQZ = curPzh.substring(0, 2);

            curW_YW_LIST = new W_YW_LIST();
    
            requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.CaiWu.JinHuoFuKuanDan.W_YW_LIST&curpzh=" + curPzh + "&curywlx=" + curDjlx), curW_YW_LIST, null);


        }
    }
    this.Export = function () {
        dw_list.Export();
    }
    this.Exit = function () { 
        requestor.Close();
    }
}