source: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVView.cs@ 1011

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

UCPatientAppts: Fixes printing empty table bug reported by EHS.
DAccessTemplate: Various usability improvements.
CGDocumentManager: Fixed Delegate code so that it can operate asynchronously
CGAVView: Some temporary fixes (not totally usable): Added non-functional Delete Slots menu option; Added Background worker for saving acccess slots
In the future, Delete Slots will work; and will use ADO.net Updatable datatable for saving access slots.
calendarGrid: just some comments for now
AssemblyInfo: bumped version up to v1.4.2

File size: 58.2 KB
Line 
1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Diagnostics;
7using System.Data;
8using System.Data.OleDb;
9using System.IO;
10using System.Runtime.Serialization;
11using System.Runtime.Serialization.Formatters.Binary;
12using IndianHealthService.BMXNet;
13
14
15namespace IndianHealthService.ClinicalScheduling
16{
17 /// <summary>
18 /// Summary description for CGAVView.
19 /// </summary>
20 public class CGAVView : System.Windows.Forms.Form
21 {
22
23
24 public CGAVView()
25 {
26 //
27 // Required for Windows Form Designer support
28 //
29 InitializeComponent();
30
31 //
32 // TODO: Add any constructor code after InitializeComponent call
33 //
34 this.panelRight.Visible = false;
35 this.tvSchedules.Visible = false;
36 m_ClipList = new CGAppointments();
37 }
38
39 #region Windows Form Designer generated code
40 /// <summary>
41 /// Required method for Designer support - do not modify
42 /// the contents of this method with the code editor.
43 /// </summary>
44 private void InitializeComponent()
45 {
46 this.components = new System.ComponentModel.Container();
47 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CGAVView));
48 this.panelRight = new System.Windows.Forms.Panel();
49 this.panelClip = new System.Windows.Forms.Panel();
50 this.lstClip = new System.Windows.Forms.ListBox();
51 this.ctxApptClipMenu = new System.Windows.Forms.ContextMenu();
52 this.mnuRemoveClipItem = new System.Windows.Forms.MenuItem();
53 this.mnuClearClipItems = new System.Windows.Forms.MenuItem();
54 this.label1 = new System.Windows.Forms.Label();
55 this.panelBottom = new System.Windows.Forms.Panel();
56 this.statusBar1 = new System.Windows.Forms.StatusBar();
57 this.panelTop = new System.Windows.Forms.Panel();
58 this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
59 this.lblResource = new System.Windows.Forms.Label();
60 this.panelCenter = new System.Windows.Forms.Panel();
61 this.ctxCalendarGrid = new System.Windows.Forms.ContextMenu();
62 this.ctxCalGridAdd = new System.Windows.Forms.MenuItem();
63 this.ctxCalGridEdit = new System.Windows.Forms.MenuItem();
64 this.ctxCalGridDelete = new System.Windows.Forms.MenuItem();
65 this.tvSchedules = new System.Windows.Forms.TreeView();
66 this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
67 this.menuItem1 = new System.Windows.Forms.MenuItem();
68 this.mnuLoadTemplate = new System.Windows.Forms.MenuItem();
69 this.mnuSaveTemplate = new System.Windows.Forms.MenuItem();
70 this.mnuDeleteAllAppointments = new System.Windows.Forms.MenuItem();
71 this.menuItem6 = new System.Windows.Forms.MenuItem();
72 this.mnuSchedulingManagment = new System.Windows.Forms.MenuItem();
73 this.menuItem5 = new System.Windows.Forms.MenuItem();
74 this.mnuClose = new System.Windows.Forms.MenuItem();
75 this.mnuAvailability = new System.Windows.Forms.MenuItem();
76 this.mnuAddNewAV = new System.Windows.Forms.MenuItem();
77 this.mnuRemoveAV = new System.Windows.Forms.MenuItem();
78 this.mnuEditAV = new System.Windows.Forms.MenuItem();
79 this.mnuCalendar = new System.Windows.Forms.MenuItem();
80 this.mnu1Day = new System.Windows.Forms.MenuItem();
81 this.mnu5Day = new System.Windows.Forms.MenuItem();
82 this.mnu7Day = new System.Windows.Forms.MenuItem();
83 this.menuItem7 = new System.Windows.Forms.MenuItem();
84 this.mnuTimeScale = new System.Windows.Forms.MenuItem();
85 this.mnu10Minute = new System.Windows.Forms.MenuItem();
86 this.mnu15Minute = new System.Windows.Forms.MenuItem();
87 this.mnu20Minute = new System.Windows.Forms.MenuItem();
88 this.mnu30Minute = new System.Windows.Forms.MenuItem();
89 this.mnuViewRightPanel = new System.Windows.Forms.MenuItem();
90 this.mnuHelp = new System.Windows.Forms.MenuItem();
91 this.mnuHelpAbout = new System.Windows.Forms.MenuItem();
92 this.splitter1 = new System.Windows.Forms.Splitter();
93 this.saveAccessBlocksWorker = new System.ComponentModel.BackgroundWorker();
94 this.calendarGrid1 = new IndianHealthService.ClinicalScheduling.CalendarGrid();
95 this.panelRight.SuspendLayout();
96 this.panelClip.SuspendLayout();
97 this.panelBottom.SuspendLayout();
98 this.panelTop.SuspendLayout();
99 this.panelCenter.SuspendLayout();
100 this.SuspendLayout();
101 //
102 // panelRight
103 //
104 this.panelRight.Controls.Add(this.panelClip);
105 this.panelRight.Dock = System.Windows.Forms.DockStyle.Right;
106 this.panelRight.Location = new System.Drawing.Point(728, 0);
107 this.panelRight.Name = "panelRight";
108 this.panelRight.Size = new System.Drawing.Size(120, 393);
109 this.panelRight.TabIndex = 1;
110 //
111 // panelClip
112 //
113 this.panelClip.Controls.Add(this.lstClip);
114 this.panelClip.Controls.Add(this.label1);
115 this.panelClip.Dock = System.Windows.Forms.DockStyle.Top;
116 this.panelClip.Location = new System.Drawing.Point(0, 0);
117 this.panelClip.Name = "panelClip";
118 this.panelClip.Size = new System.Drawing.Size(120, 448);
119 this.panelClip.TabIndex = 1;
120 //
121 // lstClip
122 //
123 this.lstClip.AllowDrop = true;
124 this.lstClip.ContextMenu = this.ctxApptClipMenu;
125 this.lstClip.DisplayMember = "ToString()";
126 this.lstClip.Dock = System.Windows.Forms.DockStyle.Fill;
127 this.lstClip.Location = new System.Drawing.Point(0, 32);
128 this.lstClip.Name = "lstClip";
129 this.lstClip.Size = new System.Drawing.Size(120, 416);
130 this.lstClip.TabIndex = 0;
131 this.lstClip.DragDrop += new System.Windows.Forms.DragEventHandler(this.lstClip_DragDrop);
132 this.lstClip.DragEnter += new System.Windows.Forms.DragEventHandler(this.lstClip_DragEnter);
133 this.lstClip.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstClip_MouseDown);
134 this.lstClip.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lstClip_MouseMove);
135 //
136 // ctxApptClipMenu
137 //
138 this.ctxApptClipMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
139 this.mnuRemoveClipItem,
140 this.mnuClearClipItems});
141 this.ctxApptClipMenu.Popup += new System.EventHandler(this.ctxApptClipMenu_Popup);
142 //
143 // mnuRemoveClipItem
144 //
145 this.mnuRemoveClipItem.Index = 0;
146 this.mnuRemoveClipItem.Text = "Remove Item";
147 this.mnuRemoveClipItem.Click += new System.EventHandler(this.mnuRemoveClipItem_Click);
148 //
149 // mnuClearClipItems
150 //
151 this.mnuClearClipItems.Index = 1;
152 this.mnuClearClipItems.Text = "Clear All";
153 this.mnuClearClipItems.Click += new System.EventHandler(this.mnuClearClipItems_Click);
154 //
155 // label1
156 //
157 this.label1.Dock = System.Windows.Forms.DockStyle.Top;
158 this.label1.Location = new System.Drawing.Point(0, 0);
159 this.label1.Name = "label1";
160 this.label1.Size = new System.Drawing.Size(120, 32);
161 this.label1.TabIndex = 1;
162 this.label1.Text = "Access Block Clipboard";
163 this.label1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
164 //
165 // panelBottom
166 //
167 this.panelBottom.Controls.Add(this.statusBar1);
168 this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
169 this.panelBottom.Location = new System.Drawing.Point(8, 369);
170 this.panelBottom.Name = "panelBottom";
171 this.panelBottom.Size = new System.Drawing.Size(720, 24);
172 this.panelBottom.TabIndex = 2;
173 //
174 // statusBar1
175 //
176 this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
177 this.statusBar1.Location = new System.Drawing.Point(0, 0);
178 this.statusBar1.Name = "statusBar1";
179 this.statusBar1.Size = new System.Drawing.Size(720, 24);
180 this.statusBar1.SizingGrip = false;
181 this.statusBar1.TabIndex = 1;
182 //
183 // panelTop
184 //
185 this.panelTop.Controls.Add(this.dateTimePicker1);
186 this.panelTop.Controls.Add(this.lblResource);
187 this.panelTop.Dock = System.Windows.Forms.DockStyle.Top;
188 this.panelTop.Location = new System.Drawing.Point(8, 0);
189 this.panelTop.Name = "panelTop";
190 this.panelTop.Size = new System.Drawing.Size(720, 24);
191 this.panelTop.TabIndex = 3;
192 //
193 // dateTimePicker1
194 //
195 this.dateTimePicker1.Dock = System.Windows.Forms.DockStyle.Right;
196 this.dateTimePicker1.DropDownAlign = System.Windows.Forms.LeftRightAlignment.Right;
197 this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Short;
198 this.dateTimePicker1.Location = new System.Drawing.Point(592, 0);
199 this.dateTimePicker1.Name = "dateTimePicker1";
200 this.dateTimePicker1.Size = new System.Drawing.Size(128, 20);
201 this.dateTimePicker1.TabIndex = 4;
202 this.dateTimePicker1.ValueChanged += new System.EventHandler(this.dateTimePicker1_ValueChanged);
203 //
204 // lblResource
205 //
206 this.lblResource.Dock = System.Windows.Forms.DockStyle.Fill;
207 this.lblResource.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
208 this.lblResource.ForeColor = System.Drawing.SystemColors.Highlight;
209 this.lblResource.Location = new System.Drawing.Point(0, 0);
210 this.lblResource.Name = "lblResource";
211 this.lblResource.Size = new System.Drawing.Size(720, 24);
212 this.lblResource.TabIndex = 3;
213 this.lblResource.Text = "lblResource";
214 //
215 // panelCenter
216 //
217 this.panelCenter.Controls.Add(this.calendarGrid1);
218 this.panelCenter.Dock = System.Windows.Forms.DockStyle.Fill;
219 this.panelCenter.Location = new System.Drawing.Point(8, 24);
220 this.panelCenter.Name = "panelCenter";
221 this.panelCenter.Size = new System.Drawing.Size(712, 345);
222 this.panelCenter.TabIndex = 4;
223 //
224 // ctxCalendarGrid
225 //
226 this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
227 this.ctxCalGridAdd,
228 this.ctxCalGridEdit,
229 this.ctxCalGridDelete});
230 this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
231 //
232 // ctxCalGridAdd
233 //
234 this.ctxCalGridAdd.Index = 0;
235 this.ctxCalGridAdd.Text = "Add New Access Block";
236 this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
237 //
238 // ctxCalGridEdit
239 //
240 this.ctxCalGridEdit.Index = 1;
241 this.ctxCalGridEdit.Text = "Edit Access Block";
242 this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
243 //
244 // ctxCalGridDelete
245 //
246 this.ctxCalGridDelete.Index = 2;
247 this.ctxCalGridDelete.Text = "Delete Access Block";
248 this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
249 //
250 // tvSchedules
251 //
252 this.tvSchedules.BackColor = System.Drawing.SystemColors.ControlLight;
253 this.tvSchedules.Dock = System.Windows.Forms.DockStyle.Left;
254 this.tvSchedules.HotTracking = true;
255 this.tvSchedules.Location = new System.Drawing.Point(0, 0);
256 this.tvSchedules.Name = "tvSchedules";
257 this.tvSchedules.Size = new System.Drawing.Size(8, 393);
258 this.tvSchedules.Sorted = true;
259 this.tvSchedules.TabIndex = 5;
260 //
261 // mainMenu1
262 //
263 this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
264 this.menuItem1,
265 this.mnuAvailability,
266 this.mnuCalendar,
267 this.mnuHelp});
268 //
269 // menuItem1
270 //
271 this.menuItem1.Index = 0;
272 this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
273 this.mnuLoadTemplate,
274 this.mnuSaveTemplate,
275 this.mnuDeleteAllAppointments,
276 this.menuItem6,
277 this.mnuSchedulingManagment,
278 this.menuItem5,
279 this.mnuClose});
280 this.menuItem1.Text = "&File";
281 //
282 // mnuLoadTemplate
283 //
284 this.mnuLoadTemplate.Index = 0;
285 this.mnuLoadTemplate.Shortcut = System.Windows.Forms.Shortcut.CtrlA;
286 this.mnuLoadTemplate.Text = "&Apply Template";
287 this.mnuLoadTemplate.Click += new System.EventHandler(this.mnuLoadTemplate_Click);
288 //
289 // mnuSaveTemplate
290 //
291 this.mnuSaveTemplate.Index = 1;
292 this.mnuSaveTemplate.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
293 this.mnuSaveTemplate.Text = "&Save Template";
294 this.mnuSaveTemplate.Click += new System.EventHandler(this.mnuSaveTemplate_Click);
295 //
296 // mnuDeleteAllAppointments
297 //
298 this.mnuDeleteAllAppointments.Enabled = false;
299 this.mnuDeleteAllAppointments.Index = 2;
300 this.mnuDeleteAllAppointments.Shortcut = System.Windows.Forms.Shortcut.CtrlD;
301 this.mnuDeleteAllAppointments.Text = "&Delete All Appointments";
302 this.mnuDeleteAllAppointments.Click += new System.EventHandler(this.mnuDeleteAllAppointments_Click);
303 //
304 // menuItem6
305 //
306 this.menuItem6.Index = 3;
307 this.menuItem6.Text = "-";
308 //
309 // mnuSchedulingManagment
310 //
311 this.mnuSchedulingManagment.Index = 4;
312 this.mnuSchedulingManagment.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftM;
313 this.mnuSchedulingManagment.Text = "Scheduling &Management";
314 this.mnuSchedulingManagment.Click += new System.EventHandler(this.mnuSchedulingManagment_Click);
315 //
316 // menuItem5
317 //
318 this.menuItem5.Index = 5;
319 this.menuItem5.Text = "-";
320 //
321 // mnuClose
322 //
323 this.mnuClose.Index = 6;
324 this.mnuClose.Shortcut = System.Windows.Forms.Shortcut.CtrlW;
325 this.mnuClose.Text = "&Close";
326 this.mnuClose.Click += new System.EventHandler(this.mnuClose_Click);
327 //
328 // mnuAvailability
329 //
330 this.mnuAvailability.Index = 1;
331 this.mnuAvailability.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
332 this.mnuAddNewAV,
333 this.mnuRemoveAV,
334 this.mnuEditAV});
335 this.mnuAvailability.Text = "&Access Blocks";
336 this.mnuAvailability.Popup += new System.EventHandler(this.mnuAvailability_Popup);
337 //
338 // mnuAddNewAV
339 //
340 this.mnuAddNewAV.Index = 0;
341 this.mnuAddNewAV.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
342 this.mnuAddNewAV.Text = "Add &New Block";
343 this.mnuAddNewAV.Click += new System.EventHandler(this.mnuAddNewAV_Click);
344 //
345 // mnuRemoveAV
346 //
347 this.mnuRemoveAV.Index = 1;
348 this.mnuRemoveAV.Shortcut = System.Windows.Forms.Shortcut.CtrlR;
349 this.mnuRemoveAV.Text = "&Remove Block";
350 this.mnuRemoveAV.Click += new System.EventHandler(this.mnuRemoveAV_Click);
351 //
352 // mnuEditAV
353 //
354 this.mnuEditAV.Index = 2;
355 this.mnuEditAV.Shortcut = System.Windows.Forms.Shortcut.CtrlE;
356 this.mnuEditAV.Text = "&Edit Block";
357 this.mnuEditAV.Click += new System.EventHandler(this.mnuEditAV_Click);
358 //
359 // mnuCalendar
360 //
361 this.mnuCalendar.Index = 2;
362 this.mnuCalendar.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
363 this.mnu1Day,
364 this.mnu5Day,
365 this.mnu7Day,
366 this.menuItem7,
367 this.mnuTimeScale,
368 this.mnuViewRightPanel});
369 this.mnuCalendar.Text = "&View";
370 //
371 // mnu1Day
372 //
373 this.mnu1Day.Index = 0;
374 this.mnu1Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl1;
375 this.mnu1Day.Text = "&1-Day View";
376 this.mnu1Day.Click += new System.EventHandler(this.mnu1Day_Click);
377 //
378 // mnu5Day
379 //
380 this.mnu5Day.Index = 1;
381 this.mnu5Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl5;
382 this.mnu5Day.Text = "&5-Day View";
383 this.mnu5Day.Click += new System.EventHandler(this.mnu5Day_Click);
384 //
385 // mnu7Day
386 //
387 this.mnu7Day.Index = 2;
388 this.mnu7Day.Shortcut = System.Windows.Forms.Shortcut.Ctrl7;
389 this.mnu7Day.Text = "&7-Day View";
390 this.mnu7Day.Click += new System.EventHandler(this.mnu7Day_Click);
391 //
392 // menuItem7
393 //
394 this.menuItem7.Index = 3;
395 this.menuItem7.Text = "-";
396 //
397 // mnuTimeScale
398 //
399 this.mnuTimeScale.Index = 4;
400 this.mnuTimeScale.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
401 this.mnu10Minute,
402 this.mnu15Minute,
403 this.mnu20Minute,
404 this.mnu30Minute});
405 this.mnuTimeScale.Text = "&Time Scale";
406 //
407 // mnu10Minute
408 //
409 this.mnu10Minute.Index = 0;
410 this.mnu10Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl0;
411 this.mnu10Minute.Text = "&10-Minute";
412 this.mnu10Minute.Click += new System.EventHandler(this.mnu10Minute_Click);
413 //
414 // mnu15Minute
415 //
416 this.mnu15Minute.Index = 1;
417 this.mnu15Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl4;
418 this.mnu15Minute.Text = "&15-Minute";
419 this.mnu15Minute.Click += new System.EventHandler(this.mnu15Minute_Click);
420 //
421 // mnu20Minute
422 //
423 this.mnu20Minute.Index = 2;
424 this.mnu20Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl3;
425 this.mnu20Minute.Text = "&20-Minute";
426 this.mnu20Minute.Click += new System.EventHandler(this.mnu20Minute_Click);
427 //
428 // mnu30Minute
429 //
430 this.mnu30Minute.Index = 3;
431 this.mnu30Minute.Shortcut = System.Windows.Forms.Shortcut.Ctrl2;
432 this.mnu30Minute.Text = "&30-Minute";
433 this.mnu30Minute.Click += new System.EventHandler(this.mnu30Minute_Click);
434 //
435 // mnuViewRightPanel
436 //
437 this.mnuViewRightPanel.Index = 5;
438 this.mnuViewRightPanel.Text = "&Access Block Clipboard";
439 this.mnuViewRightPanel.Click += new System.EventHandler(this.mnuViewRightPanel_Click);
440 //
441 // mnuHelp
442 //
443 this.mnuHelp.Index = 3;
444 this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
445 this.mnuHelpAbout});
446 this.mnuHelp.Text = "&Help";
447 //
448 // mnuHelpAbout
449 //
450 this.mnuHelpAbout.Index = 0;
451 this.mnuHelpAbout.Text = "&About";
452 this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click);
453 //
454 // splitter1
455 //
456 this.splitter1.Dock = System.Windows.Forms.DockStyle.Right;
457 this.splitter1.Location = new System.Drawing.Point(720, 24);
458 this.splitter1.Name = "splitter1";
459 this.splitter1.Size = new System.Drawing.Size(8, 345);
460 this.splitter1.TabIndex = 6;
461 this.splitter1.TabStop = false;
462 //
463 // saveAccessBlocksWorker
464 //
465 this.saveAccessBlocksWorker.WorkerReportsProgress = true;
466 this.saveAccessBlocksWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.saveAccessBlocksWorker_DoWork);
467 this.saveAccessBlocksWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.saveAccessBlocksWorker_ProgressChanged);
468 this.saveAccessBlocksWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.saveAccessBlocksWorker_RunWorkerCompleted);
469 //
470 // calendarGrid1
471 //
472 this.calendarGrid1.AllowDrop = true;
473 this.calendarGrid1.Appointments = null;
474 this.calendarGrid1.ApptDragSource = null;
475 this.calendarGrid1.AutoScroll = true;
476 this.calendarGrid1.AutoScrollMinSize = new System.Drawing.Size(600, 1898);
477 this.calendarGrid1.AvailabilityArray = null;
478 this.calendarGrid1.BackColor = System.Drawing.SystemColors.Window;
479 this.calendarGrid1.Columns = 5;
480 this.calendarGrid1.ContextMenu = this.ctxCalendarGrid;
481 this.calendarGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
482 this.calendarGrid1.DrawWalkIns = true;
483 this.calendarGrid1.GridBackColor = "blue";
484 this.calendarGrid1.GridEnter = false;
485 this.calendarGrid1.Location = new System.Drawing.Point(0, 0);
486 this.calendarGrid1.Name = "calendarGrid1";
487 this.calendarGrid1.Resources = ((System.Collections.ArrayList)(resources.GetObject("calendarGrid1.Resources")));
488 this.calendarGrid1.SelectedAppointment = 0;
489 this.calendarGrid1.Size = new System.Drawing.Size(712, 345);
490 this.calendarGrid1.StartDate = new System.DateTime(2003, 1, 27, 0, 0, 0, 0);
491 this.calendarGrid1.TabIndex = 2;
492 this.calendarGrid1.TimeScale = 20;
493 this.calendarGrid1.CGAppointmentAdded += new IndianHealthService.ClinicalScheduling.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentAdded);
494 this.calendarGrid1.CGAppointmentChanged += new IndianHealthService.ClinicalScheduling.CGAppointmentChangedHandler(this.calendarGrid1_CGAppointmentChanged);
495 this.calendarGrid1.CGSelectionChanged += new IndianHealthService.ClinicalScheduling.CGSelectionChangedHandler(this.calendarGrid1_CGSelectionChanged);
496 this.calendarGrid1.DoubleClick += new System.EventHandler(this.calendarGrid1_DoubleClick);
497 //
498 // CGAVView
499 //
500 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
501 this.ClientSize = new System.Drawing.Size(848, 393);
502 this.Controls.Add(this.panelCenter);
503 this.Controls.Add(this.splitter1);
504 this.Controls.Add(this.panelTop);
505 this.Controls.Add(this.panelBottom);
506 this.Controls.Add(this.panelRight);
507 this.Controls.Add(this.tvSchedules);
508 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
509 this.Menu = this.mainMenu1;
510 this.Name = "CGAVView";
511 this.Text = "CGAVView";
512 this.Closing += new System.ComponentModel.CancelEventHandler(this.CGAVView_Closing);
513 this.Load += new System.EventHandler(this.CGAVView_Load);
514 this.panelRight.ResumeLayout(false);
515 this.panelClip.ResumeLayout(false);
516 this.panelBottom.ResumeLayout(false);
517 this.panelTop.ResumeLayout(false);
518 this.panelCenter.ResumeLayout(false);
519 this.ResumeLayout(false);
520
521 }
522 #endregion
523
524 private IContainer components;
525
526 #region Member Variables
527
528 private CGAVDocument m_Document;
529 private System.Windows.Forms.Panel panelRight;
530 private System.Windows.Forms.Panel panelBottom;
531 private System.Windows.Forms.Panel panelTop;
532 private System.Windows.Forms.Panel panelCenter;
533 private System.Windows.Forms.Label lblResource;
534 private System.Windows.Forms.TreeView tvSchedules;
535 private System.Windows.Forms.DateTimePicker dateTimePicker1;
536 private IndianHealthService.ClinicalScheduling.CalendarGrid calendarGrid1;
537 private System.Windows.Forms.StatusBar statusBar1;
538 private System.Windows.Forms.MainMenu mainMenu1;
539 private System.Windows.Forms.MenuItem mnuAvailability;
540 private System.Windows.Forms.MenuItem mnuAddNewAV;
541 private System.Windows.Forms.MenuItem mnuRemoveAV;
542 private System.Windows.Forms.MenuItem mnuEditAV;
543 private System.Windows.Forms.MenuItem menuItem1;
544 private System.Windows.Forms.MenuItem mnuSchedulingManagment;
545 private System.Windows.Forms.MenuItem menuItem5;
546 private System.Windows.Forms.MenuItem menuItem6;
547 private System.Windows.Forms.MenuItem mnuClose;
548 private System.Windows.Forms.MenuItem mnuHelp;
549 private System.Windows.Forms.MenuItem mnuHelpAbout;
550 private System.Windows.Forms.MenuItem mnuLoadTemplate;
551 private System.Windows.Forms.MenuItem mnuSaveTemplate;
552 private System.Windows.Forms.Panel panelClip;
553 private System.Windows.Forms.ListBox lstClip;
554 private System.Windows.Forms.Label label1;
555 private System.Windows.Forms.MenuItem mnuCalendar;
556 private System.Windows.Forms.MenuItem mnuViewRightPanel;
557 private System.Windows.Forms.MenuItem mnuTimeScale;
558 private System.Windows.Forms.MenuItem mnu10Minute;
559 private System.Windows.Forms.MenuItem mnu15Minute;
560 private System.Windows.Forms.MenuItem mnu20Minute;
561 private System.Windows.Forms.MenuItem mnu30Minute;
562 private System.Windows.Forms.MenuItem menuItem7;
563 private System.Windows.Forms.MenuItem mnu1Day;
564 private System.Windows.Forms.MenuItem mnu5Day;
565 private System.Windows.Forms.MenuItem mnu7Day;
566 private System.Windows.Forms.Splitter splitter1;
567 private CGDocumentManager m_DocManager;
568 private CGAppointments m_ClipList;
569 private System.Windows.Forms.ContextMenu ctxApptClipMenu;
570 private System.Windows.Forms.MenuItem mnuRemoveClipItem;
571 private System.Windows.Forms.MenuItem mnuClearClipItems;
572 private System.Windows.Forms.ContextMenu ctxCalendarGrid;
573 private System.Windows.Forms.MenuItem ctxCalGridAdd;
574 private System.Windows.Forms.MenuItem ctxCalGridEdit;
575 private System.Windows.Forms.MenuItem ctxCalGridDelete;
576 private BackgroundWorker saveAccessBlocksWorker;
577 private MenuItem mnuDeleteAllAppointments;
578 private bool m_bDragDropStart = false;
579
580 #endregion
581
582 #region Properties
583
584 /// <summary>
585 /// Access the CalendarGrid associated with this view
586 /// </summary>
587 public CalendarGrid CGrid
588 {
589 get
590 {
591 return this.calendarGrid1;
592 }
593 }
594 /// <summary>
595 /// Accesses the document associated with this view
596 /// </summary>
597 public CGAVDocument Document
598 {
599 get
600 {
601 return this.m_Document;
602 }
603 set
604 {
605 this.m_Document = value;
606 }
607 }
608
609 public CGDocumentManager DocManager
610 {
611 get
612 {
613 return m_DocManager;
614 }
615 set
616 {
617 m_DocManager = value;
618 }
619
620 }
621
622 public CGAppointments AVBlocks
623 {
624 get
625 {
626 return this.calendarGrid1.Appointments;
627 }
628 set
629 {
630 this.calendarGrid1.Appointments = value;
631 }
632 }
633
634 public DateTime StartDate
635 {
636 get
637 {
638 return this.calendarGrid1.StartDate;
639 }
640 set
641 {
642 this.calendarGrid1.StartDate = value;
643 }
644 }
645
646 #endregion //Properties
647
648 #region Methods
649
650 private void RaiseRPMSEvent(string sEvent, string sParams)
651 {
652 try
653 {
654 //Signal RPMS to raise an event
655// string sSql;
656// sSql = "BSDX RAISE EVENT^" + sEvent + "^" + sParams + "^^";
657// DataTable dtAppt =m_DocManager.RPMSDataTable(sSql, "RaiseEvent");
658 this.m_DocManager.ConnectInfo.RaiseEvent(sEvent, sParams, true);
659 }
660 catch (Exception ex)
661 {
662 Debug.Write(ex.Message);
663 }
664 }
665
666 void UpdateStatusBar(DateTime dStart, DateTime dEnd)
667 {
668 string sMsg = dStart.ToShortTimeString() + " to " + dEnd.ToShortTimeString();
669 this.statusBar1.Text = sMsg;
670 }
671
672 private void AvailabilityEdit()
673 {
674 try
675 {
676 int nApptID = this.calendarGrid1.SelectedAppointment;
677 if (nApptID != 0)
678 {
679
680 CGAppointment pAppt = this.Document.AVBlocks.GetAppointment(nApptID);
681 DAccessBlock dA = new DAccessBlock();
682 dA.InitializePage(pAppt, m_DocManager.GlobalDataSet);
683 calendarGrid1.CGToolTip.Active = false;
684 if (dA.ShowDialog(this) == DialogResult.Cancel)
685 {
686 calendarGrid1.CGToolTip.Active = true;
687 return;
688 }
689 calendarGrid1.CGToolTip.Active = true;
690 this.Document.DeleteAvailability(nApptID);
691 this.Document.CreateAppointment(dA.Appointment);
692 this.calendarGrid1.Invalidate();
693 this.m_DocManager.UpdateViews((string) this.m_Document.Resources[0], "");
694 }
695 }
696 catch (Exception ex)
697 {
698 MessageBox.Show("Unable to add new access block " + ex.Message, "Clinical Scheduling");
699 return;
700 }
701 try
702 {
703 RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
704 this.calendarGrid1.Invalidate();
705 }
706 catch (Exception ex)
707 {
708 Debug.Write(ex.Message);
709 }
710 }
711
712 private void AvailabilityAddNew()
713 {
714 try
715 {
716 CGAppointment appt = new CGAppointment();
717
718 //Get Time and Resource from Selected Cell
719 DateTime dStart = DateTime.Today;
720 DateTime dEnd = DateTime.Today;
721 string sResource = "";
722 bool bRet = this.calendarGrid1.GetSelectedTime(out dStart, out dEnd, out sResource);
723 if (bRet == false)
724 return;
725
726 foreach (CGAppointment a in this.Document.m_AVBlocks.AppointmentTable.Values)
727 {
728 DateTime sStart2 = a.StartTime;
729 DateTime sEnd2 = a.EndTime;
730 if (CGSchedLib.TimesOverlap(dStart, dEnd, a.StartTime, a.EndTime))
731 {
732 MessageBox.Show("Access blocks may not overlap.","Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
733 return;
734 }
735 }
736
737 string sNote = "";
738 DAccessBlock dA = new DAccessBlock();
739 dA.InitializePage(dStart, dEnd, sResource, sNote, this.m_DocManager.GlobalDataSet);
740 if (dA.ShowDialog(this) == DialogResult.Cancel)
741 {
742 return;
743 }
744 appt.StartTime = dStart;
745 appt.EndTime = dEnd;
746 appt.Resource = sResource;
747 appt.Note = " " + dA.Note; // + ": " + dA.Slots.ToString()+ " Slots";
748 appt.AccessTypeID = dA.AccessTypeID;
749 appt.Slots = dA.Slots;
750
751 //Call Document to add a new appointment
752 this.Document.CreateAppointment(appt);
753 this.m_DocManager.UpdateViews((string) this.m_Document.Resources[0], "");
754 }
755 catch (Exception ex)
756 {
757 MessageBox.Show("Unable to add new access block " + ex.Message, "Clinical Scheduling");
758 return;
759 }
760 try
761 {
762 RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
763 this.calendarGrid1.Invalidate();
764 }
765 catch (Exception ex)
766 {
767 Debug.Write(ex.Message);
768 }
769 }//End AvailabilityAddNew
770
771 private void MassAppointmentDelete()
772 {
773 DialogResult msgResult = MessageBox.Show("Delete all Access Slots?", "Delete Slots?",MessageBoxButtons.YesNo);
774 if (msgResult != DialogResult.Yes) return;
775
776 CGAppointments appointments = new CGAppointments();
777 appointments = this.Document.AVBlocks;
778
779 foreach (CGAppointment a in appointments.AppointmentTable.Values)
780 {
781 int nApptID = a.AppointmentKey;
782 Debug.Assert(nApptID != 0);
783 try
784 {
785 Document.DeleteAvailability(nApptID);
786 }
787 catch (Exception ex)
788 {
789 MessageBox.Show("Unable to delete access block" + ex.Message, "Clinical Scheduling");
790 }
791
792 }
793
794 this.m_DocManager.UpdateViews((string)this.m_Document.Resources[0], "");
795 RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
796 this.calendarGrid1.Invalidate();
797 }
798
799 private void AppointmentDelete()
800 {
801 calendarGrid1.CGToolTip.Active = false;
802 string sMsg = " this access block?";
803 if (calendarGrid1.SelectedAppointments.AppointmentTable.Count > 1)
804 sMsg = " these access blocks?";
805
806 calendarGrid1.CGToolTip.Active = true;
807
808 bool bDeleted = false;
809 foreach (CGAppointment a in this.calendarGrid1.SelectedAppointments.AppointmentTable.Values)
810 {
811 int nApptID = a.AppointmentKey;
812 Debug.Assert(nApptID != 0);
813 try
814 {
815 Document.DeleteAvailability(nApptID);
816 bDeleted = true;
817 }
818 catch (Exception ex)
819 {
820 MessageBox.Show("Unable to delete access block" + ex.Message, "Clinical Scheduling");
821 }
822 }
823 if (bDeleted == true)
824 {
825 try
826 {
827 this.m_DocManager.UpdateViews((string) this.m_Document.Resources[0], "");
828 RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
829 }
830 catch (Exception ex)
831 {
832 Debug.Write(ex.Message);
833 }
834 this.calendarGrid1.Invalidate();
835 }
836 }
837
838 private void AccessTypeManage()
839 {
840// DAccessType dAT = new DAccessType();
841// dAT.InitializePage(0, this.m_DocManager.GlobalDataSet, this.m_DocManager.ADOConnection);
842// if (dAT.ShowDialog(this) == DialogResult.Cancel)
843// {
844// return;
845// }
846 }
847
848 private void SchedulingManagement()
849 {
850 try
851 {
852 bool bLock = DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXMGR", "+");
853 if (bLock == false)
854 {
855 throw new Exception("Another user is currently in Scheduling Management. Try later.");
856 }
857
858 DManagement dMgm = new DManagement();
859 dMgm.InitializeDialog(this.m_DocManager);
860
861 if (dMgm.ShowDialog(this) == DialogResult.Cancel)
862 {
863 return;
864 }
865 bLock = DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXMGR", "-");
866 }
867 catch (Exception ex)
868 {
869 MessageBox.Show("Scheduling Management Error: " + ex.Message, "Clinical Scheduling");
870 }
871 }
872
873 public void UpdateArrays()
874 {
875 //TODO: Create these components
876 this.calendarGrid1.Resources = this.m_Document.Resources;
877 this.calendarGrid1.OnUpdateArrays();
878 this.lblResource.Text = this.m_Document.DocName;
879
880 }
881
882 /// <summary>
883 /// Clean up any resources being used.
884 /// </summary>
885 protected override void Dispose( bool disposing )
886 {
887 if( disposing )
888 {
889 if(components != null)
890 {
891 components.Dispose();
892 }
893 }
894 base.Dispose( disposing );
895 }
896 #endregion //Methods
897
898 #region Events
899
900 private void dateTimePicker1_ValueChanged(object sender, System.EventArgs e)
901 {
902 DateTime dDate = dateTimePicker1.Value;
903 dDate = dDate.Date;
904 this.Document.SelectedDate = dDate;
905 if (this.calendarGrid1.Columns > 1)
906 {
907 this.StartDate = this.Document.StartDate;
908 }
909 else
910 {
911 this.StartDate = this.Document.SelectedDate;
912 }
913 this.Document.UpdateAllViews();
914 this.calendarGrid1.Invalidate();
915 }
916
917 private void CGAVView_Load(object sender, System.EventArgs e)
918 {
919 Debug.Assert (this.Document != null);
920
921 //Register the view
922 CGDocumentManager.Current.RegisterAVDocumentView(this.Document, this);
923 this.mnu5Day.Click += new System.EventHandler(this.dateTimePicker1_ValueChanged); // MJL 1/17/2007
924 this.mnu7Day.Click += new System.EventHandler(this.dateTimePicker1_ValueChanged);
925
926 //Set start date
927 DateTime startDate,endDate;
928 Document.WeekNeedsRefresh(1, DateTime.Today, out startDate, out endDate);
929 this.StartDate = startDate;
930 //Draw the calendar
931 this.calendarGrid1.OnUpdateArrays();
932 this.calendarGrid1.Invalidate();
933
934 }
935
936 private void CGAVView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
937 {
938 this.calendarGrid1.CloseGrid();
939 DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXRES(" + Document.ResourceID.ToString() + ")", "-");
940 }
941
942 private void calendarGrid1_CGSelectionChanged(object sender, IndianHealthService.ClinicalScheduling.CGSelectionChangedArgs e)
943 {
944 UpdateStatusBar(e.StartTime, e.EndTime);
945 }
946
947 private void calendarGrid1_CGAppointmentChanged(object sender, IndianHealthService.ClinicalScheduling.CGAppointmentChangedArgs e)
948 {
949 try
950 {
951// this.DocManager.EnableAutoRefresh(false);
952
953 m_Document.ChangeAppointmentTime(e.Appointment, e.StartTime, e.EndTime, e.Resource);
954 this.m_DocManager.UpdateViews((string) this.m_Document.Resources[0], "");
955 }
956 catch (Exception ex)
957 {
958 MessageBox.Show("Unable to change access block " + ex.Message, "Clinical Scheduling");
959 this.m_DocManager.UpdateViews();
960 return;
961 }
962 finally
963 {
964// this.DocManager.EnableAutoRefresh(true);
965 }
966 try
967 {
968 RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
969 this.calendarGrid1.Invalidate();
970 }
971 catch (Exception ex)
972 {
973 Debug.Write(ex.Message);
974 }
975 }
976
977 private void mnuAddNewAV_Click(object sender, System.EventArgs e)
978 {
979 AvailabilityAddNew();
980 }
981
982 private void mnuRemoveAV_Click(object sender, System.EventArgs e)
983 {
984 this.AppointmentDelete();
985 }
986
987 private void mnuManageAT_Click(object sender, System.EventArgs e)
988 {
989 AccessTypeManage();
990 }
991
992 private void mnuEditAV_Click(object sender, System.EventArgs e)
993 {
994 AvailabilityEdit();
995 }
996
997 private void mnuAvailability_Popup(object sender, System.EventArgs e)
998 {
999 this.mnuAddNewAV.Enabled = (this.calendarGrid1.SelectedRange.Cells.CellCount > 0);
1000 this.mnuEditAV.Enabled = (this.calendarGrid1.SelectedAppointment > 0);
1001 this.mnuRemoveAV.Enabled = (this.calendarGrid1.SelectedAppointment > 0);
1002 }
1003
1004 private void mnuSchedulingManagment_Click(object sender, System.EventArgs e)
1005 {
1006 SchedulingManagement();
1007 }
1008
1009 #endregion //Events
1010
1011 private void mnuClose_Click(object sender, System.EventArgs e)
1012 {
1013 DialogResult dr = MessageBox.Show("Are you sure you want to close this schedule?", Application.ProductName, MessageBoxButtons.OKCancel);
1014 if (dr != DialogResult.OK)
1015 return;
1016
1017 this.Close();
1018 }
1019
1020 private void mnuHelpAbout_Click(object sender, System.EventArgs e)
1021 {
1022 MessageBox.Show("Clinical Scheduling Version " + Application.ProductVersion, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Information);
1023 }
1024
1025 private void ImplementMsg()
1026 {
1027 MessageBox.Show("Clinical Scheduling", "TODO: Implement this function");
1028 }
1029
1030 private void mnuLoadTemplate_Click(object sender, System.EventArgs e)
1031 {
1032 /*
1033 * Display dialog to collect:
1034 * - Number of weeks to apply template
1035 * - Starting week Monday
1036 * - Template path & filename
1037 *
1038 * for each week,
1039 * Delete all availability during that week
1040 * apply the template
1041 *
1042 */
1043 DAccessTemplate dlg = new DAccessTemplate();
1044 dlg.InitializePage();
1045 if (dlg.ShowDialog(this) == DialogResult.Cancel)
1046 {
1047 return;
1048 }
1049
1050 try
1051 {
1052 this.saveAccessBlocksWorker.RunWorkerAsync(dlg);
1053 //OpenFileDialog openFileDialog1 = dlg.FileDialog;
1054 //openFileDialog1.RestoreDirectory = false; // go back to our dir
1055 //Stream streamFile;
1056 //if((streamFile = openFileDialog1.OpenFile())== null)
1057 //{
1058 // MessageBox.Show("Unable to open template file.");
1059 // return;
1060 //}
1061
1062 //BinaryFormatter formatter = new BinaryFormatter();
1063 //CGAppointments cgaTemp = (CGAppointments) formatter.Deserialize(streamFile);
1064 //streamFile.Close();
1065
1066 //DateTime dtStart = dlg.StartDate;
1067 //DateTime newStartDate, newEndDate;
1068 //this.Document.WeekNeedsRefresh(1,dtStart, out newStartDate, out newEndDate);
1069 //dtStart = newStartDate;
1070 //int nWeeksToApply = dlg.WeeksToApply;
1071 //DateTime dtEnd = dtStart.AddDays(6); // or 7?
1072
1073 //string sResourceID = this.m_Document.ResourceID.ToString();
1074 //DataTable dt;
1075
1076 //for (int j=1; j < nWeeksToApply + 1; j++)
1077 //{
1078 // //Convert start and end to string
1079 // //string sStart = dtStart.ToString("M/d/yyyy");
1080 // //string sEnd = dtEnd.ToString("M/d/yyyy");
1081 // //i18n
1082 // string sStart = FMDateTime.Create(dtStart).DateOnly.FMDateString;
1083 // string sEnd = FMDateTime.Create(dtEnd).DateOnly.FMDateString;
1084 // //Cancel all existing access blocks in the date range
1085 // string sSql = "BSDX CANCEL AV BY DATE^" + sResourceID + "^" + sStart + "^" + sEnd;
1086 // dt = this.m_DocManager.RPMSDataTable(sSql, "Cancelled");
1087
1088 // //for each CGAppointment in AVBlocks, call AddNew
1089 // string sResource = "";
1090 // sResource = (string) this.Document.Resources[0];
1091 // foreach (CGAppointment a in cgaTemp.AppointmentTable.Values)
1092 // {
1093 // //Change the resource to the current one
1094 // a.Resource = sResource;
1095
1096 // //Change the date to correspond to the GridColumn member
1097 // int col = a.GridColumn;
1098 // col--;
1099 // DateTime dBuildDate = dtStart.Date;
1100 // dBuildDate = dBuildDate.AddDays(col);
1101 // dBuildDate = dBuildDate.AddHours(a.StartTime.Hour);
1102 // dBuildDate = dBuildDate.AddMinutes(a.StartTime.Minute);
1103 // a.StartTime = dBuildDate;
1104 // dBuildDate = dtStart.Date;
1105 // dBuildDate = dBuildDate.AddDays(col);
1106 // dBuildDate = dBuildDate.AddHours(a.EndTime.Hour);
1107 // dBuildDate = dBuildDate.AddMinutes(a.EndTime.Minute);
1108 // a.EndTime = dBuildDate;
1109
1110 // //Call Document to add a new appointment
1111 // this.Document.CreateAppointmentAuto(a);
1112 // }
1113
1114 // //Increment start and end
1115 // dtStart = dtStart.AddDays(7);
1116 // dtEnd = dtStart.AddDays(6);
1117
1118 // }//end for
1119 try
1120 {
1121 RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
1122 }
1123 catch (Exception ex)
1124 {
1125 Debug.Write(ex.Message);
1126 }
1127 this.calendarGrid1.Invalidate();
1128 this.m_DocManager.UpdateViews((string) this.m_Document.Resources[0], "");
1129 }
1130 catch (Exception ex)
1131 {
1132 MessageBox.Show(this, "Error loading template: " + ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
1133 }
1134 }
1135
1136 //Check that there are no blocks in document
1137// if (this.Document.AVBlocks.AppointmentTable.Count > 0)
1138// {
1139// Exception bmxex = new Exception("You may not load a template if there are already access blocks defined for the week.");
1140// throw bmxex;
1141// }
1142// OpenFileDialog openFileDialog1 = new OpenFileDialog();
1143// string sPath = "";
1144// sPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
1145//
1146// openFileDialog1.InitialDirectory = "c:\\" ;
1147// openFileDialog1.InitialDirectory = sPath ;
1148// openFileDialog1.Filter = "Schedule Template Files (*.bsdxa)|*.bsdxa|All files (*.*)|*.*" ;
1149// openFileDialog1.FilterIndex = 0 ;
1150// openFileDialog1.RestoreDirectory = true ;
1151
1152// Stream streamFile;
1153// if(openFileDialog1.ShowDialog() == DialogResult.OK)
1154// {
1155// if((streamFile = openFileDialog1.OpenFile())!= null)
1156// {
1157// BinaryFormatter formatter = new BinaryFormatter();
1158// CGAppointments cgaTemp = (CGAppointments) formatter.Deserialize(streamFile);
1159// streamFile.Close();
1160//
1161// //for each CGAppointment in AVBlocks, call AddNew
1162// string sResource = "";
1163// sResource = (string) this.Document.Resources[0];
1164// foreach (CGAppointment a in cgaTemp.AppointmentTable.Values)
1165// {
1166// //Change the resource to the current one
1167// a.Resource = sResource;
1168//
1169// //Change the date to correspond to the GridColumn member
1170// int col = a.GridColumn;
1171// Rectangle r = new Rectangle(0,0,0,0);
1172// int row = 5;
1173// CGCell c = new CGCell(r, row, col);
1174// DateTime dTemp = this.calendarGrid1.GetTimeFromCell(c);
1175// DateTime dBuildDate = dTemp.Date;
1176// dBuildDate = dBuildDate.AddHours(a.StartTime.Hour);
1177// dBuildDate = dBuildDate.AddMinutes(a.StartTime.Minute);
1178// a.StartTime = dBuildDate;
1179// dBuildDate = dTemp.Date;
1180// dBuildDate = dBuildDate.AddHours(a.EndTime.Hour);
1181// dBuildDate = dBuildDate.AddMinutes(a.EndTime.Minute);
1182// a.EndTime = dBuildDate;
1183//
1184// //Call Document to add a new appointment
1185// this.Document.CreateAppointment(a);
1186// }
1187// try
1188// {
1189// RaiseRPMSEvent("SCHEDULE-" + m_Document.DocName, "");
1190// }
1191// catch (Exception ex)
1192// {
1193// Debug.Write(ex.Message);
1194// }
1195// this.calendarGrid1.Invalidate();
1196// this.m_DocManager.UpdateViews((string) this.m_Document.Resources[0], "");
1197// }
1198// }
1199// }//end try
1200// catch (Exception ex)
1201// {
1202// MessageBox.Show(this, "Error loading template: " + ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
1203// }
1204// }
1205
1206 private void mnuSaveTemplate_Click(object sender, System.EventArgs e)
1207 {
1208 try
1209 {
1210 //Check that there is at least one block in document
1211// if (this.Document.AVBlocks.AppointmentTable.Count == 0)
1212// {
1213// Exception bmxex = new Exception("You may not save a template if there are no access blocks defined for the week.");
1214// throw bmxex;
1215// }
1216
1217 Stream streamFile ;
1218 SaveFileDialog saveFileDialog1 = new SaveFileDialog();
1219
1220 saveFileDialog1.Filter = "Schedule Template Files (*.bsdxa)|*.bsdxa|All files (*.*)|*.*" ;
1221 saveFileDialog1.FilterIndex = 0 ;
1222 saveFileDialog1.RestoreDirectory = true ;
1223 saveFileDialog1.AddExtension = true;
1224 saveFileDialog1.DefaultExt = "bsdxa";
1225
1226 //Iterate through AVBlocks and set the GridColumn member based on the date
1227 foreach (CGAppointment a in this.Document.AVBlocks.AppointmentTable.Values)
1228 {
1229 //Get the column by subtracting the grid's Start day from dStart.
1230 int col =(int) a.StartTime.DayOfWeek - (int) this.calendarGrid1.StartDate.DayOfWeek + 1;
1231 a.GridColumn = col;
1232 }
1233
1234 if(saveFileDialog1.ShowDialog() == DialogResult.OK)
1235 {
1236 if((streamFile = saveFileDialog1.OpenFile()) != null)
1237 {
1238 BinaryFormatter formatter = new BinaryFormatter();
1239
1240 formatter.Serialize(streamFile, this.Document.AVBlocks);
1241
1242 streamFile.Close();
1243 }
1244 }
1245 }
1246 catch (Exception ex)
1247 {
1248 MessageBox.Show(this, "Error saving template: " + ex.Message, "Clinical Scheduling", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
1249 }
1250 }
1251
1252 private void mnuViewRightPanel_Click(object sender, System.EventArgs e)
1253 {
1254 this.mnuViewRightPanel.Checked = this.panelRight.Visible;
1255 this.panelRight.Visible = !(this.panelRight.Visible);
1256 this.mnuViewRightPanel.Checked = !(this.mnuViewRightPanel.Checked);
1257 }
1258
1259 private void lstClip_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
1260 {
1261 try
1262 {
1263 CGAppointment a = (CGAppointment) e.Data.GetData(typeof(CGAppointment));
1264 if (m_ClipList.AppointmentTable.Contains((int) a.AppointmentKey))
1265 {
1266 return;
1267 }
1268 m_ClipList.AddAppointment(a);
1269 lstClip.Items.Add(a);
1270 }
1271 catch(Exception ex)
1272 {
1273 Debug.Write(ex.Message);
1274 }
1275 }
1276
1277 private void lstClip_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
1278 {
1279 bool b = e.Data.GetDataPresent(typeof(CGAppointment));
1280 if (b == true)
1281 {
1282 e.Effect = DragDropEffects.Move;
1283 }
1284 else
1285 {
1286 e.Effect = DragDropEffects.None;
1287 }
1288 }
1289
1290 private void lstClip_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
1291 {
1292 m_bDragDropStart = false;
1293 }
1294
1295 private void lstClip_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
1296 {
1297 try
1298 {
1299 if ((m_bDragDropStart == false)&&(lstClip.SelectedIndex > -1))
1300 {
1301 CGAppointment a = (CGAppointment) lstClip.Items[lstClip.SelectedIndex];
1302 this.calendarGrid1.ApptDragSource = "list";
1303 DragDropEffects effect = DoDragDrop(a, DragDropEffects.Move);
1304 m_bDragDropStart = true;
1305 }
1306 }
1307 catch (Exception ex)
1308 {
1309 Debug.Write(ex.Message);
1310 }
1311 }
1312
1313 private void calendarGrid1_CGAppointmentAdded(object sender, IndianHealthService.ClinicalScheduling.CGAppointmentChangedArgs e)
1314 {
1315 //CalendarGrid Event raised when appointment is dragdropped onto the grid
1316
1317 try
1318 {
1319 CGAppointment aCopy = new CGAppointment();
1320 aCopy.CreateAppointment(e.StartTime, e.EndTime, e.Appointment.Note, 0, e.Resource);
1321 aCopy.AccessTypeID = e.AccessTypeID;
1322 aCopy.Slots = e.Slots;
1323
1324 m_Document.CreateAppointment(aCopy);
1325 // RaiseRPMSEvent("SCHEDULE-" + e.Resource , "");
1326 this.m_DocManager.UpdateViews(e.Resource, e.OldResource);
1327 }
1328 catch (Exception ex)
1329 {
1330 MessageBox.Show("Unable to add new access block " + ex.Message, "Clinical Scheduling");
1331 return;
1332 }
1333 try
1334 {
1335 RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
1336 if (e.Resource != e.OldResource)
1337 RaiseRPMSEvent("BSDX SCHEDULE", m_Document.DocName);
1338 this.calendarGrid1.Invalidate();
1339 }
1340 catch (Exception ex)
1341 {
1342 Debug.Write(ex.Message);
1343 }
1344 }
1345
1346 #region ctxApptClipMenu Handlers
1347
1348 private void ctxApptClipMenu_Popup(object sender, System.EventArgs e)
1349 {
1350 mnuClearClipItems.Enabled = (m_ClipList.AppointmentTable.Count > 0);
1351 mnuRemoveClipItem.Enabled = (lstClip.SelectedIndex > -1);
1352 }
1353
1354 private void mnuRemoveClipItem_Click(object sender, System.EventArgs e)
1355 {
1356 int i = lstClip.SelectedIndex;
1357 CGAppointment a = (CGAppointment) lstClip.SelectedItem;
1358 int nKey = a.AppointmentKey;
1359 if (i > -1)
1360 {
1361 m_ClipList.RemoveAppointment(nKey);
1362 lstClip.Items.RemoveAt(i);
1363 }
1364 }
1365
1366 private void mnuClearClipItems_Click(object sender, System.EventArgs e)
1367 {
1368 this.m_ClipList.ClearAllAppointments();
1369 lstClip.Items.Clear();
1370 }
1371
1372 #endregion ctxApptClipMenu Handlers
1373
1374 #region ctxCalGridMenu Handlers
1375
1376 private void ctxCalGridAdd_Click(object sender, System.EventArgs e)
1377 {
1378 AvailabilityAddNew();
1379 }
1380
1381 private void ctxCalGridEdit_Click(object sender, System.EventArgs e)
1382 {
1383 AvailabilityEdit();
1384 }
1385
1386 private void ctxCalGridDelete_Click(object sender, System.EventArgs e)
1387 {
1388 AppointmentDelete();
1389 }
1390
1391 private void ctxCalendarGrid_Popup(object sender, System.EventArgs e)
1392 {
1393 //Toggle availability of make, edit and delete appointments
1394 //based on whether appropriate element is selected.
1395 ctxCalGridAdd.Enabled = ((calendarGrid1.SelectedRange.Cells.CellCount > 0) );
1396 ctxCalGridDelete.Enabled = (calendarGrid1.SelectedAppointment > 0);
1397 ctxCalGridEdit.Enabled = (calendarGrid1.SelectedAppointment > 0);
1398 }
1399
1400 private void calendarGrid1_DoubleClick(object sender, System.EventArgs e)
1401 {
1402 if (calendarGrid1.SelectedAppointment > 0)
1403 AvailabilityEdit();
1404 }
1405
1406 #endregion ctxCalGridMenu Handlers
1407
1408 private void mnu10Minute_Click(object sender, System.EventArgs e)
1409 {
1410 CalendarGrid cg = this.calendarGrid1;
1411 cg.TimeScale = 10;
1412 PositionGrid(cg, 7);
1413 }
1414
1415 private void mnu15Minute_Click(object sender, System.EventArgs e)
1416 {
1417 CalendarGrid cg = this.calendarGrid1;
1418 cg.TimeScale = 15;
1419 PositionGrid(cg, 7);
1420 }
1421
1422 private void mnu20Minute_Click(object sender, System.EventArgs e)
1423 {
1424 CalendarGrid cg = this.calendarGrid1;
1425 cg.TimeScale = 20;
1426 PositionGrid(cg, 7);
1427 }
1428
1429 private void mnu30Minute_Click(object sender, System.EventArgs e)
1430 {
1431 CalendarGrid cg = this.calendarGrid1;
1432 cg.TimeScale = 30;
1433 PositionGrid(cg, 7);
1434 }
1435
1436 private void mnu1Day_Click(object sender, System.EventArgs e)
1437 {
1438 DateTime dtPicker = dateTimePicker1.Value;
1439 DateTime DayOnly = new DateTime(dtPicker.Year, dtPicker.Month, dtPicker.Day);
1440 this.calendarGrid1.StartDate = DayOnly;
1441 this.calendarGrid1.Columns = 1;
1442 }
1443
1444 private void mnu5Day_Click(object sender, System.EventArgs e)
1445 {
1446 this.calendarGrid1.Columns = 5;
1447 this.Document.m_nColumnCount = 5; //TODO: redundant but now needed
1448 }
1449
1450 private void mnu7Day_Click(object sender, System.EventArgs e)
1451 {
1452 this.calendarGrid1.Columns = 7;
1453 this.Document.m_nColumnCount = 7; //TODO: redundant but now needed
1454 }
1455
1456 private void PositionGrid(CalendarGrid cg, int nHour)
1457 {
1458 //Position grid to nHour
1459 int nRow = 0, nCol = 0;
1460 DateTime dStart = DateTime.Today;
1461 dStart = dStart.AddHours(nHour);
1462 cg.GetCellFromTime(dStart, ref nRow, ref nCol, false, "");
1463 int nHeight = cg.CellHeight;
1464 nHeight *= nRow;
1465 cg.AutoScrollPosition = new Point(50, nHeight);
1466 cg.Invalidate();
1467 }
1468
1469
1470
1471 private void saveAccessBlocksWorker_DoWork(object sender, DoWorkEventArgs e)
1472 {
1473 BackgroundWorker worker = (BackgroundWorker)sender;
1474 DAccessTemplate dlg = (DAccessTemplate)e.Argument;
1475
1476 OpenFileDialog openFileDialog1 = dlg.FileDialog;
1477 openFileDialog1.RestoreDirectory = false; // go back to our dir
1478 Stream streamFile;
1479 if ((streamFile = openFileDialog1.OpenFile()) == null)
1480 {
1481 MessageBox.Show("Unable to open template file.");
1482 return;
1483 }
1484
1485 BinaryFormatter formatter = new BinaryFormatter();
1486 CGAppointments cgaTemp = (CGAppointments)formatter.Deserialize(streamFile);
1487 streamFile.Close();
1488
1489 DateTime dtStart = dlg.StartDate;
1490 DateTime newStartDate, newEndDate;
1491 this.Document.WeekNeedsRefresh(1, dtStart, out newStartDate, out newEndDate);
1492 dtStart = newStartDate;
1493 int nWeeksToApply = dlg.WeeksToApply;
1494 DateTime dtEnd = dtStart.AddDays(6); // or 7?
1495
1496 string sResourceID = this.m_Document.ResourceID.ToString();
1497 DataTable dt;
1498
1499 for (int j = 1; j < nWeeksToApply + 1; j++)
1500 {
1501 float fProgressPercentage = ((float)j / (float)nWeeksToApply) * 100;
1502 int iProgressPercentage = (int)fProgressPercentage;
1503 worker.ReportProgress(iProgressPercentage);
1504 //Convert start and end to string
1505 //string sStart = dtStart.ToString("M/d/yyyy");
1506 //string sEnd = dtEnd.ToString("M/d/yyyy");
1507 //i18n
1508 string sStart = FMDateTime.Create(dtStart).DateOnly.FMDateString;
1509 string sEnd = FMDateTime.Create(dtEnd).DateOnly.FMDateString;
1510 //Cancel all existing access blocks in the date range
1511 string sSql = "BSDX CANCEL AV BY DATE^" + sResourceID + "^" + sStart + "^" + sEnd;
1512 CGDocumentManager.RPMSDataTableDelegate d = new CGDocumentManager.RPMSDataTableDelegate(m_DocManager.RPMSDataTable);
1513 //dt = this.m_DocManager.RPMSDataTable(sSql, "Cancelled");
1514 dt = d(sSql, "Cancelled");
1515 //for each CGAppointment in AVBlocks, call AddNew
1516 string sResource = "";
1517 sResource = (string)this.Document.Resources[0];
1518 foreach (CGAppointment a in cgaTemp.AppointmentTable.Values)
1519 {
1520 //Change the resource to the current one
1521 a.Resource = sResource;
1522
1523 //Change the date to correspond to the GridColumn member
1524 int col = a.GridColumn;
1525 col--;
1526 DateTime dBuildDate = dtStart.Date;
1527 dBuildDate = dBuildDate.AddDays(col);
1528 dBuildDate = dBuildDate.AddHours(a.StartTime.Hour);
1529 dBuildDate = dBuildDate.AddMinutes(a.StartTime.Minute);
1530 a.StartTime = dBuildDate;
1531 dBuildDate = dtStart.Date;
1532 dBuildDate = dBuildDate.AddDays(col);
1533 dBuildDate = dBuildDate.AddHours(a.EndTime.Hour);
1534 dBuildDate = dBuildDate.AddMinutes(a.EndTime.Minute);
1535 a.EndTime = dBuildDate;
1536
1537 //Call Document to add a new appointment
1538 this.Document.CreateAppointmentAuto(a);
1539 }
1540
1541 //Increment start and end
1542 dtStart = dtStart.AddDays(7);
1543 dtEnd = dtStart.AddDays(6);
1544
1545 }
1546
1547 }
1548
1549 private void saveAccessBlocksWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
1550 {
1551 this.statusBar1.Text = "Done saving access blocks.";
1552 }
1553
1554 private void saveAccessBlocksWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
1555 {
1556 this.statusBar1.Text = "Saving Data to VISTA. Progress: " + e.ProgressPercentage + " %";
1557 }
1558
1559 private void mnuDeleteAllAppointments_Click(object sender, EventArgs e)
1560 {
1561 MassAppointmentDelete();
1562 }
1563 }
1564}
Note: See TracBrowser for help on using the repository browser.