Beispiel #1
0
        private int Generate()
        {
            int       totalCount            = 0;
            DataTable dtLeaveConfigurations = GlobalCache.ExecuteCache <DataTable>(typeof(Business.LeaveManagement.LeaveConfiguration), "LeaveConfigurations_GetAll", new Entity.LeaveManagement.LeaveConfiguration()
            {
            });

            if (dtLeaveConfigurations != null)
            {
                if (dtLeaveConfigurations.Select("LeaveTypeId = " + ddlLeaveType.SelectedValue).Any())
                {
                    DataRow drLeaveConfiguration = dtLeaveConfigurations.Select("LeaveTypeId = " + ddlLeaveType.SelectedValue).FirstOrDefault();
                    if (drLeaveConfiguration != null)
                    {
                        //Getting all Employees
                        DataTable dtEmployees = new Business.HR.EmployeeMaster().Employee_GetAll_Active(new Entity.HR.EmployeeMaster()
                        {
                            CompanyId_FK = 1
                        });
                        //Getting all Designation wise Leave Configurations
                        DataTable dtLeaveDesignationConfigurations =
                            new Business.LeaveManagement.LeaveDesignationWiseConfiguration().LeaveDesignationConfig_GetAll(new Entity.LeaveManagement.LeaveDesignationWiseConfiguration());

                        if (dtLeaveDesignationConfigurations != null && dtLeaveDesignationConfigurations.AsEnumerable().Any())
                        {
                            foreach (DataRow drEmployee in dtEmployees.Rows)
                            {
                                //Getting Designation of each employee
                                int     designationId = Convert.ToInt32(drEmployee["DesignationMasterId"].ToString());
                                int     leaveTypeId   = Convert.ToInt32(ddlLeaveType.SelectedValue);
                                DataRow drLeaveDesignationConfiguration = dtLeaveDesignationConfigurations
                                                                          .Select("DesignationId = " + designationId + " AND LeaveTypeId = " + leaveTypeId.ToString()).FirstOrDefault();
                                if (drLeaveDesignationConfiguration != null)
                                {
                                    decimal leaveAmount = Convert.ToDecimal(drLeaveDesignationConfiguration["LeaveCount"].ToString());

                                    if (leaveAmount > 0)
                                    {
                                        Business.LeaveManagement.LeaveAccountBalance objLeaveAccountBalance = new Business.LeaveManagement.LeaveAccountBalance();
                                        int response = objLeaveAccountBalance.LeaveAccontBalance_Adjust(new Entity.LeaveManagement.LeaveAccountBalance()
                                        {
                                            LeaveTypeId = leaveTypeId,
                                            Amount      = +leaveAmount,
                                            EmployeeId  = Convert.ToInt32(drEmployee["EmployeeMasterId"].ToString()),
                                            Reason      = ddlLeaveType.SelectedItem + " IS GENERATED FOR " + ddlMonths.SelectedValue + "_" + ddlQuarters.SelectedValue + "_" + ddlHalf.SelectedValue + "_" + ddlYears.SelectedValue
                                        });
                                        if (response > 0)
                                        {
                                            totalCount++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(totalCount);
        }
Beispiel #2
0
        private void LeaveDesignationWiseConfiguration_GetAll()
        {
            Business.LeaveManagement.LeaveDesignationWiseConfiguration objLeaveDesignationWiseConfiguration = new Business.LeaveManagement.LeaveDesignationWiseConfiguration();
            Entity.LeaveManagement.LeaveDesignationWiseConfiguration   leaveDesignationWiseConfiguration    = new Entity.LeaveManagement.LeaveDesignationWiseConfiguration();

            DataTable dt = objLeaveDesignationWiseConfiguration.LeaveDesignationConfig_GetAll(leaveDesignationWiseConfiguration);

            gvLeaveDesignationConfiguration.DataSource = dt;
            gvLeaveDesignationConfiguration.DataBind();
        }
Beispiel #3
0
        private void LeaveDesignationConfig_GetById()
        {
            Business.LeaveManagement.LeaveDesignationWiseConfiguration objLeaveDesignationWiseConfiguration = new Business.LeaveManagement.LeaveDesignationWiseConfiguration();

            DataTable dt = objLeaveDesignationWiseConfiguration.LeaveDesignationConfig_GetById(LeaveDesignationWiseConfigurationId);

            if (dt.Rows.Count > 0)
            {
                ddlLeaveType.SelectedValue = dt.Rows[0]["LeaveTypeId"].ToString();
                ddlDesignation.Text        = dt.Rows[0]["DesignationId"].ToString();
                txtCarryForwardCount.Text  = dt.Rows[0]["CarryForwardCount"].ToString();
                txtLeaveCount.Text         = dt.Rows[0]["LeaveCount"].ToString();
                txtMinApplyDays.Text       = dt.Rows[0]["MinApplyDays"].ToString();
                txtMaxApplyDays.Text       = dt.Rows[0]["MaxApplyDays"].ToString();
            }
        }
Beispiel #4
0
        protected void gvLeaveDesignationConfiguration_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "E")
                {
                    LeaveDesignationWiseConfigurationId = Convert.ToInt32(e.CommandArgument.ToString());
                    LeaveDesignationConfig_GetById();
                }
                else
                {
                    if (e.CommandName == "D")
                    {
                        Business.LeaveManagement.LeaveDesignationWiseConfiguration objLeaveDesignationWiseConfiguration = new Business.LeaveManagement.LeaveDesignationWiseConfiguration();
                        LeaveDesignationWiseConfigurationId = Convert.ToInt32(e.CommandArgument.ToString());
                        int RowsAffected = objLeaveDesignationWiseConfiguration.LeaveDesignationConfig_Delete(LeaveDesignationWiseConfigurationId);
                        if (RowsAffected > 0)
                        {
                            LoadLeaveType();
                            LeaveDesignationWiseConfiguration_GetAll();
                            Message.Show = true;
                            Message.Text = "Deleted Successfully";
                        }
                        else
                        {
                            Message.Show = false;
                            Message.Text = "Data Dependency Exists";
                        }
                        Message.Show = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
        }
Beispiel #5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (LeaveDesignationConfigValidate())
                {
                    Business.LeaveManagement.LeaveDesignationWiseConfiguration objLeaveDesignationWiseConfiguration = new Business.LeaveManagement.LeaveDesignationWiseConfiguration();
                    Entity.LeaveManagement.LeaveDesignationWiseConfiguration   leaveDesignationWiseConfiguration    = new Entity.LeaveManagement.LeaveDesignationWiseConfiguration();

                    leaveDesignationWiseConfiguration.LeaveDesignationConfigId = LeaveDesignationWiseConfigurationId;
                    leaveDesignationWiseConfiguration.LeaveTypeId       = Convert.ToInt32(ddlLeaveType.SelectedValue);
                    leaveDesignationWiseConfiguration.DesignationId     = Convert.ToInt32(ddlDesignation.SelectedValue);
                    leaveDesignationWiseConfiguration.LeaveCount        = Convert.ToDecimal(txtLeaveCount.Text.Trim());
                    leaveDesignationWiseConfiguration.CarryForwardCount = Convert.ToDecimal(txtCarryForwardCount.Text.Trim());
                    leaveDesignationWiseConfiguration.MinApplyDays      = Convert.ToDecimal(txtMinApplyDays.Text.Trim());
                    leaveDesignationWiseConfiguration.MaxApplyDays      = Convert.ToDecimal(txtMaxApplyDays.Text.Trim());
                    int response = objLeaveDesignationWiseConfiguration.LeaveDesignationConfig_Save(leaveDesignationWiseConfiguration);
                    if (response > 0)
                    {
                        Clear();
                        LeaveDesignationWiseConfiguration_GetAll();
                        Message.IsSuccess = true;
                        Message.Text      = "Saved Successfully";
                    }
                    else
                    {
                        Message.IsSuccess = false;
                        Message.Text      = "Exists";
                    }
                }
                Message.Show = true;
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
        }
        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);
        }
Beispiel #7
0
        private bool LeaveDesignationConfigValidate()
        {
            bool retValue = true;

            try
            {
                if (ddlLeaveType.SelectedIndex == 0)
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Please select Leave Type.";
                    Message.Show      = true;
                    return(false);
                }
                if (ddlDesignation.SelectedIndex == 0)
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Please select Designation.";
                    Message.Show      = true;
                    return(false);
                }
                if (string.IsNullOrEmpty(txtLeaveCount.Text.Trim()))
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Please enter Leave Total.";
                    Message.Show      = true;
                    return(false);
                }
                if (string.IsNullOrEmpty(txtCarryForwardCount.Text.Trim()))
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Please enter Carry Forward Amount.";
                    Message.Show      = true;
                    return(false);
                }
                if (string.IsNullOrEmpty(txtMinApplyDays.Text.Trim()))
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Please enter Min Apply Days.";
                    Message.Show      = true;
                    return(false);
                }
                if (string.IsNullOrEmpty(txtMaxApplyDays.Text.Trim()))
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Please enter Max Apply Days.";
                    Message.Show      = true;
                    return(false);
                }

                Business.LeaveManagement.LeaveDesignationWiseConfiguration objLeaveDesignationWiseConfiguration = new Business.LeaveManagement.LeaveDesignationWiseConfiguration();
                Entity.LeaveManagement.LeaveDesignationWiseConfiguration   leaveDesignationWiseConfiguration    = new Entity.LeaveManagement.LeaveDesignationWiseConfiguration();
                leaveDesignationWiseConfiguration.LeaveTypeId   = Convert.ToInt32(ddlLeaveType.SelectedValue);
                leaveDesignationWiseConfiguration.DesignationId = Convert.ToInt32(ddlDesignation.SelectedValue);
                DataTable dt = objLeaveDesignationWiseConfiguration.LeaveDesignationConfig_GetAll(leaveDesignationWiseConfiguration);
                if (LeaveDesignationWiseConfigurationId == 0)
                {
                    if (dt != null && dt.AsEnumerable().Any())
                    {
                        Message.IsSuccess = false;
                        Message.Text      = "Designation configuration already exists.";
                        Message.Show      = true;
                        return(false);
                    }
                }
                else
                {
                    if (dt == null || !dt.AsEnumerable().Any())
                    {
                        Message.IsSuccess = false;
                        Message.Text      = "Designation configuration does not exists.";
                        Message.Show      = true;
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
            return(retValue);
        }