Esempio n. 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WTCJ.Model.User_Columns DataRowToModel(DataRow row)
 {
     WTCJ.Model.User_Columns model = new WTCJ.Model.User_Columns();
     if (row != null)
     {
         if (row["id"] != null)
         {
             model.id = row["id"].ToString();
         }
         if (row["type"] != null)
         {
             model.type = row["type"].ToString();
         }
         if (row["tableName"] != null)
         {
             model.tableName = row["tableName"].ToString();
         }
         if (row["allColumns"] != null)
         {
             model.allColumns = row["allColumns"].ToString();
         }
         if (row["showColumns"] != null)
         {
             model.showColumns = row["showColumns"].ToString();
         }
         if (row["hideColumns"] != null)
         {
             model.hideColumns = row["hideColumns"].ToString();
         }
         if (row["UserID"] != null)
         {
             model.UserID = row["UserID"].ToString();
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
         if (row["CreateBy"] != null)
         {
             model.CreateBy = row["CreateBy"].ToString();
         }
         if (row["UpdateTime"] != null && row["UpdateTime"].ToString() != "")
         {
             model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString());
         }
         if (row["UpdateBy"] != null)
         {
             model.UpdateBy = row["UpdateBy"].ToString();
         }
     }
     return(model);
 }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SqlTransaction tran, WTCJ.Model.User_Columns model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update User_Columns set ");
            strSql.Append("type=@type,");
            strSql.Append("tableName=@tableName,");
            strSql.Append("allColumns=@allColumns,");
            strSql.Append("showColumns=@showColumns,");
            strSql.Append("hideColumns=@hideColumns,");
            strSql.Append("UserID=@UserID,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("CreateBy=@CreateBy,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("UpdateBy=@UpdateBy");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@type",        SqlDbType.VarChar,     50),
                new SqlParameter("@tableName",   SqlDbType.VarChar,     50),
                new SqlParameter("@allColumns",  SqlDbType.VarChar,   4000),
                new SqlParameter("@showColumns", SqlDbType.VarChar,   4000),
                new SqlParameter("@hideColumns", SqlDbType.VarChar,   4000),
                new SqlParameter("@UserID",      SqlDbType.VarChar,     50),
                new SqlParameter("@Remark",      SqlDbType.VarChar,    200),
                new SqlParameter("@CreateTime",  SqlDbType.DateTime),
                new SqlParameter("@CreateBy",    SqlDbType.VarChar,     36),
                new SqlParameter("@UpdateTime",  SqlDbType.DateTime),
                new SqlParameter("@UpdateBy",    SqlDbType.VarChar,     36),
                new SqlParameter("@id",          SqlDbType.VarChar, 36)
            };
            parameters[0].Value  = model.type;
            parameters[1].Value  = model.tableName;
            parameters[2].Value  = model.allColumns;
            parameters[3].Value  = model.showColumns;
            parameters[4].Value  = model.hideColumns;
            parameters[5].Value  = model.UserID;
            parameters[6].Value  = model.Remark;
            parameters[7].Value  = model.CreateTime;
            parameters[8].Value  = model.CreateBy;
            parameters[9].Value  = model.UpdateTime;
            parameters[10].Value = model.UpdateBy;
            parameters[11].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(tran, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WTCJ.Model.User_Columns model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into User_Columns(");
            strSql.Append("id,type,tableName,allColumns,showColumns,hideColumns,UserID,Remark,CreateTime,CreateBy,UpdateTime,UpdateBy)");
            strSql.Append(" values (");
            strSql.Append("@id,@type,@tableName,@allColumns,@showColumns,@hideColumns,@UserID,@Remark,@CreateTime,@CreateBy,@UpdateTime,@UpdateBy)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",          SqlDbType.VarChar,     36),
                new SqlParameter("@type",        SqlDbType.VarChar,     50),
                new SqlParameter("@tableName",   SqlDbType.VarChar,     50),
                new SqlParameter("@allColumns",  SqlDbType.VarChar,   4000),
                new SqlParameter("@showColumns", SqlDbType.VarChar,   4000),
                new SqlParameter("@hideColumns", SqlDbType.VarChar,   4000),
                new SqlParameter("@UserID",      SqlDbType.VarChar,     50),
                new SqlParameter("@Remark",      SqlDbType.VarChar,    200),
                new SqlParameter("@CreateTime",  SqlDbType.DateTime),
                new SqlParameter("@CreateBy",    SqlDbType.VarChar,     36),
                new SqlParameter("@UpdateTime",  SqlDbType.DateTime),
                new SqlParameter("@UpdateBy",    SqlDbType.VarChar, 36)
            };
            parameters[0].Value  = model.id;
            parameters[1].Value  = model.type;
            parameters[2].Value  = model.tableName;
            parameters[3].Value  = model.allColumns;
            parameters[4].Value  = model.showColumns;
            parameters[5].Value  = model.hideColumns;
            parameters[6].Value  = model.UserID;
            parameters[7].Value  = model.Remark;
            parameters[8].Value  = model.CreateTime;
            parameters[9].Value  = model.CreateBy;
            parameters[10].Value = model.UpdateTime;
            parameters[11].Value = model.UpdateBy;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WTCJ.Model.User_Columns GetModel(string id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,type,tableName,allColumns,showColumns,hideColumns,UserID,Remark,CreateTime,CreateBy,UpdateTime,UpdateBy from User_Columns ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.VarChar, 36)
            };
            parameters[0].Value = id;

            WTCJ.Model.User_Columns model = new WTCJ.Model.User_Columns();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }