Esempio n. 1
0
        private void editTrip_Click(object sender, EventArgs e)
        {
            if (tripGridView.Rows.Count > 0)
            {
                var toEdit = tripGridView.SelectedRows[0].DataBoundItem as Portion;
                var pf     = new EditPortion(toEdit);

                if (pf.ShowDialog() == DialogResult.OK)
                {
                    portionBindingSource.ResetBindings(false);
                }
            }
            else
            {
                MessageBox.Show("Sorry,there is nothing to edit.By the way, add some potions or delete the agency..");
            }
        }
Esempio n. 2
0
        private void addTrip_Click(object sender, EventArgs e)
        {
            var pf = new EditPortion();

            if (pf.ShowDialog() == DialogResult.OK)
            {
                Agency.Portions.Add(pf.Portion);

                portionBindingSource.ResetBindings(false);

                // select and scroll to the last row
                if (tripGridView.Rows.Count > 1)
                {
                    var lastIdx = tripGridView.Rows.Count - 1;
                    tripGridView.Rows[lastIdx].Selected          = true;
                    tripGridView.FirstDisplayedScrollingRowIndex = lastIdx;
                }
            }
        }