private void buttonBack_Click(object sender, EventArgs e)
        {
            ManagerMainForm ManagerMForm = new ManagerMainForm();

            this.Hide();
            ManagerMForm.Show();
        }
Beispiel #2
0
        private void buttonEnter_Click(object sender, EventArgs e)
        {
            var Id = 0;

            Connection.Open();
            OleDbCommand Command = new OleDbCommand();

            Command.Connection  = Connection;
            Command.CommandText = "SELECT authorization_id FROM authorizations WHERE login = '******' and password = '******'";

            OleDbDataReader Reader = Command.ExecuteReader();
            int             count  = 0;

            while (Reader.Read())
            {
                count++;
            }

            Reader.Close();

            if (count == 1)
            {
                Id = Int32.Parse(Command.ExecuteScalar().ToString());

                bool         SearchSuccessfull;
                OleDbCommand CommandSearchInClients  = new OleDbCommand();
                OleDbCommand CommandSearchInTeachers = new OleDbCommand();
                OleDbCommand CommandSearchInManagers = new OleDbCommand();

                CommandSearchInClients.Connection   = Connection;
                CommandSearchInTeachers.Connection  = Connection;
                CommandSearchInManagers.Connection  = Connection;
                CommandSearchInClients.CommandText  = "SELECT * FROM clients WHERE authorization_id = " + Id + "";
                CommandSearchInTeachers.CommandText = "SELECT * FROM teachers WHERE authorization_id = " + Id + "";
                CommandSearchInManagers.CommandText = "SELECT * FROM managers WHERE authorization_id = " + Id + "";
                OleDbDataReader ReaderClients = CommandSearchInClients.ExecuteReader();
                SearchSuccessfull = false;
                while (ReaderClients.Read())
                {
                    SearchSuccessfull = true;
                }

                if (SearchSuccessfull == true)
                {
                    ClientMainForm ClientMForm = new ClientMainForm();
                    this.Hide();
                    ClientMForm.Show();
                }
                ReaderClients.Close();

                OleDbDataReader ReaderTeachers = CommandSearchInTeachers.ExecuteReader();
                SearchSuccessfull = false;
                while (ReaderTeachers.Read())
                {
                    SearchSuccessfull = true;
                }

                if (SearchSuccessfull == true)
                {
                    TeacherMainForm TeacherMForm = new TeacherMainForm();
                    this.Hide();
                    TeacherMForm.Show();
                }
                ReaderTeachers.Close();

                OleDbDataReader ReaderManagers = CommandSearchInManagers.ExecuteReader();
                SearchSuccessfull = false;
                while (ReaderManagers.Read())
                {
                    SearchSuccessfull = true;
                }

                if (SearchSuccessfull == true)
                {
                    ManagerMainForm ManagerMForm = new ManagerMainForm();
                    this.Hide();
                    ManagerMForm.Show();
                }

                ReaderManagers.Close();
            }

            if (count == 0)
            {
                MessageBox.Show("Неверный логин или пароль, попробуйте заново");
            }

            Connection.Close();
        }