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

Last change on this file was 1474, checked in by Sam Habiel, 12 years ago

Finally, v 1.7 to the main repo. I will delete the branch after this.

This commit merges all the BMX4 changes in the Scheduling GUI back to the main trunk.

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