public void Update(DemandProductModel model)
        {
            DbCommand Command = dbw.GetStoredProcCommand("UP_mwDemand_Update");

            dbw.AddInParameter(Command,"@demandid",DbType.Int32,model.DemandID);
            dbw.AddInParameter(Command,"@demandname",DbType.String,model.DemandName);
            dbw.AddInParameter(Command,"@smallimage",DbType.String,model.SmallImage);
            dbw.AddInParameter(Command,"@mediumimage",DbType.String,model.MediumImage);
            dbw.AddInParameter(Command,"@categoryid",DbType.Int32,model.CategoryID);
            dbw.AddInParameter(Command,"@categorypath",DbType.String,model.CategoryPath);
            dbw.AddInParameter(Command,"@price",DbType.Decimal,model.Price);
            dbw.AddInParameter(Command,"@count",DbType.Int32,model.Count);
            dbw.AddInParameter(Command,"@usagecondition",DbType.Int16,model.UsageCondition);
            dbw.AddInParameter(Command,"@expirationtime",DbType.DateTime,model.ExpirationTime);
            dbw.AddInParameter(Command,"@brief",DbType.String,model.Brief);
            dbw.AddInParameter(Command,"@userid",DbType.String,model.UserID);
            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.AddInParameter(Command,"@status",DbType.Int16,model.Status);
            dbw.AddInParameter(Command,"@inserttime",DbType.DateTime,model.InsertTime);
            dbw.AddInParameter(Command,"@updatetime",DbType.DateTime,model.UpdateTime);

            dbw.ExecuteNonQuery(Command);
        }
 public void Update(DemandProductModel model)
 {
     dal.Update(model);
 }
 public void Add(DemandProductModel model)
 {
     dal.Add(model);
 }
Пример #4
0
        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_Price.Text) || !PageValidate.IsDecimal(TextBox_Price.Text)) { ErrorMessage += "请输入正确的产品价格\\n"; }
            if (String.IsNullOrEmpty(TextBox_Count.Text) || !PageValidate.IsNumber(TextBox_Count.Text)) { ErrorMessage += "请输入正确的产品数量\\n"; }
            if (String.IsNullOrEmpty(TextBox_ExpireTime.Text) || !PageValidate.IsDate(TextBox_ExpireTime.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)/* validate */) { 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;
            }

            DemandProductModel model = new DemandProductModel();
            MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID);
            int DemandID = CommDataHelper.GetNewSerialNum(AppType.MagicWorld);
            string[] ProductImages;
            if (MagicWorldImageRule.SaveProductMainImage(DemandID, FileUpload_ProductImage.PostedFile, out ProductImages))
            {
                model.DemandID = DemandID;
                model.DemandName = StringUtility.RemoveHtmlTags(TextBox_ProductName.Text);
                model.Address = TextBox_Address.Text;
                model.Brief = TextBox_Brief.Text ;
                model.CategoryID = CategoryID;
                model.CategoryPath = cate.CategoryPath;
                model.CellPhone = TextBox_CellPhone.Text;
                model.Count = Convert.ToInt32(TextBox_Count.Text);
                model.ExpirationTime = Convert.ToDateTime(TextBox_ExpireTime.Text);
                model.InsertTime = DateTime.Now;
                model.SmallImage = ProductImages[0];
                model.MediumImage = ProductImages[1];
                model.Phone = TextBox_Phone.Text;
                model.PostCode = TextBox_PostCode.Text;
                model.Price = Convert.ToDecimal(TextBox_Price.Text);
                model.Region = String.Format("{0} {1} {2}", regionInfo.Province, regionInfo.City, regionInfo.County);
                model.Status = (int)DemandProductStatus.尚未审核;
                model.TrueName = TextBox_TrueName.Text;
                model.UpdateTime = DateTime.Now;
                model.UsageCondition = Convert.ToInt32(DropDown_Usage.SelectedValue);
                model.UserID = GetUserID();

                bll.Add(model);
                Response.Redirect("../SubmitSucc.aspx");
            }
            else
            {
                MessageBox.Show(this, "图片上传失败");
            }
        }