Exemplo n.º 1
0
        public ActionResult CancelAccount(string id)
        {
            long nAccountId = long.Parse(id);
            if (nAccountId == LoginAccountId)
            {
                return Json(InnoSoft.LS.Resources.Strings.CanNotCancelLoginAccount);
            }

            //修改数据
            string strErrText;
            AuthenticateSystem auth = new AuthenticateSystem();
            if (auth.CancelAccount(nAccountId, LoginAccountId, LoginStaffName, out strErrText))
            {
                return Json(string.Empty);
            }
            else
            {
                return Json(strErrText);
            }
        }
Exemplo n.º 2
0
        public JsonResult LoadStaffAccounts()
        {
            string strErrText;
            AuthenticateSystem auth = new AuthenticateSystem();
            List<Account> listAccount = auth.LoadStaffAccounts(LoginAccountId, LoginStaffName, out strErrText);
            if (listAccount == null)
            {
                throw new Exception(strErrText);
            }

            var ret = from a in listAccount
                      select new
                      {
                          a.Id,
                          a.StaffName
                      };

            return Json(ret, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 3
0
        public ActionResult Index(LogOnViewModel model)
        {
            if (ModelState.IsValid)
            {
                //校验验证码
                string strIndentifyCode = string.Empty;
                if (Session["IndentifyCode"] != null)
                {
                    strIndentifyCode = Session["IndentifyCode"].ToString();
                }
                if (model.IndentifyCode.ToLower() == strIndentifyCode)
                {
                    //检查是否已用其它用户登录
                    for (int i = 0; i < Session.Keys.Count; i++)
                    {
                        if (Session.Keys[i] == "LoginAccountId")
                        {
                            return Json(InnoSoft.LS.Resources.Strings.SystemIsInUse);
                        }
                    }

                    //校验帐户名与密码
                    string strErrText;
                    AuthenticateSystem auth = new AuthenticateSystem();
                    Account data = auth.StaffLogin(model.LoginAccount, model.Password, out strErrText);
                    if (data != null)
                    {
                        FormsService.SignIn(model.LoginAccount, false);

                        LoginAccountId = data.Id;
                        LoginStaffName = data.Name;
                        LoginAccountType = data.AccountType;
                        LoginOrganId = data.OrganId;
                        LoginOrganName = data.OrganFullName;
                        LoginStaffId = data.StaffId;
                        LoginStaffName = data.StaffName;

                        return Json(string.Empty);
                    }
                    else
                    {
                        return Json(strErrText);
                    }
                }
                else
                {
                    return Json(InnoSoft.LS.Resources.Strings.WrongIndentifyCode);
                }
            }
            return View(model);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 public ActionResult ResetPassword(ResetPasswordViewModel model)
 {
     if (ModelState.IsValid)
     {
         //保存数据
         string strErrText;
         AuthenticateSystem auth = new AuthenticateSystem();
         if (auth.ResetPassword(model.AccountId, model.NewPassword, LoginAccountId, LoginStaffName, out strErrText))
         {
             return Json(string.Empty);
         }
         else
         {
             return Json(strErrText);
         }
     }
     return View(model);
 }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
0
        public ActionResult NewAccount(AccountViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.AccountType == InnoSoft.LS.Resources.Options.Staff)
                {
                    if (model.OrganId == 0)
                    {
                        return Json(InnoSoft.LS.Resources.Strings.NotSelectedOrgan);
                    }
                    if (model.StaffId == 0)
                    {
                        return Json(InnoSoft.LS.Resources.Strings.NotSelectedStaff);
                    }
                }
                else
                {
                    if (model.CustomerId == 0)
                    {
                        return Json(InnoSoft.LS.Resources.Strings.NotSelectedCustomer);
                    }
                    if (model.ContactName.Trim() == string.Empty)
                    {
                        return Json(InnoSoft.LS.Resources.Strings.NotEnterContactName);
                    }
                }

                //创建数据
                Account data = new Account();
                data.Name = model.Name;
                data.AccountType = model.AccountType;
                data.OrganId = model.AccountType == InnoSoft.LS.Resources.Options.Staff ? model.OrganId : model.CustomerId;
                data.StaffId = model.AccountType == InnoSoft.LS.Resources.Options.Staff ? model.StaffId : 0;
                data.StaffName = model.AccountType == InnoSoft.LS.Resources.Options.Staff ? string.Empty : model.ContactName;

                //保存数据
                string strErrText;
                AuthenticateSystem auth = new AuthenticateSystem();
                if (auth.InsertAccount(data, LoginAccountId, LoginStaffName, out strErrText) > 0)
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }
Exemplo n.º 8
0
        public ActionResult ModifyAccount(string id)
        {
            string strErrText;

            //生成Model数据
            long nAccountId = long.Parse(id);
            AuthenticateSystem auth = new AuthenticateSystem();
            Account data = auth.LoadAccount(nAccountId, LoginAccountId, LoginStaffName, out strErrText);
            if (data == null)
            {
                throw new Exception(strErrText);
            }

            AccountViewModel model = new AccountViewModel();
            model.Id = data.Id;
            model.Name = data.Name;
            model.Password = data.Password;
            model.AccountType = data.AccountType;
            model.OrganId = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? data.OrganId : 0;
            model.StaffId = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? data.StaffId : 0;
            model.CustomerId = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? 0 : data.OrganId;
            model.ContactName = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? string.Empty : data.StaffName;
            model.IsCancel = data.IsCancel;

            if (data.AccountType == InnoSoft.LS.Resources.Options.Staff)
            {
                //生成组织部门下拉列表
                OrganizationSystem organ = new OrganizationSystem();
                List<Organization> listOrganization = organ.LoadOrganizations(LoginAccountId, LoginStaffName, out strErrText);
                if (listOrganization == null)
                {
                    throw new Exception(strErrText);
                }
                List<SelectListItem> selectListOrganization = new List<SelectListItem>();
                selectListOrganization.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                selectListOrganization.AddRange(from o in listOrganization
                                                orderby o.FullName
                                                select new SelectListItem
                                                {
                                                    Text = o.FullName,
                                                    Value = o.Id.ToString()
                                                });
                ViewData["Organizations"] = new SelectList(selectListOrganization, "Value", "Text", model.OrganId);

                //生成空的客户下拉列表
                List<Customer> listCustomer = new List<Customer>();
                List<SelectListItem> selectListCustomer = new List<SelectListItem>();
                selectListCustomer.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                selectListCustomer.AddRange(from c in listCustomer
                                            select new SelectListItem
                                            {
                                                Text = c.Name,
                                                Value = c.Id.ToString()
                                            });
                ViewData["Customers"] = new SelectList(selectListCustomer, "Value", "Text");
            }
            else
            {
                //生成空的组织部门下拉列表
                {
                    List<Organization> listOrganization = new List<Organization>();
                    List<SelectListItem> selectListOrganization = new List<SelectListItem>();
                    selectListOrganization.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                    selectListOrganization.AddRange(from o in listOrganization
                                                    select new SelectListItem
                                                    {
                                                        Text = o.FullName,
                                                        Value = o.Id.ToString()
                                                    });
                    ViewData["Organizations"] = new SelectList(selectListOrganization, "Value", "Text");
                }

                //生成客户下拉列表
                CustomerSystem customer = new CustomerSystem();
                List<Customer> listCustomer = customer.LoadCustomers(LoginAccountId, LoginStaffName, out strErrText);
                if (listCustomer == null)
                {
                    throw new Exception(strErrText);
                }
                List<SelectListItem> selectListCustomer = new List<SelectListItem>();
                selectListCustomer.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                selectListCustomer.AddRange(from c in listCustomer
                                            orderby c.Name
                                            select new SelectListItem
                                            {
                                                Text = c.Name,
                                                Value = c.Id.ToString()
                                            });
                ViewData["Customers"] = new SelectList(selectListCustomer, "Value", "Text", model.OrganId);
            }

            //生成员工下拉列表
            if (data.AccountType == InnoSoft.LS.Resources.Options.Staff)
            {
                StaffSystem staff = new StaffSystem();
                List<Staff> listStaff = staff.LoadStaffsByOrganId(model.OrganId, LoginAccountId, LoginStaffName, out strErrText);
                if (listStaff == null)
                {
                    throw new Exception(strErrText);
                }
                List<SelectListItem> selectListStaff = new List<SelectListItem>();
                selectListStaff.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                selectListStaff.AddRange(from s in listStaff
                                         select new SelectListItem
                                         {
                                             Text = s.FullName,
                                             Value = s.Id.ToString()
                                         });

                ViewData["Staffs"] = new SelectList(selectListStaff, "Value", "Text", model.StaffId);
            }
            else
            {
                List<Staff> listStaff = new List<Staff>();
                List<SelectListItem> selectListStaff = new List<SelectListItem>();
                selectListStaff.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                selectListStaff.AddRange(from s in listStaff
                                         select new SelectListItem
                                         {
                                             Text = s.Name,
                                             Value = s.Id.ToString()
                                         });
                ViewData["Staffs"] = new SelectList(selectListStaff, "Value", "Text");
            }

            return View(model);
        }
Exemplo n.º 9
0
        public JsonResult IsCustomerNew(long nPlanId)
        {
            //读取计划数据
            string strErrText;
            PlanSystem plan = new PlanSystem();
            DeliverPlan data = plan.LoadDeliverPlan(nPlanId, LoginAccountId, LoginStaffName, out strErrText);
            if (data == null)
            {
                throw new Exception(strErrText);
            }

            //读取创建人数据
            AuthenticateSystem auth = new AuthenticateSystem();
            Account data2 = auth.LoadAccount(data.CreatorId, LoginAccountId, LoginStaffName, out strErrText);
            if (data2 == null)
            {
                throw new Exception(strErrText);
            }

            if (data2.AccountType == InnoSoft.LS.Resources.Options.Customer)
                return Json(true, JsonRequestBehavior.AllowGet);
            else
                return Json(false, JsonRequestBehavior.AllowGet);
        }