示例#1
0
        public ActionResult Register()
        {
            RegisterModel model = new RegisterModel();
            PersonService pservice = new PersonService();

            //model.ListOfPersonName = pservice.GetListOnWorkingOfPersonName(System.DateTime.Now, null, null).ToList();

            return View(model);
        }
示例#2
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    if (!WebSecurity.UserExists(model.UserName))
                    {
                        AddNewAccount(model);

                        ViewBag.StatusMessage = "Tạo tài khoản thành công.";
                    }
                    else
                        ViewBag.StatusMessage = "Email này đã được sử dụng bởi nhân viên khác.";

                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            PersonService pservice = new PersonService();

            model.ListOfPersonName = pservice.GetListOnWorkingOfPersonDto(System.DateTime.Now, null, null).ToList();

            // If we got this far, something failed, redisplay form
            return View(model);
        }
示例#3
0
        public ActionResult Index()
        {
            RegisterModel model = new RegisterModel();
            PersonService pservice = new PersonService();
            DepartmentService departmentService = new DepartmentService();

            //model.ListOfPersonName = pservice.GetListOnWorkingOfPersonName(System.DateTime.Now, null, null).ToList();
            model.Departments = departmentService.GetAll().ToList();
            model.ListOfPersonName = pservice.GetListOnWorkingOfPersonDto(System.DateTime.Now, null, null).ToList();

            return View(model);
        }
示例#4
0
        public JsonResult DeleteAllAccount()
        {
            string result = string.Empty;

            PersonService pservice = new PersonService();

            foreach (PersonAccount pa in pservice.GetAllPersonAccount())
            {
                result = DeleteByUserId(pa.UserId);

                if (result != string.Empty)
                    break;
            }

            return Json(result);
        }
示例#5
0
        public JsonResult CreateAccountAutomatic(string password)
        {
            string result = string.Empty;

            PersonService pservice = new PersonService();

            try
            {
                foreach (Person p in pservice.GetAll())
                {
                    if (p.Email != null && !p.Email.Trim().Equals(string.Empty) && !WebSecurity.UserExists(p.Email.Trim()))
                    {
                        RegisterModel model = new RegisterModel()
                        {
                            UserName = p.Email,
                            Password = password,
                            View1Role = true,
                            View2Role = false,
                            View3Role = false,
                            EditRole = false,
                            DeleteRole = false,
                            AdminRole = false,
                            PersonId = p.Id
                        };

                        AddNewAccount(model);
                    }
                }
            }
            catch (Exception ex)
            {
                result = "Lỗi: " + ex.Message;
            }

            return Json(result);
        }
示例#6
0
        public ActionResult GetList(JQueryDataTableParamModel param, string reportDate, int departmentId, int filter)
        {
            PersonService pservice = new PersonService();
            IEnumerable<PersonDto> allPersons = new List<PersonDto>();
            int? department = null;
            System.DateTime endedDate;

            if (!System.DateTime.TryParse(reportDate, out endedDate))
                endedDate = System.DateTime.Now;

            if (departmentId != -1)
                department = departmentId;

            switch (filter)
            {
                case 1:
                    if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view1Role))
                        allPersons = pservice.GetListOnWorkingOfPersonDto(System.DateTime.Now, department, pservice.GetPersonIdByUserId(WebSecurity.CurrentUserId));

                    if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view2Role))
                    {
                        Person p = pservice.GetPersonByUserId(WebSecurity.CurrentUserId);
                        if (p != null)
                        {
                            if (p.Department != null)
                            {
                                if (p.Department.Id == departmentId)
                                    allPersons = pservice.GetListOnWorkingOfPersonDto(System.DateTime.Now, departmentId, null);
                            }
                        }
                    }

                    if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view3Role))
                        allPersons = pservice.GetListOnWorkingOfPersonDto(System.DateTime.Now, department, null);

                    break;

                case 2:
                    if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view1Role))
                        allPersons = pservice.GetListAllOfReleasedPersonDto(System.DateTime.Now, department, pservice.GetPersonIdByUserId(WebSecurity.CurrentUserId));

                    if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view2Role))
                    {
                        Person p = pservice.GetPersonByUserId(WebSecurity.CurrentUserId);
                        if (p != null)
                        {
                            if (p.Department != null)
                            {
                                if (p.Department.Id == departmentId)
                                    allPersons = pservice.GetListOnWorkingOfPersonDto(System.DateTime.Now, departmentId, null);
                            }
                        }
                    }

                    if (Roles.IsUserInRole(WebSecurity.CurrentUserName, RoleNames.view3Role))
                        allPersons = pservice.GetListAllOfReleasedPersonDto(System.DateTime.Now, department, null);

                    break;
            }

            IEnumerable<PersonDto> filteredPersons;

            if (!string.IsNullOrEmpty(param.sSearch))
            {
                //Used if particulare columns are filtered
                var lastnameFilter = Convert.ToString(Request["sSearch_0"]);
                var firstnameFilter = Convert.ToString(Request["sSearch_1"]);
                var phongbanFilter = Convert.ToString(Request["sSearch_6"]);

                //Optionally check whether the columns are searchable at all
                var isLastnameSearchable = Convert.ToBoolean(Request["bSearchable_0"]);
                var isFirstnameSearchable = Convert.ToBoolean(Request["bSearchable_1"]);
                var isPhongBanSearchable = Convert.ToBoolean(Request["bSearchable_6"]);

                filteredPersons = allPersons
                   .Where(c => isLastnameSearchable && c.Lastname != null && c.Lastname.ToString().ToLower().Contains(param.sSearch.ToLower())
                            ||
                            isFirstnameSearchable && c.Firstname != null && c.Firstname.ToString().ToLower().Contains(param.sSearch.ToLower())
                           );
            }
            else
            {
                filteredPersons = allPersons;
            }

            var isLastnameSortable = Convert.ToBoolean(Request["bSortable_0"]);
            var isFirstnameSortable = Convert.ToBoolean(Request["bSortable_1"]);
            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            Func<PersonDto, string> orderingFunction = (c =>
                                                          sortColumnIndex == 2 && isLastnameSortable ? c.Lastname.ToString() :
                                                          sortColumnIndex == 3 && isFirstnameSortable ? c.Firstname.ToString() :
                                                          "");

            var sortDirection = Request["sSortDir_0"]; // asc or desc
            if (sortDirection == "asc")
                filteredPersons = filteredPersons.OrderBy(orderingFunction);
            else
                filteredPersons = filteredPersons.OrderByDescending(orderingFunction);

            IEnumerable<PersonDto> displayedPersons;

            if (param.iDisplayLength != -1)
                displayedPersons = filteredPersons.Skip(param.iDisplayStart).Take(param.iDisplayLength);
            else
                displayedPersons = filteredPersons;

            var result = from c in displayedPersons
                         select new string[]
                              {
                                  c.Id.ToString(),
                                  c.Lastname,
                                  c.Firstname,
                                  c.GenderName,
                                  c.Birthday,
                                  c.ChucDanhName,
                                  c.DepartmentName,
                                  c.PhoneNumber,
                                  c.Email,
                                  c.RecruitedDate,
                                  c.NgayNghi,
                                  c.Note
                              };

            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = allPersons.Count(),
                iTotalDisplayRecords = filteredPersons.Count(),
                aaData = result
            },
                        JsonRequestBehavior.AllowGet);
        }
示例#7
0
        public ActionResult Index()
        {
            PersonModel model = new PersonModel();
            GenderService genderService = new GenderService();
            DepartmentService departmentService = new DepartmentService();
            ChucDanhService chucDanhService = new ChucDanhService();
            PersonService personService = new PersonService();

            model.Departments = departmentService.GetAll().ToList();
            model.Departments.Insert(0, new Department() { Id = -1, Name = "Tất cả"});
            model.ChucDanhs = chucDanhService.GetAll().ToList();
            model.ReportDate = System.DateTime.Now.ToShortDateString();

            model.ListOfFilterNames = new List<FilterName>();
            model.ListOfFilterNames.Add(new FilterName() { Id = 1, Name = "Đang công tác" });
            model.ListOfFilterNames.Add(new FilterName() { Id = 2, Name = "Thôi việc" });
            model.ListOfFilterNames.Add(new FilterName() { Id = 3, Name = "Tất cả" });

            model.Genders = genderService.GetAll().ToList();
            return View(model);
        }