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

	 var self=this;
	 var requestor= new PBWindow();
	 var dw_1= new DataWindow( requestor );
	 var tb_1= new ToolStrip( requestor );

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

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

		 if(typeof(self.Ok)=="function") 
			 win.AttachEvent("btn_Ok","Clicked",self.Ok); 

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

	 }

	 if(typeof(this.unbind)=="function") var baseUnBind=this.unbind; 
	 this.unbind=function() {
	 if(typeof(this.Release)=="function") this.Release(); 
	 if(typeof(baseUnBind)=="function") baseUnBind(); 

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

		 setTimeout(CollectGarbage, 100); 
	 }

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

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

    this.Ok = function () {

        if (dw_1.AcceptText() != 1)
            return false;

        //数据没有修改
        if ((dw_1.ModifiedCount()) <= 0) {
            alert("没有数据修改");
            return false;
        }


        //执行保存的WebService
        var success = false;
        var curDwObject = dw_1.GetDataObject();
        var curDwChange = dw_1.GetChanges();

        webReq.Invoke("Ywdjlsh_Save", "dataObject=" + curDwObject + "&dwChanges=" + curDwChange);
        if (webReq.StatusCode() == 200) {
            dw_1.ResetUpdate();
            alert('数据保存成功');
        }
        else {
            requestor.MessageBox("提示", "数据保存失败!详细信息为：\r\n" + webReq.ResponseText(), ICON.StopSign);
        }
        dw_1.SetColumn("zdlsh");
        dw_1.SetFocus();
        return success;

    }

    this.Exit = function () {
        if (self.CloseQuery() == 1)
            return;
        setTimeout("window.close();", 100);
    }

    this.CloseQuery = function () {
        if (requestor.MessageBox("提示", "是否退出?", ICON.Question, BUTTON.YesNo) == 2)
            return 1;
    }
}