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

Last change on this file since 1038 was 1038, checked in by Sam Habiel, 13 years ago

UCPatientAppts: Now uses LINQ. Mumps side fixes deal with other bugs.
calendarGrid: Fixes 1 day drawing bug showing yesterday's appointments
CGAVView: Cosmetic changes so far
CGDocument: Documentation change due to change in return values from Mumps.

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