Example #1
0
        public ActionResult LeaveReport(FormCollection frm)
        {
            EmployeeLeaveApplyVM viewModel = new EmployeeLeaveApplyVM();

            if (frm["EmployeeId"] != null && !string.IsNullOrEmpty(frm["EmployeeId"]))
            {
                viewModel.EmployeeId = Convert.ToInt32(frm["EmployeeId"]);
            }


            if (ModelState.IsValid)
            {
                PresentationLayer.Helpers.SessionHelper.ReportIndex = 5;
                PresentationLayer.Helpers.SessionHelper.TempId      = viewModel.EmployeeId;
                return(Redirect(@"~\Report.aspx"));
            }
            else
            {
                EmployeeBAL employeeBAL = new EmployeeBAL();
                viewModel.EmployeeList = from obj in employeeBAL.GetAll() select new SelectListItem()
                {
                    Text = obj.FirstName.Trim() + " " + obj.MiddleName.Trim() + " " + obj.LastName.Trim(), Value = obj.EmployeeId.ToString()
                };
                return(View(viewModel));
            }
        }
Example #2
0
        public ActionResult EmployeeLeaveApply()
        {
            EmployeeBAL employeeBAL = new EmployeeBAL();

            EmployeeLeaveApplyVM viewModel = new EmployeeLeaveApplyVM();

            viewModel.EmployeeList = from obj in employeeBAL.GetAll() select new SelectListItem()
            {
                Text = obj.FirstName.Trim() + " " + obj.MiddleName.Trim() + " " + obj.LastName.Trim(), Value = obj.EmployeeId.ToString()
            };
            return(View(viewModel));
        }
Example #3
0
        public ActionResult EmployeeLeaveApply(EmployeeLeaveApplyVM viewModel)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    Entities.EmployeeLeaveTransaction entity = new Entities.EmployeeLeaveTransaction();
                    entity.EmployeeId    = viewModel.EmployeeId;
                    entity.LeaveFromDate = viewModel.LeaveFromDate;
                    entity.LeaveToDate   = viewModel.LeaveToDate;
                    entity.LeaveType     = viewModel.LeaveType;

                    entity.Remark = viewModel.Remark == null ? string.Empty : viewModel.Remark;

                    decimal leaveDays = (decimal)(entity.LeaveToDate - entity.LeaveFromDate).TotalDays;
                    if (leaveDays < 0)
                    {
                        TempData["Error"] = "Select valid from date - to date.";
                        // return View(viewModel);
                        return(RedirectToAction("EmployeeLeaveApply"));
                    }
                    entity.LeavesInDays = leaveDays + 1;

                    entity.BalanceLeaves = viewModel.BalanceLeaves - entity.LeavesInDays;


                    EmployeeBAL balObject = new EmployeeBAL();
                    balObject.leaveApply(entity);
                    return(RedirectToAction("EmployeeLeaveApply"));
                }
                else
                {
                    return(View(viewModel));
                }
            }
            catch
            {
                return(View(viewModel));
            }
        }