Beispiel #1
0
        // Add new Administrator.
        private void Button_AddAdministrator_Click(object sender, EventArgs e)
        {
            string         chiefAdmin      = this.textBox_ChiefAdministrator.Text.Trim();
            string         adminPassword   = this.textBox_ChiefAdminPassword.Text.Trim();
            string         newAdmin        = this.textBox_NewAdministrator.Text.Trim();
            string         firstName       = this.textBox_AdministratorFirstName.Text.Trim();
            string         lastName        = this.textBox_AdministratorLastName.Text.Trim();
            string         password        = this.textBox_Password.Text.Trim();
            string         confirmPassword = this.textBox_ConfirmPassword.Text.Trim();
            Administrator  administrator   = new Administrator();
            Administration administration  = new Administration();

            if (administrator.IsDataValid(chiefAdmin, adminPassword, newAdmin, firstName, lastName, password, confirmPassword, out string message))
            {
                if (administration.IsChiefAdminCorrect(chiefAdmin, adminPassword, out int administrationId, out message))
                {
                    if (!administrator.DoesAdministratorExists(administrationId, newAdmin, out message))
                    {
                        if (password == confirmPassword)
                        {
                            if (administrator.AddNewAdministrator(administrationId, newAdmin, firstName, lastName, password, out message))
                            {
                                MessageBox.Show(message,
                                                "Add Administrator",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Information);
                                ClearNewAdminData();
                            }
                            else
                            {
                                MessageBox.Show(message,
                                                "Add Administrator",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Password and Confirm Password must be the same!",
                                            "Add Administrator",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show(message,
                                        "Add Administrator",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show(message,
                                    "Add Administrator",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
            }
Beispiel #2
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);
                }
            }
Beispiel #3
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);
            }
        }
Beispiel #4
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);
            }
        }