protected void deleteRedirect_Click(object sender, EventArgs e) { int id = Int32.Parse((sender as LinkButton).CommandArgument); PaymentType pt = PaymentTypeRepository.db.PaymentTypes.Where(payType => payType.PaymentTypesId == id).FirstOrDefault(); HeaderTransaction ht = TransactionRepository.db.HeaderTransactions.Where(headTran => headTran.PaymentTypeId == id).FirstOrDefault(); int idIsUseOnTransaction; try { idIsUseOnTransaction = ht.PaymentTypeId; } catch { idIsUseOnTransaction = 0; } if (idIsUseOnTransaction == pt.PaymentTypesId) { validateDeleteIsReferencesID.Text = "Payment Type cannot be delete because it reference on other table"; } else { PaymentTypeController.deletePaymentType(id); refreshTable(); } }
private void deleteButton_Click(object sender, EventArgs e) { Button currButton = (Button)sender; int selectedRowIndex = 0; if (int.TryParse(currButton.ID.Substring(0, currButton.ID.Length - 2), out selectedRowIndex)) { int paymentId = int.Parse(((Label)PaymentTypeTable.Rows[selectedRowIndex].Cells[1].Controls[0]).Text); PaymentTypeController.deletePaymentType(paymentId); Response.Redirect("./ViewPaymentType.aspx"); } }
protected void deletePaymentType(object sender, EventArgs e) { if (currPaymentType == null) { return; } string error = PaymentTypeController.deletePaymentType(currPaymentType); if (error == "") { currPaymentType = null; Response.Redirect(Request.RawUrl); } else { ErrorMessage.Text = error; } }