コード例 #1
0
        public static YF.Mode.User getUserEmail(string email)//得到一个对象
        {
            YF.Mode.User user = new Mode.User();

            string strsql = "select * from _user where email='" + email + "'";

            DataTable dataTable = YF.MsSqlHelper.YFMsSqlHelper.Query(strsql).Tables[0];

            if (dataTable.Rows.Count != 0)
            {
                user.Id       = int.Parse(dataTable.Rows[0]["Id"].ToString());
                user.Name     = dataTable.Rows[0]["Name"].ToString();
                user.Rename   = dataTable.Rows[0]["Rename"].ToString();
                user.Sex      = int.Parse(dataTable.Rows[0]["Sex"].ToString());
                user.Email    = dataTable.Rows[0]["Email"].ToString();
                user.Phone    = dataTable.Rows[0]["Phone"].ToString();
                user.Address  = dataTable.Rows[0]["Address"].ToString();
                user.Password = dataTable.Rows[0]["Password"].ToString();
            }

            return(user);
        }
コード例 #2
0
        public static List <YF.Mode.User> DttolistU(DataTable dt)//把对象构建成一个list
        {
            List <YF.Mode.User> list = new List <Mode.User>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                YF.Mode.User user = new Mode.User();

                user.Id      = int.Parse(dt.Rows[i]["Id"].ToString());
                user.Name    = dt.Rows[i]["Name"].ToString();
                user.Rename  = dt.Rows[i]["Rename"].ToString();
                user.Sex     = int.Parse(dt.Rows[i]["Sex"].ToString());
                user.Email   = dt.Rows[i]["Email"].ToString();
                user.Phone   = dt.Rows[i]["Phone"].ToString();
                user.Address = dt.Rows[i]["Address"].ToString();
                //这里没有拿密码,管理员对密码无权访问

                list.Add(user);
            }

            return(list);
        }