void EnviarDatos(eTipoRegistro _tipo) { String _patron = String.Empty; switch (_tipo) { case eTipoRegistro.eCompra: _patron = "*.cpv"; break; case eTipoRegistro.eVenta: _patron = "*.vpv"; break; } PuntoVenta_Business oPuntoVenta = new PuntoVenta_Business(); try { foreach (String _file in Directory.GetFiles(Properties.Settings.Default.Files.ToString(), _patron)) { bool _enviar = false; switch (_tipo) { case eTipoRegistro.eCompra: WS_Info.Compra _compra = new WS_Info.Compra(); _compra = (WS_Info.Compra)oPuntoVenta.Deserializar(_file); _enviar = EnviarDatos(_compra, getToken()); break; case eTipoRegistro.eVenta: WS_Info.VentaVO _venta = new WS_Info.VentaVO(); _venta = (WS_Info.VentaVO)oPuntoVenta.Deserializar(_file); _enviar = EnviarDatos(_venta, getToken()); break; } if (_enviar == true) { File.Delete(_file); } } } catch (Exception ex) { MessageBox.Show("Imposible enviar datos " + ex.Message); } }
private void Frm_Salidas_Load(object sender, EventArgs e) { DateTime Hoy = DateTime.Now; PuntoVenta_Business oPuntoVenta = new PuntoVenta_Business(); string filename = Properties.Settings.Default.Files.ToString() + "\\" + Properties.Settings.Default.ListaProductos + Hoy.Year.ToString() + Hoy.Month.ToString() + Hoy.Day.ToString() + ".txt"; lblFecha.Text = DateTime.Now.ToShortDateString(); txtCodigoBarras.Focus(); _productos = (List <WS_Info.ProductoVO>)oPuntoVenta.Deserializar(filename); }
Object Deserializar(eTipoObjeto eTipo) { Object objetoDeserializado = null; PuntoVenta_Business oBusiness = new PuntoVenta_Business(); DateTime Hoy = DateTime.Now; String filename = String.Empty; if (eTipo == eTipoObjeto.Productos) { filename = Properties.Settings.Default.Files.ToString() + "\\" + Properties.Settings.Default.ListaProductos + Hoy.Year.ToString() + Hoy.Month.ToString() + Hoy.Day.ToString() + ".txt"; objetoDeserializado = oBusiness.Deserializar(filename); } if (eTipo == eTipoObjeto.Proveedores) { filename = Properties.Settings.Default.Files.ToString() + "\\" + Properties.Settings.Default.ListaProveedores + Hoy.Year.ToString() + Hoy.Month.ToString() + Hoy.Day.ToString() + ".txt"; objetoDeserializado = oBusiness.Deserializar(filename); } return(objetoDeserializado); }