Exemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public AndroidMvcServer.Model.Tb_User DataRowToModel(DataRow row)
 {
     AndroidMvcServer.Model.Tb_User model = new AndroidMvcServer.Model.Tb_User();
     if (row != null)
     {
         if (row["UserId"] != null)
         {
             model.UserId = row["UserId"].ToString();
         }
         if (row["UserName"] != null)
         {
             model.UserName = row["UserName"].ToString();
         }
         if (row["EnglishName"] != null)
         {
             model.EnglishName = row["EnglishName"].ToString();
         }
         if (row["Pwd"] != null)
         {
             model.Pwd = row["Pwd"].ToString();
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = int.Parse(row["Status"].ToString());
         }
         if (row["DeptId"] != null)
         {
             model.DeptId = row["DeptId"].ToString();
         }
         if (row["Gender"] != null && row["Gender"].ToString() != "")
         {
             model.Gender = int.Parse(row["Gender"].ToString());
         }
         if (row["Signature"] != null)
         {
             model.Signature = row["Signature"].ToString();
         }
         if (row["HeadPic"] != null && row["HeadPic"].ToString() != "")
         {
             model.HeadPic = int.Parse(row["HeadPic"].ToString());
         }
         if (row["CellPhone"] != null)
         {
             model.CellPhone = row["CellPhone"].ToString();
         }
         if (row["OfficePhone"] != null)
         {
             model.OfficePhone = row["OfficePhone"].ToString();
         }
         if (row["Email"] != null)
         {
             model.Email = row["Email"].ToString();
         }
         if (row["Position"] != null)
         {
             model.Position = row["Position"].ToString();
         }
         if (row["DisplayIndex"] != null && row["DisplayIndex"].ToString() != "")
         {
             model.DisplayIndex = int.Parse(row["DisplayIndex"].ToString());
         }
         if (row["Comment"] != null)
         {
             model.Comment = row["Comment"].ToString();
         }
     }
     return model;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AndroidMvcServer.Model.Tb_User GetModel(string UserId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select UserId,UserName,EnglishName,Pwd,Status,DeptId,Gender,Signature,HeadPic,CellPhone,OfficePhone,Email,Position,DisplayIndex,Comment from tb_user ");
            strSql.Append(" where UserId=@UserId ");
            MySqlParameter[] parameters = {
                    new MySqlParameter("@UserId", MySqlDbType.VarChar,15)			};
            parameters[0].Value = UserId;

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