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

	 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.Edit)=="function") 
			 win.AttachEvent("dw_list","DoubleClicked",self.Edit); 

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

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

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

		 if(typeof(self.Exit)=="function") 
			 win.AttachEvent("btn_6","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 curW_Mmxyyjzjf_Edit = new W_Mmxyyjzjf_Edit();
    var webReq = new WebRequestor();
    webReq.SetWebServiceUrl("/Service/HuiyuanJiFenchuli.ashx");
    this.add = function () {
        curW_Mmxyyjzjf_Edit.SetDataWindow(dw_list, "")
        requestor.Open("/Service/LoadWindow.ashx?WinName=A8ERP.CuXiao.Mmxyyjzjf.W_Mmxyyjzjf_Edit&opFlag=ADD", curW_Mmxyyjzjf_Edit, null);
    }
    this.Edit = function () {
        if (dw_list.RowCount() < 1) {
            return;
        }
        curW_Mmxyyjzjf_Edit.SetDataWindow(dw_list, dw_list.GetItemString(dw_list.GetRow(), "pzh"))
        requestor.Open("/Service/LoadWindow.ashx?WinName=A8ERP.CuXiao.Mmxyyjzjf.W_Mmxyyjzjf_Edit&opFlag=EDIT", curW_Mmxyyjzjf_Edit, null);
    }
    this.Exit = function () {
        setTimeout("window.close()", 100);
    }
    this.Delete = function () {
        if (requestor.MessageBox("提示", "是否确定删除该方案?", ICON.Question, BUTTON.YesNo) == 2)
            return;
        webReq.Invoke("W_HY_MMXYYXFZY__Edit_Delete", "curPZH=" + dw_list.GetItemString(dw_list.GetRow(), "pzh"));
        if (webReq.StatusCode() == 200) {
            var curPzh = webReq.ResponseText();
            requestor.MessageBox("提示", "数据删除成功!", ICON.Information);
            dw_list.Refresh();
            return;
        }
        else {
            requestor.MessageBox("提示", webReq.ResponseText(), ICON.StopSign);
        }
    }
}