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

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

CalendarGrid:

  • Added PositionGrid from CGView
  • Added Delegates from other classes that contained just one line.

CGAppointmentChangedArgs & CGSelectionChangedArgs:

  • Changed to use automatic properties

CGAvailability:

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