private void buttonDeleteByIdEncash_Click(object sender, EventArgs e) { if (encash.Count != 0) { var index = dataGridViewEncash.CurrentRow.Index; int Id = encash[index].Id; DialogResult result = MessageBox.Show("Удалить?", "Удаление", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { bool delete = EncashModel.Delete(Id); if (delete) { ShowEncash(); } else { MessageBox.Show("Ошибка"); } } } else { MessageBox.Show("Таблица пустая"); } }
private void buttonAddEncash_Click(object sender, EventArgs e) { EncashModel encashModel = new EncashModel(); encashModel.Price = Convert.ToInt32(textBoxPriceEncash.Text); encashModel.Date = dateTimePicker1.Value.ToString("dd-MM-yyyy"); int lastId = EncashModel.Insert(encashModel); if (lastId > 0) { ShowEncash(); textBoxPriceEncash.Text = ""; } else { MessageBox.Show("Ошибка"); } }
private void ShowEncash() { encash = EncashModel.SelectAll(); dataGridViewEncash.DataSource = encash; }
public static int Insert(EncashModel encash) { return(DBManager.InsertEncash(encash)); }