private void вернутьсяНаГлавнуюToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ManagerMainForm managerMain = new ManagerMainForm();

            managerMain.Show();
            this.Hide();
        }
示例#2
0
        private void SinginButton_Click(object sender, EventArgs e)
        {
            SqlConnection sqlConnection;

            sqlConnection = new SqlConnection(connectionPath);
            sqlConnection.Open();
            SqlDataReader sdr        = null;
            SqlCommand    cmdSelect  = new SqlCommand("SELECT * FROM Users", sqlConnection);
            bool          checklogin = false;

            try
            {
                sdr = cmdSelect.ExecuteReader();

                while (sdr.Read())
                {
                    Console.WriteLine(sdr["ID"]);
                    Console.WriteLine(sdr["Login"]);
                    Console.WriteLine(sdr["Password"]);
                    Console.WriteLine(sdr["Role"]);



                    if (LoginTB.Text == Convert.ToString(sdr["Login"]))
                    {
                        checklogin = true;

                        if (PasswordTB.Text == Convert.ToString(sdr["Password"]))
                        {
                            BaseForm.idCurrentUser = Convert.ToInt32(Convert.ToString(sdr["ID"]));

                            switch (Convert.ToString(sdr["Role"]))
                            {
                            case "admin":
                                AdminAllUsersForm admForm = new AdminAllUsersForm();
                                admForm.Show();
                                this.Hide();
                                break;

                            case "engineer":
                                EngineerMainForm engineer = new EngineerMainForm();
                                engineer.Show();
                                this.Hide();
                                break;

                            case "salesman":
                                SalesmanMainForm salesman = new SalesmanMainForm();
                                salesman.Show();
                                this.Hide();
                                break;

                            case "manager":
                                ManagerMainForm managerForm = new ManagerMainForm();
                                managerForm.Show();
                                this.Hide();
                                break;
                            }
                        }
                        else
                        {
                            PasswordTB.Text = "";
                            MessageBox.Show("Введеный пароль некорректный. Попробуйте еще раз.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        }
                    }
                }

                if (checklogin == false)
                {
                    MessageBox.Show("Введеный логин некорректный. Попробуйте еще раз.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }