コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.HotelDetailViewModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into HotelDetailView(");
            strSql.Append("HotelPlatName,HotelPlatID,HotelID,HotelName,PlatName,PlatID)");
            strSql.Append(" values (");
            strSql.Append("HotelPlatName,HotelPlatID,HotelID,HotelName,PlatName,PlatID)");
            SqlParameter[] parameters =
            {
                new SqlParameter("HotelPlatName", SqlDbType.NVarChar, 100),
                new SqlParameter("HotelPlatID",   SqlDbType.NVarChar, 100),
                new SqlParameter("HotelID",       SqlDbType.Int,        4),
                new SqlParameter("HotelName",     SqlDbType.VarChar,   20),
                new SqlParameter("PlatName",      SqlDbType.NVarChar,  20),
                new SqlParameter("PlatID",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.HotelPlatName;
            parameters[1].Value = model.HotelPlatID;
            parameters[2].Value = model.HotelID;
            parameters[3].Value = model.HotelName;
            parameters[4].Value = model.PlatName;
            parameters[5].Value = model.PlatID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.HotelDetailViewModel DataRowToModel(DataRow row)
 {
     Maticsoft.Model.HotelDetailViewModel model = new Maticsoft.Model.HotelDetailViewModel();
     if (row != null)
     {
         if (row["HotelPlatName"] != null)
         {
             model.HotelPlatName = row["HotelPlatName"].ToString();
         }
         if (row["HotelPlatID"] != null)
         {
             model.HotelPlatID = row["HotelPlatID"].ToString();
         }
         if (row["HotelID"] != null && row["HotelID"].ToString() != "")
         {
             model.HotelID = int.Parse(row["HotelID"].ToString());
         }
         if (row["Star"] != null && row["Star"].ToString() != "")
         {
             model.Star = int.Parse(row["Star"].ToString());
         }
         if (row["HotelName"] != null)
         {
             model.HotelName = row["HotelName"].ToString();
         }
         if (row["PlatName"] != null)
         {
             model.PlatName = row["PlatName"].ToString();
         }
         if (row["City"] != null)
         {
             model.City = row["City"].ToString();
         }
         if (row["Area"] != null)
         {
             model.Area = row["Area"].ToString();
         }
         if (row["PlatID"] != null && row["PlatID"].ToString() != "")
         {
             model.PlatID = int.Parse(row["PlatID"].ToString());
         }
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
     }
     return(model);
 }
コード例 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.HotelDetailViewModel GetModel(string id)
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from HotelDetailView ");
            strSql.Append(" where id=" + id);
            SqlParameter[] parameters =
            {
            };

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Maticsoft.Model.HotelDetailViewModel model)
 {
     return(dal.Update(model));
 }
コード例 #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Maticsoft.Model.HotelDetailViewModel model)
 {
     return(dal.Add(model));
 }