Ejemplo n.º 1
0
    /// <summary>
    /// Function to load the customer details
    /// </summary>
    public void WorkCustomerNumber(object sender, EventArgs e)
    {
        try
        {
            ClearPageMessages();
            string strCustNo = CustNoTextBox.Text;
            int    strCnt    = 0;
            //if ((strCustNo != "") && (strCustNo.Contains("%") == true))
            //{
            //    //strCustNo.Replace("'", "''");
            //    if (isNumeric(strCustNo.Remove(strCustNo.Length - 1, 1), System.Globalization.NumberStyles.Integer) == false)
            //        strCnt = Convert.ToInt32(cntCustName(strCustNo));
            //    else
            //        strCnt = Convert.ToInt32(cntCustNo(strCustNo));
            //    int maxRowCount = custDet.GetSQLWarningRowCount();


            //    if (strCnt < maxRowCount)
            //        ScriptManager.RegisterClientScriptBlock(CustNoTextBox, CustNoTextBox.GetType(), "Customer", "LoadCustomerLookup('" + Server.UrlEncode(PFC.SOE.Securitylayer.Cryptor.Encrypt(strCustNo)) + "');", true);
            //    else
            //        ScriptManager.RegisterClientScriptBlock(CustNoTextBox, CustNoTextBox.GetType(), "Customer", "alert('Maximum row exceeds for this search.please enter additional data.');", true);
            //}
            bool textIsNumeric = true;
            try
            {
                int.Parse(strCustNo);
            }
            catch
            {
                textIsNumeric = false;
            }

            if ((strCustNo != "") && !textIsNumeric)
            {
                ScriptManager.RegisterClientScriptBlock(CustNoTextBox, CustNoTextBox.GetType(), "Customer", "LoadCustomerLookup('" + Server.UrlEncode(PFC.SOE.Securitylayer.Cryptor.Encrypt(strCustNo)) + "');", true);
            }
            else
            {
                if (strCustNo != "")
                {
                    #region Code to fill the customer details in the controls
                    // Call the webservice to get the customer address detail
                    DataSet dsCustomer = orderEntry.GetCustomerDetails(strCustNo);
                    if (dsCustomer != null && dsCustomer.Tables[0].Rows.Count != 0)
                    {
                        if (dsCustomer.Tables[0].Columns.Contains("ErrorMessage"))
                        {
                            ScriptManager.RegisterClientScriptBlock(CustNoTextBox, typeof(TextBox), "invalid", "alert('" + dsCustomer.Tables[0].Rows[0]["ErrorMessage"].ToString() + "');", true);
                            ECommQuoteRecallScriptManager.SetFocus("CustNoTextBox");
                            return;
                        }
                        else
                        {
                            string creditStatus = "";
                            if (dsCustomer.Tables[0].Rows[0]["CustCd"].ToString() != "BT" && dsCustomer.Tables[0].Rows[0]["fBillToNo"].ToString() != "")
                            {
                                creditStatus = orderEntry.GetCreditReview(dsCustomer.Tables[0].Rows[0]["fBillToNo"].ToString().ToString(), dsCustomer.Tables[2].Rows[0]["CreditInd"].ToString().Trim(), "0", "Order");
                                if (creditStatus.ToUpper() != "OK")
                                {
                                    ScriptManager.RegisterClientScriptBlock(CustNoTextBox, typeof(TextBox), "invalid", "alert('" + creditStatus + "');", true);
                                    ECommQuoteRecallScriptManager.SetFocus("CustNoTextBox");
                                    return;
                                }
                            }
                            else
                            {
                                //ISBillToCustomer = true;
                                ScriptManager.RegisterClientScriptBlock(CustNoTextBox, typeof(TextBox), "invalid", "alert('Bill To Only Customer could not process order');document.getElementById('" + CustNoTextBox.ClientID + "').value='';document.getElementById('" + CustNoTextBox.ClientID + "').focus();document.getElementById('" + CustNoTextBox.ClientID + "').select();", true);
                                ECommQuoteRecallScriptManager.SetFocus("CustNoTextBox");
                                return;
                            }
                            Session[HeaderTableName.Value] = null;
                            CustNameLabel.Text             = dsCustomer.Tables[2].Rows[0]["Name"].ToString();
                            HeaderUpdatePanel.Update();
                            GetCustQuotes(CustNoTextBox.Text);
                        }
                    }
                    else
                    {
                        //hidCust.Value = "";
                        ScriptManager.RegisterClientScriptBlock(CustNoTextBox, typeof(TextBox), "invalid", "alert('Invalid Customer value (1)');document.getElementById('" + CustNoTextBox.ClientID + "').value='';document.getElementById('" + CustNoTextBox.ClientID + "').focus();document.getElementById('" + CustNoTextBox.ClientID + "').select();", true);
                    }
                    #endregion
                }
                else
                {
                    //ClearLabels();
                }
            }
        }
        catch (Exception e2)
        {
            ShowPageMessage("WorkCustomerNumber Error " + e2.ToString(), 2);
        }
    }
Ejemplo n.º 2
0
    /// <summary>ear
    /// Function to load the customer details
    /// </summary>
    public void LoadCustomerDetails()
    {
        string strCustNo = custNumber = txtCustNo.Text;
        int    strCnt    = 0;

        bool textIsNumeric = true;

        try
        {
            int.Parse(strCustNo);
        }
        catch
        {
            textIsNumeric = false;
        }

        if ((strCustNo != "") && !textIsNumeric)
        {
            ScriptManager.RegisterClientScriptBlock(txtCustNo, txtCustNo.GetType(), "Customer", "LoadCustomerLookup('" + Server.UrlEncode(PFC.SOE.Securitylayer.Cryptor.Encrypt(strCustNo)) + "');", true);
        }
        else
        {
            if (strCustNo != "")
            {
                #region Code to fill the customer details in the controls

                // Call the webservice to get the customer address detail
                DataSet dsCustomer = orderEntry.GetCustomerDetails(txtCustNo.Text.Trim().Replace("'", ""));

                // Function to clear the value in the label
                ClearLabels();

                if (dsCustomer != null && dsCustomer.Tables[0].Rows.Count != 0)
                {
                    string creditStatus = "";
                    if (dsCustomer.Tables[0].Rows[0]["CustCd"].ToString() != "BT" && dsCustomer.Tables[0].Rows[0]["fBillToNo"].ToString() != "")
                    {
                        creditStatus = orderEntry.GetCreditReview(dsCustomer.Tables[0].Rows[0]["fBillToNo"].ToString().ToString(), dsCustomer.Tables[2].Rows[0]["CreditInd"].ToString().Trim(), "0", "Order");
                        if (creditStatus.ToUpper() == "OK")
                        {
                            hidCust.Value             = txtCustNo.Text;
                            Session["CustomerNumber"] = hidCust.Value.Trim();
                            Session["CustomerDetail"] = dsCustomer;
                            CustPriceCode             = dsCustomer.Tables[0].Rows[0]["Customer Price Code"].ToString().Trim();
                            CustomerName = dsCustomer.Tables[0].Rows[0]["Name"].ToString().Trim();
                            FillCustomerAddress(dsCustomer);
                            lblCusNum.Text     = hidCust.Value.Trim();
                            lblCustNum.Text    = hidCust.Value.Trim();
                            lblChainValue.Text = dsCustomer.Tables[0].Rows[0]["Chain Name"].ToString().Trim();
                            lblBillCustNo.Text = dsCustomer.Tables[0].Rows[0]["fBillToNo"].ToString().Trim();
                            lblShip_Name.Text  = dsCustomer.Tables[3].Rows[0]["Name"].ToString().Trim();
                            lblSold_Name.Text  = dsCustomer.Tables[0].Rows[0]["Name"].ToString().Trim();
                            lblSoDate.Text     = DateTime.Now.ToShortDateString();
                            // Code to bind the location details
                            DataSet dsLocation = custDet.GetLocationDetails();
                            CreditInd = dsCustomer.Tables[2].Rows[0]["CreditInd"].ToString().Trim();
                            InsertHeaderDetail();
                            lblTermDesc.Text = termDesc;
                            string script = "var popUp=window.open (\"CASReport.aspx?CustNo=" + Session["CustomerNumber"].ToString() + "\",\"Maximize\",'height=505,width=705,scrollbars=no,status=no,top='+((screen.height/2) - (460/2))+',left='+((screen.width/2) - (705/2))+',resizable=NO','');" +
                                            "popUp.focus();";
                            lblTermDesc.Attributes.Add("onclick", script);
                            SetTermColor();
                            ISBillToCustomer = false;
                            // txtSONumber.ReadOnly = true;
                            txtCustNo.ReadOnly = true;
                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(txtCustNo, typeof(TextBox), "invalid", "alert('" + creditStatus + "');", true);
                            return;
                        }
                    }
                    else
                    {
                        ISBillToCustomer = true;
                        ScriptManager.RegisterClientScriptBlock(txtCustNo, typeof(TextBox), "invalid", "alert('Bill To Only Customer could not process order');document.getElementById('" + txtCustNo.ClientID + "').value='';document.getElementById('" + txtCustNo.ClientID + "').focus();document.getElementById('" + txtCustNo.ClientID + "').select();", true);
                    }
                }
                else
                {
                    hidCust.Value = "";
                    ScriptManager.RegisterClientScriptBlock(txtCustNo, typeof(TextBox), "invalid", "alert('Invalid Customer value');document.getElementById('" + txtCustNo.ClientID + "').value='';document.getElementById('" + txtCustNo.ClientID + "').focus();document.getElementById('" + txtCustNo.ClientID + "').select();", true);
                }
                #endregion
            }
            else
            {
                ClearLabels();
            }
        }
    }