protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ComboTLNCardType.ParentNode = TreeListNode.FindByCode(iSabayaContext, "cardtype");
            ComboTLNCardType.DataBind();

            CallbackSearchByCard.ClientInstanceName     = this.ClientID + CallbackSearchByCard.ClientID;
            CallbacklikeCustomerName.ClientInstanceName = this.ClientID + CallbacklikeCustomerName.ClientID;
            cbSelect.ClientInstanceName        = this.ClientID + cbSelect.ClientID;
            cbLostFocus.ClientInstanceName     = this.ClientID + cbLostFocus.ClientID;
            GridCustomer.ClientInstanceName    = this.ClientID + GridCustomer.ClientID;
            txtFirstName.ClientInstanceName    = this.ClientID + txtFirstName.ClientID;
            btnFindName.ClientInstanceName     = this.ClientID + btnFindName.ClientID;
            btnFindCard.ClientInstanceName     = this.ClientID + btnFindCard.ClientID;
            btnFindName.ClientInstanceName     = this.ClientID + btnFindName.ClientID;
            GridCustomer.ClientSideEvents.Init = @"function(s, e) {
                  s.SetFocusedRowIndex(-1);
            }";

            CallbackSearchByCard.ClientSideEvents.CallbackComplete = @"function(s, e) {
                " + GridCustomer.ClientInstanceName + @".SetFocusedRowIndex(-1);
                " + GridCustomer.ClientInstanceName + @".PerformCallback();
            }";

            CallbacklikeCustomerName.ClientSideEvents.CallbackComplete = @"function(s, e) {
                " + GridCustomer.ClientInstanceName + @".SetFocusedRowIndex(-1);
                " + GridCustomer.ClientInstanceName + @".PerformCallback();
            }";

            btnFindCard.ClientSideEvents.Click = @"function(s, e) {
            " + CallbackSearchByCard.ClientInstanceName + @".SendCallback();
            }";

            btnFindName.ClientSideEvents.Click = @"function(s, e) {
            " + CallbacklikeCustomerName.ClientInstanceName + @".SendCallback();
            }";

            //--------------------------------------------------------
            lblMFCustomerName.ClientInstanceName = this.ClientID + lblMFCustomerName.ClientID;
            txtMFCustomerNo.ClientInstanceName   = this.ClientID + txtMFCustomerNo.ClientID;

            popupAccount.ClientInstanceName      = this.ClientID + popupAccount.ClientID;
            cbpTxtMFAccountNo.ClientInstanceName = this.ClientID + cbpTxtMFAccountNo.ClientID;

            String lostFocus = @"function(s,e){
       
            " + cbLostFocus.ClientInstanceName + ".SendCallback(" + txtMFCustomerNo.ClientInstanceName + @".GetValue()); 
            }";
            txtMFCustomerNo.ClientSideEvents.LostFocus = lostFocus;

            String buttonClick = @"function(s,e){ 
                    var win = " + popupAccount.ClientInstanceName + @".GetWindow(0); 
                    " + popupAccount.ClientInstanceName + @".ShowWindow(win);
                    }";

            txtMFCustomerNo.ClientSideEvents.ButtonClick = buttonClick;
            //+ cbpTxtMFAccountNo.ClientInstanceName + @".PerformCallback();
            cbSelect.ClientSideEvents.CallbackComplete = @"function(s,e){
                " + txtMFCustomerNo.ClientInstanceName + @".SetValue(e.result);
                if(typeof(oncompleteLoadCustomer)!='undefined'){                   
                       oncompleteLoadCustomer();
                }
                var value = e.result;
                " + ClientSideEvents.AfterSelectedChanged + @"
            }";

            cbLostFocus.ClientSideEvents.CallbackComplete = @"function(s,e){ 
                if(e.result=='hit'){
                    " + cbpTxtMFAccountNo.ClientInstanceName + @".PerformCallback(); 
                    if(typeof(oncompleteLoadCustomer)!='undefined'){                   
                           oncompleteLoadCustomer();                       
                    }
                    var value = " + txtMFCustomerNo.ClientInstanceName + @".GetText();
                    " + ClientSideEvents.AfterSelectedChanged + @"
                }else{
                    " + txtMFCustomerNo.ClientInstanceName + @".SetValue('');
                    " + lblMFCustomerName.ClientInstanceName + @".SetValue('');
                    var value = '';
                    " + ClientSideEvents.AfterSelectedChanged + @"
                }
            }";

            GridCustomer.ClientSideEvents.CustomButtonClick = @"function(s,e){
                var buttonID = e.buttonID;               
                var visibleIndex = e.visibleIndex;
                  if(buttonID = 'buttonSelect')
                  {                         
                     " + cbSelect.ClientInstanceName + @".SendCallback(visibleIndex);         
                     " + popupAccount.ClientInstanceName + @".Hide();
                  }
            }";
        }
        if (IsRequiredField)
        {
            txtMFCustomerNo.SetValidation(ValidationGroup);
        }

        if (Session[this.ID + this.GetType().ToString() + "GridCustomerVOS"] != null)
        {
            GridCustomer.DataSource = (IList <MFCustomer>)Session[this.ID + this.GetType().ToString() + "GridCustomerVOS"];
            GridCustomer.DataBind();
        }
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            initControl("th", PersistenceLayer.WebSessionManager.PersistenceSession);
            ComboTLNCardType.ParentNode = TreeListNode.FindByCode(iSabayaContext, "cardtype");
            ComboTLNCardType.DataBind();

            ASPxPopupControl1.ClientInstanceName = ASPxPopupControl1.ClientID;

            LabelCustomerName.ClientInstanceName    = LabelCustomerName.ClientID;
            cbpGridAccountOutput.ClientInstanceName = cbpGridAccountOutput.ClientID;

            CallbackSearchByCard.ClientInstanceName = CallbackSearchByCard.ClientID;

            CallbacklikeCustomerName.ClientInstanceName = CallbacklikeCustomerName.ClientID;
            Callback1FromPopup.ClientInstanceName       = Callback1FromPopup.ClientID;
            GridCustomer.ClientInstanceName             = GridCustomer.ClientID;
            TextSearchString.ClientInstanceName         = TextSearchString.ClientID;
            ButtonSearch.ClientInstanceName             = ButtonSearch.ClientID;
            buttonApplyAndClose.ClientInstanceName      = buttonApplyAndClose.ClientID;
            buttonClose.ClientInstanceName = buttonClose.ClientID;
            /*LostFocus*/
            TextCardCode.ClientSideEvents.LostFocus = @"function(s, e) {";

            TextCardCode.ClientSideEvents.LostFocus += CallbackSearchByCard.ClientInstanceName + ".SendCallback(s.GetValue());      }";

            /*Search by card complete*/
            CallbackSearchByCard.ClientSideEvents.CallbackComplete =
                @"function(s, e) {
                    document.getElementById('" + LabelCustomerName.ClientInstanceName + @"').innerHTML=e.result;
            " + cbpGridAccountOutput.ClientInstanceName + @".PerformCallback();
            setTimeout('" + GridName + ".PerformCallback()', 5000); ";
            CallbackSearchByCard.ClientSideEvents.CallbackComplete +=
                @"
                    var params = new Array(1);
                    params['source']='completeSearch';
                    //alert(eventCallback);
                    //if(eventCallback!= undefined){
                    //   eventCallback(params);
                    //}
            }";

            /*Click search from name*/
            String script = "function(s, e) { var likeCustomerName = " + TextSearchString.ClientInstanceName + ".GetValue();";
            script += " " + CallbacklikeCustomerName.ClientInstanceName + ".SendCallback(likeCustomerName);";
            script += "var win = " + ASPxPopupControl1.ClientInstanceName + ".GetWindow(0);";
            script += ASPxPopupControl1.ClientInstanceName + ".ShowWindow(win);";
            script += "}";
            ButtonSearch.ClientSideEvents.Click = script;

            /*show grid name like criteria*/
            CallbacklikeCustomerName.ClientSideEvents.CallbackComplete =
                @"function(s, e) {
            " + cbpGridAccountOutput.ClientInstanceName + @".PerformCallback();
             " + GridCustomer.ClientInstanceName + ".PerformCallback();  " +
                GridCustomer.ClientInstanceName + ".SetFocusedRowIndex(0); }";

            /*grid FocusedRowChanged*/
            GridCustomer.ClientSideEvents.FocusedRowChanged  = @"function(s, e) {
                     if(" + GridCustomer.ClientInstanceName + ".GetFocusedRowIndex()!=-1){";
            GridCustomer.ClientSideEvents.FocusedRowChanged += CallbackTest.ClientInstanceName + ".SendCallback(" + GridCustomer.ClientInstanceName + ".GetFocusedRowIndex());} }";

            /*click select from popup*/
            String scriptString1 = "function(s, e) { ";
            scriptString1 += Callback1FromPopup.ClientInstanceName + ".SendCallback();";
            scriptString1 += cbpGridAccountOutput.ClientInstanceName + ".PerformCallback();";
            scriptString1 += ASPxPopupControl1.ClientInstanceName + ".Hide();";
            scriptString1 += " }";
            buttonApplyAndClose.ClientSideEvents.Click = scriptString1;

            String scriptStringClose = "function(s, e) { ";
            scriptString1 += ASPxPopupControl1.ClientInstanceName + ".Hide();";
            scriptString1 += " }";
            buttonClose.ClientSideEvents.Click = scriptStringClose;

            /*Search by name complete after selected from grid*/
            Callback1FromPopup.ClientSideEvents.CallbackComplete =
                @"function(s, e) {
                    document.getElementById('" + LabelCustomerName.ClientInstanceName + "').innerHTML=e.result; setTimeout('" + GridName + ".PerformCallback()', 5000);  ";
            Callback1FromPopup.ClientSideEvents.CallbackComplete +=
                @"
                    var params = new Array(1);
                    params['source']='completeSearch';
                    if(typeof(eventCallback)!='undefined'){
                       eventCallback(params);
                    }
            }";

            gridAccountOutput.ClientInstanceName                 = gridAccountOutput.ClientID;
            cbSelectedIndexChnage.ClientInstanceName             = cbSelectedIndexChnage.ClientID;
            gridAccountOutput.ClientSideEvents.FocusedRowChanged = @"function(s, e) {
                    /*alert('hi');*/
                    var rowIndex = " + gridAccountOutput.ClientInstanceName + @".GetFocusedRowIndex();
                " + cbSelectedIndexChnage.ClientInstanceName + @".SendCallback(rowIndex);
            }";
        }

        if (Session[this.ID + "cbpGridAccountOutput"] != null)
        {
            IList <MFAccount> accounts = (IList <MFAccount>)Session[this.ID + "cbpGridAccountOutput"];

            gridAccountOutput.DataSource = accounts;

            gridAccountOutput.DataBind();
        }
        if (Session["GridCustomerVOS"] != null)
        {
            GridCustomer.DataSource = (IList <MFCustomer>)Session["GridCustomerVOS"];
            GridCustomer.DataBind();
        }
        if (Session[this.ID + "ctrls_CustomerControl_CurrentParty"] != null)
        {
            partyId = (int)Session[this.ID + "ctrls_CustomerControl_CurrentParty"];
        }
    }