Beispiel #1
0
        public CustomerForm(Customer customer)
        {
            InitializeComponent();
            _customer          = customer;
            EditButton.Enabled = false;

            _performers = Performer.ReadPerformersList("performers");
            _performers.ForEach(performer =>
            {
                ListOfPerformers.Items.Add(performer.ToString());
            });

            if (_customer != null && _customer.ServiceOf != null && _customer.PerformerOfOrder != null)
            {
                ListOfPerformers.SelectedIndex = ListOfPerformers.Items.IndexOf(customer.PerformerOfOrder.ToString());
                ServiceOfText.Text             = customer.ServiceOf;
                CustomerAddressText.Text       = customer.CustomerAddress.ToString();
            }
        }
Beispiel #2
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            int selectedIndex = ListOfPerformers.SelectedIndex;

            if (selectedIndex < 0 || selectedIndex >= _performers.Count)
            {
                MessageBox.Show("Choose performer");
                return;
            }
            PerformerForm performerModal = new PerformerForm(_performers[selectedIndex]);

            if (performerModal.ShowDialog() == DialogResult.OK)
            {
                ListOfPerformers.Items[selectedIndex] = _performers[selectedIndex].ToString();
                Performer.WritePerformersToFile("performers", _performers);
            }
            else
            {
                MessageBox.Show("Changes was not saved");
            }
        }