/// <summary> /// 对象实体绑定数据 /// </summary> public NoName.NetShop.Model.SuitProductModel ReaderBind(IDataReader dataReader) { NoName.NetShop.Model.SuitProductModel model = new NoName.NetShop.Model.SuitProductModel(); object ojb; ojb = dataReader["SuitProductId"]; if (ojb != null && ojb != DBNull.Value) { model.SuitProductId = (int)ojb; } ojb = dataReader["ProductId"]; if (ojb != null && ojb != DBNull.Value) { model.ProductId = (int)ojb; } model.SuitName = dataReader["SuitName"].ToString(); ojb = dataReader["MerchantPrice"]; if (ojb != null && ojb != DBNull.Value) { model.MerchantPrice = (decimal)ojb; } ojb = dataReader["TradePrice"]; if (ojb != null && ojb != DBNull.Value) { model.TradePrice = (decimal)ojb; } ojb = dataReader["Status"]; if (ojb != null && ojb != DBNull.Value) { model.Status = (int)ojb; } return(model); }
private void ShowInfo(int SuitProductId) { NoName.NetShop.BLL.SuitProductModelBll bll = new NoName.NetShop.BLL.SuitProductModelBll(); NoName.NetShop.Model.SuitProductModel model = bll.GetModel(SuitProductId); this.lblProductId.Text = model.ProductId.ToString(); this.lblSuitName.Text = model.SuitName; this.lblMerchantPrice.Text = model.MerchantPrice.ToString(); this.lblTradePrice.Text = model.TradePrice.ToString(); this.lblStatus.Text = model.Status.ToString(); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(NoName.NetShop.Model.SuitProductModel model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("UP_pdSuitProduct_Update"); db.AddInParameter(dbCommand, "SuitProductId", DbType.Int32, model.SuitProductId); db.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId); db.AddInParameter(dbCommand, "SuitName", DbType.AnsiString, model.SuitName); db.AddInParameter(dbCommand, "MerchantPrice", DbType.Decimal, model.MerchantPrice); db.AddInParameter(dbCommand, "TradePrice", DbType.Decimal, model.TradePrice); db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status); db.ExecuteNonQuery(dbCommand); }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtProductId.Text)) { strErr += "ProductId不是数字!\\n"; } if (this.txtSuitName.Text == "") { strErr += "SuitName不能为空!\\n"; } if (!PageValidate.IsDecimal(txtMerchantPrice.Text)) { strErr += "MerchantPrice不是数字!\\n"; } if (!PageValidate.IsDecimal(txtTradePrice.Text)) { strErr += "TradePrice不是数字!\\n"; } if (!PageValidate.IsNumber(txtStatus.Text)) { strErr += "Status不是数字!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int ProductId = int.Parse(this.txtProductId.Text); string SuitName = this.txtSuitName.Text; decimal MerchantPrice = decimal.Parse(this.txtMerchantPrice.Text); decimal TradePrice = decimal.Parse(this.txtTradePrice.Text); int Status = int.Parse(this.txtStatus.Text); NoName.NetShop.Model.SuitProductModel model = new NoName.NetShop.Model.SuitProductModel(); model.ProductId = ProductId; model.SuitName = SuitName; model.MerchantPrice = MerchantPrice; model.TradePrice = TradePrice; model.Status = Status; NoName.NetShop.BLL.SuitProductModelBll bll = new NoName.NetShop.BLL.SuitProductModelBll(); bll.Update(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public NoName.NetShop.Model.SuitProductModel GetModel(int SuitProductId) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("UP_pdSuitProduct_GetModel"); db.AddInParameter(dbCommand, "SuitProductId", DbType.Int32, SuitProductId); NoName.NetShop.Model.SuitProductModel 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(!PageValidate.IsNumber(txtProductId.Text)) { strErr+="ProductId�������֣�\\n"; } if(this.txtSuitName.Text =="") { strErr+="SuitName����Ϊ�գ�\\n"; } if(!PageValidate.IsDecimal(txtMerchantPrice.Text)) { strErr+="MerchantPrice�������֣�\\n"; } if(!PageValidate.IsDecimal(txtTradePrice.Text)) { strErr+="TradePrice�������֣�\\n"; } if(!PageValidate.IsNumber(txtStatus.Text)) { strErr+="Status�������֣�\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int ProductId=int.Parse(this.txtProductId.Text); string SuitName=this.txtSuitName.Text; decimal MerchantPrice=decimal.Parse(this.txtMerchantPrice.Text); decimal TradePrice=decimal.Parse(this.txtTradePrice.Text); int Status=int.Parse(this.txtStatus.Text); NoName.NetShop.Model.SuitProductModel model=new NoName.NetShop.Model.SuitProductModel(); model.ProductId=ProductId; model.SuitName=SuitName; model.MerchantPrice=MerchantPrice; model.TradePrice=TradePrice; model.Status=Status; NoName.NetShop.BLL.SuitProductModelBll bll=new NoName.NetShop.BLL.SuitProductModelBll(); bll.Update(model); }
/// <summary> /// ����ʵ������� /// </summary> public NoName.NetShop.Model.SuitProductModel ReaderBind(IDataReader dataReader) { NoName.NetShop.Model.SuitProductModel model=new NoName.NetShop.Model.SuitProductModel(); object ojb; ojb = dataReader["SuitProductId"]; if(ojb != null && ojb != DBNull.Value) { model.SuitProductId=(int)ojb; } ojb = dataReader["ProductId"]; if(ojb != null && ojb != DBNull.Value) { model.ProductId=(int)ojb; } model.SuitName=dataReader["SuitName"].ToString(); ojb = dataReader["MerchantPrice"]; if(ojb != null && ojb != DBNull.Value) { model.MerchantPrice=(decimal)ojb; } ojb = dataReader["TradePrice"]; if(ojb != null && ojb != DBNull.Value) { model.TradePrice=(decimal)ojb; } ojb = dataReader["Status"]; if(ojb != null && ojb != DBNull.Value) { model.Status=(int)ojb; } return model; }