private void dtProduct_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 46) { DialogResult dialogResult = MessageBox.Show("Silmek istediğinize emin misiniz ? ", "Dikkat", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { var a = dtProduct.SelectedRows[0].DataBoundItem as Product; Product t = new Product() { Id = a.Id }; t.Delete(); } LoadProduct(); } }
private void dtProduct_CellEndEdit(object sender, DataGridViewCellEventArgs e) { var a = dtProduct.Rows[e.RowIndex].DataBoundItem as Product; string value = dtProduct.Rows[e.RowIndex].Cells["ProductName"].Value.ToString(); double price = Convert.ToDouble(dtProduct.Rows[e.RowIndex].Cells["SalesPrice"].Value.ToString()); int Id = a.Id; //int Id = Convert.ToInt32(dtProduct.Rows[e.RowIndex].Cells[0].Value); DialogResult dialogResult = MessageBox.Show("Güncellemek istediğinize emin misiniz ? ", "Dikkat", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { Product t = new Product() { Id = Id, ProductName = value, SalesPrice = price }; t.Update(); MessageBox.Show("Ürün güncelleme işleminiz gerçekleştirilmiştir.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { LoadProduct(); } }