source: Scheduling/branches/GUI1.2/CGAVView.cs@ 855

Last change on this file since 855 was 620, checked in by Sam Habiel, 15 years ago

Remove references to IHS; typically "IHS Clinical Scheduling" becomes "Clinical Scheduling"
Deleted Debug folder--no need to version this.

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