Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CdHotelManage.Model.customerState model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update customerState set ");
            strSql.Append("csName=@csName,");
            strSql.Append("Reamrk=@Reamrk");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@csName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Reamrk", SqlDbType.NVarChar, 50),
                new SqlParameter("@ID",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.csName;
            parameters[1].Value = model.Reamrk;
            parameters[2].Value = model.ID;

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

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

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

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CdHotelManage.Model.customerState DataRowToModel(DataRow row)
 {
     CdHotelManage.Model.customerState model = new CdHotelManage.Model.customerState();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["csName"] != null)
         {
             model.csName = row["csName"].ToString();
         }
         if (row["Reamrk"] != null)
         {
             model.Reamrk = row["Reamrk"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CdHotelManage.Model.customerState GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,csName,Reamrk from customerState ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

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