示例#1
0
        private void addGoalButton_Click(object sender, EventArgs e)
        {
            if (budgetBindingSource.Count < 1)
            {
                MessageBox.Show("Create a budget first.");
                return;
            }

            var newGoal = databaseDataSet.Goal.NewGoalRow();

            newGoal.BudgetID = (int)((DataRowView)budgetBindingSource.Current).Row["BudgetID"];
            newGoal.Amount   = 0.0f;
            newGoal.Category = TransactionCategory.Uncategorized;
            databaseDataSet.Goal.Rows.Add(newGoal);
            goalTableAdapter.Update(databaseDataSet.Goal);
            var goalID   = newGoal.GoalID;
            var position = goalBindingSource.Find("GoalID", goalID);

            goalBindingSource.Position = position;

            var goalForm = new GoalForm(goalID);

            goalForm.ShowDialog();

            goalTableAdapter.Fill(databaseDataSet.Goal);
            position = goalBindingSource.Find("GoalID", goalID);
            goalBindingSource.Position = position;
            goalBindingSource.ResetCurrentItem();
        }
示例#2
0
        private void editGoalButton_Click(object sender, EventArgs e)
        {
            if (goalBindingSource.Count < 1)
            {
                addGoalButton_Click(sender, e);
                return;
            }
            var selectedIndex = goalGridView.SelectedRows[0].Index;
            var goalID        = (int)goalGridView.CurrentRow.Cells[0].Value;
            var goalForm      = new GoalForm(goalID);

            goalForm.ShowDialog();

            goalTableAdapter.Fill(databaseDataSet.Goal);
            var position = goalBindingSource.Find("GoalID", goalID);

            goalBindingSource.Position = position;
            goalBindingSource.ResetCurrentItem();
            goalGridView.ClearSelection();
            goalGridView.Rows[selectedIndex].Selected = true;
        }