private CachetTypeManageModel _DataBind(int Code) { CachetTypeManageModel model = new CachetTypeManageModel(); StringBuilder builder = new StringBuilder(); builder.Append("select * from CachetTypeManage "); builder.Append(" where Code=@Code"); this._DataProcess.CommandText = builder.ToString(); this._DataProcess.ProcessParametersAdd("@Code", SqlDbType.Int, 4, Code); SqlDataReader sqlDataReader = null; try { try { sqlDataReader = this._DataProcess.GetSqlDataReader(); while (sqlDataReader.Read()) { this.Initialize(sqlDataReader, model); } } catch (SqlException exception) { throw exception; } } finally { if (sqlDataReader != null) { sqlDataReader.Close(); } } return(model); }
public int Update(CachetTypeManageModel ObjModel) { int num = 0; using (SqlConnection connection = new SqlConnection(FunctionRule.GetConnectionString())) { connection.Open(); SqlTransaction transaction = connection.BeginTransaction(); try { try { num = new CachetTypeManageBLL().Update(ObjModel, transaction); transaction.Commit(); } catch (SqlException exception) { transaction.Rollback(); connection.Close(); throw exception; } return(num); } finally { connection.Close(); } } return(num); }
private List <CachetTypeManageModel> _Select(CachetTypeManageQueryModel qmObj) { List <CachetTypeManageModel> list = new List <CachetTypeManageModel>(); StringBuilder builder = new StringBuilder(); builder.Append("select * from CachetTypeManage "); builder.Append(qmObj.QueryConditionStr); if (qmObj.SortColumns.Length == 0) { builder.Append(" ORDER BY Code desc"); } else { builder.Append(" ORDER BY " + qmObj.SortColumns); } this._DataProcess.CommandText = builder.ToString(); this._DataProcess.SqlParameters = qmObj.Parameters; SqlDataReader sqlDataReader = null; int num = 0; try { try { sqlDataReader = this._DataProcess.GetSqlDataReader(); while (sqlDataReader.Read()) { if ((num >= qmObj.StartRecord) && ((list.Count < qmObj.MaxRecords) || (qmObj.MaxRecords == -1))) { CachetTypeManageModel model = new CachetTypeManageModel(); this.Initialize(sqlDataReader, model); list.Add(model); } num++; } } catch (SqlException exception) { throw exception; } } finally { if (sqlDataReader != null) { sqlDataReader.Close(); } } return(list); }
private void Initialize(SqlDataReader reader, CachetTypeManageModel obj) { if (reader.GetValue(0) != DBNull.Value) { obj.Code = reader.GetInt32(0); } if (reader.GetValue(1) != DBNull.Value) { obj.CachetName = reader.GetString(1); } if (reader.GetValue(2) != DBNull.Value) { obj.Type = reader.GetString(2); } }
public CachetTypeManageModel GetCachetTypeManage(int Code) { CachetTypeManageModel model = new CachetTypeManageModel(); using (SqlConnection connection = new SqlConnection(FunctionRule.GetConnectionString())) { try { model = new CachetTypeManageBLL().GetModel(Code, connection); connection.Close(); } catch (SqlException exception) { throw exception; } } return(model); }
private int _Insert(CachetTypeManageModel mObj) { StringBuilder builder = new StringBuilder(); builder.Append("insert into CachetTypeManage("); builder.Append("CachetName,Type)"); builder.Append(" values ("); builder.Append("@CachetName,@Type) "); builder.Append("SELECT @Code = SCOPE_IDENTITY()"); this._DataProcess.CommandText = builder.ToString(); this._DataProcess.ProcessParametersAdd("@CachetName", SqlDbType.VarChar, 100, mObj.CachetName); this._DataProcess.ProcessParametersAdd("@Type", SqlDbType.VarChar, 50, mObj.Type); SqlParameter parameter = this._DataProcess.ProcessParametersAdd("@Code", SqlDbType.Int, 4, null); parameter.Direction = ParameterDirection.Output; this._DataProcess.RunSql(); mObj.Code = (int)parameter.Value; return(mObj.Code); }
private int _Update(CachetTypeManageModel mObj) { StringBuilder builder = new StringBuilder(); builder.Append("update CachetTypeManage set "); if (mObj.CachetName != null) { builder.Append("CachetName=@CachetName,"); this._DataProcess.ProcessParametersAdd("@CachetName", SqlDbType.VarChar, 100, mObj.CachetName); } if (mObj.Type != null) { builder.Append("Type=@Type,"); this._DataProcess.ProcessParametersAdd("@Type", SqlDbType.VarChar, 50, mObj.Type); } builder.Remove(builder.Length - 1, 1); builder.Append(" where Code=@Code"); this._DataProcess.ProcessParametersAdd("@Code", SqlDbType.Int, 4, mObj.Code); this._DataProcess.CommandText = builder.ToString(); return(this._DataProcess.RunSql()); }
public int Update(CachetTypeManageModel ObjModel, SqlTransaction Transaction) { CachetTypeManageDAL edal = new CachetTypeManageDAL(Transaction); return(edal.Update(ObjModel)); }
public int Insert(CachetTypeManageModel ObjModel, SqlTransaction Transaction) { CachetTypeManageDAL edal = new CachetTypeManageDAL(Transaction); return(edal.Insert(ObjModel)); }
public int Update(CachetTypeManageModel mObj) { return(this._Update(mObj)); }
public int Insert(CachetTypeManageModel mObj) { return(this._Insert(mObj)); }
public int Delete(CachetTypeManageModel mObj) { return(this._Delete(mObj.Code)); }