public shablons[] getShablon() { shablons[] request_note = new shablons[getCountShablon()]; SQLiteConnection connection = openConnection(); string query = "SELECT * FROM shablon;"; SQLiteCommand Command = new SQLiteCommand(query, connection); SQLiteDataReader reader = Command.ExecuteReader(); int i = 0; while (reader.Read()) { request_note[i].id = Convert.ToInt32(reader["id"]); request_note[i].sex = Convert.ToInt32(reader["sex"]); request_note[i].text = reader["text"].ToString(); i++; } reader.Close(); closeConnection(ref connection); return(request_note); }
public void setShablon(shablons post) { // Изменение записи в таблице Шаблонов SQLiteConnection connection = openConnection(); string query = "UPDATE shablon SET text = '" + post.text + "', sex = '" + post.sex + "' WHERE id = " + post.id + ";"; SQLiteCommand Command = new SQLiteCommand(query, connection); Command.ExecuteNonQuery(); closeConnection(ref connection); }
public void addShablon(shablons post) { // Добавление записи в таблицу шаблонов SQLiteConnection connection = openConnection(); string query = "INSERT INTO shablon (sex, text) VALUES ('" + post.sex + "','" + post.text + "');"; SQLiteCommand Command = new SQLiteCommand(query, connection); Command.ExecuteNonQuery(); closeConnection(ref connection); }
private void shablonEdit_Load(object sender, EventArgs e) { this.Text = (id > 0) ? "Изменить" : "Добавить"; add.Text = (id > 0) ? "Изменить" : "Добавить"; if (id > 0) { shablons answer = note.getSingleShablon(id); text.Text = answer.text; if (answer.sex == 0) { radioButton1.Checked = true; } else if (answer.sex == 1) { radioButton2.Checked = true; } else { radioButton3.Checked = true; } } }