コード例 #1
0
        private void buttonPayStub_Click(object sender, EventArgs e)
        {
            //Declare local variables
            string  nameOfEmployee;
            decimal weeklyHours, rateOfPay, aCalculatePay;

            PayStub aPayStub;

            // Assign variable values
            nameOfEmployee = textBoxName.Text;

            weeklyHours = numericUpDownHours.Value;
            rateOfPay   = numericUpDownRate.Value;

            //Instatiate new PayStub object and pass variables
            aPayStub = new PayStub(nameOfEmployee, weeklyHours, rateOfPay);

            //Assign aCalculatePay variable
            aCalculatePay = aPayStub.NetPay;

            //Display result in label
            labelPay.Text = aCalculatePay.ToString("c2");

            //Disable controls
            groupBoxCalculate.Enabled = false;
            buttonPayStub.Enabled     = false;
        }
コード例 #2
0
        private void buttonSummary_Click(object sender, EventArgs e)
        {
            //Prepare summary message to dispaly to message box
            string stringMessage = $" Total Number of Pay Stubs: {PayStub.TotalPayStubs.ToString("n0")} \n Total Net Pay: {PayStub.TotalNetPay.ToString("c2")} \n Average Net Pay: {PayStub.CalculateAverageNetPay().ToString("c2")}";

            //Display the message box
            MessageBox.Show(stringMessage, "Summary", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }