public static void printReceipt(string receiptType, double dolars, double pesos, double exchangeRate) { PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); byte[] BytesValue = Encoding.ASCII.GetBytes(" "); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.DoubleHeight2()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Centro Cambiario San Pedro\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Recibo del cliente\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("-----------------------------\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(DateTime.Now.ToString() + "\n")); if (receiptType == "buy") { BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Compra de Dolares\n")); } else { BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Venta de Dolares\n")); } BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Dolares: $ " + string.Format("{0:#,##0.00}", double.Parse(dolars.ToString())) + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Pesos: $ " + string.Format("{0:#,##0.00}", double.Parse(pesos.ToString())) + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Tipo de cambio: " + string.Format("{0:#,##0.00}", double.Parse(exchangeRate.ToString())) + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("-----------------------------\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(" \n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("\n\n\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, cutPage()); PrintReceipt(BytesValue); }
static void Main(string[] args) { Console.WriteLine("Prepare for test.. Press one key"); Console.ReadKey(); PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); StreamReader sr = new StreamReader(@"C:\logo\58mmWidth.prn"); Image newImage = Image.FromFile(@"c:\logo\logo.bmp"); //var BytesValue = ImageToByteArray(newImage); //var BytesValue = ReadAllBytes(@"c:\photo\logo.bmp"); byte[] BytesValue = Encoding.ASCII.GetBytes("Sier Group 1 22 333 4444"); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Sier Group 1 22 333 4444\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Sier Group 1 22 333 4444\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontC()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.DoubleWidth4()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Sier Group 1 22 333 4444\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Lf()); BytesValue = PrintExtensions.AddBytes(BytesValue, CutPage()); PrinterUtility.PrintExtensions.Print(BytesValue, "COM7"); Console.WriteLine("Hope it went well.. Bye"); Console.ReadKey(); //Printer printer = new Printer("Thermal Printer"); //printer.TestPrinter(); //printer.FullPaperCut(); //printer.PrintDocument(); }
private byte[] GenerateReceipt(Receipt receipt) { var togLogoPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\Images\\tog-logo.png"; PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); var BytesValue = Encoding.ASCII.GetBytes(string.Empty); BytesValue = PrintExtensions.AddBytes(BytesValue, ImageToByteArray(togLogoPath)); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.DoubleWidth6()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("TOG Connection Pte Ltd\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("201 Victoria Street .#05-04\n\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("SINGAPORE - 188067\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Phone: 66341967\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("E-mail: [email protected]\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("GST Reg No: 201229862H\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes($"Bill No: {receipt.BillNo} Date: {receipt.CreatedDate.ToString("dd/MM/yyyy")}\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes($"Cashier: {receipt.CashierName} Couter: {receipt.CounterName}\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("No Itm Qty Net Total\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); if (receipt.Items.Any()) { foreach (var item in receipt.Items) { BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0}{1,-40}{2,6}{3,9}{4,9:N2}\n", item.No, item.Name, item.Quantity, item.Price, item.Amount)); } } BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes($" Total Amount: {receipt.TotalAmount}\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes($" (GST S$ {receipt.GTSAmount} Inclusive)\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes($" Net Qty: {receipt.NetQuantity} Net Total: {receipt.NetTotal}\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes($"Retain Your Receipt for Exchange within {receipt.ExchangeDayQuantity} Days For Selected Items Only!Thanks!Please Come again\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Lf()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.DoubleHeight6()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.BarCode.Code128("12345")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.QrCode.Print("12345", PrinterUtility.Enums.QrCodeSize.Grande)); BytesValue = PrintExtensions.AddBytes(BytesValue, "-------------------Thank you for coming------------------------\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); BytesValue = PrintExtensions.AddBytes(BytesValue, CutPage()); return(BytesValue); }
private void print() { PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); String sep = "\n------------------------------\n"; var bytes = logo(); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontA()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.Alignment.Center()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(sep)); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" _ _ _______ __ __ \n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" | | | |__ __| \\/ |\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" | |__| | | | | \\ / |\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" | __ | | | | |\\/| |\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" | | | | | | | | | |\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" |_| |_| |_| |_| |_|")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(sep)); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("HackTheMidlands4.0\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("Meal Voucher")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(sep)); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("\n" + cmbVendor.Text + "\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("\n" + nudID.Value + "\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(sep)); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontB()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("Valid for one meal only.\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("This voucher is only redeemable at the\nabove vendor. ")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("For more information,\nplease contact one of the organisers.")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontA()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(sep)); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("\n\n\n\n")); if (File.Exists(".\\tmpPrint.print")) { File.Delete(".\\tmpPrint.print"); } File.WriteAllBytes(".\\tmpPrint.print", bytes); IPrinter printer = new Printer(); printer.PrintRawFile("POS-58", ".\\tmpPrint.print"); try { File.Delete(".\\tmpPrint.print"); } catch { } }
public static object[] Print(string table) { _table = table.Split(new string[] { " " }, StringSplitOptions.None)[0]; // 判斷是否同日 if (DateTime.Now.DayOfYear != _todayOfYear) { _todayOfYear = DateTime.Now.DayOfYear; _number = 1; } object[] returnObj = new object[2]; returnObj[0] = false; returnObj[1] = ""; try { /* 中文輸出 */ PrintDocument document = new PrintDocument(); document.PrintPage += OrderDetail_PrintPage; document.DocumentName = "opt"; document.PrinterSettings.PrinterName = GetDefaultPrinter(); document.PrintController = new StandardPrintController(); document.OriginAtMargins = false; document.Print(); PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); byte[] BytesValue = new byte[100]; /* Feed Paper And Cut Page */ //BytesValue = PrinterUtility.PrintExtensions.NewLine(BytesValue, 2); BytesValue = PrinterUtility.PrintExtensions.AddBytes(BytesValue, CutPage()); // TODO 路徑設定方法須實測條碼列印機連線AP後的實際狀況 PrinterUtility.PrintExtensions.Print(BytesValue, $"{GetDefaultPrinter()}"); returnObj[0] = true; } catch (Exception ex) { returnObj[0] = false; returnObj[1] = ex.Message; } finally { _table = string.Empty; } return(returnObj); }
private void printing() { PrinterUtility.EscPosEpsonCommands.EscPosEpson tempObj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); var bytesValue = tempObj.CharSize.DoubleWidth6(); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Center()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.FontSelect.FontC()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Dahab Cafe\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.CharSize.Nomarl()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.CharSize.DoubleWidth4()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Invoice\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.CharSize.DoubleWidth2()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Left()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Date: " + DateTime.Now.ToString() + "\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Table Number: " + selectedTarabyza + "\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Item Quantity Net Total\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); double totalPrice = 0.0; int selectedTarabezaIndex = 0; for (int i = 0; i < salaManager.liveOrders.Count; i++) { if (salaManager.liveOrders[i].tarabyza == selectedTarabyza) { selectedTarabezaIndex = i; // salaManager.liveOrders[i] foreach (var drink in salaManager.liveOrders[i].drinks) { double drinkTotalPrice = double.Parse(drink.Value.amount.ToString()) * double.Parse(drink.Value.price); bytesValue = PrintExtensions.AddBytes(bytesValue, string.Format("{0, -40}{1, 6}{2, 9}{3, 9:N2}\n", drink.Value.name, drink.Value.amount, drink.Value.price, drinkTotalPrice.ToString())); totalPrice += drinkTotalPrice; } break; } } bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Right()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Price : " + salaManager.liveOrders[selectedTarabezaIndex].price.ToString() + "\n")); //bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes(totalPrice.ToString() + "\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Tax : " + salaManager.liveOrders[selectedTarabezaIndex].taxPrice + "\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Service : " + salaManager.liveOrders[selectedTarabezaIndex].servicePrice + "\n")); if (salaManager.liveOrders[selectedTarabezaIndex].discount != 0) { bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Discount : " + salaManager.liveOrders[selectedTarabezaIndex].discount.ToString() + "\n")); //bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Total After Discount : " + salaManager.liveOrders[selectedTarabezaIndex].totalPrice + "\n")); //bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes((totalPrice + "\n")); } bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Total : " + salaManager.liveOrders[selectedTarabezaIndex].totalPrice + "\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Center()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("-------Thanks for Coming-------\n\n\n\n\n\n")); //bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Mina w Mahoraaaaa\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Left()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes(CutPage())); byte[] openDrawer = new byte[5] { (byte)27, (byte)112, (byte)0, (byte)25, (byte)250 }; bytesValue = PrintExtensions.AddBytes(bytesValue, openDrawer); // PrinterUtility.PrintExtensions.Print(bytesValue, Cafe_Template.Properties.Settings.Default.PrinterPath); try { PrinterUtility.PrintExtensions.Print(bytesValue, DataManager.printerPath); } catch { MessageBox.Show("برجاء فحص الطابعة"); } }
private void sell() { //throw new NotImplementedException(); try { if (textBoxTotalAmount.Text != "" && textBoxBalance.Text != "" && textBoxCash.Text != "" || textBox2.Text != "") { getreceiptno(); foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[0].Value != null) { //float available = 0,totalqty; available = Convert.ToInt32(textBox1.Text); //sold = Convert.ToInt32(textBoxQuantity.Text); totalqty = available - qty; getCreditno(); sqlconnectionclass getstatus = new sqlconnectionclass(); DR = getstatus.ReadDB("select count(*) from stockin where productno='" + row.Cells[0].Value + "'"); if (DR.HasRows) { DR.Read(); if (Convert.ToInt32(DR[0]) > 0) { status = 0; } else { status = 1; } } string insertsale = "INSERT INTO [Sales]([ProductNo],[sqty],[sprice],[totalcost],[VAT],[credit_customerID],[credit_no],[unknown],[receiptno],[date])VALUES('" + row.Cells[0].Value + "','" + row.Cells[3].Value + "','" + row.Cells[2].Value + "','" + row.Cells[5].Value + "','" + row.Cells[4].Value + "','" + cust_id + "','" + nextcreditno + "','" + status + "','" + ReceiptNo + "','" + System.DateTime.Now + "')"; new sqlconnectionclass().WriteDB(insertsale); string insertstockcard = "INSERT INTO [Stockcard]([ProductNo] ,[Transaction_Date],[Naration] ,[Qty_in] ,[Qty_out],[Lacation],[System_User],[New_Stock],[Available_Stock],[DateReport],[Timereport]) VALUES('" + row.Cells[0].Value + "','" + System.DateTime.Now + "','Sale of ''" + productname + "','" + '0' + "','" + row.Cells[3].Value + "','Store','" + Form1.UserName + "','" + totalqty + "','" + textBox1.Text + "','" + System.DateTime.Now + "','" + System.DateTime.Now + "')"; new sqlconnectionclass().WriteDB(insertstockcard); if (radioButton2.Checked == true) { string insertcredit = "INSERT INTO credit_sales([credit_no],[credit_customerID],[amount],[description],[user],[date])values('" + nextcreditno + "','" + cust_id + "','" + txtcreditsales.Text + "','being sales of''" + productname + "','" + Form1.UserName + "','" + System.DateTime.Now.ToShortDateString() + "')"; new sqlconnectionclass().WriteDB(insertcredit); creditbalance(); totalbal = Convert.ToInt32(txtcreditsales.Text); bal2 = bal + totalbal; string insertgledger = "INSERT INTO [GLedger]([credit_customerID],[Debit],[Balance],[Date],[user],[Naration])values('" + cust_id + "','" + txtcreditsales.Text + "','" + bal2 + "','" + System.DateTime.Now + "','" + Form1.UserName + "','Being sales of''" + productname + "')"; new sqlconnectionclass().WriteDB(insertgledger); } } } //if(){} /*****======================Begin Print=====================*****/ PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); var BytesValue = Encoding.ASCII.GetBytes(string.Empty); //BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.DoubleWidth2()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); //BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("JOMAT GENERAL HARDWARE\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Dealers in: Hardware e.g Iron sheets, Cement,\n Plywood, Paints, Glassmart, Supply of general\nbuilding materials etc.\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("P.O. BOX 4, NGONG\nNGONG RD-KISERIAN, MATASIA SHOPPING CENTRE\nTEL: 0721-283-402/0724-477-792\nKRA PIN.:A001204489T \n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("RECEIPT\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Receipt No : " + ReceiptNo + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Date : " + System.DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss", CultureInfo.InvariantCulture) + "\n")); //BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("PIN. :A001204489T \n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); //BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Right()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(" Item Qty U. Price VAT Total\n")); //BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(" Name KES KES KES\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); foreach (DataGridViewRow dgv in dataGridView1.Rows) { BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-19}{1,9}{2,9}{3,10}{4,16:N2}\n", dgv.Cells[1].Value, dgv.Cells[3].Value, dgv.Cells[2].Value, dgv.Cells[4].Value, dgv.Cells[5].Value)); } //BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-40}{1,6}{2,9}{3,9:N2}\n", "item 1", 12, 11, 144.00)); //BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-40}{1,6}{2,9}{3,9:N2}\n", "item 2", 12, 11, 144.00)); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Right()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Total: ")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(textBoxTotalAmount.Text + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Cash: ")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(textBoxCash.Text + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Change: ")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(textBoxBalance.Text + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.DoubleWidth2()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Mpesa Till No 524049\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Lf()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); //BytesValue = PrintExtensions.AddBytes(BytesValue, obj.BarCode.Code128("12345")); //BytesValue = PrintExtensions.AddBytes(BytesValue, obj.QrCode.Print("12345", PrinterUtility.Enums.QrCodeSize.Grande)); BytesValue = PrintExtensions.AddBytes(BytesValue, "Goods Once sold cannot be returned\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, "You're served by " + Form1.UserName + "\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, "Designed by Amtech Technologies\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, "Website: www.amtechafrica.com Email: [email protected]\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, "------Thank you for shopping with us-------\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); BytesValue = PrintExtensions.AddBytes(BytesValue, CutPage()); //PrinterUtility.PrintExtensions.Print(BytesValue, EasyPOS.Properties.Settings.Default.printerpath); if (File.Exists(".\\tmpPrint.print")) { File.Delete(".\\tmpPrint.print"); } File.WriteAllBytes(".\\tmpPrint.print", BytesValue); RawPrinterHelper.SendFileToPrinter("Generic / Text Only", ".\\tmpPrint.print"); try { File.Delete(".\\tmpPrint.print"); } catch { } /******END PRINT & Begin collection**********/ PrinterUtility.EscPosEpsonCommands.EscPosEpson obj1 = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); var BytesValue1 = Encoding.ASCII.GetBytes(string.Empty); //BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.CharSize.DoubleWidth2()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.FontSelect.FontA()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.Alignment.Center()); //BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("\n")); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, Encoding.ASCII.GetBytes("JOMAT GENERAL HARDWARE\n")); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.CharSize.Nomarl()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, Encoding.ASCII.GetBytes("Collection RECEIPT\n")); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.CharSize.Nomarl()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.Alignment.Right()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, Encoding.ASCII.GetBytes("Receipt No : " + ReceiptNo + "\n")); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, Encoding.ASCII.GetBytes("Date: " + System.DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss", CultureInfo.InvariantCulture) + "\n")); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, Encoding.ASCII.GetBytes(" Item Qty U. Price VAT Total\n")); //BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); BytesValue = PrintExtensions.AddBytes(BytesValue1, Encoding.ASCII.GetBytes(" Name KES KES KES\n")); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.Separator()); foreach (DataGridViewRow dgv in dataGridView1.Rows) { BytesValue1 = PrintExtensions.AddBytes(BytesValue1, string.Format("{0,-19}{1,9}{2,9}{3,10}{4,16:N2}\n", dgv.Cells[1].Value, dgv.Cells[3].Value, dgv.Cells[2].Value, dgv.Cells[4].Value, dgv.Cells[5].Value)); } BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.Alignment.Right()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.Separator()); //BytesValue1 = PrintExtensions.AddBytes(BytesValue1, Encoding.ASCII.GetBytes("Total: ")); //BytesValue1 = PrintExtensions.AddBytes(BytesValue1, Encoding.ASCII.GetBytes(textBoxTotalAmount.Text + "\n")); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj.Lf()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, "Signed:.............................................\n"); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.Alignment.Center()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, "You're served by " + Form1.UserName + "\n"); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj.Separator()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, "Designed by Amtech Technologies\n"); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, "Website: www.amtechafrica.com Email: [email protected]\n"); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, obj1.Alignment.Left()); BytesValue1 = PrintExtensions.AddBytes(BytesValue1, CutPage()); if (File.Exists(".\\tmpPrint1.print")) { File.Delete(".\\tmpPrint1.print"); } File.WriteAllBytes(".\\tmpPrint1.print", BytesValue1); RawPrinterHelper.SendFileToPrinter("Generic / Text Only", ".\\tmpPrint1.print"); try { File.Delete(".\\tmpPrint1.print"); } catch { } /*********END collector copy****************/ textBoxTotalAmount.Text = "0"; textBoxCash.Text = "0"; textBoxBalance.Text = "0"; } else { MessageBox.Show("Enter Cash Amount"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void buttonPay_Click(object sender, EventArgs e) { string paymode = ""; if (radioButton1.Checked == true) { paymode = "Cash"; } else if (radioButton2.Checked == true) { paymode = "Cheque"; } string pay = "INSERT INTO [creditPayment]([credit_customerID],[BussinessName],[paymentmode],[amount],[balance],[description],[chequeno],[datepay],[duedate],[date],[user])VALUES('" + pid + "','" + cmbBusinessname.Text + "','" + paymode + "','" + textBoxAmount.Text + "','" + txtRemaining.Text + "','Payment of Credit','" + textBoxChequeNo.Text + "','" + datePay.Text + "','" + Duedate.Text + "','" + System.DateTime.Now + "','" + Form1.UserName + "')"; new sqlconnectionclass().WriteDB(pay); string gledger = "INSERT INTO [GLedger]([credit_customerID],[Credit],[Balance],[Date],[user],[Naration])VALUES('" + pid + "','" + textBoxAmount.Text + "','" + txtRemaining.Text + "','" + System.DateTime.Now + "','" + Form1.UserName + "','Credit Payment')"; new sqlconnectionclass().WriteDB(gledger); MessageBox.Show("success"); /*****======================Begin Print=====================*****/ PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); var BytesValue = Encoding.ASCII.GetBytes(string.Empty); //BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.DoubleWidth2()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); //BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("JOMAT GENERAL HARDWARE\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Dealers in: Hardware e.g Iron sheets, Cement,\n Plywood, Paints, Glassmart, Supply of general\nbuilding materials etc.\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("P.O. BOX 4, NGONG\nNGONG RD-KISERIAN, MATASIA SHOPPING CENTRE\nTEL: 0721-283-402/0724-477-792\nKRA PIN.:A001204489T \n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("CREDIT PAYMENT RECEIPT\n")); // BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); // BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Receipt No : " + ReceiptNo + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Date : " + System.DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss", CultureInfo.InvariantCulture) + "\n")); //BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("PIN. :A001204489T \n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Right()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(" MEMBER NAME TOTAL Balance CASH Paid REMAINING\n")); ////BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(" Name KES KES KES\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); //foreach (DataGridViewRow dgv in dataGridView1.Rows) //{ BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,19}{1,9}{2,10}{3,16:N2}\n", cmbBusinessname.Text, balancetxt.Text, textBoxAmount.Text, txtRemaining.Text)); //} //BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-40}{1,6}{2,9}{3,9:N2}\n", "item 1", 12, 11, 144.00)); //BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-40}{1,6}{2,9}{3,9:N2}\n", "item 2", 12, 11, 144.00)); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Right()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Total Balance: ")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(balancetxt.Text + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Cash: ")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(textBoxAmount.Text + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Remaining: ")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(txtRemaining.Text + "\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.DoubleWidth2()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Mpesa Till No 524049\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Lf()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); //BytesValue = PrintExtensions.AddBytes(BytesValue, obj.BarCode.Code128("12345")); //BytesValue = PrintExtensions.AddBytes(BytesValue, obj.QrCode.Print("12345", PrinterUtility.Enums.QrCodeSize.Grande)); // BytesValue = PrintExtensions.AddBytes(BytesValue, "Goods Once sold cannot be returned\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, "You're served by " + Form1.UserName + "\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, "Designed by Amtech Technologies\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, "Website: www.amtechafrica.com Email: [email protected]\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, "------Thank you for shopping with us-------\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); BytesValue = PrintExtensions.AddBytes(BytesValue, CutPage()); //PrinterUtility.PrintExtensions.Print(BytesValue, EasyPOS.Properties.Settings.Default.printerpath); if (File.Exists(".\\tmpPrint.print")) { File.Delete(".\\tmpPrint.print"); } File.WriteAllBytes(".\\tmpPrint.print", BytesValue); RawPrinterHelper.SendFileToPrinter("Generic / Text Only", ".\\tmpPrint.print"); try { File.Delete(".\\tmpPrint.print"); } catch { } }
private void btnPrint_Click(object sender, EventArgs e) { try { Anu_Order order = new Anu_Order(); order.Anu_Order_Id = lblBillNo.Text; order.Anu_Order_OrderDate = Convert.ToDateTime(lblBillDate.Text); var uurn = ""; long unique = 1; var MaxUNIQUE = (from a in _context.Anu_Orders select a).AsEnumerable().Max(p => p.Anu_Order_URNNo); if (MaxUNIQUE != 0) { unique = Convert.ToInt64(MaxUNIQUE) + 1; } uurn = unique.ToString("00000"); order.Anu_Order_URNNo = Convert.ToInt32(uurn); order.Anu_Order_TotalQty = TotalQty; order.Anu_Order_Status = Status.Paid; order.Anu_Order_TotalAmount = Total; order.Anu_Order_Mode = Mode.Cash; order.Anu_Order_IsActive = true; order.Anu_Order_Createdby = SessionMgr.UserId; order.Anu_Order_CreatedDate = DateTime.Now; _context.Anu_Orders.Add(order); _context.SaveChanges(); var cart = _context.Anu_Carts.ToList(); foreach (var item in cart) { var odid = ""; long urn = 1; var MaxURN = (from a in _context.Anu_Order_Details select a).AsEnumerable().Max(p => p.Anu_Order_Detail_Id.Split('-')[1]); if (MaxURN != null) { urn = Convert.ToInt64(MaxURN) + 1; } odid = "AGPODD/" + DateTime.Now.Month + "/" + DateTime.Now.Year + "-" + urn.ToString("0000"); Anu_Order_Detail orderdetail = new Anu_Order_Detail(); orderdetail.Anu_Order_Detail_Id = odid; orderdetail.Anu_Order_Id = order.Anu_Order_Id; orderdetail.Anu_Order_Detail_Discount = Convert.ToDecimal(lblDiscount.Text); orderdetail.Anu_Order_Detail_Qty = item.Anu_cart_Qty; orderdetail.Anu_Order_Detail_Rate = item.Anu_cart_Rate; orderdetail.Anu_Product_Id = item.Anu_Product_Id; orderdetail.Anu_Order_Detail_Type = item.Anu_cart_Type; orderdetail.Anu_Order_Detail_Subtotal = SubTotal; orderdetail.Anu_Order_Detail_ReceivedAmount = Convert.ToDecimal(txtReceived.Text.Trim()); orderdetail.Anu_Order_Detail_RemainingAmount = Convert.ToDecimal(lblRemain.Text); _context.Anu_Order_Details.Add(orderdetail); _context.SaveChanges(); var stock = _context.Anu_Stocks.Include(a => a.stdetail).Where(a => a.Anu_Product_Id.Contains(item.Anu_Product_Id)).SingleOrDefault(); stock.Anu_Stock_Qty = stock.Anu_Stock_Qty - Convert.ToDecimal(item.Anu_cart_Qty); _context.SaveChanges(); Anu_Cart crt = _context.Anu_Carts.Find(item.Anu_Cart_Id); _context.Anu_Carts.Remove(crt); _context.SaveChanges(); } prdCombo.SelectedIndex = 0; txtCat.Text = ""; txtQty.Text = ""; txtRate.Text = ""; lblStock.Text = ""; lblGSt.Text = ""; TypeCombo.SelectedIndex = 0; ////PrintReceipt(lblBillNo.Text); ////printTest(); //Printdoc(); var orderdetails = from a in _context.Anu_Order_Details.Include(aaa => aaa.order).Include(ad => ad.product) where (a.Anu_Order_Id.Contains(lblBillNo.Text)) select a; decimal TotalAmt = _context.Anu_Orders.Where(a => a.Anu_Order_Id == lblBillNo.Text).Select(a => a.Anu_Order_TotalAmount).SingleOrDefault(); PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); var BytesValue = GetLogo(@"C:\Banner.png"); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Cash Bill\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Invoice no.'" + lblBillNo.Text)); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Date.'" + orderdetails.FirstOrDefault().order.Anu_Order_OrderDate)); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Item Qty Amount")); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); //BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-40},{1,6},{2,9},{3,9:N2}\n", "item 1", 12, 11, 144.00)); //BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-40},{1,6},{2,9},{3,9:N2}\n", "item 1", 12, 11, 144.00)); foreach (var item in orderdetails) { BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-40}{1,6}{2,9}{3,9:N2}\n", item.product.Anu_Product_Name, item.Anu_Order_Detail_Qty, item.Anu_Order_Detail_Rate)); } BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Right()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Total")); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(TotalAmt.ToString())); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Lf()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.BarCode.Code128("12345")); BytesValue = PrintExtensions.AddBytes(BytesValue, "-------------------Thanking you------------------\n"); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left()); BytesValue = PrintExtensions.AddBytes(BytesValue, Cutpage()); BytesValue = PrintExtensions.AddBytes(BytesValue, Anugraha.Properties.Settings.Default.PrinterName); Init(); //printTest(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btn_PrintPW_Click(object sender, EventArgs e) { PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); String sep = "\n------------------------------\n"; var bytes = logo(); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontA()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.Alignment.Center()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(sep)); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" _ _ _______ __ __ \n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" | | | |__ __| \\/ |\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" | |__| | | | | \\ / |\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" | __ | | | | |\\/| |\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" | | | | | | | | | |\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(" |_| |_| |_| |_| |_|")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(sep)); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("HackTheMidlands4.0\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("HELPq Mentor")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(sep)); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("\nAccess the mentor system at:\nhelp.hackthemidlands.com\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("\nLogin with the following\nusername and password:\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontB()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("\nUsername:\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontA()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(txtUser.Text + "\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontB()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("Password:\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontA()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(txtPassword.Text + "\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(sep)); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontB()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("Please keep this ticket safe\n(take a picture of it),\nalong with the attached Meal Vouchers.\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("For more information about HELPq,\nplease contact one of the organisers.")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontA()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(sep)); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontB()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes(nudIndex.Text + "\n")); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, obj.FontSelect.FontA()); bytes = PrinterUtility.PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("\n\n\n")); if (File.Exists(".\\tmpPrint.print")) { File.Delete(".\\tmpPrint.print"); } File.WriteAllBytes(".\\tmpPrint.print", bytes); IPrinter printer = new Printer(); printer.PrintRawFile("POS-58", ".\\tmpPrint.print"); try { File.Delete(".\\tmpPrint.print"); nudIndex.Value = nudIndex.Value - 1; updateUserPW((int)nudIndex.Value); } catch { } }
public void getDailyReport() { DataManager.loadOrdersData(); if (typeOfReport == "") { MessageBox.Show("يجب اختيار نوع التقرير"); return; } string dateOfReport = ""; if (checkValideData()) { if (typeOfReport == "daily") { dateOfReport = dayCombo.Text + "/" + monthCombo.Text + "/" + yearCombo.Text; } } if (typeOfReport == "daily") { var orders = DataManager.orders.Where(item => item.Key == dateOfReport).Select(i => i.Value); if (orders.Count() == 0) { MessageBox.Show("لا يوجد تقارير"); return; } PrinterUtility.EscPosEpsonCommands.EscPosEpson tempObj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); var bytesValue = tempObj.CharSize.DoubleWidth6(); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Center()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.FontSelect.FontC()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Dahab Cafe\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.CharSize.Nomarl()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.CharSize.DoubleWidth4()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Report\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.CharSize.DoubleWidth2()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Left()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Date Table Total\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); double totalPrice = 0.0; foreach (var dayOrder in orders) { foreach (var order in dayOrder) { bytesValue = PrintExtensions.AddBytes(bytesValue, string.Format("{0, -40}{1, 6}{2, 9}\n", order.date.ToString(), order.tarabyza, order.totalPrice.ToString())); totalPrice += order.totalPrice; } } bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Right()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Total Price : " + totalPrice.ToString() + "\n\n\n\n\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Left()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes(CutPage())); // PrinterUtility.PrintExtensions.Print(bytesValue, Cafe_Template.Properties.Settings.Default.PrinterPath); try { PrintExtensions.Print(bytesValue, DataManager.printerPath); } catch { MessageBox.Show("برجاء فحص الطابعة"); } var items = StatisticsCalculator.drinksCalculation(dateOfReport); tempObj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); bytesValue = Encoding.ASCII.GetBytes(""); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Center()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.FontSelect.FontC()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Dahab Cafe\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.CharSize.Nomarl()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.CharSize.DoubleWidth4()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Report\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.CharSize.DoubleWidth2()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Left()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("Item Count\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); foreach (var item in items) { bytesValue = PrintExtensions.AddBytes(bytesValue, string.Format("{0, -40}{1, 6}\n", item.Key, item.Value.ToString())); } bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Center()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Separator()); bytesValue = PrintExtensions.AddBytes(bytesValue, tempObj.Alignment.Left()); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes("\n\n\n\n\n\n")); bytesValue = PrintExtensions.AddBytes(bytesValue, Encoding.ASCII.GetBytes(CutPage())); // PrinterUtility.PrintExtensions.Print(bytesValue, Cafe_Template.Properties.Settings.Default.PrinterPath); try { PrintExtensions.Print(bytesValue, DataManager.printerPath); } catch { MessageBox.Show("برجاء فحص الطابعة"); } } }
private void print1_Load(object sender, EventArgs e) { PrinterUtility.EscPosEpsonCommands.EscPosEpson EscPosEpson = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); //var BytesValue ; }
private void btnImprimirVenta_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(this.txtIDCliente.Text)) { MessageBox.Show("Error: Debe seleccionar un cliente."); return; } decimal ventaSoles = decimal.Parse((string.IsNullOrEmpty(this.txtVentaSoles.Text) ? "0.00" : this.txtVentaSoles.Text)); decimal pagoSoles = decimal.Parse((string.IsNullOrEmpty(this.txtPagoSoles.Text) ? "0.00" : this.txtPagoSoles.Text)); if (ventaSoles > pagoSoles) { MessageBox.Show("Monto pago es insuficiente."); } else { var documento = new DocumentoElectronico { Emisor = CrearEmisor(), Receptor = new Contribuyente { NroDocumento = "20100039207", TipoDocumento = "6", NombreLegal = "RANSA COMERCIAL S.A.", Email = "*****@*****.**" }, IdDocumento = "", FechaEmision = dtpFechaHora.Value.ToShortDateString(), Moneda = "PEN", MontoEnLetras = enletras(txtVentaSoles.Text), //"SON CIENTO DIECIOCHO SOLES CON 0/100", CalculoIgv = 0.18m, CalculoIsc = 0.10m, CalculoDetraccion = 0.04m, TipoDocumento = cboFacturaBoleta.SelectedValue.ToString(), TotalIgv = 18, TotalVenta = 118, Gravadas = 100 }; foreach (DataGridViewRow row in grvDetalleVenta.Rows) { documento.Items.Add(new DetalleDocumento { IdDocumento = documento.IdDocumento, //+ i.ToString().PadLeft(8, char.Parse("0")), Id = row.Index + 1, Cantidad = decimal.Parse(row.Cells["Cantidad"].Value.ToString()), PrecioReferencial = decimal.Parse(row.Cells["PUnit"].Value.ToString()), PrecioUnitario = decimal.Parse(row.Cells["PUnit"].Value.ToString()), TipoPrecio = "01", CodigoItem = row.Cells["CodProd"].Value.ToString(), Descripcion = row.Cells["Descripcion"].Value.ToString(), UnidadMedida = row.Cells["UnidMed"].Value.ToString(), Impuesto = 18, TipoImpuesto = (row.Cells["FlgAfectoIGV"].Value.ToString() == "1") ? "10" : "30",// Gravada TotalVenta = decimal.Parse(row.Cells["TotaItem"].Value.ToString()), Suma = decimal.Parse(row.Cells["TotaItem"].Value.ToString()), }); } FirmadoResponse response = FirmadoCPE.Generar(documento); var resumentFirma = response.ResumenFirma; var firma = response.ValorFirma; var mensajeError = response.MensajeError; BE_Comprobante pBE_ComprobanteTMP = new BE_Comprobante() { ID = 0, Str_Tipo_Comprobante = documento.TipoDocumento, Str_Serie_Comprobante = "", Str_Numero_Comprobante = "", Str_Num_Documento_Cliente = documento.Receptor.NroDocumento, Str_Fecha_Hora_Comprobante = documento.FechaEmision, Str_Placa_Comprobante = txtPlaca.Text, Str_Linea_Cred_Soles_Comprobante = txtLineaCredSoles.Text, Str_Cod_Operador = this.txtCodOperador.Text, Str_Cod_Turno = this.txtCodTurno.Text, Str_Tarjeta_Soles_Comprobante = this.txtTarjetaSoles.Text, Str_Linea_Cred_Comprobante = this.txtUsarLineaCred.Text, //Dec_Total_Gravado_Comprobante = decimal.Parse(txtSTGravado.Text), Dec_Total_Gravado_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtSTGravado.Text) ? "0.00" : this.txtSTGravado.Text)), Dec_Total_Gratuito_Comprobante = 0, //Dec_Total_Inafecto_Comprobante = decimal.Parse(txtSTInafecto.Text), Dec_Total_Inafecto_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtSTInafecto.Text) ? "0.00" : this.txtSTInafecto.Text)), Dec_Total_Exonerado_Comprobante = 0, Dec_Dscnto_Global_Comprobante = 0, //Dec_Total_Venta_Soles_Comprobante = decimal.Parse(txtVentaSoles.Text), Dec_Total_Venta_Soles_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtVentaSoles.Text) ? "0.00" : this.txtVentaSoles.Text)), Dec_Total_Igv_Soles_Comprobante = 0, Dec_Total_Isc_Soles_Comprobante = 0, //Dec_Efectivo_Soles_Comprobante = decimal.Parse(txtEfectivoSoles.Text), Dec_Efectivo_Soles_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtEfectivoSoles.Text) ? "0.00" : this.txtEfectivoSoles.Text)), //Dec_Tipo_Cambio_Comprobante = decimal.Parse(txtTipoCambio.Text), Dec_Tipo_Cambio_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtTipoCambio.Text) ? "0.00" : this.txtTipoCambio.Text)), //Dec_Efectivo_Dolares_Comprobante = decimal.Parse(txtEfectivoDolares.Text), Dec_Efectivo_Dolares_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtEfectivoDolares.Text) ? "0.00" : this.txtEfectivoDolares.Text)), //Dec_Pago_Comprobante = decimal.Parse(txtPagoSoles.Text), Dec_Pago_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtPagoSoles.Text) ? "0.00" : this.txtPagoSoles.Text)), //Dec_Vuelto_Comprobante = decimal.Parse(txtVueltoSoles.Text), Dec_Vuelto_Comprobante = decimal.Parse((string.IsNullOrEmpty(this.txtVueltoSoles.Text) ? "0.00" : this.txtVueltoSoles.Text)), Str_Monto_Letras_Comprobante = documento.MontoEnLetras, Str_Hash_Comprobante = resumentFirma, Str_MsjRpta_Comprobante = mensajeError, IDUsuarioCreacion = VariablesGlobales.operador_actual.ID }; pBE_ComprobanteTMP.Listado_Detalle = new List <BE_Comprobante_Detalle>(); foreach (DataGridViewRow row in grvDetalleVenta.Rows) { pBE_ComprobanteTMP.Listado_Detalle.Add(new BE_Comprobante_Detalle() { Str_Cod_Isla = row.Cells["Isla"].Value.ToString(), Str_Cod_Surtidor = row.Cells["Surtidor"].Value.ToString(), Str_Cod_Lados = row.Cells["Cara"].Value.ToString(), Str_Cod_Manguera = row.Cells["Manguera"].Value.ToString(), Str_Cod_Producto = row.Cells["Cara"].Value.ToString(), Dec_Precio_Unitario_DComprobante = decimal.Parse(row.Cells["PUnit"].Value.ToString()), Dec_Cantidad_DComprobante = decimal.Parse(row.Cells["Cantidad"].Value.ToString()), Dec_SubTotal_Gravado_DComprobante = decimal.Parse(row.Cells["STGravado"].Value.ToString()), Dec_SubTotal_Inafecto_DComprobante = decimal.Parse(row.Cells["STInafecto"].Value.ToString()), Dec_SubTotal_Gratuito_DComprobante = 0, Dec_SubTotal_Exonerado_DComprobante = 0, Dec_SubTotal_Item_DComprobante = decimal.Parse(row.Cells["TotaItem"].Value.ToString()), Int_Flg_Agecto_IGV = int.Parse(row.Cells["FlgAfectoIGV"].Value.ToString()), Dec_IGV_Item_DComprobante = decimal.Parse(row.Cells["IGVUnit"].Value.ToString()), Int_Flg_Agecto_ISC = int.Parse(row.Cells["FlgAfectoISC"].Value.ToString()), Dec_ISC_Item_DComprobante = decimal.Parse(row.Cells["ISCUnit"].Value.ToString()), IDUsuarioCreacion = VariablesGlobales.operador_actual.ID }); } int id = BL_Comprobante.Registrar_Comprobante(pBE_ComprobanteTMP); if (id > 0) { if (string.IsNullOrEmpty(GestionCombustibles.Properties.Settings.Default.PrinterPath)) { MessageBox.Show("No hay una impresora configurada."); } else { string xNumComprobante = txtSerieNumero.Text; string xFecha = dtpFechaHora.Value.Day.ToString().PadLeft(2, char.Parse("0")) + "-" + dtpFechaHora.Value.Month.ToString().PadLeft(2, char.Parse("0")) + "-" + dtpFechaHora.Value.Year.ToString().PadLeft(2, char.Parse("0")) + " " + dtpFechaHora.Value.Hour.ToString().PadLeft(2, char.Parse("0")) + ":" + dtpFechaHora.Value.Minute.ToString().PadLeft(2, char.Parse("0")) + ":" + dtpFechaHora.Value.Second.ToString().PadLeft(2, char.Parse("0")); string xSurtidor = cboSurtidor.SelectedValue.ToString(); string xLado = cboCara.SelectedValue.ToString(); string xCodHash = txtCodHash.Text; string xPlaca = txtPlaca.Text; // decimal xTotal = Convert.ToDecimal("00"); decimal xTotal_gravado = Convert.ToDecimal("00"); decimal xTotal_inafecto = Convert.ToDecimal("00"); decimal xTotal_igv = Convert.ToDecimal("00"); decimal xTotal_exonerado = Convert.ToDecimal("00"); decimal xTotal_isc = Convert.ToDecimal("00"); // List <string> xHeader = new List <string>(); xHeader.Add((string.IsNullOrEmpty(VariablesGlobales.empresa.Str_nom_empresa) ? "" : VariablesGlobales.empresa.Str_nom_empresa) + "\n"); xHeader.Add((string.IsNullOrEmpty(VariablesGlobales.empresa.Str_direccion_empresa) ? "" : VariablesGlobales.empresa.Str_direccion_empresa)); xHeader.Add((string.IsNullOrEmpty(VariablesGlobales.empresa.Str_Nom_Distrito) ? "" : VariablesGlobales.empresa.Str_Nom_Distrito) + ", " + (string.IsNullOrEmpty(VariablesGlobales.empresa.Str_Nom_Provincia) ? "" : VariablesGlobales.empresa.Str_Nom_Provincia) + ", " + (string.IsNullOrEmpty(VariablesGlobales.empresa.Str_Nom_Departamento) ? "" : VariablesGlobales.empresa.Str_Nom_Departamento) + "\n"); xHeader.Add("RUC " + (string.IsNullOrEmpty(VariablesGlobales.empresa.Str_num_documento) ? "" : VariablesGlobales.empresa.Str_num_documento) + "\n"); xHeader.Add("----------------------------------------\n"); xHeader.Add("BOLETA DE VENTA ELECTRONICA\n"); xHeader.Add(" " + xNumComprobante + "\n"); xHeader.Add(" " + xFecha + "\n"); xHeader.Add("----------------------------------------\n"); xHeader.Add("POS :" + xSurtidor + " LADO: " + xLado + "\n"); xHeader.Add("----------------------------------------\n"); List <string> xFooter = new List <string>(); xFooter.Add("----------------------------------------\n"); xFooter.Add("Placa del Vehiculo: " + xPlaca + "\n"); xFooter.Add("Cod Has: " + xCodHash + "\n"); xFooter.Add("Autorizado mediante\n"); xFooter.Add("Resolucion Nro.034-005-0006616/SUNAT \n"); xFooter.Add("RUC 20519069262 BOLETA de Venta\n"); xFooter.Add("Electronica, para consultar el\n"); xFooter.Add("documento ingrese a www.facturas.com.pe\n"); xFooter.Add("----------------------------------------\n"); xFooter.Add("*** GRACIAS POR SU COMPRA ***\n"); // List <string> xCodigo = new List <string>(); List <string> xProducto = new List <string>(); List <string> xValor = new List <string>(); List <string> xCant = new List <string>(); List <string> xUM = new List <string>(); ////////// cargar los datos de los productos a facturar ////////xCodigo.Add("GH90"); ////////xProducto.Add("GASOLINA90"); ////////xCant.Add("1.925"); ////////xUM.Add("GLN"); ////////xValor.Add("20.00"); ////////// ////////// cargar los datos de los productos a facturar ////////xCodigo.Add("AG01"); ////////xProducto.Add("CIELO 250ML"); ////////xCant.Add("1"); ////////xUM.Add("UND"); ////////xValor.Add("1.50"); ////////// foreach (DataGridViewRow row in grvDetalleVenta.Rows) { xCodigo.Add(row.Cells[5].Value.ToString()); xProducto.Add(row.Cells[6].Value.ToString()); xCant.Add(row.Cells[8].Value.ToString()); xUM.Add("GLN"); xValor.Add(row.Cells[9].Value.ToString()); } PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson(); var BytesValue = Encoding.ASCII.GetBytes(string.Empty); BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center()); // // IMPRIMIENDO ENCABEZADO // for (int i = 0; i < xHeader.Count; i++) { BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(xHeader[i])); } BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl()); // IMPRIMIENDO DETALLES // for (int i = 0; i < xCodigo.Count; i++) { string xC = xCodigo[i]; string xP = xProducto[i]; string xQ = xCant[i]; string xU = xUM[i]; string xV = xValor[i]; xTotal = xTotal + Convert.ToDecimal(xV); string linea = Der(xC, 8) + Der(xP, 12) + Izq(xQ, 8) + Der(xU, 4) + Izq(xV, 8) + "\n"; BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(linea)); } BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl()); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("----------------------------------------\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{1,10}{2,10:N2}\n", "TOTAL", "", xTotal)); BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "OP.GRAVADA", "", "", xTotal_gravado)); BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "OP.INAFECTA", "", "", xTotal_inafecto)); BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "IGV (18.00%)", "", "", xTotal_igv)); BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "OP.EXONERADA", "", "", xTotal_exonerado)); BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "I.S.C.", "", "", xTotal_isc)); BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-20}{2,10}{3,10:N2}\n", "IMPORTE TOTAL", "", "", xTotal)); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Conserve su comprobante\n")); // IMPRESION DE PIE DE COMPROBANTE // for (int i = 0; i < xFooter.Count; i++) { BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(xFooter[i])); } BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, VariablesGlobales.empresa.Str_texto); BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("\n")); BytesValue = PrintExtensions.AddBytes(BytesValue, CutPage()); PrinterUtility.PrintExtensions.Print(BytesValue, GestionCombustibles.Properties.Settings.Default.PrinterPath); // COMO HABILITAR LA IMPRESORA: // configurar una impresora Generic/Txt apuntando a puerto FILE, renombrarla y compartirla como TMU220 // en Settings: crear una clave PrinterPath \\\\<nombre de esta pc>\\TMU220 // ejemplo : \\\\DEVELOPER_01\\TMU220 // // FIN DE IMPRESION } Descartar(); } else { MessageBox.Show("Ocurrió un error al registrar la operación."); } } } catch (Exception ex) { MessageBox.Show("ERROR:" + ex.ToString()); } }