예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.HotelDetailModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update HotelDetail set ");
            strSql.Append("HotelID=@HotelID,");
            strSql.Append("PlatID=@PlatID,");
            strSql.Append("HotelPlatID=@HotelPlatID,");
            strSql.Append("HotelName=@HotelName,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("UpdateDate=@UpdateDate");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@HotelID",     SqlDbType.Int,         4),
                new SqlParameter("@PlatID",      SqlDbType.Int,         4),
                new SqlParameter("@HotelPlatID", SqlDbType.NVarChar,  100),
                new SqlParameter("@HotelName",   SqlDbType.NVarChar,  100),
                new SqlParameter("@CreateDate",  SqlDbType.DateTime),
                new SqlParameter("@UpdateDate",  SqlDbType.DateTime),
                new SqlParameter("@ID",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.HotelID;
            parameters[1].Value = model.PlatID;
            parameters[2].Value = model.HotelPlatID;
            parameters[3].Value = model.HotelName;
            parameters[4].Value = model.CreateDate;
            parameters[5].Value = model.UpdateDate;
            parameters[6].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(Maticsoft.Model.HotelDetailModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into HotelDetail(");
            strSql.Append("HotelID,PlatID,HotelPlatID,HotelName,CreateDate,UpdateDate)");
            strSql.Append(" values (");
            strSql.Append("@HotelID,@PlatID,@HotelPlatID,@HotelName,@CreateDate,@UpdateDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@HotelID",     SqlDbType.Int,         4),
                new SqlParameter("@PlatID",      SqlDbType.Int,         4),
                new SqlParameter("@HotelPlatID", SqlDbType.NVarChar,  100),
                new SqlParameter("@HotelName",   SqlDbType.NVarChar,  100),
                new SqlParameter("@CreateDate",  SqlDbType.DateTime),
                new SqlParameter("@UpdateDate",  SqlDbType.DateTime)
            };
            parameters[0].Value = model.HotelID;
            parameters[1].Value = model.PlatID;
            parameters[2].Value = model.HotelPlatID;
            parameters[3].Value = model.HotelName;
            parameters[4].Value = model.CreateDate;
            parameters[5].Value = model.UpdateDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.HotelDetailModel DataRowToModel(DataRow row)
 {
     Maticsoft.Model.HotelDetailModel model = new Maticsoft.Model.HotelDetailModel();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["HotelID"] != null && row["HotelID"].ToString() != "")
         {
             model.HotelID = int.Parse(row["HotelID"].ToString());
         }
         if (row["PlatID"] != null && row["PlatID"].ToString() != "")
         {
             model.PlatID = int.Parse(row["PlatID"].ToString());
         }
         if (row["HotelPlatID"] != null)
         {
             model.HotelPlatID = row["HotelPlatID"].ToString();
         }
         if (row["HotelName"] != null)
         {
             model.HotelName = row["HotelName"].ToString();
         }
         if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
         {
             model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
         }
         if (row["UpdateDate"] != null && row["UpdateDate"].ToString() != "")
         {
             model.UpdateDate = DateTime.Parse(row["UpdateDate"].ToString());
         }
     }
     return(model);
 }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.HotelDetailModel GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,HotelID,PlatID,HotelPlatID,HotelName,CreateDate,UpdateDate from HotelDetail ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Maticsoft.Model.HotelDetailModel model)
 {
     return(dal.Update(model));
 }
예제 #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Maticsoft.Model.HotelDetailModel model)
 {
     return(dal.Add(model));
 }