예제 #1
0
        public string Create(Bank bank)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Banks.Add(bank);
                    db.SaveChanges();

                    return WebComm.ReturnAlertMessage(ActionReturnStatus.成功, "添加银行成功!", "bankMainList", "", CallBackType.none, "");
                }
            }
            catch (Exception ex)
            {
                return WebComm.ReturnAlertMessage(ActionReturnStatus.失败, "验证失败!" + ex.Message, "", "", CallBackType.none, "");
            }

            return WebComm.ReturnAlertMessage(ActionReturnStatus.失败, "验证失败!", "", "", CallBackType.none, "");
        }
예제 #2
0
 public ActionResult List(Bank bank)
 {
     int pageNO = 1;
     if (Request.Form["pageNum"] != null)
     {
         int.TryParse(Request.Form["pageNum"], out pageNO);
     }
     List<Bank> bankList = GetBankList(pageNO, bank);
     return View(viewFolder + "List.cshtml", bankList);
 }
예제 #3
0
        /// <summary>
        /// 根据当前页码,获取银行列表
        /// </summary>
        /// <param name="currentPage"></param>
        /// <returns></returns>
        private List<Bank> GetBankList(int currentPage, Bank bank)
        {
            var bankList = db.Banks.AsQueryable();
            if (bank != null)
            {
                if (!string.IsNullOrEmpty(bank.cBankName))
                {
                    bankList = bankList.Where(b => b.cBankName.Contains(bank.cBankName));
                }
            }

            List<Bank> list = bankList.OrderBy(b => b.ID).Skip((currentPage - 1) * pageSize).Take(pageSize).ToList();

            SetPagerOptions(db.Banks.Count(), currentPage);
            return list;
        }