Exemple #1
0
        /// <summary>
        /// 依据sql语句查询用户
        /// </summary>
        /// <param name="safeSql"></param>
        /// <returns></returns>
        private static IList <User> GetUsersBySql(string safeSql)
        {
            List <User> list = new List <User>();

            using (DataTable table = DBHelper.GetDataSet(safeSql))
            {
                foreach (DataRow row in table.Rows)
                {
                    User user = new User();

                    user.Id        = (int)row["Id"];
                    user.LoginName = (string)row["LoginId"];
                    user.LoginPwd  = (string)row["LoginPwd"];
                    user.Name      = (string)row["Name"];
                    user.Address   = (string)row["Address"];
                    user.Phone     = (string)row["Phone"];
                    user.Mail      = (string)row["Mail"];
                    user.UserState = UserStateService.GetUserStateById((int)row["UserStateId"]); //FK
                    user.UserRole  = UserRoleService.GetUserRoleById((int)row["UserRoleId"]);    //FK

                    list.Add(user);
                }

                return(list);
            }
        }
 /// <summary>
 /// 根据Id获得UserRole对象
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public UserRole GetUserRoleById(int id)
 {
     return(urs.GetUserRoleById(id));
 }
Exemple #3
0
 public static UserRole GetUserRoleById(int id)
 {
     return(UserRoleService.GetUserRoleById(id));
 }