Пример #1
0
        // Login to the Dashboard Form.
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            string         administrationName = this.textBoxAdministration.Text.Trim();
            string         adminLogin         = this.TextBox_Administrator.Text.Trim();
            string         adminPassword      = this.TextBox_Password.Text.Trim();
            Administration administration     = new Administration();
            Administrator  administrator      = new Administrator();

            if (administration.IsDataValid(administrationName, out string message))
            {
                if (administrator.IsDataValid(adminLogin, adminPassword, out message))
                {
                    if (administration.DoesAdministrationExists(administrationName, out message))
                    {
                        if (administrator.IsLoginAdminCorrect(adminLogin, adminPassword, out int administrationId, out message))
                        {
                            Globals.SetGlobalAdministrationId(administrationId);

                            using (Form_Dashboard dashBoard = new Form_Dashboard())
                            {
                                dashBoard.ShowDialog();
                            }

                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show(message,
                                            "Login",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show(message,
                                        "Login",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show(message,
                                    "Login",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
            }
Пример #2
0
        // Delete Administration
        private void Button_DeleteAdministration_Click(object sender, EventArgs e)
        {
            string         administrationName = this.textBox_AdministrationName.Text.Trim();
            string         chiefAdminLogin    = this.textBox_ChiefAdministrator.Text.Trim();
            string         chiefAdminPassword = this.textBox_Password.Text.Trim();
            Administration administration     = new Administration();

            if (administration.IsDataValid(administrationName, chiefAdminLogin, chiefAdminPassword, out string errorMessage))
            {
                if (administration.DoesAdministrationExists(administrationName, out errorMessage))
                {
                    if (administration.DeleteAdministration(administrationName, chiefAdminLogin, chiefAdminPassword, out errorMessage))
                    {
                        MessageBox.Show(errorMessage,
                                        "Delete Administration",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                        ClearTextBoxesData();
                    }
                    else
                    {
                        MessageBox.Show(errorMessage + " Please inform your database administrator.",
                                        "Delete Administration",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show(errorMessage,
                                    "Delete Administration",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("The next Fields are incorrect: " + errorMessage,
                                "Delete Administration",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }
        }
Пример #3
0
        // Add new Administration
        private void Button_AddAdministration_Click(object sender, EventArgs e)
        {
            string         administrationName = this.textBox_AdministrationName.Text.Trim();
            string         chiefAdminLogin    = this.textBox_ChiefAdministrator.Text.Trim();
            string         adminFirstName     = this.textBox_AdministratorFirtName.Text.Trim();
            string         adminLastName      = this.textBox_AdministratorLastName.Text.Trim();
            string         password           = this.textBox_Password.Text.Trim();
            string         confirmPassword    = this.textBox_ConfirmPassword.Text.Trim();
            Administration administration     = new Administration();

            if (administration.IsDataValid(administrationName, chiefAdminLogin, adminFirstName, adminLastName, password, confirmPassword, out string errorMessage))
            {
                if (password == confirmPassword)
                {
                    if (!administration.DoesAdministrationExists(administrationName, out errorMessage))
                    {
                        if (administration.AddAdministration(administrationName, chiefAdminLogin, password, out errorMessage))
                        {
                            if (administration.AddChiefAdministrator(administrationName, chiefAdminLogin, adminFirstName, adminLastName, password, out errorMessage))
                            {
                                MessageBox.Show(errorMessage,
                                                "Add Administration",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Information);
                                ClearTextBoxesData();
                            }
                            else
                            {
                                // Delete the unsuccessfulli registered administration.
                                if (!administration.DeleteAdministration(administrationName, chiefAdminLogin, password, out string deleteError))
                                {
                                    errorMessage += Environment.NewLine
                                                    + deleteError
                                                    + Environment.NewLine
                                                    + "Please ask your database admin to delete the administration manualy!";
                                }

                                MessageBox.Show(errorMessage,
                                                "Add Administration",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show(errorMessage,
                                            "Add Administration",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show(errorMessage,
                                        "Add Administration",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Password and Confirm Password must be the same!",
                                    "Add Administration",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("The next Fields are incorrect: " + errorMessage,
                                "Add Administration",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }
        }