コード例 #1
0
        /// <summary>
        /// Save Form Data
        /// </summary>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Address anyAddress = LoadClassData();
                anyAddress.InsertDB();

                int addressID = anyAddress.AddressID;

                if (ThisCustomer.PrimaryBillingAddressID == 0)
                {
                    DB.ExecuteSQL("Update Customer set BillingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                }
                if (ThisCustomer.PrimaryShippingAddressID == 0)
                {
                    DB.ExecuteSQL("Update Customer set ShippingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                    ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, addressID);
                }
                Response.Redirect(hfPreviousURL.Value, false);
                Context.ApplicationInstance.CompleteRequest();
            }
            catch (Exception ex)
            {
                SysLog.LogMessage(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " :: " + System.Reflection.MethodBase.GetCurrentMethod().Name,
                                  ex.Message + ((ex.InnerException != null && string.IsNullOrEmpty(ex.InnerException.Message)) ? " :: " + ex.InnerException.Message : ""),
                                  MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);
            }
        }
コード例 #2
0
        void AddressList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "edit":
                Response.Redirect(String.Format("editaddress.aspx?Checkout={0}&AddressType={1}&AddressID={2}&ReturnURL={3}", Checkout.ToString(), AddressType, e.CommandArgument, ReturnURL));
                break;

            case "delete":
                DB.ExecuteSQL("exec aspdnsf_DeleteAddress " + e.CommandArgument + ", " + ThisCustomer.CustomerID.ToString());
                InitializePageContent();
                break;

            case "makeprimary":
                int AddressID = System.Int32.Parse(e.CommandArgument.ToString());
                DB.ExecuteSQL("update customer set " + CommonLogic.IIF(AddressType == AddressTypes.Billing || AddressType == AddressTypes.Unknown, "BillingAddressID=", "ShippingAddressID=") + AddressID.ToString() + " where customerid = " + ThisCustomer.CustomerID.ToString());
                // make sure cart is now updated to use this shipping address id, but not if multi-ship is enabled
                if (AddressType == AddressTypes.Shipping)
                {
                    ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, AddressID);
                }
                InitializePageContent();
                break;
            }
        }
コード例 #3
0
        void btnNewAddress_Click(object sender, EventArgs e)
        {
            lblErrMsg.Text = "";
            AddressTypes AddressType = (AddressTypes)Enum.Parse(typeof(AddressTypes), AddressTypeString, true);
            int          OriginalRecurringOrderNumber   = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber");
            bool         AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") && !AppLogic.AppConfigBool("SkipShippingOnCheckout");

            if (!AllowShipToDifferentThanBillTo)
            {
                //Shipping and Billing address nust be the same so save both
                AddressType = AddressTypes.Billing | AddressTypes.Shipping;
            }

            if (CommonLogic.FormCanBeDangerousContent("AddressFirstName") == "")
            {
                lblErrMsg.Text += "First Name is required";
            }
            if (CommonLogic.FormCanBeDangerousContent("AddressLastName") == "")
            {
                lblErrMsg.Text += "Last Name is required";
            }
            if (CommonLogic.FormCanBeDangerousContent("AddressPhone") == "")
            {
                lblErrMsg.Text += "Phone is required";
            }
            if (CommonLogic.FormCanBeDangerousContent("AddressAddress1") == "")
            {
                lblErrMsg.Text += "Address1 is required";
            }
            if (CommonLogic.FormCanBeDangerousContent("AddressCity") == "")
            {
                lblErrMsg.Text += "City is required";
            }
            if (CommonLogic.FormCanBeDangerousContent("AddressState") == "")
            {
                lblErrMsg.Text += "State is required";
            }
            if (CommonLogic.FormCanBeDangerousContent("AddressZip") == "")
            {
                lblErrMsg.Text += "ZIP is required";
            }
            if (ValidateAddress(CommonLogic.FormCanBeDangerousContent("AddressAddress1")))
            {
                lblErrMsg.Text += AppLogic.GetString("createaccount_process.aspx.3", SkinID, ThisCustomer.LocaleSetting) + "";
            }

            Address thisAddress = new Address();

            thisAddress.CustomerID    = ThisCustomer.CustomerID;
            thisAddress.NickName      = CommonLogic.FormCanBeDangerousContent("AddressNickName");
            thisAddress.FirstName     = CommonLogic.FormCanBeDangerousContent("AddressFirstName");
            thisAddress.LastName      = CommonLogic.FormCanBeDangerousContent("AddressLastName");
            thisAddress.Company       = CommonLogic.FormCanBeDangerousContent("AddressCompany");
            thisAddress.Address1      = CommonLogic.FormCanBeDangerousContent("AddressAddress1");
            thisAddress.Address2      = CommonLogic.FormCanBeDangerousContent("AddressAddress2");
            thisAddress.Suite         = CommonLogic.FormCanBeDangerousContent("AddressSuite");
            thisAddress.City          = CommonLogic.FormCanBeDangerousContent("AddressCity");
            thisAddress.State         = CommonLogic.FormCanBeDangerousContent("AddressState");
            thisAddress.Zip           = CommonLogic.FormCanBeDangerousContent("AddressZip");
            thisAddress.Country       = CommonLogic.FormCanBeDangerousContent("AddressCountry");
            thisAddress.Phone         = CommonLogic.FormCanBeDangerousContent("AddressPhone");
            thisAddress.EMail         = ThisCustomer.EMail;
            thisAddress.ResidenceType = (ResidenceTypes)CommonLogic.FormNativeInt("ResidenceType");

            if (lblErrMsg.Text == "")
            {
                thisAddress.InsertDB();
                int AddressID = thisAddress.AddressID;

                if (ThisCustomer.PrimaryBillingAddressID == 0)
                {
                    DB.ExecuteSQL("Update Customer set BillingAddressID=" + AddressID.ToString() + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                }
                if (ThisCustomer.PrimaryShippingAddressID == 0)
                {
                    DB.ExecuteSQL("Update Customer set ShippingAddressID=" + AddressID.ToString() + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                    ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, AddressID);
                }

                if (OriginalRecurringOrderNumber != 0)
                {
                    //put it in the ShoppingCart record
                    string sql = String.Empty;
                    if ((AddressType & AddressTypes.Billing) != 0)
                    {
                        sql = String.Format("BillingAddressID={0}", AddressID);
                    }
                    if ((AddressType & AddressTypes.Shipping) != 0)
                    {
                        if (sql.Length != 0)
                        {
                            sql += ",";
                        }
                        sql += String.Format("ShippingAddressID={0}", AddressID);
                    }
                    sql = String.Format("update ShoppingCart set " + sql + " where OriginalRecurringOrderNumber={0}", OriginalRecurringOrderNumber.ToString());
                    DB.ExecuteSQL(sql);
                }

                if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
                {
                    Address StandardizedAddress = new Address();
                    String  VerifyResult        = AddressValidation.RunValidate(thisAddress, out StandardizedAddress);
                    VerifyAddressPrompt = (VerifyResult != AppLogic.ro_OK);
                    if (VerifyAddressPrompt)
                    {
                        thisAddress = StandardizedAddress;
                        thisAddress.UpdateDB();
                        Response.Redirect(String.Format("editaddress.aspx?Checkout={0}&AddressType={1}&ReturnURL={2}&AddressID={3}&Prompt={4}", Checkout.ToString(), AddressTypeString, Server.UrlEncode(ReturnURL), thisAddress.AddressID, VerifyResult));
                    }
                    else
                    {
                        Response.Redirect(String.Format("selectaddress.aspx?Checkout={0}&AddressType={1}&ReturnURL={2}", Checkout.ToString(), AddressTypeString, Server.UrlEncode(ReturnURL)));
                    }
                }
                else
                {
                    Response.Redirect(String.Format("selectaddress.aspx?Checkout={0}&AddressType={1}&ReturnURL={2}", Checkout.ToString(), AddressTypeString, Server.UrlEncode(ReturnURL)));
                }
            }
            else
            {
                // Redisplay the info they gave us so they don't have to re-enter it.
                litNewAddressForm.Text = thisAddress.InputHTML();
            }
        }
コード例 #4
0
        protected void btnNewAddress_Click(object sender, EventArgs e)
        {
            AddressControl ctrlNewAddress = pnlContent.FindControl("ctrlNewAddress") as AddressControl;

            if (ctrlNewAddress != null)
            {
                ctrlNewAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlNewAddress.Country);
            }

            Page.Validate("AddAddress");

            if (Page.IsValid)
            {
                AddressTypes addressType = AddressMode;
                bool         AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") &&
                                                              !AppLogic.AppConfigBool("SkipShippingOnCheckout");

                if (!AllowShipToDifferentThanBillTo)
                {
                    //Shipping and Billing address must be the same so save both
                    addressType = AddressTypes.Billing | AddressTypes.Shipping;
                }

                AspDotNetStorefrontCore.Address anyAddress = new AspDotNetStorefrontCore.Address();

                if (ctrlNewAddress != null)
                {
                    anyAddress.CustomerID    = ThisCustomer.CustomerID;
                    anyAddress.NickName      = ctrlNewAddress.NickName;
                    anyAddress.FirstName     = ctrlNewAddress.FirstName;
                    anyAddress.LastName      = ctrlNewAddress.LastName;
                    anyAddress.Company       = ctrlNewAddress.Company;
                    anyAddress.Address1      = ctrlNewAddress.Address1;
                    anyAddress.Address2      = ctrlNewAddress.Address2;
                    anyAddress.Suite         = ctrlNewAddress.Suite;
                    anyAddress.City          = ctrlNewAddress.City;
                    anyAddress.State         = ctrlNewAddress.State;
                    anyAddress.Zip           = ctrlNewAddress.ZipCode;
                    anyAddress.Country       = ctrlNewAddress.Country;
                    anyAddress.Phone         = ctrlNewAddress.PhoneNumber;
                    anyAddress.ResidenceType = (ResidenceTypes)addressType;

                    anyAddress.InsertDB();

                    int addressID = anyAddress.AddressID;

                    if (ThisCustomer.PrimaryBillingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set BillingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                    }
                    if (ThisCustomer.PrimaryShippingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set ShippingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                        ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, addressID);
                    }

                    if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
                    {
                        AspDotNetStorefrontCore.Address standardizedAddress = new AspDotNetStorefrontCore.Address();
                        String VerifyResult        = AddressValidation.RunValidate(anyAddress, out standardizedAddress);
                        bool   verifyAddressPrompt = (VerifyResult != AppLogic.ro_OK);

                        if (verifyAddressPrompt)
                        {
                            anyAddress = standardizedAddress;
                            anyAddress.UpdateDB();
                        }
                    }

                    String sURL = CommonLogic.ServerVariables("URL") + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING") != "", "?" + CommonLogic.ServerVariables("QUERY_STRING"), "");

                    if (!CommonLogic.IsStringNullOrEmpty(sURL))
                    {
                        Response.Redirect(sURL);
                    }
                }
            }
        }
コード例 #5
0
ファイル: Address.aspx.cs プロジェクト: lulzzz/BrandStore
        protected void btnNewAddress_Click(object sender, EventArgs e)
        {
            AddressControl ctrlNewAddress = pnlContent.FindControl("ctrlNewAddress") as AddressControl;

            if (ctrlNewAddress != null)
            {
                ctrlNewAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlNewAddress.Country);
            }

            Page.Validate("AddAddress");

            if (Page.IsValid)
            {
                AspDotNetStorefrontCore.Address anyAddress = new AspDotNetStorefrontCore.Address();

                if (ctrlNewAddress != null)
                {
                    anyAddress.CustomerID = ThisCustomer.CustomerID;
                    anyAddress.NickName   = ctrlNewAddress.NickName;
                    anyAddress.FirstName  = ctrlNewAddress.FirstName;
                    anyAddress.LastName   = ctrlNewAddress.LastName;
                    anyAddress.Company    = ctrlNewAddress.Company;
                    anyAddress.Address1   = ctrlNewAddress.Address1;
                    anyAddress.Address2   = ctrlNewAddress.Address2;
                    anyAddress.Suite      = ctrlNewAddress.Suite;
                    anyAddress.City       = ctrlNewAddress.City;
                    anyAddress.State      = ctrlNewAddress.State;
                    anyAddress.Zip        = ctrlNewAddress.ZipCode;
                    anyAddress.Country    = ctrlNewAddress.Country;
                    anyAddress.Phone      = ctrlNewAddress.PhoneNumber;
                    //anyAddress.ResidenceType = (ResidenceTypes)addressType;
                    anyAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlNewAddress.ResidenceType, true);

                    anyAddress.InsertDB();

                    int addressID = anyAddress.AddressID;

                    if (ThisCustomer.PrimaryBillingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set BillingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                    }
                    if (ThisCustomer.PrimaryShippingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set ShippingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                        ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, addressID);
                    }
                    if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
                    {
                        AspDotNetStorefrontCore.Address standardizedAddress = new AspDotNetStorefrontCore.Address();
                        String validateResult = AddressValidation.RunValidate(anyAddress, out standardizedAddress);
                        validateResult = "address.validation.errormsg".StringResource() + validateResult;

                        if (validateResult != AppLogic.ro_OK)
                        {
                            Session["ErrorMsgLabelText"] = System.Web.HttpUtility.HtmlEncode(validateResult);
                        }
                        else
                        {
                            anyAddress = standardizedAddress;
                            anyAddress.UpdateDB();
                        }
                    }

                    String sURL = CommonLogic.ServerVariables("URL") + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").Length > 0, "?" + CommonLogic.ServerVariables("QUERY_STRING"), "");
                    if (!CommonLogic.IsStringNullOrEmpty(sURL))
                    {
                        Response.Redirect(sURL);
                    }
                }
            }
        }
コード例 #6
0
        protected void btnNewAddress_Click(object sender, EventArgs e)
        {
            AddressControl ctrlNewAddress = pnlContent.FindControl("ctrlNewAddress") as AddressControl;

            if (ctrlNewAddress != null)
            {
                ctrlNewAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlNewAddress.Country);
            }
            //LovelyEcom Add
            string  VerifyResult0       = string.Empty;
            Address StandardizedAddress = null;

            lbAddressError.Text = "";
            if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
            {
                Address Verifyaddress = new Address();
                Verifyaddress.Address1 = ctrlNewAddress.Address1;
                Verifyaddress.Address2 = ctrlNewAddress.Address2;
                Verifyaddress.City     = ctrlNewAddress.City;
                Verifyaddress.State    = ctrlNewAddress.State;
                Verifyaddress.Zip      = ctrlNewAddress.ZipCode;

                VerifyResult0 = AddressValidation.RunValidate(Verifyaddress, out StandardizedAddress);

                if (VerifyResult0 != AppLogic.ro_OK)
                {
                    lbAddressError.Text += VerifyResult0; //lovely Ecom Added
                    return;
                }
            }
            //LovelyEcom end
            Page.Validate("AddAddress");

            if (Page.IsValid)
            {
                AspDotNetStorefrontCore.Address anyAddress = new AspDotNetStorefrontCore.Address();

                if (ctrlNewAddress != null)
                {
                    anyAddress.CustomerID = ThisCustomer.CustomerID;
                    anyAddress.NickName   = ctrlNewAddress.NickName;
                    anyAddress.FirstName  = ctrlNewAddress.FirstName;
                    anyAddress.LastName   = ctrlNewAddress.LastName;
                    anyAddress.Company    = ctrlNewAddress.Company;
                    anyAddress.Address1   = ctrlNewAddress.Address1;
                    anyAddress.Address2   = ctrlNewAddress.Address2;
                    anyAddress.Suite      = ctrlNewAddress.Suite;
                    anyAddress.City       = ctrlNewAddress.City;
                    anyAddress.State      = ctrlNewAddress.State;
                    anyAddress.Zip        = ctrlNewAddress.ZipCode;
                    anyAddress.Country    = ctrlNewAddress.Country;
                    anyAddress.Phone      = ctrlNewAddress.PhoneNumber;
                    //anyAddress.ResidenceType = (ResidenceTypes)addressType;
                    anyAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlNewAddress.ResidenceType, true);

                    anyAddress.InsertDB();

                    int addressID = anyAddress.AddressID;

                    if (ThisCustomer.PrimaryBillingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set BillingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                    }
                    if (ThisCustomer.PrimaryShippingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set ShippingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                        ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, addressID);
                    }

                    if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
                    {
                        AspDotNetStorefrontCore.Address standardizedAddress = new AspDotNetStorefrontCore.Address();
                        String VerifyResult        = AddressValidation.RunValidate(anyAddress, out standardizedAddress);
                        bool   verifyAddressPrompt = (VerifyResult != AppLogic.ro_OK);

                        if (verifyAddressPrompt)
                        {
                            anyAddress = standardizedAddress;
                            anyAddress.UpdateDB();
                        }
                    }

                    String sURL = CommonLogic.ServerVariables("URL") + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING") != "", "?" + CommonLogic.ServerVariables("QUERY_STRING"), "");

                    if (!CommonLogic.IsStringNullOrEmpty(sURL))
                    {
                        Response.Redirect(sURL);
                    }
                }
            }
        }