Пример #1
0
        private void ReceiptDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Font HeaderFont = new Font("Courier New", 20, FontStyle.Regular);
            Font font       = new Font("Courier New", 8, FontStyle.Regular);
            int  item       = 10;
            int  qty        = item + 110;
            int  price      = qty + 50;
            int  amount     = price + 50;
            int  yPos       = 270;

            string dash = "=================================";

            e.Graphics.DrawString(dash, font, Brushes.Black, new Point(10, 250));
            e.Graphics.DrawString(dash, font, Brushes.Black, new Point(10, 230));


            //Image img = Resources.accounts;
            //e.Graphics.DrawImage(img, 400, 2, img.Width, img.Height);
            DataSet ds   = SelectProductClass.Select();
            string  name = ds.Tables[0].Rows[0]["Name"].ToString();

            e.Graphics.DrawString(name, HeaderFont, Brushes.Black, new Point(10, 50));

            e.Graphics.DrawString("Date: " + DateTime.Now, font, Brushes.Black, new Point(10, 200));

            e.Graphics.DrawString("Client Name " + lblCustname.Text, font, Brushes.Black, new Point(10, 220));


            e.Graphics.DrawString("ITEM ", font, Brushes.Black, new Point(item, 240));
            e.Graphics.DrawString("QTY ", font, Brushes.Black, new Point(qty, 240));
            e.Graphics.DrawString("PRICE ", font, Brushes.Black, new Point(price, 240));
            e.Graphics.DrawString("AMOUNT ", font, Brushes.Black, new Point(amount, 240));



            //foreach(var i in dgv.Rows)
            //{
            //    e.Graphics.DrawString(i., new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(350, 240));
            //}
            for (int i = 0; i < dgv.Rows.Count; i++)
            {
                e.Graphics.DrawString(dgv.Rows[i].Cells[1].Value.ToString(), font, Brushes.Black, new Point(item, yPos));
                e.Graphics.DrawString(dgv.Rows[i].Cells[2].Value.ToString(), font, Brushes.Black, new Point(qty, yPos));
                e.Graphics.DrawString(dgv.Rows[i].Cells[3].Value.ToString(), font, Brushes.Black, new Point(price, yPos));
                e.Graphics.DrawString(dgv.Rows[i].Cells[4].Value.ToString(), font, Brushes.Black, new Point(amount, yPos));

                yPos += 20;
            }

            e.Graphics.DrawString(dash, font, Brushes.Black, new Point(item, yPos + 10));

            e.Graphics.DrawString("Total Items: " + lblItems.Text, font, Brushes.Black, new Point(item, yPos + 20));
            e.Graphics.DrawString("Total Amount: " + lblAmt.Text, font, Brushes.Black, new Point(item, yPos + 40));
            e.Graphics.DrawString("Total To Pay: " + lblToPay.Text, font, Brushes.Black, new Point(item, yPos + 60));
        }
Пример #2
0
        private void PrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            #region RECEIPT
            var headerFont    = new Font("Arial", 20, FontStyle.Regular);
            var subHeaderFont = new Font("Courier New", 16, FontStyle.Regular);
            var font          = new Font("Courier New", 8, FontStyle.Regular);
            int itemID        = 10;
            int item          = 100;
            int qty           = item + 400;
            int price         = qty + 100;
            int amount        = price + 100;
            int yPos          = 270;
            //InvoiceType = "Sale Invoice";

            string dash       = "==============================================================================================================";
            string SingleDash = "------------------------------------------------------------------------------------------------------------------";

            e.Graphics.DrawString(dash, font, Brushes.Black, new Point(10, 250));
            e.Graphics.DrawString(dash, font, Brushes.Black, new Point(10, 230));
            e.Graphics.DrawString(SingleDash, font, Brushes.Black, new Point(itemID, 110));


            //Image img = Resources.accounts;
            //e.Graphics.DrawImage(img, 400, 2, img.Width, img.Height);
            //SELECT ACCOUNT INFO
            DataSet ds      = SelectProductClass.Select();
            string  name    = ds.Tables[0].Rows[0]["Name"].ToString();
            string  slogan  = ds.Tables[0].Rows[0]["Slogan"].ToString();
            string  address = ds.Tables[0].Rows[0]["Address"].ToString();
            string  contact = ds.Tables[0].Rows[0]["Contact"].ToString();

            e.Graphics.DrawString("Invoice Type: " + InvoiceType, font, Brushes.Black, new Point(10, 170));

            //shop name, slogan, address, contact
            e.Graphics.DrawString(name, headerFont, Brushes.Black, new Point(240, 20));
            e.Graphics.DrawString(slogan, subHeaderFont, Brushes.Black, new Point(200, 50));
            e.Graphics.DrawString(address, subHeaderFont, Brushes.Black, new Point(180, 70));
            e.Graphics.DrawString(contact, subHeaderFont, Brushes.Black, new Point(260, 90));

            e.Graphics.DrawString("Customer Name: " + txtCustName.Text, font, Brushes.Black, new Point(10, 130));
            e.Graphics.DrawString("Order No: " + txtInvID.Text, font, Brushes.Black, new Point(10, 150));
            e.Graphics.DrawString("Date: " + DateTime.Now, font, Brushes.Black, new Point(600, 150));


            e.Graphics.DrawString("PRODUCT ID ", font, Brushes.Black, new Point(itemID, 240));
            e.Graphics.DrawString("ITEM ", font, Brushes.Black, new Point(item, 240));
            e.Graphics.DrawString("QTY ", font, Brushes.Black, new Point(qty, 240));
            e.Graphics.DrawString("PRICE ", font, Brushes.Black, new Point(price, 240));
            e.Graphics.DrawString("AMOUNT ", font, Brushes.Black, new Point(amount, 240));

            for (int i = 0; i < dgvCart.Rows.Count; i++)
            {
                e.Graphics.DrawString(dgvCart.Rows[i].Cells["ProductID"].Value.ToString(), font, Brushes.Black, new Point(itemID, yPos));
                e.Graphics.DrawString(dgvCart.Rows[i].Cells["NAME"].Value.ToString(), font, Brushes.Black, new Point(item, yPos));
                e.Graphics.DrawString(dgvCart.Rows[i].Cells["QUANTITY"].Value.ToString(), font, Brushes.Black, new Point(qty, yPos));
                e.Graphics.DrawString(dgvCart.Rows[i].Cells["PRICE"].Value.ToString(), font, Brushes.Black, new Point(price, yPos));
                e.Graphics.DrawString(dgvCart.Rows[i].Cells["AMOUNT"].Value.ToString(), font, Brushes.Black, new Point(amount, yPos));

                yPos += 20;
            }
            e.Graphics.DrawString(SingleDash, font, Brushes.Black, new Point(itemID, yPos + 10));
            e.Graphics.DrawString(SingleDash, font, Brushes.Black, new Point(itemID, yPos + 30));
            //e.Graphics.DrawString(dash, font, Brushes.Black, new Point(item, yPos + 10));

            e.Graphics.DrawString("Total", font, Brushes.Black, new Point(item, yPos + 20));
            // e.Graphics.DrawString(txtTotalItems.Text, font, Brushes.Black, new Point(qty, yPos + 20));
            e.Graphics.DrawString(txtGrandTotal.Text, font, Brushes.Black, new Point(amount, yPos + 20));
            e.Graphics.DrawString("Invoice Total  (RS): " + txtGrandTotal.Text, font, Brushes.Black, new Point(qty, yPos + 50));
            //e.Graphics.DrawString("Total To Pay: " + lblTotalToPay.Text, font, Brushes.Black, new Point(item, yPos + 60));
            // e.Graphics.DrawString("Discount: " + txtDiscount.Text, font, Brushes.Black, new Point(item, yPos + 80));
            e.Graphics.DrawString("Total Payment  (RS): " + txtTotalPayment.Text, font, Brushes.Black, new Point(qty, yPos + 70));
            e.Graphics.DrawString("Payment Due    (RS): " + txtPaymentDue.Text, font, Brushes.Black, new Point(qty, yPos + 90));
            e.Graphics.DrawString(SingleDash, font, Brushes.Black, new Point(itemID, yPos + 100));
            e.Graphics.DrawString("Software by Developer Studio: 923366536339", font, Brushes.Black, new Point(itemID, yPos + 110));
        }