예제 #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SHMetroTestSysModel.Tmp_jc_User DataRowToModel(DataRow row)
 {
     SHMetroTestSysModel.Tmp_jc_User model=new SHMetroTestSysModel.Tmp_jc_User();
     if (row != null)
     {
         if(row["Id"]!=null && row["Id"].ToString()!="")
         {
             model.Id=int.Parse(row["Id"].ToString());
         }
         if(row["UserGroupId"]!=null)
         {
             model.UserGroupId=row["UserGroupId"].ToString();
         }
         if(row["UserIdCard"]!=null)
         {
             model.UserIdCard=row["UserIdCard"].ToString();
         }
         if(row["UserPwd"]!=null)
         {
             model.UserPwd=row["UserPwd"].ToString();
         }
         if(row["TrueName"]!=null)
         {
             model.TrueName=row["TrueName"].ToString();
         }
         if(row["UserSex"]!=null)
         {
             model.UserSex=row["UserSex"].ToString();
         }
         if(row["Corporation"]!=null)
         {
             model.Corporation=row["Corporation"].ToString();
         }
         if(row["Education"]!=null)
         {
             model.Education=row["Education"].ToString();
         }
         if(row["Phone"]!=null)
         {
             model.Phone=row["Phone"].ToString();
         }
         if(row["UserQQ"]!=null)
         {
             model.UserQQ=row["UserQQ"].ToString();
         }
         if(row["UserBirthday"]!=null && row["UserBirthday"].ToString()!="")
         {
             model.UserBirthday=DateTime.Parse(row["UserBirthday"].ToString());
         }
         if(row["ProhibitSubject"]!=null)
         {
             model.ProhibitSubject=row["ProhibitSubject"].ToString();
         }
         if(row["ProhibitLibrary"]!=null)
         {
             model.ProhibitLibrary=row["ProhibitLibrary"].ToString();
         }
         if(row["ValidityDate"]!=null)
         {
             model.ValidityDate=row["ValidityDate"].ToString();
         }
     }
     return model;
 }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SHMetroTestSysModel.Tmp_jc_User GetModel(int Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Id,UserGroupId,UserIdCard,UserPwd,TrueName,UserSex,Corporation,Education,Phone,UserQQ,UserBirthday,ProhibitSubject,ProhibitLibrary,ValidityDate from Tmp_jc_User ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

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