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

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

i18n code (use FM Dates instead of localized dates)

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