コード例 #1
0
 // Sets expenses[] to shell values
 private void InitializeExpenses()
 {
     for(int i = 0; i < EXPENSE_MAX; i++)
     {
         expenses[i] = new Expense("", 0);
     }
 }
コード例 #2
0
 // Takes user input from TextBoxes into expenses[]
 // // Really could use some error handling here
 public void PopulateExpenses()
 {
     //expenseCount = 0;
     // Read TextBoxes in to expenses[] as long as they've been changed
     // Will blow chunks if both boxes have been changed AND expCostBox.Text doesn't parse to double
     if(expNameBox1.Text != "Name" && expCostBox1.Text != "Cost/Payday")
     { expenses[0] = new Expense(expNameBox1.Text, double.Parse(expCostBox1.Text)); }
     if (expNameBox2.Text != "Name" && expCostBox2.Text != "Cost/Payday")
     { expenses[1] = new Expense(expNameBox2.Text, double.Parse(expCostBox2.Text)); }
     if (expNameBox3.Text != "Name" && expCostBox3.Text != "Cost/Payday")
     { expenses[2] = new Expense(expNameBox3.Text, double.Parse(expCostBox3.Text)); }
     if (expNameBox4.Text != "Name" && expCostBox4.Text != "Cost/Payday")
     { expenses[3] = new Expense(expNameBox4.Text, double.Parse(expCostBox4.Text)); }
     if (expNameBox5.Text != "Name" && expCostBox5.Text != "Cost/Payday")
     { expenses[4] = new Expense(expNameBox5.Text, double.Parse(expCostBox5.Text)); }
     if (expNameBox6.Text != "Name" && expCostBox6.Text != "Cost/Payday")
     { expenses[5] = new Expense(expNameBox6.Text, double.Parse(expCostBox6.Text)); }
     if (expNameBox7.Text != "Name" && expCostBox7.Text != "Cost/Payday")
     { expenses[6] = new Expense(expNameBox7.Text, double.Parse(expCostBox7.Text)); }
     if (expNameBox8.Text != "Name" && expCostBox8.Text != "Cost/Payday")
     { expenses[7] = new Expense(expNameBox8.Text, double.Parse(expCostBox8.Text)); }
     if (expNameBox9.Text != "Name" && expCostBox9.Text != "Cost/Payday")
     { expenses[8] = new Expense(expNameBox9.Text, double.Parse(expCostBox9.Text)); }
     if (expNameBox10.Text != "Name" && expCostBox10.Text != "Cost/Payday")
     { expenses[9] = new Expense(expNameBox10.Text, double.Parse(expCostBox10.Text)); }
     if (expNameBox11.Text != "Name" && expCostBox11.Text != "Cost/Payday")
     { expenses[10] = new Expense(expNameBox11.Text, double.Parse(expCostBox11.Text)); }
     if (expNameBox12.Text != "Name" && expCostBox12.Text != "Cost/Payday")
     { expenses[11] = new Expense(expNameBox12.Text, double.Parse(expCostBox12.Text)); }
     if (expNameBox13.Text != "Name" && expCostBox13.Text != "Cost/Payday")
     { expenses[12] = new Expense(expNameBox13.Text, double.Parse(expCostBox13.Text)); }
     if (expNameBox14.Text != "Name" && expCostBox14.Text != "Cost/Payday")
     { expenses[13] = new Expense(expNameBox14.Text, double.Parse(expCostBox14.Text)); }
     if (expNameBox15.Text != "Name" && expCostBox15.Text != "Cost/Payday")
     { expenses[14] = new Expense(expNameBox15.Text, double.Parse(expCostBox15.Text)); }
 }
コード例 #3
0
        // Sets TextBox.Text back to default
        // Clears expenses[] by setting all names to "" and costs to 0
        // Calls UpdateForm1Info
        private void clearButton_Click(object sender, EventArgs e)
        {
            payCheckBox.Text = "0.00";

            expNameBox1.Text = "Name";
            expNameBox2.Text = "Name";
            expNameBox3.Text = "Name";
            expNameBox4.Text = "Name";
            expNameBox5.Text = "Name";

            expNameBox6.Text = "Name";
            expNameBox7.Text = "Name";
            expNameBox8.Text = "Name";
            expNameBox9.Text = "Name";
            expNameBox10.Text = "Name";

            expNameBox11.Text = "Name";
            expNameBox12.Text = "Name";
            expNameBox13.Text = "Name";
            expNameBox14.Text = "Name";
            expNameBox15.Text = "Name";

            expCostBox1.Text = "Cost/Payday";
            expCostBox2.Text = "Cost/Payday";
            expCostBox3.Text = "Cost/Payday";
            expCostBox4.Text = "Cost/Payday";
            expCostBox5.Text = "Cost/Payday";

            expCostBox6.Text = "Cost/Payday";
            expCostBox7.Text = "Cost/Payday";
            expCostBox8.Text = "Cost/Payday";
            expCostBox9.Text = "Cost/Payday";
            expCostBox10.Text = "Cost/Payday";

            expCostBox11.Text = "Cost/Payday";
            expCostBox12.Text = "Cost/Payday";
            expCostBox13.Text = "Cost/Payday";
            expCostBox14.Text = "Cost/Payday";
            expCostBox15.Text = "Cost/Payday";

            for(int i = 0; i < EXPENSE_MAX; i++)
            {
                expenses[i] = new Expense("", 0);
            }

            UpdateForm1Info();
        }
コード例 #4
0
 public void SetExpense(Expense exp, int id)
 {
     expenses[id] = exp;
 }