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

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

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

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

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

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

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

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

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

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