예제 #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Danyl.SnnuURP.Model.RoomUseView DataRowToModel(DataRow row)
 {
     Danyl.SnnuURP.Model.RoomUseView model = new Danyl.SnnuURP.Model.RoomUseView();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Uid"] != null)
         {
             model.Uid = row["Uid"].ToString();
         }
         if (row["Uname"] != null)
         {
             model.Uname = row["Uname"].ToString();
         }
         if (row["UserPhone"] != null)
         {
             model.UserPhone = row["UserPhone"].ToString();
         }
         if (row["Rname"] != null)
         {
             model.Rname = row["Rname"].ToString();
         }
         if (row["RoomType"] != null)
         {
             model.RoomType = row["RoomType"].ToString();
         }
         if (row["Capacity"] != null && row["Capacity"].ToString() != "")
         {
             model.Capacity = int.Parse(row["Capacity"].ToString());
         }
         if (row["Purpose"] != null)
         {
             model.Purpose = row["Purpose"].ToString();
         }
         if (row["UseDate"] != null && row["UseDate"].ToString() != "")
         {
             model.UseDate = DateTime.Parse(row["UseDate"].ToString());
         }
         if (row["UseStatus"] != null)
         {
             model.UseStatus = row["UseStatus"].ToString();
         }
         if (row["Rid"] != null && row["Rid"].ToString() != "")
         {
             model.Rid = int.Parse(row["Rid"].ToString());
         }
         if (row["UserEmail"] != null)
         {
             model.UserEmail = row["UserEmail"].ToString();
         }
     }
     return model;
 }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Danyl.SnnuURP.Model.RoomUseView GetModel(int Id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,Uid,Uname,UserPhone,Rname,RoomType,Capacity,Purpose,UseDate,UseStatus,Rid,UserEmail from RoomUseView ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)            };
            parameters[0].Value = Id;

            Danyl.SnnuURP.Model.RoomUseView model = new Danyl.SnnuURP.Model.RoomUseView();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }