Ejemplo n.º 1
0
        /// <summary>
        /// Reset the values of the selected database table.
        /// </summary>
        private void ResetButton_Click(object sender, System.EventArgs e)
        {
            if (tableComboBox.SelectedIndex != 0)
            {
                // Do not allow the form to be closed.
                allowClose = false;

                string confirmMessage = "";

                // Set a confirmation message according to the selected table.
                switch (tableComboBox.Text)
                {
                case "Employee Schedule":
                    confirmMessage = "This will reset the values of all employee schedules to \"OFF\".\nProceed?";
                    break;

                case "Customer Attendance":
                    confirmMessage = "This will reset the values of all customer attendances to \"N/A\".\nProceed?";
                    break;
                }

                try {
                    if (GetConfirmation(confirmMessage))
                    {
                        switch (tableComboBox.Text)
                        {
                        case "Employee Schedule":
                            DatabaseWorker.ResetEmployeeSchedule();
                            break;

                        case "Customer Attendance":
                            DatabaseWorker.ResetCustomerAttendance();
                            break;
                        }

                        // Refresh the reset table.
                        ReloadTable();
                        MessageBoxAdv.Show(this, "Table was successfully reset.", "Success.");
                    }
                }
                catch (Exception) {
                    MessageBoxAdv.Show(this, "Table reset failed.", "Failed.");
                }
            }
            else
            {
                MessageBoxAdv.Show(this, "Please select a table.", "Error.");

                allowClose = false;
            }
        }