Example #1
0
        public void Button_Click_1(object sender, RoutedEventArgs e)
        {
            bool correct = CheckCaptcha();

            passwordPB.Password = checkBox.IsChecked == true ? passwordPB.Password = passwordTB.Text : passwordPB.Password;
            string    authorizeQuery = "SELECT * FROM user WHERE login='******'AND password='******'";
            DataTable dt_user        = dBContext.Authorize(authorizeQuery);

            if (dt_user.Rows.Count == 1 && correct == true)
            {
                switch (dt_user.Rows[0][4].ToString().ToLower())
                {
                case "заказчик":
                    UserForm userForm = new UserForm();
                    userForm.Show();
                    this.Hide();
                    break;

                case "менеджер":
                    ManagerForm managerForm = new ManagerForm();
                    managerForm.Show();
                    this.Hide();
                    break;

                case "мастер":
                    MasterForm masterForm = new MasterForm();
                    masterForm.Show();
                    this.Hide();
                    break;

                case "заместитель директора":
                    DeputyDirectorForm deputyDirectorForm = new DeputyDirectorForm();
                    deputyDirectorForm.Show();
                    this.Hide();
                    break;

                case "директор":
                    DirectorForm directorForm = new DirectorForm();
                    directorForm.Show();
                    this.Hide();
                    break;

                default:
                    MessageBox.Show($"Unknown role {dt_user.Rows[0][4].ToString().ToLower()}");
                    break;
                }
            }
            else if (correct == true && dt_user.Rows.Count != 1 && passwordPB.Password != "" && loginTB.Text != "")
            {
                MessageBox.Show("Пользователь не найден!");
            }
            else if (passwordPB.Password == "" || loginTB.Text == "")
            {
                MessageBox.Show("Все поля должны быть заполнены!");
            }
            else if (correct == false && passwordPB.Password != "" && loginTB.Text != "")
            {
                MessageBox.Show("Неверно введена капча!");
            }
        }
Example #2
0
        private void ShowForm(MasterForm newForm)
        {
            newForm.WindowState = this.ParentForm.WindowState;
            newForm.Size = this.ParentForm.Size;
            newForm.Show();

            this.ParentForm.Hide();
        }
Example #3
0
 private void btnBack_Click(object sender, EventArgs e)
 {
     WaitCursor.Set();
     try
     {
         MasterForm billMasterForm = new MasterForm(billType);
         billMasterForm.Show();
         this.Close();
     }
     catch (Exception ex)
     {
         WaitCursor.Restore();
         MessageBox.Show(ex.Message);
     }
 }
Example #4
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            //кнопка входа - авторизирует пользователя
            string[] userData;
            if (cn.CheckLogin(LoginTextBox.Text, PasswordTextBox.Text, out userData))
            {
                ExceptionLabel.Visible = false;
                LoginTextBox.Text      = "";
                PasswordTextBox.Text   = "";
                this.Hide();

                if (userData[3] == "r")//роль приемщика
                {
                    ReceiverForm receiverForm = new ReceiverForm(userData[0], userData[1], userData[2]);
                    receiverForm.Show();
                }
                else if (userData[3] == "m")//роль мастера
                {
                    MasterForm masterForm = new MasterForm(userData[0], userData[1], userData[2]);
                    masterForm.Show();
                }
                else if (userData[3] == "a")//роль админа
                {
                    ReceiverForm receiverForm = new ReceiverForm(userData[0], userData[1], userData[2]);
                    receiverForm.Show();

                    MasterForm masterForm = new MasterForm(userData[0], userData[1], userData[2]);
                    masterForm.Show();
                }
                else
                {
                }
            }
            else
            {
                ExceptionLabel.Visible = true;
            }
        }