Ejemplo n.º 1
0
        public SavingResult ReInstate(int EmployeeID, string Reason, EmployeeServiceDetailViewModel ServiceDetail)
        {
            SavingResult res = new SavingResult();

            using (dbVisionEntities db = new dbVisionEntities())
            {
                var SaveModel = db.tblEmployees.Find(EmployeeID);
                if (SaveModel == null)
                {
                    res.ValidationError = "Selected employee not found.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }

                tblEmployeeServiceDetail EmployeeServiceDetail = new tblEmployeeServiceDetail()
                {
                    tblEmployee             = SaveModel,
                    EmploymentEffectiveDate = ServiceDetail.EmploymentEffectiveDate,
                    ContractExpiryDate      = ServiceDetail.ContractExpiryDate,
                    EmploymentType          = ServiceDetail.EmploymentType,

                    EmployeeDesignationID = ServiceDetail.EmployeeDesignationID,
                    EmployeeDepartmentID  = ServiceDetail.EmployeeDepartmentID,
                    EmployeeWIBAClassID   = ServiceDetail.EmployeeWIBAClassID,
                    LocationID            = ServiceDetail.LocationID,
                    MinimumWageCategoryID = ServiceDetail.MinimumWageCategoryID,

                    DailyRate        = ServiceDetail.DailyRate,
                    BasicSalary      = ServiceDetail.BasicSalary,
                    HousingAllowance = ServiceDetail.HousingAllowance,
                    WeekendAllowance = ServiceDetail.WeekendAllowance,

                    EmployeeShiftType = ServiceDetail.EmployeeShiftTypeID,
                    EmployeeShiftID   = ServiceDetail.EmployeeShiftID,

                    ReinstatementReason = Reason,
                };

                db.tblEmployeeServiceDetails.Add(EmployeeServiceDetail);

                SaveModel.tblEmployeeServiceDetail = EmployeeServiceDetail;
                try
                {
                    db.SaveChanges();
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    CommonFunctions.GetFinalError(res, ex);
                }
            }
            return(res);
        }
Ejemplo n.º 2
0
        public SavingResult Termination(int EmployeeID, eTerminationType Type, DateTime TerminationDate, string Reason)
        {
            SavingResult res = new SavingResult();

            using (dbVisionEntities db = new dbVisionEntities())
            {
                var SaveModel = db.tblEmployees.Find(EmployeeID);
                if (SaveModel == null)
                {
                    res.ValidationError = "Selected employee not found.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }
                tblEmployeeServiceDetail ServiceSaveModel = null;
                if (SaveModel.EmployeeLastServiceDetailID != null)
                {
                    ServiceSaveModel = db.tblEmployeeServiceDetails.Find(SaveModel.EmployeeLastServiceDetailID);
                }
                if (ServiceSaveModel == null)
                {
                    res.ValidationError = "No service detail found.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }

                ServiceSaveModel.EmployeementStatus = (byte)(Type == eTerminationType.Resignation ? eEmployementStatus.Resigned : eEmployementStatus.Terminated);
                ServiceSaveModel.TerminationTypeID  = (byte)Type;
                ServiceSaveModel.TerminationDate    = TerminationDate;
                ServiceSaveModel.TerminationReason  = Reason;
                db.tblEmployeeServiceDetails.Attach(ServiceSaveModel);
                db.Entry(ServiceSaveModel).State = System.Data.Entity.EntityState.Modified;

                try
                {
                    db.SaveChanges();
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    CommonFunctions.GetFinalError(res, ex);
                }
            }
            return(res);
        }
Ejemplo n.º 3
0
        void GetPaySlipData(int EmployeeID)
        {
            ClearPayrollValues();
            //--
            EmployeeSaveModel = EmployeeDALObj.FindSaveModelByPrimeKey(EmployeeID);
            if (EmployeeSaveModel == null)
            {
                return;
            }

            ServiceSaveModel = EmployeeSaveModel.tblEmployeeServiceDetail;
            if (ServiceSaveModel == null)
            {
                return;
            }

            BasicIncome        = ServiceSaveModel.BasicSalary;
            txtIncomeType.Text = (EmployeeSaveModel.IncomeType ? "Primary" : "Secondry") + " Income";
            HRA = ServiceSaveModel.HousingAllowance;

            NormalOvertimeRatio = CommonProperties.LoginInfo.SoftwareSettings.OvertimeRate;
            DoubleOvertimeRatio = CommonProperties.LoginInfo.SoftwareSettings.DoubleOvertimeRate;

            decimal GrossPay             = BasicIncome + HRA;
            decimal WorkingHoursPerMonth = ((CommonProperties.LoginInfo.SoftwareSettings.WorkingHoursPerWeek * 52) / 12);

            BasicPayRatePerHour = Math.Round(BasicIncome / WorkingHoursPerMonth, 2);
            BasicPayRatePerDay  = Math.Round((BasicIncome / WorkingHoursPerMonth) * CommonProperties.LoginInfo.SoftwareSettings.WorkingHoursPerDay, 2);

            GrossPayRatePerHour = Math.Round(GrossPay / WorkingHoursPerMonth, 2);
            GrossPayRatePerDay  = Math.Round((GrossPay / WorkingHoursPerMonth) * CommonProperties.LoginInfo.SoftwareSettings.WorkingHoursPerDay, 2);

            LatenessRatePerDay = Model.CommonProperties.LoginInfo.SoftwareSettings.LatenessPenaltyAmount;

            EditingEmployeeDetail = DALObj.FindPayrollEmployeeDetail(DateFrom.Month, DateFrom.Year, EmployeeSaveModel.EmployeeID);
            if (EditingEmployeeDetail != null)
            {
                #region Fill saved data in form
                NormalOvertimeHours = EditingEmployeeDetail.NormalOvertimeHours;
                DoubleOvertimeHours = EditingEmployeeDetail.DoubleOvertimeHours;
                AbsentDays          = EditingEmployeeDetail.AbsentDays;

                AbsentDays += EditingEmployeeDetail.MissedPunchDays;

                WeekendWorkedDays   = EditingEmployeeDetail.WeekendWorkedDays;
                LeaveEncashmentDays = EditingEmployeeDetail.LeaveEncashmentDays;
                NoticePayDay        = EditingEmployeeDetail.NoticePayDays;

                LatenessDays       = EditingEmployeeDetail.LateDays;
                LoanInstallmentAmt = EditingEmployeeDetail.LoanInstallmentAmount;
                lookUpVehicle_NonCashBenefit.EditValue = EditingEmployeeDetail.Vehicle_NoncashBenefitID;

                foreach (var r in EditingEmployeeDetail.tblPayrollEmployeeEarningsDeductions)
                {
                    var ViewModel = dsEarningAndDeduction.FirstOrDefault(rr => rr.EarningAndDeductionID == r.EarningsDeductionID && r.Value != 0);
                    if (ViewModel != null)
                    {
                        ViewModel.Value = r.Value;
                    }
                }
                gvEarnings.RefreshData();
                gvDeductions.RefreshData();

                foreach (var r in EditingEmployeeDetail.tblPayrollEmployeeNonCashBenefits)
                {
                    var ViewModel = dsNonCashBenefit.FirstOrDefault(rr => rr.NonCashBenefitID == r.NonCashBenefitID);
                    if (ViewModel != null)
                    {
                        ViewModel.Selected           = true;
                        ViewModel.CostValue          = r.CostValue;
                        ViewModel.KRAValuePercentage = r.KRAPerc;
                        ViewModel.KRAValue           = r.KRAValue;
                        ViewModel.Recurrning         = r.Recurring;
                    }
                }
                gvNonCashBenefit.RefreshData();

                foreach (var r in EditingEmployeeDetail.tblPayrollEmployePAYEReliefs)
                {
                    var ViewModel = dsPAYERelief.FirstOrDefault(rr => rr.PAYEReliefID == r.PAYEReliefID && r.PAYEReliefAmt != 0);
                    if (ViewModel != null)
                    {
                        ViewModel.Selected      = true;
                        ViewModel.PAYEReliefAmt = r.PAYEReliefAmt;
                    }
                }
                #endregion
            }
            else if (((eTAAttendanceType)EmployeeSaveModel.TAAttendanceType) == eTAAttendanceType.Integrated)
            {
                #region Processing Attendance Data
                Model.Employee.eTAAttendanceType AttendanceType = ((Model.Employee.eTAAttendanceType)EmployeeSaveModel.TAAttendanceType);

                if (AttendanceType == eTAAttendanceType.Integrated)
                {
                    EmployeeAttendanceDAL AttendanceDALObj = new EmployeeAttendanceDAL();
                    var dsAttendance = AttendanceDALObj.GetEmployeeAttendanceData(DateFrom, DateTo, EmployeeSaveModel.EmployeeID);

                    #region Earnings
                    NormalOvertimeHours = Math.Round(dsAttendance.Sum(r => r.NormalOvertimeHour), 2);

                    if (((Model.Employee.eTAWeekEndAttendance)EmployeeSaveModel.TAWeekEndAttendance) == Model.Employee.eTAWeekEndAttendance.Overtime)
                    {
                        DoubleOvertimeHours = Math.Round(dsAttendance.Sum(r => r.DoubleOvertimeHour), 2);
                    }

                    if (((Model.Employee.eTAWeekEndAttendance)EmployeeSaveModel.TAWeekEndAttendance) == Model.Employee.eTAWeekEndAttendance.Allowance)
                    {
                        // Round off not required, if weekend worked then whole day will be counted as worked.
                        WeekendWorkedDays = dsAttendance.Count(r =>
                                                               ((r.Weekend == eEmployeeWeekendDayType.WeekendWorked && r.WeekendWorkedApproved) ||
                                                                (r.RestDay == eEmployeeRestDayDayType.RestDayWorked || r.RestDayWorkedApproved)) && (((eTAMissPunch)EmployeeSaveModel.TAMissPunch) == eTAMissPunch.Present || !r.MissedPunch));
                    }

                    LeaveEncashmentDays = DALObj.CountLeaveEncashmentDays(EmployeeSaveModel.EmployeeID, DateFrom, DateTo);
                    #endregion

                    #region Deductions
                    AbsentDays = dsAttendance.Sum(r => r.AbsentCount);

                    if (((eTAMissPunch)EmployeeSaveModel.TAMissPunch) == eTAMissPunch.Abscent)
                    {
                        AbsentDays += dsAttendance.Count(r => r.MissedPunch);
                    }

                    if (((Model.Employee.eTALatenessCharges)EmployeeSaveModel.TALatenessCharges) == Model.Employee.eTALatenessCharges.Applicable)
                    {
                        LatenessDays = dsAttendance.Count(r => r.LateIn && !r.LatenessApproved);
                    }

                    LoanInstallmentAmt = DALObj.GetLoanInstallmentAmt(EmployeeSaveModel.EmployeeID, DateFrom, DateTo);
                    #endregion
                }
                #endregion
            }
            CalculatePAYE();
            CalculatePayslipTab();
        }
Ejemplo n.º 4
0
        void ClearPayrollValues()
        {
            EmployeeSaveModel     = null;
            ServiceSaveModel      = null;
            EditingEmployeeDetail = null;
            NormalOvertimeHours   = 0;
            DoubleOvertimeHours   = 0;
            AbsentDays            = 0;
            NoticePayDay          = 0;
            LeaveEncashmentDays   = 0;
            WeekendWorkedDays     = 0;

            LatenessDays = 0;
            //LatenessAmt = 0;
            LoanInstallmentAmt = 0;

            lookUpVehicle_NonCashBenefit.EditValue = null;

            dsEarningAndDeduction.ForEach(r => r.Value = 0);
            gvEarnings.RefreshData();
            gvDeductions.RefreshData();

            dsNonCashBenefit.ForEach(r =>
            {
                r.Selected   = false;
                r.Recurrning = false;

                var defaultValues = dsNonCashBenefitDefaultValues.FirstOrDefault(dr => dr.NonCashBenefitID == r.NonCashBenefitID);
                if (defaultValues != null)
                {
                    r.KRAValue           = defaultValues.KRAValue;
                    r.KRAValuePercentage = defaultValues.KRAValuePercentage;
                    r.CostValue          = defaultValues.CostValue;
                }
            });
            gvNonCashBenefit.RefreshData();

            dsPAYERelief.ForEach(r =>
            {
                if (r.Mandatory == Model.Settings.ePAYEReliefeMandatory.Yes)
                {
                    r.Selected      = true;
                    r.PAYEReliefAmt = r.MonthlyLimit;
                }
                else
                {
                    r.Selected = false;
                }
                //r.PAYEReliefAmt = 0;
            });
            gvPAYERelief.RefreshData();

            cmbNSSF.SelectedIndex           = 1;
            cmbNHIFApplicable.SelectedIndex = 1;

            BasicIncome        = 0;
            HRA                = 0;
            GrossTaxableIncome = 0;
            TaxableIncome      = 0;
            NetTaxableIncome   = 0;

            PAYETaxableEarningBindingSource.Clear();
            gvTaxableEarnings.RefreshData();

            PAYENoncashBenefitBindingSource.Clear();
            gvPAYE_NonCashBenefit.RefreshData();

            PAYEReliefeBindingSource.Clear();
            gvPAYE_PAYERelief.RefreshData();
        }
Ejemplo n.º 5
0
        public SavingResult SaveNewRecord(tblEmployee SaveModel,
                                          EmployeeServiceDetailViewModel ServiceDetail,
                                          List <EmployeePersonalDocumentViewModel> DoucmentsList,
                                          List <EmployeeFamilyDetailsViewModel> FamilyDetailsList)
        {
            SavingResult res = new SavingResult();

            //-- Perform Validation
            //res.ExecutionResult = eExecutionResult.ValidationError;
            //res.ValidationError = "Validation error message";
            //return res;
            //--
            using (dbVisionEntities db = new dbVisionEntities())
            {
                //tblEmployee SaveModel;
                if (SaveModel.EmployeeFirstName == "")
                {
                    res.ValidationError = "Can not accept blank value. Please enter Employee Name.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }
                else if (IsDuplicateRecord(SaveModel.EmployeeFirstName, SaveModel.EmployeeLastName, SaveModel.EmployeeID, db))
                {
                    res.ValidationError = "Can not accept duplicate value. The Employee Name is already exists.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }

                if (SaveModel.EmployeeID == 0) // New Entry
                {
                    //SaveModel = new tblEmployee();
                    SaveModel.rcuid     = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.rcdt      = DateTime.Now;
                    SaveModel.CompanyID = Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID;
                    db.tblEmployees.Add(SaveModel);
                }
                else
                {
                    SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.redt  = DateTime.Now;
                    db.tblEmployees.Attach(SaveModel);
                    db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified;
                    db.tblEmployeeDocuments.RemoveRange(SaveModel.tblEmployeeDocuments);
                    db.tblEmployeeFamilies.RemoveRange(SaveModel.tblEmployeeFamilies);

                    if (ServiceDetail != null)
                    {
                        db.tblEmployeeLeaveOpeningBalances.RemoveRange(SaveModel.tblEmployeeServiceDetail.tblEmployeeLeaveOpeningBalances);

                        SaveModel.EmployeeLastServiceDetailID = null;
                        db.tblEmployeeServiceDetails.RemoveRange(db.tblEmployeeServiceDetails.Where(r => r.EmployeeID == SaveModel.EmployeeID && r.EmploymentEffectiveDate >= ServiceDetail.EmploymentEffectiveDate));
                    }
                }

                //--
                tblEmployeeServiceDetail EmployeeServiceDetail = null;
                if (ServiceDetail != null)
                {
                    if (SaveModel.EmployeeLastServiceDetailID == null) // first employment record
                    {
                        EmployeeServiceDetail = new tblEmployeeServiceDetail()
                        {
                            tblEmployee             = SaveModel,
                            EmploymentEffectiveDate = ServiceDetail.EmploymentEffectiveDate,
                            ContractExpiryDate      = ServiceDetail.ContractExpiryDate,
                            EmploymentType          = ServiceDetail.EmploymentType,

                            EmployeeDesignationID = ServiceDetail.EmployeeDesignationID,
                            EmployeeDepartmentID  = ServiceDetail.EmployeeDepartmentID,
                            EmployeeWIBAClassID   = ServiceDetail.EmployeeWIBAClassID,
                            LocationID            = ServiceDetail.LocationID,
                            MinimumWageCategoryID = ServiceDetail.MinimumWageCategoryID,

                            DailyRate        = ServiceDetail.DailyRate,
                            BasicSalary      = ServiceDetail.BasicSalary,
                            HousingAllowance = ServiceDetail.HousingAllowance,
                            WeekendAllowance = ServiceDetail.WeekendAllowance,

                            EmployeeShiftType = ServiceDetail.EmployeeShiftTypeID,
                            EmployeeShiftID   = ServiceDetail.EmployeeShiftID,
                        };

                        db.tblEmployeeServiceDetails.Add(EmployeeServiceDetail);

                        db.tblEmployeeLeaveOpeningBalances.AddRange(ServiceDetail.EmployeeLeaveOpeningBalance.Select(lopb =>
                                                                                                                     new tblEmployeeLeaveOpeningBalance()
                        {
                            tblEmployee = SaveModel,
                            tblEmployeeServiceDetail = EmployeeServiceDetail,
                            LeaveTypeID         = lopb.LeaveTypeID,
                            LeaveOpeningBalance = lopb.OpeningBalance,
                            CompanyID           = CommonProperties.LoginInfo.LoggedInCompany.CompanyID,
                            FinPeriodID         = CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodID,
                        }));
                    }
                }
                //--

                db.tblEmployeeDocuments.AddRange(DoucmentsList.Select(r => new tblEmployeeDocument()
                {
                    tblEmployee  = SaveModel,
                    DocumentName = r.DocumentName,
                    FileName     = r.FileName
                }));

                if (FamilyDetailsList != null)
                {
                    db.tblEmployeeFamilies.AddRange(FamilyDetailsList.Select(r => new tblEmployeeFamily()
                    {
                        tblEmployee  = SaveModel,
                        Address      = r.Address,
                        Beneficiary  = r.Beneficiary,
                        City         = r.City,
                        Email        = r.Email,
                        MobileNo     = r.MobileNo,
                        Name         = r.Name,
                        POBoxNo      = r.POBoxNo,
                        Relationship = r.Relationship
                    }));
                }
                try
                {
                    db.SaveChanges();
                    res.PrimeKeyValue   = SaveModel.EmployeeID;
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    CommonFunctions.GetFinalError(res, ex);
                    return(res);
                }

                if (EmployeeServiceDetail != null)
                {
                    SaveModel.EmployeeLastServiceDetailID = EmployeeServiceDetail.EmployeeServiceDetailID;
                    try
                    {
                        db.SaveChanges();
                        res.PrimeKeyValue   = SaveModel.EmployeeID;
                        res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                    }
                    catch (Exception ex)
                    {
                        CommonFunctions.GetFinalError(res, ex);
                        return(res);
                    }
                }

                //                // Assign Employee ID in past Attendance data
                //                if (res.ExecutionResult == eExecutionResult.CommitedSucessfuly)
                //                {
                //                    db.Database.ExecuteSqlCommand($@"
                //Update att SET EmployeeID = e.EmployeeID, CompanyID = e.CompanyID
                //from tblEmployeeAttendance att
                //Inner Join tblEmployee e on e.TACode = att.EmployeeTACode
                //where att.EmployeeID is NULL AND att.EmployeeTACode IS NOT NULL AND e.EmployeeID = {SaveModel.EmployeeID}

                //Update ad Set ad.EmployeeID = a.EmployeeID, ad.CompanyID = a.CompanyID
                //from tblEmployeeAttendanceDetail ad
                //inner join tblEmployeeAttendance a on a.EmployeeAttendanceID = ad.EmployeeAttendanceID
                //where ad.EmployeeID IS NULL AND a.EmployeeID = {SaveModel.EmployeeID}");

                //                }
            }
            return(res);
        }