Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MSCD.Model.LayerType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update b_LayerType set ");
            strSql.Append("Name=@Name");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name", SqlDbType.VarChar, 50),
                new SqlParameter("@id",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MSCD.Model.LayerType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into b_LayerType(");
            strSql.Append("Name)");
            strSql.Append(" values (");
            strSql.Append("@Name)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.Name;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MSCD.Model.LayerType DataRowToModel(DataRow row)
 {
     MSCD.Model.LayerType model = new MSCD.Model.LayerType();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
     }
     return model;
 }
Beispiel #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MSCD.Model.LayerType DataRowToModel(DataRow row)
 {
     MSCD.Model.LayerType model = new MSCD.Model.LayerType();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
     }
     return(model);
 }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MSCD.Model.LayerType GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,Name from b_LayerType ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MSCD.Model.LayerType GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,Name from b_LayerType ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            MSCD.Model.LayerType model = new MSCD.Model.LayerType();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Beispiel #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(MSCD.Model.LayerType model)
 {
     return(dal.Update(model));
 }
Beispiel #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(MSCD.Model.LayerType model)
 {
     return(dal.Add(model));
 }