private bool ValidDateRange(int employeeID, string fromDate) { bool ReturnValue = true; List <LeaveApplication> thisLeaveApplicationList = LeaveApplicationManagement.GetEmployeePendingLeaveApplicationsAll(employeeID); if (thisLeaveApplicationList.Count > 0) { var LastApplication = thisLeaveApplicationList.OrderBy(leave => leave.DateAdded).LastOrDefault(); if (LastApplication.Status != MicroEnums.ApprovalStatus.Rejected.GetStringValue()) { if (Convert.ToDateTime(fromDate) <= LastApplication.DateTo) { ReturnValue = false; string DateRange = string.Concat(LastApplication.DateFrom.ToString(MicroConstants.DateFormat.ToString()), " to ", LastApplication.DateFrom.ToString(MicroConstants.DateFormat.ToString())); if (LastApplication.Status.Equals(MicroEnums.ApprovalStatus.Pending.GetStringValue())) { lbl_TheMessage.Text = string.Concat("Already a application avail with Pending status from date ", DateRange); } else if (LastApplication.Status.Equals(MicroEnums.ApprovalStatus.Approved.GetStringValue())) { lbl_TheMessage.Text = string.Concat("Already a application avail with Approved status from date ", DateRange); } } } } return(ReturnValue); }
private void BindGridLeaveApplicationsToApproveReject(string searchText = "") { try { PageVariables.TheUserReferenceID = Connection.LoggedOnUser.UserReferenceID; Employee TheEmployee = EmployeeManagement.GetInstance.GetEmployeeByID(PageVariables.TheUserReferenceID); List <LeaveApplication> LeaveApplications = new List <LeaveApplication>(); LeaveApplications = LeaveApplicationManagement.GetPeningApplicationsAllByReportingEmployee(TheEmployee.EmployeeID); string TheMessage; if (!(LeaveApplications.Count.Equals(0))) { TheMessage = String.Format("<div id='LeaveCount'>Total No. of Leaves(s) to approve:<b>{0}</b> </div> ", LeaveApplications.Count); gridview_LeaveApproveBalanceShow.DataSource = LeaveApplications; gridview_LeaveApproveBalanceShow.DataBind(); } else { TheMessage = "<div id='BiggerTextInformation'>There are no leave applications to approve/reject at this moment.<div>"; } lit_Message.Text = TheMessage; } catch (Exception ex) { Response.Write(ex.Message); } }
private void FillGridView() { PageVariables.TheUserReferenceID = Connection.LoggedOnUser.UserReferenceID; Employee TheEmployee = EmployeeManagement.GetInstance.GetEmployeeByID(PageVariables.TheUserReferenceID); txt_From.Text = TheEmployee.EmailID; //*******************************// //To Get emailAddress his/her supervisor List <Employee> ReporttingEmployeeList = new List <Employee>(); ReporttingEmployeeList = EmployeeManagement.GetInstance.GetReportingEmployeesEmailAllByEmployee(TheEmployee.EmployeeID); foreach (Employee emp in ReporttingEmployeeList) { string email = emp.EmailID; txt_To.Text = email; } List <LeaveTypeSettings> LeaveBalanceList; LeaveBalanceList = LeaveBalanceManagement.GetLeaveBalanceByEmployee(TheEmployee.EmployeeID); gridview_LeaveApplyBalance.DataSource = LeaveBalanceList; gridview_LeaveApplyBalance.DataBind(); List <LeaveApplication> LeaveApplicationLists = new List <LeaveApplication>(); LeaveApplicationLists = LeaveApplicationManagement.GetEmployeeLeaveApplicationsAll(TheEmployee.EmployeeID); gridview_LeaveApplyBalanceShow.DataSource = LeaveApplicationLists; gridview_LeaveApplyBalanceShow.DataBind(); }
private int InsertRecord() { int ProcReturnValue = 0; LeaveApplication TheLeaveApplication = new LeaveApplication(); PageVariables.TheUserReferenceID = Connection.LoggedOnUser.UserReferenceID; Employee TheEmployee = EmployeeManagement.GetInstance.GetEmployeeByID(PageVariables.TheUserReferenceID); LeaveBalanceList = LeaveBalanceManagement.GetLeaveBalanceByEmployee(TheEmployee.EmployeeID); var LeaveBalance = (from st in LeaveBalanceList where st.LeaveTypeDescription == ddl_LeaveDescription.Text select st.TotalNumberOfLeavesElligibleToAvail).First(); int TotalLeaveBalance = LeaveBalance; LeaveBalance = (from st in LeaveBalanceList where st.LeaveTypeDescription == ddl_LeaveDescription.Text select st.NumberOfConsecutiveDaysAllowed).First(); LeaveBalance = (from st in LeaveBalanceList where st.LeaveTypeDescription == ddl_LeaveDescription.Text select st.LeaveTypeID).First(); int LeaveTypeID = LeaveBalance; if (txt_Count.Text == "") { txt_Count.Text = "0"; } TheLeaveApplication.EmployeeID = TheEmployee.EmployeeID; TheLeaveApplication.LeaveTypeID = LeaveTypeID; TheLeaveApplication.LeaveTypeDescription = ddl_LeaveDescription.SelectedItem.ToString(); TheLeaveApplication.DateApplied = DateTime.Today.Date; TheLeaveApplication.DateFrom = DateTime.Parse(txt_FromDate.Text); TheLeaveApplication.DateTo = DateTime.Parse(txt_Todate.Text); TheLeaveApplication.ApplicationReason = txt_Reason.Text; TheLeaveApplication.Status = "Pending"; ProcReturnValue = LeaveApplicationManagement.InsertLeaveApplication(TheLeaveApplication); if (ProcReturnValue > 0) { //========================================================= // SENDING THE LEAVE REQUEST MAIL TO THE SUPERVISOR //========================================================= SendLeaveRequestMail(TheEmployee, TheLeaveApplication); //========================================================== } return(ProcReturnValue); }
protected void lnkEdit_Click(object sender, EventArgs e) { PageVariables.TheUserReferenceID = Connection.LoggedOnUser.UserReferenceID; StaffMaster TheStaffMaster = StaffMasterManagement.GetInstance.GetEmployeeByID(PageVariables.TheUserReferenceID); LinkButton TheLinkBtn = (LinkButton)sender; btn_Save.Text = MicroEnums.DataOperation.Update.GetStringValue(); btn_LeaveCancel.Visible = true; LeaveApplicationID = int.Parse(TheLinkBtn.CommandArgument); LeaveApplication LType = new LeaveApplication(); LType = LeaveApplicationManagement.GetLeaveApplicationByLeaveApplicationID(LeaveApplicationID); if (LType.Status != "Pending") { ddl_LeaveDescription.Text = LType.LeaveTypeDescription; ddl_LeaveDescription.Enabled = false; txt_FromDate.Text = LType.DateFrom.ToShortDateString(); txt_FromDate.Enabled = false; txt_Todate.Text = LType.DateTo.ToShortDateString(); txt_Todate.Enabled = false; txt_Reason.Text = LType.ApplicationReason; txt_Reason.Enabled = false; txt_Status.Text = LType.Status; txt_ApprovedBy.Text = LType.ApprovedByEmployeeName; txt_RemarksDetails.Text = LType.ApprovalOrRejectionReason; btn_Save.Visible = false; } else { ddl_LeaveDescription.Text = LType.LeaveTypeDescription; txt_FromDate.Text = LType.DateFrom.ToShortDateString(); txt_Todate.Text = LType.DateTo.ToShortDateString(); txt_Reason.Text = LType.ApplicationReason; txt_Status.Text = LType.Status; txt_ApprovedBy.Text = ""; txt_RemarksDetails.Text = ""; btn_Save.Visible = true; txt_Todate_TextChanged(sender, e); } }
protected void lnkCancel_Click(object sender, EventArgs e) { PageVariables.TheUserReferenceID = Connection.LoggedOnUser.UserReferenceID; Employee TheEmployee = EmployeeManagement.GetInstance.GetEmployeeByID(PageVariables.TheUserReferenceID); LeaveBalanceList = LeaveBalanceManagement.GetLeaveBalanceByEmployee(TheEmployee.EmployeeID); LinkButton TheLinkBtn = (LinkButton)sender; LeaveApplicationID = int.Parse(TheLinkBtn.CommandArgument); LeaveApplication LType = new LeaveApplication(); int ProcReturnValue = 0; LType = LeaveApplicationManagement.GetLeaveApplicationByLeaveApplicationID(LeaveApplicationID); if (LType.Status == "Pending") { LeaveApplication LeaveApplicationObject = new LeaveApplication(); LeaveApplicationObject.EmployeeID = TheEmployee.EmployeeID; LeaveApplicationObject.ApplicationReason = txt_Reason.Text; LeaveApplicationObject.Status = "Pending"; if (LeaveApplicationID > 0) { LeaveApplicationObject.LeaveApplicationID = LeaveApplicationID; ProcReturnValue = LeaveApplicationManagement.DeletetLeaveApplication(LeaveApplicationObject); lbl_TheMessage.Text = ReadXML.GetSuccessMessage("OK_LEAVEAPPLICATION_DELETED"); dialog_Message.Show(); // ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", "alert('Leave Application Deleted Successfully');", true); btn_LeaveCancel.Visible = false; FillGridView(); } } else { lbl_TheMessage.Text = ReadXML.GetSuccessMessage("KO_LEAVEAPPLICATION_DELETED"); dialog_Message.Show(); // ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", "alert('Leave Application n't Cancelled Due to Approved/Cancelled');", true); } }
private int UpdateRecord() { int ProcReturnValue = 0; LeaveApplication TheLeaveApplication = new LeaveApplication(); PageVariables.TheUserReferenceID = Connection.LoggedOnUser.UserReferenceID; Employee TheEmployee = EmployeeManagement.GetInstance.GetEmployeeByID(PageVariables.TheUserReferenceID); LeaveBalanceList = LeaveBalanceManagement.GetLeaveBalanceByEmployee(TheEmployee.EmployeeID); var LeaveBalance = (from st in LeaveBalanceList where st.LeaveTypeDescription == ddl_LeaveDescription.Text select st.TotalNumberOfLeavesElligibleToAvail).First(); LeaveBalance = (from st in LeaveBalanceList where st.LeaveTypeDescription == ddl_LeaveDescription.Text select st.NumberOfConsecutiveDaysAllowed).First(); LeaveBalance = (from st in LeaveBalanceList where st.LeaveTypeDescription == ddl_LeaveDescription.Text select st.LeaveTypeID).First(); int LeaveTypeID = LeaveBalance; TheLeaveApplication.LeaveApplicationID = LeaveApplicationID; TheLeaveApplication.LeaveTypeID = LeaveTypeID; TheLeaveApplication.LeaveTypeDescription = ddl_LeaveDescription.SelectedItem.ToString(); TheLeaveApplication.DateApplied = DateTime.Today.Date; TheLeaveApplication.DateFrom = DateTime.Parse(txt_FromDate.Text); TheLeaveApplication.DateTo = DateTime.Parse(txt_Todate.Text); TheLeaveApplication.ApplicationReason = txt_Reason.Text; TheLeaveApplication.Status = "Pending"; ProcReturnValue = LeaveApplicationManagement.UpdateLeaveApplication(TheLeaveApplication); return(ProcReturnValue); }
protected void lnkEdit_Click(object sender, EventArgs e) { try { EnableDisableCommandButtons(true); LinkButton lnkBtn = (LinkButton)sender; LeaveApplicationID = int.Parse(lnkBtn.CommandArgument); LeaveApplication objLeaveAppln = new LeaveApplication(); objLeaveAppln = LeaveApplicationManagement.GetLeaveApplicationByLeaveApplicationID(LeaveApplicationID); lbl_LeaveShowHistoyrDetails.Text = String.Format("{0} details of {1}", objLeaveAppln.LeaveTypeDescription, objLeaveAppln.EmployeeName); txt_LeaveDescription.Text = objLeaveAppln.LeaveTypeDescription; txt_FromDate.Text = objLeaveAppln.DateFrom.ToShortDateString(); txt_ToDate.Text = objLeaveAppln.DateTo.ToShortDateString(); txt_Reason.Text = objLeaveAppln.ApplicationReason; } catch (Exception ex) { Response.Write(ex.Message); } }
private void SaveLeaveApplication() { Validate(); if (checkNull()) { return; } ((LeaveApplication)leaveApplicationBindingSource.Current).LeaveSpent = _spent; leaveApplicationBindingSource.EndEdit(); var iResult = LeaveApplicationManagement.Save((LeaveApplication)leaveApplicationBindingSource.Current); if (iResult > 0) { MessageBox.Show(@"Record was successfully saved.", @"Save", MessageBoxButtons.OK, MessageBoxIcon.Information); personnelNoComboBox.Focus(); } else { MessageBox.Show(@"Error occurred in saving.", @"Save", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DeleteLeave() { if (leaveObjBindingSource != null) { var dResult = MessageBox.Show(@"Delete current record?", @"Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dResult == DialogResult.Yes) { if (LeaveApplicationManagement.Delete(((LeaveApplication)leaveObjBindingSource.Current).LeaveApplicationNo)) { MessageBox.Show(@"Record was deleted successfully.", @"Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); leaveObjBindingSource.RemoveCurrent(); } else { MessageBox.Show(@"Error on delete operation.", @"Delete", MessageBoxButtons.OK, MessageBoxIcon.Error); leaveObjDataGridView.Focus(); } } } }
protected void btn_Save_Click(object sender, EventArgs e) { try { int ProcReturnValue; LeaveApplication TheLeaveApplication = new LeaveApplication(); TheLeaveApplication.LeaveApplicationID = LeaveApplicationID; TheLeaveApplication.Status = ddl_LeaveStatus.SelectedValue; TheLeaveApplication.ApproveDate = DateTime.Now.Date; TheLeaveApplication.ApprovalOrRejectionReason = txt_Remarks.Text; ProcReturnValue = LeaveApplicationManagement.ApproveOrRejectLeaveApplication(TheLeaveApplication); if (ProcReturnValue > 0) { // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", String.Format("alert('successfully {0} the leave application.');", TheLeaveApplication.Status), true); lbl_TheMessage.Text = ReadXML.GetSuccessMessage("OK_LEAVEAPPLICATION_APRPOVED"); dialog_Message.Show(); BindGridLeaveApplicationsToApproveReject(); ResetTextBoxes(); } else if (ProcReturnValue < 0) { lbl_TheMessage.Text = ReadXML.GetSuccessMessage("KO_LEAVEAPPLICATION_APRPOVED"); BindGridLeaveApplicationsToApproveReject(); dialog_Message.Show(); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('Sorry! failed to approve / reject the leave application.');", true); ResetTextBoxes(); } EnableDisableCommandButtons(false); } catch (Exception ex) { Response.Write(ex.Message); } }