Exemplo n.º 1
0
 protected void btnAddAddress_Click(object sender, System.EventArgs e)
 {
     if (this.ValShippingAddress())
     {
         if (PersonalHelper.GetShippingAddressCount(HiContext.Current.User.UserId) >= HiContext.Current.Config.ShippingAddressQuantity)
         {
             this.ShowMessage(string.Format("最多只能添加{0}个收货地址", HiContext.Current.Config.ShippingAddressQuantity), false);
             this.Reset();
         }
         else
         {
             ShippingAddressInfo shippingAddressInfo = this.GetShippingAddressInfo();
             if (PersonalHelper.CreateShippingAddress(shippingAddressInfo))
             {
                 this.ShowMessage("成功的添加了一个收货地址", true);
                 this.Reset();
             }
             else
             {
                 this.ShowMessage("地址已经在,请重新输入一次再试", false);
             }
             this.BindList();
         }
     }
 }
Exemplo n.º 2
0
        private bool ValShippingAddress(HttpContext context, ref string erromsg)
        {
            Regex regex = new Regex(@"[\u4e00-\u9fa5a-zA-Z]+[\u4e00-\u9fa5_a-zA-Z0-9]*");

            if (string.IsNullOrEmpty(context.Request.Params["ShippingTo"].Trim()) || !regex.IsMatch(context.Request.Params["ShippingTo"].Trim()))
            {
                erromsg = "收货人名字不能为空,只能是汉字或字母开头,长度在2-20个字符之间";
                return(false);
            }
            if (string.IsNullOrEmpty(context.Request.Params["AddressDetails"].Trim()))
            {
                erromsg = "详细地址不能为空";
                return(false);
            }
            if ((context.Request.Params["AddressDetails"].Trim().Length < 3) || (context.Request.Params["AddressDetails"].Trim().Length > 60))
            {
                erromsg = "详细地址长度在3-60个字符之间";
                return(false);
            }
            if (string.IsNullOrEmpty(context.Request.Params["RegionId"].Trim()) || (Convert.ToInt32(context.Request.Params["RegionId"].Trim()) <= 0))
            {
                erromsg = "请选择收货地址";
                return(false);
            }
            if (string.IsNullOrEmpty(context.Request.Params["TelPhone"].Trim()) && string.IsNullOrEmpty(context.Request.Params["CellHphone"].Trim().Trim()))
            {
                erromsg = "电话号码和手机二者必填其一";
                return(false);
            }
            if (!string.IsNullOrEmpty(context.Request.Params["TelPhone"].Trim()) && ((context.Request.Params["TelPhone"].Trim().Length < 3) || (context.Request.Params["TelPhone"].Trim().Length > 20)))
            {
                erromsg = "电话号码长度限制在3-20个字符之间";
                return(false);
            }
            if (!string.IsNullOrEmpty(context.Request.Params["CellHphone"].Trim()) && ((context.Request.Params["CellHphone"].Trim().Length < 3) || (context.Request.Params["CellHphone"].Trim().Length > 20)))
            {
                erromsg = "手机号码长度限制在3-20个字符之间";
                return(false);
            }
            if (PersonalHelper.GetShippingAddressCount(HiContext.Current.User.UserId) >= HiContext.Current.Config.ShippingAddressQuantity)
            {
                erromsg = string.Format("最多只能添加{0}个收货地址", HiContext.Current.Config.ShippingAddressQuantity);
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        public void btnCreateOrder_Click(object sender, EventArgs e)
        {
            if (ValidateCreateOrder())
            {
                OrderInfo orderInfo = GetOrderInfo(shoppingCart);

                if (shoppingCart.Quantity > 1)
                {
                    isSignBuy = false;
                }

                if (orderInfo == null)
                {
                    ShowMessage("购物车中已经没有任何商品", false);
                }
                else if (!HiContext.Current.User.IsAnonymous && (shoppingCart.GetTotalNeedPoint() > ((Member)HiContext.Current.User).Points))
                {
                    ShowMessage("您当前的积分不够兑换所需积分!", false);
                }
                else if (isCountDown && (ProductBrowser.GetCountDownInfo(shoppingCart.LineItems[productSku].ProductId).EndDate < DateTime.Now))
                {
                    ShowMessage("此订单为抢购订单,但抢购时间已到!", false);
                }
                else
                {
                    try
                    {
                        if (ShoppingProcessor.CreatOrder(orderInfo))
                        {
                            Messenger.OrderCreated(orderInfo, HiContext.Current.User);
                            orderInfo.OnCreated();
                            if (shoppingCart.GetTotalNeedPoint() > 0)
                            {
                                ShoppingProcessor.CutNeedPoint(shoppingCart.GetTotalNeedPoint());
                            }
                            if ((!isCountDown && !isGroupBuy) && !isSignBuy)
                            {
                                ShoppingCartProcessor.ClearShoppingCart();
                            }
                            if (!HiContext.Current.User.IsAnonymous && (PersonalHelper.GetShippingAddressCount(HiContext.Current.User.UserId) == 0))
                            {
                                ShippingAddressInfo shippingAddress = new ShippingAddressInfo();
                                shippingAddress.UserId    = HiContext.Current.User.UserId;
                                shippingAddress.ShipTo    = Globals.HtmlEncode(txtShipTo.Text);
                                shippingAddress.RegionId  = dropRegions.GetSelectedRegionId().Value;
                                shippingAddress.Address   = Globals.HtmlEncode(txtAddress.Text);
                                shippingAddress.Zipcode   = txtZipcode.Text;
                                shippingAddress.CellPhone = txtCellPhone.Text;
                                shippingAddress.TelPhone  = txtTelPhone.Text;
                                PersonalHelper.CreateShippingAddress(shippingAddress);
                            }
                            Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("FinishOrder", new object[] { orderInfo.OrderId }));
                        }
                    }
                    catch (Exception exception)
                    {
                        ShowMessage(exception.ToString(), false);
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int num = 0;
            SortedDictionary <string, string> requestPost = this.GetRequestPost();

            if (requestPost.Count > 0)
            {
                string             openIdType     = "hishop.plugins.openid.alipay.alipayservice";
                OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType);
                if (openIdSettings == null)
                {
                    base.Response.Write("登录失败,没有找到对应的插件配置信息。");
                    return;
                }
                XmlDocument document = new XmlDocument();
                document.LoadXml(HiCryptographer.Decrypt(openIdSettings.Settings));
                AliPayNotify notify      = new AliPayNotify(requestPost, base.Request.Form["notify_id"], document.FirstChild.SelectSingleNode("Partner").InnerText, document.FirstChild.SelectSingleNode("Key").InnerText);
                string       responseTxt = notify.ResponseTxt;
                string       str3        = base.Request.Form["sign"];
                string       mysign      = notify.Mysign;
                if ((responseTxt == "true") && (str3 == mysign))
                {
                    string str5 = base.Request.Form["receive_address"];
                    if (!string.IsNullOrEmpty(str5))
                    {
                        XmlDocument document2 = new XmlDocument();
                        document2.LoadXml(str5);
                        ShippingAddressInfo shippingAddress = new ShippingAddressInfo();
                        shippingAddress.UserId = HiContext.Current.User.UserId;
                        if ((document2.SelectSingleNode("/receiveAddress/address") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/address").InnerText))
                        {
                            shippingAddress.Address = Globals.HtmlEncode(document2.SelectSingleNode("/receiveAddress/address").InnerText);
                        }
                        if ((document2.SelectSingleNode("/receiveAddress/fullname") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/fullname").InnerText))
                        {
                            shippingAddress.ShipTo = Globals.HtmlEncode(document2.SelectSingleNode("/receiveAddress/fullname").InnerText);
                        }
                        if ((document2.SelectSingleNode("/receiveAddress/post") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/post").InnerText))
                        {
                            shippingAddress.Zipcode = document2.SelectSingleNode("/receiveAddress/post").InnerText;
                        }
                        if ((document2.SelectSingleNode("/receiveAddress/mobile_phone") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/mobile_phone").InnerText))
                        {
                            shippingAddress.CellPhone = document2.SelectSingleNode("/receiveAddress/mobile_phone").InnerText;
                        }
                        if ((document2.SelectSingleNode("/receiveAddress/phone") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/phone").InnerText))
                        {
                            shippingAddress.TelPhone = document2.SelectSingleNode("/receiveAddress/phone").InnerText;
                        }
                        string innerText = string.Empty;
                        string str7      = string.Empty;
                        string str8      = string.Empty;
                        if ((document2.SelectSingleNode("/receiveAddress/area") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/area").InnerText))
                        {
                            innerText = document2.SelectSingleNode("/receiveAddress/area").InnerText;
                        }
                        if ((document2.SelectSingleNode("/receiveAddress/city") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/city").InnerText))
                        {
                            str7 = document2.SelectSingleNode("/receiveAddress/city").InnerText;
                        }
                        if ((document2.SelectSingleNode("/receiveAddress/prov") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/prov").InnerText))
                        {
                            str8 = document2.SelectSingleNode("/receiveAddress/prov").InnerText;
                        }
                        if ((string.IsNullOrEmpty(innerText) && string.IsNullOrEmpty(str7)) && string.IsNullOrEmpty(str8))
                        {
                            shippingAddress.RegionId = 0;
                        }
                        else
                        {
                            shippingAddress.RegionId = RegionHelper.GetRegionId(innerText, str7, str8);
                        }
                        SiteSettings siteSettings = HiContext.Current.SiteSettings;
                        if (PersonalHelper.GetShippingAddressCount(HiContext.Current.User.UserId) < HiContext.Current.Config.ShippingAddressQuantity)
                        {
                            num = PersonalHelper.AddShippingAddress(shippingAddress);
                        }
                    }
                }
            }
            this.Page.Response.Redirect(Globals.ApplicationPath + "/SubmmitOrder.aspx?shippingId=" + num);
        }
Exemplo n.º 5
0
 public void btnCreateOrder_Click(object sender, System.EventArgs e)
 {
     if (this.ValidateCreateOrder())
     {
         OrderInfo orderInfo = this.GetOrderInfo(this.shoppingCart);
         if (this.shoppingCart.GetQuantity() > 1)
         {
             this.isSignBuy = false;
         }
         if (orderInfo == null)
         {
             this.ShowMessage("购物车中已经没有任何商品", false);
         }
         else
         {
             if (orderInfo.GetTotal() < 0m)
             {
                 this.ShowMessage("订单金额不能为负", false);
             }
             else
             {
                 if (!Hidistro.Membership.Context.HiContext.Current.User.IsAnonymous)
                 {
                     int totalNeedPoint = this.shoppingCart.GetTotalNeedPoint();
                     int points         = ((Hidistro.Membership.Context.Member)Hidistro.Membership.Context.HiContext.Current.User).Points;
                     if (points >= 0 && totalNeedPoint > points)
                     {
                         this.ShowMessage("您当前的积分不够兑换所需积分!", false);
                         return;
                     }
                 }
                 if (this.isCountDown)
                 {
                     CountDownInfo countDownInfo = ProductBrowser.GetCountDownInfo(this.shoppingCart.LineItems[this.productSku].ProductId);
                     if (countDownInfo.EndDate < System.DateTime.Now)
                     {
                         this.ShowMessage("此订单为抢购订单,但抢购时间已到!", false);
                         return;
                     }
                     if (this.shoppingCart.LineItems[this.productSku].Quantity > countDownInfo.MaxCount)
                     {
                         this.ShowMessage("你购买的数量超过限购数量:" + countDownInfo.MaxCount.ToString(), false);
                         return;
                     }
                     int num = ShoppingProcessor.CountDownOrderCount(this.shoppingCart.LineItems[this.productSku].ProductId);
                     if (num + this.shoppingCart.LineItems[this.productSku].Quantity > countDownInfo.MaxCount)
                     {
                         this.ShowMessage(string.Format("你已经抢购过该商品{0}件,每个用户只允许抢购{1}件,如果你有未付款的抢购单,请及时支付!", num, countDownInfo.MaxCount), false);
                         return;
                     }
                 }
                 try
                 {
                     if (ShoppingProcessor.CreatOrder(orderInfo))
                     {
                         Messenger.OrderCreated(orderInfo, Hidistro.Membership.Context.HiContext.Current.User);
                         orderInfo.OnCreated();
                         if (this.shoppingCart.GetTotalNeedPoint() > 0)
                         {
                             ShoppingProcessor.CutNeedPoint(this.shoppingCart.GetTotalNeedPoint(), orderInfo.OrderId);
                         }
                         if (!this.isCountDown && !this.isGroupBuy && !this.isSignBuy && !this.isBundling)
                         {
                             ShoppingCartProcessor.ClearShoppingCart();
                         }
                         if (!Hidistro.Membership.Context.HiContext.Current.User.IsAnonymous && PersonalHelper.GetShippingAddressCount(Hidistro.Membership.Context.HiContext.Current.User.UserId) == 0)
                         {
                             PersonalHelper.CreateShippingAddress(new ShippingAddressInfo
                             {
                                 UserId    = Hidistro.Membership.Context.HiContext.Current.User.UserId,
                                 ShipTo    = Globals.HtmlEncode(this.txtShipTo.Text),
                                 RegionId  = this.dropRegions.GetSelectedRegionId().Value,
                                 Address   = Globals.HtmlEncode(this.txtAddress.Text),
                                 Zipcode   = this.txtZipcode.Text,
                                 CellPhone = this.txtCellPhone.Text,
                                 TelPhone  = this.txtTelPhone.Text
                             });
                         }
                         this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("FinishOrder", new object[]
                         {
                             orderInfo.OrderId
                         }));
                     }
                 }
                 catch (System.Exception ex)
                 {
                     this.ShowMessage(ex.ToString(), false);
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 protected override void AttachChildControls()
 {
     this.dropRegions         = (RegionSelector)this.FindControl("dropRegions");
     this.txtShipTo           = (System.Web.UI.WebControls.TextBox) this.FindControl("txtShipTo");
     this.txtAddress          = (System.Web.UI.WebControls.TextBox) this.FindControl("txtAddress");
     this.txtZipcode          = (System.Web.UI.WebControls.TextBox) this.FindControl("txtZipcode");
     this.txtCellPhone        = (System.Web.UI.WebControls.TextBox) this.FindControl("txtCellPhone");
     this.txtTelPhone         = (System.Web.UI.WebControls.TextBox) this.FindControl("txtTelPhone");
     this.txtInvoiceTitle     = (System.Web.UI.WebControls.TextBox) this.FindControl("txtInvoiceTitle");
     this.drpShipToDate       = (System.Web.UI.HtmlControls.HtmlSelect) this.FindControl("drpShipToDate");
     this.litTaxRate          = (System.Web.UI.WebControls.Label) this.FindControl("litTaxRate");
     this.shippingModeList    = (Common_ShippingModeList)this.FindControl("Common_ShippingModeList");
     this.paymentModeList     = (Common_PaymentModeList)this.FindControl("grd_Common_PaymentModeList");
     this.inputPaymentModeId  = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("inputPaymentModeId");
     this.inputShippingModeId = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("inputShippingModeId");
     this.hdbuytype           = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hdbuytype");
     this.pannel_useraddress  = (System.Web.UI.WebControls.Panel) this.FindControl("pannel_useraddress");
     this.lblPaymentPrice     = (FormatedMoneyLabel)this.FindControl("lblPaymentPrice");
     this.lblShippModePrice   = (FormatedMoneyLabel)this.FindControl("lblShippModePrice");
     this.chkTax                = (System.Web.UI.HtmlControls.HtmlInputCheckBox) this.FindControl("chkTax");
     this.cartProductList       = (Common_SubmmintOrder_ProductList)this.FindControl("Common_SubmmintOrder_ProductList");
     this.cartGiftList          = (Common_SubmmintOrder_GiftList)this.FindControl("Common_SubmmintOrder_GiftList");
     this.litProductAmount      = (System.Web.UI.WebControls.Literal) this.FindControl("litProductAmount");
     this.litProductBundling    = (System.Web.UI.WebControls.Literal) this.FindControl("litProductBundling");
     this.litAllWeight          = (System.Web.UI.WebControls.Label) this.FindControl("litAllWeight");
     this.litPoint              = (System.Web.UI.WebControls.Label) this.FindControl("litPoint");
     this.hlkSentTimesPoint     = (System.Web.UI.WebControls.HyperLink) this.FindControl("hlkSentTimesPoint");
     this.lblOrderTotal         = (FormatedMoneyLabel)this.FindControl("lblOrderTotal");
     this.txtMessage            = (System.Web.UI.WebControls.TextBox) this.FindControl("txtMessage");
     this.hlkFeeFreight         = (System.Web.UI.WebControls.HyperLink) this.FindControl("hlkFeeFreight");
     this.hlkReducedPromotion   = (System.Web.UI.WebControls.HyperLink) this.FindControl("hlkReducedPromotion");
     this.lblTotalPrice         = (FormatedMoneyLabel)this.FindControl("lblTotalPrice");
     this.htmlCouponCode        = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("htmlCouponCode");
     this.CmbCoupCode           = (System.Web.UI.HtmlControls.HtmlSelect) this.FindControl("CmbCoupCode");
     this.tbCoupon              = (System.Web.UI.HtmlControls.HtmlTable) this.FindControl("tbCoupon");
     this.litCouponAmout        = (FormatedMoneyLabel)this.FindControl("litCouponAmout");
     this.btnCreateOrder        = ButtonManager.Create(this.FindControl("btnCreateOrder"));
     this.btnCreateOrder.Click += new System.EventHandler(this.btnCreateOrder_Click);
     Hidistro.Membership.Context.SiteSettings masterSettings = Hidistro.Membership.Context.SettingsManager.GetMasterSettings(false);
     if (!this.Page.IsPostBack)
     {
         this.BindUserAddress();
         this.shippingModeList.DataSource = ShoppingProcessor.GetShippingModes();
         this.shippingModeList.DataBind();
         this.ReBindPayment();
         if (this.shoppingCart != null)
         {
             this.litTaxRate.Text = masterSettings.TaxRate.ToString(System.Globalization.CultureInfo.InvariantCulture);
             this.BindShoppingCartInfo(this.shoppingCart);
             if (this.isGroupBuy || this.isCountDown || this.isBundling || this.shoppingCart.LineItems.Count == 0)
             {
                 this.tbCoupon.Visible = false;
             }
             this.CmbCoupCode.DataTextField  = "DisplayText";
             this.CmbCoupCode.DataValueField = "ClaimCode";
             this.CmbCoupCode.DataSource     = ShoppingProcessor.GetCoupon(this.shoppingCart.GetTotal());
             this.CmbCoupCode.DataBind();
             System.Web.UI.WebControls.ListItem item = new System.Web.UI.WebControls.ListItem("", "0");
             this.CmbCoupCode.Items.Insert(0, item);
             this.hdbuytype.Value            = this.buytype;
             this.pannel_useraddress.Visible = (!Hidistro.Membership.Context.HiContext.Current.User.IsAnonymous && PersonalHelper.GetShippingAddressCount(Hidistro.Membership.Context.HiContext.Current.User.UserId) > 0);
         }
     }
 }
Exemplo n.º 7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int num = 0;

            System.Collections.Generic.SortedDictionary <string, string> requestPost = this.GetRequestPost();
            if (requestPost.Count > 0)
            {
                string             openIdType     = "hishop.plugins.openid.alipay.alipayservice";
                OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType);
                if (openIdSettings == null)
                {
                    base.Response.Write("登录失败,没有找到对应的插件配置信息。");
                    return;
                }
                System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
                xmlDocument.LoadXml(HiCryptographer.Decrypt(openIdSettings.Settings));
                AliPayNotify aliPayNotify = new AliPayNotify(requestPost, base.Request.Form["notify_id"], xmlDocument.FirstChild.SelectSingleNode("Partner").InnerText, xmlDocument.FirstChild.SelectSingleNode("Key").InnerText);
                string       responseTxt  = aliPayNotify.ResponseTxt;
                string       a            = base.Request.Form["sign"];
                string       mysign       = aliPayNotify.Mysign;
                if (responseTxt == "true" && a == mysign)
                {
                    string text = base.Request.Form["receive_address"];
                    if (!string.IsNullOrEmpty(text))
                    {
                        System.Xml.XmlDocument xmlDocument2 = new System.Xml.XmlDocument();
                        xmlDocument2.LoadXml(text);
                        ShippingAddressInfo shippingAddressInfo = new ShippingAddressInfo();
                        shippingAddressInfo.UserId = Hidistro.Membership.Context.HiContext.Current.User.UserId;
                        if (xmlDocument2.SelectSingleNode("/receiveAddress/address") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/address").InnerText))
                        {
                            shippingAddressInfo.Address = Globals.HtmlEncode(xmlDocument2.SelectSingleNode("/receiveAddress/address").InnerText);
                        }
                        if (xmlDocument2.SelectSingleNode("/receiveAddress/fullname") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/fullname").InnerText))
                        {
                            shippingAddressInfo.ShipTo = Globals.HtmlEncode(xmlDocument2.SelectSingleNode("/receiveAddress/fullname").InnerText);
                        }
                        if (xmlDocument2.SelectSingleNode("/receiveAddress/post") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/post").InnerText))
                        {
                            shippingAddressInfo.Zipcode = xmlDocument2.SelectSingleNode("/receiveAddress/post").InnerText;
                        }
                        if (xmlDocument2.SelectSingleNode("/receiveAddress/mobile_phone") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/mobile_phone").InnerText))
                        {
                            shippingAddressInfo.CellPhone = xmlDocument2.SelectSingleNode("/receiveAddress/mobile_phone").InnerText;
                        }
                        if (xmlDocument2.SelectSingleNode("/receiveAddress/phone") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/phone").InnerText))
                        {
                            shippingAddressInfo.TelPhone = xmlDocument2.SelectSingleNode("/receiveAddress/phone").InnerText;
                        }
                        string text2 = string.Empty;
                        string text3 = string.Empty;
                        string text4 = string.Empty;
                        if (xmlDocument2.SelectSingleNode("/receiveAddress/area") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/area").InnerText))
                        {
                            text2 = xmlDocument2.SelectSingleNode("/receiveAddress/area").InnerText;
                        }
                        if (xmlDocument2.SelectSingleNode("/receiveAddress/city") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/city").InnerText))
                        {
                            text3 = xmlDocument2.SelectSingleNode("/receiveAddress/city").InnerText;
                        }
                        if (xmlDocument2.SelectSingleNode("/receiveAddress/prov") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/prov").InnerText))
                        {
                            text4 = xmlDocument2.SelectSingleNode("/receiveAddress/prov").InnerText;
                        }
                        if (string.IsNullOrEmpty(text2) && string.IsNullOrEmpty(text3) && string.IsNullOrEmpty(text4))
                        {
                            shippingAddressInfo.RegionId = 0;
                        }
                        else
                        {
                            shippingAddressInfo.RegionId = RegionHelper.GetRegionId(text2, text3, text4);
                        }
                        Hidistro.Membership.Context.SiteSettings arg_371_0 = Hidistro.Membership.Context.HiContext.Current.SiteSettings;
                        if (PersonalHelper.GetShippingAddressCount(Hidistro.Membership.Context.HiContext.Current.User.UserId) < Hidistro.Membership.Context.HiContext.Current.Config.ShippingAddressQuantity)
                        {
                            num = PersonalHelper.AddShippingAddress(shippingAddressInfo);
                        }
                    }
                }
            }
            this.Page.Response.Redirect(Globals.ApplicationPath + "/SubmmitOrder.aspx?shippingId=" + num);
        }
Exemplo n.º 8
0
        private bool ValShippingAddress(System.Web.HttpContext context, ref string erromsg)
        {
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("[\\u4e00-\\u9fa5a-zA-Z]+[\\u4e00-\\u9fa5_a-zA-Z0-9]*");
            bool result;

            if (string.IsNullOrEmpty(context.Request.Params["ShippingTo"].Trim()) || !regex.IsMatch(context.Request.Params["ShippingTo"].Trim()))
            {
                erromsg = "收货人名字不能为空,只能是汉字或字母开头,长度在2-20个字符之间";
                result  = false;
            }
            else
            {
                if (string.IsNullOrEmpty(context.Request.Params["AddressDetails"].Trim()))
                {
                    erromsg = "详细地址不能为空";
                    result  = false;
                }
                else
                {
                    if (context.Request.Params["AddressDetails"].Trim().Length < 3 || context.Request.Params["AddressDetails"].Trim().Length > 60)
                    {
                        erromsg = "详细地址长度在3-60个字符之间";
                        result  = false;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(context.Request.Params["RegionId"].Trim()) || System.Convert.ToInt32(context.Request.Params["RegionId"].Trim()) <= 0)
                        {
                            erromsg = "请选择收货地址";
                            result  = false;
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(context.Request.Params["TelPhone"].Trim()) && string.IsNullOrEmpty(context.Request.Params["CellHphone"].Trim().Trim()))
                            {
                                erromsg = "电话号码和手机二者必填其一";
                                result  = false;
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(context.Request.Params["TelPhone"].Trim()) && (context.Request.Params["TelPhone"].Trim().Length < 3 || context.Request.Params["TelPhone"].Trim().Length > 20))
                                {
                                    erromsg = "电话号码长度限制在3-20个字符之间";
                                    result  = false;
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(context.Request.Params["CellHphone"].Trim()) && (context.Request.Params["CellHphone"].Trim().Length < 3 || context.Request.Params["CellHphone"].Trim().Length > 20))
                                    {
                                        erromsg = "手机号码长度限制在3-20个字符之间";
                                        result  = false;
                                    }
                                    else
                                    {
                                        if (PersonalHelper.GetShippingAddressCount(Hidistro.Membership.Context.HiContext.Current.User.UserId) >= Hidistro.Membership.Context.HiContext.Current.Config.ShippingAddressQuantity)
                                        {
                                            erromsg = string.Format("最多只能添加{0}个收货地址", Hidistro.Membership.Context.HiContext.Current.Config.ShippingAddressQuantity);
                                            result  = false;
                                        }
                                        else
                                        {
                                            result = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }