Exemplo n.º 1
0
        public ActionResult ViewStaffDetails(string id)
        {
            string strErrText;

            //生成Model数据
            long nStaffId = long.Parse(id);
            StaffSystem staff = new StaffSystem();
            Staff data = staff.LoadStaff(nStaffId, LoginAccountId, LoginStaffName, out strErrText);
            if (data == null)
            {
                throw new Exception(strErrText);
            }

            StaffViewModel model = new StaffViewModel();
            model.Id = data.Id;
            model.FamilyName = data.FamilyName;
            model.Name = data.Name;
            model.Sex = data.Sex;
            model.OrganId = data.OrganId;
            model.OrganName = data.OrganName;
            model.OrganFullName = data.OrganFullName;
            model.PositionId = data.PositionId;
            model.PositionName = data.PositionName;
            model.OfficeTel = data.OfficeTel;
            model.TelExt = data.TelExt;
            model.Fax = data.Fax;
            model.MobileTel1 = data.MobileTel1;
            model.MobileTel2 = data.MobileTel2;
            model.MobileTel3 = data.MobileTel3;
            model.EMail = data.EMail;
            model.QQ = data.QQ;
            model.IsOrganManager = data.IsOrganManager;
            model.IsOrganLeader = data.IsOrganLeader;
            model.BossStaffId = data.BossStaffId;
            model.BossStaffName = data.BossStaffName;

            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult NewStaff()
        {
            string strErrText;

            //生成组织部门下拉列表项
            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 = string.Empty });
            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");

            //生成岗位下拉列表项
            PositionSystem position = new PositionSystem();
            List<Position> listPosition = position.LoadPositions(LoginAccountId, LoginStaffName, out strErrText);
            if (listPosition == null)
            {
                throw new Exception(strErrText);
            }
            List<SelectListItem> selectListPosition = new List<SelectListItem>();
            selectListPosition.Add(new SelectListItem { Text = string.Empty, Value = string.Empty });
            selectListPosition.AddRange(from p in listPosition
                                        select new SelectListItem
                                        {
                                            Text = p.Name,
                                            Value = p.Id.ToString()
                                        });

            ViewData["Positions"] = new SelectList(selectListPosition, "Value", "Text");

            //生成上司下拉列表项
            StaffSystem staff = new StaffSystem();
            List<Staff> listStaff = staff.LoadStaffs(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["Bosses"] = new SelectList(selectListStaff, "Value", "Text");

            //创建空的Model
            StaffViewModel model = new StaffViewModel();

            return View(model);
        }
Exemplo n.º 3
0
        public ActionResult NewStaff(StaffViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                Staff data = new Staff();
                data.FamilyName = model.FamilyName;
                data.Name = model.Name ?? string.Empty;
                data.Sex = model.Sex;
                data.OrganId = model.OrganId;
                data.PositionId = model.PositionId;
                data.OfficeTel = model.OfficeTel ?? string.Empty;
                data.TelExt = model.TelExt ?? string.Empty;
                data.Fax = model.Fax ?? string.Empty;
                data.MobileTel1 = model.MobileTel1;
                data.MobileTel2 = model.MobileTel2 ?? string.Empty;
                data.MobileTel3 = model.MobileTel3 ?? string.Empty;
                data.EMail = model.EMail ?? string.Empty;
                data.QQ = model.QQ ?? string.Empty;
                data.IsOrganManager = model.IsOrganManager;
                data.IsOrganLeader = model.IsOrganLeader;
                data.BossStaffId = model.BossStaffId;

                //保存数据
                string strErrText;
                StaffSystem staff = new StaffSystem();
                if (staff.InsertStaff(data, LoginAccountId, LoginStaffName, out strErrText) > 0)
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }
Exemplo n.º 4
0
        public ActionResult ModifyStaff(string id)
        {
            string strErrText;

            //生成Model数据
            long nStaffId = long.Parse(id);
            StaffSystem staff = new StaffSystem();
            Staff data = staff.LoadStaff(nStaffId, LoginAccountId, LoginStaffName, out strErrText);
            if (data == null)
            {
                throw new Exception(strErrText);
            }

            StaffViewModel model = new StaffViewModel();
            model.Id = data.Id;
            model.FamilyName = data.FamilyName;
            model.Name = data.Name;
            model.Sex = data.Sex;
            model.OrganId = data.OrganId;
            model.PositionId = data.PositionId;
            model.OfficeTel = data.OfficeTel;
            model.TelExt = data.TelExt;
            model.Fax = data.Fax;
            model.MobileTel1 = data.MobileTel1;
            model.MobileTel2 = data.MobileTel2;
            model.MobileTel3 = data.MobileTel3;
            model.EMail = data.EMail;
            model.QQ = data.QQ;
            model.IsOrganManager = data.IsOrganManager;
            model.IsOrganLeader = data.IsOrganLeader;
            model.BossStaffId = data.BossStaffId;

            //生成组织部门下拉列表项
            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 = string.Empty });
            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);

            //生成岗位下拉列表项
            PositionSystem position = new PositionSystem();
            List<Position> listPosition = position.LoadPositions(LoginAccountId, LoginStaffName, out strErrText);
            if (listPosition == null)
            {
                throw new Exception(strErrText);
            }
            List<SelectListItem> selectListPosition = new List<SelectListItem>();
            selectListPosition.Add(new SelectListItem { Text = string.Empty, Value = string.Empty });
            selectListPosition.AddRange(from p in listPosition
                                        select new SelectListItem
                                        {
                                            Text = p.Name,
                                            Value = p.Id.ToString()
                                        });

            ViewData["Positions"] = new SelectList(selectListPosition, "Value", "Text", model.PositionId);

            //生成上司下拉列表项
            List<Staff> listStaff = staff.LoadStaffsExcludeSelfAndSubordinates(nStaffId, 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["Bosses"] = new SelectList(selectListStaff, "Value", "Text", model.BossStaffId);

            return View(model);
        }