private void btnDelete_Click(object sender, EventArgs e) { if (dataGridViewTblUser.Rows.Count != 0) { FormError confirmDialog = new FormError(); confirmDialog.changeLabel.Text = "Delete this account?\n" + dataGridViewTblUser.CurrentRow.Cells[1].Value + " " + dataGridViewTblUser.CurrentRow.Cells[2].Value; confirmDialog.changeTitle = "Confirm Delete"; confirmDialog.changeButtonTwo.Text = "Cancel"; confirmDialog.ShowDialog(); if (FormError.getClickResult_FormError()) { int remove = (int)dataGridViewTblUser.CurrentRow.Cells[0].Value; tblUser user = dbe.tblUsers.First(p => p.UserID == remove); dbe.tblUsers.Remove(user); dbe.SaveChanges(); messageBox(2); dataGridViewTblUser.DataSource = dbe.tblUsers.ToList(); txtBoxSearch.Text = ""; } } }
private void btnDelete_Click(object sender, EventArgs e) { if (dataGridViewTblProducts.Rows.Count != 0) { FormError confirmDialog = new FormError(); confirmDialog.changeLabel.Text = "Delete this product?\n" + dataGridViewTblProducts.CurrentRow.Cells[0].Value + "." + dataGridViewTblProducts.CurrentRow.Cells[2].Value; confirmDialog.changeTitle = "Confirm Delete"; confirmDialog.changeButtonTwo.Text = "Cancel"; confirmDialog.ShowDialog(); if (FormError.getClickResult_FormError()) { int remove = (int)dataGridViewTblProducts.CurrentRow.Cells[0].Value; tblProduct product = dbe.tblProducts.First(p => p.ProductID == remove); dbe.tblProducts.Remove(product); dbe.SaveChanges(); dataGridViewTblProducts.DataSource = dbe.tblProducts.ToList(); FormError successMessage = new FormError(); successMessage.changeButtonTwo.Hide(); successMessage.changeTitle = "Deleted"; successMessage.changeLabel.Text = "Product Deleted"; successMessage.ShowDialog(); } } txtBoxSearch.Text = ""; }
private void btnDelete_Click(object sender, EventArgs e) { FormError confirmDialog = new FormError(); confirmDialog.changeLabel.Text = "Delete this Promotional Code?\n" + tblPromotionDataGridView.CurrentRow.Cells[0].Value + "." + tblPromotionDataGridView.CurrentRow.Cells[1].Value; confirmDialog.changeTitle = "Confirm Delete"; confirmDialog.changeButtonTwo.Text = "Cancel"; confirmDialog.ShowDialog(); if (FormError.getClickResult_FormError()) { int remove = (int)tblPromotionDataGridView.CurrentRow.Cells[0].Value; tblPromotion code = dbe.tblPromotions.First(p => p.ID == remove); dbe.tblPromotions.Remove(code); dbe.SaveChanges(); FormError sucessful = new FormError(); sucessful.changeTitle = "Confirmation."; sucessful.changeLabel.Text = "Deleted sucessfully!"; sucessful.changeButtonTwo.Hide(); sucessful.changeButtonTwo.Hide(); sucessful.ShowDialog(); //refresh data: display(); if (tblPromotionDataGridView.Rows.Count == 0) { cmbDiscount.Text = ""; } } txtBoxSearch.Text = ""; txtBoxDiscount.Text = ""; }