private void Guardarbutton_Click(object sender, EventArgs e) { Factura factura; bool Paso = false; RepositorioFactura repositorio = new RepositorioFactura(); if (HayErrores()) { MessageBox.Show("Favor revisar todos los campos!!", "Validación!!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } factura = LlenaClase(); if (IdnumericUpDown.Value == 0) { int num = Convert.ToInt32(TipoPagocomboBox.SelectedIndex); if (num == 0) { Paso = repositorio.GuardarNormal(factura); MessageBox.Show("Guardado!!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (num == 1) { Paso = repositorio.Guardar(factura); MessageBox.Show("Guardado!!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { int id = Convert.ToInt32(IdnumericUpDown.Value); RepositorioBase <Factura> repositorioDos = new RepositorioBase <Factura>(); Factura fac = repositorioDos.Buscar(id); if (fac != null) { Paso = repositorio.Modificar(factura); MessageBox.Show("Modificado!!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Id no existe", "Falló", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (Paso) { Nuevobutton.PerformClick(); } else { MessageBox.Show("No se pudo guardar!!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected void ButtonGuardar_Click(object sender, EventArgs e) { if (Page.IsValid) { RepositorioFactura rb = new RepositorioFactura();; int id = 0; if (ComprobarID(id) == 0) { if (rb.Guardar(LlenaClase())) { ScriptManager.RegisterStartupScript(this, typeof(Page), "toastr_message", script: "toastr['success']('Facturas Guardada');", addScriptTags: true); ClearAll(); total = 0; } } else { if (rb.Modificar(LlenaClase())) { ScriptManager.RegisterStartupScript(this, typeof(Page), "toastr_message", script: "toastr['success']('Factura Modificada');", addScriptTags: true); } ClearAll(); } } }
public void ModificarTest() { RepositorioFactura repo = new RepositorioFactura(); Facturas factura = repo.Buscar(2); bool paso = repo.Modificar(factura); Assert.AreEqual(paso, true); }
public void Modificar() { RepositorioFactura repositorio = new RepositorioFactura(); int id = 15; var factura = repositorio.Buscar(id); factura.Detalle.Add(new FacturaDetalle(20, 15, 1, "Salami Induveca", 2, 150, 300)); bool paso = repositorio.Modificar(factura); Assert.AreEqual(true, paso); }
public void ModificarTest() { RepositorioFactura repositorio = new RepositorioFactura(); Facturas factura = new Facturas(); List <DetalleFactura> detalle = new List <DetalleFactura>(); factura.FacturaId = 4; factura.ClienteId = 2; factura.Fecha = DateTime.Now; factura.UsuarioId = 1; factura.Detalles = detalle; factura.Total = 0; Assert.IsTrue(repositorio.Modificar(factura)); }
protected void guardarButton_Click(object sender, EventArgs e) { bool paso = false; RepositorioFactura repositorio = new RepositorioFactura(); Factura factura = new Factura(); if (HayErrores()) { return; } else { factura = LlenarClase(); if (Utils.ToInt(facturaIdTextBox.Text) == 0) { paso = repositorio.Guardar(factura); Utils.ShowToastr(this, "Guardado", "Exito", "success"); LimpiaObjetos(); } else { RepositorioFactura repository = new RepositorioFactura(); int id = Utils.ToInt(facturaIdTextBox.Text); factura = repository.Buscar(id); if (factura != null) { paso = repository.Modificar(LlenarClase()); Utils.ShowToastr(this, "Modificado", "Exito", "success"); LimpiaObjetos(); } else { Utils.ShowToastr(this, "Id no existe", "Error", "error"); } } if (paso) { LimpiaObjetos(); } else { Utils.ShowToastr(this, "No se pudo guardar", "Error", "error"); } } }
public void ModificarTest() { bool paso; Facturas ventas = new Facturas(); RepositorioFactura repositorio = new RepositorioFactura(); ventas.IdFactura = 1; ventas.IdCliente = 1; ventas.Fecha = DateTime.Now; ventas.Monto = 400; ventas.Observacion = "Venta a credito"; ventas.Cantidad = 1; ventas.Lista.Add(new FacturasDetalle(1, 1, 1, 2, "Maria", 200, 400)); paso = repositorio.Modificar(ventas); Assert.AreEqual(paso, true); }
private void Guardarbutton_Click(object sender, EventArgs e) { if (!Validar()) { return; } bool paso; Facturas facturas; RepositorioFactura repositorio = new RepositorioFactura(); facturas = LlenaClase(); if (IDnumericUpDown.Value == 0) { paso = repositorio.Guardar(facturas); } else { if (!Existe()) { MessageBox.Show("No se puede modificar porque no existe en la base de datos.", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } paso = repositorio.Modificar(facturas); } if (paso) { MessageBox.Show("Guardado!!", "ButterSoft", MessageBoxButtons.OK, MessageBoxIcon.Information); var resultado = MessageBox.Show("Deseas imprimir esta factura?.", "ButterSoft", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (resultado == DialogResult.Yes) { ReporteFacturaConsumidor reporte = new ReporteFacturaConsumidor(Detalle); reporte.ShowDialog(); } Limpiar(); } else { MessageBox.Show("No fue posible guardar!!", "ButterSoft", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void GuardarButton_Click(object sender, EventArgs e) { bool paso = false; RepositorioFactura repof = new RepositorioFactura(); Facturas factura = new Facturas(); if (!Validar()) { return; } factura = LlenarClase(); int Id = Convert.ToInt32(ClienteComboBox.SelectedValue.ToString()); if (IDNumericUpDown.Value == 0) { paso = repof.Guardar(factura, Id); } else { if (!ExisteEnLaBaseDeDatos()) { MessageBox.Show("No se puede modificar", "Facturacion no registrada", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } paso = repof.Modificar(factura); } if (paso) { Limpiar(); MessageBox.Show("Guardado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No fue posible guardar", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected void GuardarButton_Click(object sender, EventArgs e) { RepositorioFactura repositorio = new RepositorioFactura(); Servicios servicios = repositorio.Buscar(Utils.ToInt(IDTextBox.Text)); if (Validar()) { return; } if (servicios == null) { if (repositorio.Guardar(LlenaClase())) { Utils.ShowToastr(this, "Guardado", "Exito", "success"); Limpiar(); } else { Utils.ShowToastr(this, "No existe", "Error", "error"); Limpiar(); } } else { if (repositorio.Modificar(LlenaClase())) { Utils.ShowToastr(this.Page, "Modificado con exito!!", "Guardado", "success"); Limpiar(); } else { Utils.ShowToastr(this.Page, "No se puede modificar", "Error", "error"); Limpiar(); } } }