Example #1
0
 public void TextoRegimen(string par1)
 {
     ticket = "";
     max    = par1.Length;
     if (max > 40)                                 // **********
     {
         cort   = max - 40;
         parte1 = par1.Remove(40, cort);          // si es mayor que 40 caracteres, lo corta
     }
     else
     {
         parte1 = par1;
     }                                                        // **********
     max = (int)(40 - parte1.Length) / 2;                     // saca la cantidad de espacios libres y divide entre dos
     for (int i = 0; i < max; i++)                            // **********
     {
         ticket += " ";                                       // Agrega espacios antes del texto a centrar
     }                                                        // **********
     ticket += parte1 + "\n";
     RawPrinterHelper.SendStringToPrinter(impresora, ticket); // imprime texto
 }
 public void TextoDerecha(string par1)
 {
     ticket = "";
     max    = par1.Length;
     if (max > 40)                                 // **********
     {
         cort   = max - 40;
         parte1 = par1.Remove(40, cort);           // si es mayor que 40 caracteres, lo corta
     }
     else
     {
         parte1 = par1;
     }                                           // **********
     max = 40 - par1.Length;                     // obtiene la cantidad de espacios para llegar a 40
     for (int i = 0; i < max; i++)
     {
         ticket += " ";                                       // agrega espacios para alinear a la derecha
     }
     ticket += parte1 + "\n";                                 //Agrega el texto
     RawPrinterHelper.SendStringToPrinter(impresora, ticket); // imprime texto
 }
Example #3
0
            public void TextoIzquierda(string texto, bool Justificado = false)                          // agrega texto a la izquierda
            {
                string Alineacion = "\x1B" + "a" + "\x0";

                RawPrinterHelper.SendStringToPrinter(PrinterName, Alineacion); // comando de alineación

                if (Justificado)
                {
                    ticket = AlineaTexto(texto, 40, true, PrinterName);
                }
                else
                {
                    ticket = texto;
                }

                if (isAvanzaLinea)
                {
                    ticket += "\n";
                }

                RawPrinterHelper.SendStringToPrinter(PrinterName, ticket);
            }
Example #4
0
 public void AgregaTotales(string par1, double total)
 {
     max = par1.Length;
     if (max > 25)                                 // **********
     {
         cort   = max - 25;
         parte1 = par1.Remove(25, cort);          // si es mayor que 25 lo corta
     }
     else
     {
         parte1 = par1;
     }                                            // **********
     ticket = parte1;
     parte2 = total.ToString("c");
     max    = 40 - (parte1.Length + parte2.Length);
     for (int i = 0; i < max; i++)                            // **********
     {
         ticket += " ";                                       // Agrega espacios para poner el valor de moneda al final
     }                                                        // **********
     ticket += parte2 + "\n";
     RawPrinterHelper.SendStringToPrinter(impresora, ticket); // imprime texto
 }
        public void SendStringToPrinterTest()
        {
            string szPrinterName = GetCurrentPrinterName();

            if (!string.IsNullOrEmpty(szPrinterName))
            {
                string szString =
                    "^XA\n" +
                    "^FO50,50^ADN,36,20^FDrestoration-printer-test\n" +
                    "^FS\n" +
                    "^XZ\n";

                bool expected = true; // TODO: Initialize to an appropriate value
                bool actual;
                actual = RawPrinterHelper.SendStringToPrinter(szPrinterName, szString);
                Assert.AreEqual(expected, actual, "Failed.  Win32 problem?");
            }
            else
            {
                Assert.Fail("Printer name is unavailable.  No printer installed or selected?");
            }
        }
Example #6
0
        public void printMails()
        {
            try
            {
                foreach (ActiveUp.Net.Mail.Message msg in this.ListMessageInbox)
                {
                    string mailToPrint = this.FormatMailToPrint(msg);
                    RawPrinterHelper.SendStringToPrinter(this.printerName, mailToPrint);
                    msg.StoreToFile("C:/Mytext.txt");

                    if (msg.Attachments != null)
                    {
                        for (int i = 0; i < msg.Attachments.Count; i++)
                        {
                            string directory = Path.Combine(Path.GetTempPath(), Constants.SAVE_FOLDER);

                            if (!Directory.Exists(directory))
                            {
                                Directory.CreateDirectory(directory);
                            }

                            if (msg.Attachments[i] != null)
                            {
                                string fileDirectory = Path.Combine(directory, msg.Attachments[i].Filename);
                                msg.Attachments[i].StoreToFile(fileDirectory);

                                RawPrinterHelper.SendFileToPrinter(this.printerName, fileDirectory);
                                File.Delete(fileDirectory);
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Could not print the mails", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #7
0
        private static void printaj()
        {
            string        printerName = DTsetting.Rows[0]["windows_printer_name"].ToString();
            PrintDocument printDoc    = new PrintDocument();

            printDoc.PrinterSettings.PrinterName = printerName;

            string drawString = _1 + _2 + _3;

            for (int i = 0; i < Convert.ToInt16(DTsetting.Rows[0]["linija_praznih_bottom"].ToString()); i++)
            {
                _5 += Environment.NewLine;
            }

            string ttx = "\r\n" + _1 + _2 + fiskal_tekst + kockice + _3 + _4 + _5;

            ttx = ttx.Replace("č", "c");
            ttx = ttx.Replace("Č", "C");
            ttx = ttx.Replace("ž", "z");
            ttx = ttx.Replace("Ž", "Z");
            ttx = ttx.Replace("ć", "c");
            ttx = ttx.Replace("Ć", "C");
            ttx = ttx.Replace("đ", "d");
            ttx = ttx.Replace("Đ", "D");
            ttx = ttx.Replace("š", "s");
            ttx = ttx.Replace("Š", "S");

            string GS  = Convert.ToString((char)29);
            string ESC = Convert.ToString((char)27);

            string COMMAND = "";

            COMMAND  = ESC + "@";
            COMMAND += GS + "V" + (char)1;

            RawPrinterHelper.SendStringToPrinter(printDoc.PrinterSettings.PrinterName, ttx + COMMAND);
        }
Example #8
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (nudJumlahBayar.Value == 0)
            {
                main.SetMessage("Bayar tidak boleh 0");
                nudBayar.Focus();
                nudBayar.Select(0, 9);
            }
            else if (paymentMethod == "")
            {
                main.SetMessage("Metode harus dipilih");
                nudBayar.Focus();
                nudBayar.Select(0, 9);
            }
            else
            {
                DataTable dt           = ExecuteQuery("SELECT pvcPaymentID FROM PVCSalesPayment WHERE pvcSalesID = " + setPVCSalesID + " ORDER BY pvcPaymentID DESC LIMIT 0, 1");
                string    pvcPaymentID = dt == null ? "0" : dt.Rows.Count == 0 ? "0" : dt.Rows[0]["pvcPaymentID"].ToString();
                pvcPaymentID = (Int32.Parse(pvcPaymentID) + 1) + "";
                int bayar = Convert.ToInt32(nudJumlahBayar.Value);
                //MessageBox.Show("INSERT INTO PVCSalesPayment VALUES (" + setPVCSalesID + ", " + pvcPaymentID + ", '" + bayar + "', now(), '" + paymentMethod + "', 0)");
                ExecuteQuery("INSERT INTO PVCSalesPayment VALUES (" + setPVCSalesID + ", " + pvcPaymentID + ", '" + bayar + "', now(), '" + paymentMethod + "', 0)");

                if (paymentMethod == "CASH")
                {
                    RawPrinterHelper.SendStringToPrinter(@"\\RHY-SERVER-PC\EPSON TM-U220 Receipt", System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, 112, 48, 55, 121 }));
                }

                result = System.Windows.Forms.DialogResult.OK;

                nudJumlahBayar.Value = 0;
                ClearButtonBack();
                paymentMethod = "";
                ViewSalesPVCCreatePayment_Load(sender, e);
            }
        }
        //-----INICIO---SB-VTEX2020---20201222_12:57----
        //public void imp_etiqueta2(string ven_id)
        public void imp_etiqueta2(string ven_id, string tienda_id)
        //-----FIN---SB-VTEX2020---20201222_12:57----
        {
            try
            {
                //-----INICIO---SB-VTEX2020---20201222_12:57----
                //string strGuia = str_etiqueta2(ven_id);
                string strGuia = str_etiqueta2(ven_id, tienda_id);
                //-----FIN---SB-VTEX2020---20201222_12:57----
                if (strGuia.Length == 0)
                {
                    return;
                }

                PrintDocument doc = new PrintDocument();
                doc.PrinterSettings = new PrinterSettings();
                //doc.PrinterSettings.PrinterName = ConfigurationManager.AppSettings["Impresora"].ToString();
                // Impresión de Comandos
                RawPrinterHelper.SendStringToPrinter(Ent_Global._impresora_etiquetas, strGuia);
            }
            catch (Exception)
            {
            }
        }
Example #10
0
        void PrintBill(int BillNo)
        {
            DataRow dr;

            //// RawPrinterHelper printer = new RawPrinterHelper();
            using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString))
                using (DataAccess da = new DataAccess())
                {
                    conn.Open();
                    dr = da.getData(string.Format(@"SELECT PS.*,VT.Description VType,ISNULL(PIN.PlateNo,'') PlateNo,PIN.InTime,PIN.InMiti,POUT.OutTime,POUT.OutMiti,U.UserName, POUT.Interval, POUT.ChargedHours FROM ParkingSales PS 
                                    INNER JOIN Users U ON U.UID = PS.UID
                                    LEFT JOIN ParkingOutDetails POUT  ON PS.PID = POUT.PID AND PS.FYID = POUT.FYID
                                    LEFT JOIN (ParkingInDetails PIN   
                                    LEFT JOIN VehicleType VT ON VT.VTypeID=PIN.VehicleType) ON PS.PID = PIN.PID AND PS.FYID = PIN.FYID
                                    WHERE BillNo = {0} AND PS.FYID = {1}", BillNo, GlobalClass.FYID), conn).Rows[0];
                }
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "           " + GlobalClass.CompanyName + Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "                    " + GlobalClass.CompanyAddress + Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "                Parking Invoice" + Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "Bill No : " + (BillNo + "          ").Substring(0, 10) + "        Date : " + dr["TMiti"] + Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "------------------------------------------------" + Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "Sno. |         Particulars          |  Amount  |" + Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "------------------------------------------------" + Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "1.     " + dr["Description"] + "                    " + GParse.ToDecimal(dr["GrossAmount"]).ToString("#0.00") + "  " + Environment.NewLine, "Receipt");
            // RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "       IN  : " + dr["InTime"] + " " + dr["InMiti"] + "                " + Environment.NewLine, "Receipt");
            //RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "       OUT : " + dr["OutTime"] + " " + dr["OutMiti"] + "                " + Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "------------------------------------------------" + Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "Cashier : " + dr["UserName"] + "(" + dr["TTime"] + ")" + Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, Environment.NewLine, "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, "------------------------------------------------", "Receipt");
            RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, ((char)29).ToString() + ((char)86).ToString() + ((char)1).ToString(), "Receipt");
        }
Example #11
0
    public void TextoExtremos(string par1, string par2)
    {
        max = par1.Length;

        if (max > 18)                                     // **********
        {
            cort   = max - 18;
            parte1 = par1.Remove(18, cort);              // si par1 es mayor que 18 lo corta
        }
        else
        {
            parte1 = par1;
        }

        ticket = parte1;                                 // agrega el primer parametro
        max    = par2.Length;

        if (max > 18)                                     // **********
        {
            cort   = max - 18;
            parte2 = par2.Remove(18, cort);              // si par2 es mayor que 18 lo corta
        }
        else
        {
            parte2 = par2;
        }

        max = 40 - (parte1.Length + parte2.Length);
        for (int i = 0; i < max; i++)
        {
            ticket += " ";
        }

        ticket += parte2 + "\n";                                  // agrega el segundo parametro al final
        RawPrinterHelper.SendStringToPrinter(_impresora, ticket); // imprime texto
    }
Example #12
0
 public void LineasIgual()
 {
     ticket = "========================================\n";   // agrega lineas separadoras =
     RawPrinterHelper.SendStringToPrinter(impresora, ticket); // imprime linea
 }
Example #13
0
 public void LineasAsterisco()
 {
     ticket = "****************************************\n";   // agrega lineas separadoras *
     RawPrinterHelper.SendStringToPrinter(impresora, ticket); // imprime linea
 }
Example #14
0
 public void LineasGuion()
 {
     ticket = "----------------------------------------\n";   // agrega lineas separadoras -
     RawPrinterHelper.SendStringToPrinter(impresora, ticket); // imprime linea
 }
Example #15
0
 public void EncabezadoVenta()
 {
     ticket = "Articulo             ITBIS      VALOR\n";      // agrega lineas de  encabezados
     RawPrinterHelper.SendStringToPrinter(impresora, ticket); // imprime texto
 }
Example #16
0
 public void LineasTotales()
 {
     ticket = "                             -----------\n";;  // agrega lineas de total
     RawPrinterHelper.SendStringToPrinter(impresora, ticket); // imprime linea
 }
Example #17
0
        public void AbreCajon(string impresora)
        {
            string cajon = "\x1B" + "p" + "\x00" + "\x0F" + "\x96";

            RawPrinterHelper.SendStringToPrinter(impresora, cajon);
        }
Example #18
0
        private void cmdImprimir_Click(object sender, EventArgs e)
        {
            DataTable dt      = this.grdItens.BindingSource.DataSource as DataTable;
            DataView  dv      = new DataView(dt, "sel = 1", "", DataViewRowState.CurrentRows);
            int       iQtdeDV = dv.Count;

            if (iQtdeDV == 0)
            {
                MsgBox.Show("Não foram encontrados registros para esta pesquisa."
                            , "Pesquisa"
                            , MessageBoxButtons.OK
                            , MessageBoxIcon.Information);
            }
            else
            {
                string sMensage = string.Empty;
                if (iQtdeDV == 1)
                {
                    sMensage += "Será impresso um documento, você confirma?";
                }
                else
                {
                    sMensage += string.Format("Serão impressos {0} documentos, você confirma?", iQtdeDV);
                }

                DialogResult dr = MsgBox.Show(sMensage
                                              , "Impressão de Duplicatas"
                                              , MessageBoxButtons.YesNo
                                              , MessageBoxIcon.Question);

                if (dr == DialogResult.Yes)
                {
                    bool    bPreview = this.optTela.Checked;
                    Funcoes func;

                    string sfileImpressao = Application.StartupPath + @"\Impressao.txt";
                    string sPorta         = func.Busca_Propriedade("Porta_Padrao_Matricial");

                    foreach (DataRowView row in dv)
                    {
                        if (File.Exists(sfileImpressao))
                        {
                            File.Delete(sfileImpressao);
                        }

                        ERP.NotaFiscal.EmissaoNotaFiscal enf = new ERP.NotaFiscal.EmissaoNotaFiscal(true);
                        enf.Emitir_Duplicata(Convert.ToInt32(row["Nota_Fiscal"]), Convert.ToInt32(row["Numero_Parcela"]), !bPreview);

                        if (!bPreview)
                        {
                            using (StreamReader sr = new StreamReader(sfileImpressao))
                            {
                                RawPrinterHelper.SendStringToPrinter(sPorta, sr.ReadToEnd());
                            }
                        }
                    }

                    //-- Visualiza ou imprime em papel
                    if (bPreview)
                    {
                        CompSoft.Reports.Preview_Matricial pm = new CompSoft.Reports.Preview_Matricial();
                        pm.Visualizar();
                    }
                    else
                    {
                        ((DataTable)this.grdItens.BindingSource.DataSource).Clear();
                        this.cmdImprimir.Visible = false;
                    }
                }
            }
        }
Example #19
0
 public void ImprimirTicket(String impresora)
 {
     RawPrinterHelper.SendStringToPrinter(impresora, linea.ToString());
     linea.Clear();
 }
Example #20
0
        private void ZPLPrintLabelUpacket(string printerName, MyLabel[] labels, int height)
        {
            string labelIdCmd      = string.Empty;
            string labelContentCmd = string.Empty;
            string headTitle       = string.Empty;
            string barcodeNo       = string.Empty;

            foreach (MyLabel label in labels)
            {
                if (label.Id == "ExpressCode")//快递单号
                {
                    barcodeNo += "^FDMA,YF" + label.Text + "^FS";
                }
                else if (label.Id == "packgeinfo")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 30);
                }
                else if (label.Id == "Companyaddr")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "Companyaddr2")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "shopname")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "shoppost")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "shopphone")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "SKU")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "image1")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 30);
                }
                else if (label.Id == "packgecode" || label.Id == "packgecode2")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 60);
                }
                else
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 35);
                }
            }
            #region 打印具有格式的小票
            string content = labelContentCmd               //画图代码
                             + "^XA^LH0,0^PR2,2^MD20^FO0,0"
                                                           //+ headTitle
                                                           //+ "^FO20,80^GB560,0,3^FS"
                             + labelIdCmd                  //Label位置信息
                                                           //+ "^FT180,420^BY3,2.4,50^BKN,N,80,Y,N,a,a"  //BKN,N,150,Y,N,A,A  代表条码
                                                           //+ barcodeNo
                             + "^FO80,120 ^GB145,150,3^FS" //^GC150,5,B^FS 圆
                             + "^FO80,150 ^GB145,2,3^FS"
                             + "^FO80,200 ^GB145,2,3^FS"
                             + "^BY6,1.5,30"
                             + "^FT120,510^BY3,2.4,50^BKN,N,80,Y,N,a,a" //BKN,N,150,Y,N,A,A  代表条码
                             + "^FD" + barcodeNo + "^FS"
                             + "^PQ1,0,1,Y^XZ";
            bool isprintOK = RawPrinterHelper.SendStringToPrinter(printerName, content);
            if (!isprintOK)
            {
                throw new Exception("打印失败!");
            }

            #endregion
        }
Example #21
0
        private void ZPLPrintLabelYmato(string printerName, MyLabel[] labels, int height)
        {
            string labelIdCmd      = string.Empty;
            string labelContentCmd = string.Empty;
            string headTitle       = string.Empty;
            string barcodeNo       = string.Empty;

            foreach (MyLabel label in labels)
            {
                if (label.Id == "ExpressCode")//快递单号
                {
                    barcodeNo += "^FDMA,YF" + label.Text + "^FS";
                }
                else if (label.Id == "OurZipCode")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 30);
                }
                else if (label.Id == "Ourtelephone")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 30);
                }
                else if (label.Id == "MessageForBuyer")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 30);
                }
                else if (label.Id == "MessageForBuyer1")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 30);
                }
                else if (label.Id == "MResponsible")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 30);
                }
                else if (label.Id == "Phone")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "SKU")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "YamtoCompany1")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 30);
                }
                else if (label.Id == "YamtoCompany2")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "YamtoCompany3")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "YamtoCompany4")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 25);
                }
                else if (label.Id == "packgecode2")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 60);
                }
                else if (label.Id == "packgecode3")
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, 60);
                }
                else
                {
                    labelIdCmd      += "^FT" + label.XPos.ToString() + "," + label.YPos.ToString() + "^XG" + label.Id + ",1,1^FS";
                    labelContentCmd += TextToHex(label.Text, label.Id, height);
                }
            }
            #region 打印具有格式的小票
            string content = labelContentCmd                            //画图代码
                             + "^XA^LH0,0^PR2,2^MD20^FO0,0"
                                                                        //+ headTitle
                                                                        //+ "^FO20,80^GB560,0,3^FS"
                             + labelIdCmd                               //Label位置信息
                             + "^FT180,420^BY3,2.4,50^BKN,N,80,Y,N,a,a" //BKN,N,150,Y,N,A,A  代表条码
                             + barcodeNo
                             + "^PQ1,0,1,Y^XZ";
            bool isprintOK = RawPrinterHelper.SendStringToPrinter(printerName, content);
            if (!isprintOK)
            {
                throw new Exception("打印失败!");
            }

            #endregion
        }
Example #22
0
 private bool printLabel(AppSettings appSettings, string zpl)
 {
     return(RawPrinterHelper.SendStringToPrinter(appSettings.PrintNames, zpl));
 }
Example #23
0
        /// <summary>
        /// Print the current label
        /// </summary>
        /// <param name="device">Label</param>
        public void Print(PrinterDevice device)
        {
            string epl = GetEPLCode();

            RawPrinterHelper.SendStringToPrinter(device.QueueName, epl);
        }
Example #24
0
        /// <summary>
        /// ZPL 코드를 라벨발행기로 출력
        /// </summary>
        /// <param name="strPort">발행포트</param>
        /// <param name="strZPL">ZPL내용</param>
        /// <returns></returns>
        public static void PrintZPL(string strPort, string strZPL)
        {
            switch (strPort.Substring(0, 3))
            {
            case "USB":
                RawPrinterHelper.SendStringToPrinter(strPort, strZPL);
                break;

            case "COM":
                SerialPort SP = new System.IO.Ports.SerialPort(strPort, 9600, Parity.None, 8, StopBits.One);
                try
                {
                    SP.Open();
                }
                catch (Exception ex)
                {
                    return;
                }
                StringBuilder DataString = new StringBuilder();
                try
                {
                    if (!SP.IsOpen)
                    {
                        SP.Open();
                    }
                }
                catch (Exception ex)
                {
                    return;
                }
                DataString.Append(strZPL);
                try
                {
                    SP.WriteLine(DataString.ToString());
                }
                catch (Exception ex)
                {
                    return;
                }
                break;

            case "LPT":
                TextWriter sw = new StreamWriter(@"C:\ZPL.TXT");
                sw.WriteLine(strZPL);
                sw.Close();

                System.Diagnostics.Process          process   = new System.Diagnostics.Process();
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.FileName         = "CMD.exe";
                startInfo.WorkingDirectory = @"D:\";

                startInfo.UseShellExecute        = false;
                startInfo.RedirectStandardInput  = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.RedirectStandardError  = true;
                startInfo.CreateNoWindow         = true;
                startInfo.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;

                process.EnableRaisingEvents = false;
                process.StartInfo           = startInfo;
                process.Start();
                process.StandardInput.Write(@"COPY C:\ZPL.TXT " + strPort + Environment.NewLine);
                process.StandardInput.Close();

                process.WaitForExit();
                process.Close();
                break;

            case "SCR":
                MsgBox.Show(strZPL, "ZPL 출력 내용", MessageBoxButtons.OK);
                break;

            default:
                RawPrinterHelper.SendStringToPrinter(strPort, strZPL);
                break;
            }
        }
Example #25
0
        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            rcvrNum = txtReceiverNumber.Text;
            string numCopies = numberCopies.Value.ToString();

            rev = txtRevision.Text;



            //Connect to syteline database and command to retrieve Part Number and PO#

            SqlCommand cmd1 = new SqlCommand(@"SELECT rcvr_num, item, ref_num, ref_line
                                            FROM [EM_App].[dbo].[RS_QCRcvr]
                                            Where rcvr_num = @RCVRNUM", con);

            cmd1.Parameters.AddWithValue("@RCVRNUM", rcvrNum);



            con.Open();
            SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
            DataTable      dt1 = new DataTable();

            da1.Fill(dt1);

            // Check to see if receiver number returned information
            if (dt1.Rows.Count > 0)
            {
                string PN     = dt1.Rows[0][1].ToString();
                string PO     = dt1.Rows[0][2].ToString();
                string POline = dt1.Rows[0][3].ToString();



                //--------------------------Logic for printing from a Zebra------------------------

                //string s = $"^XA^PW700\n^FO250,50^ADN,30,20^FDBI ACCEPTED^FS\n^FO0,150^ADN,90,40^FDPN:{PN}^FS\n^FO0,250^ADN,50,30^FDPO#:{PO}^FS\n^FO0,310^ADN,90,30^FDDate:{time}^FS\n^FO0,410^ADN,50,30^FDINSP:{Username.Substring(0,2)}^FS\n^FO0,470^ADN,90,30^FDREV:{rev}^FS\n^XZ";

                string s = $"^XA^PW609^LL406\n" +
                           $"^FO205,20^CF0,40,40^FDBI ACCEPTED^FS\n" +
                           $"^FO10,100^CF0,60,40^FDPN:^FS\n" +
                           $"^FO80,60^CF0,120,60^FD{PN}^FS\n" +
                           $"^FO10,160^CF0,30,25^FDPO#:^FS\n" +
                           $"^FO10,220^FDREV:^FS\n" +
                           $"^FO10,280^FDDATE:^FS\n" +
                           $"^FO10,340^FDINSP:^FS\n" +
                           $"^FO80,340^FD{Username.Substring(0, 2).ToUpper()}^FS\n" +
                           $"^FO80,200^CF0,60,60^FD{rev}^FS\n" +
                           $"^FO80,270^FD{DateTime.Today.ToString("MM/dd/yyyy")}^FS\n" +
                           $"^FO80,160^CF0,30,25^FD{PO}^FS\n" +
                           $"^PQ{numCopies}\n" +
                           $"^XZ";


                PrintDialog pd = new PrintDialog();
                pd.PrinterSettings = new PrinterSettings();
                if (DialogResult.OK == pd.ShowDialog(this))
                {
                    RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s);
                }

                //------------------Logic for printing from a DYNO-------------
                //lbl.SetObjectText("lblFirstName", PN);
                //lbl.SetObjectText("lblLastName", PO);
                //lbl.Print("DYMO LabelWriter 450 Turbo");
            }
            else//if receiver number didnt return results
            {
                Console.WriteLine($"Receiver Number {rcvrNum} not found");
                MessageBox.Show("Receiver Number " + rcvrNum + " was not found", "ERROR");
            }
            con.Close();
            txtRevision.Clear();
            txtReceiverNumber.Clear();
            txtReceiverNumber.Focus();
        }
Example #26
0
        private void printaj()
        {
            string        printerName = DTsetting.Rows[0]["windows_printer_name"].ToString();
            PrintDocument printDoc    = new PrintDocument();

            printDoc.PrinterSettings.PrinterName = printerName;

            //byte[] codeOpenCashDrawer = new byte[] { 27, 112, 48, 55, 121 };
            //IntPtr pUnmanagedBytes = new IntPtr(0);
            //pUnmanagedBytes = Marshal.AllocCoTaskMem(5);
            //Marshal.Copy(codeOpenCashDrawer, 0, pUnmanagedBytes, 5);
            //RawPrinterHelper.SendBytesToPrinter(printDoc.PrinterSettings.PrinterName, pUnmanagedBytes, 5);
            //Marshal.FreeCoTaskMem(pUnmanagedBytes);

            for (int i = 0; i < Convert.ToInt16(DTsetting.Rows[0]["linija_praznih_bottom"].ToString()); i++)
            {
                tekst += Environment.NewLine;
            }

            if (DTpostavke.Rows[0]["direct_print"].ToString() == "1")
            {
                string ttx = "\r\n" + tekst;
                ttx = ttx.Replace("č", "c");
                ttx = ttx.Replace("Č", "C");
                ttx = ttx.Replace("ž", "z");
                ttx = ttx.Replace("Ž", "Z");
                ttx = ttx.Replace("ć", "c");
                ttx = ttx.Replace("Ć", "C");
                ttx = ttx.Replace("đ", "d");
                ttx = ttx.Replace("Đ", "D");
                ttx = ttx.Replace("š", "s");
                ttx = ttx.Replace("Š", "S");

                string GS  = Convert.ToString((char)29);
                string ESC = Convert.ToString((char)27);

                string COMMAND = "";
                COMMAND  = ESC + "@";
                COMMAND += GS + "V" + (char)1;

                RawPrinterHelper.SendStringToPrinter(printDoc.PrinterSettings.PrinterName, ttx + COMMAND);
            }
            else
            {
                if (!printDoc.PrinterSettings.IsValid)
                {
                    string msg = string.Format(
                        "Can't find printer \"{0}\".", printerName);
                    MessageBox.Show(msg, "Print Error");
                    return;
                }
                printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
                printDoc.Print();
            }

            //string GS = Convert.ToString((char)29);
            //string ESC = Convert.ToString((char)27);

            //string COMMAND = "";
            //COMMAND = ESC + "@";
            //COMMAND += GS + "V" + (char)1;

            //RawPrinterHelper.SendStringToPrinter(printDoc.PrinterSettings.PrinterName, COMMAND);
        }
 public void EncabezadoVenta()
 {
     //ticket = "Articulo        Can    P.Unit    Importe\n";   // agrega lineas de  encabezados
     ticket = "Cant       Articulo              Importe\n";   // agrega lineas de  encabezados
     RawPrinterHelper.SendStringToPrinter(impresora, ticket); // imprime texto
 }
Example #28
0
    public static void Imprimir(int _numped, int _count, String _host)
    {
        /*    DadosEtiqueta etiq = SqlSv.getDadosEtiqueta(_numped);
         *
         *  System.IntPtr lhPrinter = new System.IntPtr();
         *  DOCINFO di = new DOCINFO();
         *  int pcWritten = 0;
         *  string st1;
         *  // text to print with a form feed character
         *
         *  di.pDocName = "my test document";
         *  di.pDataType = "RAW";
         *
         *  //lhPrinter contains the handle for the printer opened
         *  //If lhPrinter is 0 then an error has occured
         * //   PrintDirect.OpenPrinter("\\\\"+_host+"\\Etiq", ref lhPrinter, 0);
         *  PrintDirect.OpenPrinter("\\\\hspmcac005\\Etiq", ref lhPrinter, 0);
         *  PrintDirect.StartDocPrinter(lhPrinter, 1, ref di);
         *  PrintDirect.StartPagePrinter(lhPrinter);
         * //   for (int i = 0; i < _count; i++)
         *  {
         *      try
         *      {
         *          st1 = "HSPM - CENTRO DIAGNOSTICO\r\n\n";
         *          PrintDirect.WritePrinter(lhPrinter, st1, st1.Length, ref pcWritten);
         *
         *          st1 = "PEDIDO: " + etiq.Numped.ToString() + "\r\n";
         *          PrintDirect.WritePrinter(lhPrinter, st1, st1.Length, ref pcWritten);
         *          if (etiq.CodTipId == 1)
         *              st1 = "RH: " + etiq.Id.ToString() + "\r\n";
         *          else
         *              st1 = "BE: " + etiq.Id.ToString() + "\r\n";
         *          PrintDirect.WritePrinter(lhPrinter, st1, st1.Length, ref pcWritten);
         *
         *          st1 = "NOME: " + etiq.Nome + "\r\n";
         *          PrintDirect.WritePrinter(lhPrinter, st1, st1.Length, ref pcWritten);
         *
         *          st1 = "DATA: " + etiq.Dt.ToShortDateString() + "\r\n";
         *          PrintDirect.WritePrinter(lhPrinter, st1, st1.Length, ref pcWritten);
         *
         *          st1 = etiq.Procedencia + "\n\n\n\n";
         *          PrintDirect.WritePrinter(lhPrinter, st1, st1.Length, ref pcWritten);
         *
         *      }
         *      catch (Exception e)
         *      {
         *          Console.WriteLine(e.Message);
         *      }
         *  }
         *  PrintDirect.EndPagePrinter(lhPrinter);
         *  PrintDirect.EndDocPrinter(lhPrinter);
         *  PrintDirect.ClosePrinter(lhPrinter);
         * }*/
        DadosEtiqueta etiq = SqlSv.getDadosEtiqueta(_numped);

        StringBuilder st1 = new StringBuilder();

        for (int i = 0; i < _count; i++)
        {
            st1.Append("   HSPM - CENTRO DIAGNOSTICO\r\n\n");


            st1.Append("PEDIDO: " + etiq.Numped.ToString() + "      ");

            if (etiq.CodTipId == 1)
            {
                st1.Append("RH: " + etiq.Id.ToString() + "\r\n");
            }
            else
            {
                st1.Append("BE: " + etiq.Id.ToString() + "\r\n");
            }

            if (etiq.Nome.Length > 31)
            {
                etiq.Nome = etiq.Nome.Substring(0, 24);
            }
            st1.Append("NOME: " + etiq.Nome + "\r\n");


            st1.Append("DATA: " + etiq.Dt.ToShortDateString() + "\r\n");

            st1.Append("EXAME: " + etiq.TipExm + "\r\n");
            if (etiq.Procedencia.Length > 31)
            {
                etiq.Procedencia = etiq.Procedencia.Substring(0, 30);
            }
            st1.Append(etiq.Procedencia + "\n\n\n");
        }

        RawPrinterHelper.SendStringToPrinter("\\\\" + _host + "\\etiq", st1.ToString());
    }
Example #29
0
 public void Post(PrintJob printJob)
 {
     RawPrinterHelper.SendStringToPrinter(printJob.printerName, printJob.labelContent);
 }
        public override void DoPrint(string[] lines)
        {
            var text = string.Join(Environment.NewLine, lines);

            RawPrinterHelper.SendStringToPrinter(Printer.ShareName, text + Environment.NewLine);
        }