/// <summary>
        ///  增加一条数据
        /// </summary>
        public void Add(AuctionProductModel model)
        {
            DbCommand dbCommand = dbw.GetStoredProcCommand("UP_mwAuctionProduct_ADD");

            dbw.AddInParameter(dbCommand, "@AuctionId", DbType.Int32, model.AuctionID);
            dbw.AddInParameter(dbCommand, "@ProductName", DbType.AnsiString, model.ProductName);
            dbw.AddInParameter(dbCommand, "@SmallImage", DbType.AnsiString, model.SmallImage);
            dbw.AddInParameter(dbCommand, "@MediumImage", DbType.AnsiString, model.MediumImage);
            dbw.AddInParameter(dbCommand, "@OutLinkUrl", DbType.AnsiString, model.OutLinkUrl);
            dbw.AddInParameter(dbCommand, "@StartPrice", DbType.Decimal, model.StartPrice);
            dbw.AddInParameter(dbCommand, "@AddPrices", DbType.String, model.AddPrices);
            dbw.AddInParameter(dbCommand, "@CurPrice", DbType.Decimal, model.CurPrice);
            dbw.AddInParameter(dbCommand, "@Brief", DbType.AnsiString, model.Brief);
            dbw.AddInParameter(dbCommand, "@StartTime", DbType.DateTime, model.StartTime);
            dbw.AddInParameter(dbCommand, "@EndTime", DbType.DateTime, model.EndTime);
            dbw.AddInParameter(dbCommand, "@Status", DbType.Byte, model.Status);
            dbw.AddInParameter(dbCommand, "@CateID", DbType.Int32, model.CategoryID);
            dbw.AddInParameter(dbCommand, "@CatePath", DbType.String, model.CategoryPath);
            dbw.AddInParameter(dbCommand, "@userid", DbType.String, model.UserID);
            dbw.AddInParameter(dbCommand, "@truename", DbType.String, model.TrueName);
            dbw.AddInParameter(dbCommand, "@phone", DbType.String, model.Phone);
            dbw.AddInParameter(dbCommand, "@cellphone", DbType.String, model.CellPhone);
            dbw.AddInParameter(dbCommand, "@postcode", DbType.String, model.PostCode);
            dbw.AddInParameter(dbCommand, "@region", DbType.String, model.Region);
            dbw.AddInParameter(dbCommand, "@address", DbType.String, model.Address);
            dbw.AddInParameter(dbCommand, "@inserttime", DbType.String, model.InsertTime);
            dbw.AddInParameter(dbCommand, "@updatetime", DbType.String, model.UpdateTime);

            dbw.ExecuteNonQuery(dbCommand);
        }
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public AuctionProductModel ReaderBind(IDataReader dataReader)
        {
            AuctionProductModel model=new AuctionProductModel();
            object ojb;
            ojb = dataReader["AuctionId"];
            if(ojb != null && ojb != DBNull.Value)
            {
                model.AuctionID=(int)ojb;
            }
            model.ProductName=dataReader["ProductName"].ToString();
            model.SmallImage=dataReader["SmallImage"].ToString();
            model.MediumImage=dataReader["MediumImage"].ToString();
            model.OutLinkUrl=dataReader["OutLinkUrl"].ToString();
            ojb = dataReader["StartPrice"];
            if(ojb != null && ojb != DBNull.Value)
            {
                model.StartPrice=(decimal)ojb;
            }
            ojb = dataReader["AddPrices"];
            if(ojb != null && ojb != DBNull.Value)
            {
                model.AddPrices=ojb.ToString();
            }
            ojb = dataReader["CurPrice"];
            if(ojb != null && ojb != DBNull.Value)
            {
                model.CurPrice=(decimal)ojb;
            }
            model.Brief=dataReader["Brief"].ToString();
            ojb = dataReader["StartTime"];
            if(ojb != null && ojb != DBNull.Value)
            {
                model.StartTime=(DateTime)ojb;
            }
            ojb = dataReader["EndTime"];
            if(ojb != null && ojb != DBNull.Value)
            {
                model.EndTime=(DateTime)ojb;
            }
            ojb = dataReader["Status"];
            if(ojb != null && ojb != DBNull.Value)
            {
                model.Status=Convert.ToInt32(ojb);
            }
            ojb = dataReader["cateid"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CategoryID = Convert.ToInt32(ojb);
            }
            ojb = dataReader["catepath"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CategoryPath = Convert.ToString(ojb);
            }

            model.UserID = Convert.ToString(dataReader["userid"]);
            model.TrueName = Convert.ToString(dataReader["truename"]);
            model.Phone = Convert.ToString(dataReader["phone"]);
            model.CellPhone = Convert.ToString(dataReader["cellphone"]);
            model.PostCode = Convert.ToString(dataReader["postcode"]);
            model.Region = Convert.ToString(dataReader["region"]);
            model.Address = Convert.ToString(dataReader["address"]);
            model.InsertTime = Convert.ToDateTime(dataReader["inserttime"]);
            model.UpdateTime = Convert.ToDateTime(dataReader["updatetime"]);
            return model;
        }
        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_StartPrice.Text) || !PageValidate.IsDecimal(TextBox_StartPrice.Text)) { ErrorMessage += "起始价格不正确\\n"; }
            if (String.IsNullOrEmpty(TextBox_AddPrices.Text))
            {
                ErrorMessage += "每次加价不能为空\\n";
            }
            else
            {
                if (TextBox_AddPrices.Text.Replace(',', ',').Split(',').Length > 7)
                {
                    ErrorMessage += "最多只能输入7个加价\\n";
                }
            }
            if (String.IsNullOrEmpty(TextBox_StartTime.Text)/* validate */) { ErrorMessage += "开始时间不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_EndTime.Text)/* validate */) { 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 AuctionID = CommDataHelper.GetNewSerialNum(AppType.MagicWorld);

            string[] ProductImages;
            if (MagicWorldImageRule.SaveProductMainImage(AuctionID, FileUpload_ProductImage.PostedFile, out ProductImages))
            {
                AuctionProductModel model = new AuctionProductModel();
                MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID);

                model.AuctionID = AuctionID;
                model.ProductName = StringUtility.RemoveHtmlTags(TextBox_ProductName.Text);
                model.CategoryID = CategoryID;
                model.CategoryPath = cate.CategoryPath;
                model.SmallImage = ProductImages[0];
                model.MediumImage = ProductImages[1];
                model.StartPrice = Convert.ToDecimal(TextBox_StartPrice.Text);
                model.CurPrice = model.StartPrice;
                model.AddPrices = TextBox_AddPrices.Text.Replace(',', ',').EndsWith(",") ? TextBox_AddPrices.Text.Replace(',', ',').Substring(0, TextBox_AddPrices.Text.Length - 1) : TextBox_AddPrices.Text.Replace(',', ',');
                model.StartTime = Convert.ToDateTime(TextBox_StartTime.Text);
                model.EndTime = Convert.ToDateTime(TextBox_EndTime.Text);
                model.Brief = TextBox_Brief.Text;
                model.InsertTime = DateTime.Now;
                model.UpdateTime = DateTime.Now;

                model.UserID = GetUserID();
                model.TrueName = TextBox_TrueName.Text;
                model.Phone = TextBox_Phone.Text;
                model.CellPhone = TextBox_CellPhone.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)AuctionProductStatus.尚未审核;
                model.OutLinkUrl = "";

                bll.Add(model);
                Response.Redirect("../SubmitSucc.aspx");
            }
            else
            {
                MessageBox.Show(this, "图片上传失败");
            }
        }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(AuctionProductModel model)
 {
     dal.Add(model);
 }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(AuctionProductModel model)
 {
     dal.Update(model);
 }
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<AuctionProductModel> GetModelList(string strWhere)
 {
     DataSet ds = dal.GetList(strWhere);
     List<AuctionProductModel> modelList = new List<AuctionProductModel>();
     int rowsCount = ds.Tables[0].Rows.Count;
     if (rowsCount > 0)
     {
         AuctionProductModel model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new AuctionProductModel();
             if(ds.Tables[0].Rows[n]["AuctionId"].ToString()!="")
             {
                 model.AuctionID=int.Parse(ds.Tables[0].Rows[n]["AuctionId"].ToString());
             }
             model.ProductName=ds.Tables[0].Rows[n]["ProductName"].ToString();
             model.SmallImage=ds.Tables[0].Rows[n]["SmallImage"].ToString();
             model.MediumImage=ds.Tables[0].Rows[n]["MediumImage"].ToString();
             model.OutLinkUrl=ds.Tables[0].Rows[n]["OutLinkUrl"].ToString();
             if(ds.Tables[0].Rows[n]["StartPrice"].ToString()!="")
             {
                 model.StartPrice=decimal.Parse(ds.Tables[0].Rows[n]["StartPrice"].ToString());
             }
             if(ds.Tables[0].Rows[n]["AddPrices"].ToString()!="")
             {
                 model.AddPrices= ds.Tables[0].Rows[n]["AddPrices"].ToString();
             }
             if(ds.Tables[0].Rows[n]["CurPrice"].ToString()!="")
             {
                 model.CurPrice=decimal.Parse(ds.Tables[0].Rows[n]["CurPrice"].ToString());
             }
             model.Brief=ds.Tables[0].Rows[n]["Brief"].ToString();
             if(ds.Tables[0].Rows[n]["StartTime"].ToString()!="")
             {
                 model.StartTime=DateTime.Parse(ds.Tables[0].Rows[n]["StartTime"].ToString());
             }
             if(ds.Tables[0].Rows[n]["EndTime"].ToString()!="")
             {
                 model.EndTime=DateTime.Parse(ds.Tables[0].Rows[n]["EndTime"].ToString());
             }
             if(ds.Tables[0].Rows[n]["Status"].ToString()!="")
             {
                 model.Status=int.Parse(ds.Tables[0].Rows[n]["Status"].ToString());
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }