source: Scheduling/trunk/cs/bsdx0200GUISourceCode/DCopyAppts.cs@ 1104

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

Fixes for i18n.

File size: 10.4 KB
Line 
1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Data;
7using IndianHealthService.BMXNet;
8using System.Threading;
9using System.Net;
10using System.Net.Sockets;
11using System.Diagnostics;
12
13namespace IndianHealthService.ClinicalScheduling
14{
15 /// <summary>
16 /// Summary description for DCopyAppts.
17 /// </summary>
18 public class DCopyAppts : System.Windows.Forms.Form
19 {
20 private System.Windows.Forms.Button cmdOK;
21 private System.Windows.Forms.Panel pnlOKCancel;
22 private System.Windows.Forms.Label lblSummary;
23 private System.Windows.Forms.Label lblProgress;
24 private System.ComponentModel.IContainer components;
25
26
27 #region Fields
28 private DateTime m_dtBegin;
29 private DateTime m_dtEnd;
30 private string m_HospLocationID;
31 private string m_HospLocationName;
32 private string m_ResourceID;
33 private string m_ResourceName;
34 private string m_sTask;
35 private CGDocumentManager m_DocManager;
36
37 private System.Windows.Forms.Timer timerPoll;
38 private System.Windows.Forms.Label label1;
39 private System.Windows.Forms.Label label2;
40
41 //protected delegate void UpdateDisplayDelegate(string sText);
42 //protected delegate void RegisterEventDelegate(string sPort, string sEvent);
43
44 #endregion Fields
45
46 public DCopyAppts()
47 {
48 InitializeComponent();
49 }
50
51 /// <summary>
52 /// Clean up any resources being used.
53 /// </summary>
54 protected override void Dispose( bool disposing )
55 {
56 if( disposing )
57 {
58 if(components != null)
59 {
60 components.Dispose();
61 }
62 }
63 base.Dispose( disposing );
64 }
65
66 #region Windows Form Designer generated code
67 /// <summary>
68 /// Required method for Designer support - do not modify
69 /// the contents of this method with the code editor.
70 /// </summary>
71 private void InitializeComponent()
72 {
73 this.components = new System.ComponentModel.Container();
74 this.pnlOKCancel = new System.Windows.Forms.Panel();
75 this.cmdOK = new System.Windows.Forms.Button();
76 this.lblSummary = new System.Windows.Forms.Label();
77 this.lblProgress = new System.Windows.Forms.Label();
78 this.timerPoll = new System.Windows.Forms.Timer(this.components);
79 this.label1 = new System.Windows.Forms.Label();
80 this.label2 = new System.Windows.Forms.Label();
81 this.pnlOKCancel.SuspendLayout();
82 this.SuspendLayout();
83 //
84 // pnlOKCancel
85 //
86 this.pnlOKCancel.Controls.Add(this.cmdOK);
87 this.pnlOKCancel.Dock = System.Windows.Forms.DockStyle.Bottom;
88 this.pnlOKCancel.Location = new System.Drawing.Point(0, 211);
89 this.pnlOKCancel.Name = "pnlOKCancel";
90 this.pnlOKCancel.Size = new System.Drawing.Size(376, 40);
91 this.pnlOKCancel.TabIndex = 4;
92 //
93 // cmdOK
94 //
95 this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK;
96 this.cmdOK.Location = new System.Drawing.Point(208, 8);
97 this.cmdOK.Name = "cmdOK";
98 this.cmdOK.Size = new System.Drawing.Size(136, 24);
99 this.cmdOK.TabIndex = 0;
100 this.cmdOK.Text = "OK";
101 //
102 // lblSummary
103 //
104 this.lblSummary.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
105 this.lblSummary.Location = new System.Drawing.Point(32, 32);
106 this.lblSummary.Name = "lblSummary";
107 this.lblSummary.Size = new System.Drawing.Size(312, 64);
108 this.lblSummary.TabIndex = 48;
109 this.lblSummary.Text = "lblSummary";
110 //
111 // lblProgress
112 //
113 this.lblProgress.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
114 this.lblProgress.Location = new System.Drawing.Point(32, 128);
115 this.lblProgress.Name = "lblProgress";
116 this.lblProgress.Size = new System.Drawing.Size(312, 72);
117 this.lblProgress.TabIndex = 49;
118 this.lblProgress.Text = "lblProgress";
119 //
120 // timerPoll
121 //
122 this.timerPoll.Tick += new System.EventHandler(this.timerPoll_Tick);
123 //
124 // label1
125 //
126 this.label1.Location = new System.Drawing.Point(32, 112);
127 this.label1.Name = "label1";
128 this.label1.Size = new System.Drawing.Size(144, 16);
129 this.label1.TabIndex = 50;
130 this.label1.Text = "Status:";
131 //
132 // label2
133 //
134 this.label2.Location = new System.Drawing.Point(32, 16);
135 this.label2.Name = "label2";
136 this.label2.Size = new System.Drawing.Size(144, 16);
137 this.label2.TabIndex = 51;
138 this.label2.Text = "Job Summary:";
139 //
140 // DCopyAppts
141 //
142 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
143 this.ClientSize = new System.Drawing.Size(376, 251);
144 this.Controls.Add(this.label2);
145 this.Controls.Add(this.label1);
146 this.Controls.Add(this.lblProgress);
147 this.Controls.Add(this.lblSummary);
148 this.Controls.Add(this.pnlOKCancel);
149 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
150 this.MaximizeBox = false;
151 this.Name = "DCopyAppts";
152 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
153 this.Text = "Copy Appointments";
154 this.Load += new System.EventHandler(this.DCopyAppts_Load);
155 this.Closing += new System.ComponentModel.CancelEventHandler(this.DCopyAppts_Closing);
156 this.pnlOKCancel.ResumeLayout(false);
157 this.ResumeLayout(false);
158
159 }
160 #endregion
161
162 #region Methods and Handlers
163
164 public void InitializePage(DateTime StartDate, DateTime EndDate,
165 string HospLocationID, string HospLocationName,
166 string ResourceID, string ResourceName,
167 CGDocumentManager DocManager)
168 {
169 string sMsg = "Copying appointments from " + HospLocationName + " to " + ResourceName + ", ";
170 sMsg += "beginning with apppointments on " + StartDate.ToLongDateString();
171 sMsg += " and going through " + EndDate.ToLongDateString() + ".";
172 lblSummary.Text = sMsg;
173 m_dtBegin = StartDate;
174 m_dtEnd = EndDate;
175 m_HospLocationID = HospLocationID;
176 m_HospLocationName = HospLocationName;
177 m_ResourceID = ResourceID;
178 m_ResourceName = ResourceName;
179 m_DocManager = DocManager;
180 }
181
182 private void DCopyAppts_Load(object sender, System.EventArgs e)
183 {
184 try
185 {
186 //Start M copy job and get the ZTSK number
187 //this.timerPoll.Stop();
188 lblProgress.Text = "Starting Process... \r\n";
189
190 string sFMBeginDate = FMDateTime.Create(m_dtBegin).DateOnly.FMDateString;
191 string sFMEndDate = FMDateTime.Create(m_dtEnd).DateOnly.FMDateString;
192
193 //smh - i18n
194 //string sSql = "BSDX COPY APPOINTMENTS^" + m_ResourceID + "^" + m_HospLocationID + "^" + m_dtBegin.ToShortDateString() + "^" + m_dtEnd.ToShortDateString();
195 string sSql = "BSDX COPY APPOINTMENTS^" + m_ResourceID + "^" + m_HospLocationID + "^" + sFMBeginDate + "^" + sFMEndDate;
196
197 DataTable dt = m_DocManager.RPMSDataTable(sSql, "ApptCopy");
198 Debug.Assert(dt.Rows.Count == 1);
199
200 // TODO (later): delegate is supposed to support cross thread communication -- but this doesn't work.
201 //m_DocManager d = new RPMSDataTableDelegate(m_DocManager.RPMSDataTable);
202 //DataTable dt = d.Invoke(sSql, "ApptCopy");
203 //Debug.Assert(dt.Rows.Count == 1);
204
205 DataRow dr = dt.Rows[0];
206 m_sTask = "0";
207 Object oTask = dr["TASK_NUMBER"];
208 m_sTask = oTask.ToString();
209
210 Object oError = dr["ERRORID"];
211 string sError = oError.ToString();
212 if (sError != "OK")
213 {
214 //timerPoll.Stop();
215 lblProgress.Text = sError;
216 cmdOK.Enabled = true;
217 }
218 else
219 {
220 lblProgress.Text += "VistA Job queued as Task #" + m_sTask;
221 //this.timerPoll.Start();
222 cmdOK.Enabled = true;
223 }
224
225 }
226 catch (Exception Ex)
227 {
228 MessageBox.Show(Ex.Message);
229 }
230
231 }
232
233 private void cmdCancel_Click(object sender, System.EventArgs e)
234 {
235 try
236 {
237 //Check status and update progress control
238 string sSql = "BSDX COPY APPOINTMENT CANCEL^" + m_sTask;
239 DataTable dt = m_DocManager.RPMSDataTable(sSql, "ApptCopyCancel");
240 Debug.Assert(dt.Rows.Count == 1);
241 DataRow dr = dt.Rows[0];
242 Object oCount = dr["RECORD_COUNT"];
243 string sCount = oCount.ToString();
244
245 lblProgress.Text = "Cancelling job...";
246 }
247 catch (Exception Ex)
248 {
249 MessageBox.Show(Ex.Message);
250 }
251 }
252
253 private void DCopyAppts_Closing(object sender, System.ComponentModel.CancelEventArgs e)
254 {
255
256 }
257
258 private void timerPoll_Tick(object sender, System.EventArgs e)
259 {
260 try
261 {
262 return;
263 //Check status and update progress control
264 //string sSql = "BSDX COPY APPOINTMENT STATUS^" + m_sTask;
265 //DataTable dt = m_DocManager.RPMSDataTable(sSql, "ApptCopyStatus");
266 //Debug.Assert(dt.Rows.Count == 1);
267 //DataRow dr = dt.Rows[0];
268 //Object oCount = dr["RECORD_COUNT"];
269 //string sCount = oCount.ToString();
270 //Object oError = dr["ERRORID"];
271 //string sError = oError.ToString();
272 //if (sError != "OK")
273 //{
274 // timerPoll.Stop();
275 // lblProgress.Text = sError;
276 //}
277 //else if ((sCount.StartsWith("Finished"))||(sCount.StartsWith("Cancelled")))
278 //{
279 // timerPoll.Stop();
280 // lblProgress.Text = sCount;
281 // cmdOK.Enabled = true;
282 // cmdCancel.Enabled = false;
283 //}
284 //else
285 //{
286 // lblProgress.Text = "RPMS Job queued as Task #" + m_sTask + ". " + sCount; // + " records copied so far.";
287 //}
288 }
289 catch (Exception Ex)
290 {
291 MessageBox.Show(Ex.Message);
292 }
293 }
294
295 #endregion Methods and Handlers
296 }
297}
Note: See TracBrowser for help on using the repository browser.