Beispiel #1
0
        private void dgvList_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
        {
            if (e.StateChanged != DataGridViewElementStates.Selected)
            {
                return;
            }

            if (dgvList.SelectedRows.Count != 0)
            {
                try
                {
                    DataGridViewRow row = this.dgvList.SelectedRows[0];
                    one = (VntOperacion)row.DataBoundItem;
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                    MetroFramework.MetroMessageBox.Show(this.MdiParent, ex.Message, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                btnEdit.Visible = true;
            }
            else
            {
                btnEdit.Visible = false;
            }
        }
Beispiel #2
0
        private void InicializarOperacion()
        {
            lblProgreso.Text = "";
            one = srvVenta.GetOne(Globals.logEmpresa.id, "11E8F22493F0CDBC8FF600270E383B06", "0");

            _oneCliente = srvCliente.GetOne(Globals.logEmpresa.id, "11E94E4F862A74768EFE00E04C6F7E24");

            one.id_cliente     = _oneCliente.id;
            one.cliente_nombre = _oneCliente.nombre;
            one.cliente_rif    = _oneCliente.rif;

            lblClienteNombre.Text = one.cliente_nombre;
            lblClienteRif.Text    = one.cliente_rif;

            //DETALLE
            _listaDetalle = srvMovimiento.GetList(one.id);
            bList         = new BindingList <App.InvMovimientoService.InvMovimiento>(_listaDetalle);

            //PAGO
            _listaInstrumentos = srvMovimientoCaja.GetList(one.id);


            bs.DataSource      = bList;
            dgvList.DataSource = bs;
            Totalizar();
            //ValidarBotones();
        }
        private void btnPagar_Click(object sender, EventArgs e)
        {
            btnPagar.Enabled = false;

            VntOperacion _one = srv.GetOne(Globals.logEmpresa.id, one.id_tipo_operacion, one.id);

            frmCajMovimientoSelection fDialog = new frmCajMovimientoSelection(one.deuda, _listaInstrumentos, "abonos");

            if (ConfigUI.LaunchDialogForm(fDialog) == DialogResult.OK)
            {
                _listaInstrumentos = fDialog.instrumentosSeleccionados;
                List <CajMovimiento> _pago = ConvertirPago(_listaInstrumentos);

                try
                {
                    srv.SetAbono(_one, _pago);

                    MetroFramework.MetroMessageBox.Show(this.MdiParent, "Pago realizado con éxito", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    GetList(_idCliente);
                    MultiplicarMoneda();
                }
                catch (Exception)
                {
                    MetroFramework.MetroMessageBox.Show(this.MdiParent, "Se produjeron errores intentando procesar el registro, por favor revise los valores e intente nuevamente", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    btnPagar.Enabled = true;
                }
            }
        }
        public frmCajMovimientoSelection(VntOperacion _one, List <App.CajMovimientoService.CajMovimiento> _instrumentos, string padre)
        {
            factor = Globals.valorCotizacion;

            _totalDocumento = _one.total_moneda;
            _padre          = padre;
            idTipoOperacion = _one.id_tipo_operacion;

            InitializeComponent();
            lblClienteNombre.Text = _one.cliente_nombre;
            lblClienteRif.Text    = _one.cliente_rif;
            CargarListas();
            cmbTipoOperacion.SelectedValue = _one.id_tipo_operacion;
            if (_padre == "devolucion")
            {
                cmbTipoOperacion.Enabled = false;
            }

            instrumentosSeleccionados = _instrumentos;
            foreach (App.CajMovimientoService.CajMovimiento item in instrumentosSeleccionados)
            {
                item.monto_moneda = item.monto * factor;
            }
            OcultarListaInstrumentos();
            AgregarListaInstrumentos();
            CalcularTotales();

            this.KeyPreview = true;
            this.KeyDown   +=
                new KeyEventHandler(frmCajMovimientoSelection_KeyDown);
        }
Beispiel #5
0
        public static VntOperacion ConvertirHeadVenta(ColOperacion headVenta)
        {
            VntOperacion _head = new VntOperacion();

            _head.id                = headVenta.id;
            _head.order_id          = headVenta.order_id;
            _head.last_update       = headVenta.last_update;
            _head.id_empresa        = headVenta.id_empresa;
            _head.id_tipo_operacion = headVenta.id_tipo_operacion;
            _head.numero            = headVenta.numero;
            _head.nro_control       = headVenta.nro_control;
            _head.fecha             = headVenta.fecha;
            _head.fecha_registro    = headVenta.fecha_registro;
            _head.id_destino        = headVenta.id_destino;
            _head.id_cliente        = headVenta.id_cliente;
            _head.cliente_nombre    = headVenta.cliente_nombre;
            _head.cliente_rif       = headVenta.cliente_rif;

            _head.id_tipo_documento     = headVenta.id_tipo_documento;
            _head.tipo_documento_nombre = headVenta.tipo_documento_nombre;
            _head.nro_control_documento = headVenta.nro_control_documento;
            _head.nro_documento         = headVenta.nro_documento;
            _head.fecha_documento       = headVenta.fecha_documento;
            _head.nro_factura_afectada  = headVenta.nro_factura_afectada;
            _head.id_doc_origen         = headVenta.id_doc_origen;
            _head.id_cotizacion         = headVenta.id_cotizacion;

            _head.monto_exento      = headVenta.monto_exento;
            _head.base_imponible_tg = headVenta.base_imponible_tg;
            _head.base_imponible_tr = headVenta.base_imponible_tr;
            _head.base_imponible_ta = headVenta.base_imponible_ta;
            _head.pct_alicuota_tg   = headVenta.pct_alicuota_tg;
            _head.pct_alicuota_tr   = headVenta.pct_alicuota_tr;
            _head.pct_alicuota_ta   = headVenta.pct_alicuota_ta;
            _head.monto_iva_tg      = headVenta.monto_iva_tg;
            _head.monto_iva_tr      = headVenta.monto_iva_tr;
            _head.monto_iva_ta      = headVenta.monto_iva_ta;
            _head.total             = headVenta.total;

            _head.monto_exento_moneda      = headVenta.monto_exento_moneda;
            _head.base_imponible_tg_moneda = headVenta.base_imponible_tg_moneda;
            _head.base_imponible_tr_moneda = headVenta.base_imponible_tr_moneda;
            _head.base_imponible_ta_moneda = headVenta.base_imponible_ta_moneda;
            _head.monto_iva_tg_moneda      = headVenta.monto_iva_tg_moneda;
            _head.monto_iva_tr_moneda      = headVenta.monto_iva_tr_moneda;
            _head.monto_iva_ta_moneda      = headVenta.monto_iva_ta_moneda;
            _head.total_moneda             = headVenta.total_moneda;

            _head.pct_descuento  = headVenta.pct_descuento;
            _head.pct_adicional  = headVenta.pct_adicional;
            _head.id_status      = headVenta.id_status;
            _head.id_estado      = headVenta.id_estado;
            _head.id_usuario     = headVenta.id_usuario;
            _head.usuario_nombre = headVenta.usuario_nombre;
            _head.observacion    = headVenta.observacion;

            return(_head);
        }
Beispiel #6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            VntOperacion _one = new VntOperacion();

            _one = srv.GetOne(Globals.logEmpresa.id, cmbTipoOperacion.SelectedValue.ToString(), "0");
            Form f = new frmVntOperacionesDetail(_one);

            ConfigUI.LaunchChildForm(f, Globals.appParentWindow);
        }
        private void btnAbonos_Click(object sender, EventArgs e)
        {
            VntOperacion _one = new VntOperacion();

            _one = srv.GetOne(Globals.logEmpresa.id, one.id_tipo_operacion, one.id);

            frmVntClientesAbonos fDetalle = new frmVntClientesAbonos(_one);

            ConfigUI.LaunchDialogForm(fDetalle);
        }
Beispiel #8
0
        private void SelPago()
        {
            _listaInstrumentos.Clear();
            frmCajMovimientoSelection fDialog = new frmCajMovimientoSelection(one, _listaInstrumentos, "venta");

            if (ConfigUI.LaunchDialogForm(fDialog) == DialogResult.OK)
            {
                one.id_cotizacion     = _oneCotizacion.id_cotizacion;
                one.id_tipo_operacion = fDialog.idTipoOperacion;

                _tipoOperacion            = GetTipoOperacion(one.id_tipo_operacion);
                one.tipo_documento_nombre = _tipoOperacion.nombre;

                _oneCliente = srvCliente.GetOne(Globals.logEmpresa.id, one.id_cliente);

                _listaInstrumentos = fDialog.instrumentosSeleccionados;
                _listaDetalle      = srvMovimiento.GetList(one.id);

                //CONVERSIONES
                VntOperacion _one = Globals.ConvertirHeadVenta(one);
                _one.id = "0";
                List <App.VntOperacionService.InvMovimiento> _detail = Globals.ConvertirDetalleVenta(_listaDetalle);
                List <App.VntOperacionService.CajMovimiento> _pago   = Globals.ConvertirPago(_listaInstrumentos);

                //SAVE
                try
                {
                    string res = srvVenta.SetOne(_one, _detail, _pago);
                    if (res.Length > 1)
                    {
                        if (one.id_tipo_operacion == "11E8F22493F0CDBC8FF600270E383B06")
                        {
                            Globals.ImprimirFacturaFiscal(_oneCliente, _one, _detail, lblProgreso);
                        }
                        else
                        {
                            //imprimirOperacion();
                            Globals.ImprimirTicketVenta(_one, _detail, factor);
                        }

                        srvCola.UpdateOne(one, 3);
                        MetroFramework.MetroMessageBox.Show(this.MdiParent, "Operación registrada con éxito", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        InicializarOperacion();
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this.MdiParent, "No se guardó la operación", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception)
                {
                    MetroFramework.MetroMessageBox.Show(this.MdiParent, "Se produjeron errores intentando procesar la operación, por favor revise los valores e intente nuevamente", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
        private void btnNullify_Click(object sender, EventArgs e)
        {
            //ONE
            VntOperacion one = selectedOperacion;

            frmDevolucion fDialog = new frmDevolucion(one);

            if (ConfigUI.LaunchDialogForm(fDialog) == DialogResult.OK)
            {
            }
        }
Beispiel #10
0
        public frmVntOperacionesDetail(VntOperacion _one)
        {
            InitializeComponent();

            //ONE
            if (_one == null)
            {
                return;
            }
            one = _one;
            CrearBindings();

            //LISTAS
            _tipoOperacion = srvOperacion.GetOne(one.id_tipo_operacion);
            if (_tipoOperacion == null)
            {
                return;
            }
            lblTitle.Text    = _tipoOperacion.nombre;
            lblSubTitle.Text = one.nro_control;
            CargarListas();

            //CLIENTE
            if (one.id_cliente != "")
            {
                VntCliente cliente = srvCliente.GetOne(Globals.logEmpresa.id, one.id_cliente);
                if (cliente != null)
                {
                    AsignarCliente(cliente);
                }
            }


            //DETALLE
            _listaDetalle = srvMovimiento.GetList(one.id);
            bList         = new BindingList <InvMovimientoService.InvMovimiento>(_listaDetalle);

            //PAGO
            _listaInstrumentos = srvMovimientoCaja.GetList(one.id);

            Globals.ConfigurarComboMonedas(cmbCotizacion);

            bs.DataSource      = bList;
            dgvList.DataSource = bs;
            Totalizar();
            ValidarBotones();
        }
Beispiel #11
0
        public frmDevolucion(VntOperacion _one)
        {
            InitializeComponent();

            _listaOperaciones = srvOperacion.GetList("11E7C39A0EACD9A08F1A00E04C6F7E24");

            oneDocumentoOrigen = _one;


            //COTIZACION
            CnfCotizacionClient         srvCotizacion = new CnfCotizacionClient();
            List <CnfCotizacionDetalle> _cotizacion   = srvCotizacion.GetListDetail(oneDocumentoOrigen.id_cotizacion);

            foreach (CnfCotizacionDetalle item in _cotizacion)
            {
                if (item.id_moneda == Globals.logEmpresa.moneda_defecto)
                {
                    factor = item.valor;
                }
            }

            //HEADER
            lblTitle.Text    = "Devolución: " + oneDocumentoOrigen.tipo_documento_nombre;
            lblSubTitle.Text = oneDocumentoOrigen.nro_control;

            lblClienteNombre.Text = oneDocumentoOrigen.cliente_nombre;
            lblClienteRif.Text    = oneDocumentoOrigen.cliente_rif;

            InicializarDevolucion();

            bList              = new BindingList <App.InvMovimientoService.InvMovimiento>(_listaDetalle);
            bs.DataSource      = bList;
            dgvList.DataSource = bs;
            Totalizar();

            lblProgreso.Visible = false;

            this.KeyPreview = true;
            this.KeyDown   +=
                new KeyEventHandler(frmPuntoVenta_KeyDown);
        }
Beispiel #12
0
        private void SelOperacion()
        {
            frmVntOperacionSelection fDialog = new frmVntOperacionSelection();

            if (ConfigUI.LaunchDialogForm(fDialog) == DialogResult.OK)
            {
                one         = fDialog.selectedOperacion;
                _oneCliente = srvCliente.GetOne(Globals.logEmpresa.id, one.id_cliente);

                lblClienteNombre.Text = _oneCliente.nombre;
                lblClienteRif.Text    = _oneCliente.rif;

                //DETALLE
                _listaDetalle      = srvMovimiento.GetList(one.id);
                bList              = new BindingList <App.InvMovimientoService.InvMovimiento>(_listaDetalle);
                bs.DataSource      = bList;
                dgvList.DataSource = bs;
                Totalizar();
                //ValidarBotones();
            }
        }
Beispiel #13
0
        private void InicializarDevolucion()
        {
            switch (oneDocumentoOrigen.id_tipo_operacion)
            {
            case "11E8F22493F0CDBC8FF600270E383B06":     //FACTURA
                oneDevolucion = srvVenta.GetOne(Globals.logEmpresa.id, "11E95C6B1693D4D2808B00E04C6F7E24", "0");
                break;

            case "11E8F2249FB109E98FF600270E383B06":     //NOTA DE ENTREGA
                oneDevolucion = srvVenta.GetOne(Globals.logEmpresa.id, "11E95C6B30D59DAE808B00E04C6F7E24", "0");
                break;
            }

            oneDevolucion.id_cliente     = oneDocumentoOrigen.id_cliente;
            oneDevolucion.cliente_nombre = oneDocumentoOrigen.cliente_nombre;
            oneDevolucion.cliente_rif    = oneDocumentoOrigen.cliente_rif;

            oneDevolucion.id_tipo_documento     = oneDocumentoOrigen.id_tipo_operacion;
            oneDevolucion.nro_control_documento = oneDocumentoOrigen.nro_control;
            oneDevolucion.nro_documento         = oneDocumentoOrigen.nro_control;
            oneDevolucion.fecha_documento       = oneDocumentoOrigen.fecha;
            oneDevolucion.nro_factura_afectada  = oneDocumentoOrigen.nro_control;
            oneDevolucion.id_cotizacion         = oneDocumentoOrigen.id_cotizacion;
            oneDevolucion.id_doc_origen         = oneDocumentoOrigen.id;

            //DETALLE
            _listaDetalleOriginal     = srvMovimiento.GetList(oneDocumentoOrigen.id);
            _listaDetalleRelacionados = srvMovimiento.GetListByOrigen(oneDocumentoOrigen.id);

            foreach (App.InvMovimientoService.InvMovimiento item in _listaDetalleRelacionados)
            {
                App.InvMovimientoService.InvMovimiento obj = _listaDetalleOriginal.Find(x => x.id_producto.Contains(item.id_producto));
                obj.cantidad -= item.cantidad;
            }

            _listaDetalle = _listaDetalleOriginal;

            //PAGO
            _listaInstrumentos = srvMovimientoCaja.GetList(oneDocumentoOrigen.id);
        }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            //ONE
            VntOperacion one = selectedOperacion;
            //DETAIL
            BindingList <App.InvMovimientoService.InvMovimiento> bList   = new BindingList <App.InvMovimientoService.InvMovimiento>(srvMovimiento.GetList(one.id));
            List <App.VntOperacionService.InvMovimiento>         _detail = Globals.ConvertirDetalle(bList);
            //COTIZACION
            double _factor = 1;
            CnfCotizacionClient         srvCotizacion = new CnfCotizacionClient();
            List <CnfCotizacionDetalle> _cotizacion   = srvCotizacion.GetListDetail(one.id_cotizacion);

            foreach (CnfCotizacionDetalle item in _cotizacion)
            {
                if (item.id_moneda == Globals.logEmpresa.moneda_defecto)
                {
                    _factor = item.valor;
                }
            }

            //PRINT
            Globals.ImprimirTicketVenta(one, _detail, _factor);
        }
Beispiel #15
0
        public frmPvConfirmar(VntOperacion _one, BindingList <App.InvMovimientoService.InvMovimiento> bListDetalle)
        {
            //factor = Globals.valorCotizacion;

            //_padre = padre;
            //idTipoOperacion = _one.id_tipo_operacion;


            InitializeComponent();

            cmbUsuarios.DataSource    = Globals.listaUsuarios;
            cmbUsuarios.DisplayMember = "numero";
            cmbUsuarios.ValueMember   = "id";

            lblClienteNombre.Text  = _one.cliente_nombre;
            lblClienteRif.Text     = _one.cliente_rif;
            txtTotalDocumento.Text = (_one.total_moneda).ToString("N2", Globals.nfiVE);

            dgvList.DataSource = bListDetalle;

            /*this.KeyPreview = true;
             * this.KeyDown +=
             *  new KeyEventHandler(frmPvConfirmar_KeyDown);*/
        }
        public string SetOne(VntOperacion one, List <InvMovimiento> detail, List <CajMovimiento> pago)
        {
            string _id = srv.SetOne(one, detail, pago);

            return(_id);
        }
        public string SetAbono(VntOperacion one, List <CajMovimiento> pago)
        {
            string _id = srv.SetAbono(one, pago);

            return(_id);
        }
        public string NullOne(VntOperacion one, List <InvMovimiento> detail)
        {
            string _id = srv.NullOne(one, detail);

            return(_id);
        }
        public VntOperacion GetOne(string idEmpresa, string idTipo, string id)
        {
            VntOperacion _one = srv.GetOne(idEmpresa, idTipo, id);

            return(_one);
        }
Beispiel #20
0
        //FISCAL
        //DOCUMENTOS FISCALES
        public static Boolean ImprimirFacturaFiscal(VntCliente _oneCliente, VntOperacion one, List <App.VntOperacionService.InvMovimiento> _listaDetalle, Label lblProgreso)
        {
            lblProgreso.Text = "Imprimiendo";

            string  c = "";
            Boolean bRet;

            //MessageBox.Show("Nombre Cliente");
            string nombre = FormatoTexto(_oneCliente.nombre, 40);

            c    = "iS*" + nombre;
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo el  nombre del cliente";
            }

            //MessageBox.Show("RIF Cliente");
            string rif = FormatoTexto(_oneCliente.rif, 11);

            c    = "iR*" + rif;
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo el rif del cliente";
            }

            //MessageBox.Show("Direccion");
            string direccion = FormatoTexto(_oneCliente.direccion, 30);

            c    = "i01DIRECCION: " + direccion;
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo la dirección del cliente";
            }

            //MessageBox.Show("Tlf");
            string telefono = FormatoTexto(_oneCliente.telefono, 30);

            c    = "i02TELEFONO: " + telefono;
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo el teléfono del cliente";
            }

            //MessageBox.Show("NRO CONTROL");
            string numero = FormatoTexto(one.nro_control, 30);

            c    = "i03N. CONTROL: " + numero;
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo el número de control";
            }

            //MessageBox.Show("CONDICION DE VENTA");
            c    = "i04" + "CONDICION VENTA: ** CONTADO **";
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo la condición de venta";
            }


            /********************** PRODUCTOS *************************************/

            for (int i = 0; i < (_listaDetalle.Count); i++)
            {
                c = "";
                if (Convert.ToInt16(_listaDetalle[i].valor_impuesto) == 0)
                {
                    c = " ";
                }

                if (Convert.ToInt16(_listaDetalle[i].valor_impuesto) == Convert.ToInt16(Globals.TasaG))
                {
                    c = "!";
                }

                //MessageBox.Show(c);

                Double precioBase  = Convert.ToDouble(_listaDetalle[i].precio_moneda);
                Double valorIva    = (Convert.ToDouble(_listaDetalle[i].valor_impuesto) / 100) + 1;
                Double precioFinal = Convert.ToDouble(_listaDetalle[i].precio_moneda);

                Double formatoPrecio   = precioFinal * 100;
                Double formatoCantidad = Convert.ToInt64(_listaDetalle[i].cantidad) * 1000;

                string precio   = formatoPrecio.ToString("0000000000");
                string cantidad = formatoCantidad.ToString("00000000");
                string producto = FormatoTexto(_listaDetalle[i].producto_nombre.ToString(), 40);
                Console.Write(producto);

                //MessageBox.Show(producto);

                c   += precio + cantidad + producto;
                bRet = Globals.Impresora.SendCmd(c);
                if (bRet == false)
                {
                    lblProgreso.Text = "Ocurrió un error imprimiendo el producto " + c;
                }
            }
            //TOTALIZAR
            c    = "3";
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error totalizando la factura";
            }
            //EFECTIVO
            c    = "101";
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error cerrando el documento";
            }

            return(true);
        }
Beispiel #21
0
        public static Boolean ImprimirNotaCreditoFiscal(VntOperacion one, List <App.VntOperacionService.InvMovimiento> _listaDetalle, Label lblProgreso)
        {
            lblProgreso.Text = "Imprimiendo";

            string  c = "";
            Boolean bRet;

            //MessageBox.Show("Nombre Cliente");
            string nombre = FormatoTexto(one.cliente_nombre, 40);

            c    = "iS*" + nombre;
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo el  nombre del cliente";
            }

            //MessageBox.Show("Rif Cliente");
            string rif = FormatoTexto(one.cliente_rif, 11);

            c    = "iR*" + rif;
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo el rif del cliente";
            }

            string numero = "00000000";

            if (one.nro_factura_afectada != null)
            {
                numero = one.nro_factura_afectada;
            }
            c    = "iF*" + numero;
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo el número de factura";
            }


            //MessageBox.Show("FECHA");
            string fecha = "01-01-01";

            if (one.fecha_documento != null)
            {
                fecha = one.fecha_documento.ToString();
            }
            c    = "iD*" + fecha;
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo la fecha del documento";
            }


            string serial = "Z4A1234567";

            try
            {
                //EstatusS5 = Globals.Impresora.GetS5PrinterData();
                //serial = EstatusS5.RegisteredMachineNumber;
                // MessageBox.Show("Obtuve el serial de la maquina: " + serial);
            }
            catch (Exception)
            {
                serial = "Z4A1234567";
            }

            //MessageBox.Show("SERIAL");
            c    = "iI*" + serial;
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error imprimiendo el serial";
            }



            /********************** PRODUCTOS *************************************/

            for (int i = 0; i < (_listaDetalle.Count); i++)
            {
                //MessageBox.Show(_listaDetalle[i].valor_impuesto.ToString());

                c = "";
                if (Convert.ToInt16(_listaDetalle[i].valor_impuesto) == 0)
                {
                    c = "d0";
                }

                if (Convert.ToInt16(_listaDetalle[i].valor_impuesto) == Convert.ToInt16(Globals.TasaG))
                {
                    c = "d1";
                }

                //MessageBox.Show("El valor del impuesto es: " + c);

                Double precioBase = Convert.ToDouble(_listaDetalle[i].precio);
                Double valorIva   = (Convert.ToDouble(_listaDetalle[i].valor_impuesto) / 100) + 1;
                //Double precioFinal = precioBase / valorIva;
                Double precioFinal = precioBase;

                Double formatoPrecio   = precioFinal * 100;
                Double formatoCantidad = Convert.ToInt64(_listaDetalle[i].cantidad) * 1000;

                string precio   = formatoPrecio.ToString("0000000000");
                string cantidad = formatoCantidad.ToString("00000000");
                string producto = FormatoTexto(_listaDetalle[i].producto_nombre.ToString(), 40);
                Console.Write(producto);
                c += precio + cantidad + producto;
                //MessageBox.Show("El producto es: " + c);

                try
                {
                    bRet = Globals.Impresora.SendCmd(c);
                    if (bRet == false)
                    {
                        lblProgreso.Text = "Ocurrió un error imprimiendo el producto " + c;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            //EFECTIVO
            //MessageBox.Show("FORMA DE PAGO");
            c    = "101";
            bRet = Globals.Impresora.SendCmd(c);
            if (bRet == false)
            {
                lblProgreso.Text = "Ocurrió un error cerrando el documento";
            }


            /*Nota de Crédito*/
            //Boolean bRet;
            //bRet = Globals.Impresora.SendCmd("iR*21.122.012");
            ////MessageBox.Show("iR " + bRet.ToString());
            //bRet = Globals.Impresora.SendCmd("iS*Pedro Perez");
            ////MessageBox.Show("iS " + bRet.ToString());
            //bRet = Globals.Impresora.SendCmd("iF*00000000001");
            ////MessageBox.Show("iF " + bRet.ToString());
            //bRet = Globals.Impresora.SendCmd("iD*22/08/2016");
            ////MessageBox.Show("iD " + bRet.ToString());
            //bRet = Globals.Impresora.SendCmd("iI*Z1F1234567");
            ////MessageBox.Show("iI " + bRet.ToString());
            //bRet = Globals.Impresora.SendCmd("i00Direccion: Ppal Siempre Viva");
            ////MessageBox.Show("i00 " + bRet.ToString());
            //bRet = Globals.Impresora.SendCmd("i01Telefono: +101 (1234) 555-55-55");
            ////MessageBox.Show("i01 " + bRet.ToString());
            ////bRet = Globals.Impresora.SendCmd("i02CAJERO: 00001");
            ////MessageBox.Show("i02 " + bRet.ToString());
            //MessageBox.Show("Antes de entrar: " + bRet.ToString());
            //bRet = Globals.Impresora.SendCmd("d1000000050000001000Tax Producto Tasa General");
            //MessageBox.Show("d1 " + bRet.ToString());

            ////bRet = Globals.Impresora.SendCmd("d1000000050000001000Tax Producto Tasa General");
            ////MessageBox.Show("d1 " + bRet.ToString());
            ////bRet = Globals.Impresora.SendCmd("d2000000070000001000Tax Producto Tasa Reducida");
            ////MessageBox.Show("d2 " + bRet.ToString());
            ////bRet = Globals.Impresora.SendCmd("d3000000090000001000Tax Producto Tasa Adicional");
            ////MessageBox.Show("d3 " + bRet.ToString());
            //bRet = Globals.Impresora.SendCmd("101");
            //MessageBox.Show("101 " + bRet.ToString());



            //bRet = Globals.Impresora.SendCmd(" 000000030000001000Tax Free/Producto Exento");
            //bRet = Globals.Impresora.SendCmd("!000000050000001000Tax Rate 1/Producto Tasa General");
            //bRet = Globals.Impresora.SendCmd('\u0022' + "000000070000001000Tax Rate 2/ Producto Tasa Reducida");
            //bRet = Globals.Impresora.SendCmd("#000000090000001000Tax Rate 3/ Producto Tasa Adicional");
            //bRet = Globals.Impresora.SendCmd("3");
            //bRet = Globals.Impresora.SendCmd("101");



            //MessageBox.Show("RESPUESTA");
            //MessageBox.Show(bRet.ToString());
            return(true);
        }
Beispiel #22
0
        //GENERIC PRINTER
        public static void ImprimirTicketVenta(VntOperacion one, List <App.VntOperacionService.InvMovimiento> _listaDetalle, double factor)
        {
            PrintDocument printDocument = new PrintDocument();

            //printDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(CrearTicket); //add an event handler that will do the printing
            printDocument.PrintPage += delegate(object sender, System.Drawing.Printing.PrintPageEventArgs e)
            {
                double montoExento = (one.monto_exento) * factor;
                double montoBase   = (one.base_imponible_ta + one.base_imponible_tg + one.base_imponible_tr) * factor;
                double montoIva    = (one.monto_iva_ta + one.monto_iva_tg + one.monto_iva_tr) * factor;

                Graphics graphic = e.Graphics;

                int startX = 0;
                int startY = 10;
                int offset = 280;

                //HEADER
                graphic.DrawString(Globals.logEmpresa.rif, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY);
                graphic.DrawString(Globals.logEmpresa.nombre, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 20);
                graphic.DrawString(Globals.logEmpresa.direccion, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 40);
                graphic.DrawString("TUCUPITA - EDO. DELTA AMACURO", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 60);
                graphic.DrawString("TLF: " + Globals.logEmpresa.telefono, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 80);

                graphic.DrawString(" ", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 100);
                string Cliente = "";
                if (one.cliente_nombre.Length < 31)
                {
                    Cliente = one.cliente_nombre;
                }
                else
                {
                    Cliente = one.cliente_nombre.Substring(0, 31);
                }

                graphic.DrawString("CLIENTE: " + Cliente, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 120);
                graphic.DrawString("RIF: " + one.cliente_rif, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 140);
                graphic.DrawString("REF: *01556901", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 160);
                graphic.DrawString("USU: VENTAS VEN: 01", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 180);


                graphic.DrawString(one.tipo_documento_nombre + ": " + one.nro_control, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 200);
                graphic.DrawString("FECHA: " + one.fecha, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 220);
                graphic.DrawString("----------------------------------------", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + 240);



                //DETAIL
                foreach (App.VntOperacionService.InvMovimiento item in _listaDetalle)
                {
                    string linea = "";
                    if (item.cantidad > 1)
                    {
                        linea = item.cantidad.ToString("N2") + " " + item.producto_unidad + " x Bs. " + item.precio_moneda.ToString("N2");
                        graphic.DrawString(linea, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);
                        offset += 20;
                    }

                    int espacios = 26 - item.producto_nombre.Length;

                    string elProd = "";
                    if (espacios > 0)
                    {
                        elProd = item.producto_nombre;

                        for (int i = 0; i <= espacios; i++)
                        {
                            elProd += " ";
                        }
                    }
                    else
                    {
                        elProd = item.producto_nombre.Substring(0, 26);
                    }

                    string elMonto = "Bs " + item.monto_moneda.ToString("N2");

                    graphic.DrawString(elProd + " " + elMonto, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);
                    offset += 20;
                    graphic.DrawString("----------------------------------------", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);
                }

                //FOOTER
                int    miMargen = 0;
                string miTexto  = "";

                offset  += 20;
                miTexto  = "EXENTO Bs: " + FillString(montoExento.ToString("N2"), 13);
                miMargen = 39 - miTexto.Length;
                graphic.DrawString("".PadRight(40 - miTexto.Length) + miTexto, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);

                offset  += 20;
                miTexto  = "BASE IMPONIBLE Bs: " + FillString(montoBase.ToString("N2"), 13);
                miMargen = 39 - miTexto.Length;
                graphic.DrawString("".PadRight(40 - miTexto.Length) + miTexto, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);

                offset  += 20;
                miTexto  = "TOTAL IVA Bs: " + FillString(montoIva.ToString("N2"), 13);
                miMargen = 39 - miTexto.Length;
                graphic.DrawString("".PadRight(40 - miTexto.Length) + miTexto, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);

                offset  += 20;
                miTexto  = "TOTAL Bs: " + FillString(one.total_moneda.ToString("N2"), 13);
                miMargen = 39 - miTexto.Length;
                graphic.DrawString("".PadRight(40 - miTexto.Length) + miTexto, new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);

                offset = offset + 40;
                graphic.DrawString("        GRACIAS POR SU COMPRA!", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);
                offset = offset + 40;

                graphic.DrawString(" ", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);
                offset = offset + 20;
                graphic.DrawString(" ", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);
                offset = offset + 20;
                graphic.DrawString(" ", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);
                offset = offset + 20;
                graphic.DrawString(" ", new Font("Courier New", 18), new SolidBrush(Color.Black), startX, startY + offset);
            };
            try
            {
                printDocument.Print();
            }
            catch (Exception ex)
            {
                throw new Exception("Ocurrió un error al intentar imprimir, ", ex);
            }
            printDocument.Print();
        }