internal static void Calculate(MainForm form, int idEmployee, DateTime date)
        {
            Employees.EmployeeManager employeeManager = new Employees.EmployeeManager();
            Employees.Employee        employee        = employeeManager.GetEmployee(idEmployee, TableView.view, ConnectionToDB.disconnect);
            int hoursToWork   = Salary.GetHoursToWork(date);
            int sumAllMinutes = 0;

            SalaryWork salaryWork = new SalaryWork(idEmployee, date);

            form.LblIloscGodzinDoPrzepracowania = hoursToWork.ToString();
            form.LblGodzinyPrzepracowane        = salaryWork.NumberOfMinutesRegular.ToString();
            form.LblGodzinyNadliczbowe50        = salaryWork.NumberOfMinutes50.ToString();
            form.LblGodzinyNadliczbowe100       = salaryWork.NumberOfMinutes100.ToString();
            sumAllMinutes          += salaryWork.NumberOfMinutesAll;
            form.LblZaGodziny       = salaryWork.CalculateSalaryRegular(employee.RateRegular, hoursToWork);
            form.LblZaNadgodziny50  = salaryWork.CalculateSalaryOvertime50(employee.RateOvertime);
            form.LblZaNadgodziny100 = salaryWork.CalculateSalaryOvertime100(employee.RateOvertime);

            SalaryDayOff salaryDayOff = new SalaryDayOff(idEmployee, date);

            form.LblGodzinyUrlopowePlatne    = salaryDayOff.NumberOfMinutesDayOffPaid.ToString();
            form.LblGodzinyUrlopoweBezplatne = salaryDayOff.NumberOfMinutesDayOffFree.ToString();
            sumAllMinutes          += (salaryDayOff.NumberOfMinutesDayOffFree + salaryDayOff.NumberOfMinutesDayOffPaid);
            form.LblPozostaloUrlopu = employee.NumberDaysOffLeft;
            form.LblZaUrlopowe      = salaryDayOff.CalculateSalaryDayOff(employee.RateRegular, hoursToWork);

            SalaryIllness salaryIllness = new SalaryIllness(idEmployee, date);

            form.LblGodzinyChorobowe80  = salaryIllness.NumberOfMinutesIllness80.ToString();
            form.LblGodzinyChorobowe100 = salaryIllness.NumberOfMinutesIllness100.ToString();
            sumAllMinutes         += (salaryIllness.NumberOfMinutesIllness80 + salaryIllness.NumberOfMinutesIllness100);
            form.LblZaChorobowe80  = salaryIllness.CalculateSalaryIllness80(employee.RateRegular, hoursToWork);
            form.LblZaChorobowe100 = salaryIllness.CalculateSalaryIllness100(employee.RateRegular, hoursToWork);

            SalaryAddition salaryAddition = new SalaryAddition(idEmployee, date);

            form.LblZaDodatek = salaryAddition.ForAdditions;

            SalaryAdvance salaryAdvance = new SalaryAdvance(idEmployee, date);

            form.LblZaZaliczke = salaryAdvance.ForAdvances;

            SalaryLoanInstallment salaryLoanInstallment = new SalaryLoanInstallment();

            form.LblPozostaloPozyczki = salaryLoanInstallment.LoansRemianedToPay(employee.IdEmployee);
            form.LblZaPozyczke        = salaryLoanInstallment.AmountForPaidOffInstallmentInMonth(employee.IdEmployee, date);

            form.LblSumaGodzin         = sumAllMinutes.ToString();
            form.LblZaWszystko         = salaryWork.ForAll + salaryIllness.ForAll + salaryDayOff.ForDayOff;
            form.LblDoWyplaty          = salaryWork.ForAll + salaryIllness.ForAll + salaryDayOff.ForDayOff - salaryAdvance.ForAdvances + salaryAddition.ForAdditions - salaryLoanInstallment.ForInstallment;
            form.LblStawka             = employee.RateRegular.RateValue;
            form.LblStawkaNadgodzinowa = employee.RateOvertime.RateValue;
        }
        public void CalculateSalaryOverTime50Test()
        {
            //Arange
            RateOvertime rateOvertime = new RateOvertime(DateTime.Now, 20.9f);

            employee.RateOvertime = rateOvertime;
            SalaryWork salaryWork = new SalaryWork(employee.IdEmployee, date);

            salaryWork.NumberOfMinutes100 = 1590; //26:30
            salaryWork.NumberOfMinutes50  = 1955; //32:35

            double should = 1021.49d;

            //Act
            var result = salaryWork.CalculateSalaryOvertime50(rateOvertime);

            //Arrange
            Assert.AreEqual(should, result);
        }
        private bool FillPage(int x, int y, Employee employee, PrintPageEventArgs e)
        {
            // utworzenie fonta
            Font font10     = new Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Point);
            Font font10Bold = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point);
            Font font8      = new Font("Arial", 8, FontStyle.Regular, GraphicsUnit.Point);
            Font font8Bold  = new Font("Arial", 8, FontStyle.Bold, GraphicsUnit.Point);

            //kolor pióra czarny
            Pen penBlack = new Pen(Brushes.Black);

            SalaryDayOff          salaryDayOff          = new SalaryDayOff(employee.IdEmployee, date);
            SalaryIllness         salaryIllness         = new SalaryIllness(employee.IdEmployee, date);
            SalaryWork            salaryWork            = new SalaryWork(employee.IdEmployee, date);
            SalaryLoanInstallment salaryLoanInstallment = new SalaryLoanInstallment();
            SalaryAdvance         salaryAdvance         = new SalaryAdvance(employee.IdEmployee, date);
            SalaryAddition        salaryAddition        = new SalaryAddition(employee.IdEmployee, date);

            StringFormat sf = new StringFormat();

            //ustawienie tekstu w prostokątach
            sf.Alignment = StringAlignment.Center;//środek

            //pierwszy prostokąt LEWA strona tabeli
            SizeF     sF_Left;
            Rectangle r_Left = new Rectangle();

            //drugi prostokąt Kwota
            SizeF     sF_right;
            Rectangle r_Right = new Rectangle();

            //PIERWSZA LINIA
            e.Graphics.DrawLine(penBlack, x, y, e.PageBounds.Right - 25, y);
            Rectangle rect = new Rectangle(x, y + 10, e.PageBounds.Right - 25, (int)Math.Ceiling(font10.GetHeight(e.Graphics)));

            e.Graphics.DrawString(string.Format("ROZLICZENIE CZASU PRACY - {0} {1}, {2}.{3}",
                                                employee.FirstName, employee.LastName, date.Month, date.Year), font10Bold, Brushes.Black, rect, sf);

            ///////////////////////////////////////////
            ///////////////////////////////////////////     LEFT COLUMN
            //////////////////////////////////////////////
            sf.Alignment = StringAlignment.Near;//do lewej

            //godziny przepracowane
            sF_Left       = e.Graphics.MeasureString("Godziny przepracowane:", font8);
            r_Left.X      = x + space;
            r_Left.Y      = rect.Bottom;
            r_Left.Width  = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Height = (int)Math.Ceiling(sF_Left.Height);
            r_Left.Y     += r_Left.Height;
            e.Graphics.DrawString("Godziny przepracowane:", font8, Brushes.Black, r_Left, sf);

            sF_right       = e.Graphics.MeasureString("999:999", font8Bold);
            r_Right.X      = r_Left.Right;
            r_Right.Y      = r_Left.Y;
            r_Right.Width  = (int)Math.Ceiling(sF_right.Width);
            r_Right.Height = (int)Math.Ceiling(sF_right.Height);
            int tempWork = salaryWork.NumberOfMinutesRegular;

            e.Graphics.DrawString(string.Format("{0}:{1:00}", (tempWork / 60), (tempWork % 60)), font8Bold, Brushes.Black, r_Right, sf);


            //ilość godzin nadliczbowych 50%
            sF_Left      = e.Graphics.MeasureString("Godziny przepracowane 50%:", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Godziny przepracowane (50%):", font8, Brushes.Black, r_Left, sf);


            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            int tempWork50 = salaryWork.NumberOfMinutes50;

            e.Graphics.DrawString(string.Format("{0}:{1:00}", (tempWork50 / 60), (tempWork50 % 60)), font8Bold, Brushes.Black, r_Right, sf);


            //ilość godzin nadliczbowych 100%
            sF_Left      = e.Graphics.MeasureString("Godziny przepracowane (100%):", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Godziny przepracowane (100%):", font8, Brushes.Black, r_Left, sf);


            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            int tempWork100 = salaryWork.NumberOfMinutes100;

            e.Graphics.DrawString(string.Format("{0}:{1:00}", (tempWork100 / 60), (tempWork100 % 60)), font8Bold, Brushes.Black, r_Right, sf);


            //godziny urlopowe (płatne)
            sF_Left      = e.Graphics.MeasureString("Godziny urlopowe (płatne):", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Godziny urlopowe (płatne):", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            int temp = salaryDayOff.NumberOfMinutesDayOffPaid;

            e.Graphics.DrawString(string.Format("{0}:{1:00}", (temp / 60), (temp % 60)), font8Bold, Brushes.Black, r_Right, sf);

            // godziny urlopowe (bezpłatne)
            sF_Left      = e.Graphics.MeasureString("Godziny urlopowe (bezpłatne):", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Godziny urlopowe (bezpłatne):", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            int tempFree = salaryDayOff.NumberOfMinutesDayOffFree;

            e.Graphics.DrawString(string.Format("{0}:{1:00}", (tempFree / 60), (tempFree % 60)), font8Bold, Brushes.Black, r_Right, sf);

            //godziny chorobowe 80%
            sF_Left      = e.Graphics.MeasureString("Godziny chorobowe (80%):", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Godziny chorobowe (80%):", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            int tempIlness80 = salaryIllness.NumberOfMinutesIllness80;

            e.Graphics.DrawString(string.Format("{0}:{1:00}", (tempIlness80 / 60), (tempIlness80 % 60)), font8Bold, Brushes.Black, r_Right, sf);

            //godziny chorobowe 100%
            sF_Left      = e.Graphics.MeasureString("Godziny chorobowe (100%):", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Godziny chorobowe (100%):", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            int tempIlness100 = salaryIllness.NumberOfMinutesIllness100;

            e.Graphics.DrawString(string.Format("{0}:{1:00}", (tempIlness100 / 60), (tempIlness100 % 60)), font8Bold, Brushes.Black, r_Right, sf);

            //pogrubienie SUMA GODZIN
            sF_Left      = e.Graphics.MeasureString("Suma godzin:", font8Bold);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Suma godzin:", font8Bold, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            int tempWorkAll = salaryWork.NumberOfMinutesAll + salaryDayOff.NumberOfMinutesDayOffFree + salaryDayOff.NumberOfMinutesDayOffPaid +
                              salaryIllness.NumberOfMinutesIllness80 + salaryIllness.NumberOfMinutesIllness100;

            e.Graphics.DrawString(string.Format("{0}:{1:00}", (tempWorkAll / 60), (tempWorkAll % 60)), font8Bold, Brushes.Black, r_Right, sf);

            //normatywny czas pracy
            sF_Left      = e.Graphics.MeasureString("Normatywny czas pracy:", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height * 2;
            e.Graphics.DrawString("Normatywny czas pracy:", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0}", hoursToWork), font8, Brushes.Black, r_Right, sf);

            ////////////////////////////////
            ///////////////////////////////MIDDLE COLUMN
            ///////////////////////////////
            //za godziny
            sF_Left      = e.Graphics.MeasureString("Za przepracowane:", font8);
            r_Left.X     = r_Right.Right + space * 2;
            r_Left.Y     = rect.Bottom + r_Left.Height;
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            e.Graphics.DrawString("Za przepracowane:", font8, Brushes.Black, r_Left, sf);

            sF_right     = e.Graphics.MeasureString("300.524,00 zł", font8Bold);
            r_Right.X    = r_Left.Right;
            r_Right.Y    = r_Left.Y;
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            e.Graphics.DrawString(string.Format("{0:C}", salaryWork.CalculateSalaryRegular(employee.RateRegular, hoursToWork)), font8Bold, Brushes.Black, r_Right, sf);

            // za nadgodziny 50%
            sF_Left      = e.Graphics.MeasureString("Za nadgodziny (50%):", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Za nadgodziny (50%):", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0:C}", salaryWork.CalculateSalaryOvertime50(employee.RateOvertime)), font8Bold, Brushes.Black, r_Right, sf);

            //następna linia - za nadgodziny 100%
            sF_Left      = e.Graphics.MeasureString("Za nadgodziny (100%):", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Za nadgodziny (100%):", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0:C}", salaryWork.CalculateSalaryOvertime100(employee.RateOvertime)), font8Bold, Brushes.Black, r_Right, sf);

            //następna linia - za urlop
            sF_Left      = e.Graphics.MeasureString("Za urlop:", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Za urlop:", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0:C}", salaryDayOff.CalculateSalaryDayOff(employee.RateRegular, hoursToWork)), font8Bold, Brushes.Black, r_Right, sf);

            //następna linia - za chorobowe 80%
            sF_Left      = e.Graphics.MeasureString("Za chorobowe (80%):", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Za chorobowe (80%):", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0:C}", salaryIllness.CalculateSalaryIllness80(employee.RateRegular, hoursToWork)), font8Bold, Brushes.Black, r_Right, sf);

            //następna linia - za chorobowe 100%
            sF_Left      = e.Graphics.MeasureString("Za chorobowe (100%):", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Za chorobowe (100%):", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.Right;
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0:C}", salaryIllness.CalculateSalaryIllness100(employee.RateRegular, hoursToWork)), font8Bold, Brushes.Black, r_Right, sf);


            //następna linia - za wszystko
            sF_Left      = e.Graphics.MeasureString("Razem:", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Razem:", font8Bold, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.X + r_Left.Width;//obok lewego
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0:C}", salaryWork.ForAll + salaryIllness.ForAll + salaryDayOff.ForDayOff), font8Bold, Brushes.Black, r_Right, sf);

            //następna linia - pozostało urlopu
            sF_Left      = e.Graphics.MeasureString("Pozostało urlopu:", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height * 2;
            e.Graphics.DrawString("Pozostało urlopu:", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.X + r_Left.Width;
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0}", employee.NumberDaysOffLeft), font8Bold, Brushes.Black, r_Right, sf);

            //następna linia - pozostało pożyczki
            sF_Left      = e.Graphics.MeasureString("Pozostało do oddania (pożyczka):", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Pozostało do oddania (pożyczka):", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.X + r_Left.Width;
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0:C}", salaryLoanInstallment.LoansRemianedToPay(employee.IdEmployee)), font8Bold, Brushes.Black, r_Right, sf);

            /////////////////////////////////////
            ////////////////////////////////////    RIGHT COLUMN
            ////////////////////////////////////
            //zaliczki
            sF_Left      = e.Graphics.MeasureString("Zailczki:", font8);
            r_Left.X     = r_Right.Right + space;
            r_Left.Y     = rect.Bottom + r_Left.Height;
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            e.Graphics.DrawString("Zailczki:", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.X + r_Left.Width;//obok lewego
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0:C}", salaryAdvance.ForAdvances), font8Bold, Brushes.Black, r_Right, sf);

            // pożyczki
            sF_Left      = e.Graphics.MeasureString("Pożyczki:", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Pożyczki:", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.X + r_Left.Width;//obok lewego
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0:C}", salaryLoanInstallment.AmountForPaidOffInstallmentInMonth(employee.IdEmployee, date)), font8Bold, Brushes.Black, r_Right, sf);

            // dodatki
            sF_Left      = e.Graphics.MeasureString("Dodatki:", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Dodatki:", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.X + r_Left.Width;//obok lewego
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0:C}", salaryAddition.ForAdditions), font8Bold, Brushes.Black, r_Right, sf);

            // (większy odstęp) - stawka
            sF_Left      = e.Graphics.MeasureString("Stawka:", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += (r_Left.Height * 2);
            e.Graphics.DrawString("Stawka:", font8, Brushes.Black, r_Left, sf);

            sF_right      = e.Graphics.MeasureString("9.999,999 zł/mc", font8Bold);
            r_Right.Width = (int)Math.Ceiling(sF_right.Width);
            r_Right.X     = r_Left.X + r_Left.Width;
            r_Right.Y     = r_Left.Y;
            if (employee.RateRegular.IsMonthlyOrHourly == RateType.hourly)//zł/h
            {
                e.Graphics.DrawString(string.Format("{0} zł/h", employee.RateRegular.RateValue), font8Bold, Brushes.Black, r_Right, sf);
            }
            else
            {
                e.Graphics.DrawString(string.Format("{0} zł/mc", employee.RateRegular.RateValue), font8Bold, Brushes.Black, r_Right, sf);
            }


            // stawka nadodziny
            sF_Left      = e.Graphics.MeasureString("Stawka nadgodzinowa:", font8);
            r_Left.Width = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Y    += r_Left.Height;
            e.Graphics.DrawString("Stawka nadgodzinowa:", font8, Brushes.Black, r_Left, sf);

            r_Right.X = r_Left.X + r_Left.Width;
            r_Right.Y = r_Left.Y;
            e.Graphics.DrawString(string.Format("{0} zł/h", employee.RateOvertime.RateValue), font8Bold, Brushes.Black, r_Right, sf);

            //następna linia - do wypłaty
            sF_Left       = e.Graphics.MeasureString("Do wypłaty:", font10Bold);
            r_Left.Width  = (int)Math.Ceiling(sF_Left.Width);
            r_Left.Height = (int)Math.Ceiling(sF_Left.Height);
            r_Left.Y     += r_Left.Height * 2;
            e.Graphics.DrawString("Do wypłaty:", font10, Brushes.Black, r_Left, sf);

            sF_right       = e.Graphics.MeasureString("30.524,00 zł", font10Bold);
            r_Right.X      = r_Left.X + r_Left.Width;            //obok lewego
            r_Right.Y      = r_Left.Y;
            r_Right.Width  = (int)Math.Ceiling(sF_right.Width);  //szerokość prostokąta wg SizeF zaokraglone
            r_Right.Height = (int)Math.Ceiling(sF_right.Height); //wysokość prostokąta wg SizeF
            e.Graphics.DrawString(string.Format("{0:C}", salaryWork.ForAll + salaryIllness.ForAll + salaryDayOff.ForDayOff - salaryAdvance.ForAdvances + salaryAddition.ForAdditions - salaryLoanInstallment.ForInstallment), font10Bold, Brushes.Black, r_Right, sf);

            //przypisanie zmiennych dla nowego pracownika
            this.y = r_Right.Bottom + r_Right.Height * 2;

            if (employeeCounter == sumEmployeesPerPage)
            {
                return(true);
            }

            return(false);
        }