Example #1
0
        public ActionResult RejectApplication(String Application_Id, string ManagerRemarks)
        {
            if (Session["EmpID"] == null)
            {
                return(RedirectToAction("Index", "LogIn"));
            }

            try
            {
                Application_Id = LeaveApplication.Models.Encryption.Base64Decode(Application_Id);
                int.Parse(Application_Id);
                if (((Employee)Session["Employee"]).IsManager && ManagerBusinessLayer.IsUnderManagement(Application_Id, ((Employee)Session["Employee"]).EmployeeID))
                {
                    lb.RejectApplication(Application_Id, ManagerRemarks);
                    LeaveApplication.Models.LeaveApplication l1 = new Models.LeaveApplication();
                    l1.ApplicationId = Application_Id;
                    l1.NotifyRejectedLeave();
                }
            }
            catch (FormatException)
            {
                return(RedirectToAction("FacultyApplications"));
            }

            return(RedirectToAction("FacultyApplications"));
        }
Example #2
0
        public LeaveApplication GetViewApplication(string Application_Id)
        {
            string Querry = string.Format(@"select LeaveApplication.LeaveApplicationID,LeaveApplication.EmployeeID,LeaveType.LeaveType,LeaveApplication.ApplyDate,
LeaveApplication.FromDate, LeaveApplication.ToDate, LeaveApplication.TotalDays, LeaveApplication.Remarks,
Reasons.LeaveReason, Attachments.FileId, Attachments.FileName,LeaveApplication.ManagerRemarks from LeaveApplication inner join LeaveType on LeaveApplication.LeaveTypeID = LeaveType.LeaveTypeID
  inner join Reasons on LeaveApplication.ReasonID = Reasons.ReasonID  left join Attachments on LeaveApplication.LeaveApplicationID = Attachments.LeaveApplicationId
where LeaveApplication.LeaveApplicationID = '{0}'", Application_Id);

            DataSet ds = database.Read(Querry);

            LeaveApplication v1 = new Models.LeaveApplication();

            v1.ApplicationId     = ds.Tables[0].Rows[0][0].ToString();
            v1.EmployeeID        = ds.Tables[0].Rows[0][1].ToString();
            v1.LeaveType         = ds.Tables[0].Rows[0][2].ToString();
            v1.ApplyDate         = DateTime.Parse(ds.Tables[0].Rows[0][3].ToString()).ToString();
            v1.FromDate          = DateTime.Parse(ds.Tables[0].Rows[0][4].ToString()).ToString("dd/MM/yyyy h:mm tt");
            v1.ToDate            = DateTime.Parse(ds.Tables[0].Rows[0][5].ToString()).ToString("dd/MM/yyyy h:mm tt");
            v1.TotalDays         = double.Parse(ds.Tables[0].Rows[0][6].ToString());
            v1.LeaveRemarks      = ds.Tables[0].Rows[0][7].ToString();
            v1.LeaveReason       = ds.Tables[0].Rows[0][8].ToString();
            v1.ApplicationStatus = GetApplicationStatus(v1.ApplicationId);
            if (ds.Tables[0].Rows[0][9] != DBNull.Value)
            {
                v1.FileId   = Encryption.Base64Encode(Convert.ToString(ds.Tables[0].Rows[0][9]));
                v1.FileName = ds.Tables[0].Rows[0][10].ToString();
            }
            v1.ManagerRemarks = ds.Tables[0].Rows[0][11].ToString();


            return(v1);
        }
Example #3
0
        public LeaveApplication GetApplication(string Application_Id)
        {
            //return application for edit application feature...

            string Querry = string.Format(@"select LeaveApplication.LeaveApplicationID,LeaveApplication.EmployeeID,LeaveType.LeaveTypeID,
                LeaveApplication.ApplyDate,LeaveApplication.FromDate,LeaveApplication.ToDate,LeaveApplication.TotalDays,
LeaveApplication.Remarks,LeaveApplication.ReasonID,Attachments.AttachmentId,Attachments.FileName,LeaveApplication.ApplicationType from 
LeaveApplication inner join LeaveType on LeaveApplication.LeaveTypeID=LeaveType.LeaveTypeID 
left join Attachments on LeaveApplication.LeaveApplicationID=Attachments.LeaveApplicationId 
where LeaveApplication.LeaveApplicationID='{0}'", Application_Id);

            DataSet ds = database.Read(Querry);


            LeaveApplication v1 = new Models.LeaveApplication();

            v1.ApplicationId = ds.Tables[0].Rows[0][0].ToString();
            v1.EmployeeID    = ds.Tables[0].Rows[0][1].ToString();
            v1.LeaveTypeID   = ds.Tables[0].Rows[0][2].ToString();
            v1.LeaveType     = ds.Tables[0].Rows[0][2].ToString();
            v1.ApplyDate     = DateTimeHelper.dd_MM_yyyy(ds.Tables[0].Rows[0][3].ToString());

            v1.TotalDays = double.Parse(ds.Tables[0].Rows[0][6].ToString());
            if (v1.TotalDays == 0.5)
            {
                v1.FromDate = DateTimeHelper.dd_MM_yyyy_HH_mm_tt(ds.Tables[0].Rows[0][4].ToString());
                v1.FromTime = DateTimeHelper.ToTime(ds.Tables[0].Rows[0][4].ToString());
                v1.ToTime   = DateTimeHelper.ToTime(ds.Tables[0].Rows[0][5].ToString());
            }
            else
            {
                v1.FromDate = DateTimeHelper.dd_MM_yyyy(ds.Tables[0].Rows[0][4].ToString());
                v1.ToDate   = DateTimeHelper.dd_MM_yyyy(ds.Tables[0].Rows[0][5].ToString());
            }
            v1.LeaveRemarks = ds.Tables[0].Rows[0][7].ToString();
            v1.LeaveReason  = ds.Tables[0].Rows[0][8].ToString();

            v1.ApplicationStatus = GetApplicationStatus(v1.ApplicationId);
            if (ds.Tables[0].Rows[0][9] != DBNull.Value)
            {
                v1.FileId   = Encryption.Base64Encode(Convert.ToString(ds.Tables[0].Rows[0][9]));
                v1.FileName = ds.Tables[0].Rows[0][10].ToString();
            }
            v1.ApplicationType = Convert.ToBoolean(ds.Tables[0].Rows[0][11]);

            if (v1.ApplicationStatus == "Pending")
            {
                return(v1);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        public async Task <IActionResult> OnPostAsync(long id, string status)
        {
            LeaveApplication = await _db.LeaveApplications.Include(a => a.User).ThenInclude(o => o.Attendances).SingleAsync(a => a.Id == id);

            switch (status)
            {
            case "Pending":
                LeaveApplication.Status = LeaveApplicationStatus.Pending;
                break;

            case "Approved":
                LeaveApplication.Status = LeaveApplicationStatus.Approved;
                break;

            case "Rejected":
                LeaveApplication.Status = LeaveApplicationStatus.Rejected;
                break;

            case "Default":
                LeaveApplication.Status = LeaveApplicationStatus.Pending;
                break;
            }

            if (LeaveApplication.Status == LeaveApplicationStatus.Approved)
            {
                for (int i = 0; i < LeaveApplication.Days; i++)
                {
                    var new_date = LeaveApplication.StartDate.AddDays(i);
                    LeaveApplication.User.Attendances.Add(new Attendance
                    {
                        Status = AttendanceStatus.InLeave,
                        Date   = new_date,
                        Day    = new_date.Day,
                        Month  = new_date.Month,
                        Year   = new_date.Year
                    });
                }
            }

            await _db.SaveChangesAsync();

            return(RedirectToPage("./LeaveApplicationList"));
        }
Example #5
0
        public async Task <IActionResult> OnGetAsync(long id)
        {
            if (_accountManage.IsLoggedIn != true || _accountManage.User.UserType != UserType.Admin)
            {
                return(RedirectToPage("/LoginPage"));
            }
            ViewData["User_Name"] = _accountManage.User.Name;
            ViewData.Add("ProfileImg", _accountManage.User.ProfileImageSrc);



            LeaveApplication = await _db.LeaveApplications.Include(a => a.LeaveCategory).Include(a => a.User).AsNoTracking().SingleAsync(a => a.Id == id);

            if (LeaveApplication == null)
            {
                return(NotFound());
            }


            return(Page());
        }