Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(ZSystem.Model.t_OperationState model)
        {
            StringBuilder strSql;

            DbParameter[] cmdParms;
            PrepareUpdateCommand(model, out strSql, out cmdParms);
            return(dbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms));
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(ZSystem.Model.t_OperationState model)
        {
            int count = dal.Update(model);

            if (EnableCache && count > 0)
            {
                RemoveModelCache(model.KeyID);
            }
        }
        public override bool Equals(object obj)
        {
            ZSystem.Model.t_OperationState model = obj as ZSystem.Model.t_OperationState;
            if (model != null && model.KeyID == this.KeyID)
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// 为更新一条数据准备参数
        /// </summary>
        internal static void PrepareUpdateCommand(ZSystem.Model.t_OperationState model, out StringBuilder strSql, out DbParameter[] cmdParms)
        {
            strSql = new StringBuilder();
            strSql.Append("UPDATE t_OperationState SET ");
            strSql.Append("sStatusName=@in_sStatusName,");
            strSql.Append("iIndex=@in_iIndex");
            strSql.Append(" WHERE KeyID=@in_KeyID");

            cmdParms = new DbParameter[] {
                dbHelper.CreateInDbParameter("@in_sStatusName", DbType.String, model.sStatusName),
                dbHelper.CreateInDbParameter("@in_iIndex", DbType.Int32, model.iIndex),
                dbHelper.CreateInDbParameter("@in_KeyID", DbType.Int32, model.KeyID)
            };
        }
        /// <summary>
        /// 为新增一条数据准备参数
        /// </summary>
        internal static void PrepareAddCommand(ZSystem.Model.t_OperationState model, out StringBuilder strSql, out DbParameter[] cmdParms)
        {
            strSql = new StringBuilder();
            strSql.Append("INSERT INTO t_OperationState(");
            strSql.Append("KeyID, sStatusName, iIndex)");
            strSql.Append(" VALUES (");
            strSql.Append("@in_KeyID, @in_sStatusName, @in_iIndex)");

            cmdParms = new DbParameter[] {
                dbHelper.CreateInDbParameter("@in_KeyID", DbType.Int32, model.KeyID),
                dbHelper.CreateInDbParameter("@in_sStatusName", DbType.String, model.sStatusName),
                dbHelper.CreateInDbParameter("@in_iIndex", DbType.Int32, model.iIndex)
            };
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ZSystem.Model.t_OperationState GetModel(int?KeyID)
 {
     ZSystem.Model.t_OperationState model = null;
     if (!EnableCache)
     {
         model = dal.GetModel(KeyID);
     }
     else
     {
         string key = KeyID.ToString();
         if (GetModelCache(key) != null)
         {
             model = (ZSystem.Model.t_OperationState)GetModelCache(key);
         }
         else
         {
             model = dal.GetModel(KeyID);
             TryAddModelCache(key, model, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
         }
     }
     return(model);
 }
 /// <summary>
 /// 由一行数据得到一个实体
 /// </summary>
 private ZSystem.Model.t_OperationState GetModel(DbDataReader dr)
 {
     ZSystem.Model.t_OperationState model = new ZSystem.Model.t_OperationState();
     PrepareModel(model, dr);
     return model;
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(ZSystem.Model.t_OperationState model)
 {
     dal.Add(model);
 }
 /// <summary>
 /// 由一行数据得到一个实体
 /// </summary>
 internal static void PrepareModel(ZSystem.Model.t_OperationState model, DbDataReader dr)
 {
     model.KeyID       = GetInt(dr["KeyID"]);
     model.sStatusName = GetString(dr["sStatusName"]);
     model.iIndex      = GetInt(dr["iIndex"]);
 }
Beispiel #10
0
 /// <summary>
 /// 由一行数据得到一个实体
 /// </summary>
 private ZSystem.Model.t_OperationState GetModel(DbDataReader dr)
 {
     ZSystem.Model.t_OperationState model = new ZSystem.Model.t_OperationState();
     PrepareModel(model, dr);
     return(model);
 }