private void GuardaCambioPrecios() { foreach (var pa in partidas) { foreach (var pr in productosActualizados) { if (pa.ProductoId.Equals(pr.ProductoId)) { var p = productoController.SelectOne(pa.ProductoId); if (p != null) { //precios viejos cambioPrecio = new CambiosPrecio(); cambioPrecio.ProductoId = p.ProductoId; cambioPrecio.PrecioCompraViejo = p.PrecioCompra; cambioPrecio.Precio1Viejo = p.Precio1; cambioPrecio.Precio2Viejo = p.Precio2; cambioPrecio.Precio3Viejo = p.Precio3; cambioPrecio.Precio4Viejo = p.Precio4; cambioPrecio.Utilidad1Viejo = p.Utilidad1; cambioPrecio.Utilidad2Viejo = p.Utilidad2; cambioPrecio.Utilidad3Viejo = p.Utilidad3; cambioPrecio.Utilidad4Viejo = p.Utilidad4; //precios nuevos cambioPrecio.PrecioCompraNuevo = pa.PrecioCompra; cambioPrecio.Precio1Nuevo = pr.Precio1; cambioPrecio.Precio2Nuevo = pr.Precio2; cambioPrecio.Precio3Nuevo = pr.Precio3; cambioPrecio.Precio4Nuevo = pr.Precio4; cambioPrecio.Utilidad1Nuevo = pr.Utilidad1; cambioPrecio.Utilidad2Nuevo = pr.Utilidad2; cambioPrecio.Utilidad3Nuevo = pr.Utilidad3; cambioPrecio.Utilidad4Nuevo = pr.Utilidad4; cambioPrecio.CompraId = compra.CompraId; cambioPrecio.CreatedAt = DateTime.Now; cambioPrecio.CreatedBy = Ambiente.LoggedUser.UsuarioId; cambioPrecioController.InsertOne(cambioPrecio); } else { Ambiente.Mensaje("El producto ya no existe"); } } } } }
public bool Update(CambiosPrecio o) { try { using (var db = new DymContext()) { db.Entry(o).State = EntityState.Modified; db.SaveChanges(); return(true); } } catch (Exception ex) { Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString()); } return(false); }
public bool InsertOne(CambiosPrecio 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); }
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(); }