private void ShowInfo(int BrandId) { NoName.NetShop.BLL.BrandModelBll bll = new NoName.NetShop.BLL.BrandModelBll(); NoName.NetShop.Model.BrandModel model = bll.GetModel(BrandId); this.lblBrandName.Text = model.BrandName; this.lblCateId.Text = model.CateId.ToString(); this.lblCatePath.Text = model.CatePath; this.lblBrandLogo.Text = model.BrandLogo; this.lblBrief.Text = model.Brief; }
/// <summary> /// 更新一条数据 /// </summary> public void Update(NoName.NetShop.Model.BrandModel model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("UP_pdBrand_Update"); db.AddInParameter(dbCommand, "BrandId", DbType.Int32, model.BrandId); db.AddInParameter(dbCommand, "BrandName", DbType.AnsiString, model.BrandName); db.AddInParameter(dbCommand, "CateId", DbType.Int32, model.CateId); db.AddInParameter(dbCommand, "CatePath", DbType.AnsiString, model.CatePath); db.AddInParameter(dbCommand, "BrandLogo", DbType.AnsiString, model.BrandLogo); db.AddInParameter(dbCommand, "Brief", DbType.AnsiString, model.Brief); db.ExecuteNonQuery(dbCommand); }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtBrandName.Text == "") { strErr += "BrandName不能为空!\\n"; } if (!PageValidate.IsNumber(txtCateId.Text)) { strErr += "CateId不是数字!\\n"; } if (this.txtCatePath.Text == "") { strErr += "CatePath不能为空!\\n"; } if (this.txtBrandLogo.Text == "") { strErr += "BrandLogo不能为空!\\n"; } if (this.txtBrief.Text == "") { strErr += "Brief不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string BrandName = this.txtBrandName.Text; int CateId = int.Parse(this.txtCateId.Text); string CatePath = this.txtCatePath.Text; string BrandLogo = this.txtBrandLogo.Text; string Brief = this.txtBrief.Text; NoName.NetShop.Model.BrandModel model = new NoName.NetShop.Model.BrandModel(); model.BrandName = BrandName; model.CateId = CateId; model.CatePath = CatePath; model.BrandLogo = BrandLogo; model.Brief = Brief; NoName.NetShop.BLL.BrandModelBll bll = new NoName.NetShop.BLL.BrandModelBll(); bll.Update(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public NoName.NetShop.Model.BrandModel GetModel(int BrandId) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("UP_pdBrand_GetModel"); db.AddInParameter(dbCommand, "BrandId", DbType.Int32, BrandId); NoName.NetShop.Model.BrandModel 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.txtBrandName.Text =="") { strErr+="BrandName����Ϊ�գ�\\n"; } if(!PageValidate.IsNumber(txtCateId.Text)) { strErr+="CateId�������֣�\\n"; } if(this.txtCatePath.Text =="") { strErr+="CatePath����Ϊ�գ�\\n"; } if(this.txtBrandLogo.Text =="") { strErr+="BrandLogo����Ϊ�գ�\\n"; } if(this.txtBrief.Text =="") { strErr+="Brief����Ϊ�գ�\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } string BrandName=this.txtBrandName.Text; int CateId=int.Parse(this.txtCateId.Text); string CatePath=this.txtCatePath.Text; string BrandLogo=this.txtBrandLogo.Text; string Brief=this.txtBrief.Text; NoName.NetShop.Model.BrandModel model=new NoName.NetShop.Model.BrandModel(); model.BrandName=BrandName; model.CateId=CateId; model.CatePath=CatePath; model.BrandLogo=BrandLogo; model.Brief=Brief; NoName.NetShop.BLL.BrandModelBll bll=new NoName.NetShop.BLL.BrandModelBll(); bll.Update(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public NoName.NetShop.Model.BrandModel ReaderBind(IDataReader dataReader) { NoName.NetShop.Model.BrandModel model = new NoName.NetShop.Model.BrandModel(); object ojb; ojb = dataReader["BrandId"]; if (ojb != null && ojb != DBNull.Value) { model.BrandId = (int)ojb; } model.BrandName = dataReader["BrandName"].ToString(); ojb = dataReader["CateId"]; if (ojb != null && ojb != DBNull.Value) { model.CateId = (int)ojb; } model.CatePath = dataReader["CatePath"].ToString(); model.BrandLogo = dataReader["BrandLogo"].ToString(); model.Brief = dataReader["Brief"].ToString(); return(model); }
/// <summary> /// ����ʵ������� /// </summary> public NoName.NetShop.Model.BrandModel ReaderBind(IDataReader dataReader) { NoName.NetShop.Model.BrandModel model=new NoName.NetShop.Model.BrandModel(); object ojb; ojb = dataReader["BrandId"]; if(ojb != null && ojb != DBNull.Value) { model.BrandId=(int)ojb; } model.BrandName=dataReader["BrandName"].ToString(); ojb = dataReader["CateId"]; if(ojb != null && ojb != DBNull.Value) { model.CateId=(int)ojb; } model.CatePath=dataReader["CatePath"].ToString(); model.BrandLogo=dataReader["BrandLogo"].ToString(); model.Brief=dataReader["Brief"].ToString(); return model; }