コード例 #1
0
        public ActionResult Change(ChangePasswordModel model)
        {
            var sess = SessionSystem.GetUser();

            if (ModelState.IsValid)
            {
                var    userInfo = SingletonIpl.GetInstance <IplUser>().Login(sess.UserName);
                string password = Framework.Security.Crypt.SHA.sha256_hash(model.OldPassword);
                if (userInfo.Password.Equals(password))
                {
                    var newPass = Framework.Security.Crypt.SHA.sha256_hash(model.NewPassword);
                    var flag    = SingletonIpl.GetInstance <IplUser>().ChangePass(sess.UserId, newPass);
                    if (flag)
                    {
                        Logs.logs("Thay đổi pass", "thay đổi pass thành công", "/ChangPassword/Change", sess.UserId);
                        SessionSystem.ClearSession();
                        return(Redirect("/Login"));
                    }
                }
                else
                {
                    ViewBag.MsgOldPass = ConstantMsg.OldPassInvalid;
                }
            }
            return(View("Index"));
        }
コード例 #2
0
        //public ActionResult Delete(int id)
        //{
        //    var trave = _iplProject.Delete(id);
        //    if (!trave)
        //        ViewBag.msg = "Occur Error. Contact to Administrator";
        //    return RedirectToAction("Index");
        //}
        public ActionResult Delete(int id)
        {
            var sessUser = SessionSystem.GetUser();
            var role     = _iplProject_Role.ViewDetail(sessUser.UserId, id);

            if (role != null)
            {
                if (role.Delete)
                {
                    var detail = _iplProject.ViewDetail(id);
                    if (detail != null && detail.Id > 0)
                    {
                        var ret = _iplProject.Delete(id);
                    }
                    int totalRow = 0;

                    var project = _iplProject.ListAllPaging("", 1, 10, ref totalRow);
                    return(View("Index", project.ToPagedList(1, 10, totalRow)));
                }
                else
                {
                    return(RedirectToAction("Denied", "NotFound"));
                }
            }
            else
            {
                return(RedirectToAction("Denied", "NotFound"));
            }
        }
コード例 #3
0
        public ActionResult Delete(int id)
        {
            var sess = SessionSystem.GetUser();

            Logs.logs("Xóa Department", "Truy cập vào trang Department", "/Department/", sess.UserId);
            List <DepartmentEntity> depart = _iplDepartment.ListAllByTreeView();

            //if(depart.Count(x =  .))

            foreach (var item in depart)
            {
                if (item.Id == id)
                {
                    List <DepartmentEntity> b = DepartmentChild(item.Id, depart);
                    b.Add(item);
                    foreach (var item2 in b)
                    {
                        var detail = _iplDepartment.ViewDetail(item2.Id);
                        if (detail != null && detail.Id > 0)
                        {
                            var ret = _iplDepartment.Delete(item2.Id);
                        }
                    }
                }
            }
            return(RedirectToAction("Index"));
            //int totalRow = 0;
            //var department = _iplDepartment.ListAllPaging("", 1, 10, ref totalRow);
            //return View("Index", department.ToPagedList(1, 10, totalRow));
        }
コード例 #4
0
        //phân quyền theo từng project
        public void RolesProject(int projectId)
        {
            var sessUser = SessionSystem.GetUser();
            var role     = _iplProject_Role.ViewDetail(sessUser.UserId, projectId);

            ViewData["AuthorizeProjectPriceView"] = role.View;
        }
コード例 #5
0
        // GET: Backend/Profile
        public ActionResult Index(int?id)
        {
            var iplDep = SingletonIpl.GetInstance <IplDepartment>();
            var allDep = iplDep.ListAll();

            ViewData["Department"] = allDep;
            var fullName   = string.Empty;
            var address    = string.Empty;
            var phone      = string.Empty;
            var avatarPath = string.Empty;
            var sess       = SessionSystem.GetUser();
            var emp        = new EmployeeEntity();

            id = id ?? sess.EmployeeId;
            if (sess != null)
            {
                emp = _iplEmployee.ViewDetail((int)id);

                fullName   = emp != null ? emp.FirstName + " " + emp.LastName : sess.Email;
                address    = emp != null ? emp.Address : string.Empty;
                phone      = emp != null ? emp.Phone : sess.Phone;
                avatarPath = !string.IsNullOrEmpty(emp.PicturePath) ? _imagePath + emp.PicturePath : "";
            }
            ViewBag.FullName = fullName;
            ViewBag.Address  = address;
            ViewBag.Phone    = phone;
            ViewBag.Avatar   = avatarPath;
            return(View("Index", emp));
        }
コード例 #6
0
        public ActionResult logout()
        {
            var sessUser = SessionSystem.GetUser();

            Logs.logs("Thoát ra ngoài,kết thúc phiên làm việc", "Logout", "/Login/Logout", sessUser.UserId);
            SessionSystem.ClearSession();
            return(View("Index"));
        }
コード例 #7
0
        public BaseController()
        {
            var sess = SessionSystem.GetUser();

            if (sess == null)
            {
                return;
            }
        }
コード例 #8
0
        public void Roles()
        {
            var sessUser = SessionSystem.GetUser();
            var module   = _iplModule.ViewDetailByName("ProjectPrice");


            var role = _iplRole.ViewDetail(sessUser.UserId, module.ID);

            ViewData["AuthorizePriceView"] = role.View;
        }
コード例 #9
0
        public ActionResult Delete(int id)
        {
            var sess = SessionSystem.GetUser();

            Logs.logs("Xóa nhân sự", "Truy cập vào trang Employee", "/Employee/", sess.UserId);
            var detail = _iplEmployee.ViewDetail(id);

            if (detail != null && detail.Id > 0)
            {
                var ret = _iplEmployee.Delete(id);
            }
            int totalRow = 0;

            var employee = _iplEmployee.ListAllPaging("", 1, 10, ref totalRow);

            return(View("Index", employee.ToPagedList(1, 10, totalRow)));
        }
コード例 #10
0
        public PartialViewResult Delete(int id, string Code = "", string Name   = "", int AddressToId = 0,
                                        int Type            = 0, int Department = 0, int Status = 0, int Priority = 0, string DateFrom = "", int page = 1, int pageSize = 10)
        {
            var sess = SessionSystem.GetUser();

            Logs.logs("Xóa công văn đến", "Truy cập vào trang DispatchIn", "/DispatchIn/", sess.UserId);
            var detail = _ipldispatchin.ViewDetail(id);

            if (detail != null && detail.Id > 0)
            {
                var ret = _ipldispatchin.Delete(id);
            }
            int totalRow   = 0;
            var dispatchIn = _ipldispatchin.ListAllPaging(Code, Name, Type, Department, Status, Priority,
                                                          DateFrom, AddressToId, page, pageSize, ref totalRow).ToPagedList(page, pageSize, totalRow);

            return(PartialView("_DispatchInList", dispatchIn));
        }
コード例 #11
0
 public JsonResult CreateComment(int id, string comment, int projectID)
 {
     if (id == 0)
     {
         var  sessUser   = SessionSystem.GetUser();
         long projectCmt = 0;
         Project_CommentEntity entity = new Project_CommentEntity();
         entity.Description = comment.ToString();
         entity.CreateDate  = DateTime.Now;
         entity.UserId      = sessUser.UserId;
         entity.ProjectId   = projectID;
         entity.FullName    = sessUser.FirstName + " " + sessUser.LastName;
         projectCmt         = _iplProjectComment.Insert(entity);
         if (projectCmt == -1)
         {
             return(Json(new { status = false }));
         }
         else
         {
             return(Json(new { status = true, data = 0 }));
         }
     }
     else
     {
         var  sessUser   = SessionSystem.GetUser();
         long projectCmt = 0;
         Project_CommentEntity entity = new Project_CommentEntity();
         entity.Description = comment.ToString();
         entity.CreateDate  = DateTime.Now;
         entity.UserId      = sessUser.UserId;
         entity.ProjectId   = projectID;
         entity.ParentId    = id;
         entity.FullName    = sessUser.FirstName + " " + sessUser.LastName;
         projectCmt         = _iplProjectComment.Insert(entity);
         if (projectCmt == -1)
         {
             return(Json(new { status = false }));
         }
         else
         {
             return(Json(new { status = true, data = id }));
         }
     }
 }
コード例 #12
0
        public JsonResult ResetPass(int userId)
        {
            var sess = SessionSystem.GetUser();

            Logs.logs("Reset lại pass", "Truy cập vào trang User", "/User/", sess.UserId);
            var ipluser    = SingletonIpl.GetInstance <IplUser>();
            var userExists = ipluser.ViewDetail(userId);

            if (userExists != null && userExists.Id > 0)
            {
                string newPass = Framework.Security.Crypt.SHA.sha256_hash("12345678");
                var    retVal  = ipluser.ChangePass(userId, newPass);
                return(Json(new
                {
                    status = retVal
                }));
            }
            return(Json(new { status = false }));
        }
コード例 #13
0
        public ActionResult Save(UserEntity entity)
        {
            if (ModelState.IsValid)
            {
                var sess = SessionSystem.GetUser();
                Logs.logs("Sửa User", "Truy cập vào trang User", "/User/", sess.UserId);
                var ipluser = SingletonIpl.GetInstance <IplUser>();
                entity.Password = Framework.Security.Crypt.SHA.sha256_hash(entity.Password);
                var userId = ipluser.Insert(entity);
                if (userId > 0)
                {
                    return(RedirectToAction("Index", "Roles", new { id = userId }));
                }
                ViewBag.Msg = ConstantMsg.ErrorProgress;
            }
            var iplemp  = SingletonIpl.GetInstance <IplEmployee>();
            var empInfo = iplemp.ViewDetail(entity.EmployeeId);

            ViewData["EmpInfo"] = empInfo;
            return(View("Index", entity));
        }
コード例 #14
0
        public ActionResult Save(EmployeeEntity model)
        {
            var entity = new EmployeeEntity();

            if (ModelState.IsValid)
            {
                if (model.Id > 0)
                {
                    var sess = SessionSystem.GetUser();
                    Logs.logs("Sửa Profile", "Truy cập vào trang Profile", "/Profile/", sess.UserId);
                    entity = _iplEmployee.ViewDetail(model.Id);
                    if (entity != null && entity.Id > 0)
                    {
                        entity.DepartmentId  = model.DepartmentId;
                        entity.FirstName     = model.FirstName;
                        entity.LastName      = model.LastName;
                        entity.Phone         = model.Phone;
                        entity.Address       = model.Address;
                        entity.AcademicLevel = model.AcademicLevel;

                        if (model.file != null && model.file.ContentLength > 0)
                        {
                            if (!Utility.CheckfileUpload(model.file.FileName))
                            {
                                ViewBag.msgUpload = ConstantMsg.ErrorImageFormat;
                                return(View(model));
                            }
                            var retUpload = Upload.upload(_imagePath, model.file, 250, 250);
                            entity.PicturePath = retUpload.pathThumb;
                        }
                        var retVal = _iplEmployee.Update(entity);
                    }
                }
            }
            var iplDep = SingletonIpl.GetInstance <IplDepartment>();
            var allDep = iplDep.ListAll();

            ViewData["Department"] = allDep;
            return(View("Index", entity));
        }
コード例 #15
0
        public ActionResult Save(Employee_HistoryEntity model)
        {
            var entity = new Employee_HistoryEntity();

            var iplPosition = SingletonIpl.GetInstance <IplPosition>();
            var allPosition = iplPosition.ListAll();

            ViewData["Position"] = allPosition;

            var iplDepartment = SingletonIpl.GetInstance <IplDepartment>();
            var allDepartment = iplDepartment.ListAll();

            ViewData["Department"] = allDepartment;


            if (model.Id > 0)
            {
                var sess = SessionSystem.GetUser();
                Logs.logs("Sửa lịch sử nhân sự", "Truy cập vào trang Employee_History", "/Employee_History/EditEmployee_History", sess.UserId);
                entity = _iplEmployee_history.ViewDetail(model.Id);
                if (entity != null && entity.Id > 0)
                {
                    entity.EmployeeId   = model.EmployeeId;
                    entity.DepartmentId = model.DepartmentId;
                    entity.Position     = model.Position;
                    entity.TimeIn       = model.TimeIn;
                    entity.TimeOut      = model.TimeOut;
                    entity.Note         = model.Note;
                    var retVal = _iplEmployee_history.Update(entity);
                    if (retVal)
                    {
                        return(RedirectToAction("Index", "Employee_History"));
                    }
                }
            }

            ViewBag.Msg = ConstantMsg.ErrorProgress;
            return(View("EditEmployee_History", model));
        }
コード例 #16
0
        public ActionResult Save(DispatchTypeEntity model)
        {
            var entity = new DispatchTypeEntity();

            //if (ModelState.IsValid)
            //{
            if (model.Id > 0)
            {
                var sess = SessionSystem.GetUser();
                Logs.logs("Sửa Loại công văn", "Truy cập vào trang DispatchType", "/DispatchType/CreateDispatchType", sess.UserId);
                entity = _ipldispatchtype.ViewDetail(model.Id);

                if (entity != null && entity.Id > 0)
                {
                    entity.Name = model.Name;

                    var retVal = _ipldispatchtype.Update(entity);
                    if (retVal)
                    {
                        return(RedirectToAction("Index", "DispatchType"));
                    }
                }
            }
            else
            {
                var sess = SessionSystem.GetUser();
                Logs.logs("Thêm mới Loại công văn", "Truy cập vào trang DispatchType", "/DispatchType/CreateDispatchType", sess.UserId);
                model.Createdate = DateTime.Now;
                var empId = _ipldispatchtype.Insert(model);
                if (empId > 0)
                {
                    return(RedirectToAction("Index", "DispatchType", new { id = empId }));
                }
            }
            //}
            ViewBag.Msg = ConstantMsg.ErrorProgress;
            return(View("DispatchType", model));
        }
コード例 #17
0
        //[AuthorizeUser(ModuleName = "Project", AccessLevel = Constants.Add)]
        public ActionResult CreateOrEdit(int?id)
        {
            var sessUser = SessionSystem.GetUser();

            LoadData();
            ProjectEntity entity = new ProjectEntity();

            if (id.HasValue)
            {
                var role = _iplProject_Role.ViewDetail(sessUser.UserId, id.Value);
                if (role != null)
                {
                    if (role.Edit)
                    {
                        ViewBag.Title = "Sửa thông tin dự án";
                        //Edit
                        entity = _iplProject.ViewDetail(id.Value);
                        if (entity == null)
                        {
                            return(HttpNotFound("Không tìm thấy tin"));
                        }
                        return(View(entity));
                    }
                    else
                    {
                        return(RedirectToAction("Denied", "NotFound"));
                    }
                }
                else
                {
                    return(RedirectToAction("Denied", "NotFound"));
                }
            }


            return(View());
        }
コード例 #18
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)

        {
            var sess       = SessionSystem.GetUser();
            var returnUrl  = filterContext.RequestContext.HttpContext.Request.RawUrl;
            int indexParam = returnUrl.IndexOf('?');
            int indexP     = 0;
            int temp1      = returnUrl.Count(f => f == '/');

            if (returnUrl.Count(f => f == '/') > 2)
            {
                indexP = returnUrl.LastIndexOf('/');
            }
            string temp = returnUrl;

            if (indexParam > -1)
            {
                temp = returnUrl.Substring(0, indexParam);
            }
            if (indexP > 0)
            {
                temp = returnUrl.Substring(0, indexP);
            }
            // LongNDG Check url request and get current module
            var urls = temp.Split('/');
            var url  = "";

            if (urls.Length > 2)
            {
                url = urls[2];
            }
            else
            {
                url = "Home";
            }
            //var test = urls[2];
            if (sess == null)
            {
                filterContext.Result = new RedirectToRouteResult(new
                                                                 RouteValueDictionary(new { controller = "Login", action = "Index", returnUrl = returnUrl.ToString() }));
            }
            else
            {
                //Check token online. Logging a only PC
                //var userDetail = obj.ViewDetail(sess.AccID,sess.Token);
                //if (userDetail == null)
                //{
                //    this.Session.Clear();
                //    filterContext.Result = new RedirectToRouteResult(new
                //           RouteValueDictionary(new { controller = "Login", action = "Index", Area = "manager", returnUrl = returnUrl.ToString() }));
                //}
                //else {
                if (Session["Role_" + sess.UserName] != null)
                {
                    if (temp == "/ChangePassword/ChangePwd")
                    {
                        return;
                    }
                    var checkRole = (List <RoleEntity>)Session["Role_" + sess.UserName];
                    int index     = -1;
                    if (returnUrl != "/")
                    {
                        for (int i = 0; i < checkRole.Count; i++)
                        {
                            if (checkRole[i].Name.ToLower().IndexOf(url.ToLower()) != -1)
                            {
                                index = i;
                            }
                        }
                        if (index >= 0)
                        {
                            if (!checkRole[index].View)
                            {
                                filterContext.Result = new RedirectToRouteResult(new
                                                                                 RouteValueDictionary(new { controller = "NotFound", action = "Denied", returnUrl = returnUrl.ToString() }));
                            }
                        }
                        //else
                        //{
                        //    filterContext.Result = new RedirectToRouteResult(new
                        //        RouteValueDictionary(new { controller = "NotFound", action = "Denied", Area = "Backend", returnUrl = returnUrl.ToString() }));
                        //    //filterContext.Result = new RedirectResult("/manager/Denied/Index");
                        //}
                    }
                }
                else
                {
                    filterContext.Result = new RedirectToRouteResult(new
                                                                     RouteValueDictionary(new { controller = "NotFound", action = "Denied", returnUrl = returnUrl.ToString() }));
                }
                //}
            }
            base.OnActionExecuting(filterContext);
        }
コード例 #19
0
        // GET: ProjectComment
        /// <summary>
        /// Lấy các bình luận về project
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Index(long?id)
        {
            if (id.HasValue && id.Value > 0)
            {
                var sessUser = SessionSystem.GetUser();
                var role     = _iplProjectRole.ViewDetail(sessUser.UserId, id.Value);
                if (role != null)
                {
                    if (role.View == true)
                    {
                        RolesProject(id.Value);
                        ViewBag.id = id.Value;
                        //Lấy thông tin người đăng nhập
                        var objProject = _iplProject.ViewDetail(id.Value);
                        try
                        {
                            ViewBag.ProjectName  = objProject.Name;
                            ViewBag.Description  = objProject.Description;
                            ViewBag.ProjectPrice = objProject.Price;

                            var statusproject = _iplProject_Status.ViewDetail(objProject.StatusId);
                            ViewBag.Status = statusproject.Name;

                            var sales = _iplEmployee.ViewDetail(objProject.SalesId);
                            ViewBag.sales = sales.FirstName + " " + sales.LastName;
                            var roles = _iplProjectRole.ListAllByProject(objProject.Id);


                            foreach (var item in roles)
                            {
                                ViewBag.Lanhdao = item.FullName + " ;";
                                //string positionname = item.PositionName;
                                //switch (positionname)
                                //{
                                //    case "Lãnh đạo":
                                //        ViewBag.Lanhdao = item.FullName + " ;";
                                //        break;
                                //    case "Kỹ thuật":
                                //        ViewBag.Technical = item.FullName + " ;";
                                //        break;
                                //    case "Trợ lý":
                                //        ViewBag.Troly = item.FullName + " ;";
                                //        break;
                                //    case "Mua hàng":
                                //        ViewBag.Muahang = item.FullName + " ;";
                                //        break;
                                //    default:
                                //        break;
                                //}
                            }
                            //ViewBag.Troly = "";


                            //ViewBag.Technical = "";
                            var customer = _iplCustomer.ViewDetail(objProject.CustomerId);
                            ViewBag.Customer = customer.Name;
                        }
                        catch { }
                        if (objProject != null)
                        {
                            //Lấy toàn bộ danh sách các bình luận theo dự án
                            List <Project_CommentEntity> glst = _iplProjectComment.GetByFKProject(objProject.Id);
                            return(View(glst));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("Denied", "NotFound"));
                    }
                }
                else
                {
                    return(RedirectToAction("Denied", "NotFound"));
                }
            }
            else
            {
                ViewData["ID"] = 0;
            }
            return(View());
        }
コード例 #20
0
        public ActionResult Save(DepartmentEntity model)
        {
            var entity       = new DepartmentEntity();
            var employeetity = new EmployeeEntity();

            ReturnViewData(0);
            if (ModelState.IsValid)
            {
                if (model.Id > 0) //update
                {
                    var sess = SessionSystem.GetUser();
                    Logs.logs("Sửa Department", "Truy cập vào trang CreateDepartment", "/Department/CreateDepartment", sess.UserId);
                    entity = _iplDepartment.ViewDetail(model.Id);
                    if (entity != null && entity.Id > 0)
                    {
                        //get thông tin của Phòng
                        entity.ParentId = model.ParentId;
                        entity.Name     = model.Name;
                        entity.Location = model.Location;
                        //entity.CreatedDate = model.CreatedDate;
                        entity.ModifiedDate               = DateTime.Now;
                        entity.EmployeeManagerId          = model.EmployeeManagerId;
                        entity.EmployeeDebutyManagerId    = model.EmployeeDebutyManagerId;
                        entity.EmployeeChiefOfTheOfficeId = model.EmployeeChiefOfTheOfficeId;
                        entity.SumEmployeesExpected       = model.SumEmployeesExpected;
                        var retVal = _iplDepartment.Update(entity);

                        if (retVal)
                        {
                            int departid = entity.Id;
                            if (departid > 0)
                            {
                                employeetity = _iplEmployee.ViewDetail(model.EmployeeManagerId);//lấy thông tin user trưởng phòng
                                if (employeetity != null && employeetity.Id > 0)
                                {
                                    if (employeetity.DepartmentId != departid) //check xem nếu nằm trong phòng hiện tại thì bỏ qua.
                                    {
                                        employeetity.LastDepartment = employeetity.DepartmentId;
                                        //trường hợp đổi phòng thì update lại phòng cũ chưa có vị trí mà employee này từng làm
                                        entity = _iplDepartment.ViewDetail(employeetity.LastDepartment);
                                        entity.EmployeeManagerId = 0;
                                        var updatedepartment = _iplDepartment.Update(entity);

                                        SaveHistory(employeetity, departid, _iplEmployee_History);
                                    }
                                    employeetity.DepartmentId = departid; //update cho employee thông tin về bộ phận làm việc.
                                    employeetity.ModifiedDate = DateTime.Now;
                                    var revalmanager = _iplEmployee.Update(employeetity);
                                }

                                employeetity = _iplEmployee.ViewDetail(model.EmployeeDebutyManagerId);// thông tin phó phòng
                                if (employeetity != null && employeetity.Id > 0)
                                {
                                    if (employeetity.DepartmentId != departid)
                                    {
                                        employeetity.LastDepartment = employeetity.DepartmentId;
                                        //trường hợp đổi phòng thì update lại phòng cũ chưa có vị trí mà employee này từng làm
                                        entity = _iplDepartment.ViewDetail(employeetity.LastDepartment);
                                        entity.EmployeeDebutyManagerId = 0;
                                        var updatedepartment = _iplDepartment.Update(entity);

                                        SaveHistory(employeetity, departid, _iplEmployee_History);
                                    }
                                    employeetity.DepartmentId = departid; //update cho employee thông tin về bộ phận làm việc.
                                    employeetity.ModifiedDate = DateTime.Now;

                                    var revalmanager = _iplEmployee.Update(employeetity);
                                }

                                employeetity = _iplEmployee.ViewDetail(model.EmployeeChiefOfTheOfficeId);// thông tin Chánh văn phòng
                                if (employeetity != null && employeetity.Id > 0)
                                {
                                    if (employeetity.DepartmentId != departid)
                                    {
                                        employeetity.LastDepartment = employeetity.DepartmentId;
                                        //trường hợp đổi phòng thì update lại phòng cũ chưa có vị trí mà employee này từng làm
                                        entity = _iplDepartment.ViewDetail(employeetity.LastDepartment);
                                        entity.EmployeeChiefOfTheOfficeId = 0;
                                        var updatedepartment = _iplDepartment.Update(entity);

                                        SaveHistory(employeetity, departid, _iplEmployee_History);
                                    }
                                    employeetity.DepartmentId = departid; //update cho employee thông tin về bộ phận làm việc.
                                    employeetity.ModifiedDate = DateTime.Now;
                                    var revalmanager = _iplEmployee.Update(employeetity);
                                }
                            }
                            return(RedirectToAction("Index", "Department"));
                        }
                    }
                }
                else //insert
                {
                    var sess = SessionSystem.GetUser();
                    Logs.logs("Thêm mới Department", "Truy cập vào trang CreateDepartment", "/Department/CreateDepartment", sess.UserId);
                    model.CreatedDate = DateTime.Now;
                    var departid = _iplDepartment.Insert(model);
                    if (departid > 0)
                    {
                        employeetity = _iplEmployee.ViewDetail(model.EmployeeManagerId);//lấy thông tin user trưởng phòng
                        if (employeetity != null && employeetity.Id > 0)
                        {
                            if (employeetity.DepartmentId != departid)
                            {
                                employeetity.LastDepartment = employeetity.DepartmentId;
                            }
                            employeetity.DepartmentId = departid; //update cho employee thông tin về bộ phận làm việc.
                            employeetity.ModifiedDate = DateTime.Now;
                            var revalmanager = _iplEmployee.Update(employeetity);
                        }

                        employeetity = _iplEmployee.ViewDetail(model.EmployeeDebutyManagerId);// thông tin phó phòng
                        if (employeetity != null && employeetity.Id > 0)
                        {
                            if (employeetity.DepartmentId != departid)
                            {
                                employeetity.LastDepartment = employeetity.DepartmentId;
                            }
                            employeetity.DepartmentId = departid; //update cho employee thông tin về bộ phận làm việc.
                            employeetity.ModifiedDate = DateTime.Now;

                            var revalmanager = _iplEmployee.Update(employeetity);
                        }

                        employeetity = _iplEmployee.ViewDetail(model.EmployeeChiefOfTheOfficeId);// thông tin Chánh văn phòng
                        if (employeetity != null && employeetity.Id > 0)
                        {
                            if (employeetity.DepartmentId != departid)
                            {
                                employeetity.LastDepartment = employeetity.DepartmentId;
                            }
                            employeetity.DepartmentId = departid; //update cho employee thông tin về bộ phận làm việc.
                            employeetity.ModifiedDate = DateTime.Now;
                            var revalmanager = _iplEmployee.Update(employeetity);
                        }

                        return(RedirectToAction("Index", "Department", new { id = departid }));
                    }
                }
            }
            ViewBag.Msg = ConstantMsg.ErrorProgress;
            return(View("CreateDepartment", model));
        }
コード例 #21
0
        public ActionResult Save(DispatchInEntity model)
        {
            var entity   = new DispatchInEntity();
            var sessUser = SessionSystem.GetUser();

            if (model.File != null)
            {
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    model.File.InputStream.CopyTo(memoryStream);
                }
            }
            if (ModelState.IsValid)
            {
                var sess = SessionSystem.GetUser();
                //model.FileId = 0;
                if (model.Id > 0) //update
                {
                    Logs.logs("Sửa Công văn đến", "Truy cập vào trang DispatchIn", "/DispatchIn/CreateDispatchIn", sess.UserId);
                    entity = _ipldispatchin.ViewDetail(model.Id);
                    if (entity != null && entity.Id > 0)
                    {
                        entity.DispatchNo     = model.DispatchNo;
                        entity.DispatchName   = model.DispatchName;
                        entity.DispatchType   = model.DispatchType;
                        entity.Priority       = model.Priority;
                        entity.DateFrom       = model.DateFrom;
                        entity.DatePublish    = model.DatePublish;
                        entity.Signer         = model.Signer;
                        entity.DispatchStatus = model.DispatchStatus;
                        entity.AddressFromId  = model.AddressFromId;
                        entity.AddressToId    = model.AddressToId;
                        entity.ReceiverId     = model.ReceiverId;
                        entity.ChiefOfStaffId = model.ChiefOfStaffId;
                        entity.Note           = model.Note;
                        entity.Description    = model.Description;
                        entity.ModifiedBy     = sessUser.UserId;
                        entity.ModifiedDate   = DateTime.Now;

                        var retVal = _ipldispatchin.Update(entity);

                        if (retVal)
                        {
                            int departid = entity.Id;

                            var OldFile = _iplfile.ViewDetail(model.FileId);
                            if (model.File != null)
                            {
                                OldFile.IsDel = true;
                                _iplfile.Update(OldFile); //đổi file cũ sang trạng thái đã xóa
                            }
                            SaveFile(model.Id, sessUser.UserId, model);
                            return(RedirectToAction("Index", "DispatchIn", new { AddressToId = model.AddressToId }));
                        }
                    }
                }
                else //insert
                {
                    Logs.logs("Thêm Công văn đến", "Truy cập vào trang DispatchIn", "/DispatchIn/CreateDispatchIn", sess.UserId);
                    model.CreatedBy   = sessUser.UserId;
                    model.CreatedDate = DateTime.Now;
                    var Id = _ipldispatchin.Insert(model);
                    if (Id > 0)
                    {
                        SaveFile(Id, sessUser.UserId, model);
                        return(RedirectToAction("Index", "DispatchIn", new { AddressToId = model.AddressToId }));
                    }
                }
            }
            else
            {
                ListDropdown();
            }
            ViewBag.Msg = ConstantMsg.ErrorProgress;
            return(View("CreateDispatchIn", model));
        }
コード例 #22
0
        public ActionResult CreateOrEdit(ProjectEntity entity, int?id)
        {
            var sessUser = SessionSystem.GetUser();

            LoadData();
            if (ModelState.IsValid)
            {
                entity.IsDel = false;

                foreach (var item in entity.SelectedIDListManager)
                {
                    entity.ListManager += item.ToString() + ";";
                }

                //foreach (var item in entity.SelectedIDListTechnical)
                //{
                //    entity.ListTechnical += item.ToString() + ";";
                //}
                //foreach (var item in entity.SelectedIDListAssistant)
                //{
                //    entity.ListAssistant += item.ToString() + ";";
                //}
                //foreach (var item in entity.SelectedIDListBuyer)
                //{
                //    entity.ListBuyer += item.ToString() + ";";
                //}

                int projectId = 0;

                if (id.HasValue && id.Value > 0) //update
                {
                    var role = _iplProject_Role.ViewDetail(sessUser.UserId, id.Value);
                    if (role != null)
                    {
                        if (role.Edit)
                        {
                            var entityExist = _iplProject.ViewDetail(id.Value);
                            if (entityExist == null)
                            {
                                return(HttpNotFound("Không có tin tức"));
                            }
                            entityExist.Name          = entity.Name;
                            entityExist.Price         = entity.Price;
                            entityExist.CustomerId    = entity.CustomerId;
                            entityExist.SalesId       = entity.SalesId;
                            entityExist.ModifiedDate  = DateTime.Now;
                            entityExist.ListAssistant = entity.ListAssistant;
                            entityExist.ListManager   = entity.ListManager;
                            entityExist.ListTechnical = entity.ListTechnical;
                            entityExist.ListBuyer     = entity.ListBuyer;
                            entityExist.TypeId        = entity.TypeId;
                            entityExist.StatusId      = entity.StatusId;
                            entityExist.Description   = entity.Description;
                            projectId = _iplProject.Update(entityExist);
                            ActionProject_Roles(projectId, entity, "edit");
                        }
                        else
                        {
                            return(RedirectToAction("Denied", "NotFound"));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("Denied", "NotFound"));
                    }
                }
                else //insert
                {
                    entity.CreateDate = DateTime.Now;
                    projectId         = _iplProject.Insert(entity);

                    //ActionProject_Roles(projectId, entity,"add");
                }
                if (projectId < 1)
                {
                    ModelState.AddModelError("Name", "Xảy ra lỗi, vui lòng liên hệ với coder");
                    return(View(entity));
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(entity));
            }
        }
コード例 #23
0
        //[AuthorizeUser(ModuleName = "Employee", AccessLevel = Constants.Save)]
        public ActionResult Save(EmployeeEntity model, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                EmployeeEntity entity       = _iplEmployee.ViewDetail(model.Id);
                var            DepartmentId = form["DepartmentId"];
                var            PositionId   = form["Position"];
                string[]       arrayDepartment;
                string[]       arrayPosition;
                arrayDepartment = DepartmentId.Split(',');
                arrayPosition   = PositionId.Split(',');
                var      DispatchWorkId = form["DispatchWork"];
                string[] arrayDispatchWork;
                arrayDispatchWork = DispatchWorkId.Split(',');

                #region Sửa Employee
                if (model.Id > 0)
                {
                    var sess = SessionSystem.GetUser();
                    Logs.logs("Sửa nhân sự", "Truy cập vào trang Employee", "/Employee/CreateEmployee", sess.UserId);
                    #region Sửa lịch sử Chức Vụ, Phòng Ban
                    if (DepartmentId != null && PositionId != null && arrayDepartment.Count() > 0 && arrayPosition.Count() == arrayDepartment.Count())
                    {
                        //ListHistory là list thêm mới, sửa phòng, chức
                        List <Employee_HistoryEntity> listHistory = ListHistory(model.Id, arrayDepartment, arrayPosition);
                        //ListHistoryOld lấy ra thằng TimeOut = null và IdDepartment và IdPosition không có trong param hoặc bị xóa
                        List <Employee_HistoryEntity> EmpHisOld = ListHistoryOld(model.Id, arrayDepartment, arrayPosition);
                        if (listHistory != null && listHistory.Count() == 0 && EmpHisOld != null && EmpHisOld.Count() > 0)
                        {
                            foreach (var item in EmpHisOld)
                            {
                                var listHistoryOld = _iplEmployee_History.SelectByPositionDepartment(item.EmployeeId, item.Position, item.DepartmentId);
                                if (listHistoryOld != null)
                                {
                                    listHistoryOld.TimeOut = DateTime.Now;
                                    var updateEmpHis = _iplEmployee_History.Update(listHistoryOld);
                                }
                            }
                        }
                        if (listHistory != null && listHistory.Count() > 0)
                        {
                            //Lưu thời gian nghỉ
                            foreach (var item in EmpHisOld)
                            {
                                var listHistoryOld = _iplEmployee_History.SelectByPositionDepartment(item.EmployeeId, item.Position, item.DepartmentId);
                                if (listHistoryOld != null)
                                {
                                    listHistoryOld.TimeOut = DateTime.Now;
                                    var updateEmpHis = _iplEmployee_History.Update(listHistoryOld);
                                }
                            }
                            foreach (var item in listHistory)
                            {
                                var EmpHis = new Employee_HistoryEntity();
                                EmpHis.Position     = item.Position;
                                EmpHis.DepartmentId = item.DepartmentId;
                                EmpHis.EmployeeId   = model.Id;
                                EmpHis.TimeIn       = DateTime.Now;
                                EmpHis.Note         = item.Note != null ? item.Note : form["Department" + item.DepartmentId];
                                _iplEmployee_History.Insert(EmpHis);
                            }
                        }
                        //Xóa liên kết cũ
                        _iplEmployee.DeleteDepartment(model.Id);
                        //Lưu liên kết mới
                        for (int i = 0; i < arrayDepartment.Count(); i++)
                        {
                            Employee_Department a = new Employee_Department();
                            a.IdDepartment = int.Parse(arrayDepartment[i]);
                            a.IdEmployee   = model.Id;
                            a.IdPosition   = int.Parse(arrayPosition[i]);
                            _iplEmployee.InsertDepartment(a);
                        }
                    }
                    else
                    {
                        ReturnFalse(model.Id);
                        ViewBag.ErrPosition = "Chức vụ và phòng ban phải tương đồng.";
                        return(View("CreateEmployee", model));
                    }
                    #endregion
                    #region Sửa Công Việc
                    if (DispatchWorkId != null)
                    {
                        //Xóa liên kết cũ
                        _iplEmployee.DeleteWork(model.Id);
                        //Lưu liên kết mới
                        foreach (var item in arrayDispatchWork)
                        {
                            Employee_DispatchWork a = new Employee_DispatchWork();
                            a.IdDispatchWork = int.Parse(item);
                            a.IdEmployee     = model.Id;
                            _iplEmployee.InsertDispatchWork(a);
                        }
                    }
                    else
                    {
                        ReturnFalse(model.Id);
                        ViewBag.ErrDispatchWork = "Công việc không được để trống.";
                        return(View("CreateEmployee", model));
                    }
                    #endregion
                    if (entity != null && entity.Id > 0)
                    {
                        entity.FirstName            = model.FirstName;
                        entity.LastName             = model.LastName;
                        entity.Phone                = model.Phone;
                        entity.Address              = model.Address;
                        entity.AcademicLevel        = model.AcademicLevel;
                        entity.Birthday             = model.Birthday;
                        entity.Gender               = model.Gender;
                        entity.IsActive             = model.IsActive;
                        entity.Position             = model.Position;
                        entity.DepartmentId         = model.DepartmentId;
                        entity.WageAgreement        = model.WageAgreement;
                        entity.ProbationaryFromDate = model.ProbationaryFromDate;
                        entity.ProbationaryToDate   = model.ProbationaryToDate;
                        entity.WorkFromDate         = model.WorkFromDate;
                        entity.WorkToDate           = model.WorkToDate;

                        if (model.file != null && model.file.ContentLength > 0)
                        {
                            if (!Utility.CheckImageFormat(model.file.FileName))
                            {
                                ViewBag.msgUpload = ConstantMsg.ErrorImageFormat;
                                return(View(model));
                            }
                            var retUpload = Upload.upload(_imagePath, model.file, 250, 250);
                            entity.PicturePath = retUpload.pathThumb;
                        }
                        var retVal = _iplEmployee.Update(entity);

                        if (retVal)
                        {
                            return(RedirectToAction("Index", "Employee"));
                        }
                    }
                }
                #endregion
                #region Thêm mới Employee
                else
                {
                    var sess = SessionSystem.GetUser();
                    Logs.logs("Thêm nhân sự", "Truy cập vào trang Employee", "/Employee/CreateEmployee", sess.UserId);
                    if (model.file != null && model.file.ContentLength > 0)
                    {
                        if (!Utility.CheckImageFormat(model.file.FileName))
                        {
                            ViewBag.msgUpload = ConstantMsg.ErrorImageFormat;
                            return(View(model));
                        }
                        var retUpload = Upload.upload(_imagePath, model.file, 250, 250);
                        model.PicturePath = retUpload.pathThumb;
                    }
                    var empId = _iplEmployee.Insert(model);

                    if (empId > 0)
                    {
                        for (int i = 0; i < arrayDepartment.Count(); i++)
                        {
                            var EmpHis = new Employee_HistoryEntity();
                            EmpHis.Position     = int.Parse(arrayPosition[i]);
                            EmpHis.DepartmentId = int.Parse(arrayDepartment[i]);
                            EmpHis.EmployeeId   = empId;
                            EmpHis.TimeIn       = DateTime.Now;
                            EmpHis.Note         = "Bắt đầu làm việc";
                            _iplEmployee_History.Insert(EmpHis);

                            var employee_Department = new Employee_Department();
                            employee_Department.IdDepartment = int.Parse(arrayDepartment[i]);
                            employee_Department.IdEmployee   = empId;
                            employee_Department.IdPosition   = int.Parse(arrayPosition[i]);
                            _iplEmployee.InsertDepartment(employee_Department);
                        }
                        //Lưu liên kết mới
                        foreach (var item in arrayDispatchWork)
                        {
                            Employee_DispatchWork a = new Employee_DispatchWork();
                            a.IdDispatchWork = int.Parse(item);
                            a.IdEmployee     = empId;
                            _iplEmployee.InsertDispatchWork(a);
                        }
                        return(RedirectToAction("Index", "User", new { id = empId }));
                    }
                }
                #endregion
            }
            ReturnFalse(model.Id);
            return(View("CreateEmployee", model));
        }