Exemplo n.º 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")
                {
                    AdminForm formAdmin = new AdminForm();
                    formAdmin.Show();
                }
                else if (role == "research")
                {
                    ResearcherForm formResearcher = new ResearcherForm();
                    formResearcher.Show();
                }
                else
                {
                    MessageBox.Show("Ошибка! Логин или пароль введен неверно!", "Ошибка", MessageBoxButtons.OK);
                }
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            ResearcherForm researcherForm = new ResearcherForm();

            researcherForm.Show();
        }