Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(LanyunMES.Entity.ColumnInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ColumnInfo(");
            strSql.Append("TableName,ColumnName,HeadText,Position,ColumnType,visable)");
            strSql.Append(" values (");
            strSql.Append("@TableName,@ColumnName,@HeadText,@Position,@ColumnType,@visable)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TableName",  SqlDbType.NVarChar, 50),
                new SqlParameter("@ColumnName", SqlDbType.NVarChar, 50),
                new SqlParameter("@HeadText",   SqlDbType.NVarChar, 50),
                new SqlParameter("@Position",   SqlDbType.Int,       4),
                new SqlParameter("@ColumnType", SqlDbType.NVarChar, 50),
                new SqlParameter("@visable",    SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.TableName;
            parameters[1].Value = model.ColumnName;
            parameters[2].Value = model.HeadText;
            parameters[3].Value = model.Position;
            parameters[4].Value = model.ColumnType;
            parameters[5].Value = model.visable;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public LanyunMES.Entity.ColumnInfo DataRowToModel(DataRow row)
 {
     LanyunMES.Entity.ColumnInfo model = new LanyunMES.Entity.ColumnInfo();
     if (row != null)
     {
         if (row["TableName"] != null)
         {
             model.TableName = row["TableName"].ToString();
         }
         if (row["ColumnName"] != null)
         {
             model.ColumnName = row["ColumnName"].ToString();
         }
         if (row["HeadText"] != null)
         {
             model.HeadText = row["HeadText"].ToString();
         }
         if (row["Position"] != null && row["Position"].ToString() != "")
         {
             model.Position = int.Parse(row["Position"].ToString());
         }
         if (row["ColumnType"] != null)
         {
             model.ColumnType = row["ColumnType"].ToString();
         }
         if (row["visable"] != null && row["visable"].ToString() != "")
         {
             if ((row["visable"].ToString() == "1") || (row["visable"].ToString().ToLower() == "true"))
             {
                 model.visable = true;
             }
             else
             {
                 model.visable = false;
             }
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LanyunMES.Entity.ColumnInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ColumnInfo set ");
            strSql.Append("ColumnName=@ColumnName,");
            strSql.Append("HeadText=@HeadText,");
            strSql.Append("Position=@Position,");
            strSql.Append("ColumnType=@ColumnType,");
            strSql.Append("visable=@visable");
            strSql.Append(" where TableName=@TableName ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ColumnName", SqlDbType.NVarChar, 50),
                new SqlParameter("@HeadText",   SqlDbType.NVarChar, 50),
                new SqlParameter("@Position",   SqlDbType.Int,       4),
                new SqlParameter("@ColumnType", SqlDbType.NVarChar, 50),
                new SqlParameter("@visable",    SqlDbType.Bit,       1),
                new SqlParameter("@TableName",  SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.ColumnName;
            parameters[1].Value = model.HeadText;
            parameters[2].Value = model.Position;
            parameters[3].Value = model.ColumnType;
            parameters[4].Value = model.visable;
            parameters[5].Value = model.TableName;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LanyunMES.Entity.ColumnInfo GetModel(string TableName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 TableName,ColumnName,HeadText,Position,ColumnType,visable from ColumnInfo ");
            strSql.Append(" where TableName=@TableName ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TableName", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = TableName;

            LanyunMES.Entity.ColumnInfo model = new LanyunMES.Entity.ColumnInfo();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

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