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

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

Bumped version of BMXNet21.dll to 2.1.2

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