Ejemplo n.º 1
0
        protected void ContBilling(bool fromPayment, bool validate, Explore.NetSuite.DataAccess.NDAL client, ref Customer cust)
        {
            try
            {
                if (!fromPayment)
                {
                    Session["RedrawForm"] = false;
                }

                bool goOn = true;
                if (validate)
                {
                    if (!Page.IsValid)
                    {
                        goOn = false;
                    }
                }

                if (goOn)
                {
                    if (!fromPayment)
                    {
                        Session["FormClicked"] = true;
                    }
                    bool isStateValid = false;
                    if (StateLabel2RadComboBox.Visible)
                    {
                        if (StateLabel2RadComboBox.SelectedValue != "-1")
                            isStateValid = true;
                    }
                    else
                    {
                        if (StateLabel2TextBox.Text.Trim() != "")
                            isStateValid = true;
                    }

                    if (isStateValid)
                    {
                        if (Session["UserID"] != null)
                        {

                            //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                            //  DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            //  "info",
                            //  "---SaveBilling address function GetCustomer() Begin------"));

                            //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                            //  DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            //  "info",
                            //  "---SaveBilling address function GetCustomer() End------"));

                            Address adr = new Address();
                            adr.DefaultBilling = true;
                            adr.DefaultShipping = false;
                            adr.DefaultDelivery = false;
                            adr.Residential = false;
                            adr.DefaultAccount = false;

                            if (!fromPayment)
                            {
                                Session["RedrawForm"] = true;
                                Session["formpage"] = "3";
                            }

                            Session["BillingNameLabel"] = AttentionLabel1TextBox.Text;
                            BillingNameLabel.Text = AttentionLabel1TextBox.Text;

                            Session["BillingCompanyLabel"] = CompanyLabel2TextBox.Text;
                            BillingCompanyLabel.Text = CompanyLabel2TextBox.Text;
                            adr.CompanyName = CompanyLabel2TextBox.Text;

                            string state = "";
                            if (StateLabel2RadComboBox.Visible)
                                state = StateLabel2RadComboBox.SelectedItem.Text;
                            else
                                state = StateLabel2TextBox.Text;

                            Session["BillingStateLabel"] = state;
                            BillingStateLabel.Text = CityLabel2TextBox.Text + ", " + state + " " + ZipLabel2TextBox.Text;
                            adr.State = state;

                            Session["BillingCityLabel"] = CityLabel2TextBox.Text;
                            adr.City = CityLabel2TextBox.Text;

                            Session["BillingPhoneLabel"] = PhoneLabel2TextBox.Text;
                            Session["BillingEx"] = ex2TextBox.Text;
                            BillingPhoneLabel.Text = PhoneLabel2TextBox.Text;
                            adr.Phone = PhoneLabel2TextBox.Text;
                            if (ex2TextBox.Text.Trim() != "")
                            {
                                BillingPhoneLabel.Text = PhoneLabel2TextBox.Text + " x" + ex2TextBox.Text;
                                adr.Phone = PhoneLabel2TextBox.Text + " x" + ex2TextBox.Text;
                            }

                            Session["BillingAttentionLabel"] = AttentionLabel1TextBox.Text;
                            adr.Attention = AttentionLabel1TextBox.Text;

                            Session["BillingAddressLabel"] = Address1Label2TextBox.Text;
                            adr.Address1 = Address1Label2TextBox.Text;

                            Session["BillingAddress2Label"] = Address2Label2TextBox.Text;
                            adr.Address2 = Address2Label2TextBox.Text;

                            Session["BillingZipLabel"] = ZipLabel2TextBox.Text;
                            adr.Zip = ZipLabel2TextBox.Text;

                            Session["BillingCountryLabel"] = CountryLabel2RadComboBox.SelectedValue;
                            DataSet dsCount = doQuery("SELECT * FROM Countries WHERE country_name = '" +
                            CountryLabel2RadComboBox.SelectedItem.Text + "'");
                            adr.Country = dsCount.Tables[0].Rows[0]["country_2_code"].ToString();

                            object refAdrs = (object)adr;
                            SaveDynamicFields("2", ref refAdrs);
                            adr = (Address)refAdrs;

                            UpdateAddress(adr, ref cust, AddressTypes.Billing);

                            //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                            //  DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            //  "info",
                            //  "---SaveBilling address function UpdateCustomer() Begin------"));
                            //
                            //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                            //  DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            //  "info",
                            //  "---SaveBilling address function UpdateCustomer() End------"));

                            client.UpdateCustomer(cust);

                            SamesAsCheckBox2.Checked = false;

                            if (!fromPayment)
                            {
                                FillShipping();
                                if (Session["EditBillingClicked"] != null)
                                    if (bool.Parse(Session["EditBillingClicked"].ToString()))
                                    {

                                        Session["formpage"] = "6";
                                        GoToForm(6, 2);
                                        SetBoxes();
                                        BuildIt(client, cust);
                                    }
                                    else
                                        GoToForm(3, 2);
                                else
                                    GoToForm(3, 2);
                            }
                        }
                        else
                        {
                            ErrorLabel.Text = "user is null";
                        }
                    }
                    else
                    {
                        ErrorLabelBilling.Text = "State is required.";
                    }
                }

            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString();
            }
        }