public string Create(UserAccount ua)
        {
            try
            {
                User loginUser = Session[SessionList.FamilyManageUser.ToString()] as User;
                ua.UserID = loginUser.ID;
                ua.ctypeName = WebComm.GetAccountListByXml().Where(c => c.TypeID == int.Parse(Request.Form["ctypeID"])).SingleOrDefault().TypeName;

                db.UserAccounts.Add(ua);
                db.SaveChanges();
                return WebComm.ReturnAlertMessage(ActionReturnStatus.成功, "添加成功", "UserAccountList", "", CallBackType.none, "");
            }
            catch (Exception ex)
            {
                return WebComm.ReturnAlertMessage(ActionReturnStatus.失败, "添加失败!" + ex.Message, "", "", CallBackType.none, "");
            }
        }
 public ActionResult List(UserAccount ua)
 {
     int pageNO = 1;
     if (Request.Form["pageNum"] != null)
     {
         int.TryParse(Request.Form["pageNum"], out pageNO);
     }
     BindComboxUser();
     BindAccountType();
     List<UserAccount> list = GetUserAccountList(pageNO, ua);
     return View(viewFolder + "List.cshtml", list);
 }
        /// <summary>
        /// 获取用户账号列表
        /// </summary>
        /// <param name="currentPage">当前页码</param>
        /// <param name="uBank">查询实体</param>
        /// <returns></returns>
        private List<UserAccount> GetUserAccountList(int currentPage, UserAccount uAccount)
        {
            var ubList = db.UserAccounts.AsQueryable();
            User loginUser = Session[SessionList.FamilyManageUser.ToString()] as User;
            //区分用户加载数据,如果不是超级管理员,只能查看自己的数据
            if (!UserPower.adminUserCode.Contains(loginUser.cUserCode))
            {
                ubList = ubList.Where(ub => ub.UserID == loginUser.ID);
            }
            if (uAccount != null && uAccount.UserID > 0)
            {
                ubList = ubList.Where(c => c.UserID == uAccount.UserID);
            }

            if (uAccount != null && uAccount.ctypeID > 0)
            {
                ubList = ubList.Where(c => c.ctypeID == uAccount.ctypeID);
            }
            if (uAccount != null && !string.IsNullOrEmpty(uAccount.cname))
            {
                ubList = ubList.Where(c => c.cname.Contains(uAccount.cname));
            }

            SetPagerOptions(ubList.Count(), currentPage);
            List<UserAccount> list = ubList.OrderBy(b => b.ID).Skip((currentPage - 1) * pageSize).Take(pageSize).ToList();

            return list;
        }
        public string Edit(UserAccount ua)
        {
            try
            {
                User loginUser = Session[SessionList.FamilyManageUser.ToString()] as User;
                ua.ctypeName = WebComm.GetAccountListByXml().Where(c => c.TypeID == int.Parse(Request.Form["ctypeID"])).SingleOrDefault().TypeName;

                db.Entry(ua).State = EntityState.Modified;
                db.SaveChanges();
                return WebComm.ReturnAlertMessage(ActionReturnStatus.成功, "修改成功", "UserAccountList", "", CallBackType.none, "");
            }
            catch (Exception ex)
            {
                return WebComm.ReturnAlertMessage(ActionReturnStatus.失败, "修改失败" + ex.Message, "", "", CallBackType.none, "");
            }
        }