public bool InsertaPartida(Comprap o) { try { using (var db = new DymContext()) { db.Add(o); db.SaveChanges(); return(true); } } catch (Exception ex) { Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString()); } return(false); }
public bool Update(Comprap o) { try { using (var db = new DymContext()) { db.Entry(o).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); return(true); } } catch (Exception ex) { Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString()); } return(false); }
private void ResetPDC() { //objetos compra = new Compra(); comprap = new Comprap(); producto = new Producto(); proveedor = new Proveedor(); cambioPrecio = new CambiosPrecio(); empresa = new EmpresaController().SelectTopOne(); //listas partidas = new List <Comprap>(); impuestos = new List <Impuesto>(); lotes = new List <Lote>(); productosActualizados = new List <Producto>(); //Controladores compraController = new CompraController(); comprapController = new ComprapController(); loteController = new LoteController(); movInvController = new MovInvController(); flujoController = new FlujoController(); productoController = new ProductoController(); laboratorioController = new LaboratorioController(); cambioPrecioController = new CambioPrecioController(); //Variables SigPartida = 0; subtotal = 0; impuesto = 0; sobreGrid = false; //Reset malla Malla.Rows.Clear(); GridImpuestos.Rows.Clear(); for (int i = 0; i < NPARTIDAS; i++) { Malla.Rows.Add(); Malla.Rows[i].Cells[4].Style.BackColor = Color.Yellow; Malla.Rows[i].Cells[6].Style.BackColor = Color.Yellow; Malla.Rows[i].Cells[8].Style.BackColor = Color.Yellow; Malla.Rows[i].Cells[9].Style.BackColor = Color.Yellow; Malla.Rows[i].Cells[14].Style.BackColor = Color.Yellow; Malla.Rows[i].Cells[15].Style.BackColor = Color.Yellow; } TxtProvedorId.Text = ""; TxtFacturaProveedor.Text = ""; DpFechaDoc.Value = DateTime.Now; DpFechaVencimiento.Value = DateTime.Now; TxtDatosProveedor.Text = ""; TxtProductoId.Text = ""; NCantidad.Value = 1; TxtPrecioCompra.Text = ""; TxtPrecioCaja.Text = ""; NDesc.Value = 0; TxtDescripcion.Text = ""; TxtU1.Text = ""; TxtU2.Text = ""; TxtU3.Text = ""; TxtU4.Text = ""; TxtPrecio1.Text = ""; TxtPrecio2.Text = ""; TxtPrecio3.Text = ""; TxtPrecio4.Text = ""; TxtPrecioS1.Text = ""; TxtPrecioS2.Text = ""; TxtPrecioS3.Text = ""; TxtPrecioS4.Text = ""; PbxImagen.Image = null; TxtSubtotal.Text = ""; TxtImpuestos.Text = ""; TxtTotal.Text = ""; CreaCompra(); }
private void InsertaPartida() { if (producto == null && TxtProductoId.Text.Trim().Length == 0) { Ambiente.Mensaje("Producto no encontrado"); } producto = productoController.SelectOne(TxtProductoId.Text.Trim()); if (producto == null) { return; } if (compra.CompraId == 0) { Ambiente.Mensaje("La compra no existe"); return; } //partida a la lista var partida = new Comprap(); partida.CompraId = compra.CompraId; partida.ProductoId = producto.ProductoId; partida.Descripcion = producto.Descripcion; partida.LaboratorioId = producto.LaboratorioId; partida.LaboratorioName = laboratorioController.SelectOne(producto.LaboratorioId).Nombre.Trim(); partida.Stock = producto.Stock; partida.Cantidad = NCantidad.Value; partida.PrecioCompra = Ambiente.ToDecimal(TxtPrecioCompra.Text); partida.PrecioCaja = Ambiente.ToDecimal(TxtPrecioCaja.Text); partida.Descuento = NDesc.Value / 100; partida.NImpuestos = impuestos.Count; //control lotes if (producto.TieneLote) { using (var form = new FrmLoteCaducidad(compra.CompraId, NCantidad.Value, producto.ProductoId)) { if (form.ShowDialog() == DialogResult.OK) { partida.Lote = form.lotes[0].NoLote; partida.Caducidad = form.lotes[0].Caducidad; } else { partida.Lote = null; partida.Caducidad = null; } } } //cambios de precio if (partida.PrecioCompra != producto.PrecioCompra) { producto.PrecioCompra = Ambiente.ToDecimal(TxtPrecioCompra.Text); producto.PrecioCaja = Ambiente.ToDecimal(TxtPrecioCaja.Text); producto.Precio1 = Ambiente.ToDecimal(TxtPrecio1.Text); producto.Precio2 = Ambiente.ToDecimal(TxtPrecio2.Text); producto.Precio3 = Ambiente.ToDecimal(TxtPrecio3.Text); producto.Precio4 = Ambiente.ToDecimal(TxtPrecio4.Text); producto.Utilidad1 = Ambiente.ToDecimal(TxtU1.Text); producto.Utilidad2 = Ambiente.ToDecimal(TxtU2.Text); producto.Utilidad3 = Ambiente.ToDecimal(TxtU3.Text); producto.Utilidad4 = Ambiente.ToDecimal(TxtU4.Text); productosActualizados.Add(producto); } //totales partida.Impuesto1 = impuestos[0].Tasa; partida.Impuesto2 = impuestos[1].Tasa; partida.Subtotal = partida.Cantidad * partida.PrecioCompra; partida.Subtotal -= partida.Subtotal * partida.Descuento; partida.ImporteImpuesto1 = partida.Subtotal * partida.Impuesto1; partida.ImporteImpuesto2 = partida.Subtotal * partida.Impuesto2; partida.Total = partida.Subtotal + partida.ImporteImpuesto1 + partida.ImporteImpuesto2; partidas.Add(partida); CalculaTotales(); // partida al grid Malla.Rows[SigPartida].Cells[0].Value = partida.ProductoId; Malla.Rows[SigPartida].Cells[1].Value = partida.Descripcion; Malla.Rows[SigPartida].Cells[2].Value = partida.LaboratorioName; Malla.Rows[SigPartida].Cells[3].Value = partida.Stock; Malla.Rows[SigPartida].Cells[4].Value = partida.Cantidad; Malla.Rows[SigPartida].Cells[5].Value = partida.PrecioCaja; Malla.Rows[SigPartida].Cells[6].Value = partida.PrecioCompra; Malla.Rows[SigPartida].Cells[7].Value = partida.Descuento; Malla.Rows[SigPartida].Cells[8].Value = partida.Impuesto1; Malla.Rows[SigPartida].Cells[9].Value = partida.Impuesto2; Malla.Rows[SigPartida].Cells[10].Value = partida.Subtotal; Malla.Rows[SigPartida].Cells[11].Value = partida.ImporteImpuesto1 + partida.ImporteImpuesto2; Malla.Rows[SigPartida].Cells[12].Value = partida.Subtotal + partida.ImporteImpuesto1 + partida.ImporteImpuesto2; Malla.Rows[SigPartida].Cells[13].Value = partida.NImpuestos; Malla.Rows[SigPartida].Cells[14].Value = partida.Lote; Malla.Rows[SigPartida].Cells[15].Value = partida.Caducidad; ResetPartida(); }