Example #1
0
        private void editBudgetButton_Click(object sender, EventArgs e)
        {
            if (budgetBindingSource.Count < 1)
            {
                addBudgetButton_Click(sender, e);
                return;
            }
            var budgetID   = (int)((DataRowView)budgetBindingSource.Current).Row["BudgetID"];
            var budgetForm = new BudgetForm(budgetID);

            budgetForm.ShowDialog();

            budgetTableAdapter.Fill(databaseDataSet.Budget);
            var position = budgetBindingSource.Find("BudgetID", budgetID);

            budgetBindingSource.Position = position;
            budgetBindingSource.ResetCurrentItem();
        }
Example #2
0
        private void addBudgetButton_Click(object sender, EventArgs e)
        {
            var newBudget = databaseDataSet.Budget.NewBudgetRow();

            newBudget.Name      = "New Budget";
            newBudget.StartDate = DateTime.Now;
            newBudget.EndDate   = newBudget.StartDate.AddMonths(1);
            databaseDataSet.Budget.Rows.Add(newBudget);
            budgetTableAdapter.Update(databaseDataSet.Budget);
            var budgetID = newBudget.BudgetID;
            var position = budgetBindingSource.Find("BudgetID", budgetID);

            budgetBindingSource.Position = position;

            var budgetForm = new BudgetForm(budgetID);

            budgetForm.ShowDialog();

            budgetTableAdapter.Fill(databaseDataSet.Budget);
            budgetBindingSource.Position = position;
            budgetBindingSource.ResetCurrentItem();
        }