Beispiel #1
0
        private void SignIn_Click(object sender, EventArgs e)
        {
            infoLabel.Text    = "";
            infoLabel.Visible = true;

            if (userName_textBox.Text.Length > 0 && password_textBox.Text.Length > 0)
            {
                string userName = userName_textBox.Text.ToString();
                string query    = "SELECT u_name, u_surname, u_role FROM users WHERE u_login = '******' AND u_password = '******';";

                try
                {
                    DataTable user = Db.GetTableFromDb(query);
                    infoLabel.Text = "Добро пожаловать, " + user.Rows[0][0] + " " + user.Rows[0][1];
                    role           = user.Rows[0][2].ToString();
                    CurrentAccount account = new CurrentAccount(userName);
                    account.Owner = this;

                    if (role == "admin")
                    {
                        DialogResult result = MessageBox.Show(infoLabel.Text + '\n' +
                                                              "У вас роль: 'админ'." + '\n' + "Желаете зайти в административную панель?",
                                                              "Админ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            AdminPanel adminPanel = new AdminPanel(userName);
                            adminPanel.Owner = this;
                            adminPanel.Show();
                        }
                        else
                        {
                            account.Show();
                        }
                    }
                    else if (role == "user")
                    {
                        MessageBox.Show(infoLabel.Text);
                        account.Show();
                    }
                    this.Hide();
                }
                catch (Exception)
                {
                    infoLabel.Text = "Проверьте введённые данные!";
                }
            }
            else
            {
                infoLabel.Text = "Заполните все поля!";
            }
        }
Beispiel #2
0
        private void carBooking_FormClosing(object sender, FormClosingEventArgs e)
        {
            CurrentAccount account = (CurrentAccount)this.Owner;

            account.UpdateAll();
            account.Show();
        }
Beispiel #3
0
        private void backToUser_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Authorization  auth    = (Authorization)this.Owner;
            CurrentAccount account = new CurrentAccount(userName);

            account.Owner = auth;
            account.Show();
            showAuth = false;
            Close();
        }