private bool LeaveApprovalValidation() { try { if (string.IsNullOrEmpty(txtRemarks.Text.Trim())) { Message.IsSuccess = false; Message.Text = "Please enter remarks."; Message.Show = true; return(false); } Business.LeaveManagement.LeaveApplication objLeaveApplication = new Business.LeaveManagement.LeaveApplication(); Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster = new Entity.LeaveManagement.LeaveApplicationMaster(); leaveApplicationMaster.LeaveApplicationId = Business.Common.Context.LeaveApplicationId; DataTable dtLeaveApplication = objLeaveApplication.LeaveApplicationMaster_GetAll(leaveApplicationMaster); DataTable dtLeaveAccountBalance = new Business.LeaveManagement.LeaveAccountBalance().LeaveAccountBalance_ByEmployeeId(Convert.ToInt32(dtLeaveApplication.Rows[0]["RequestorId"].ToString()), Convert.ToInt32(dtLeaveApplication.Rows[0]["LeaveTypeId"].ToString())).Tables[0]; DataSet dsLeaveDetails = objLeaveApplication.GetLeaveApplicationDetails_ByLeaveApplicationId(Business.Common.Context.LeaveApplicationId); decimal totalLeaveCount = 0; totalLeaveCount = Convert.ToDecimal(dsLeaveDetails.Tables[2].Compute("Sum(AppliedForDay)", string.Empty)); if (dtLeaveAccountBalance != null && dtLeaveAccountBalance.AsEnumerable().Any()) { if (totalLeaveCount > Convert.ToDecimal(dtLeaveAccountBalance.Rows[0]["Amount"].ToString())) { Message.Text = "Applicant's Leave Balance is low."; Message.IsSuccess = false; Message.Show = true; return(false); } if (Convert.ToBoolean(dtLeaveAccountBalance.Rows[0]["LeaveBlocked"].ToString())) { Message.Text = "Applicant's leaves are blocked. Please contact to HR."; Message.IsSuccess = false; Message.Show = true; return(false); } } else { Message.Text = "Applicant do not have any Leave Balance."; Message.IsSuccess = false; Message.Show = true; return(false); } return(true); } catch (Exception ex) { ex.WriteException(); Message.Text = ex.Message; Message.IsSuccess = false; Message.Show = true; return(false); } }
public static DataSet LeaveApplication_GetAll(Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster) { using (DataSet ds = new DataSet()) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_HR_LeaveApplication_GetAll"; if (leaveApplicationMaster.LeaveTypeId == 0) { cmd.Parameters.AddWithValue("@LeaveTypeId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@LeaveTypeId", leaveApplicationMaster.LeaveTypeId); } if (leaveApplicationMaster.RequestorId == 0) { cmd.Parameters.AddWithValue("@EmployeeId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@EmployeeId", leaveApplicationMaster.RequestorId); } if (leaveApplicationMaster.FromDate == DateTime.MinValue) { cmd.Parameters.AddWithValue("@FromDate", DBNull.Value); } else { cmd.Parameters.AddWithValue("@FromDate", leaveApplicationMaster.FromDate); } if (leaveApplicationMaster.ToDate == DateTime.MinValue) { cmd.Parameters.AddWithValue("@ToDate", DBNull.Value); } else { cmd.Parameters.AddWithValue("@ToDate", leaveApplicationMaster.ToDate); } using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } con.Close(); } } return(ds); } }
private Entity.LeaveManagement.LeaveApplicationMaster LeaveApplicationMaster_Save() { Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster = new Entity.LeaveManagement.LeaveApplicationMaster(); Business.LeaveManagement.LeaveApplication objLeaveApplicationMaster = new Business.LeaveManagement.LeaveApplication(); leaveApplicationMaster.ApplyDate = DateTime.Now; leaveApplicationMaster.FromDate = Convert.ToDateTime(lbFromDate.Text); leaveApplicationMaster.ToDate = Convert.ToDateTime(lbToDate.Text); leaveApplicationMaster.LeaveAccumulationTypeId = (int)LeaveAccumulationEnum.Taken; leaveApplicationMaster.LeaveStatusId = (int)LeaveStatusEnum.Pending; leaveApplicationMaster.LeaveTypeId = Convert.ToInt32(ddlLeaveType.SelectedValue); leaveApplicationMaster.Reason = txtReason.Text.Trim(); leaveApplicationMaster.RequestorId = Convert.ToInt32(HttpContext.Current.User.Identity.Name); leaveApplicationMaster.Attachment = (fileUploadAttachment.HasFile) ? System.IO.Path.GetExtension(fileUploadAttachment.FileName) : string.Empty; leaveApplicationMaster = objLeaveApplicationMaster.LeaveApplicationMaster_Save(leaveApplicationMaster); return(leaveApplicationMaster); }
private void LeaveApplication_GetAll() { Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster = new Entity.LeaveManagement.LeaveApplicationMaster(); leaveApplicationMaster.LeaveTypeId = Convert.ToInt32(ddlLeaveType.SelectedValue); leaveApplicationMaster.RequestorId = Convert.ToInt32(ddlEmployee.SelectedValue); leaveApplicationMaster.FromDate = (string.IsNullOrEmpty(txtFromDate.Text.Trim())) ? DateTime.MinValue : Convert.ToDateTime(txtFromDate.Text.Trim()); leaveApplicationMaster.ToDate = (string.IsNullOrEmpty(txtToDate.Text.Trim())) ? DateTime.MinValue : Convert.ToDateTime(txtToDate.Text.Trim()); Business.LeaveManagement.LeaveApplication objLeaveApplication = new Business.LeaveManagement.LeaveApplication(); DataSet dsLeaveApplication = objLeaveApplication.LeaveApplication_GetAll(leaveApplicationMaster); if (dsLeaveApplication != null && dsLeaveApplication.Tables.Count > 1) { if (gvLeaveReport.PageIndex == 0) { gvLeaveTotalReport.DataSource = dsLeaveApplication.Tables[0]; gvLeaveTotalReport.DataBind(); } gvLeaveReport.DataSource = dsLeaveApplication.Tables[1]; gvLeaveReport.DataBind(); } }
public static int LeaveApplicationMaster_Delete(Entity.LeaveManagement.LeaveApplicationMaster objLeaveApplicationMaster) { int rowsAffacted = 0; using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_HR_LeaveApplicationMaster_Delete"; cmd.Parameters.AddWithValue("@LeaveApplicationId", objLeaveApplicationMaster); if (con.State == ConnectionState.Closed) { con.Open(); } rowsAffacted = cmd.ExecuteNonQuery(); con.Close(); } } return(rowsAffacted); }
public static DataTable LeaveApplicationDetails_GetByDate(Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster) { using (DataTable dt = new DataTable()) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_HR_LeaveApplicationDetails_GetByDate"; if (leaveApplicationMaster.LeaveApplicationId == 0) { cmd.Parameters.AddWithValue("@LeaveApplicationId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@LeaveApplicationId", leaveApplicationMaster.LeaveApplicationId); } if (leaveApplicationMaster.RequestorId == 0) { cmd.Parameters.AddWithValue("@RequestorId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@RequestorId", leaveApplicationMaster.RequestorId); } if (leaveApplicationMaster.LeaveTypeId == 0) { cmd.Parameters.AddWithValue("@LeaveTypeId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@LeaveTypeId", leaveApplicationMaster.LeaveTypeId); } if (string.IsNullOrEmpty(leaveApplicationMaster.LeaveStatuses)) { cmd.Parameters.AddWithValue("@LeaveStatuses", DBNull.Value); } else { cmd.Parameters.AddWithValue("@LeaveStatuses", leaveApplicationMaster.LeaveStatuses); } if (leaveApplicationMaster.FromLeaveDate == DateTime.MinValue) { cmd.Parameters.AddWithValue("@FromLeaveDate", DBNull.Value); } else { cmd.Parameters.AddWithValue("@FromLeaveDate", leaveApplicationMaster.FromLeaveDate); } if (leaveApplicationMaster.ToLeaveDate == DateTime.MinValue) { cmd.Parameters.AddWithValue("@ToLeaveDate", DBNull.Value); } else { cmd.Parameters.AddWithValue("@ToLeaveDate", leaveApplicationMaster.ToLeaveDate); } using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dt); } con.Close(); } } return(dt); } }
public static Entity.LeaveManagement.LeaveApplicationMaster LeaveApplicationMaster_Save(Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_HR_LeaveApplicationMaster_Save"; cmd.Parameters.AddWithValue("@LeaveApplicationId", leaveApplicationMaster.LeaveApplicationId); if (string.IsNullOrEmpty(leaveApplicationMaster.LeaveApplicationNumber)) { cmd.Parameters.AddWithValue("@LeaveApplicationNumber", DBNull.Value); } else { cmd.Parameters.AddWithValue("@LeaveApplicationNumber", leaveApplicationMaster.LeaveApplicationNumber); } if (leaveApplicationMaster.RequestorId == 0) { cmd.Parameters.AddWithValue("@RequestorId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@RequestorId", leaveApplicationMaster.RequestorId); } if (leaveApplicationMaster.LeaveTypeId == 0) { cmd.Parameters.AddWithValue("@LeaveTypeId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@LeaveTypeId", leaveApplicationMaster.LeaveTypeId); } if (leaveApplicationMaster.LeaveAccumulationTypeId == 0) { cmd.Parameters.AddWithValue("@LeaveAccumulationTypeId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@LeaveAccumulationTypeId", leaveApplicationMaster.LeaveAccumulationTypeId); } if (leaveApplicationMaster.FromDate == DateTime.MinValue) { cmd.Parameters.AddWithValue("@FromDate", DBNull.Value); } else { cmd.Parameters.AddWithValue("@FromDate", leaveApplicationMaster.FromDate); } if (leaveApplicationMaster.ToDate == DateTime.MinValue) { cmd.Parameters.AddWithValue("@ToDate", DBNull.Value); } else { cmd.Parameters.AddWithValue("@ToDate", leaveApplicationMaster.ToDate); } if (leaveApplicationMaster.LeaveStatusId == 0) { cmd.Parameters.AddWithValue("@LeaveStatusId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@LeaveStatusId", leaveApplicationMaster.LeaveStatusId); } if (string.IsNullOrEmpty(leaveApplicationMaster.Reason)) { cmd.Parameters.AddWithValue("@Reason", DBNull.Value); } else { cmd.Parameters.AddWithValue("@Reason", leaveApplicationMaster.Reason); } if (string.IsNullOrEmpty(leaveApplicationMaster.Attachment)) { cmd.Parameters.AddWithValue("@Attachment", DBNull.Value); } else { cmd.Parameters.AddWithValue("@Attachment", leaveApplicationMaster.Attachment); } if (con.State == ConnectionState.Closed) { con.Open(); } SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { if (dr.HasRows) { leaveApplicationMaster.LeaveApplicationId = Convert.ToInt32(dr["LeaveApplicationId"].ToString()); leaveApplicationMaster.LeaveApplicationNumber = dr["LeaveApplicationNumber"].ToString(); } } con.Close(); } } return(leaveApplicationMaster); }
private bool LeaveApplyValidation() { if (!LeaveApplicationControlValidation()) { return(false); } DataTable dtLeaveConfigurations = GlobalCache.ExecuteCache <DataTable>(typeof(Business.LeaveManagement.LeaveConfiguration), "LeaveConfigurations_GetAll", new Entity.LeaveManagement.LeaveConfiguration() { }); Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster = new Entity.LeaveManagement.LeaveApplicationMaster(); leaveApplicationMaster.RequestorId = Convert.ToInt32(HttpContext.Current.User.Identity.Name); DataTable dtLeaveApplicationMaster = new Business.LeaveManagement.LeaveApplication().LeaveApplicationMaster_GetAll(leaveApplicationMaster); if (dtLeaveConfigurations != null && dtLeaveConfigurations.AsEnumerable().Any()) { DataRow drLeaveConfiguration = dtLeaveConfigurations.Select("LeaveTypeId = " + ddlLeaveType.SelectedValue).FirstOrDefault(); if (drLeaveConfiguration == null) { Message.Text = "Leave Configuration not found"; Message.IsSuccess = false; Message.Show = true; return(false); } if (!(DateTime.Now.Date >= Convert.ToDateTime(drLeaveConfiguration["LeaveAccrueDate"].ToString()))) { Message.Text = "Leave Not Yet Applicable"; Message.IsSuccess = false; Message.Show = true; return(false); } if (dtLeaveApplicationMaster != null && dtLeaveApplicationMaster.AsEnumerable().Any()) { if (dtLeaveApplicationMaster.Select("LeaveStatusId = " + ((int)LeaveStatusEnum.Pending).ToString()).Any()) { Message.Text = "You already have leave approval pending."; Message.IsSuccess = false; Message.Show = true; return(false); } } } else { Message.Text = "Leave Configuration not found"; Message.IsSuccess = false; Message.Show = true; return(false); } DataTable dtEmployee = new Business.HR.EmployeeMaster().EmployeeMaster_ById(new Entity.HR.EmployeeMaster() { EmployeeMasterId = Convert.ToInt32(HttpContext.Current.User.Identity.Name) }); if (dtEmployee != null && dtEmployee.AsEnumerable().Any()) { if (dtEmployee.Rows[0]["ReportingEmployeeId"] == DBNull.Value) { Message.Text = "Please update reporting person."; Message.IsSuccess = false; Message.Show = true; return(false); } Entity.LeaveManagement.LeaveDesignationWiseConfiguration leaveDesignationWiseConfiguration = new Entity.LeaveManagement.LeaveDesignationWiseConfiguration(); leaveDesignationWiseConfiguration.LeaveTypeId = Convert.ToInt32(ddlLeaveType.SelectedValue); leaveDesignationWiseConfiguration.DesignationId = Convert.ToInt32(dtEmployee.Rows[0]["DesignationMasterId_FK"].ToString()); DataTable dtLeaveDesignationConfiguration = new Business.LeaveManagement.LeaveDesignationWiseConfiguration().LeaveDesignationConfig_GetAll(leaveDesignationWiseConfiguration); if (dtLeaveDesignationConfiguration != null && dtLeaveDesignationConfiguration.AsEnumerable().Any()) { decimal totalDays = Convert.ToDecimal(lbTotalCount.Text.Trim()); if (totalDays < Convert.ToDecimal(dtLeaveDesignationConfiguration.Rows[0]["MinApplyDays"].ToString())) { Message.Text = "Min leave should be more than " + dtLeaveDesignationConfiguration.Rows[0]["MinApplyDays"].ToString() + " days"; Message.IsSuccess = false; Message.Show = true; return(false); } else if (totalDays > Convert.ToDecimal(dtLeaveDesignationConfiguration.Rows[0]["MaxApplyDays"].ToString())) { Message.Text = "Max leave should be less than " + dtLeaveDesignationConfiguration.Rows[0]["MaxApplyDays"].ToString() + " days"; Message.IsSuccess = false; Message.Show = true; return(false); } //if (Convert.ToDecimal(lbTotalCount.Text.Trim()) > Convert.ToDecimal(dtLeaveDesignationConfiguration.Rows[0]["LeaveCount"].ToString())) //{ // Message.Text = "Maximum Leave you can apply is " + dtLeaveDesignationConfiguration.Rows[0]["LeaveCount"].ToString() + " days in a year"; // Message.IsSuccess = false; // Message.Show = true; // return false; //} } else { Message.Text = "Leave designation configuration not found"; Message.IsSuccess = false; Message.Show = true; return(false); } DataTable dtLeaveAccountBalance = new Business.LeaveManagement.LeaveAccountBalance().LeaveAccountBalance_ByEmployeeId(Convert.ToInt32(HttpContext.Current.User.Identity.Name), Convert.ToInt32(ddlLeaveType.SelectedValue)).Tables[0]; if (dtLeaveAccountBalance != null && dtLeaveAccountBalance.AsEnumerable().Any()) { if (Convert.ToInt32(lbTotalCount.Text.Trim()) > Convert.ToDecimal(dtLeaveAccountBalance.Rows[0]["Amount"].ToString())) { Message.Text = "Your Leave Balance is low."; Message.IsSuccess = false; Message.Show = true; return(false); } if (Convert.ToBoolean(dtLeaveAccountBalance.Rows[0]["LeaveBlocked"].ToString())) { Message.Text = "Your leaves are blocked. Please contact to HR."; Message.IsSuccess = false; Message.Show = true; return(false); } } else { Message.Text = "You do not have any Leave Balance."; Message.IsSuccess = false; Message.Show = true; return(false); } //Checking leave date overlapping DataTable dtLeaveApplicationDetails = new Business.LeaveManagement.LeaveApplication().LeaveApplicationDetails_GetByDate(new Entity.LeaveManagement.LeaveApplicationMaster() { RequestorId = Convert.ToInt32(HttpContext.Current.User.Identity.Name), FromLeaveDate = Convert.ToDateTime(lbFromDate.Text.Trim()), ToLeaveDate = Convert.ToDateTime(lbToDate.Text.Trim()), LeaveStatuses = Convert.ToString((int)LeaveStatusEnum.Approved) + "," + Convert.ToString((int)LeaveStatusEnum.Pending) }); if (dtLeaveApplicationDetails != null && dtLeaveApplicationDetails.AsEnumerable().Any()) { Message.Text = "Your leave dates are overlapping. Please check your Approved/Pending list."; Message.IsSuccess = false; Message.Show = true; return(false); } if (!string.IsNullOrEmpty(hdnHalfDayList.Value.Replace(',', ' ').Trim())) { if (!(ddlLeaveType.SelectedValue == ((int)LeaveTypeEnum.CL).ToString()) && !(ddlLeaveType.SelectedValue == ((int)LeaveTypeEnum.LWP).ToString())) { Message.Text = "You cannot apply half day with leave type " + ddlLeaveType.SelectedItem.Text; Message.IsSuccess = false; Message.Show = true; return(false); } } } else { Message.Text = "Employee Details not found."; Message.IsSuccess = false; Message.Show = true; return(false); } return(true); }
protected void btnSave_Click(object sender, EventArgs e) { try { if (LeaveApplyValidation()) { Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster = LeaveApplicationMaster_Save(); if (leaveApplicationMaster.LeaveApplicationId > 0) { if (!string.IsNullOrEmpty(hdnHalfDayList.Value.Trim()))//Checking if has half day { string[] halfdays = hdnHalfDayList.Value.Trim().Split(','); foreach (DateTime selectedDate in Business.Common.Context.SelectedDates) { foreach (string halfday in halfdays) { if (!string.IsNullOrEmpty(halfday.Trim())) { if (selectedDate.Date == Convert.ToDateTime(halfday).Date) { LeaveApplicationDetails_Save(leaveApplicationMaster.LeaveApplicationId, selectedDate, 0.5M); break; } else { LeaveApplicationDetails_Save(leaveApplicationMaster.LeaveApplicationId, selectedDate, 1); break; } } } } } else//If not half day { foreach (DateTime selectedDate in Business.Common.Context.SelectedDates) { LeaveApplicationDetails_Save(leaveApplicationMaster.LeaveApplicationId, selectedDate, 1); } } int approvalResponse = LeaveApprovalDetails_Save(leaveApplicationMaster.LeaveApplicationId); if (approvalResponse > 0) { if (fileUploadAttachment.HasFile) { fileUploadAttachment.PostedFile.SaveAs(Server.MapPath(" ") + "\\LeaveAttachment\\" + leaveApplicationMaster.LeaveApplicationNumber.ToString() + leaveApplicationMaster.Attachment); } Message.IsSuccess = true; Message.Text = "Leave applied successfully."; Message.Show = true; } else { Message.IsSuccess = false; Message.Text = "Leave approval send failed! Please contact system administrator."; Message.Show = true; } } else { Message.IsSuccess = false; Message.Text = "Leave apply failed! Please contact system administrator."; Message.Show = true; } } } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }
public DataSet LeaveApplication_GetAll(Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster) { return(DataAccess.LeaveManagement.LeaveApplication.LeaveApplication_GetAll(leaveApplicationMaster)); }
public DataTable LeaveApplicationDetails_GetByDate(Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster) { return(DataAccess.LeaveManagement.LeaveApplication.LeaveApplicationDetails_GetByDate(leaveApplicationMaster)); }
public int LeaveApplicationMaster_Delete(Entity.LeaveManagement.LeaveApplicationMaster objLeaveApplicationMaster) { return(DataAccess.LeaveManagement.LeaveApplication.LeaveApplicationMaster_Delete(objLeaveApplicationMaster)); }
public DataTable LeaveApplicationMaster_GetAll(Entity.LeaveManagement.LeaveApplicationMaster objLeaveApplicationMaster) { return(DataAccess.LeaveManagement.LeaveApplication.LeaveApplicationMaster_GetAll(objLeaveApplicationMaster)); }
public Entity.LeaveManagement.LeaveApplicationMaster LeaveApplicationMaster_Save(Entity.LeaveManagement.LeaveApplicationMaster objLeaveApplicationMaster) { return(DataAccess.LeaveManagement.LeaveApplication.LeaveApplicationMaster_Save(objLeaveApplicationMaster)); }
protected void btnApprove_Click(object sender, EventArgs e) { try { if (LeaveApprovalValidation()) { Entity.LeaveManagement.LeaveApprovalDetails leaveApprovalDetails = new Entity.LeaveManagement.LeaveApprovalDetails(); leaveApprovalDetails.ApproverId = Convert.ToInt32(HttpContext.Current.User.Identity.Name); leaveApprovalDetails.LeaveApplicationId = Business.Common.Context.LeaveApplicationId; leaveApprovalDetails.Status = (int)LeaveStatusEnum.Approved; leaveApprovalDetails.Remarks = txtRemarks.Text.Trim(); int response = new Business.LeaveManagement.LeaveApprovalDetails().LeaveApprove(leaveApprovalDetails); if (response > 0) { //Fetching Requestor Id Entity.LeaveManagement.LeaveApplicationMaster leaveApplicationMaster = new Entity.LeaveManagement.LeaveApplicationMaster(); Business.LeaveManagement.LeaveApplication objLeaveApplication = new Business.LeaveManagement.LeaveApplication(); leaveApplicationMaster.LeaveApplicationId = Business.Common.Context.LeaveApplicationId; DataTable dtLeaveApplication = objLeaveApplication.LeaveApplicationMaster_GetAll(leaveApplicationMaster); Business.LeaveManagement.LeaveApprovalConfiguration objLeaveApprovalConfiguration = new Business.LeaveManagement.LeaveApprovalConfiguration(); DataTable dtLeaveEmployeeWiseApprovalConfiguration = objLeaveApprovalConfiguration.LeaveEmployeeWiseApprovalConfiguration_GetAll( new Entity.LeaveManagement.LeaveApprovalConfiguration() { EmployeeId = (dtLeaveApplication != null && dtLeaveApplication.AsEnumerable().Any()) ? Convert.ToInt32(dtLeaveApplication.Rows[0]["RequestorId"].ToString()) : 0 }); int currentLeaveApproverLevel = 0; if (dtLeaveEmployeeWiseApprovalConfiguration != null && dtLeaveEmployeeWiseApprovalConfiguration.AsEnumerable().Any() && dtLeaveEmployeeWiseApprovalConfiguration.Select("ApproverId = " + HttpContext.Current.User.Identity.Name).Any()) { //Fetching the current approver approval level currentLeaveApproverLevel = Convert.ToInt32(dtLeaveEmployeeWiseApprovalConfiguration .Select("ApproverId = " + HttpContext.Current.User.Identity.Name).FirstOrDefault()["ApprovalLevel"].ToString()); currentLeaveApproverLevel = currentLeaveApproverLevel + 1; } if (dtLeaveEmployeeWiseApprovalConfiguration != null && dtLeaveEmployeeWiseApprovalConfiguration.AsEnumerable().Any() && dtLeaveEmployeeWiseApprovalConfiguration.Select("ApprovalLevel = " + currentLeaveApproverLevel).Any()) { Business.LeaveManagement.LeaveApprovalDetails objLeaveApprovalDetails = new Business.LeaveManagement.LeaveApprovalDetails(); leaveApprovalDetails.LeaveApprovalDetailId = 0; leaveApprovalDetails.LeaveApplicationId = Business.Common.Context.LeaveApplicationId; leaveApprovalDetails.Status = (int)LeaveStatusEnum.Pending; leaveApprovalDetails.ApproverId = Convert.ToInt32(dtLeaveEmployeeWiseApprovalConfiguration.Select("ApprovalLevel = " + currentLeaveApproverLevel).FirstOrDefault()["ApproverId"].ToString()); //Assigning Leave Request to next approver int approvalResponse = objLeaveApprovalDetails.LeaveApprovalDetails_Save(leaveApprovalDetails); if (approvalResponse > 0) { GetLeaveApplications_ByApproverId(ckShowAll.Checked ? (int)LeaveStatusEnum.None : (int)LeaveStatusEnum.Pending); MessageSuccess.IsSuccess = true; MessageSuccess.Text = "Approval moved to next level."; MessageSuccess.Show = true; ModalPopupExtender1.Hide(); } } else { //If final Appoval approved then update status in Master table new Business.LeaveManagement.LeaveApplication().LeaveApplicationMaster_Save( new Entity.LeaveManagement.LeaveApplicationMaster() { LeaveApplicationId = Business.Common.Context.LeaveApplicationId, LeaveStatusId = (int)LeaveStatusEnum.Approved }); int adjustResponse = LeaveAccontBalance_Deduct(Business.Common.Context.LeaveApplicationId); if (adjustResponse > 0) { GetLeaveApplications_ByApproverId(ckShowAll.Checked ? (int)LeaveStatusEnum.None : (int)LeaveStatusEnum.Pending); MessageSuccess.IsSuccess = true; MessageSuccess.Text = "Leave approved."; MessageSuccess.Show = true; ModalPopupExtender1.Hide(); } else { Message.IsSuccess = false; Message.Text = "Something went wrong! Please contact system administrator"; Message.Show = true; TabContainer1.ActiveTab = Approval; ModalPopupExtender1.Show(); } } } else { Message.IsSuccess = false; Message.Text = "Response not given."; Message.Show = true; TabContainer1.ActiveTab = Approval; ModalPopupExtender1.Show(); } } else { TabContainer1.ActiveTab = Approval; ModalPopupExtender1.Show(); } } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }