private void apptCreateButton_Click(object sender, EventArgs e)
        {
            this.Hide();
            AppointmentForm appointment = new AppointmentForm(activeUser)
            {
                Owner = this
            };

            appointment.ShowDialog();
            this.Show();
        }
Esempio n. 2
0
        private void selectButton_Click(object sender, EventArgs e)
        {
            switch (Type)
            {
            case RecordType.Customer:
                Customer customerModel = new Customer {
                    CustomerId = (int)selectionBox.SelectedValue
                };
                GlobalConfig.Connection.GetCustomer(customerModel);
                switch (Action)
                {
                case RecordAction.Modify:
                    CustomerForm customer = new CustomerForm(customerModel, activeUser)
                    {
                        Owner = this
                    };
                    customer.ShowDialog();
                    this.Close();
                    break;

                case RecordAction.Drop:
                    GlobalConfig.Connection.DropCustomer(customerModel);
                    if (MessageBox.Show($"{customerModel.CustomerName} Removed From The Database Successfully.\n Remove Another?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        selectionBox.DataSource = null;
                        // TODO -- LAMBDA EXPRESSION to remove the old record from the previous populated 'customers' list
                        customers.RemoveAll(x => x.CustomerName == customerModel.CustomerName);
                        RefreshList(customers, "CustomerName", "CustomerId");
                    }
                    else
                    {
                        this.Owner.Show();
                        this.Close();
                    }
                    break;

                case RecordAction.Report:
                    ReportForm custReport = new ReportForm(ReportType.Customer, customerModel.CustomerId);
                    custReport.ShowDialog();
                    this.Close();
                    break;

                default:
                    break;
                }
                break;

            case RecordType.Appointment:
                Appointment appointmentModel = new Appointment {
                    AppointmentId = (int)selectionBox.SelectedValue
                };
                GlobalConfig.Connection.GetAppointment(appointmentModel);
                switch (Action)
                {
                case RecordAction.Modify:
                    AppointmentForm appointment = new AppointmentForm(appointmentModel, activeUser)
                    {
                        Owner = this
                    };
                    appointment.ShowDialog();
                    this.Close();
                    break;

                case RecordAction.Drop:
                    GlobalConfig.Connection.DropAppointment(appointmentModel);
                    if (MessageBox.Show($"{appointmentModel.ApptSelectDisplay} Removed From The Database Successfully.\n Remove Another?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        selectionBox.DataSource = null;
                        // TODO -- LAMBDA EXPRESSION to remove the old record from the previous populated 'appointment' list
                        appointments.RemoveAll(x => x.AppointmentId == appointmentModel.AppointmentId);
                        RefreshList(appointments, "ApptSelectDisplay", "AppointmentId");
                    }
                    else
                    {
                        this.Owner.Show();
                        this.Close();
                    }
                    break;

                default:
                    break;
                }
                break;

            case RecordType.User:
                User userModel = new User {
                    UserId = (int)selectionBox.SelectedValue
                };
                GlobalConfig.Connection.GetUser(userModel);
                ReportForm userReport = new ReportForm(ReportType.User, userModel.UserId);
                userReport.ShowDialog();
                this.Close();
                break;

            case RecordType.Month:
                ReportForm monthReport = new ReportForm(ReportType.Month, (int)selectionBox.SelectedIndex + 1);
                monthReport.ShowDialog();
                this.Close();
                break;
            }
        }