/// <summary>
        /// Sorts the report by name in ascending order using bubble sort.
        /// </summary>
        private void SortByNameDescending()
        {
            bool sorted = false;

            while (!sorted)
            {
                sorted = true;
                for (int i = 0; i < this.payrollList.Count - 1; i++)
                {
                    if (String.Compare(this.payrollList[i].Name, this.payrollList[i + 1].Name) < 0)
                    {
                        sorted = false;
                        Payroll tempPayroll = this.payrollList[i];
                        this.payrollList[i]     = this.payrollList[i + 1];
                        this.payrollList[i + 1] = tempPayroll;
                    }
                }
            }
        }
        /// <summary>
        /// Sorts the report by total wage in descending order using bubble sort.
        /// </summary>
        private void SortByTotalDescending()
        {
            bool sorted = false;

            while (!sorted)
            {
                sorted = true;
                for (int i = 0; i < this.payrollList.Count - 1; i++)
                {
                    if (payrollList[i].Total < payrollList[i + 1].Total)
                    {
                        sorted = false;
                        Payroll tempPayroll = this.payrollList[i];
                        this.payrollList[i]     = this.payrollList[i + 1];
                        this.payrollList[i + 1] = tempPayroll;
                    }
                }
            }
        }
 /// <summary>
 /// Manages the global list.
 /// From global list, removes payroll detail of employee not present in the global employee list
 /// Then set payroll detail of employee in this class from global payroll list if set there.
 /// Calls the handler method on list change.
 /// </summary>
 private void ManageGlobalList()
 {
     if (Globals.payrollList.Count == 0)
     {
         Globals.payrollList = this.payrollList.ToList();;
     }
     else
     {
         for (int i = 0; i < this.payrollList.Count; i++)
         {
             Payroll localPayroll = this.payrollList[i];
             foreach (Payroll globalPayroll in Globals.payrollList)
             {
                 if (localPayroll.Id == globalPayroll.Id)
                 {
                     localPayroll.HoursWorked = globalPayroll.HoursWorked;
                     this.payrollList[i]      = localPayroll;
                 }
             }
         }
         Globals.payrollList = this.payrollList.ToList();
     }
     this.payrollList.ListChanged += payrollList_ListChanged;
 }
        /// <summary>
        /// Updates the record of payroll.
        /// New instance is created as updating only the properties did not result in proper update in the datagridview
        /// </summary>
        /// <param name="hoursWorked">The hours worked.</param>
        private void UpdateRecord(int hoursWorked)
        {
            Payroll payroll = this.payrollList[row];

            this.payrollList[row] = new Payroll(payroll.Employee, hoursWorked);
        }
Exemple #5
0
 public PayrollUpdatedEventArgs(Payroll payroll)
 {
     this.payroll = payroll;
 }