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

	 var self=this;
	 var requestor= new PBWindow();
	 var tab_1= new TabControl( requestor );
	 var dw_1= new DataWindow( requestor );
	 var cb_add= new CommandButton( 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(tab_1 == null ) tab_1= new TabControl( requestor );
		 tab_1.Attach( win.Control( "tab_1") ); 
		 if(dw_1 == null ) dw_1= new DataWindow( requestor );
		 dw_1.Attach( win.Control( "dw_1") ); 
		 if(cb_add == null ) cb_add= new CommandButton( requestor );
		 cb_add.Attach( win.Control( "cb_add") ); 

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

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

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

		 if(typeof(self.Exit)=="function") 
			 win.AttachEvent("cb_quit","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(); 

		 tab_1.Detach(); tab_1=null; 
		 dw_1.Detach(); dw_1=null; 
		 cb_add.Detach(); cb_add=null; 
		 requestor.Detach(); requestor=null; 

		 setTimeout(CollectGarbage, 100); 
	 }

	 //以上代码由设计器自动生成,请不要手工修改
	 //ExtPB.Net JavaScript End  设计器查找标志,请不要删除或修改
    var dw_list = null;
    var curEditDw = null;
    var tv_1 = null;
    var curParentSelf = null;
    this.SetParentWindow = function (pTv, dw) {
        dw_list = dw;
        tv_1 = pTv;
    }
    this.Save = function () {

    }
    this.Exit = function () {
        requestor.Close();
    }
    this.Add = function () {
   
    }
    this.refList = function () {
        if (dw_list != null) {
            var row = dw_1.GetRow();
            if (dw_1.GetItemStatus(row, 0, DWBUFFER.Primary) == DWITEMSTATUS.NewModified) {
                dw_1.CopyDataEx(dw_1.GetRow(), dw_list, 0);
            }
            else {
                dw_1.CopyDataEx(dw_1.GetRow(), dw_list, dw_list.GetRow());
            }
        }
    }
    this.PadLeft = function (str, v_length) {
        var tempstr = "";
        if (str.length >= v_length)
            return str;
        else {
            for (i = 0; i < v_length; i++) {
                tempstr += "0"
            }
            return tempstr + str
        }

    }
}