Example #1
0
        public JsonResult LoadActiveAccountsGrid(string sidx, string sord, int page, int rows)
        {
            //读取全部数据
            string strErrText;
            AuthenticateSystem auth = new AuthenticateSystem();
            List<Account> listAccount = auth.LoadActiveAccounts(LoginAccountId, LoginStaffName, out strErrText);
            if (listAccount == null)
            {
                throw new Exception(strErrText);
            }

            //提取当前页面数据
            int nTotalRows = listAccount.Count;
            int nPageIndex = page;
            int nPageSize = rows;
            int nTotalPages = nTotalRows / nPageSize;
            if (nTotalRows % nPageSize > 0)
                nTotalPages++;

            string sortExpression = (sidx ?? "Id") + " " + (sord ?? "ASC");
            var data = listAccount.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList();

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from a in data
                      select new
                      {
                          id = a.Id,
                          cell = new string[]
                          {
                              a.Id.ToString(),
                              a.Name,
                              a.AccountType,
                              a.OrganFullName,
                              a.StaffName
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }
Example #2
0
        public ActionResult ResetPassword()
        {
            string strErrText;

            //生成帐号下拉列表项
            AuthenticateSystem auth = new AuthenticateSystem();
            List<Account> listAccount = auth.LoadActiveAccounts(LoginAccountId, LoginStaffName, out strErrText);
            if (listAccount == null)
            {
                throw new Exception(strErrText);
            }
            List<SelectListItem> selectListAccount = new List<SelectListItem>();
            selectListAccount.Add(new SelectListItem { Text = string.Empty, Value = "0" });
            selectListAccount.AddRange(from a in listAccount
                                       orderby a.Name
                                       select new SelectListItem
                                       {
                                           Text = a.Name,
                                           Value = a.Id.ToString()
                                       });
            ViewData["Accounts"] = new SelectList(selectListAccount, "Value", "Text");

            return View();
        }