Esempio n. 1
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            ProductLineInfo productLineInfo = new ProductLineInfo
            {
                Name         = this.txtProductLineName.Text.Trim(),
                SupplierName = (this.dropSuppliers.SelectedValue.Length > 0) ? this.dropSuppliers.SelectedValue : null
            };
            ValidationResults validationResults = Validation.Validate <ProductLineInfo>(productLineInfo, new string[]
            {
                "ValProductLine"
            });
            string text = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    text += Formatter.FormatErrorMessage(current.Message);
                }
                this.ShowMsg(text, false);
                return;
            }
            if (ProductLineHelper.AddProductLine(productLineInfo))
            {
                this.Reset();
                this.ShowMsg("成功的添加了一条产品线", true);
                return;
            }
            this.ShowMsg("添加产品线失败", false);
        }
Esempio n. 2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            ProductLineInfo info2 = new ProductLineInfo();

            info2.Name         = this.txtProductLineName.Text.Trim();
            info2.SupplierName = (this.dropSuppliers.SelectedValue.Length > 0) ? this.dropSuppliers.SelectedValue : null;
            ProductLineInfo   target  = info2;
            ValidationResults results = Hishop.Components.Validation.Validation.Validate <ProductLineInfo>(target, new string[] { "ValProductLine" });
            string            msg     = string.Empty;

            if (!results.IsValid)
            {
                foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                {
                    msg = msg + Formatter.FormatErrorMessage(result.Message);
                }
                this.ShowMsg(msg, false);
            }
            else if (ProductLineHelper.AddProductLine(target))
            {
                this.Reset();
                this.ShowMsg("成功的添加了一条产品线", true);
            }
            else
            {
                this.ShowMsg("添加产品线失败", false);
            }
        }