예제 #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);
        }
예제 #2
0
        private int LeaveAccontBalance_Adjust(int leaveApplicationId)
        {
            Entity.LeaveManagement.LeaveAccountBalance   leaveAccountBalance    = new Entity.LeaveManagement.LeaveAccountBalance();
            Business.LeaveManagement.LeaveAccountBalance objLeaveAccountBalance = new Business.LeaveManagement.LeaveAccountBalance();

            leaveAccountBalance.EmployeeId  = EmployeeMasterId;
            leaveAccountBalance.LeaveTypeId = Convert.ToInt32(ddlLeaveType.SelectedValue);
            leaveAccountBalance.Amount      = (ddlOperation.SelectedValue == "1") ? Convert.ToDecimal(txtLeaveAmount.Text.Trim()) : -Convert.ToDecimal(txtLeaveAmount.Text.Trim());
            leaveAccountBalance.Reason      = "MANUAL ADJUSTMENT: " + txtComments.Text.Trim();

            int response = objLeaveAccountBalance.LeaveAccontBalance_Adjust(leaveAccountBalance);

            return(response);
        }
예제 #3
0
        private int LeaveAccontBalance_Deduct(int leaveApplicationId)
        {
            Entity.LeaveManagement.LeaveAccountBalance   leaveAccountBalance    = new Entity.LeaveManagement.LeaveAccountBalance();
            Business.LeaveManagement.LeaveAccountBalance objLeaveAccountBalance = new Business.LeaveManagement.LeaveAccountBalance();

            DataTable dtLeaveApplicationMaster = new Business.LeaveManagement.LeaveApplication()
                                                 .LeaveApplicationMaster_GetAll(
                new Entity.LeaveManagement.LeaveApplicationMaster()
            {
                LeaveApplicationId = leaveApplicationId
            });

            if (dtLeaveApplicationMaster != null && dtLeaveApplicationMaster.AsEnumerable().Any())
            {
                leaveAccountBalance.EmployeeId  = Convert.ToInt32(dtLeaveApplicationMaster.Rows[0]["RequestorId"].ToString());
                leaveAccountBalance.LeaveTypeId = Convert.ToInt32(dtLeaveApplicationMaster.Rows[0]["LeaveTypeId"].ToString());
                leaveAccountBalance.Amount      = -(Convert.ToDecimal(dtLeaveApplicationMaster.Rows[0]["TotalLeaveDays"].ToString()));
                leaveAccountBalance.Reason      = "LEAVE APPROVED";
            }

            int response = objLeaveAccountBalance.LeaveAccontBalance_Adjust(leaveAccountBalance);

            return(response);
        }