Esempio n. 1
0
 private void ShowInfo(int ProductId)
 {
     NoName.NetShop.BLL.ProductExtModelBll bll   = new NoName.NetShop.BLL.ProductExtModelBll();
     NoName.NetShop.Model.ProductExtModel  model = bll.GetModel(ProductId);
     this.lblProductId.Text   = model.ProductId.ToString();
     this.txtProductDesc.Text = model.ProductDesc;
 }
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(NoName.NetShop.Model.ProductExtModel model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_pdProductExt_Update");

            db.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId);
            db.AddInParameter(dbCommand, "ProductDesc", DbType.String, model.ProductDesc);
            db.ExecuteNonQuery(dbCommand);
        }
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public NoName.NetShop.Model.ProductExtModel ReaderBind(IDataReader dataReader)
        {
            NoName.NetShop.Model.ProductExtModel model = new NoName.NetShop.Model.ProductExtModel();
            object ojb;

            ojb = dataReader["ProductId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ProductId = (int)ojb;
            }
            model.ProductDesc = dataReader["ProductDesc"].ToString();
            return(model);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NoName.NetShop.Model.ProductExtModel GetModel(int ProductId)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_pdProductExt_GetModel");

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

            NoName.NetShop.Model.ProductExtModel model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(this.txtProductDesc.Text =="")
            {
            strErr+="ProductDesc����Ϊ�գ�\\n";
            }

            if(strErr!="")
            {
            MessageBox.Show(this,strErr);
            return;
            }
            string ProductDesc=this.txtProductDesc.Text;

            NoName.NetShop.Model.ProductExtModel model=new NoName.NetShop.Model.ProductExtModel();
            model.ProductDesc=ProductDesc;

            NoName.NetShop.BLL.ProductExtModelBll bll=new NoName.NetShop.BLL.ProductExtModelBll();
            bll.Add(model);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtProductDesc.Text == "")
            {
                strErr += "ProductDesc不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string ProductDesc = this.txtProductDesc.Text;

            NoName.NetShop.Model.ProductExtModel model = new NoName.NetShop.Model.ProductExtModel();
            model.ProductDesc = ProductDesc;

            NoName.NetShop.BLL.ProductExtModelBll bll = new NoName.NetShop.BLL.ProductExtModelBll();
            bll.Add(model);
        }
 /// <summary>
 /// ����ʵ�������
 /// </summary>
 public NoName.NetShop.Model.ProductExtModel ReaderBind(IDataReader dataReader)
 {
     NoName.NetShop.Model.ProductExtModel model=new NoName.NetShop.Model.ProductExtModel();
     object ojb;
     ojb = dataReader["ProductId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.ProductId=(int)ojb;
     }
     model.ProductDesc=dataReader["ProductDesc"].ToString();
     return model;
 }