source: Scheduling/trunk/cs/bsdx0200GUISourceCode/DPatientLetter.cs@ 772

Last change on this file since 772 was 772, checked in by Sam Habiel, 14 years ago

Removal of Crystal Reports
Partial Rework of Clinic Patient List report
Other reports that used Crystal don't work yet.
Fixes for Strongly typed DataTables (change the RESOURCEID from uint to int) to support table merge from untyped table.
Support for command line arguments: /s= for server /p= for port /a= for access code /v= for verify code
Only the following combinations work: none; /s and /p; /s, /p, /a, /v

File size: 6.1 KB
Line 
1using System;
2using System.Windows.Forms;
3using System.Data;
4using System.Drawing.Printing;
5using System.Drawing;
6
7namespace IndianHealthService.ClinicalScheduling
8{
9 /// <summary>
10 /// Summary description for DPatientLetter.
11 /// </summary>
12 public class DPatientLetter : System.Windows.Forms.PrintPreviewDialog
13 {
14 /// <summary>
15 /// Required designer variable.
16 /// </summary>
17 private System.ComponentModel.Container components = null;
18 private System.Drawing.Printing.PrintDocument printDocument1;
19
20 #region Fields
21 DateTime _dtBegin, _dtEnd; //global fields to use in passing to printing method
22 int _currentResourcePrinting = 0;
23 int _currentApptPrinting = 0;
24 dsPatientApptDisplay2 _ds;
25 #endregion Fields
26
27 public void InitializeFormClinicSchedule(CGDocumentManager docManager,
28 string sClinicList,
29 DateTime dtBegin,
30 DateTime dtEnd)
31 {
32 try
33 {
34 if (sClinicList == "")
35 {
36 throw new Exception("At least one clinic must be selected.");
37 }
38 _dtBegin = dtBegin;
39 _dtEnd = dtEnd;
40 string sBegin = dtBegin.ToShortDateString();
41 string sEnd = dtEnd.ToShortDateString();
42 this.Text="Clinic Schedules";
43
44 string sSql = "BSDX CLINIC LETTERS^" + sClinicList + "^" + sBegin + "^" + sEnd;
45 string sSql2 = "BSDX RESOURCE LETTERS^" + sClinicList;
46
47 _ds = new dsPatientApptDisplay2();
48 _ds.BSDXResource.Merge(docManager.RPMSDataTable(sSql2, "Resources"));
49 _ds.PatientAppts.Merge(docManager.RPMSDataTable(sSql, "PatientAppts"));
50 }
51 catch (Exception ex)
52 {
53 throw ex;
54 }
55 }
56
57 public void InitializeFormRebookLetters(CGDocumentManager docManager,
58 string sClinicList,
59 DataTable dtLetters)
60 {
61 try
62 {
63 if (sClinicList == "")
64 {
65 throw new Exception("At least one clinic must be selected.");
66 }
67
68 System.Data.DataSet ds = new System.Data.DataSet();
69 ds.Tables.Add(dtLetters.Copy());
70
71 string sSql = "BSDX RESOURCE LETTERS^" + sClinicList;
72 DataTable dt = docManager.RPMSDataTable(sSql, "Resources");
73 ds.Tables.Add(dt.Copy());
74 }
75 catch (Exception ex)
76 {
77 throw ex;
78 }
79 }
80
81 public void InitializeFormCancellationLetters(CGDocumentManager docManager,
82 string sClinicList,
83 DataTable dtLetters)
84 {
85 try
86 {
87 if (sClinicList == "")
88 {
89 throw new Exception("At least one clinic must be selected.");
90 }
91
92 System.Data.DataSet ds = new System.Data.DataSet();
93 ds.Tables.Add(dtLetters.Copy());
94
95 string sSql = "BSDX RESOURCE LETTERS^" + sClinicList;
96 DataTable dt = docManager.RPMSDataTable(sSql, "Resources");
97 ds.Tables.Add(dt.Copy());
98
99 }
100 catch (Exception ex)
101 {
102 throw ex;
103 }
104 }
105
106 public void InitializeFormClinicLetters(CGDocumentManager docManager,
107 string sClinicList,
108 DateTime dtBegin,
109 DateTime dtEnd)
110 {
111 try
112 {
113 if (sClinicList == "")
114 {
115 throw new Exception("At least one clinic must be selected.");
116 }
117
118 string sBegin = dtBegin.ToShortDateString();
119 string sEnd = dtEnd.ToShortDateString();
120
121 string sSql = "BSDX CLINIC LETTERS^" + sClinicList + "^" + sBegin + "^" + sEnd;
122
123 System.Data.DataSet ds = new System.Data.DataSet();
124 DataTable dtAppt = docManager.RPMSDataTable(sSql, "PatientAppts");
125 ds.Tables.Add(dtAppt.Copy());
126
127 sSql = "BSDX RESOURCE LETTERS^" + sClinicList;
128 DataTable dt = docManager.RPMSDataTable(sSql, "Resources");
129 ds.Tables.Add(dt.Copy());
130
131 }
132 catch (Exception ex)
133 {
134 throw ex;
135 }
136 }
137
138
139 public DPatientLetter()
140 {
141 //
142 // Required for Windows Form Designer support
143 //
144 InitializeComponent();
145
146 //
147 // TODO: Add any constructor code after InitializeComponent call
148 //
149 }
150
151 /// <summary>
152 /// Clean up any resources being used.
153 /// </summary>
154 protected override void Dispose( bool disposing )
155 {
156 if( disposing )
157 {
158 if(components != null)
159 {
160 components.Dispose();
161 }
162 }
163 base.Dispose( disposing );
164 }
165
166 #region Windows Form Designer generated code
167 /// <summary>
168 /// Required method for Designer support - do not modify
169 /// the contents of this method with the code editor.
170 /// </summary>
171 private void InitializeComponent()
172 {
173 this.printDocument1 = new System.Drawing.Printing.PrintDocument();
174 this.SuspendLayout();
175 //
176 // printDocument1
177 //
178 this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
179 //
180 // DPatientLetter
181 //
182 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
183 this.ClientSize = new System.Drawing.Size(648, 398);
184 this.Document = this.printDocument1;
185 this.Name = "DPatientLetter";
186 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
187 this.Text = "Patient Letter";
188 this.ResumeLayout(false);
189
190 }
191 #endregion
192
193 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
194 {
195 // _currentResourcePrinting starts with zero. There will be at least this one.
196 ClinicalScheduling.Printing.PrintAppointments(_ds, e, _dtBegin, _dtEnd,
197 _currentResourcePrinting, ref _currentApptPrinting);
198
199 //If the printing routine says it needs more pages to print the appointments,
200 //return here and have it print again.
201 if (e.HasMorePages == true) return;
202
203 // if there are more resouces to print, increment. Setting HasMorePages to true
204 // calls this routine again, so printing will happen with the incremented _currentResourcePrinting
205 if (_currentResourcePrinting < _ds.BSDXResource.Rows.Count - 1)
206 {
207 _currentResourcePrinting++;
208 e.HasMorePages = true;
209 }
210
211 }
212 }
213}
Note: See TracBrowser for help on using the repository browser.