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

            strSql.Append("update mtPrice set ");
            strSql.Append("MTID=@MTID,");
            strSql.Append("RoomType=@RoomType,");
            strSql.Append("Price=@Price,");
            strSql.Append("Dayprice=@Dayprice,");
            strSql.Append("zdPrice=@zdPrice,");
            strSql.Append("lcPrice=@lcPrice,");
            strSql.Append("mothPrice=@mothPrice");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MTID",      SqlDbType.Int,    4),
                new SqlParameter("@RoomType",  SqlDbType.Int,    4),
                new SqlParameter("@Price",     SqlDbType.Int,    4),
                new SqlParameter("@Dayprice",  SqlDbType.Int,    4),
                new SqlParameter("@zdPrice",   SqlDbType.Float,  4),
                new SqlParameter("@lcPrice",   SqlDbType.Int,    4),
                new SqlParameter("@mothPrice", SqlDbType.NChar, 10),
                new SqlParameter("@ID",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.MTID;
            parameters[1].Value = model.RoomType;
            parameters[2].Value = model.Price;
            parameters[3].Value = model.Dayprice;
            parameters[4].Value = model.zdPrice;
            parameters[5].Value = model.lcPrice;
            parameters[6].Value = model.mothPrice;
            parameters[7].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CdHotelManage.Model.mtPrice DataRowToModel(DataRow row)
 {
     CdHotelManage.Model.mtPrice model = new CdHotelManage.Model.mtPrice();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["MTID"] != null && row["MTID"].ToString() != "")
         {
             model.MTID = int.Parse(row["MTID"].ToString());
         }
         if (row["RoomType"] != null && row["RoomType"].ToString() != "")
         {
             model.RoomType = int.Parse(row["RoomType"].ToString());
         }
         if (row["Price"] != null && row["Price"].ToString() != "")
         {
             model.Price = int.Parse(row["Price"].ToString());
         }
         if (row["Dayprice"] != null && row["Dayprice"].ToString() != "")
         {
             model.Dayprice = int.Parse(row["Dayprice"].ToString());
         }
         if (row["zdPrice"] != null && row["zdPrice"].ToString() != "")
         {
             model.zdPrice = float.Parse(row["zdPrice"].ToString());
         }
         if (row["lcPrice"] != null && row["lcPrice"].ToString() != "")
         {
             model.lcPrice = int.Parse(row["lcPrice"].ToString());
         }
         if (row["mothPrice"] != null)
         {
             model.mothPrice = row["mothPrice"].ToString();
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(CdHotelManage.Model.mtPrice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into mtPrice(");
            strSql.Append("MTID,RoomType,Price,Dayprice,zdPrice,lcPrice,mothPrice)");
            strSql.Append(" values (");
            strSql.Append("@MTID,@RoomType,@Price,@Dayprice,@zdPrice,@lcPrice,@mothPrice)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MTID",      SqlDbType.Int,   4),
                new SqlParameter("@RoomType",  SqlDbType.Int,   4),
                new SqlParameter("@Price",     SqlDbType.Int,   4),
                new SqlParameter("@Dayprice",  SqlDbType.Int,   4),
                new SqlParameter("@zdPrice",   SqlDbType.Float, 4),
                new SqlParameter("@lcPrice",   SqlDbType.Int,   4),
                new SqlParameter("@mothPrice", SqlDbType.NChar, 10)
            };
            parameters[0].Value = model.MTID;
            parameters[1].Value = model.RoomType;
            parameters[2].Value = model.Price;
            parameters[3].Value = model.Dayprice;
            parameters[4].Value = model.zdPrice;
            parameters[5].Value = model.lcPrice;
            parameters[6].Value = model.mothPrice;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CdHotelManage.Model.mtPrice GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,MTID,RoomType,Price,Dayprice,zdPrice,lcPrice,mothPrice from mtPrice ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

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