source: Scheduling/trunk/cs/bsdx0200GUISourceCode/DApptSearch.cs@ 1488

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

CalendarGrid: Many changes:

  1. Dragover handler to handle auto scrolling when dragging. Also highlights destination cell in dragging.
  2. Solution for the click-right click problem by better handling of right click issues.
  3. New method OnRButtonDown()
  4. Extra comments everywhere.
  5. Fix for single column being enabled when there are multiple resources. Columns property now calls this.SetColumnInfo() to rectify that problem.

CGDocument:

  1. EditAppoitment Used to send request a refresh from the DB and update the view itself, rather than letting the view handle that. That's now changed.

CGDocumentManager:

  1. MessageBox displayed during login splash now are shown BY the splash form.

CGView:

  1. Shortcuts and some display text updated.
  2. Splash screen when updating now removed.
  3. If print appointment slip checkbox is checked when EditAppointment is chosen, now it will print the routing slip.
  4. Tiny change in appointment structure generated during drag and drop (added Patient member, as it was causing a crash)

DApptSearch:

  1. Change of name of Appointment to Slot, for better user understanding.

DSplash:

  1. RemoteMessage box methods and associated delegates for mickey mousing the form from another thread.

Updated release exes and dlls

File size: 43.1 KB
RevLine 
[614]1using System;
2using System.Collections;
[1097]3using System.Collections.Generic;
[614]4using System.Windows.Forms;
5using System.Data;
[1097]6using System.Linq;
[614]7
8namespace IndianHealthService.ClinicalScheduling
9{
10 /// <summary>
[1097]11 /// Modal Dialog for searching for Patient Slots
[614]12 /// </summary>
13 public class DApptSearch : System.Windows.Forms.Form
14 {
15 private System.Windows.Forms.Panel panel1;
16 private System.Windows.Forms.Button cmdCancel;
[1097]17 private System.Windows.Forms.Button btnAccept;
[614]18 private System.Windows.Forms.Panel pnlDescription;
19 private System.Windows.Forms.GroupBox grpDescription;
20 private System.Windows.Forms.Label lblDescription;
21 private System.Windows.Forms.GroupBox groupBox1;
22 private System.Windows.Forms.Label label3;
23 private System.Windows.Forms.Label label2;
24 private System.Windows.Forms.CheckedListBox lstAccessTypes;
25 private System.Windows.Forms.ComboBox cboAccessTypeFilter;
26 private System.Windows.Forms.GroupBox grpDayOfWeek;
27 private System.Windows.Forms.CheckBox chkSun;
28 private System.Windows.Forms.CheckBox chkSat;
29 private System.Windows.Forms.CheckBox chkFri;
30 private System.Windows.Forms.CheckBox chkThu;
31 private System.Windows.Forms.CheckBox chkWed;
32 private System.Windows.Forms.CheckBox chkTue;
33 private System.Windows.Forms.CheckBox chkMon;
34 private System.Windows.Forms.GroupBox grpTimeOfDay;
35 private System.Windows.Forms.RadioButton rdoBoth;
36 private System.Windows.Forms.RadioButton rdoPM;
37 private System.Windows.Forms.RadioButton rdoAM;
[1097]38 private System.Windows.Forms.Label label1;
39 private System.Windows.Forms.GroupBox groupBox2;
40 private System.Windows.Forms.Button cmdSearch;
41 private ListView lstResults;
42 private ColumnHeader colStartTime;
43 private ColumnHeader colEndTime;
44 private ColumnHeader colResource;
45 private ColumnHeader colSlots;
46 private ColumnHeader colAccessType;
47 private ColumnHeader colDate;
48 private Label lblEnd;
49 private Label lblStart;
50 private DateTimePicker dtEnd;
51 private DateTimePicker dtStart;
52 private ColumnHeader colDOW;
53 private ColumnHeader colID;
[1106]54 private Label lblMessage;
[1097]55
56 private System.ComponentModel.IContainer components;
[614]57
58 public DApptSearch()
59 {
60 InitializeComponent();
61 }
62
63 #region Fields
64
65 private CGDocumentManager m_DocManager;
66
67 private DataSet m_dsGlobal;
68 DataTable m_dtTypes;
69 DataView m_dvTypes;
[1097]70 List<CGAvailability> lstResultantAvailabilities;
71 private CGAvailability _selectedAvailability;
[614]72 DateTime m_dStart;
73 DateTime m_dEnd;
74 ArrayList m_alResources;
75 ArrayList m_alAccessTypes;
[1097]76 string m_sWeekDays; //only practical use now is for sending to server
77 string m_sAmpm; // same here.
[614]78
79 #endregion Fields
80
81 #region Methods
82
83 public void LoadListBox(string sGroup)
84 {
85 if (sGroup == "ALL")
86 {
87 //Load the Access Type list box with ALL access types
88 m_dtTypes = m_dsGlobal.Tables["AccessTypes"];
89 m_dvTypes = new DataView(m_dtTypes);
90 lstAccessTypes.DataSource = m_dvTypes;
91 lstAccessTypes.DisplayMember = "ACCESS_TYPE_NAME";
92 lstAccessTypes.Tag = 1; //This holds the column index of the ACCESS_TYPE_NAME column
93 lstAccessTypes.ValueMember = "BMXIEN";
94 }
95 else
96 {
97 //Load the Access Type list box with active access types belonging
98 //to group sGroup
99
100 //Build AccessGroup table containing *active* AccessTypes and their Groups
101 m_dtTypes = m_dsGlobal.Tables["AccessGroupType"];
102 //Create a view that is filterable on Access Group
103 m_dvTypes = new DataView(m_dtTypes);
104 m_dvTypes.RowFilter = "ACCESS_GROUP = '" + this.cboAccessTypeFilter.Text + "'";
105 lstAccessTypes.DataSource = m_dvTypes;
106 lstAccessTypes.DisplayMember = "ACCESS_TYPE";
107 lstAccessTypes.ValueMember = "ACCESS_TYPE_ID";
108 lstAccessTypes.Tag = 4; //This holds the column index of the ACCESS_TYPE column
109 }
110 }
111
112 public void InitializePage(ArrayList alResources, CGDocumentManager docManager)
113 {
114
[1143]115 this.Text = "Searching for available slots in: " + string.Join(" | ", alResources.Cast<string>());
[1097]116
117 this.m_DocManager = docManager;
[614]118 this.m_dsGlobal = m_DocManager.GlobalDataSet;
[1097]119
[614]120 LoadListBox("ALL");
121
122 m_dStart = DateTime.Today;
123 m_dEnd = new DateTime(9999);
124 this.m_alResources = alResources;
125 this.m_alAccessTypes = new ArrayList();
126 this.m_sAmpm="both";
127 this.m_sWeekDays = "";
128
129 //Load filter combo with list of access type groups
130 DataTable dtGroup = m_dsGlobal.Tables["AccessGroup"];
131 DataSet dsTemp = new DataSet("dsTemp");
132 dsTemp.Tables.Add(dtGroup.Copy());
133 DataTable dtTemp = dsTemp.Tables["AccessGroup"];
134 DataView dvGroup = new DataView(dtTemp);
135 DataRowView drv = dvGroup.AddNew();
136 drv["ACCESS_GROUP"]="<Show All Access Types>";
137 cboAccessTypeFilter.DataSource = dvGroup;
138 cboAccessTypeFilter.DisplayMember = "ACCESS_GROUP";
139 cboAccessTypeFilter.SelectedText = "<Show All Access Types>";
140 cboAccessTypeFilter.SelectedIndex = cboAccessTypeFilter.Items.Count - 1;
141 cboAccessTypeFilter.Refresh();
142
[1097]143
144 /* OLD CODE
145 //Create DataGridTableStyle for Result grid
[614]146 DataGridTableStyle tsResult = new DataGridTableStyle();
147 tsResult.MappingName = "Result";
148 tsResult.ReadOnly = true;
[1097]149
[614]150 // Add START_TIME column style.
151 DataGridTextBoxColumn colStartTime = new DataGridTextBoxColumn();
[1097]152 colStartTime.MappingName = "StartTime";
[614]153 colStartTime.HeaderText = "Start Time";
154 colStartTime.Width = 200;
155 colStartTime.Format = "f";
156 tsResult.GridColumnStyles.Add(colStartTime);
157
158 // Add END_TIME column style.
159 DataGridTextBoxColumn colEndTime = new DataGridTextBoxColumn();
[1097]160 colEndTime.MappingName = "EndTime";
[614]161 colEndTime.HeaderText = "End Time";
162 colEndTime.Width = 75;
163 colEndTime.Format = "h:mm tt";
164 tsResult.GridColumnStyles.Add(colEndTime);
165
166 // Add RESOURCE column style.
167 DataGridTextBoxColumn colResource = new DataGridTextBoxColumn();
[1097]168 colResource.MappingName = "ResourceList";
[614]169 colResource.HeaderText = "Resource";
170 colResource.Width = 200;
171 tsResult.GridColumnStyles.Add(colResource);
172
173 // Add SLOTS column style.
174 DataGridTextBoxColumn colSlots = new DataGridTextBoxColumn();
175 colSlots.MappingName = "SLOTS";
176 colSlots.HeaderText = "Slots";
177 colSlots.Width = 50;
178 tsResult.GridColumnStyles.Add(colSlots);
179
180 // Add AMPM column style.
181 DataGridTextBoxColumn colAccess = new DataGridTextBoxColumn();
182 colAccess.MappingName = "ACCESSNAME";
183 colAccess.HeaderText = "Access Type";
184 colAccess.Width = 200;
185 tsResult.GridColumnStyles.Add(colAccess);
[1097]186 //grdResult.TableStyles.Add(tsResult);
187 */
188
[614]189 this.UpdateDialogData(true);
190
191 }
192
193 /// <summary>
194 /// If b is true, moves member vars into control data
195 /// otherwise, moves control data into member vars
196 /// </summary>
197 /// <param name="b"></param>
198 private void UpdateDialogData(bool b)
199 {
200 if (b == true) //move member vars into controls
201 {
202
203 }
204 else //move control data into member vars
205 {
206
207 //Build AccessType list
208
209 this.m_alAccessTypes.Clear();
210
211 for (int j = 0; j < this.lstAccessTypes.CheckedItems.Count; j++)
212 {
213 DataRowView drv = (DataRowView) lstAccessTypes.CheckedItems[j];
214 int nIndex = (int) lstAccessTypes.Tag;
215 string sItem = drv.Row.ItemArray[nIndex].ToString();
216 m_alAccessTypes.Add(sItem);
217 }
218
219 //AM/PM
220 this.m_sAmpm = (this.rdoAM.Checked == true) ? "AM":"BOTH";
221 if (this.m_sAmpm != "AM")
222 this.m_sAmpm = (this.rdoPM.Checked == true) ? "PM":"BOTH";
223
224
225 //Weekday
226 this.m_sWeekDays = ""; //any
227 if (chkMon.Checked == true)
228 m_sWeekDays += "Monday";
229 if (chkTue.Checked == true)
230 m_sWeekDays += "Tuesday";
231 if (chkWed.Checked == true)
232 m_sWeekDays += "Wednesday";
233 if (chkThu.Checked == true)
234 m_sWeekDays += "Thursday";
235 if (chkFri.Checked == true)
236 m_sWeekDays += "Friday";
237 if (chkSat.Checked == true)
238 m_sWeekDays += "Saturday";
239 if (chkSun.Checked == true)
240 m_sWeekDays += "Sunday";
241
242 //Start
[1097]243 this.m_dStart = this.dtStart.Value;
[614]244
245 //End
[1123]246 this.m_dEnd = this.dtEnd.Value;
[614]247 }
248 }
249
250
251 /// <summary>
252 /// Clean up any resources being used.
253 /// </summary>
254 protected override void Dispose( bool disposing )
255 {
256 if( disposing )
257 {
258 if(components != null)
259 {
260 components.Dispose();
261 }
262 }
263 base.Dispose( disposing );
264 }
265
266 #endregion Methods
267
268 #region Windows Form Designer generated code
269 /// <summary>
270 /// Required method for Designer support - do not modify
271 /// the contents of this method with the code editor.
272 /// </summary>
273 private void InitializeComponent()
274 {
[908]275 this.panel1 = new System.Windows.Forms.Panel();
[1143]276 this.lblMessage = new System.Windows.Forms.Label();
[908]277 this.cmdSearch = new System.Windows.Forms.Button();
278 this.cmdCancel = new System.Windows.Forms.Button();
[1097]279 this.btnAccept = new System.Windows.Forms.Button();
[908]280 this.pnlDescription = new System.Windows.Forms.Panel();
281 this.grpDescription = new System.Windows.Forms.GroupBox();
282 this.lblDescription = new System.Windows.Forms.Label();
283 this.groupBox1 = new System.Windows.Forms.GroupBox();
[1097]284 this.lblEnd = new System.Windows.Forms.Label();
285 this.lblStart = new System.Windows.Forms.Label();
286 this.dtEnd = new System.Windows.Forms.DateTimePicker();
287 this.dtStart = new System.Windows.Forms.DateTimePicker();
[908]288 this.label3 = new System.Windows.Forms.Label();
289 this.label2 = new System.Windows.Forms.Label();
290 this.lstAccessTypes = new System.Windows.Forms.CheckedListBox();
291 this.cboAccessTypeFilter = new System.Windows.Forms.ComboBox();
292 this.grpDayOfWeek = new System.Windows.Forms.GroupBox();
293 this.chkSun = new System.Windows.Forms.CheckBox();
294 this.chkSat = new System.Windows.Forms.CheckBox();
295 this.chkFri = new System.Windows.Forms.CheckBox();
296 this.chkThu = new System.Windows.Forms.CheckBox();
297 this.chkWed = new System.Windows.Forms.CheckBox();
298 this.chkTue = new System.Windows.Forms.CheckBox();
299 this.chkMon = new System.Windows.Forms.CheckBox();
300 this.grpTimeOfDay = new System.Windows.Forms.GroupBox();
301 this.rdoBoth = new System.Windows.Forms.RadioButton();
302 this.rdoPM = new System.Windows.Forms.RadioButton();
303 this.rdoAM = new System.Windows.Forms.RadioButton();
304 this.label1 = new System.Windows.Forms.Label();
305 this.groupBox2 = new System.Windows.Forms.GroupBox();
[1097]306 this.lstResults = new System.Windows.Forms.ListView();
307 this.colID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
308 this.colDate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
309 this.colDOW = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
310 this.colStartTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
311 this.colEndTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
312 this.colResource = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
313 this.colSlots = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
314 this.colAccessType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
[908]315 this.panel1.SuspendLayout();
316 this.pnlDescription.SuspendLayout();
317 this.grpDescription.SuspendLayout();
318 this.groupBox1.SuspendLayout();
319 this.grpDayOfWeek.SuspendLayout();
320 this.grpTimeOfDay.SuspendLayout();
321 this.groupBox2.SuspendLayout();
322 this.SuspendLayout();
323 //
324 // panel1
325 //
[1106]326 this.panel1.Controls.Add(this.lblMessage);
[908]327 this.panel1.Controls.Add(this.cmdSearch);
328 this.panel1.Controls.Add(this.cmdCancel);
[1097]329 this.panel1.Controls.Add(this.btnAccept);
[908]330 this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
331 this.panel1.Location = new System.Drawing.Point(0, 461);
332 this.panel1.Name = "panel1";
333 this.panel1.Size = new System.Drawing.Size(923, 40);
334 this.panel1.TabIndex = 4;
335 //
[1143]336 // lblMessage
337 //
338 this.lblMessage.AutoSize = true;
339 this.lblMessage.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
340 this.lblMessage.ForeColor = System.Drawing.Color.Red;
341 this.lblMessage.Location = new System.Drawing.Point(337, 16);
342 this.lblMessage.Name = "lblMessage";
343 this.lblMessage.Size = new System.Drawing.Size(0, 16);
344 this.lblMessage.TabIndex = 3;
345 //
[908]346 // cmdSearch
347 //
[1106]348 this.cmdSearch.Location = new System.Drawing.Point(33, 6);
[908]349 this.cmdSearch.Name = "cmdSearch";
350 this.cmdSearch.Size = new System.Drawing.Size(72, 24);
351 this.cmdSearch.TabIndex = 2;
352 this.cmdSearch.Text = "Search";
353 this.cmdSearch.Click += new System.EventHandler(this.cmdSearch_Click);
354 //
355 // cmdCancel
356 //
357 this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
[1106]358 this.cmdCancel.Location = new System.Drawing.Point(828, 8);
[908]359 this.cmdCancel.Name = "cmdCancel";
360 this.cmdCancel.Size = new System.Drawing.Size(64, 24);
361 this.cmdCancel.TabIndex = 1;
362 this.cmdCancel.Text = "Cancel";
363 //
[1097]364 // btnAccept
[908]365 //
[1097]366 this.btnAccept.DialogResult = System.Windows.Forms.DialogResult.OK;
[1106]367 this.btnAccept.Location = new System.Drawing.Point(135, 8);
[1097]368 this.btnAccept.Name = "btnAccept";
369 this.btnAccept.Size = new System.Drawing.Size(176, 24);
370 this.btnAccept.TabIndex = 0;
371 this.btnAccept.Text = "Select Slot for Appointment";
372 this.btnAccept.Click += new System.EventHandler(this.btnAccept_Click);
[908]373 //
374 // pnlDescription
375 //
376 this.pnlDescription.Controls.Add(this.grpDescription);
377 this.pnlDescription.Dock = System.Windows.Forms.DockStyle.Bottom;
378 this.pnlDescription.Location = new System.Drawing.Point(0, 397);
379 this.pnlDescription.Name = "pnlDescription";
380 this.pnlDescription.Size = new System.Drawing.Size(923, 64);
381 this.pnlDescription.TabIndex = 47;
382 //
383 // grpDescription
384 //
385 this.grpDescription.Controls.Add(this.lblDescription);
386 this.grpDescription.Dock = System.Windows.Forms.DockStyle.Fill;
387 this.grpDescription.Location = new System.Drawing.Point(0, 0);
388 this.grpDescription.Name = "grpDescription";
389 this.grpDescription.Size = new System.Drawing.Size(923, 64);
390 this.grpDescription.TabIndex = 0;
391 this.grpDescription.TabStop = false;
392 this.grpDescription.Text = "Description";
393 //
394 // lblDescription
395 //
396 this.lblDescription.Dock = System.Windows.Forms.DockStyle.Fill;
397 this.lblDescription.Location = new System.Drawing.Point(3, 16);
398 this.lblDescription.Name = "lblDescription";
399 this.lblDescription.Size = new System.Drawing.Size(917, 45);
400 this.lblDescription.TabIndex = 1;
[1143]401 this.lblDescription.Text = "Search for available slots times using this panel. You may narrow your search by" +
402 " selecting an access type or by selecting specific days of the week or times of " +
403 "day.";
[908]404 //
405 // groupBox1
406 //
[1097]407 this.groupBox1.Controls.Add(this.lblEnd);
408 this.groupBox1.Controls.Add(this.lblStart);
409 this.groupBox1.Controls.Add(this.dtEnd);
410 this.groupBox1.Controls.Add(this.dtStart);
[908]411 this.groupBox1.Controls.Add(this.label3);
412 this.groupBox1.Controls.Add(this.label2);
413 this.groupBox1.Controls.Add(this.lstAccessTypes);
414 this.groupBox1.Controls.Add(this.cboAccessTypeFilter);
415 this.groupBox1.Controls.Add(this.grpDayOfWeek);
416 this.groupBox1.Controls.Add(this.grpTimeOfDay);
417 this.groupBox1.Controls.Add(this.label1);
418 this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
419 this.groupBox1.Location = new System.Drawing.Point(0, 0);
420 this.groupBox1.Name = "groupBox1";
421 this.groupBox1.Size = new System.Drawing.Size(923, 208);
422 this.groupBox1.TabIndex = 56;
423 this.groupBox1.TabStop = false;
424 this.groupBox1.Text = "Search Parameters";
425 //
[1097]426 // lblEnd
427 //
428 this.lblEnd.AutoSize = true;
429 this.lblEnd.Location = new System.Drawing.Point(12, 124);
430 this.lblEnd.Name = "lblEnd";
431 this.lblEnd.Size = new System.Drawing.Size(153, 13);
432 this.lblEnd.TabIndex = 67;
433 this.lblEnd.Text = "End Date to Search (Inclusive)";
434 //
435 // lblStart
436 //
437 this.lblStart.AutoSize = true;
438 this.lblStart.Location = new System.Drawing.Point(12, 35);
439 this.lblStart.Name = "lblStart";
440 this.lblStart.Size = new System.Drawing.Size(159, 13);
441 this.lblStart.TabIndex = 66;
442 this.lblStart.Text = "Start Date to Search (Inclusive)";
443 //
444 // dtEnd
445 //
446 this.dtEnd.Location = new System.Drawing.Point(12, 141);
447 this.dtEnd.Name = "dtEnd";
448 this.dtEnd.Size = new System.Drawing.Size(200, 20);
449 this.dtEnd.TabIndex = 65;
[1106]450 this.dtEnd.ValueChanged += new System.EventHandler(this.dtEnd_ValueChanged);
[1097]451 //
452 // dtStart
453 //
454 this.dtStart.Location = new System.Drawing.Point(12, 54);
455 this.dtStart.Name = "dtStart";
456 this.dtStart.Size = new System.Drawing.Size(200, 20);
457 this.dtStart.TabIndex = 64;
[1106]458 this.dtStart.ValueChanged += new System.EventHandler(this.dtStart_ValueChanged);
[1097]459 //
[908]460 // label3
461 //
462 this.label3.Location = new System.Drawing.Point(684, 64);
463 this.label3.Name = "label3";
464 this.label3.Size = new System.Drawing.Size(80, 16);
465 this.label3.TabIndex = 63;
466 this.label3.Text = "Access Type:";
467 //
468 // label2
469 //
470 this.label2.Location = new System.Drawing.Point(684, 21);
471 this.label2.Name = "label2";
472 this.label2.Size = new System.Drawing.Size(104, 16);
473 this.label2.TabIndex = 62;
474 this.label2.Text = "Access Group:";
475 //
476 // lstAccessTypes
477 //
478 this.lstAccessTypes.CheckOnClick = true;
479 this.lstAccessTypes.HorizontalScrollbar = true;
480 this.lstAccessTypes.Location = new System.Drawing.Point(661, 88);
481 this.lstAccessTypes.MultiColumn = true;
482 this.lstAccessTypes.Name = "lstAccessTypes";
483 this.lstAccessTypes.Size = new System.Drawing.Size(250, 109);
484 this.lstAccessTypes.TabIndex = 61;
485 //
486 // cboAccessTypeFilter
487 //
488 this.cboAccessTypeFilter.Location = new System.Drawing.Point(661, 40);
489 this.cboAccessTypeFilter.Name = "cboAccessTypeFilter";
490 this.cboAccessTypeFilter.Size = new System.Drawing.Size(250, 21);
491 this.cboAccessTypeFilter.TabIndex = 60;
492 this.cboAccessTypeFilter.Text = "cboAccessTypeFilter";
493 this.cboAccessTypeFilter.SelectionChangeCommitted += new System.EventHandler(this.cboAccessTypeFilter_SelectionChangeCommitted);
494 //
495 // grpDayOfWeek
496 //
497 this.grpDayOfWeek.Controls.Add(this.chkSun);
498 this.grpDayOfWeek.Controls.Add(this.chkSat);
499 this.grpDayOfWeek.Controls.Add(this.chkFri);
500 this.grpDayOfWeek.Controls.Add(this.chkThu);
501 this.grpDayOfWeek.Controls.Add(this.chkWed);
502 this.grpDayOfWeek.Controls.Add(this.chkTue);
503 this.grpDayOfWeek.Controls.Add(this.chkMon);
504 this.grpDayOfWeek.Location = new System.Drawing.Point(311, 94);
505 this.grpDayOfWeek.Name = "grpDayOfWeek";
506 this.grpDayOfWeek.Size = new System.Drawing.Size(240, 101);
507 this.grpDayOfWeek.TabIndex = 59;
508 this.grpDayOfWeek.TabStop = false;
509 this.grpDayOfWeek.Text = "Day of the Week";
510 //
511 // chkSun
512 //
513 this.chkSun.Location = new System.Drawing.Point(176, 64);
514 this.chkSun.Name = "chkSun";
515 this.chkSun.Size = new System.Drawing.Size(48, 16);
516 this.chkSun.TabIndex = 6;
517 this.chkSun.Text = "Sun";
518 //
519 // chkSat
520 //
521 this.chkSat.Location = new System.Drawing.Point(128, 64);
522 this.chkSat.Name = "chkSat";
523 this.chkSat.Size = new System.Drawing.Size(48, 16);
524 this.chkSat.TabIndex = 5;
525 this.chkSat.Text = "Sat";
526 //
527 // chkFri
528 //
529 this.chkFri.Location = new System.Drawing.Point(72, 64);
530 this.chkFri.Name = "chkFri";
531 this.chkFri.Size = new System.Drawing.Size(48, 16);
532 this.chkFri.TabIndex = 4;
533 this.chkFri.Text = "Fri";
534 //
535 // chkThu
536 //
537 this.chkThu.Location = new System.Drawing.Point(16, 64);
538 this.chkThu.Name = "chkThu";
539 this.chkThu.Size = new System.Drawing.Size(48, 16);
540 this.chkThu.TabIndex = 3;
541 this.chkThu.Text = "Thu";
542 //
543 // chkWed
544 //
545 this.chkWed.Location = new System.Drawing.Point(128, 32);
546 this.chkWed.Name = "chkWed";
547 this.chkWed.Size = new System.Drawing.Size(48, 16);
548 this.chkWed.TabIndex = 2;
549 this.chkWed.Text = "Wed";
550 //
551 // chkTue
552 //
553 this.chkTue.Location = new System.Drawing.Point(72, 32);
554 this.chkTue.Name = "chkTue";
555 this.chkTue.Size = new System.Drawing.Size(48, 16);
556 this.chkTue.TabIndex = 1;
557 this.chkTue.Text = "Tue";
558 //
559 // chkMon
560 //
561 this.chkMon.Location = new System.Drawing.Point(16, 32);
562 this.chkMon.Name = "chkMon";
563 this.chkMon.Size = new System.Drawing.Size(48, 16);
564 this.chkMon.TabIndex = 0;
565 this.chkMon.Text = "Mon";
566 //
567 // grpTimeOfDay
568 //
569 this.grpTimeOfDay.Controls.Add(this.rdoBoth);
570 this.grpTimeOfDay.Controls.Add(this.rdoPM);
571 this.grpTimeOfDay.Controls.Add(this.rdoAM);
572 this.grpTimeOfDay.Location = new System.Drawing.Point(311, 32);
573 this.grpTimeOfDay.Name = "grpTimeOfDay";
574 this.grpTimeOfDay.Size = new System.Drawing.Size(240, 48);
575 this.grpTimeOfDay.TabIndex = 58;
576 this.grpTimeOfDay.TabStop = false;
577 this.grpTimeOfDay.Text = "Time of Day";
578 //
579 // rdoBoth
580 //
581 this.rdoBoth.Checked = true;
582 this.rdoBoth.Location = new System.Drawing.Point(176, 24);
583 this.rdoBoth.Name = "rdoBoth";
584 this.rdoBoth.Size = new System.Drawing.Size(48, 16);
585 this.rdoBoth.TabIndex = 2;
586 this.rdoBoth.TabStop = true;
587 this.rdoBoth.Text = "Both";
588 //
589 // rdoPM
590 //
591 this.rdoPM.Location = new System.Drawing.Point(96, 24);
592 this.rdoPM.Name = "rdoPM";
593 this.rdoPM.Size = new System.Drawing.Size(72, 16);
594 this.rdoPM.TabIndex = 1;
595 this.rdoPM.Text = "PM Only";
596 //
597 // rdoAM
598 //
599 this.rdoAM.Location = new System.Drawing.Point(16, 24);
600 this.rdoAM.Name = "rdoAM";
601 this.rdoAM.Size = new System.Drawing.Size(72, 16);
602 this.rdoAM.TabIndex = 0;
603 this.rdoAM.Text = "AM Only";
604 //
605 // label1
606 //
607 this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
[1097]608 this.label1.Location = new System.Drawing.Point(6, 16);
[908]609 this.label1.Name = "label1";
610 this.label1.Size = new System.Drawing.Size(136, 16);
611 this.label1.TabIndex = 57;
612 this.label1.Text = "Date Range:";
613 //
614 // groupBox2
615 //
[1097]616 this.groupBox2.Controls.Add(this.lstResults);
[908]617 this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
618 this.groupBox2.Location = new System.Drawing.Point(0, 208);
619 this.groupBox2.Name = "groupBox2";
620 this.groupBox2.Size = new System.Drawing.Size(923, 189);
621 this.groupBox2.TabIndex = 57;
622 this.groupBox2.TabStop = false;
623 this.groupBox2.Text = "Search Result";
624 //
[1097]625 // lstResults
[908]626 //
[1097]627 this.lstResults.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
628 this.colID,
629 this.colDate,
630 this.colDOW,
631 this.colStartTime,
632 this.colEndTime,
633 this.colResource,
634 this.colSlots,
635 this.colAccessType});
636 this.lstResults.Dock = System.Windows.Forms.DockStyle.Fill;
637 this.lstResults.FullRowSelect = true;
638 this.lstResults.GridLines = true;
639 this.lstResults.Location = new System.Drawing.Point(3, 16);
640 this.lstResults.MultiSelect = false;
641 this.lstResults.Name = "lstResults";
642 this.lstResults.Size = new System.Drawing.Size(917, 170);
643 this.lstResults.TabIndex = 0;
644 this.lstResults.UseCompatibleStateImageBehavior = false;
645 this.lstResults.View = System.Windows.Forms.View.Details;
646 this.lstResults.DoubleClick += new System.EventHandler(this.lstResults_DoubleClick);
[908]647 //
[1097]648 // colID
649 //
650 this.colID.Text = "ID";
651 this.colID.Width = 0;
652 //
653 // colDate
654 //
655 this.colDate.Text = "Date";
656 this.colDate.Width = 91;
657 //
658 // colDOW
659 //
660 this.colDOW.Text = "Day of Week";
661 this.colDOW.Width = 80;
662 //
663 // colStartTime
664 //
665 this.colStartTime.Text = "Start Time";
666 this.colStartTime.Width = 87;
667 //
668 // colEndTime
669 //
670 this.colEndTime.Text = "End Time";
671 this.colEndTime.Width = 116;
672 //
673 // colResource
674 //
675 this.colResource.Text = "Resource";
676 this.colResource.Width = 370;
677 //
678 // colSlots
679 //
680 this.colSlots.Text = "Slots";
681 this.colSlots.Width = 47;
682 //
683 // colAccessType
684 //
685 this.colAccessType.Text = "Access Type";
686 this.colAccessType.Width = 101;
687 //
[908]688 // DApptSearch
689 //
690 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
691 this.CancelButton = this.cmdCancel;
692 this.ClientSize = new System.Drawing.Size(923, 501);
693 this.Controls.Add(this.groupBox2);
694 this.Controls.Add(this.groupBox1);
695 this.Controls.Add(this.pnlDescription);
696 this.Controls.Add(this.panel1);
697 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
698 this.Name = "DApptSearch";
699 this.Text = "Find Clinic Availability";
700 this.panel1.ResumeLayout(false);
[1106]701 this.panel1.PerformLayout();
[908]702 this.pnlDescription.ResumeLayout(false);
703 this.grpDescription.ResumeLayout(false);
704 this.groupBox1.ResumeLayout(false);
[1097]705 this.groupBox1.PerformLayout();
[908]706 this.grpDayOfWeek.ResumeLayout(false);
707 this.grpTimeOfDay.ResumeLayout(false);
708 this.groupBox2.ResumeLayout(false);
709 this.ResumeLayout(false);
[614]710
711 }
712 #endregion
713
714 #region Event Handlers
715
716 private void cmdSearch_Click(object sender, System.EventArgs e)
717 {
[1097]718 //Tell user we are processing
719 this.Cursor = Cursors.WaitCursor;
[1106]720 this.lblMessage.Text = String.Empty;
721
[1097]722 //Get the control data into local vars
[614]723 UpdateDialogData(false);
724 //Resource array, Begin date, Access type array, MTWTF , AM PM
725
[1097]726 //Get Availabilities and Appointments from the DB
727 //NB: m_sAmpm and m_sWeekDays don't have an effect on the M side side right now
[1123]728 m_dStart = m_dStart.Date; // move to 1200
729 m_dEnd = m_dEnd.Date.AddHours(23).AddMinutes(59).AddSeconds(59); //move to 235959
730 string sSearchInfo = "1|" + m_sAmpm + "|" + m_sWeekDays;
[1097]731 DataTable m_availTable = CGSchedLib.CreateAvailabilitySchedule(m_DocManager, m_alResources, m_dStart, m_dEnd, m_alAccessTypes, ScheduleType.Resource, sSearchInfo);
732 DataTable m_apptTable = CGSchedLib.CreateAppointmentSchedule(m_DocManager, m_alResources, m_dStart, m_dEnd);
[614]733
[1097]734#if DEBUG
735 System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
736 stopwatch.Start();
737#endif
738 lstResultantAvailabilities = (from rowAV in m_availTable.AsEnumerable()
739
740 // Calculate the number of slots consumed in this availability by appointments
741 let slotsConsumed = (from appt in m_apptTable.AsEnumerable()
742 //If the resource is the same and the user selection overlaps, then...
743 where (rowAV.Field<string>("RESOURCE") == appt.Field<string>("RESOURCENAME")
744 && CalendarGrid.TimesOverlap(rowAV.Field<DateTime>("START_TIME"), rowAV.Field<DateTime>("END_TIME"), appt.Field<DateTime>("START_TIME"), appt.Field<DateTime>("END_TIME")))
745 // if appt starttime is before avail start time, only count against the avail starting from the availability start time
746 let startTimeToCountAgainstBlock = appt.Field<DateTime>("START_TIME") < rowAV.Field<DateTime>("START_TIME") ? rowAV.Field<DateTime>("START_TIME") : appt.Field<DateTime>("START_TIME")
747 // if appt endtime is after the avail ends, only count against the avail up to where the avail ends
748 let endTimeToCountAgainstBlock = appt.Field<DateTime>("END_TIME") > rowAV.Field<DateTime>("END_TIME") ? rowAV.Field<DateTime>("END_TIME") : appt.Field<DateTime>("END_TIME")
749 // theoretical minutes per slot for the availability
750 let minPerSlot = (rowAV.Field<DateTime>("END_TIME") - rowAV.Field<DateTime>("START_TIME")).TotalMinutes / rowAV.Field<int>("SLOTS")
751 // how many minutes does this appointment take away from the slot
752 let minPerAppt = (endTimeToCountAgainstBlock - startTimeToCountAgainstBlock).TotalMinutes
753 // how many slots the appointment takes up using this availability's scale
754 let slotsConsumed = minPerAppt / minPerSlot
755 select slotsConsumed).Sum()
756
757 // Subtract the number consumed from the original ones
758 let slotsLeft = (float)rowAV.Field<int>("SLOTS") - slotsConsumed
759 // filter by that value if it is at least one slot
760 where slotsLeft >= 1
761 // Sort by Start Time, then by Resource Name
762 orderby rowAV.Field<DateTime>("START_TIME"), rowAV.Field<string>("RESOURCE")
763 //return as a CGAvailability
764 select new CGAvailability
765 {
766 ResourceList = rowAV.Field<string>("RESOURCE"),
767 StartTime = rowAV.Field<DateTime>("START_TIME"),
768 EndTime = rowAV.Field<DateTime>("END_TIME"),
769 Slots = (int)slotsLeft,
770 // AccessTypeName is grabbed from the Access Type Table using a psuedojoin syntax.
771 // "ACCESS_TYPE" is the IEN of the AcceesType.
772 // Single or default is b/c we are expecting one result.
773 AccessTypeName = (from at in m_dsGlobal.Tables["AccessTypes"].AsEnumerable()
774 where at.Field<int>("BMXIEN")==Int32.Parse(rowAV.Field<string>("ACCESS_TYPE"))
775 select at.Field<string>("ACCESS_TYPE_NAME")).SingleOrDefault<string>(),
776 AvailabilityType = rowAV.Field<int>("AVAILABILITYID")
777 })
778 // convert to Generic List
779 .ToList<CGAvailability>();
[614]780
[1097]781 // if specific access types are chosen, filter the results based on a join against them.
782 if (m_alAccessTypes.Count > 0)
783 lstResultantAvailabilities = (from av in lstResultantAvailabilities
784 join at in m_alAccessTypes.Cast<string>() on av.AccessTypeName equals at
785 select av).ToList<CGAvailability>();
[614]786
[1097]787 // if user chose AM radio button, get morning appointments
788 // TimeSpan.FromHours(12) gets the number of ticks since Midnight
789 if (rdoAM.Checked) // less than 12 pm
790 {
791 lstResultantAvailabilities = (from av in lstResultantAvailabilities
792 where av.StartTime.TimeOfDay < TimeSpan.FromHours(12)
793 select av).ToList<CGAvailability>();
794 }
795 // if user chose PM radio button, get morning appointments
796 if (rdoPM.Checked) // after or equal to 12 pm
797 {
798 lstResultantAvailabilities = (from av in lstResultantAvailabilities
799 where av.StartTime.TimeOfDay >= TimeSpan.FromHours(12)
800 select av).ToList<CGAvailability>();
801 }
[1095]802
[1097]803 // if any of the days of week are checked, create a new list based on them
804 // and clear the original list, and join the new lists together
805 if (chkMon.Checked || chkTue.Checked || chkWed.Checked || chkThu.Checked || chkFri.Checked || chkSat.Checked || chkSun.Checked)
806 {
[614]807
[1097]808 var lstMonday = new List<CGAvailability>();
809 var lstTuesday = new List<CGAvailability>();
810 var lstWednesday = new List<CGAvailability>();
811 var lstThursday = new List<CGAvailability>();
812 var lstFriday = new List<CGAvailability>();
813 var lstSaturday = new List<CGAvailability>();
814 var lstSunday = new List<CGAvailability>();
[1095]815
[1097]816 if (chkMon.Checked == true)
817 {
818 lstMonday = (from av in lstResultantAvailabilities
819 where av.StartTime.DayOfWeek == DayOfWeek.Monday
820 select av).ToList<CGAvailability>();
821 }
[614]822
[1097]823 if (chkTue.Checked == true)
824 {
825 lstTuesday = (from av in lstResultantAvailabilities
826 where av.StartTime.DayOfWeek == DayOfWeek.Tuesday
827 select av).ToList<CGAvailability>();
828 }
[614]829
[1097]830 if (chkWed.Checked == true)
831 {
832 lstWednesday = (from av in lstResultantAvailabilities
833 where av.StartTime.DayOfWeek == DayOfWeek.Wednesday
834 select av).ToList<CGAvailability>();
[614]835
[1097]836 }
[614]837
[1097]838 if (chkThu.Checked == true)
839 {
840 lstThursday = (from av in lstResultantAvailabilities
841 where av.StartTime.DayOfWeek == DayOfWeek.Thursday
842 select av).ToList<CGAvailability>();
[614]843
[1097]844 }
845
846 if (chkFri.Checked == true)
847 {
848 lstFriday = (from av in lstResultantAvailabilities
849 where av.StartTime.DayOfWeek == DayOfWeek.Friday
850 select av).ToList<CGAvailability>();
851 }
852
853 if (chkSat.Checked == true)
854 {
855 lstSaturday = (from av in lstResultantAvailabilities
856 where av.StartTime.DayOfWeek == DayOfWeek.Saturday
857 select av).ToList<CGAvailability>();
858
859 }
860
861 if (chkSun.Checked == true)
862 {
863 lstSunday = (from av in lstResultantAvailabilities
864 where av.StartTime.DayOfWeek == DayOfWeek.Sunday
865 select av).ToList<CGAvailability>();
866
867 }
868
869
870 lstResultantAvailabilities.Clear();
871 lstResultantAvailabilities.AddRange(lstMonday);
872 lstResultantAvailabilities.AddRange(lstTuesday);
873 lstResultantAvailabilities.AddRange(lstWednesday);
874 lstResultantAvailabilities.AddRange(lstThursday);
875 lstResultantAvailabilities.AddRange(lstFriday);
876 lstResultantAvailabilities.AddRange(lstSaturday);
877 lstResultantAvailabilities.AddRange(lstSunday);
878
879 lstResultantAvailabilities.OrderBy(av => av.StartTime).ThenBy(av => av.ResourceList);
880 }
881
882
883
884#if DEBUG
885 System.Diagnostics.Debug.Write("LINQ took this long: " + stopwatch.ElapsedMilliseconds + "\n");
886 stopwatch = null;
887#endif
888
889 //Then, convert the availabilities to ListViewItems
890 var items = (from item in lstResultantAvailabilities
891 let s = new string[] {item.AvailabilityType.ToString(), item.StartTime.ToShortDateString(), item.StartTime.DayOfWeek.ToString(),item.StartTime.ToShortTimeString() ,item.EndTime.ToShortTimeString() ,item.ResourceList,item.Slots.ToString(),item.AccessTypeName}
892 let lvItem = new ListViewItem(s)
893 select lvItem).ToArray<ListViewItem>();
894
895 //--Updating Listview
896 lstResults.BeginUpdate(); //tell listview to suspend drawing for now
897 lstResults.Items.Clear(); //empty it from old data
898
899 if (items.Length > 0) lstResults.Items.AddRange(items); // add new data
[1143]900 else this.lblMessage.Text = "No available slots found!";
[1097]901
902 lstResults.EndUpdate(); // ok done adding items, draw now.
903 //--End Update Listview
904
905 //We are done
906 this.Cursor = Cursors.Default;
[614]907 }
908
909 private void cboAccessTypeFilter_SelectionChangeCommitted(object sender, System.EventArgs e)
910 {
911 //Load Access Types listbox & filter
912 string sGroup = cboAccessTypeFilter.Text;
913 if (sGroup == "<Show All Access Types>")
914 {
915 LoadListBox("ALL");
916 }
917 else
918 {
919 LoadListBox("SELECTED");
920 }
921
922 }
923
924
[1106]925 private void lstResults_DoubleClick(object sender, EventArgs e)
926 {
927 ProcessChoice(sender, e);
928 }
[614]929
[1106]930 private void btnAccept_Click(object sender, EventArgs e)
931 {
932 ProcessChoice(sender, e);
[1097]933 }
[614]934
[1097]935 /// <summary>
[1106]936 /// Shared method to process a user's choice
[1097]937 /// </summary>
[1106]938 /// <param name="s">sender</param>
939 /// <param name="e">EventArgs</param>
940 private void ProcessChoice(object s, EventArgs e)
[1097]941 {
942 if (lstResults.SelectedIndices.Count == 0)
943 {
944 this.DialogResult = DialogResult.None;
[1143]945 lblMessage.Text = "No slot selected!";
[1097]946 return;
947 }
948
[1143]949 int availabilityKey = Int32.Parse(lstResults.SelectedItems[0].SubItems[0].Text);
[1097]950 _selectedAvailability = (from av in lstResultantAvailabilities
951 where av.AvailabilityType == availabilityKey
952 select av).Single<CGAvailability>();
953 this.DialogResult = DialogResult.OK;
954 }
955
[1106]956 /// <summary>
957 /// Adjust start date based on end date.
958 /// </summary>
959 /// <param name="sender"></param>
960 /// <param name="e"></param>
961 private void dtStart_ValueChanged(object sender, EventArgs e)
962 {
963 if (dtEnd.Value < dtStart.Value) dtEnd.Value = dtStart.Value;
964 }
965
966 /// <summary>
967 /// Adjust end date based on start date.
968 /// </summary>
969 /// <param name="sender"></param>
970 /// <param name="e"></param>
971 private void dtEnd_ValueChanged(object sender, EventArgs e)
972 {
973 if (dtStart.Value > dtEnd.Value) dtStart.Value = dtEnd.Value;
974 }
975
[614]976 #endregion Event Handlers
977
978 #region Properties
[1097]979
[614]980 /// <summary>
[1097]981 /// Gets the Availability Selected by the User in which to put an appointment
982 /// </summary>
983 public CGAvailability SelectedAvailability
984 {
985 get { return this._selectedAvailability; }
986 }
[614]987
988 #endregion Properties
[1106]989
990
[1097]991 }
[614]992}
Note: See TracBrowser for help on using the repository browser.