public void addSingleNote(addresss post) { SQLiteConnection connection = openConnection(); string query = "INSERT INTO address (id_notebook, address, city, state, country, postal) VALUES ('" + post.id_notebook + "','" + post.address + "','" + post.city + "','" + post.state + "','" + post.country + "','" + post.postal + "');"; SQLiteCommand Command = new SQLiteCommand(query, connection); Command.ExecuteNonQuery(); closeConnection(ref connection); }
private void formEdit_Load(object sender, EventArgs e) { this.Text = (id > 0) ? "Изменить" : "Добавить"; edit.Text = (id > 0) ? "Изменить" : "Добавить"; if (id > 0) { notebooks answer = note.getSingleNote(id); firstname.Text = answer.firstname; secondname.Text = answer.secondname; lastname.Text = answer.lastname; date.Value = answer.date; job.Text = answer.job; position.Text = answer.position; more.Text = answer.more; if (answer.sex == 0) { sex1.Checked = true; } else { sex2.Checked = true; } int size = note.getCountPhone(id); if (size > 0) { phones[] phoneAnswer = note.getSinglePhone(id); for (int i = 0; i < size; i++) { Control[] temp = phone.Controls.Find("phone" + (i + 1), true); temp[0].Text = phoneAnswer[i].phone; temp = phone.Controls.Find("note" + (i + 1), true); temp[0].Text = phoneAnswer[i].note; } } addresss addressAnswer = note.getSingleAddress(id); address.Text = addressAnswer.address; city.Text = addressAnswer.city; state.Text = addressAnswer.state; country.Text = addressAnswer.country; postal.Text = addressAnswer.postal; } }
public void setSingleNote(addresss post) { // Изменение записи в таблице address if (getCountAddress(post.id_notebook) > 0) { SQLiteConnection connection = openConnection(); string query = "UPDATE address SET address = '" + post.address + "', city = '" + post.city + "', state = '" + post.state + "', postal = '" + post.postal + "' WHERE id_notebook= '" + post.id_notebook + "';"; SQLiteCommand Command = new SQLiteCommand(query, connection); Command.ExecuteNonQuery(); closeConnection(ref connection); } else { addSingleNote(post); } }