protected void Button_Add_Click(object sender, EventArgs e)
        {
            string ErrorMessage = String.Empty;
            if(String.IsNullOrEmpty(TextBox_RentName.Text)) ErrorMessage+="商品名称不能为空\\n";
            if (String.IsNullOrEmpty(TextBox_Stock.Text) || !PageValidate.IsNumber(TextBox_Stock.Text)) ErrorMessage += "商品数量不正确\\n";
            if (String.IsNullOrEmpty(TextBox_Keywords.Text)) ErrorMessage += "关键词不能为空\\n";
            if (String.IsNullOrEmpty(TextBox_RentPrice.Text) || !PageValidate.IsDecimal(TextBox_RentPrice.Text)) ErrorMessage += "出租价格不正确\\n";
            if (String.IsNullOrEmpty(TextBox_CashPledge.Text) || !PageValidate.IsDecimal(TextBox_CashPledge.Text)) ErrorMessage += "出租押金不正确\\n";
            if (String.IsNullOrEmpty(TextBox_MaxRentDays.Text) || !PageValidate.IsNumber(TextBox_MaxRentDays.Text)) ErrorMessage += "最大出租时间不正确\\n";
            if (String.IsNullOrEmpty(TextBox_Brief.Text)) ErrorMessage += "商品简介不能为空\\n";
            if (String.IsNullOrEmpty(FileUpload_MainImage.FileName)) ErrorMessage += "商品图片不能为空\\n";

            if(!String.IsNullOrEmpty(ErrorMessage))
            {
                MessageBox.Show(this,ErrorMessage);
                return;
            }

            int RentID = CommDataHelper.GetNewSerialNum(AppType.MagicWorld);

            string[] ProductImages;
            if (MagicWorldImageRule.SaveProductMainImage(RentID, FileUpload_MainImage.PostedFile, out ProductImages))
            {
                RentProductModel model = new RentProductModel();

                model.RentID = RentID;
                model.RentName = TextBox_RentName.Text;
                model.Stock = Convert.ToInt32(TextBox_Stock.Text);
                model.Keywords = TextBox_Keywords.Text.Replace(",",",");
                model.CashPledge = Convert.ToDecimal(TextBox_CashPledge.Text);
                model.RentPrice = Convert.ToDecimal(TextBox_RentPrice.Text);
                model.MaxRentTime = Convert.ToInt32(TextBox_MaxRentDays.Text);
                model.Brief = TextBox_Brief.Text;
                model.SmallImage = ProductImages[0];
                model.MediumImage = ProductImages[1];

                model.CategoryID = CategoryID;
                model.CategoryPath = Hidden_CategoryPath.Value;
                model.CreateTime = DateTime.Now;
                model.UpdateTime = DateTime.Now;
                model.Status = (int)RentProductStatus.申请中;

                new RentProductBll().Add(model);

                PageControler.Publish(7, true);

                Response.Redirect("List.aspx");
            }
            else
            {
                MessageBox.Show(this, "图片上传失败!");
            }
        }
        public void Add(RentProductModel model)
        {
            DbCommand Command = dbw.GetStoredProcCommand("UP_mwRentProduct_Add");

            dbw.AddInParameter(Command,"@rentid",DbType.Int32,model.RentID);
            dbw.AddInParameter(Command,"@rentname",DbType.String,model.RentName);
            dbw.AddInParameter(Command,"@smallimage",DbType.String,model.SmallImage);
            dbw.AddInParameter(Command,"@mediumimage",DbType.String,model.MediumImage);
            dbw.AddInParameter(Command,"@stock",DbType.Int32,model.Stock);
            dbw.AddInParameter(Command,"@keywords",DbType.String,model.Keywords);
            dbw.AddInParameter(Command,"@categoryid",DbType.Int32,model.CategoryID);
            dbw.AddInParameter(Command,"@categorypath",DbType.String,model.CategoryPath);
            dbw.AddInParameter(Command,"@rentprice",DbType.Decimal,model.RentPrice);
            dbw.AddInParameter(Command,"@cashpledge",DbType.Decimal,model.CashPledge);
            dbw.AddInParameter(Command,"@maxrenttime",DbType.Int32,model.MaxRentTime);
            dbw.AddInParameter(Command,"@brief",DbType.String,model.Brief);
            dbw.AddInParameter(Command,"@status",DbType.Int16,model.Status);
            dbw.AddInParameter(Command,"@createtime",DbType.DateTime,model.CreateTime);
            dbw.AddInParameter(Command,"@updatetime",DbType.DateTime,model.UpdateTime);

            dbw.ExecuteNonQuery(Command);
        }
 public void Update(RentProductModel model)
 {
     dal.Update(model);
 }
 public void Add(RentProductModel model)
 {
     dal.Add(model);
 }
        private RentProductModel GetModel(DataRow row)
        {
            RentProductModel model = new RentProductModel();

            model.Brief=Convert.ToString(row["brief"]);
            model.CategoryID=Convert.ToInt32(row["categoryid"]);
            model.CategoryPath=Convert.ToString(row["categorypath"]);
            model.CreateTime=Convert.ToDateTime(row["createtime"]);
            model.Keywords=Convert.ToString(row["keywords"]);
            model.MaxRentTime=Convert.ToInt32(row["maxrenttime"]);
            model.MediumImage=Convert.ToString(row["mediumimage"]);
            model.RentID=Convert.ToInt32(row["rentid"]);
            model.RentName=Convert.ToString(row["rentname"]);
            model.RentPrice=Convert.ToDecimal(row["rentprice"]);
            model.CashPledge = Convert.ToDecimal(row["cashpledge"]);
            model.SmallImage=Convert.ToString(row["smallimage"]);
            model.Status=Convert.ToInt16(row["status"]);
            model.Stock=Convert.ToInt32(row["stock"]);
            model.UpdateTime=Convert.ToDateTime(row["updatetime"]);

            return model;
        }