// POST api/UserBank_WebAPI
        public HttpResponseMessage PostUserBank(UserBank userbank)
        {
            if (ModelState.IsValid)
            {
                db.UserBanks.Add(userbank);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, userbank);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = userbank.ID }));
                return response;
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
        public string Create(UserBank userbank)
        {
            try
            {
                User loginUser = Session[SessionList.FamilyManageUser.ToString()] as User;
                userbank.BankID = Convert.ToInt32(Request.Form["search_bank.BankID"]);
                userbank.BankName = Request.Form["search_bank.BankName"];
                userbank.UserID = loginUser.ID;
                userbank.UserName = loginUser.cUserName;
                userbank.CreateDate = DateTime.Now;

                db.UserBanks.Add(userbank);
                db.SaveChanges();
                return WebComm.ReturnAlertMessage(ActionReturnStatus.成功, "添加成功", "userBankList", "", CallBackType.none, "");
            }
            catch (Exception ex)
            {
                return WebComm.ReturnAlertMessage(ActionReturnStatus.失败, "添加失败!" + ex.Message, "", "", CallBackType.none, "");
            }
        }
        /// <summary>
        /// 获取用户开户行列表
        /// </summary>
        /// <param name="currentPage">当前页码</param>
        /// <param name="uBank">查询实体</param>
        /// <returns></returns>
        private List<UserBank> GetUserBankList(int currentPage, UserBank uBank)
        {
            var ubList = db.UserBanks.AsQueryable();
            User loginUser = Session[SessionList.FamilyManageUser.ToString()] as User;
            //区分用户加载数据,如果不是超级管理员,只能查看自己的数据
            if (!UserPower.adminUserCode.Contains(loginUser.cUserCode))
            {
                ubList = ubList.Where(ub => ub.UserID == loginUser.ID);
            }

            //筛选卡号
            if (uBank != null && !string.IsNullOrEmpty(uBank.BankNo))
            {
                ubList = ubList.Where(ub => ub.BankNo.Contains(uBank.BankNo));
            }
            //筛选银行名称
            if (uBank != null && !string.IsNullOrEmpty(uBank.BankName))
            {
                ubList = ubList.Where(ub => ub.BankName.Contains(uBank.BankName));
            }
            //筛选银行卡类型
            if (uBank != null && !string.IsNullOrEmpty(uBank.BankCardType) && uBank.BankCardType != "-1")
            {
                ubList = ubList.Where(ub => ub.BankCardType == uBank.BankCardType);
            }
            //筛选用户
            if (uBank != null && !string.IsNullOrEmpty(uBank.UserID.ToString()) && uBank.UserID > 0)
            {
                ubList = ubList.Where(ub => ub.UserID == uBank.UserID);
            }

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

            return list;
        }
 public ActionResult List(UserBank uBank)
 {
     int pageNO = 1;
     if (Request.Form["pageNum"] != null)
     {
         int.TryParse(Request.Form["pageNum"], out pageNO);
     }
     BindBankCardType();
     BindComboxUser();
     List<UserBank> list = GetUserBankList(pageNO, uBank);
     return View(viewFolder + "List.cshtml", list);
 }
        public string Edit(UserBank userbank)
        {
            try
            {
                User loginUser = Session[SessionList.FamilyManageUser.ToString()] as User;
                userbank.BankID = Convert.ToInt32(Request.Form["search_bank.BankID"]);
                userbank.BankName = Request.Form["search_bank.BankName"];
                userbank.UserID = loginUser.ID;
                userbank.UserName = loginUser.cUserName;

                db.Entry(userbank).State = EntityState.Modified;
                db.SaveChanges();
                return WebComm.ReturnAlertMessage(ActionReturnStatus.成功, "修改成功", "userBankList", "", CallBackType.none, "");
            }
            catch (Exception ex)
            {
                return WebComm.ReturnAlertMessage(ActionReturnStatus.失败, "修改失败" + ex.Message, "", "", CallBackType.none, "");
            }
        }
        // PUT api/UserBank_WebAPI/5
        public HttpResponseMessage PutUserBank(int id, UserBank userbank)
        {
            if (ModelState.IsValid && id == userbank.ID)
            {
                db.Entry(userbank).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }