private void _CreateReceipt(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Graphics graphic    = e.Graphics;
            Font     font       = new Font("Courier New", 6);
            float    FontHeight = font.GetHeight();
            int      startX     = 10;
            int      startY     = 10;
            int      offset     = 90;

            graphic.DrawString("CÀ PHÊ TRI ÂN".PadLeft(16), new Font("Courier New", 10, System.Drawing.FontStyle.Bold), new SolidBrush(Color.Black), startX, startY);

            graphic.DrawString("252 Sông Lu, xã Trung An".PadLeft(25), font, new SolidBrush(Color.Black), startX + 22, startY + 15);
            graphic.DrawString("huyện Củ Chi, TP.HCM".PadLeft(27), font, new SolidBrush(Color.Black), startX, startY + 25);

            graphic.DrawString("HÓA ĐƠN BÀN SỐ".PadLeft(16), new Font("Courier New", 10, System.Drawing.FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + 40);
            graphic.DrawString(bill.DeskNo.ToString(), new Font("Courier New", 10, System.Drawing.FontStyle.Bold), new SolidBrush(Color.Black), startX + 150, startY + 40);

            graphic.DrawString("GIỜ BẮT ĐẦU".PadLeft(8), font, new SolidBrush(Color.Black), startX, startY + 65);
            graphic.DrawString(bill.OrderTime, font, new SolidBrush(Color.Black), startX + 70, startY + 65);

            string top = "Tên Mặt Hàng".PadRight(17) + "ĐVT".PadRight(7) + "SL".PadRight(6) + "TT";

            graphic.DrawString(top, font, new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)FontHeight;     //make the spacing consistent
            graphic.DrawString("------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)FontHeight + 5; //make the spacing consistent

            //Check if product was chosen, then update quantity
            foreach (DetailBillItemViewModel item in ListDetailBill)
            {
                graphic.DrawString(item.ProductName, font, new SolidBrush(Color.Black), startX, startY + offset);
                graphic.DrawString(item.UnitName, font, new SolidBrush(Color.Black), startX + 90, startY + offset);
                graphic.DrawString(item.Quantity.ToString(), font, new SolidBrush(Color.Black), startX + 125, startY + offset);
                graphic.DrawString((item.Price * item.Quantity).ToString(), font, new SolidBrush(Color.Black), startX + 148, startY + offset);
                offset = offset + (int)FontHeight + 5; //make the spacing consistent
            }

            graphic.DrawString("------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)FontHeight + 5; //make the spacing consistent
            graphic.DrawString("TỔNG CỘNG", new Font("Courier New", 8, System.Drawing.FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
            graphic.DrawString(SumPrice.ToString(), font, new SolidBrush(Color.Black), startX + 80, startY + offset);

            graphic.DrawString("Tiền nhận", font, new SolidBrush(Color.Black), startX, startY + offset + 15);
            graphic.DrawString(MoneyReceived.ToString(), font, new SolidBrush(Color.Black), startX + 80, startY + offset + 15);

            graphic.DrawString("Tiền thối", font, new SolidBrush(Color.Black), startX, startY + offset + 25);
            graphic.DrawString(Change.ToString(), font, new SolidBrush(Color.Black), startX + 80, startY + offset + 25);

            offset = offset + (int)FontHeight + 5; //make the spacing consistent
            graphic.DrawString("XIN CHÂN THÀNH CẢM ƠN QUÝ KHÁCH!".PadLeft(12), font, new SolidBrush(Color.Black), startX, startY + offset + 35);

            offset = offset + (int)FontHeight + 5; //make the spacing consistent
            graphic.DrawString("HẸN GẶP LẠI!".PadLeft(23), font, new SolidBrush(Color.Black), startX, startY + offset + 40);
        }
Example #2
0
        public TableBill()
        {
            InitializeComponent();
            this.CloseBill       = new EventHandler(onCloseBill);
            this.ClickBtnCashier = new EventHandler(onClickBtnCashier);

            this.Layout           += TableBill_Layout;
            tableTitle_pnl.Layout += TableBill_Layout;

            btnCashier.Click += BtnCashier_Click;
            TotalPrice        = new SumPrice();

            lbPrice.DataBindings.Add("Text", TotalPrice, "Price", true, DataSourceUpdateMode.OnPropertyChanged);
            this.MinimumSize = new Size((new TableLine()).MinimumSize.Width, (new TableLine()).MinimumSize.Height + tableTitle_pnl.MinimumSize.Height + titelLine1.MinimumSize.Height + lbSumPrice.Size.Height + Space_lbSumPrice_pnCashier * 2);
        }