public static GroupProductModel GetImageUrl(GroupProductModel Product)
        {
            Product.SmallImage = config.UrlRoot + Product.SmallImage;
            Product.MediumImage = config.UrlRoot + Product.MediumImage;
            Product.LargeImage = config.UrlRoot + Product.LargeImage;

            return Product;
        }
Пример #2
0
        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;
            }
        }
        public void Add(GroupProductModel model)
        {
            DbCommand Command = dbw.GetStoredProcCommand("UP_gsProduct_ADD");

            dbw.AddInParameter(Command,"@ProductID",DbType.Int32,model.ProductID);
            dbw.AddInParameter(Command,"@ProductName",DbType.String,model.ProductName);
            dbw.AddInParameter(Command, "@ProductCode", DbType.String, model.ProductCode);
            dbw.AddInParameter(Command, "@MarketPrice", DbType.Decimal, model.MarketPrice);
            dbw.AddInParameter(Command,"@GroupPrice",DbType.Decimal,model.GroupPrice);
            dbw.AddInParameter(Command, "@PrePaidPrice", DbType.Decimal, model.PrePaidPrice);
            dbw.AddInParameter(Command, "@succedline", DbType.Int32, model.SuccedLine);
            dbw.AddInParameter(Command,"@SmallImage",DbType.String,model.SmallImage);
            dbw.AddInParameter(Command,"@MediumImage",DbType.String,model.MediumImage);
            dbw.AddInParameter(Command,"@LargeImage",DbType.String,model.LargeImage);
            dbw.AddInParameter(Command,"@Detail",DbType.String,model.Detail);
            dbw.AddInParameter(Command,"@Description",DbType.String,model.Description);
            dbw.AddInParameter(Command,"@InsertTime",DbType.DateTime,model.InsertTime);
            dbw.AddInParameter(Command,"@ChangeTime",DbType.DateTime,model.ChangeTime);
            dbw.AddInParameter(Command,"@Status",DbType.Int16,model.Status);
            dbw.AddInParameter(Command, "@ProductType", DbType.Int16, model.ProductType);
            dbw.AddInParameter(Command, "@isrecommend", DbType.Boolean, model.IsRecommend);

            dbw.ExecuteNonQuery(Command);
        }
        private GroupProductModel GetModel(DataRow row)
        {
            GroupProductModel model = new GroupProductModel();

            model.ProductID = Convert.ToInt32(row["ProductID"]);
            model.ProductName = Convert.ToString(row["ProductName"]);
            model.ProductCode = Convert.ToString(row["ProductCode"]);
            model.Description = Convert.ToString(row["Description"]);
            model.Detail = Convert.ToString(row["Detail"]);
            model.PrePaidPrice = Convert.ToDecimal(row["PrePaidPrice"]);
            model.GroupPrice = Convert.ToDecimal(row["GroupPrice"]);
            model.InsertTime = Convert.ToDateTime(row["InsertTime"]);
            model.ChangeTime = Convert.ToDateTime(row["ChangeTime"]);
            model.SmallImage = Convert.ToString(row["SmallImage"]);
            model.MediumImage = Convert.ToString(row["MediumImage"]);
            model.LargeImage = Convert.ToString(row["LargeImage"]);
            model.ProductType = Convert.ToInt16(row["ProductType"]);
            model.Status = Convert.ToInt16(row["Status"]);
            model.MarketPrice = Convert.ToDecimal(row["MarketPrice"]);
            model.SuccedLine = Convert.ToInt32(row["SuccedLine"]);
            model.IsRecommend = Convert.ToBoolean(row["IsRecommend"]);

            return model;
        }