Exemplo n.º 1
0
 private void ShowInfo(int AuctionId)
 {
     NoName.NetShop.BLL.ActionProductModelBll bll   = new NoName.NetShop.BLL.ActionProductModelBll();
     NoName.NetShop.Model.ActionProductModel  model = bll.GetModel(AuctionId);
     this.lblProductName.Text = model.ProductName;
     this.lblSmallIamge.Text  = model.SmallIamge;
     this.lblMediumImage.Text = model.MediumImage;
     this.lblOutLinkUrl.Text  = model.OutLinkUrl;
     this.lblStartPrice.Text  = model.StartPrice.ToString();
     this.lblAddPrices.Text   = model.AddPrices.ToString();
     this.lblCurPrice.Text    = model.CurPrice.ToString();
     this.lblBrief.Text       = model.Brief;
     this.lblStartTime.Text   = model.StartTime.ToString();
     this.lblEndTime.Text     = model.EndTime.ToString();
     this.lblStatus.Text      = model.Status.ToString();
 }
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public NoName.NetShop.Model.ActionProductModel ReaderBind(IDataReader dataReader)
        {
            NoName.NetShop.Model.ActionProductModel model = new NoName.NetShop.Model.ActionProductModel();
            object ojb;

            ojb = dataReader["AuctionId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AuctionId = (int)ojb;
            }
            model.ProductName = dataReader["ProductName"].ToString();
            model.SmallIamge  = dataReader["SmallIamge"].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 = (decimal)ojb;
            }
            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 = (int)ojb;
            }
            return(model);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NoName.NetShop.Model.ActionProductModel GetModel(int AuctionId)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_auActionProduct_GetModel");

            db.AddInParameter(dbCommand, "AuctionId", DbType.Int32, AuctionId);

            NoName.NetShop.Model.ActionProductModel model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(NoName.NetShop.Model.ActionProductModel model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_auActionProduct_Update");

            db.AddInParameter(dbCommand, "AuctionId", DbType.Int32, model.AuctionId);
            db.AddInParameter(dbCommand, "ProductName", DbType.AnsiString, model.ProductName);
            db.AddInParameter(dbCommand, "SmallIamge", DbType.AnsiString, model.SmallIamge);
            db.AddInParameter(dbCommand, "MediumImage", DbType.AnsiString, model.MediumImage);
            db.AddInParameter(dbCommand, "OutLinkUrl", DbType.AnsiString, model.OutLinkUrl);
            db.AddInParameter(dbCommand, "StartPrice", DbType.Decimal, model.StartPrice);
            db.AddInParameter(dbCommand, "AddPrices", DbType.Decimal, model.AddPrices);
            db.AddInParameter(dbCommand, "CurPrice", DbType.Decimal, model.CurPrice);
            db.AddInParameter(dbCommand, "Brief", DbType.AnsiString, model.Brief);
            db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, model.StartTime);
            db.AddInParameter(dbCommand, "EndTime", DbType.DateTime, model.EndTime);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            db.ExecuteNonQuery(dbCommand);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtProductName.Text == "")
            {
                strErr += "ProductName不能为空!\\n";
            }
            if (this.txtSmallIamge.Text == "")
            {
                strErr += "SmallIamge不能为空!\\n";
            }
            if (this.txtMediumImage.Text == "")
            {
                strErr += "MediumImage不能为空!\\n";
            }
            if (this.txtOutLinkUrl.Text == "")
            {
                strErr += "OutLinkUrl不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtStartPrice.Text))
            {
                strErr += "StartPrice不是数字!\\n";
            }
            if (!PageValidate.IsDecimal(txtAddPrices.Text))
            {
                strErr += "AddPrices不是数字!\\n";
            }
            if (!PageValidate.IsDecimal(txtCurPrice.Text))
            {
                strErr += "CurPrice不是数字!\\n";
            }
            if (this.txtBrief.Text == "")
            {
                strErr += "Brief不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtStartTime.Text))
            {
                strErr += "StartTime不是时间格式!\\n";
            }
            if (!PageValidate.IsDateTime(txtEndTime.Text))
            {
                strErr += "EndTime不是时间格式!\\n";
            }
            if (!PageValidate.IsNumber(txtStatus.Text))
            {
                strErr += "Status不是数字!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   ProductName = this.txtProductName.Text;
            string   SmallIamge  = this.txtSmallIamge.Text;
            string   MediumImage = this.txtMediumImage.Text;
            string   OutLinkUrl  = this.txtOutLinkUrl.Text;
            decimal  StartPrice  = decimal.Parse(this.txtStartPrice.Text);
            decimal  AddPrices   = decimal.Parse(this.txtAddPrices.Text);
            decimal  CurPrice    = decimal.Parse(this.txtCurPrice.Text);
            string   Brief       = this.txtBrief.Text;
            DateTime StartTime   = DateTime.Parse(this.txtStartTime.Text);
            DateTime EndTime     = DateTime.Parse(this.txtEndTime.Text);
            int      Status      = int.Parse(this.txtStatus.Text);


            NoName.NetShop.Model.ActionProductModel model = new NoName.NetShop.Model.ActionProductModel();
            model.ProductName = ProductName;
            model.SmallIamge  = SmallIamge;
            model.MediumImage = MediumImage;
            model.OutLinkUrl  = OutLinkUrl;
            model.StartPrice  = StartPrice;
            model.AddPrices   = AddPrices;
            model.CurPrice    = CurPrice;
            model.Brief       = Brief;
            model.StartTime   = StartTime;
            model.EndTime     = EndTime;
            model.Status      = Status;

            NoName.NetShop.BLL.ActionProductModelBll bll = new NoName.NetShop.BLL.ActionProductModelBll();
            bll.Update(model);
        }
Exemplo n.º 6
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(this.txtProductName.Text =="")
            {
            strErr+="ProductName����Ϊ�գ�\\n";
            }
            if(this.txtSmallIamge.Text =="")
            {
            strErr+="SmallIamge����Ϊ�գ�\\n";
            }
            if(this.txtMediumImage.Text =="")
            {
            strErr+="MediumImage����Ϊ�գ�\\n";
            }
            if(this.txtOutLinkUrl.Text =="")
            {
            strErr+="OutLinkUrl����Ϊ�գ�\\n";
            }
            if(!PageValidate.IsDecimal(txtStartPrice.Text))
            {
            strErr+="StartPrice�������֣�\\n";
            }
            if(!PageValidate.IsDecimal(txtAddPrices.Text))
            {
            strErr+="AddPrices�������֣�\\n";
            }
            if(!PageValidate.IsDecimal(txtCurPrice.Text))
            {
            strErr+="CurPrice�������֣�\\n";
            }
            if(this.txtBrief.Text =="")
            {
            strErr+="Brief����Ϊ�գ�\\n";
            }
            if(!PageValidate.IsDateTime(txtStartTime.Text))
            {
            strErr+="StartTime����ʱ���ʽ��\\n";
            }
            if(!PageValidate.IsDateTime(txtEndTime.Text))
            {
            strErr+="EndTime����ʱ���ʽ��\\n";
            }
            if(!PageValidate.IsNumber(txtStatus.Text))
            {
            strErr+="Status�������֣�\\n";
            }

            if(strErr!="")
            {
            MessageBox.Show(this,strErr);
            return;
            }
            string ProductName=this.txtProductName.Text;
            string SmallIamge=this.txtSmallIamge.Text;
            string MediumImage=this.txtMediumImage.Text;
            string OutLinkUrl=this.txtOutLinkUrl.Text;
            decimal StartPrice=decimal.Parse(this.txtStartPrice.Text);
            decimal AddPrices=decimal.Parse(this.txtAddPrices.Text);
            decimal CurPrice=decimal.Parse(this.txtCurPrice.Text);
            string Brief=this.txtBrief.Text;
            DateTime StartTime=DateTime.Parse(this.txtStartTime.Text);
            DateTime EndTime=DateTime.Parse(this.txtEndTime.Text);
            int Status=int.Parse(this.txtStatus.Text);

            NoName.NetShop.Model.ActionProductModel model=new NoName.NetShop.Model.ActionProductModel();
            model.ProductName=ProductName;
            model.SmallIamge=SmallIamge;
            model.MediumImage=MediumImage;
            model.OutLinkUrl=OutLinkUrl;
            model.StartPrice=StartPrice;
            model.AddPrices=AddPrices;
            model.CurPrice=CurPrice;
            model.Brief=Brief;
            model.StartTime=StartTime;
            model.EndTime=EndTime;
            model.Status=Status;

            NoName.NetShop.BLL.ActionProductModelBll bll=new NoName.NetShop.BLL.ActionProductModelBll();
            bll.Add(model);
        }
 /// <summary>
 /// ����ʵ�������
 /// </summary>
 public NoName.NetShop.Model.ActionProductModel ReaderBind(IDataReader dataReader)
 {
     NoName.NetShop.Model.ActionProductModel model=new NoName.NetShop.Model.ActionProductModel();
     object ojb;
     ojb = dataReader["AuctionId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.AuctionId=(int)ojb;
     }
     model.ProductName=dataReader["ProductName"].ToString();
     model.SmallIamge=dataReader["SmallIamge"].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=(decimal)ojb;
     }
     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=(int)ojb;
     }
     return model;
 }