void EliminarButton_Click(object sender, EventArgs e) { int idCuentaFacturacion = Convert.ToInt32(ViewState["Id"]); CuentaFacturacion cuentaFacturacion = DbsrContext.CuentaFacturacion.Single(cf => cf.IdCuentaFacturacion == idCuentaFacturacion); DbsrContext.CuentaFacturacion.Remove(cuentaFacturacion); DbsrContext.SaveChanges(); Response.Redirect("CuentaFacturacionList.aspx"); }
void GrabarButton_Click(object sender, EventArgs e) { CuentaFacturacion cuentaFacturacion; if (ViewState["Id"] == null) { cuentaFacturacion = new CuentaFacturacion { Nombre = NombreTextBox.Text }; DbsrContext.CuentaFacturacion.Add(cuentaFacturacion); } else { int idCuentaFacturacion = Convert.ToInt32(ViewState["Id"]); cuentaFacturacion = DbsrContext.CuentaFacturacion.Single(cf => cf.IdCuentaFacturacion == idCuentaFacturacion); cuentaFacturacion.Nombre = NombreTextBox.Text; } DbsrContext.SaveChanges(); Response.Redirect("CuentaFacturacionList.aspx"); }