コード例 #1
0
    public void PrintCommands(string useDefaultPrinter, string printerName, int orderId)
    {
        var listOfItems = _invoiceDataManager.GetInvoiceByOrderId(orderId);
        //Create ESC/POS commands for sample receipt
        string ESC     = "0x1B";    //ESC byte in hex notation
        string NewLine = "0x0A";    //LF byte in hex notation

        string cmds = ESC + "@";    //Initializes the printer (ESC @)

        cmds += ESC + "!" + "0x38"; //Emphasized + Double-height + Double-width mode selected (ESC ! (8 + 16 + 32)) 56 dec => 38 hex
        cmds += "BEST DEAL STORES"; //text to print
        cmds += NewLine + NewLine;
        cmds += ESC + "!" + "0x00"; //Character font A selected (ESC ! 0)
        cmds += "COOKIES                   5.00";
        cmds += NewLine;
        cmds += "MILK 65 Fl oz             3.78";
        cmds += NewLine + NewLine;
        cmds += "SUBTOTAL                  8.78";
        cmds += NewLine;
        cmds += "TAX 5%                    0.44";
        cmds += NewLine;
        cmds += "TOTAL                     9.22";
        cmds += NewLine;
        cmds += "CASH TEND                10.00";
        cmds += NewLine;
        cmds += "CASH DUE                  0.78";
        cmds += NewLine + NewLine;
        cmds += ESC + "!" + "0x18"; //Emphasized + Double-height mode selected (ESC ! (16 + 8)) 24 dec => 18 hex
        cmds += "# ITEMS SOLD 2";
        cmds += ESC + "!" + "0x00"; //Character font A selected (ESC ! 0)
        cmds += NewLine + NewLine;
        cmds += "11/03/13  19:53:17";


        //Create a ClientPrintJob and send it back to the client!
        ClientPrintJob cpj = new ClientPrintJob();

        //set  ESCPOS commands to print...
        cpj.PrinterCommands = cmds;
        cpj.FormatHexValues = true;

        //set client printer...
        if (useDefaultPrinter == "checked" || printerName == "null")
        {
            cpj.ClientPrinter = new DefaultPrinter();
        }
        else
        {
            cpj.ClientPrinter = new InstalledPrinter(printerName);
        }

        //send it...
        System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
        System.Web.HttpContext.Current.Response.BinaryWrite(cpj.GetContent());
        System.Web.HttpContext.Current.Response.End();
    }
コード例 #2
0
        // GET: Invoice
        public List <InvoiceModel> GetInvoiceByOrderId(int orderId)
        {
            var list = new List <InvoiceModel>();

            try
            {
                list = _invoiceDataManager.GetInvoiceByOrderId(orderId);
            }
            catch (Exception ex)
            {
            }
            return(list);
        }
コード例 #3
0
    private ThermalLabel GenerateBasicThermalLabel()
    {
        //Define a ThermalLabel object and set unit to inch and label size
        ThermalLabel tLabel = new ThermalLabel(Neodynamic.SDK.Printing.UnitType.Inch, 4, 6);

        tLabel.GapLength = 0.2;

        //Define a couple of TextItem objects for Employee info
        TextItem txt1 = new TextItem();

        //set data field
        txt1.DataField = "Items";
        //set font
        txt1.Font.Name   = Font.NativePrinterFontA;
        txt1.Font.Unit   = FontUnit.Point;
        txt1.Font.Size   = 10;
        txt1.TextPadding = new FrameThickness(0.5);


        TextItem txt2 = new TextItem();

        //set data field
        txt2.DataField = "Quantity";
        //set font
        txt2.Font.Name   = Font.NativePrinterFontA;
        txt2.Font.Unit   = FontUnit.Point;
        txt2.Font.Size   = 10;
        txt1.TextPadding = new FrameThickness(0.5);



        //TextItem txt3 = new TextItem();
        ////set data field
        //txt3.DataField = "Rate";
        ////set font
        //txt3.Font.Name = Font.NativePrinterFontA;
        //txt3.Font.Unit = FontUnit.Point;
        //txt3.Font.Size = 10;

        //TextItem txt4 = new TextItem(0.13, 0.05, 2.8, 0.3, "");
        ////set data field
        //txt4.DataField = "Total";
        ////set font
        //txt4.Font.Name = Font.NativePrinterFontA;
        //txt4.Font.Unit = FontUnit.Point;
        //txt4.Font.Size = 10;



        tLabel.Items.Add(txt1);
        tLabel.Items.Add(txt2);
        //tLabel.Items.Add(txt3);
        //tLabel.Items.Add(txt4);
        tLabel.DataSource = _invoiceDataManager.GetInvoiceByOrderId(1);


        //TextItem title = new TextItem(0.5, 0.5, 2.5, 0.5, "Ismartmandu");
        //title.TextPadding = new FrameThickness(0.2);
        //TextItem address = new TextItem(0.5, 0.5, 2.5, 0.5, "Kathmandu, Nepal");
        //address.TextPadding = new FrameThickness(0.2);

        //var orderlist = GetInvoiceByOrderId(1);

        //foreach(var order in orderlist)
        //{

        //}

        //TextItem Greetings = new TextItem(0.5, 0.5, 2.5, 0.5, "Thank you for vist");
        //Greetings.TextPadding = new FrameThickness(0.2);
        ////Add items to ThermalLabel object...
        //tLabel.Items.Add(title);
        //tLabel.Items.Add(address);
        //tLabel.Items.Add(Greetings);
        //tLabel.DataSource=orderlist;

        return(tLabel);
    }