コード例 #1
0
ファイル: SystemController.cs プロジェクト: zjchenxk/SYLS
        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);
        }
コード例 #2
0
ファイル: PlanController.cs プロジェクト: zjchenxk/SYLS
        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);
        }