protected void GuardarLinkButton_Click(object sender, EventArgs e) { if (IsValid) { factura = FacturaRepositorio.Buscar(Utils.ToInt(FacturaIdTextBox.Text)); if (factura == null) { if (FacturaRepositorio.Guardar(LlenaClase())) { Utils.MostrarMensaje(this, "Guardado", "Exito!!", "success"); Limpiar(); } else { Utils.MostrarMensaje(this, "No Guardado", "Advertencia", "warning"); Limpiar(); } } else { if (FacturaRepositorio.Modificar(LlenaClase())) { Utils.MostrarMensaje(this, "Modificado", "Exito!!", "info"); Limpiar(); } else { Utils.MostrarMensaje(this, "No Modificado", "Advertencia", "warning"); Limpiar(); } } } }
protected void GuardarButton2_Click(object sender, EventArgs e) { //Repositorio<Facturas> repositorio = new Repositorio<Facturas>(); FacturaRepositorio repositorio = new FacturaRepositorio(); Facturas factura = repositorio.Buscar(ToInt(FacturaIdTextBox.Text)); if (factura == null) { if (repositorio.Guardar(LlenaClase())) { CallModal("Factura Guardada"); Limpiar(); } else { CallModal("No se pudo guardar la Factura"); Limpiar(); } } else { if (repositorio.Modificar(LlenaClase())) { CallModal("Factura Modificada"); Limpiar(); } else { CallModal("No se modifico"); Limpiar(); } } }
protected void GuardarButton_Click(object sender, EventArgs e) { bool paso = false; FacturaRepositorio repositorio = new FacturaRepositorio(); Facturas factura = new Facturas(); if (HayErrores()) { return; } else { factura = LlenarClase(); if (Utils.ToInt(FacturaIdTextbox.Text) == 0) { paso = repositorio.Guardar(factura); Utils.ShowToastr(this, "Guardado", "Exito", "success"); LimpiaObjetos(); } else { FacturaRepositorio repository = new FacturaRepositorio(); int id = Utils.ToInt(FacturaIdTextbox.Text); factura = repository.Buscar(id); if (factura != null) { paso = repository.Modificar(LlenarClase()); Utils.ShowToastr(this, "Modificado", "Exito", "success"); } else { Utils.ShowToastr(this, "Id no existe", "Error", "error"); } } if (paso) { LimpiaObjetos(); } else { Utils.ShowToastr(this, "No se pudo guardar", "Error", "error"); } } }
private void GuardarButton_Click(object sender, EventArgs e) { FacturaRepositorio repositorio = new FacturaRepositorio(); bool paso = false; if (!Validar()) { return; } Factura factura = LlenaClase(); if (IdNumericUpDown.Value == 0) { paso = repositorio.Guardar(factura); } else { if (!ExisteEnLaBaseDeDatos()) { MessageBox.Show("No se encuentra en la base de datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } paso = repositorio.Modificar(factura); } if (paso) { Limpiar(); MessageBox.Show("Guardado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se puede guardar", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Error); } }