Exemple #1
0
        private void btnCreatePaySlip_Click(object sender, EventArgs e)
        {
            // declare local (method level) variables

            string  strName;
            decimal hoursWorked, payRate, payCheck;

            PaySlip aPaySlip;

            // assign input data into variables

            strName     = txtEmployeeName.Text;
            hoursWorked = Convert.ToDecimal(nudHours.Value);
            payRate     = Convert.ToDecimal(nudPayRate.Value);

            // instantiate a PaySlip object

            aPaySlip = new PaySlip(strName, hoursWorked, payRate);

            //access the NetPayCheck property

            payCheck = aPaySlip.NetPayCheck;

            // display the property

            lblPayCheckAmount.Text = payCheck.ToString("c");

            // disable controls

            btnCreatePaySlip.Enabled = false;
        }
Exemple #2
0
        private void btnDisplaySummary_Click(object sender, EventArgs e)
        {
            // display

            string strMessage = $"Total # of Pay Slips: {PaySlip.TotalPaySlips.ToString("N0")} \nTotal Gross Pay: {PaySlip.TotalGrossPay.ToString("C")} " +
                                $"\nTotal Net Pay: {PaySlip.TotalNetPay.ToString("C")} \nTotal Average Pay: {PaySlip.CalculateAvgNetPay().ToString("c")}";

            // display the result in a message box

            MessageBox.Show(strMessage, "Summary", MessageBoxButtons.OK, MessageBoxIcon.Information);

            // disable controls

            btnCreatePaySlip.Enabled = false;
        }