コード例 #1
0
        private void ADD_button_Click(object sender, EventArgs e)
        {
            Add_form addf = new Add_form(connect_sql);

            addf.ShowDialog();
            tab_refresh();
        }
コード例 #2
0
 private void Enter_button_Click(object sender, EventArgs e)
 {
     if (Guest_checkbox.Checked == true)
     {
         Add_form add = new Add_form(connect_sql);
         add.ShowDialog();
         Guest_checkbox.Checked = false;
     }
     else if (Guest_checkbox.Checked == false)
     {
         if (Login_textbox.Text.Length == 0 && Password_textbox.Text.Length != 0)
         {
             MessageBox.Show("Поле 'Логін' не заповнено!", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (Login_textbox.Text.Length != 0 && Password_textbox.Text.Length == 0)
         {
             MessageBox.Show("Поле 'Пароль' не заповнено!", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (Login_textbox.Text.Length == 0 && Password_textbox.Text.Length == 0)
         {
             MessageBox.Show("Поля 'Логін' і 'Пароль' не заповнено!", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (Password_textbox.Text.Length != 0 && Login_textbox.Text.Length != 0)
         {
             SqlCommand command_sql = connect_sql.CreateCommand();
             command_sql.CommandType = CommandType.Text;
             string access;
             command_sql.CommandText = "SELECT COUNT(*) FROM Таблиця_входу WHERE Логін = '" + Login_textbox.Text + "'and Пароль =  '" + Password_textbox.Text + "';";
             command_sql.ExecuteNonQuery();
             string res   = command_sql.ExecuteScalar().ToString();
             int    count = Convert.ToInt32(res);
             if (count == 1)
             {
                 command_sql.CommandText = "SELECT Рівень_доступу FROM Таблиця_входу WHERE Логін = '" + Login_textbox.Text + "'and Пароль =  '" + Password_textbox.Text + "';";
                 access = command_sql.ExecuteScalar().ToString();
                 main_menu menu = new main_menu(connect_sql);
                 MainForm  main = new MainForm(connect_sql);
                 Add_form  add  = new Add_form(connect_sql);
                 if (access == "Високий")
                 {
                     menu.enter_level(access);
                     main.enter_level(access);
                     menu.ShowDialog();
                 }
                 if (access == "Середній")
                 {
                     menu.enter_level(access);
                     main.enter_level(access);
                     menu.ShowDialog();
                 }
                 if (access == "Низький")
                 {
                     menu.enter_level(access);
                     main.enter_level(access);
                     add.ShowDialog();
                 }
                 Login_textbox.Clear();
                 Password_textbox.Clear();
             }
             else
             {
                 Password_textbox.Clear();
                 MessageBox.Show("Невірний логін чи пароль!", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }