- Timestamp:
- May 11, 2010, 1:24:18 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Scheduling/trunk/cs/bsdx0200GUISourceCode/UCPatientAppts.cs
r753 r755 14 14 public partial class UCPatientAppts : UserControl 15 15 { 16 DataTable dtAppt; 17 DataView dvAppt; 16 DataTable dtAppt; // Main table 17 DataView dvAppt; // Manipulated view of table 18 int rowToPrint; // Used in printing 18 19 /// <summary> 19 /// Ctor 20 /// Ctor - Creates control and populates data into datagridview 20 21 /// </summary> 21 22 /// <param name="docManager">Document Manager from main context</param> … … 44 45 { 45 46 if (ShowPastAppts) dvAppt.RowFilter = ""; 46 else dvAppt.RowFilter = "ApptDate > " + "#" + DateTime.Today.ToShortDateString() + "#"; ;47 else dvAppt.RowFilter = "ApptDate > " + "#" + DateTime.Today.ToShortDateString() + "#"; 47 48 } 48 49 … … 56 57 { 57 58 Graphics g = e.Graphics; 58 using (Font font = new Font("Lucida Console", 72)) 59 Font Serif12Bold = new Font(FontFamily.GenericSerif, 12, FontStyle.Bold); 60 Font Serif12 = new Font(FontFamily.GenericSerif, 12); 61 Font Serif14 = new Font(FontFamily.GenericSerif, 14); 62 Rectangle startDrawRectangle = e.MarginBounds; 63 int widthPerColumn = e.MarginBounds.Width/dgAppts.Columns.Count; 64 int Serif12Height = (int)Serif12.GetHeight(); 65 66 //Draw Header 67 StringFormat sf1 = new StringFormat(); 68 sf1.Alignment = StringAlignment.Center; 69 g.DrawString("Appointment Listing", Serif14, Brushes.Black, startDrawRectangle, sf1); 70 71 startDrawRectangle.Y += (int)Serif14.GetHeight(); 72 73 g.DrawString("Confidential Patient Information", Serif12, Brushes.Black, startDrawRectangle, sf1); 74 75 startDrawRectangle.Y += Serif12Height * 2; 76 77 //Patient Name + Sex + DOB 78 string identifier = "Patient Name: " + dtAppt.Rows[0]["Name"] + "\tSex: " + dtAppt.Rows[0]["Sex"] 79 + "\tDate of Birth: " + dtAppt.Rows[0]["DOB"]; 80 g.DrawString(identifier, Serif12, Brushes.Black, startDrawRectangle); 81 82 startDrawRectangle.Y += Serif12Height * 2; 83 84 foreach (DataGridViewColumn col in dgAppts.Columns) 59 85 { 60 g.DrawString("Hello,\nPrinter", font, Brushes.Black, e.MarginBounds); 86 g.DrawString(col.HeaderText, Serif12Bold, Brushes.Black, startDrawRectangle); 87 startDrawRectangle.X += widthPerColumn; 61 88 } 89 startDrawRectangle.Y += Serif12Height; 90 91 // rowToPrint initialized in print button handler. Helps us keep track of which row we 92 // are on, so that, just in case we need an extra page to print, we would know where 93 // we left off. Royal we of course. 94 for ( ; rowToPrint<dgAppts.Rows.Count; rowToPrint++) 95 { 96 // Post facto statement -- This is starting to look like Mumps... 97 // Start drawing a new page if you hit the bottom margin... 98 // Y incremented at the bottom of the for loop; but checked here 99 // because I need for statement stuff to happen first 100 if (startDrawRectangle.Y > e.MarginBounds.Bottom) 101 { 102 e.HasMorePages = true; 103 break; 104 } 105 106 startDrawRectangle.X = e.MarginBounds.X; 107 108 foreach (DataGridViewCell cell in dgAppts.Rows[rowToPrint].Cells) 109 { 110 g.DrawString(cell.Value.ToString(), Serif12, Brushes.Black, startDrawRectangle); 111 startDrawRectangle.X += widthPerColumn; 112 } 113 114 startDrawRectangle.Y += Serif12Height; 115 116 } 62 117 } 63 118 64 119 private void btnPrint_Click(object sender, EventArgs e) 65 120 { 121 rowToPrint = 0; //reset row to print 66 122 DialogResult res = printDialog1.ShowDialog(); 67 123 if (res == DialogResult.OK) this.printDialog1.Document.Print(); 68 124 } 69 125 126 private void PrintPtAppts_QueryPageSettings(object sender, System.Drawing.Printing.QueryPageSettingsEventArgs e) 127 { 128 e.PageSettings.Landscape = true; 129 } 130 70 131 } 71 132 }
Note:
See TracChangeset
for help on using the changeset viewer.