Example #1
0
        private void NewButton_Click(object sender, EventArgs e)
        {
            Bureau     bureau     = new Bureau();
            BureauForm bureauForm = new BureauForm(bureau);

            if (bureauForm.ShowDialog() == DialogResult.OK)
            {
                ListOfBureaus.Items.Add(bureau.ToShortString());
                _bureaus.Add(bureau);
            }
            else
            {
                MessageBox.Show("Changes was not saved");
            }
        }
Example #2
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            int selectedIndex = ListOfBureaus.SelectedIndex;

            if (selectedIndex < 0 || selectedIndex >= _bureaus.Count)
            {
                MessageBox.Show("Choose bureau");
                return;
            }
            BureauForm bureauForm = new BureauForm(_bureaus[ListOfBureaus.SelectedIndex]);

            if (bureauForm.ShowDialog() == DialogResult.OK)
            {
                ListOfBureaus.Items[selectedIndex] = _bureaus[ListOfBureaus.SelectedIndex].ToShortString();
            }
            else
            {
                MessageBox.Show("Changes was not saved");
            }
        }