示例#1
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            Taxpayer taxpayer;
            string   name;
            bool     married;
            decimal  salaryDec, investmentDec;
            int      exempCountInt;

            name          = nameTextBox.Text;
            married       = marriedCheckBox.Checked;
            salaryDec     = decimal.Parse(salaryTextBox.Text);
            investmentDec = decimal.Parse(investmentTextBox.Text);
            exempCountInt = int.Parse(exempTextBox.Text);
            taxpayer      = new Taxpayer(name, married, salaryDec, investmentDec, exempCountInt);

            if (married)
            {
                MarriedList.Add(taxpayer);
            }
            else
            {
                UnMarriedList.Add(taxpayer);
            }
            displayButton.Focus();
            inputBox.Visible = false;
        }
示例#2
0
 private void summaryButton_Click(object sender, EventArgs e)
 {
     if (isEmpty())
     {
         emptyOutput();
     }
     else
     {
         outputTextBox.AppendText(Taxpayer.GetSummary() + Environment.NewLine);
     }
 }
示例#3
0
 private void resetButton_Click(object sender, EventArgs e)
 {
     if (isEmpty())
     {
         emptyOutput();
     }
     else
     {
         SaveData();
         Taxpayer.ResetData();
         ResetLists();
         outputTextBox.Clear();
         enterButton.Focus();
     }
 }
示例#4
0
        private void ReadData()
        {
            OpenFileDialog dialog = new OpenFileDialog
            {
                Filter = "All text files|*.txt"
            };

            dialog.ShowDialog();
            string fileName = dialog.FileName;

            dialog.Dispose();
            using (StreamReader reader = new StreamReader(fileName)) {
                while (!reader.EndOfStream)
                {
                    string[] lineItem;
                    Taxpayer taxpayer;
                    string   name;
                    bool     married;
                    decimal  salaryDec;
                    decimal  investmentDec;
                    int      exempCountInt;

                    lineItem      = reader.ReadLine().Split(new char[] { ',' });
                    name          = lineItem[0];
                    married       = bool.Parse(lineItem[4]);
                    salaryDec     = decimal.Parse(lineItem[1]);
                    investmentDec = decimal.Parse(lineItem[2]);
                    exempCountInt = int.Parse(lineItem[3]);
                    taxpayer      = new Taxpayer(name, married, salaryDec, investmentDec, exempCountInt);

                    if (married)
                    {
                        MarriedList.Add(taxpayer);
                    }
                    else
                    {
                        UnMarriedList.Add(taxpayer);
                    }
                }
            }
        }