Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CdHotelManage.Model.floor_ld model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(CdHotelManage.Model.floor_ld model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CdHotelManage.Model.floor_ld DataRowToModel(DataRow row)
 {
     CdHotelManage.Model.floor_ld model = new CdHotelManage.Model.floor_ld();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["ld_Name"] != null)
         {
             model.ld_Name = row["ld_Name"].ToString();
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CdHotelManage.Model.floor_ld GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

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

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