예제 #1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            using (SQLiteConnection connection = new SQLiteConnection(@"Data Source=users.db"))
            {
                connection.Open();
                string        role     = "";
                string        login    = name.Text;
                string        password = this.password.Text;
                SQLiteCommand command  = connection.CreateCommand();
                command.Connection  = connection;
                command.CommandText =
                    "Select role from users where login = '******' AND password = '******'";
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    if (reader.HasRows) // если есть данные
                    {
                        while (reader.Read())
                        {
                            var dbRole = reader.GetValue(0);
                            role = dbRole.ToString();
                            break;
                        }
                    }
                }

                connection.Close();
                if (role == "admin")
                {
                    Admin formAdmin = new Admin();
                    formAdmin.Show();
                }
                else if (role == "research")
                {
                    Researcher formResearcher = new Researcher();
                    formResearcher.Show();
                }
                else
                {
                    MessageBox.Show("Ошибка! Логин или пароль введен неверно!", "Ошибка", MessageBoxButtons.OK);
                }
            }
        }
예제 #2
0
        private void researchMode_Click(object sender, EventArgs e)
        {
            Researcher researcher = new Researcher();

            researcher.Show();
        }