Exemple #1
0
        private void summaryButton_Click(object sender, EventArgs e)
        {
            // display the number of married and unmarried taxpayers and average tax or say there is no data

            if (ListsAreEmpty())
            {
                NoDataAvailable();
            }

            else
            {
                outputTextBox.AppendText(Taxpayer.Summary());
            }
        }
Exemple #2
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            // try to load data from outside source

            String taxpayerFile;

            try
            {
                OpenFileDialog taxpayerFileChooser = new OpenFileDialog();
                taxpayerFileChooser.Filter = "All text files|*.txt";
                taxpayerFileChooser.ShowDialog();
                taxpayerFile = taxpayerFileChooser.FileName;
                taxpayerFileChooser.Dispose();


                using (StreamReader fileReader = new StreamReader(taxpayerFile))
                {
                    while (fileReader.EndOfStream == false)
                    {
                        String[] properties;
                        String   line;
                        string   name;
                        double   salary;
                        double   investmentIncome;
                        int      exemptions;
                        bool     married;

                        line       = fileReader.ReadLine();
                        properties = line.Split(',');

                        name             = properties[0];
                        salary           = double.Parse(properties[1]);
                        investmentIncome = double.Parse(properties[2]);
                        exemptions       = int.Parse(properties[3]);
                        married          = bool.Parse(properties[4]);

                        Taxpayer taxpayer;
                        taxpayer = new Taxpayer(name, salary, investmentIncome, exemptions, married);
                        ListSort(married, taxpayer);
                    }
                }
            }

            // if there is an error in the loading (user cancels load or the data is not in the proper format, dispaly message saying that data wasn't loaded
            catch
            {
                MessageBox.Show("No Data Imported");
            }
        }
Exemple #3
0
        private void ListSort(bool isMarried, Taxpayer newTaxpayer)
        {
            // sort the objects into the proper list based off marital status

            if (isMarried)
            {
                marriedTaxpayers.Add(newTaxpayer);
                unsavedMarriedTaxpayers.Add(newTaxpayer);
            }
            else
            {
                unmarriedTaxpayers.Add(newTaxpayer);
                unsavedUnmarriedTaxpayers.Add(newTaxpayer);
            }

            taxpayerBindingSource.Add(newTaxpayer);
        }
Exemple #4
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            // declarations
            string name;
            double salary;
            double investmentIncome;
            int    exemptions;
            bool   married;

            Taxpayer taxpayer;

            // inputs
            name             = nameTextBox.Text;
            salary           = double.Parse(salaryTextBox.Text);
            investmentIncome = double.Parse(investmentTextBox.Text);
            exemptions       = int.Parse(exemptionTextBox.Text);
            married          = marriedCheckBox.Checked;

            if (validExemptionCount(exemptions))
            {
                // create object
                taxpayer = new Taxpayer(name, salary, investmentIncome, exemptions, married);

                // add object to list
                ListSort(married, taxpayer);

                // outputs - COMMENTED OUT FOR FINAL VERSION
                //outputTextBox.AppendText(taxpayer.Info());

                // form maintenance
                DeactivateEnterDataControls();
                GetReadyForNewInput();
            }
            else
            {
                MessageBox.Show("Please enter a valid number of exemptions (0 - 3).");
                exemptionTextBox.Clear();
                exemptionTextBox.Focus();
            }
        }