Esempio n. 1
0
        //GS k Print barcode
        //<Function A>
        public bool printBarcode(string szPrinterName, string data, int type = 2)
        { //for this example 2 = JAN/EAN13
            int[] barcode = { 29, 107, type };
            ElginI9.SendBytesToPrinter(szPrinterName, intTobyte(barcode));

            ElginI9.SendStringToPrinter(szPrinterName, data);
            int[] nul = { 0 }; // null char at the end.
            ElginI9.SendBytesToPrinter(szPrinterName, intTobyte(nul));
            return(true);
        }
Esempio n. 2
0
        //GS k Print Barcode
        // <Function B>
        public bool printBarcodeB(String szPrinterName, string data, int type = 73)
        {                                //for this example 73 = CODE128
            int size = (int)data.Length; //  the number of bytes of bar code data

            int[] barcode = { 29, 107, type, size };
            ElginI9.SendBytesToPrinter(szPrinterName, intTobyte(barcode));
            ElginI9.SendStringToPrinter(szPrinterName, data);


            return(true);
        }
Esempio n. 3
0
        //*************************** barcode  commands **********************************



        //function to print Qrcode
        public bool printQrcode(String Strdata, String szPrinterName)
        {
            int length = Strdata.Length + 3; //  string size  + 3
                                             //int length = Strdata.Length;
            byte length_low_byte = 0, length_high_byte = 0;

            length_low_byte  = (byte)(length & 0xff);        //low byte used in function 180
            length_high_byte = (byte)((length >> 8) & 0xff); //high byte in function 180


            //if you don't want to use shift operator:
            //int length_low_byte = length % 256;
            //int length_high_byte = length / 256;


            initializePrinter(szPrinterName);

            //<Function ESC a n> Select justification
            int[] escAn = { 27, 97, 0 };
            ElginI9.SendBytesToPrinter(szPrinterName, intTobyte(escAn));



            //<Function GS L> Set left margin
            int[] fGsl = { 29, 76, 0, 0 };
            ElginI9.SendBytesToPrinter(szPrinterName, intTobyte(fGsl));

            //<Function 165> GS ( k p L p H cn fn n (cn = 49,fn = 65)  QR Code: Select the model
            int[] f165 = { 29, 40, 107, 4, 0, 49, 65, 50, 0 };
            ElginI9.SendBytesToPrinter(szPrinterName, intTobyte(f165));


            //<Function 167> GS ( k pL pH cn fn n (cn = 49, fn = 67) QR Code: Set the size of module
            int[] f167 = { 29, 40, 107, 3, 0, 49, 67, 4 }; //  size of qrcode:  1-16
            ElginI9.SendBytesToPrinter(szPrinterName, intTobyte(f167));



            //<Function 169> GS ( k pL pH cn fn n (cn = 49, fn = 69) QR Code: Select the error correction level
            int[] f169 = { 29, 40, 107, 3, 0, 49, 69, 48 };
            ElginI9.SendBytesToPrinter(szPrinterName, intTobyte(f169));


            //<Function 180> GS ( k pL pH cn fn m d1…dk (cn = 49, fn = 80) QR Code: Store the data in the symbol storage area
            //pL and pH are the low- and high-order bytes of a 16-bit integer value that specifies the length in bytes of the following data

            int[] f180 = { 29, 40, 107, length_low_byte, length_high_byte, 49, 80, 48 };
            ElginI9.SendBytesToPrinter(szPrinterName, intTobyte(f180));



            //send string/url to printer
            //ElginI9.SendASCiiToPrinter(szPrinterName, Strdata);
            ElginI9.SendStringToPrinter(szPrinterName, Strdata);

            //<Function 181> GS ( k pL pH cn fn m (cn = 49, fn = 81) QR Code: Print the symbol data in the symbol storage area
            int[] f181 = { 29, 40, 107, 3, 0, 49, 81, 48 };
            ElginI9.SendBytesToPrinter(szPrinterName, intTobyte(f181));

            //


            return(true);
        }
Esempio n. 4
0
        public void ImprimirNaoFiscal(int IdVenda, string ImpNome)
        {
            StringBuilder Cupom = new StringBuilder();

            Cupom.AppendLine("              DOCUMENTO NÃO FISCAL              ");
            try
            {
                // Busca Venda
                SqlDataReader DadosCliente = Controle.ConsultaSQL("SELECT T2.CNPJCPF,T2.PESSOA,T2.ENDERECO,T2.NUMERO,T2.BAIRRO,T2.VLRDESCONTO,T3.REFERENCIA,T3.DESCRICAO,T3.SITTRIBUTARIA,T3.ICMSISS,T1.QTDE,T1.VLRUNITARIO FROM MVVENDAITENS T1 " +
                                                                  " LEFT JOIN MVVENDA T2 ON (T2.ID_VENDA=T1.ID_VENDA)  LEFT JOIN PRODUTOS T3 ON (T3.ID_PRODUTO=T1.ID_PRODUTO) WHERE T1.ID_VENDA=" + IdVenda.ToString());
                SqlDataReader Venda = Controle.ConsultaSQL("SELECT T2.CNPJCPF,T2.PESSOA,T2.ENDERECO,T2.NUMERO,T2.COMPLEMENTO,T2.BAIRRO,T2.VLRDESCONTO,T2.CREDITO,T3.REFERENCIA,T3.DESCRICAO,T3.SITTRIBUTARIA,T3.ICMSISS,T1.QTDE,T1.VLRUNITARIO,T1.VLRTOTAL AS TOTALITEM, T2.VLRTOTAL AS VLRVENDA,T2.VLRSUBTOTAL,T1.ID_PRODUTO,T3.NCM,T1.ID_VENDA,T3.UNIDADE FROM MVVENDAITENS T1 " +
                                                           " LEFT JOIN MVVENDA T2 ON (T2.ID_VENDA=T1.ID_VENDA)  LEFT JOIN PRODUTOS T3 ON (T3.ID_PRODUTO=T1.ID_PRODUTO) WHERE T1.ID_VENDA=" + IdVenda.ToString());
                SqlDataReader Pag = Controle.ConsultaSQL("SELECT T1.VLRORIGINAL,T2.ID_DOCUMENTO,T2.DOCUMENTO,T2.CODECF FROM LANCFINANCEIRO T1 LEFT JOIN TIPODOCUMENTO T2 ON (T2.ID_DOCUMENTO=T1.ID_TIPODOCUMENTO)  WHERE T1.ID_VENDA=" + IdVenda.ToString());

                //Inicializando Cupom
                DadosCliente.Read();
                try
                {
                    Cupom.AppendLine("     Data:" + DateTime.Now.Date.ToShortDateString() + "   No. Venda:" + IdVenda.ToString());
                    if (DadosCliente.HasRows)
                    {
                        Cupom.AppendLine("CPF/CNPJ: " + DadosCliente["CNPJCPF"].ToString().Trim());
                        Cupom.AppendLine("Cliente.: " + Controle.Space(DadosCliente["PESSOA"].ToString().Trim(), 30));
                    }

                    decimal VlrDesconto = 0;
                    decimal VlrVenda    = 0;
                    decimal TVlrItem    = 0;
                    int     Item        = 1;
                    Cupom.AppendLine("Item  Ref    Descrição");
                    Cupom.AppendLine("  Qtde.   Und.      Vlr.Unt         Vlr.Total");
                    Cupom.AppendLine("------------------------------------------------");
                    while (Venda.Read())
                    {
                        VlrDesconto = decimal.Parse(Venda["VLRDESCONTO"].ToString()) + decimal.Parse(Venda["CREDITO"].ToString());
                        VlrVenda    = decimal.Parse(Venda["VLRVENDA"].ToString());

                        Cupom.AppendLine(Controle.Space(Item.ToString(), 4) + " " + Controle.Space(Venda["REFERENCIA"].ToString().Trim(), 7) + Controle.Space(Venda["DESCRICAO"].ToString().Trim(), 25));

                        Cupom.AppendLine(Controle.NumSpace(string.Format("{0:N0}", decimal.Parse(Venda["Qtde"].ToString())).ToString(), 6) + "    " + Controle.Space(Venda["UNIDADE"].ToString().Trim(), 3) + "    " + Controle.NumSpace(string.Format("{0:N2}", decimal.Parse(Venda["VLRUNITARIO"].ToString())).ToString(), 10) + "         " + Controle.NumSpace(string.Format("{0:N2}", decimal.Parse(Venda["TOTALITEM"].ToString())).ToString(), 10));

                        TVlrItem = decimal.Parse(Venda["VlrUnitario"].ToString()) * decimal.Parse(Venda["QTDE"].ToString());
                        Item++;
                    }
                    Cupom.AppendLine("------------------------------------------------");
                    Cupom.AppendLine("                   (+) Sub Total R$:" + Controle.NumSpace(string.Format("{0:N2}", VlrVenda + VlrDesconto).ToString(), 10));
                    Cupom.AppendLine("                   (-) Desconto  R$:" + Controle.NumSpace(string.Format("{0:N2}", VlrDesconto).ToString(), 10));
                    Cupom.AppendLine("                                    -----------");
                    Cupom.AppendLine("                   (=) Total     R$:" + Controle.NumSpace(string.Format("{0:N2}", VlrVenda).ToString(), 10));
                    Cupom.AppendLine("------------------------------------------------");
                    Cupom.AppendLine("Documento sem valor Fiscal");
                    Cupom.AppendLine(" ");
                    Cupom.AppendLine(" ");
                    Cupom.AppendLine(" ");
                    Cupom.AppendLine(" ");
                    Cupom.AppendLine(" ");
                    Cupom.AppendLine(" ");
                    Cupom.AppendLine(" ");
                    Cupom.AppendLine(" ");
                    ElginI9.SendStringToPrinter(ImpNome, Cupom.ToString());
                }
                catch
                {
                    return;
                }
            }
            catch (Exception a)
            {
            }
        }