コード例 #1
0
        void CerrarVenta()
        {
            WS_Info.VentaVO     _venta      = new WS_Info.VentaVO();
            PuntoVenta_Business oPuntoVenta = new PuntoVenta_Business();

            if (_totalVenta > 0)
            {
                decimal   _cambio;
                Frm_Input input = new Frm_Input();
                input.ShowDialog();
                if (input._CANCELA == 0)
                {
                    _cambio = 0;
                }
                else
                {
                    _cambio = input._CANCELA - _totalVenta;
                }
                _venta.Fecha         = Convert.ToDateTime(lblFecha.Text);
                _venta.Tarjeta       = input._TARJETA;
                _venta.Productos     = _listaProductos.ToArray();
                _venta.PuntoVenta    = 1;
                _venta.NombreCliente = Properties.Settings.Default.Aplicativo;
                String nombreArchivo = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString()
                                       + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
                String filename = Properties.Settings.Default.Files.ToString() + "\\" + nombreArchivo + ".vpv";
                _venta.Archivo = nombreArchivo;
                ImprimirTiquete(_venta, input._CANCELA, _cambio, _totalVenta);
                oPuntoVenta.Serializar(filename, _venta);
                lblCambio.Text = _cambio.ToString("C");
                InicioNuevaVenta();
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
            }
            return(objetoDeserializado);
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        void Sincronizar(WS_Info.UsuarioVO _token)
        {
            DateTime                   Hoy               = DateTime.Now;
            PuntoVenta_Business        oPuntoVenta       = new PuntoVenta_Business();
            List <WS_Info.ProductoVO>  _listaProducto    = new List <WS_Info.ProductoVO>();
            List <WS_Info.ProveedorVO> _listaProveedores = new List <WS_Info.ProveedorVO>();
            bool _sincronizacion = false;

            String filename = Properties.Settings.Default.Files.ToString() + "\\" +
                              Properties.Settings.Default.ListaProductos + Hoy.Year.ToString() + Hoy.Month.ToString() + Hoy.Day.ToString() + ".txt";

            String filenameProveedores = Properties.Settings.Default.Files.ToString() + "\\" +
                                         Properties.Settings.Default.ListaProveedores + Hoy.Year.ToString() + Hoy.Month.ToString() + Hoy.Day.ToString() + ".txt";

            try
            {
                WS_Info.WS_InfoSoapClient ws = new WS_Info.WS_InfoSoapClient();
                _listaProducto    = ws.ConsultarProductos(_token).ToList <WS_Info.ProductoVO>();
                _listaProveedores = ws.ConsultarProveedores(_token).ToList <WS_Info.ProveedorVO>();
                _sincronizacion   = true;
            }
            catch (Exception ex)
            {
                _sincronizacion = false;
                MessageBox.Show("No se pudo sincronizar, intente mas tarde " + ex.Message);
            }

            if (!File.Exists(filename) && _sincronizacion == true)
            {
                foreach (string _archivo in Directory.GetFiles(Properties.Settings.Default.Files.ToString()))
                {
                    int longitud = _archivo.Length;
                    if (_archivo.Substring(longitud - 3, 3) == "txt")
                    {
                        File.Delete(_archivo);
                    }
                }
                oPuntoVenta.Serializar(filename, _listaProducto);
                oPuntoVenta.Serializar(filenameProveedores, _listaProveedores);
            }
        }
コード例 #6
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            DialogResult respuesta;
            bool         _exitoso = false;

            respuesta = MessageBox.Show("Desea confirmar compra por: " + _totalFactura.ToString(), "Punto Venta", MessageBoxButtons.YesNo);
            if (respuesta == DialogResult.Yes)
            {
                PuntoVenta_Business oPuntoVenta = new PuntoVenta_Business();
                WS_Info.Compra      _compra     = new WS_Info.Compra();
                string filename = String.Empty;
                try
                {
                    _compra.Proveedor = ddlProveedor.SelectedValue.ToString();
                    _compra.factura   = txtFactura.Text;
                    _compra.Fecha     = DateTime.Now;
                    _compra.Productos = _listado.ToArray();
                    filename          = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString()
                                        + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".cpv";
                    oPuntoVenta.Serializar(filename, _compra);
                    _exitoso = true;
                }
                catch (Exception ex) {
                    _exitoso = false;
                    MessageBox.Show("Hubo un error en el proceso: " + ex.Message);
                }
                if (_exitoso == true)
                {
                    lblTotal.Text = String.Empty;
                    _totalFactura = 0;
                    _listado      = new List <WS_Info.ProductoVO>();
                    DataBind();
                    btnGuardar.Enabled = false;
                    txtFactura.Text    = String.Empty;
                    MessageBox.Show("Registro Exitoso");
                }
            }
        }