Пример #1
0
        public void btnRefer_Click(object sender, System.EventArgs e)
        {
            ProductConsultationInfo productConsultationInfo = new ProductConsultationInfo();

            productConsultationInfo.ConsultationDate = System.DateTime.Now;
            productConsultationInfo.ProductId        = this.productId;
            productConsultationInfo.UserId           = Hidistro.Membership.Context.HiContext.Current.User.UserId;
            productConsultationInfo.UserName         = this.txtUserName.Text;
            productConsultationInfo.UserEmail        = this.txtEmail.Text;
            productConsultationInfo.ConsultationText = Globals.HtmlEncode(this.txtContent.Text);
            ValidationResults validationResults = Validation.Validate <ProductConsultationInfo>(productConsultationInfo, new string[]
            {
                "Refer"
            });
            string text = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    text += Formatter.FormatErrorMessage(current.Message);
                }
                this.ShowMessage(text, false);
            }
            else
            {
                if (string.IsNullOrEmpty(this.txtConsultationCode.Value))
                {
                    this.ShowMessage("请输入验证码", false);
                }
                else
                {
                    if (!Hidistro.Membership.Context.HiContext.Current.CheckVerifyCode(this.txtConsultationCode.Value.Trim()))
                    {
                        this.ShowMessage("验证码不正确", false);
                    }
                    else
                    {
                        if (ProductProcessor.InsertProductConsultation(productConsultationInfo))
                        {
                            this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "success", string.Format("<script>alert(\"{0}\");window.location.href=\"{1}\"</script>", "咨询成功,管理员回复即可显示", Globals.GetSiteUrls().UrlData.FormatUrl("productConsultations", new object[]
                            {
                                this.productId
                            })));
                        }
                        else
                        {
                            this.ShowMessage("咨询失败,请重试", false);
                        }
                    }
                }
            }
        }
        public void btnRefer_Click(object sender, EventArgs e)
        {
            ProductConsultationInfo target = new ProductConsultationInfo();

            target.ConsultationDate = DateTime.Now;
            target.ProductId        = this.productId;
            target.UserId           = HiContext.Current.User.UserId;
            target.UserName         = this.txtUserName.Text;
            target.UserEmail        = this.txtEmail.Text;
            target.ConsultationText = Globals.HtmlEncode(this.txtContent.Text);
            ValidationResults results = Hishop.Components.Validation.Validation.Validate <ProductConsultationInfo>(target, new string[] { "Refer" });
            string            msg     = string.Empty;

            if (!results.IsValid)
            {
                foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                {
                    msg = msg + Formatter.FormatErrorMessage(result.Message);
                }
                this.ShowMessage(msg, false);
            }
            else if (string.IsNullOrEmpty(this.txtConsultationCode.Value))
            {
                this.ShowMessage("请输入验证码", false);
            }
            else if (!HiContext.Current.CheckVerifyCode(this.txtConsultationCode.Value.Trim()))
            {
                this.ShowMessage("验证码不正确", false);
            }
            else if (ProductProcessor.InsertProductConsultation(target))
            {
                this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "success", string.Format("<script>alert(\"{0}\");window.location.href=\"{1}\"</script>", "咨询成功,管理员回复即可显示", Globals.GetSiteUrls().UrlData.FormatUrl("productConsultations", new object[] { this.productId })));
            }
            else
            {
                this.ShowMessage("咨询失败,请重试", false);
            }
        }