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;
            }
        }
Beispiel #2
0
        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");
        }