///<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" />
///<reference  path="/Base/W_OPEN_EDIT.win.js" /> 

//注意,需要在对象定义后面，手工增加以下代码实现对象继承
// W_CuXiaoFangAnSheZhi_Edit.prototype = new W_OPEN_EDIT( ); 

function W_CuXiaoFangAnSheZhi_Edit() {

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var cb_Save = new CommandButton(requestor);
    var dw_edit = new DataWindow(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 (cb_Save == null) cb_Save = new CommandButton(requestor);
        cb_Save.Attach(win.Control("cb_Save"));
        if (dw_edit == null) dw_edit = new DataWindow(requestor);
        dw_edit.Attach(win.Control("dw_edit"));

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

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

    }

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

        cb_Save.Detach(); cb_Save = null;
        dw_edit.Detach(); dw_edit = null;
        requestor.Detach(); requestor = null;

        setTimeout(CollectGarbage, 100);
    }

    //以上代码由设计器自动生成,请不要手工修改
    //ExtPB.Net JavaScript End  设计器查找标志,请不要删除或修改
    var webReq = new WebRequestor();
    webReq.SetWebServiceUrl("/Service/ServiceCuXiaoFangAn.ashx");
    this.Save = function () {
        opflag = requestor.GetEditMode();
        if (!dw_edit.CheckData("*", ""))
            return;
        var changes = dw_edit.GetChanges();
        if (changes == "") {
            return;
        }
        webReq.Invoke("W_CuXiaoFangAnSheZhi_Edit_Save", "dwObject=dw_cxfa_fasz_edit&dwChanges=" + changes);
        if (webReq.StatusCode() == 200) {
            //更新list数据
            self.refListEx();
            requestor.MessageBox("提示", "数据保存成功!", ICON.Information);
            return;
        }
        else {
            requestor.MessageBox("提示", webReq.ResponseText(), ICON.StopSign);
        }
    }
}
W_CuXiaoFangAnSheZhi_Edit.prototype = new W_OPEN_EDIT(); 