コード例 #1
0
 public New_BPLan(BudgetPlan oldPlan)
 {
     InitializeComponent();
     budgetPlan = oldPlan;
     comboBox1.Items.AddRange(Data.getActiveBList().ToArray());
     Update_BudgeterList();
     textBox1.Text = oldPlan.name;
     CalculateMinimum();
     this.editing = true;
 }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (rBBudget.Checked)
            {
                //Deposit to Budget

                //Check if there is a selected index
                if (listView1.SelectedIndices.Count > 0)
                {
                    if (listView1.SelectedIndices[0] >= 0)
                    {
                        if (listView1.SelectedIndices[0] > 0)
                        {
                            Data.getSelectedBudget().balance += Convert.ToDecimal(string.Format("{0:0.00}", numericUpDown1.Value));
                            Data.getActiveBList().ElementAt(0).balance += Convert.ToDecimal(string.Format("{0:0.00}", numericUpDown1.Value));
                        }
                        else
                        {
                            Data.getSelectedBudget().balance += Convert.ToDecimal(string.Format("{0:0.00}", numericUpDown1.Value));
                        }

                        //Update the display
                        int select = listView1.SelectedIndices[0];
                        Update_Budgetview();
                        listView1.SelectedIndices.Add(select);
                    }
                }
                else
                {
                    MessageBox.Show("Please select an expense to deposit to");
                }
            }
            else if (rBPlan.Checked)
            {
                //Deposit through plan

                //Check if plan is selected
                if (comboBox1.SelectedIndex >= 0)
                {
                    //get reference to selected plan
                    BudgetPlan plan = Data.getActiveAccount().planList.ElementAt(comboBox1.SelectedIndex);


                    decimal toDefault = numericUpDown1.Value;
                    for (int x = 0; x < plan.list.Count; x++)
                    {
                        Budgeter budgeter = plan.list.ElementAt(x);
                        // Add money if it's dollars
                        if (budgeter.type == 0)
                        {
                            budgeter.budget.balance += budgeter.value;
                            toDefault -= budgeter.value;
                        }
                        //Add money if it's percent
                        if (budgeter.type == 1)
                        {
                            budgeter.budget.balance += numericUpDown1.Value * (budgeter.value / 100);
                            toDefault -= numericUpDown1.Value * (budgeter.value / 100);
                        }
                    }
                    //Data.getDefaultBudget().balance += toDefault;
                    Data.totalBudget();
                    //Update the display
                    int select = -1;
                    if (listView1.SelectedIndices.Count > 0)
                    {
                        select = listView1.SelectedIndices[0];
                    }
                    Update_Budgetview();
                    if (select > -1)
                    {
                        listView1.SelectedIndices.Add(select);
                    }
                }
                else
                {
                    MessageBox.Show("Please select a income plan to deposit to.");
                }
            }
            else if (rBCapital.Checked)
            {
                if (listView2.SelectedIndices.Count > 0)
                {
                    if (listView2.SelectedIndices[0] >= 0)
                    {
                        if (listView2.SelectedIndices[0] > 0)
                        {
                            Data.getSelectedCapital().balance += Convert.ToDecimal(string.Format("{0:0.00}", numericUpDown1.Value));
                            Data.getActiveCList().ElementAt(0).balance += Convert.ToDecimal(string.Format("{0:0.00}", numericUpDown1.Value));
                        }
                        else
                        {
                            Data.getSelectedCapital().balance += Convert.ToDecimal(string.Format("{0:0.00}", numericUpDown1.Value));
                        }
                        //Update the display
                        int select = listView2.SelectedIndices[0];
                        Update_Capitalview();
                        listView2.SelectedIndices.Add(select);
                    }
                }
                else
                {
                    MessageBox.Show("Please select a capital source to deposit to");
                }
            }

            Save.Saveall();
        }