예제 #1
0
        private void printDocument4_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Graphics g = e.Graphics;

            g.PageUnit = GraphicsUnit.Millimeter;
            Font messageFont = new Font("Times New Roman", 14, System.Drawing.GraphicsUnit.Point);

            g.DrawString("INSTITUTE DISPENSARY", messageFont, Brushes.Black, 75, 9);
            g.DrawString("INDIAN INSTITUTE OF TECHNOLOGY ROORKEE, SAHARANPUR CAMPUS", messageFont, Brushes.Black, 22, 15);
            messageFont = new Font("Times New Roman", 15, System.Drawing.GraphicsUnit.Point);
            g.DrawString("MONTHLY DATE WISE REPORT(" + monthCalendar1.SelectionRange.Start.ToString("MMMM, yyyy") + ")", messageFont, Brushes.Black, 55, 23);
            messageFont = new Font("Times New Roman", 12, System.Drawing.GraphicsUnit.Point);
            g.DrawString("Dated: " + DateTime.Today.ToString("dd MMM, yyyy"), messageFont, Brushes.Black, 160, 30);
            Pen blackPen = new Pen(Color.Black, 1);

            g.DrawLine(blackPen, 5, 38, 205, 38);
            int total = 38;

            messageFont = new Font("Times New Roman", 15, System.Drawing.GraphicsUnit.Point);
            g.DrawString("----------------------------------------------------------------------------------------------------------", messageFont, Brushes.Black, 7, total + 2);
            g.DrawString("----------------------------------------------------------------------------------------------------------", messageFont, Brushes.Black, 7, total + 12);
            messageFont = new Font("Times New Roman", 11, System.Drawing.GraphicsUnit.Point);
            g.DrawString("Sno.", messageFont, Brushes.Black, 15, total + 8);
            g.DrawString("Date", messageFont, Brushes.Black, 45, total + 8);
            g.DrawString("Total Patients", messageFont, Brushes.Black, 95, total + 8);
            g.DrawString("Amount Collected", messageFont, Brushes.Black, 160, total + 8);
            total += 17;
            opd       opd = new opd();
            dbconnect db  = new dbconnect();

            opd.monthlyReportDatewise(monthCalendar1.SelectionRange.Start.ToString("yyyy-MM-") + "01", monthCalendar1.SelectionRange.Start.AddMonths(1).ToString("yyyy-MM-") + "01", db);
            int i      = 1;
            int amount = 0;

            while (opd.dr.Read())
            {
                messageFont = new Font("Times New Roman", 10, System.Drawing.GraphicsUnit.Point);
                g.DrawString(i.ToString(), messageFont, Brushes.Black, 15, total);
                g.DrawString(opd.dr[0].ToString(), messageFont, Brushes.Black, 45, total);
                g.DrawString(opd.dr[1].ToString(), messageFont, Brushes.Black, 100, total);
                g.DrawString(opd.dr[2].ToString(), messageFont, Brushes.Black, 165, total);
                messageFont = new Font("Times New Roman", 5, System.Drawing.GraphicsUnit.Point);
                g.DrawString("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -", messageFont, Brushes.Black, 10, total + 4);
                total  += 6;
                amount += Convert.ToInt32(opd.dr[2].ToString());
                i++;
            }
            messageFont = new Font("Times New Roman", 12, System.Drawing.GraphicsUnit.Point);
            g.DrawString("Total Amount :" + amount.ToString(), messageFont, Brushes.Black, 139, total + 2);
            messageFont = new Font("Times New Roman", 15, System.Drawing.GraphicsUnit.Point);
            g.DrawString("----------------------------------------------------------------------------------------------------------", messageFont, Brushes.Black, 7, total + 5);
            messageFont = new Font("Times New Roman", 8, System.Drawing.GraphicsUnit.Point);
            g.DrawString("© IMG Labs, IIT Roorkee, SRE", messageFont, Brushes.Black, 87, total + 10);
        }