private void BindData() { if (ProductID != 0) { GroupProductModel model = bll.GetModel(ProductID); this.Title = model.ProductName + "-团购-鼎鼎商城"; Literal_ProductName.Text = model.ProductName; Image_Small.ImageUrl = GroupShoppingImageRule.GetImageUrl(model.MediumImage); Image_Big.ImageUrl = GroupShoppingImageRule.GetImageUrl(model.LargeImage); Literal_Count.Text = model.SuccedLine.ToString(); Literal_CurrentCount.Text = ""; Literal_GroupPrice.Text = model.GroupPrice.ToString("0.00"); Literal_MarketPrice.Text = model.MarketPrice.ToString("0.00"); Literal_Time.Text = ""; Literal_Brief.Text = model.Description; if (model.ProductType == (int)GroupShoppingProductType.解决方案) { Literal_Detail.Text = String.Format("<div class=\"box7\" runat=\"server\"><div class=\"title\">解决方案明细</div><div class=\"content\"><p class=\"description\">{0}</p></div></div>", model.Detail); Literal_Detail.Visible = true; } if (Session["group-product-apply"] != null) { TextBox_Message.Text = Session["group-product-apply"].ToString(); TextBox_Message.Focus(); } Repeater_ApplyList.DataSource = abll.GetList(ProductID); Repeater_ApplyList.DataBind(); } }
private void BindData() { DropDown_ProductType.DataSource = DataTableUtil.GetEnumKeyValue(typeof(GroupShoppingProductType)); DropDown_ProductType.DataTextField = "key"; DropDown_ProductType.DataValueField = "value"; DropDown_ProductType.DataBind(); if (GroupProductID != 0) { GroupProductModel model = bll.GetModel(GroupProductID); TextBox_ProductName.Text = model.ProductName; DropDown_ProductType.SelectedValue = model.ProductType.ToString(); TextBox_ProductCode.Text = model.ProductCode; TextBox_MarketPrice.Text = model.MarketPrice.ToString("0.00"); TextBox_GroupPrice.Text = model.GroupPrice.ToString("0.00"); TextBox_PrePaidPrice.Text = model.PrePaidPrice.ToString("0.00"); TextBox_Detail.Text = model.Detail; TextBox_Brief.Text = model.Description; TextBox_SuccedLine.Text = model.SuccedLine.ToString(); CheclBox_Recommend.Checked = model.IsRecommend; Image_ProductImage.ImageUrl = GroupShoppingImageRule.GetImageUrl(model.SmallImage); } }
protected void Button_Add_Click(object sender, EventArgs e) { string ErrorMessage = String.Empty; if (String.IsNullOrEmpty(TextBox_ProductName.Text.Trim())) ErrorMessage += "产品名称不能为空\\n"; if (String.IsNullOrEmpty(TextBox_MarketPrice.Text.Trim()) || !PageValidate.IsDecimal(TextBox_MarketPrice.Text.Trim())) ErrorMessage += "市场价输入有误\\n"; if (String.IsNullOrEmpty(TextBox_GroupPrice.Text.Trim()) || !PageValidate.IsDecimal(TextBox_GroupPrice.Text.Trim())) ErrorMessage += "团购价输入有误\\n"; if (String.IsNullOrEmpty(TextBox_PrePaidPrice.Text.Trim()) || !PageValidate.IsDecimal(TextBox_PrePaidPrice.Text.Trim())) ErrorMessage += "预付金额输入有误\\n"; if (String.IsNullOrEmpty(TextBox_SuccedLine.Text.Trim()) || !PageValidate.IsNumber(TextBox_SuccedLine.Text.Trim())) ErrorMessage += "成团人数输入有误"; if (String.IsNullOrEmpty(TextBox_Brief.Text.Trim())) ErrorMessage += "产品简介不能为空\\n"; if (String.IsNullOrEmpty(FileUpload_Image.FileName.Trim())) ErrorMessage += "产品图片不能为空\\n"; if (!String.IsNullOrEmpty(ErrorMessage)) { MessageBox.Show(this, ErrorMessage); return; } int GroupProductID = CommDataHelper.GetNewSerialNum(AppType.GroupShopping); string[] FileNames = new string[3]; if (GroupShoppingImageRule.SaveImage(GroupProductID, FileUpload_Image.PostedFile, out FileNames)) { GroupProductModel model = new GroupProductModel(); model.ProductID = GroupProductID; model.ProductName = TextBox_ProductName.Text.Trim(); model.ProductType = Convert.ToInt32(DropDown_ProductType.SelectedValue); model.ProductCode = TextBox_ProductCode.Text.Trim(); model.MarketPrice = Convert.ToDecimal(TextBox_MarketPrice.Text.Trim()); model.GroupPrice = Convert.ToDecimal(TextBox_GroupPrice.Text.Trim()); model.PrePaidPrice = Convert.ToDecimal(TextBox_PrePaidPrice.Text.Trim()); model.SuccedLine = Convert.ToInt32(TextBox_SuccedLine.Text.Trim()); model.IsRecommend = CheclBox_Recommend.Checked; model.Detail = TextBox_Detail.Text.Trim(); model.Description = TextBox_Brief.Text; model.SmallImage = FileNames[0]; model.MediumImage = FileNames[1]; model.LargeImage = FileNames[2]; model.InsertTime = DateTime.Now; model.ChangeTime = DateTime.Now; model.Status = (int)GroupShoppingProductStatus.正在团购; new GroupProductBll().Add(model); Response.Redirect("List.aspx"); } else { MessageBox.Show(this, "图片上传失败,请检查后重新选择!"); return; } }
protected void Button_Edit_Click(object sender, EventArgs e) { string ErrorMessage = String.Empty; if (String.IsNullOrEmpty(TextBox_ProductName.Text.Trim())) { ErrorMessage += "产品名称不能为空\\n"; } if (String.IsNullOrEmpty(TextBox_MarketPrice.Text.Trim()) || !PageValidate.IsDecimal(TextBox_MarketPrice.Text.Trim())) { ErrorMessage += "市场价输入有误\\n"; } if (String.IsNullOrEmpty(TextBox_GroupPrice.Text.Trim()) || !PageValidate.IsDecimal(TextBox_GroupPrice.Text.Trim())) { ErrorMessage += "团购价输入有误\\n"; } if (String.IsNullOrEmpty(TextBox_PrePaidPrice.Text.Trim()) || !PageValidate.IsDecimal(TextBox_PrePaidPrice.Text.Trim())) { ErrorMessage += "预付金额输入有误\\n"; } if (String.IsNullOrEmpty(TextBox_SuccedLine.Text.Trim()) || !PageValidate.IsNumber(TextBox_SuccedLine.Text.Trim())) { ErrorMessage += "成团人数输入有误"; } if (String.IsNullOrEmpty(TextBox_Brief.Text.Trim())) { ErrorMessage += "产品简介不能为空\\n"; } if (!String.IsNullOrEmpty(ErrorMessage)) { MessageBox.Show(this, ErrorMessage); return; } GroupProductModel model = bll.GetModel(GroupProductID); model.ProductName = TextBox_ProductName.Text.Trim(); model.ProductType = Convert.ToInt32(DropDown_ProductType.SelectedValue); model.ProductCode = TextBox_ProductCode.Text.Trim(); model.MarketPrice = Convert.ToDecimal(TextBox_MarketPrice.Text.Trim()); model.GroupPrice = Convert.ToDecimal(TextBox_GroupPrice.Text.Trim()); model.PrePaidPrice = Convert.ToDecimal(TextBox_PrePaidPrice.Text.Trim()); model.SuccedLine = Convert.ToInt32(TextBox_SuccedLine.Text.Trim()); model.IsRecommend = CheclBox_Recommend.Checked; model.Detail = TextBox_Detail.Text.Trim(); model.Description = TextBox_Brief.Text; if (FileUpload_Image.FileName.Trim() != String.Empty && FileUpload_Image.PostedFile.ContentLength > 0) { string[] FileNames = new string[3]; if (GroupShoppingImageRule.SaveImage(GroupProductID, FileUpload_Image.PostedFile, out FileNames)) { model.SmallImage = FileNames[0]; model.MediumImage = FileNames[1]; model.LargeImage = FileNames[2]; } else { MessageBox.Show(this, "图片上传失败,请检查后重新选择!"); return; } } model.ChangeTime = DateTime.Now; bll.Update(model); Response.Redirect("List.aspx"); }