コード例 #1
0
ファイル: ProfileController.cs プロジェクト: rafaelbacus/EMP
        public ActionResult Create(NewEmployeeViewModel model)
        {
            BLLProfile _profile = new BLLProfile();

            try
            {
                if (ModelState.IsValid)
                {
                    if (_profile.NewEmployee(model, User.IDNO))
                    {
                        return RedirectToAction("Index");
                    }
                    else
                    {
                        ModelState.AddModelError("", "An error has been encountered. Please contact your System Administrator.");
                    }
                }

                NewEmployeeViewModel _newEmployee = new NewEmployeeViewModel();
                _newEmployee.Position = _profile.GetPositionTitles();
                _newEmployee.EmploymentStatus = _profile.GetEmploymentStatus();

                return View(_newEmployee);
            }
            catch
            {
                NewEmployeeViewModel _newEmployee = new NewEmployeeViewModel();
                _newEmployee.Position = _profile.GetPositionTitles();
                _newEmployee.EmploymentStatus = _profile.GetEmploymentStatus();

                ModelState.AddModelError("", "An error has been encountered. Please contact your System Administrator.");

                return View(_newEmployee);
            }
        }
コード例 #2
0
ファイル: ProfileController.cs プロジェクト: rafaelbacus/EMP
 public ActionResult Create()
 {
     NewEmployeeViewModel _newEmployee = new NewEmployeeViewModel();
     BLLProfile _profile = new BLLProfile();
     _newEmployee.Password = _profile.GeneratePassword();
     _newEmployee.Position = _profile.GetPositionTitles();
     _newEmployee.Department = _profile.GetDepartmentNames();
     _newEmployee.CivilStatus = _profile.GetCivilStatus();
     _newEmployee.EmploymentStatus = _profile.GetEmploymentStatus();
     return View(_newEmployee);
 }
コード例 #3
0
ファイル: BLLEmail.cs プロジェクト: rafaelbacus/EMP
        public bool EmailEmployee(LeaveViewModel model)
        {
            bool sendSuccess = false;

            BLLProfile _profile = new BLLProfile();

            using (SmtpClient client = new SmtpClient(SERVER, PORT))
            {
                string EMAIL_FROM = "*****@*****.**";
                string SUBJECT = "Leave of Absence Application [" + model.LeaveStatus + "]";
                string EMAIL_TO = _profile.GetEmployeeProfile(model.EmployeeIDNO).Email; 

                string status = "";
                switch (model.LeaveStatus)
	            {
                    case "Approved": 
                        status = "<strong style='color:#5CB85C'>APPROVED</strong>";
                        break;
                    case "Declined":
                        status = "<strong style='color:#D9534F'>DECLINED</strong>";
                        break;
		            default: break;
	            }

                StringBuilder BODY = new StringBuilder();
                BODY.Append("<p>The following Leave of Absence application has been " + status + ":</p><br>");
                BODY.Append("<p><strong>Date Filed: </strong>" + model.DateFiled.ToShortDateString() + "</p>");
                BODY.Append("<p><strong>Type: </strong>" + model.LeaveType + "</p>");
                BODY.Append("<p><strong>From: </strong>" + model.DateOfLeaveFrom.ToShortDateString() + "</p>");
                BODY.Append("<p><strong>To: </strong>" + model.DateOfLeaveTo.ToShortDateString() + "</p>");
                BODY.Append("<p><strong>Address: </strong>" + model.Address + "</p>");
                BODY.Append("<p><strong>Reason: </strong>" + model.Reason + "</p>");
                BODY.Append("<p><strong>Remarks: </strong>" + model.RemarksForEmployee + "</p><br>");
                BODY.Append("<p>Contact your Manager or HR for any questions.<p>");
                BODY.Append("<p>EMP<p>");

                MailMessage msg = new MailMessage(EMAIL_FROM, EMAIL_TO, SUBJECT, BODY.ToString());
                msg.IsBodyHtml = true;

                try
                {
                    client.Send(msg);
                    sendSuccess = true;
                }
                catch (Exception e)
                {
                    sendSuccess = false;
                    Debug.WriteLine(e);
                }
            }

            return sendSuccess;
        }
コード例 #4
0
ファイル: BLLEmail.cs プロジェクト: rafaelbacus/EMP
        public bool EmailManager(ApplyForLeaveViewModel model){
            bool sendSuccess = false;

            BLLProfile _profile = new BLLProfile();

            using (SmtpClient client = new SmtpClient(SERVER, PORT))
            {
                string EMAIL_FROM = "*****@*****.**";
                string SUBJECT = "Leave of Absence Application [no-reply]";
                //string EMAIL_TO = _profile.GetEmployeeProfile(model.DepartmentManagerIDNO).Email;
                string EMAIL_TO = "*****@*****.**";
                string LINK = "http://cebapp03/EMP/Account/Login";

                StringBuilder BODY = new StringBuilder();
                BODY.Append("<p>" + model.EmployeeName + " has applied for Leave of Absence:</p><br>");
                BODY.Append("<p><strong>Date Filed: </strong>" + model.DateFiled + "</p>");
                BODY.Append("<p><strong>Type: </strong>" + new BLLLeave().GetAllLeaveTypes().Where(i => i.LOOKUPLeaveTypeID == model.LeaveTypeID).SingleOrDefault().LeaveType + "</p>");
                BODY.Append("<p><strong>From: </strong>" + model.PeriodFrom + "</p>");
                BODY.Append("<p><strong>To: </strong>" + model.PeriodTo + "</p>");
                BODY.Append("<p><strong>Address: </strong>" + model.AddressOnLeave + "</p>");
                BODY.Append("<p><strong>Reason: </strong>" + model.Reason + "</p><br>");
                BODY.Append("<p>Click <a href='" + LINK + "' target='_blank'>here</a> to respond to the application on EMP.<p>");

                MailMessage msg = new MailMessage(EMAIL_FROM, EMAIL_TO, SUBJECT, BODY.ToString());
                msg.IsBodyHtml = true;

                try
                {
                    client.Send(msg);
                    sendSuccess = true;
                }
                catch (Exception e)
                {
                    sendSuccess = false;
                    Debug.WriteLine(e);
                }
            }

            return sendSuccess;
        }
コード例 #5
0
ファイル: LeaveController.cs プロジェクト: rafaelbacus/EMP
        public ActionResult GetEmploymentStatus(string IDNO)
        {
            BLLProfile _profile = new BLLProfile();

            EditEmployeeViewModel model =  _profile.GetEmployeeProfile(IDNO);

            return Json(model.EmploymentStatusId, JsonRequestBehavior.AllowGet);
        }
コード例 #6
0
ファイル: ProfileController.cs プロジェクト: rafaelbacus/EMP
        public ActionResult Edit(string IDNO)
        {
            BLLProfile _profile = new BLLProfile();
            EditEmployeeViewModel _employee = _profile.GetEmployeeProfile(IDNO);
            _employee.IDNO = IDNO;
            _employee.CivilStatus = _profile.GetCivilStatus();
            _employee.Department = _profile.GetDepartmentNames();
            _employee.EmploymentStatus = _profile.GetEmploymentStatus();

            return View(_employee);
        }
コード例 #7
0
ファイル: ProfileController.cs プロジェクト: rafaelbacus/EMP
 // GET: Profile List 
 public ActionResult _ProfileListPartial(int page)
 {
     BLLProfile _profile = new BLLProfile();
     var _profileList = _profile.GetProfileList(page, 10);
     return PartialView(_profileList);
 }
コード例 #8
0
ファイル: ProfileController.cs プロジェクト: rafaelbacus/EMP
 // GET: Profile
 public ActionResult Index()
 {
     BLLProfile _profile = new BLLProfile();
     var _profileList = _profile.GetProfileList(1, 10);
     return View(_profileList);
 }
コード例 #9
0
ファイル: ProfileController.cs プロジェクト: rafaelbacus/EMP
        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);
            }
        }
コード例 #10
0
        public bool IsUserExists(string IDNO)
        {
            BLLProfile _profile = new BLLProfile();

            return _profile.IsUserExists(IDNO);
        }