public void Add(PawnProductModel model) { DbCommand command = dbw.GetStoredProcCommand("UP_mwPawnProduct_Insert"); dbw.AddInParameter(command, "@pawnproductid", DbType.Int32, model.PawnProductID); dbw.AddInParameter(command, "@pawnproductname", DbType.String, model.PawnProductName); dbw.AddInParameter(command, "@pawnprice", DbType.Decimal, model.PawnPrice); dbw.AddInParameter(command, "@sellingprice", DbType.Decimal, model.SellingPrice); dbw.AddInParameter(command, "@cateid", DbType.Int32, model.CateID); dbw.AddInParameter(command, "@catepath", DbType.String, model.CatePath); dbw.AddInParameter(command, "@stock", DbType.Int32, model.Stock); dbw.AddInParameter(command, "@smallimage", DbType.String, model.SmallImage); dbw.AddInParameter(command, "@mediumimage", DbType.String, model.MediumImage); dbw.AddInParameter(command, "@brief", DbType.String, model.Brief); dbw.AddInParameter(command, "@inserttime", DbType.DateTime, model.InsertTime); dbw.AddInParameter(command, "@changetime", DbType.DateTime, model.ChangeTime); dbw.AddInParameter(command, "@status", DbType.Int32, model.Status); dbw.AddInParameter(command, "@sortvalue", DbType.Int32, model.SortValue); dbw.AddInParameter(command, "@userid", DbType.String, model.UserID); dbw.AddInParameter(command, "@deadtime", DbType.DateTime, model.DeadTime); dbw.AddInParameter(command, "@truename", DbType.String, model.TrueName); dbw.AddInParameter(command, "@phone", DbType.String, model.Phone); dbw.AddInParameter(command, "@cellphone", DbType.String, model.CellPhone); dbw.AddInParameter(command, "@postcode", DbType.String, model.PostCode); dbw.AddInParameter(command, "@region", DbType.String, model.Region); dbw.AddInParameter(command, "@address", DbType.String, model.Address); dbw.ExecuteNonQuery(command); }
protected void Button_Add_Click(object sender, EventArgs e) { string ErrorMessage = String.Empty; if (String.IsNullOrEmpty(TextBox_ProductName.Text)) { ErrorMessage += "产品名称不能为空\\n"; } if (String.IsNullOrEmpty(FileUpload_ProductImage.FileName)) { ErrorMessage += "产品图片不能为空\\n"; } if (String.IsNullOrEmpty(TextBox_EndTime.Text/* validate */)) { ErrorMessage += "绝当时间不能为空\\n"; } if (String.IsNullOrEmpty(TextBox_Price.Text) || !PageValidate.IsDecimal(TextBox_Price.Text)) { ErrorMessage += "典当价格不正确\\n"; } if (String.IsNullOrEmpty(TextBox_Brief.Text)) { ErrorMessage += "简要介绍不能为空\\n"; } if (String.IsNullOrEmpty(TextBox_TrueName.Text)) { ErrorMessage += "姓名不能为空\\n"; } if (String.IsNullOrEmpty(TextBox_Phone.Text) && String.IsNullOrEmpty(TextBox_CellPhone.Text)) { ErrorMessage += "请输入您的电话号码或者手机号码\\n"; } else { /* validate */} if (String.IsNullOrEmpty(TextBox_PostCode.Text) || !PageValidate.IsNumber(TextBox_PostCode.Text)) { ErrorMessage += "邮政编码不能为空\\n"; } if (String.IsNullOrEmpty(TextBox_Address.Text)) { ErrorMessage += "地址不能为空\\n"; } RegionInfo regionInfo = ucRegion.GetSelectedRegionInfo(); if (String.IsNullOrEmpty(regionInfo.Province) || String.IsNullOrEmpty(regionInfo.City)) { ErrorMessage += "所在地选择不完整\\n"; } if (!String.IsNullOrEmpty(ErrorMessage)) { MessageBox.Show(this, ErrorMessage); return; } int PawnProductID = CommDataHelper.GetNewSerialNum(AppType.MagicWorld); string[] ProductImages; if (MagicWorldImageRule.SaveProductMainImage(PawnProductID, FileUpload_ProductImage.PostedFile, out ProductImages)) { PawnProductModel model = new PawnProductModel(); MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID); model.PawnProductID = PawnProductID; model.PawnProductName = StringUtility.RemoveHtmlTags(TextBox_ProductName.Text); model.CateID = CategoryID; model.CatePath = cate.CategoryPath; model.PawnPrice = Convert.ToDecimal(TextBox_Price.Text); model.Stock = 1; model.Brief = TextBox_Brief.Text; model.SmallImage = ProductImages[0]; model.MediumImage = ProductImages[1]; model.SellingPrice = 0; model.DeadTime = Convert.ToDateTime(TextBox_EndTime.Text); model.InsertTime = DateTime.Now; model.ChangeTime = DateTime.Now; model.UserID = GetUserID(); model.TrueName = TextBox_TrueName.Text; model.CellPhone = TextBox_CellPhone.Text; model.Phone = TextBox_Phone.Text; model.PostCode = TextBox_PostCode.Text; model.Region = String.Format("{0} {1} {2}", regionInfo.Province, regionInfo.City, regionInfo.County); model.Address = TextBox_Address.Text; model.SortValue = PawnProductID; model.Status = (int)PawnProductStatus.尚未收当; bll.Add(model); Response.Redirect("../SubmitSucc.aspx"); } else { MessageBox.Show(this, "图片上传失败"); } }
public void Update(PawnProductModel model) { dal.Update(model); }
public void Add(PawnProductModel model) { dal.Add(model); }
private PawnProductModel BindModel(DataRow row) { PawnProductModel model = new PawnProductModel() { Address = Convert.ToString(row["address"]), Brief = Convert.ToString(row["brief"]), CateID = Convert.ToInt32(row["cateid"]), CatePath = Convert.ToString(row["catepath"]), CellPhone = Convert.ToString(row["cellphone"]), ChangeTime = Convert.ToDateTime(row["changetime"]), DeadTime = Convert.ToDateTime(row["deadtime"]), InsertTime = Convert.ToDateTime(row["inserttime"]), MediumImage = Convert.ToString(row["mediumimage"]), PawnPrice = Convert.ToDecimal(row["pawnprice"]), PawnProductID = Convert.ToInt32(row["pawnproductid"]), PawnProductName = Convert.ToString(row["pawnproductname"]), Phone = Convert.ToString(row["phone"]), PostCode = Convert.ToString(row["postcode"]), Region = Convert.ToString(row["region"]), SellingPrice = Convert.ToInt32(row["sellingprice"]), SmallImage = Convert.ToString(row["smallimage"]), SortValue = Convert.ToInt32(row["sortvalue"]), Status = Convert.ToInt16(row["status"]), Stock = Convert.ToInt32(row["stock"]), TrueName = Convert.ToString(row["truename"]), UserID = Convert.ToString(row["userid"]) }; return model; }