Esempio n. 1
0
        private int DeleteCustomer()
        {
            try
            {
                string errMsg = String.Empty;

                if (cboCustomersCustomer.SelectedIndex < 0)
                {
                    errMsg = "No customer selected" + Environment.NewLine;
                }
                if (cboCustomersCustomer.SelectedIndex < 0)
                {
                    MessageBox.Show(errMsg);
                    return(-1);
                }

                var customer = new Customer()
                {
                    Id   = ((ComboClass)cboCustomersCustomer.SelectedItem).Id,
                    Name = ((ComboClass)cboCustomersCustomer.SelectedItem).Name
                };
                booking.DeleteCustomer(customer);
                FillCustomers();
                FillBookedVideos();

                return(cboCustomersCustomer.Items.Count - 1);
            }
            catch (VideoRentalException ex)
            {
                MessageBox.Show(ex.Message);
                return(Int32.MinValue);
            }
            catch
            {
                return(-1);
            }
        }