private void ShowInfo(int VoteGroupId) { NoName.NetShop.BLL.VoteGroupModelBll bll = new NoName.NetShop.BLL.VoteGroupModelBll(); NoName.NetShop.Model.VoteGroupModel model = bll.GetModel(VoteGroupId); this.lblVoteId.Text = model.VoteId.ToString(); this.lblGroupType.Text = model.GroupType.ToString(); this.lblSubject.Text = model.Subject; this.lblContent.Text = model.Content; }
/// <summary> /// 更新一条数据 /// </summary> public void Update(NoName.NetShop.Model.VoteGroupModel model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("UP_voVoteGroup_Update"); db.AddInParameter(dbCommand, "VoteGroupId", DbType.Int32, model.VoteGroupId); db.AddInParameter(dbCommand, "VoteId", DbType.Int32, model.VoteId); db.AddInParameter(dbCommand, "GroupType", DbType.Byte, model.GroupType); db.AddInParameter(dbCommand, "Subject", DbType.AnsiString, model.Subject); db.AddInParameter(dbCommand, "Content", DbType.AnsiString, model.Content); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 得到一个对象实体 /// </summary> public NoName.NetShop.Model.VoteGroupModel GetModel(int VoteGroupId) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("UP_voVoteGroup_GetModel"); db.AddInParameter(dbCommand, "VoteGroupId", DbType.Int32, VoteGroupId); NoName.NetShop.Model.VoteGroupModel 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(txtVoteId.Text)) { strErr += "VoteId不是数字!\\n"; } if (!PageValidate.IsNumber(txtGroupType.Text)) { strErr += "GroupType不是数字!\\n"; } if (this.txtSubject.Text == "") { strErr += "Subject不能为空!\\n"; } if (this.txtContent.Text == "") { strErr += "Content不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int VoteId = int.Parse(this.txtVoteId.Text); int GroupType = int.Parse(this.txtGroupType.Text); string Subject = this.txtSubject.Text; string Content = this.txtContent.Text; NoName.NetShop.Model.VoteGroupModel model = new NoName.NetShop.Model.VoteGroupModel(); model.VoteId = VoteId; model.GroupType = GroupType; model.Subject = Subject; model.Content = Content; NoName.NetShop.BLL.VoteGroupModelBll bll = new NoName.NetShop.BLL.VoteGroupModelBll(); bll.Update(model); }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txtVoteId.Text)) { strErr+="VoteId�������֣�\\n"; } if(!PageValidate.IsNumber(txtGroupType.Text)) { strErr+="GroupType�������֣�\\n"; } if(this.txtSubject.Text =="") { strErr+="Subject����Ϊ�գ�\\n"; } if(this.txtContent.Text =="") { strErr+="Content����Ϊ�գ�\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int VoteId=int.Parse(this.txtVoteId.Text); int GroupType=int.Parse(this.txtGroupType.Text); string Subject=this.txtSubject.Text; string Content=this.txtContent.Text; NoName.NetShop.Model.VoteGroupModel model=new NoName.NetShop.Model.VoteGroupModel(); model.VoteId=VoteId; model.GroupType=GroupType; model.Subject=Subject; model.Content=Content; NoName.NetShop.BLL.VoteGroupModelBll bll=new NoName.NetShop.BLL.VoteGroupModelBll(); bll.Add(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public NoName.NetShop.Model.VoteGroupModel ReaderBind(IDataReader dataReader) { NoName.NetShop.Model.VoteGroupModel model = new NoName.NetShop.Model.VoteGroupModel(); object ojb; ojb = dataReader["VoteGroupId"]; if (ojb != null && ojb != DBNull.Value) { model.VoteGroupId = (int)ojb; } ojb = dataReader["VoteId"]; if (ojb != null && ojb != DBNull.Value) { model.VoteId = (int)ojb; } ojb = dataReader["GroupType"]; if (ojb != null && ojb != DBNull.Value) { model.GroupType = (int)ojb; } model.Subject = dataReader["Subject"].ToString(); model.Content = dataReader["Content"].ToString(); return(model); }
/// <summary> /// ����ʵ������� /// </summary> public NoName.NetShop.Model.VoteGroupModel ReaderBind(IDataReader dataReader) { NoName.NetShop.Model.VoteGroupModel model=new NoName.NetShop.Model.VoteGroupModel(); object ojb; ojb = dataReader["VoteGroupId"]; if(ojb != null && ojb != DBNull.Value) { model.VoteGroupId=(int)ojb; } ojb = dataReader["VoteId"]; if(ojb != null && ojb != DBNull.Value) { model.VoteId=(int)ojb; } ojb = dataReader["GroupType"]; if(ojb != null && ojb != DBNull.Value) { model.GroupType=(int)ojb; } model.Subject=dataReader["Subject"].ToString(); model.Content=dataReader["Content"].ToString(); return model; }