private void BtnSignIn_Click(object sender, EventArgs e)
        {
            if (!Pgs.CheckConnection())
            {
                MessageBox.Show("Невозможно соединиться с сервером. Проверка авторизации невозможна.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (tbLogin.Text == string.Empty || tbPassword.Text == string.Empty)
            {
                MessageBox.Show("Пожалуйста, заполните все поля!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            String account_role = Pgs.GetUserRole(tbLogin.Text, tbPassword.Text);

            if (account_role == "")
            {
                MessageBox.Show("Неверный логин или пароль! Пожалуйста, проверьте введенные данные.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            User.Name = tbLogin.Text;
            if (account_role.ToLower() == "admin")
            {
                User.Role = UserRole.Admin;
            }
            else if (account_role.ToLower() == "lecturer")
            {
                User.Role = UserRole.Lecturer;
            }
            else
            {
                MessageBox.Show("Неизвестная роль пользователя! Обратитесь к системному администратору!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            String ip   = DataManager.st.GetValue("server");
            String port = DataManager.st.GetValue("port");

            if (!Pgs.SetDatabaseConnectionWithRole(ip, port, account_role))
            {
                MessageBox.Show("Неизвестная ошибка подключения к серверу. Обратитесь к администратору.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            User.Autonom = false;
            this.Hide();
            MainForm mf = new MainForm(this);

            mf.Show();
        }
示例#2
0
        internal bool SignIn(string Login, string Pass)
        {
            if (!Pgs.CheckConnection())
            {
                MessageBox.Show("Невозможно соединиться с сервером. Проверка авторизации невозможна.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (Login == string.Empty || Pass == string.Empty)
            {
                MessageBox.Show("Пожалуйста, заполните все поля!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            String account_role = Pgs.GetUserRole(Login, Pass);

            if (account_role == "")
            {
                MessageBox.Show("Неверный логин или пароль! Пожалуйста, проверьте введенные данные.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            User.Name = Login;
            if (account_role.ToLower() == "admin")
            {
                User.Role = UserRole.Admin;
            }
            else if (account_role.ToLower() == "lecturer")
            {
                User.Role = UserRole.Lecturer;
            }
            else
            {
                MessageBox.Show("Неизвестная роль пользователя! Обратитесь к системному администратору!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            String ip   = DataManager.st.GetValue("server");
            String port = DataManager.st.GetValue("port");

            if (!Pgs.SetDatabaseConnectionWithRole(ip, port, account_role))
            {
                MessageBox.Show("Неизвестная ошибка подключения к серверу. Обратитесь к администратору.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            User.Autonom = false;

            return(true);
        }
示例#3
0
 internal bool GuestSignIn(string Ip, string Port)
 {
     Pgs.SetDatabaseConnectionWithRole(Ip, Port, "guest");
     User.Autonom = false;
     if (!Pgs.CheckConnection())
     {
         var result = MessageBox.Show("Внимание! Отсутствует соединение с базой данных. Вы все еще можете пользоваться некоторыми функциями программы, однако для ее эффективного использования необходимо восстановить соединение. Продолжить работу в автономном режиме?", "Ошибка подключения", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (result == DialogResult.No)
         {
             return(false);
         }
         else
         {
             User.Autonom = true;
         }
     }
     User.Role = UserRole.Guest;
     return(true);
 }