Esempio n. 1
0
        public static void DoPrintJob(ArrayList arShopDetails, ArrayList arItemList, ArrayList arVatChange)
        {
            var printerName = ConfigurationManager.AppSettings["PrinterName"].ToString();

            printerName = "EPSON TM-T20II Receipt";

            try
            {
                byte[] DrawerOpen5 = { 0xA };

                char   V          = 'a';
                byte[] DrawerOpen = { 0x1B, Convert.ToByte(V), 1 };
                RawPrinterHelper.DoSomeThing(printerName, DrawerOpen);

                V = '!';
                byte[] DrawerOpen1 = { 0x1B, Convert.ToByte(V), 0 };
                RawPrinterHelper.DoSomeThing(printerName, DrawerOpen1);

                for (int i = 0; i < arShopDetails.Count; i++)
                {
                    RawPrinterHelper.SendStringToPrinter(printerName, arShopDetails[i].ToString());
                    RawPrinterHelper.DoSomeThing(printerName, DrawerOpen5); //LINE FEED
                }


                V = 'd';
                byte[] DrawerOpen2 = { 0x1B, Convert.ToByte(V), 3 };
                RawPrinterHelper.DoSomeThing(printerName, DrawerOpen2);

                V = 'a';
                byte[] DrawerOpen3 = { 0x1B, Convert.ToByte(V), 0 };
                RawPrinterHelper.DoSomeThing(printerName, DrawerOpen3);

                V = '!';
                byte[] DrawerOpen4 = { 0x1B, Convert.ToByte(V), 1 };
                RawPrinterHelper.DoSomeThing(printerName, DrawerOpen4);

                for (int i = 0; i < arItemList.Count; i++)
                {
                    RawPrinterHelper.SendStringToPrinter(printerName, arItemList[i].ToString());
                    RawPrinterHelper.DoSomeThing(printerName, DrawerOpen5); //LINE FEED
                }


                for (int i = 0; i < arVatChange.Count; i++)
                {
                    if (i == 0)
                    {
                        V = '!';
                        byte[] DrawerOpen6 = { 0x1B, Convert.ToByte(V), 17 };
                        RawPrinterHelper.DoSomeThing(printerName, DrawerOpen6);
                    }

                    RawPrinterHelper.SendStringToPrinter(printerName, arVatChange[i].ToString());
                    RawPrinterHelper.DoSomeThing(printerName, DrawerOpen5); //LINE FEED


                    if (i == 0)
                    {
                        V = '!';
                        byte[] DrawerOpen7 = { 0x1B, Convert.ToByte(V), 0 };
                        RawPrinterHelper.DoSomeThing(printerName, DrawerOpen7);
                    }
                }

                RawPrinterHelper.DoSomeThing(printerName, DrawerOpen5); //LINE FEED
                RawPrinterHelper.DoSomeThing(printerName, DrawerOpen5); //LINE FEED

                RawPrinterHelper.FullCut(printerName);
                RawPrinterHelper.OpenCashDrawer1(printerName);
            }
            catch (Exception)
            {
                // MessageBox.Show(ex.Message);
            }
        }