Beispiel #1
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (agencyGridView1.Rows.Count > 0)
            {
                var toEdit = agencyGridView1.SelectedRows[0].DataBoundItem as Agency;
                var pf     = new EditAgency(toEdit, store);

                if (pf.ShowDialog() == DialogResult.OK)
                {
                    agencyBindingSource.ResetBindings(false);
                    HotAndFuture();
                    store.IsDirty = true;
                }
            }
            else
            {
                MessageBox.Show("Sorry, but there is no agencies to edit");
            }
        }
Beispiel #2
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var pf = new EditAgency(store);

            if (pf.ShowDialog() == DialogResult.OK)
            {
                if (pf.Agency != null)
                {
                    foreach (Portion p in pf.Agency.Portions)
                    {
                        p.AgencyName            = pf.Agency.Name;
                        pf.Agency.AmountOfTrips = pf.Agency.Portions.Count;
                    }
                    store.AddAgency(pf.Agency);

                    agencyBindingSource.ResetBindings(false);
                    HotAndFuture();
                    store.IsDirty = true;
                    var lastIdx = agencyGridView1.Rows.Count - 1;
                    agencyGridView1.Rows[lastIdx].Selected          = true;
                    agencyGridView1.FirstDisplayedScrollingRowIndex = lastIdx;
                }
            }
        }