Exemplo n.º 1
0
        private void btn_back_Click(object sender, EventArgs e)
        {
            this.Hide();
            Form_Admin form_table = new Form_Admin();

            form_table.ShowDialog();
        }
Exemplo n.º 2
0
        //Выполним вход и получим данные пользователя
        private void btn_Login_Click(object sender, EventArgs e)
        {
            try
            {
                id_person = 0;

                connection.Open();
                OleDbCommand command = new OleDbCommand();
                command.Connection  = connection;
                command.CommandText = "select * from person where Fam='" + comboBox_fam.SelectedItem.ToString() + "' and Name='" + comboBox_name.SelectedItem.ToString() + "';";
                OleDbDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    id_person       = Convert.ToInt32(reader[0]);
                    fam_person      = reader[1].ToString();
                    name_person     = reader[2].ToString();
                    mid_name_person = reader[3].ToString();
                }

                connection.Close();


                if (comboBox_fam.SelectedItem.ToString() == "Admin" && comboBox_name.SelectedItem.ToString() == "Admin")
                {
                    this.Hide();
                    Form_Admin form_admin = new Form_Admin();
                    form_admin.ShowDialog();
                }
                else if (id_person == 0)
                {
                    MessageBox.Show("Вас нету в БД. Обратитесь к администратору", "Упс!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    this.Hide();
                    Form_selection_table form_table = new Form_selection_table(this);
                    form_table.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                connection.Close();
                //  connection.Dispose();
            }
        }