Ejemplo n.º 1
0
        public EditEmployeeViewModel GetEmployeeProfile(string IDNO)
        {
            DALProfile _profile = new DALProfile();
            GetEmployeeProfileModel _model = _profile.GetEmployeeProfile(IDNO);

            EditEmployeeViewModel _employee = new EditEmployeeViewModel();
            _employee.FirstName = _model.FirstName;
            _employee.MiddleName = _model.MiddleName;
            _employee.LastName = _model.LastName;

            byte[] IDs = GetPositionStatusIDs(_model.Position, _model.EmploymentStatus);
            _employee.PositionTitleID = IDs[0];
            _employee.Position = _profile.GetPositionTitles();
            _employee.EmploymentStatusId = IDs[1];
            _employee.EmploymentStatus = _profile.GetEmploymentStatus();

            int space = _model.HireDate.ToString().IndexOf(" ");
            _employee.DateHired = _model.HireDate.ToString().Remove(space);

            _employee.CardNo = _model.CardNo;
            _employee.isActive = _model.isActive;
            _employee.IsLocked = _model.IsLocked;

            _employee.DepartmentId = _model.DepartmentId;
            _employee.CivilStatusId = _model.CivilStatusId;
            _employee.Gender = _model.Gender;
            _employee.Email = _model.Email;


            return _employee;
        }
Ejemplo n.º 2
0
        public ActionResult Edit(EditEmployeeViewModel model)
        {
            BLLProfile _profile = new BLLProfile();

            try
            {
                if(ModelState.IsValid)
                {
                    
                    if(_profile.UpdateEmployeeProfile(model, User.IDNO))
                    {
                        TempData["editEmployee_result"] = "Employee profile has successfully been updated.";
                    }
                    else
                    {
                        ModelState.AddModelError("", "An error has occurred."); 
                    }
                }

                EditEmployeeViewModel _employee = _profile.GetEmployeeProfile(model.IDNO);
                _employee.CivilStatus = _profile.GetCivilStatus();
                _employee.Position = _profile.GetPositionTitles();
                _employee.Department = _profile.GetDepartmentNames();
                _employee.EmploymentStatus = _profile.GetEmploymentStatus();

                return View(_employee);
            }
            catch(Exception e)
            {
                EditEmployeeViewModel _employee = _profile.GetEmployeeProfile(model.IDNO);
                _employee.CivilStatus = _profile.GetCivilStatus();
                _employee.Position = _profile.GetPositionTitles();
                _employee.Department = _profile.GetDepartmentNames();
                _employee.EmploymentStatus = _profile.GetEmploymentStatus();

                ModelState.AddModelError("", e.StackTrace);

                return View(_employee);
            }
        }
Ejemplo n.º 3
0
        public bool UpdateEmployeeProfile(EditEmployeeViewModel model, string rowmodifiedby)
        {
            DALProfile _profile = new DALProfile();

            return _profile.UpdateEmployeeProfile(model, rowmodifiedby);
        }
Ejemplo n.º 4
0
        public bool UpdateEmployeeProfile(EditEmployeeViewModel model, string rowmodifiedby)
        {
            using(DataContext _context = new DataContext())
            {
                int _rowsAffected = _context.Database.ExecuteSqlCommand("pUpdateEmployeeProfile @xIDNO, " +
                    "@xFirstName, @xMiddleName, @xLastName, @xPositionTitleID, @xEmploymentStatusId, " + 
                    "@xCardNo, @xHireDate, @xisActive, @xIsLocked, @xRowModifiedBy",
                    new SqlParameter("@xIDNO", model.IDNO),
                    new SqlParameter("@xFirstName", model.FirstName),
                    new SqlParameter("@xMiddleName", (object)model.MiddleName ?? DBNull.Value),
                    new SqlParameter("@xLastName", model.LastName),
                    new SqlParameter("@xPositionTitleID", model.PositionTitleID),
                    new SqlParameter("@xEmploymentStatusId", model.EmploymentStatusId),
                    new SqlParameter("@xCardNo", model.CardNo),
                    new SqlParameter("@xHireDate", model.DateHired),
                    new SqlParameter("@xisActive", model.isActive),
                    new SqlParameter("@xIsLocked", model.IsLocked),
                    new SqlParameter("@xRowModifiedBy", rowmodifiedby));

                _context.Database.Connection.Close();
                _context.Database.Connection.Dispose();

                return (_rowsAffected == 2) ? true : false;
            }
        }