예제 #1
0
        void printReceipt_PrintPage(object sender, PrintPageEventArgs e)
        {
            Login    getFirstname = (Login)Application.OpenForms["Login"];
            Graphics graphic      = e.Graphics;

            Font       font       = new Font("Courier New", 8);
            float      fontHeight = font.GetHeight();
            SolidBrush brush      = new SolidBrush(Color.Black);

            int    startX = 10; int startY = 10; int offset = 40;
            string items = "Items".PadRight(15); string quant = "Qty".PadRight(5); string Uprice = "Price".PadRight(8);
            string disc = "Discount".PadRight(12); string totalp = "Total Price";

            string columnline = items + quant + Uprice + disc + totalp;

            graphic.DrawString("Welcome To Agram Pharmacy", new Font("Courier New", 18), brush, startX, startY);
            graphic.DrawString("-----------------------------------------------------", new Font("Courier New", 8), brush, startX, startY + offset);
            offset = offset + 80;
            graphic.DrawString(columnline, font, brush, startX, startY + 60);
            graphic.DrawString("-----------------------------------------------------", new Font("Courier New", 8), brush, startX, startY + 80);

            foreach (ListViewItem Item in listViewPurchase.Items)
            {
                string item       = Item.SubItems[0].Text.PadRight(15);
                string quantity   = Item.SubItems[1].Text.PadRight(5);
                string unitPrice  = Item.SubItems[2].Text.PadRight(8);
                string discount   = Item.SubItems[3].Text.PadRight(12);
                string totalPrice = String.Format("{0:c}", Item.SubItems[4].Text);

                string line = item + quantity + unitPrice + discount + totalPrice;

                graphic.DrawString(line, font, brush, startX, startY + offset);

                offset = offset + (int)fontHeight + 5;
            }

            //string amountToPay = "Total to Pay".PadRight(30) + String.Format("{0:c}", labelTotalAmountToPay.Text);
            offset = offset + 5;
            //graphic.DrawString("-----------------------------------------------------", new Font("Courier New", 8), brush, startX, startY + 145);
            graphic.DrawString("Total to Pay".PadRight(39) + String.Format("({0:c})", labelTotalAmountToPay.Text), font, brush, startX, startY + offset);
            //graphic.DrawString("-----------------------------------------------------", new Font("Courier New", 8), brush, startX, startY + 170);
            //offset = offset + (int)fontHeight;
            CashOut getAmountPaid = (CashOut)Application.OpenForms["CashOut"];
            double  amountPaid    = Convert.ToDouble(getAmountPaid.richCashOut.Text);

            graphic.DrawString("Amount Paid".PadRight(40) + String.Format("{0:c}", amountPaid), font, brush, startX, startY + 200);
            graphic.DrawString("Change Collected".PadRight(40) + String.Format("{0:c}", labelChange.Text), font, brush, startX, startY + 230);
            graphic.DrawString("You were attended to by:  " + getFirstname.username, font, brush, startX, startY + 260);
        }
예제 #2
0
 private void btnProcess_Click(object sender, EventArgs e)
 {
     processPay = new CashOut(labelTotalAmountToPay.Text);
     processPay.Show();
 }