C# code//引用微软企业库
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.CodeName);
db.ExecuteNonQuery(sqlCommand);
}
//删除
public void Delete(string CodeLb, string CodeValue)
{
System.Data.Common.DbCommand sqlCommand = db.GetStoredProcCommand("SystemCode_Delete");
db.AddInParameter(sqlCommand, "CodeLb_in", DbType.String, CodeLb);
db.AddInParameter(sqlCommand, "CodeValue_in", DbType.String, CodeValue);
db.ExecuteNonQuery(sqlCommand);
}