private void btnCreate_Click(object sender, System.EventArgs e) { decimal weight; decimal?addWeight; decimal price; decimal?addPrice; if (!this.ValidateRegionValues(out weight, out addWeight, out price, out addPrice)) { return; } new System.Collections.Generic.List <ShippingModeGroupInfo>(); ShippingModeInfo shippingModeInfo = new ShippingModeInfo(); shippingModeInfo.Name = Globals.HtmlEncode(this.txtModeName.Text.Trim()); shippingModeInfo.Weight = weight; shippingModeInfo.AddWeight = addWeight; shippingModeInfo.Price = price; shippingModeInfo.AddPrice = addPrice; foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdRegion.Rows) { decimal price2 = 0m; decimal addPrice2 = 0m; decimal.TryParse(((System.Web.UI.WebControls.TextBox)gridViewRow.FindControl("txtModeRegionPrice")).Text, out price2); decimal.TryParse(((System.Web.UI.WebControls.TextBox)gridViewRow.FindControl("txtModeRegionAddPrice")).Text, out addPrice2); ShippingModeGroupInfo shippingModeGroupInfo = new ShippingModeGroupInfo(); shippingModeGroupInfo.Price = price2; shippingModeGroupInfo.AddPrice = addPrice2; System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox) this.grdRegion.Rows[gridViewRow.RowIndex].FindControl("txtRegionvalue_Id"); if (!string.IsNullOrEmpty(textBox.Text)) { string[] array = textBox.Text.Split(new char[] { ',' }); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text = array2[i]; ShippingRegionInfo shippingRegionInfo = new ShippingRegionInfo(); shippingRegionInfo.RegionId = System.Convert.ToInt32(text.Trim()); shippingModeGroupInfo.ModeRegions.Add(shippingRegionInfo); } } shippingModeInfo.ModeGroup.Add(shippingModeGroupInfo); } if (!SalesHelper.CreateShippingTemplate(shippingModeInfo)) { this.ShowMsg("您添加的地区有重复", false); return; } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["source"]) && this.Page.Request.QueryString["source"] == "add") { this.CloseWindow(); return; } this.ClearControlValue(); this.ShowMsg("成功添加了一个配送方式模板", true); }
private void btnCreate_Click(object sender, EventArgs e) { decimal num; decimal?nullable; decimal num2; decimal?nullable2; if (this.ValidateRegionValues(out num, out nullable, out num2, out nullable2)) { new List <ShippingModeGroupInfo>(); ShippingModeInfo shippingMode = new ShippingModeInfo { Name = Globals.HtmlEncode(this.txtModeName.Text.Trim()), Weight = num, AddWeight = nullable, Price = num2, AddPrice = nullable2 }; foreach (GridViewRow row in this.grdRegion.Rows) { decimal result = 0M; decimal num4 = 0M; decimal.TryParse(((TextBox)row.FindControl("txtModeRegionPrice")).Text, out result); decimal.TryParse(((TextBox)row.FindControl("txtModeRegionAddPrice")).Text, out num4); ShippingModeGroupInfo item = new ShippingModeGroupInfo { Price = result, AddPrice = num4 }; TextBox box = (TextBox)this.grdRegion.Rows[row.RowIndex].FindControl("txtRegionvalue_Id"); if (!string.IsNullOrEmpty(box.Text)) { foreach (string str in box.Text.Split(new char[] { ',' })) { ShippingRegionInfo info3 = new ShippingRegionInfo { RegionId = Convert.ToInt32(str.Trim()) }; item.ModeRegions.Add(info3); } } shippingMode.ModeGroup.Add(item); } if (SalesHelper.CreateShippingTemplate(shippingMode)) { if (!string.IsNullOrEmpty(this.Page.Request.QueryString["source"]) && (this.Page.Request.QueryString["source"] == "add")) { this.CloseWindow(); } else { this.ClearControlValue(); this.ShowMsg("成功添加了一个配送方式模板", true); } } else { this.ShowMsg("您添加的地区有重复", false); } } }
private void btnCreate_Click(object sender, EventArgs e) { decimal defaultNumber = default(decimal); decimal? addNumber = default(decimal?); decimal price = default(decimal); decimal? addPrice = default(decimal?); ValuationMethods valuationMethod = default(ValuationMethods); if (this.ValidateRegionValues(out defaultNumber, out addNumber, out price, out addPrice, out valuationMethod)) { IList <ShippingTemplateGroupInfo> list = new List <ShippingTemplateGroupInfo>(); string value = this.hidRegionJson.Value; if (!string.IsNullOrEmpty(value)) { IList <ShippingTemplateGroupMode> list2 = new List <ShippingTemplateGroupMode>(); list2 = JsonHelper.ParseFormJson <List <ShippingTemplateGroupMode> >(value); if (list2 != null && list2.Count > 0) { foreach (ShippingTemplateGroupMode item in list2) { ShippingTemplateGroupInfo shippingTemplateGroupInfo = new ShippingTemplateGroupInfo(); shippingTemplateGroupInfo.AddPrice = item.AddPrice; shippingTemplateGroupInfo.AddNumber = item.AddNumber; shippingTemplateGroupInfo.DefaultNumber = item.DefaultNumber; shippingTemplateGroupInfo.Price = item.DefaultPrice; string safeIDList = Globals.GetSafeIDList(item.RegionIds, ',', true); string[] array = safeIDList.Split(','); foreach (string obj in array) { ShippingRegionInfo shippingRegionInfo = new ShippingRegionInfo(); shippingRegionInfo.RegionId = obj.ToInt(0); shippingTemplateGroupInfo.ModeRegions.Add(shippingRegionInfo); } list.Add(shippingTemplateGroupInfo); } } } IList <ShippingTemplateFreeGroupInfo> list3 = new List <ShippingTemplateFreeGroupInfo>(); string value2 = this.hidFreeJson.Value; if (!string.IsNullOrEmpty(value2)) { IList <ShippingTemplateFreeGroupMode> list4 = new List <ShippingTemplateFreeGroupMode>(); list4 = JsonHelper.ParseFormJson <List <ShippingTemplateFreeGroupMode> >(value2); if (list4 != null && list4.Count > 0) { foreach (ShippingTemplateFreeGroupMode item2 in list4) { ShippingTemplateFreeGroupInfo shippingTemplateFreeGroupInfo = new ShippingTemplateFreeGroupInfo(); shippingTemplateFreeGroupInfo.ConditionType = item2.ConditionType; shippingTemplateFreeGroupInfo.ConditionNumber = item2.ConditionNumber; string safeIDList2 = Globals.GetSafeIDList(item2.RegionIds, ',', true); string[] array2 = safeIDList2.Split(','); foreach (string obj2 in array2) { ShippingFreeRegionInfo shippingFreeRegionInfo = new ShippingFreeRegionInfo(); shippingFreeRegionInfo.RegionId = obj2.ToInt(0); shippingTemplateFreeGroupInfo.ModeRegions.Add(shippingFreeRegionInfo); } list3.Add(shippingTemplateFreeGroupInfo); } } } string text = Globals.StripAllTags(this.txtModeName.Text.Trim()).Replace("\\", "").Replace("<", "") .Replace(">", ""); if (text == "" || text.Length > 20) { this.ShowMsg("模板名称不能为空,长度限制在20字符以内,不允许包含脚本标签和特殊字符,系统会自动过滤", false); } else if (SalesHelper.IsExistTemplateName(text, 0)) { this.ShowMsg("模板名称重复,请重新输入", false); } else { ShippingTemplateInfo shippingTemplateInfo = new ShippingTemplateInfo(); shippingTemplateInfo.ModeGroup = list; shippingTemplateInfo.FreeGroup = list3; shippingTemplateInfo.IsFreeShipping = (this.radIsFreeShipping.SelectedIndex != 0 && true); shippingTemplateInfo.ValuationMethod = valuationMethod; shippingTemplateInfo.TemplateName = Globals.HtmlEncode(text); shippingTemplateInfo.DefaultNumber = defaultNumber; shippingTemplateInfo.AddNumber = addNumber; shippingTemplateInfo.Price = price; shippingTemplateInfo.AddPrice = addPrice; if (SalesHelper.CreateShippingTemplate(shippingTemplateInfo)) { if (!string.IsNullOrEmpty(this.Page.Request.QueryString["source"]) && this.Page.Request.QueryString["source"] == "add") { this.CloseWindow(); } else { this.ClearControlValue(); this.ShowMsg("成功添加了一个配送方式模板", true, "ManageShippingTemplates.aspx"); } } else { this.ShowMsg("您添加的地区有重复", false); } } } }
private void btnCreate_Click(object sender, EventArgs e) { int weight = 0; int? addWeight = 0; decimal price = 0m; decimal?addPrice = 0; if (ValidateRegionValues(out weight, out addWeight, out price, out addPrice)) { new List <ShippingModeGroupInfo>(); ShippingModeInfo shippingModeInfo = new ShippingModeInfo(); shippingModeInfo.Name = Globals.HtmlEncode(txtModeName.Text.Trim()); shippingModeInfo.Weight = weight; shippingModeInfo.AddWeight = addWeight; shippingModeInfo.Price = price; shippingModeInfo.AddPrice = addPrice; ShippingModeGroupInfo shippingModeGroupInfo = null; ShippingRegionInfo shippingRegionInfo = null; foreach (GridViewRow row in grdRegion.Rows) { shippingModeGroupInfo = new ShippingModeGroupInfo(); shippingModeGroupInfo.Price = decimal.Parse(((TextBox)row.FindControl("txtModeRegionPrice")).Text); shippingModeGroupInfo.AddPrice = decimal.Parse(((TextBox)row.FindControl("txtModeRegionAddPrice")).Text); TextBox box = (TextBox)grdRegion.Rows[row.RowIndex].FindControl("txtRegionvalue_Id"); foreach (string str in box.Text.Split(new char[] { ',' })) { shippingRegionInfo = new ShippingRegionInfo(); shippingRegionInfo.RegionId = Convert.ToInt32(str.Trim()); shippingModeGroupInfo.ModeRegions.Add(shippingRegionInfo); } shippingModeInfo.ModeGroup.Add(shippingModeGroupInfo); } ValidationResults results = Hishop.Components.Validation.Validation.Validate <ShippingModeInfo>(shippingModeInfo, "ValShippingModeInfo"); string msg = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } else if (SalesHelper.CreateShippingTemplate(shippingModeInfo)) { ClearControlValue(); ShowMsg("成功添加了一个配送方式模板", true); } else { ShowMsg("您添加的地区有重复", false); } } }