private void buttonShowObr_Click(object sender, EventArgs e) { if (status == false) { login focusform = new login(); focusform.ShowDialog(); } else { getID(sebox.SelectedIndex); if (selectedItem != null) { showObr showForm = new showObr(); showForm.Show(); } } }
private void insertbutton_Click(object sender, EventArgs e) { if (status == false) { login focusform = new login(); focusform.ShowDialog(); } else { if (root == true) { addobr additform = new addobr(); additform.Show(); } else { MessageBox.Show("Вы не обладаете правами администратора", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void buttonDeleteObr_Click(object sender, EventArgs e) { if (status == false) { login focusform = new login(); focusform.ShowDialog(); } else { if (root == true) { deleteSelectedItem(); sebox.Items.Clear(); collectAll(); } else { MessageBox.Show("Вы не обладаете правами администратора", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void search_Click(object sender, EventArgs e) { if (status == false) { login focusform = new login(); focusform.ShowDialog(); } { List <string> specs = new List <string> { "year", "country", "firm", "model", "form", "material", "num" }; using var connectionDB = new SQLiteConnection(@"Data Source=C:\guitars.sqlite;Version=3;"); connectionDB.Open(); if (listBox1.SelectedIndex == -1) { var result = MessageBox.Show("Вы не выбрали категорию поиска.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { sebox.Items.Clear(); using var cmdr = new SQLiteCommand("SELECT * FROM guitars WHERE " + specs[listBox1.SelectedIndex] + " = '" + searchbox.Text + "'", connectionDB); using SQLiteDataReader reader = cmdr.ExecuteReader(); while (reader.Read()) { sebox.Items.Add($"ID[{reader["id"]}] Model: {reader["model"]}, Firm: {reader["firm"]}, Year: {reader["year"]}, Country: {reader["country"]}, Form: {reader["form"]}, Material: {reader["material"]}, Num: {reader["num"]}."); } } connectionDB.Close(); } }