private void Modificar(Guid Id) { var ov = Context.OrdenVenta.Find(Id); if (ov != null) { ov.Fecha = DateTime.Now.Date; ov.ClienteId = ClienteId; ov.Calle = txtDomicilio.Text; ov.Numero = txtNumero.Text; ov.Piso = txtPiso.Text; ov.Dpto = txtDpto.Text; ov.TransporteId = TransporteId; ov.Dominio = txtDominio.Text; ov.DominioAcoplado = txtDominioAcoplado.Text; ov.ApellidoChofer = txtApellido.Text; ov.NombreChofer = txtNombre.Text; ov.CuitChofer = txtCuitChofer.Text; ov.Pendiente = true; Context.Entry(ov).State = EntityState.Modified; Context.SaveChanges(); IEnlaceActualizar mienlace = this.Owner as Form_AdministracionOrdenVenta; if (mienlace != null) { mienlace.Enviar(true); } this.Close(); } }
private void GrabarPrecio() { try { var clase = _context.Clase.Find(_claseId); if (clase != null) { clase.FechaModificacion = DateTime.Now.Date; clase.Valor = decimal.Parse(txtPrecio.Text); clase.Vigente = true; _context.Entry(clase).State = EntityState.Modified; _context.SaveChanges(); IEnlaceActualizar mienlace = this.Owner as Form_AdministracionListaPrecio; if (mienlace != null) { mienlace.Enviar(true); } this.Dispose(); } } catch { throw; } }
private void GuardarDatos(Guid OrdenVentaId, Guid ProductoId, int año, bool nuevoDetalle) { try { OrdenVentaDetalle detalle; detalle = new OrdenVentaDetalle(); detalle.Id = Guid.NewGuid(); detalle.OrdenVentaId = OrdenVentaId; detalle.Campaña = año; detalle.ProductoId = ProductoId; detalle.DesdeCaja = long.Parse(txtCajaDesde.Text); detalle.HastaCaja = long.Parse(txtCajaHasta.Text); Context.OrdenVentaDetalle.Add(detalle); Context.SaveChanges(); AsociarOVaCaja(OrdenVentaId, ProductoId, año, detalle.DesdeCaja.Value, detalle.HastaCaja.Value); } catch { throw; } if (nuevoDetalle) { IEnlaceActualizar mienlace = this.Owner as Form_AdministracionOrdenVenta; if (mienlace != null) { mienlace.Enviar(true); } this.Close(); } }
private void GrabarTurno() { try { Turno turno; turno = new Turno(); turno.Id = Guid.NewGuid(); turno.ProductorId = _productorId; turno.FechaSolicitud = DateTime.Now.Date; DateTime fechaTurno = dpFechaSolicitud.Value.Date; turno.FechaTurno = fechaTurno; Decimal kilos = Decimal.Parse(txtKilos.Text); turno.Kilos = kilos; _context.Turno.Add(turno); _context.SaveChanges(); ImprimirTurno(turno.Id); IEnlaceActualizar mienlace = this.Owner as Form_RomaneoBuscarTurno; if (mienlace != null) { mienlace.Enviar(true); } this.Dispose(); } catch { throw; } }
private void Reclasificar(bool gestionReclasificacion, string numFardo) { long salida = 0; if (long.TryParse(numFardo, out salida)) { long fardo = long.Parse(numFardo); var pesadadet = Context.PesadaDetalle .Where(x => x.NumFardo == fardo) .FirstOrDefault(); if (pesadadet != null) { var clase = Context.Vw_Clase .Where(x => x.NOMBRE.Equals(txtReclasificacion.Text)) .FirstOrDefault(); if (clase != null) { var pesadaDetalle = Context.PesadaDetalle.Find(pesadadet.Id); pesadaDetalle.ReclasificacionId = clase.ID; Context.Entry(pesadaDetalle).State = EntityState.Modified; Context.SaveChanges(); if (ValidarDebug().Equals(false)) { if ((gestionReclasificacion.Equals(false) && ValidarImpresion().Equals(true)) || gestionReclasificacion.Equals(true) && ValidarImpresionGestionReclasificacion().Equals(true)) { string combinadoReclasificacion = txtClase.Text.Substring(0, 1) + " - " + txtReclasificacion.Text; PrintTicket(txtFardo.Text, txtClase.Text, combinadoReclasificacion, pesadaDetalle.Kilos.ToString()); } } Limpiar(); Iniciar(null); IEnlaceActualizar mienlace = this.Owner as Form_RomaneoGestionClasificacion; if (mienlace != null) { mienlace.Enviar(true); this.Close(); } } } } }
private void EliminarOV(Guid Id) { try { var cajas = Context.Caja.Where(x => x.OrdenVentaId == Id) .Update(x => new Caja() { OrdenVentaId = null }); var catas = Context.Cata.Where(x => x.OrdenVentaId == Id) .Update(x => new Cata() { OrdenVentaId = null, NumOrden = null }); Context.OrdenVentaDetalle.RemoveRange(Context.OrdenVentaDetalle.Where(x => x.OrdenVentaId == Id)); Context.OrdenVenta.RemoveRange(Context.OrdenVenta.Where(x => x.Id == Id)); var contador = Context.Contador .Where(x => x.Nombre == DevConstantes.OrdenVenta || x.Nombre == DevConstantes.NumeroOperacion) .Update(x => new Contador() { Valor = x.Valor - 1 }); Context.SaveChanges(); } catch { throw; } IEnlaceActualizar mienlace = this.Owner as Form_AdministracionOrdenVenta; if (mienlace != null) { mienlace.Enviar(true); } this.Close(); }
private void Eliminar(Guid OrdenVentaId, Guid OrdenVentaDetalleId, Guid ProductoId, int año, bool eliminarDetalle) { var ordenVenta = Context.OrdenVenta .Where(x => x.Id == OrdenVentaId) .FirstOrDefault(); if (ordenVenta != null) { var catas = Context.Cata .Where(x => x.OrdenVentaId == OrdenVentaId && x.Caja.ProductoId == ProductoId && x.Caja.Campaña == año) .Update(x => new Cata() { OrdenVentaId = null, NumOrden = null }); var cajas = Context.Caja .Where(x => x.OrdenVentaId == OrdenVentaId && x.ProductoId == ProductoId && x.Campaña == año) .Update(x => new Caja() { OrdenVentaId = null }); Context.OrdenVentaDetalle.RemoveRange(Context.OrdenVentaDetalle.Where(x => x.Id == OrdenVentaDetalleId)); Context.SaveChanges(); if (eliminarDetalle) { IEnlaceActualizar mienlace = this.Owner as Form_AdministracionOrdenVenta; if (mienlace != null) { mienlace.Enviar(true); } this.Close(); } } }
private void GenerarOrdenVenta() { try { OrdenVenta ov; ov = new OrdenVenta(); ov.Id = Guid.NewGuid(); ov.NumOperacion = ContadorNumeroOperacion(); ov.NumOrden = ContadorOrdenVenta(); ov.Fecha = DateTime.Now.Date; ov.ClienteId = ClienteId; ov.Calle = txtDomicilio.Text; ov.Numero = txtNumero.Text; ov.Piso = txtPiso.Text; ov.Dpto = txtDpto.Text; ov.TransporteId = TransporteId; ov.Dominio = txtDominio.Text; ov.DominioAcoplado = txtDominioAcoplado.Text; ov.ApellidoChofer = txtApellido.Text; ov.NombreChofer = txtNombre.Text; ov.CuitChofer = txtCuitChofer.Text; ov.Pendiente = true; Context.OrdenVenta.Add(ov); Context.SaveChanges(); ActualizarContadorOrdenVenta(); ActualizarContadorNumeroOperacion(); IEnlaceActualizar mienlace = this.Owner as Form_AdministracionOrdenVenta; if (mienlace != null) { mienlace.Enviar(true); } this.Close(); } catch { throw; } }
private void GrabarRemito() { try { //Crea Carpeta SystemDocumentsCooperativa. CreateFolder(); //Copia el Remito Electronico en dicha direccion. CopyFile(); var ordenVenta = Context.OrdenVenta .Where(x => x.Id == OrdenVentaId) .FirstOrDefault(); if (ordenVenta != null) { Remito remito; remito = new Remito(); remito.Id = Guid.NewGuid(); remito.NumOperacion = ordenVenta.NumOperacion; remito.NumOrden = ordenVenta.NumOrden; remito.ClienteId = ordenVenta.ClienteId; remito.FechaOrden = ordenVenta.Fecha; remito.FechaRemito = dpRemito.Value; remito.OrdenVentaId = ordenVenta.Id; remito.PuntoVenta = int.Parse(txtPuntoVenta.Text); remito.NumRemito = int.Parse(txtNumRemito.Text); remito.PathOrigin = path; string pathSystem = @"C:\SystemDocumentsCooperativa\RemitosElectronicos\" + txtNombrePdf.Text; remito.PathSystem = pathSystem; Context.Remito.Add(remito); Context.SaveChanges(); var orden = Context.OrdenVenta.Find(ordenVenta.Id); if (orden != null) { orden.Pendiente = false; Context.Entry(orden).State = EntityState.Modified; Context.SaveChanges(); var detalles = Context.OrdenVentaDetalle .Where(x => x.OrdenVentaId == ordenVenta.Id) .ToList(); foreach (var item in detalles) { for (long i = item.DesdeCaja.Value; i <= item.HastaCaja; i++) { var caja = Context.Caja .Where(x => x.Campaña == item.Campaña && x.ProductoId == item.ProductoId && x.NumeroCaja == i) .FirstOrDefault(); UpdateMovimientoActual(caja.Id); RegistrarMovimiento(caja.Id, 1, remito.FechaRemito.Value); } } } IEnlaceActualizar mienlace = this.Owner as Form_AdministracionRemitoElectronico; if (mienlace != null) { mienlace.Enviar(true); } this.Close(); } } catch { throw; } }