日期:2014-05-17 浏览次数:20879 次
//添加 //数据填充 SystemCodeModel SystemCodeModel = new SystemCodeModel(); SystemCodeModel.CodeLb = this.txtCodeLb.Text; SystemCodeModel.LbName = this.txtLbName.Text; SystemCodeModel.CodeValue = this.txtCodeValue.Text; SystemCodeModel.CodeName = this.txtCodeName.Text; //调用BLL层Add SystemCodeBLL.Add(SystemCodeModel); //修改: //数据填充 SystemCodeModel SystemCodeModel = new SystemCodeModel(); SystemCodeModel.CodeLb = this.txtCodeLb.Text; SystemCodeModel.LbName = this.txtLbName.Text; SystemCodeModel.CodeValue = this.txtCodeValue.Text; SystemCodeModel.CodeName = this.txtCodeName.Text; //调用BLL层Update SystemCodeBLL.Update(SystemCodeModel);
//删除事件 protected void GVList_RowDeleting(object sender, GridViewDeleteEventArgs e) { string CodeLb = this.GVList.DataKeys[e.RowIndex].Values[0].ToString(); string CodeValue = this.GVList.DataKeys[e.RowIndex].Values[1].ToString(); SystemCodeBLL.Delete(CodeLb, CodeValue); //删除完之后重新绑定 this.Init_Data(ViewState["CodeLb"] == null ? "" : ViewState["CodeLb"].ToString()); }
// 新增 public void Add(SystemCodeModel Model) { DAL.Add(Model); } //修改 public void Update(SystemCodeModel Model) { DAL.Update(Model); } //删除 public void Delete(string CodeLb, string CodeValue) { DAL.Delete(CodeLb, CodeValue); }
//引用微软企业库 using Microsoft.Practices.EnterpriseLibrary.Data; using Microsoft.Practices.EnterpriseLibrary.Common; //建立数据库访问类 Database db = DatabaseFactory.CreateDatabase(); // 新增 public void Add(SystemCodeModel Model) { System.Data.Common.DbCommand sqlCommand = db.GetStoredProcCommand("SystemCode_ADD"); db.AddInParameter(sqlCommand, "CodeLb_in", DbType.String, Model.CodeLb); db.AddInParameter(sqlCommand, "LbName_in", DbType.String, Model.LbName); db.AddInParameter(sqlCommand, "CodeValue_in", DbType.String, Model.CodeValue); db.AddInParameter(sqlCommand, "CodeName_in", DbType.String, Model.CodeName); db.ExecuteNonQuery(sqlCommand); } //修改 public void Update(SystemCodeModel Model) { System.Data.Common.DbCommand sqlCommand = db.GetStoredProcCommand("SystemCode_Update"); db.AddInParameter(sqlCommand, "CodeLb_in", DbType.String, Model.CodeLb); db.AddInParameter(sqlCommand, "LbName_in", DbType.String, Model.LbName); db.AddInParameter(sqlCommand, "CodeValue_in", DbType.String, Model.CodeValue); db.AddInParameter(sqlCommand, "CodeName_in", DbType.String, Model.CodeNam