public void Add(SecondhandProductModel model)
        {
            DbCommand Command = dbw.GetStoredProcCommand("UP_mwSecondhandProduct_ADD");

            dbw.AddInParameter(Command, "@SeProductID", DbType.Int32, model.SecondhandProductID);
            dbw.AddInParameter(Command, "@SeProductName", DbType.String, model.SecondhandProductName);
            dbw.AddInParameter(Command, "@SmallImage", DbType.String, model.SmallImage);
            dbw.AddInParameter(Command, "@MediumImage", DbType.String, model.MediumImage);
            dbw.AddInParameter(Command, "@CateID", DbType.Int32, model.CateID);
            dbw.AddInParameter(Command, "@CatePath", DbType.String, model.CatePath);
            dbw.AddInParameter(Command, "@Price", DbType.Decimal, model.Price);
            dbw.AddInParameter(Command, "@Stock", DbType.Int32, model.Stock);
            dbw.AddInParameter(Command, "@usagecondition", DbType.Int32, model.UsageCondition);
            dbw.AddInParameter(Command, "@Brief", DbType.String, model.Brief);
            dbw.AddInParameter(Command, "@UserID", DbType.String, model.UserID);
            dbw.AddInParameter(Command, "@Status", DbType.Int32, model.Status);
            dbw.AddInParameter(Command, "@SortValue", DbType.Int32, model.SortValue);
            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, "@InsertTime", DbType.DateTime, model.InsertTime);
            dbw.AddInParameter(Command, "@UpdateTime", DbType.DateTime, model.UpdateTime);

            dbw.ExecuteNonQuery(Command);
        }
 public void Update(SecondhandProductModel model)
 {
     dal.Update(model);
 }
 public void Add(SecondhandProductModel model)
 {
     dal.Add(model);
 }
Ejemplo n.º 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_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;
            }

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

            string[] ProductImages;

            if (MagicWorldImageRule.SaveProductMainImage(SecondhandProductID, FileUpload_ProductImage.PostedFile, out ProductImages))
            {
                SecondhandProductModel model = new SecondhandProductModel();
                MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID);

                model.SecondhandProductID = SecondhandProductID;
                model.SecondhandProductName = StringUtility.RemoveHtmlTags(TextBox_ProductName.Text);
                model.CateID = CategoryID;
                model.CatePath = cate.CategoryPath;
                model.Price = Convert.ToDecimal(TextBox_Price.Text);
                model.SmallImage = ProductImages[0];
                model.MediumImage = ProductImages[1];
                model.UsageCondition = Convert.ToInt32(DropDown_Usage.SelectedValue);
                model.Stock = Convert.ToInt32(TextBox_Count.Text);
                model.Brief = TextBox_Brief.Text;

                model.InsertTime = DateTime.Now;
                model.UpdateTime = 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.Status = (int)SecondhandProductStatus.尚未审核;
                model.SortValue = SecondhandProductID;

                bll.Add(model);

                Response.Redirect("../SubmitSucc.aspx");
            }
            else
            {
                MessageBox.Show(this,"图片上传失败");
            }
        }
        private SecondhandProductModel BindModel(DataRow row)
        {
            SecondhandProductModel model = new SecondhandProductModel()
            {
                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"]),
                InsertTime = Convert.ToDateTime(row["InsertTime"]),
                MediumImage = Convert.ToString(row["MediumImage"]),
                Phone = Convert.ToString(row["Phone"]),
                PostCode = Convert.ToString(row["PostCode"]),
                Price = Convert.ToDecimal(row["Price"]),
                Region = Convert.ToString(row["region"]),
                SecondhandProductID = Convert.ToInt32(row["SeProductID"]),
                SecondhandProductName = Convert.ToString(row["SeProductName"]),
                SmallImage = Convert.ToString(row["SmallImage"]),
                SortValue = Convert.ToInt32(row["SortValue"]),
                Status = Convert.ToInt32(row["Status"]),
                Stock = Convert.ToInt32(row["Stock"]),
                TrueName = Convert.ToString(row["truename"]),
                UpdateTime = Convert.ToDateTime(row["UpdateTime"]),
                UsageCondition = Convert.ToInt32(row["usagecondition"]),
                UserID = Convert.ToString(row["UserID"])
            };

            return model;
        }