예제 #1
0
        private void printDocument3_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("ANNUAL REPORT(" + comboBox1.SelectedItem.ToString() + "-" + (Convert.ToInt32(comboBox1.SelectedItem.ToString()) + 1).ToString() + ")", messageFont, Brushes.Black, 75, 25);
            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);
            messageFont = new Font("Times New Roman", 15, System.Drawing.GraphicsUnit.Point);
            g.DrawString("----------------------------------------------------------------------------------------------------------", messageFont, Brushes.Black, 7, 38 + 2);
            g.DrawString("----------------------------------------------------------------------------------------------------------", messageFont, Brushes.Black, 7, 38 + 12);
            messageFont = new Font("Times New Roman", 13, System.Drawing.GraphicsUnit.Point);
            g.DrawString("Sno.", messageFont, Brushes.Black, 10, 46);
            g.DrawString("Month", messageFont, Brushes.Black, 30, 46);
            g.DrawString("Total Patients", messageFont, Brushes.Black, 90, 46);
            g.DrawString("Total Amount", messageFont, Brushes.Black, 155, 46);
            DateTime month    = new DateTime(Convert.ToInt32(comboBox1.SelectedItem.ToString()), 4, 1);
            int      total    = 60;
            int      amount   = 0;
            int      patients = 0;

            for (int i = 1; i < 13; i++)
            {
                opd opd = new opd();
                opd.annualReport(month.AddMonths(i - 1).ToString("yyyy-MM-dd"), month.AddMonths(i).ToString("yyyy-MM-dd"));
                g.DrawString(i.ToString() + ")", messageFont, Brushes.Black, 10, total);
                g.DrawString(month.AddMonths(i - 1).ToString("MMMM, yyyy").ToUpper(), messageFont, Brushes.Black, 30, total);
                g.DrawString(opd.count, messageFont, Brushes.Black, 95, total);
                g.DrawString(opd.token, messageFont, Brushes.Black, 160, total);
                total    += 10;
                amount   += Convert.ToInt32(opd.token);
                patients += Convert.ToInt32(opd.count);
            }
            messageFont = new Font("Times New Roman", 13, System.Drawing.GraphicsUnit.Point);
            g.DrawString("Total Patients : " + patients.ToString(), messageFont, Brushes.Black, 63, total + 2);
            g.DrawString("Total Amount : " + amount.ToString(), messageFont, Brushes.Black, 130, 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);
        }