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

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

Remove CGSchedLib.OutputArray everywhere. Used to be needed in VS 2003; not anymore as you can see tables now.
CalendarGrid:

  • Make MinSince80 and TimesOverlap static functions for use by other classes since they are done over and over again.

CGAppointments:

  • Documentation updates

CGAVDocument:

CGDocument:

CGDocumentManager:

CGSchedLib: Lots of Changes

CGView:

  • OnUpdateScheduleCallback now has try catch when it this.Invokes the original form so that it won't crash if the form has been closed before it gets called.
File size: 29.8 KB
Line 
1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Data;
7//using System.Data.OleDb;
8using IndianHealthService.BMXNet;
9
10namespace IndianHealthService.ClinicalScheduling
11{
12 /// <summary>
13 /// Summary description for DApptSearch.
14 /// </summary>
15 public class DApptSearch : System.Windows.Forms.Form
16 {
17 private System.Windows.Forms.Panel panel1;
18 private System.Windows.Forms.Button cmdCancel;
19 private System.Windows.Forms.Button cmdOK;
20 private System.Windows.Forms.Panel pnlDescription;
21 private System.Windows.Forms.GroupBox grpDescription;
22 private System.Windows.Forms.Label lblDescription;
23 private System.Windows.Forms.GroupBox groupBox1;
24 private System.Windows.Forms.Label label3;
25 private System.Windows.Forms.Label label2;
26 private System.Windows.Forms.CheckedListBox lstAccessTypes;
27 private System.Windows.Forms.ComboBox cboAccessTypeFilter;
28 private System.Windows.Forms.GroupBox grpDayOfWeek;
29 private System.Windows.Forms.CheckBox chkSun;
30 private System.Windows.Forms.CheckBox chkSat;
31 private System.Windows.Forms.CheckBox chkFri;
32 private System.Windows.Forms.CheckBox chkThu;
33 private System.Windows.Forms.CheckBox chkWed;
34 private System.Windows.Forms.CheckBox chkTue;
35 private System.Windows.Forms.CheckBox chkMon;
36 private System.Windows.Forms.GroupBox grpTimeOfDay;
37 private System.Windows.Forms.RadioButton rdoBoth;
38 private System.Windows.Forms.RadioButton rdoPM;
39 private System.Windows.Forms.RadioButton rdoAM;
40 private System.Windows.Forms.Label label1;
41 private System.Windows.Forms.MonthCalendar calStartDate;
42 private System.Windows.Forms.GroupBox groupBox2;
43 private System.Windows.Forms.DataGrid grdResult;
44 private System.Windows.Forms.Button cmdSearch;
45 /// <summary>
46 /// Required designer variable.
47 /// </summary>
48 private System.ComponentModel.Container components = null;
49
50 public DApptSearch()
51 {
52 InitializeComponent();
53 }
54
55 #region Fields
56
57 private CGDocumentManager m_DocManager;
58
59 private DataSet m_dsGlobal;
60 DataTable m_dtTypes;
61 DataView m_dvTypes;
62
63 DateTime m_dStart;
64 DateTime m_dEnd;
65 ArrayList m_alResources;
66 ArrayList m_alAccessTypes;
67 string m_sWeekDays;
68 string m_sAmpm;
69
70 DataTable m_dtResult;
71 DataView m_dvResult;
72
73 string m_sSelectedResource;
74 DateTime m_sSelectedDate;
75
76 #endregion Fields
77
78 #region Methods
79
80 public void LoadListBox(string sGroup)
81 {
82 if (sGroup == "ALL")
83 {
84 //Load the Access Type list box with ALL access types
85 m_dtTypes = m_dsGlobal.Tables["AccessTypes"];
86 m_dvTypes = new DataView(m_dtTypes);
87 lstAccessTypes.DataSource = m_dvTypes;
88 lstAccessTypes.DisplayMember = "ACCESS_TYPE_NAME";
89 lstAccessTypes.Tag = 1; //This holds the column index of the ACCESS_TYPE_NAME column
90 lstAccessTypes.ValueMember = "BMXIEN";
91 }
92 else
93 {
94 //Load the Access Type list box with active access types belonging
95 //to group sGroup
96
97 //Build AccessGroup table containing *active* AccessTypes and their Groups
98 m_dtTypes = m_dsGlobal.Tables["AccessGroupType"];
99 //Create a view that is filterable on Access Group
100 m_dvTypes = new DataView(m_dtTypes);
101 m_dvTypes.RowFilter = "ACCESS_GROUP = '" + this.cboAccessTypeFilter.Text + "'";
102 lstAccessTypes.DataSource = m_dvTypes;
103 lstAccessTypes.DisplayMember = "ACCESS_TYPE";
104 lstAccessTypes.ValueMember = "ACCESS_TYPE_ID";
105 lstAccessTypes.Tag = 4; //This holds the column index of the ACCESS_TYPE column
106 }
107 }
108
109 public void InitializePage(ArrayList alResources, CGDocumentManager docManager)
110 {
111
112 this.m_DocManager = docManager;
113 this.m_dsGlobal = m_DocManager.GlobalDataSet;
114 System.IntPtr pHandle = this.Handle;
115 LoadListBox("ALL");
116
117 m_dStart = DateTime.Today;
118 m_dEnd = new DateTime(9999);
119 this.m_alResources = alResources;
120 this.m_alAccessTypes = new ArrayList();
121 this.m_sAmpm="both";
122 this.m_sWeekDays = "";
123
124 //Load filter combo with list of access type groups
125 DataTable dtGroup = m_dsGlobal.Tables["AccessGroup"];
126 DataSet dsTemp = new DataSet("dsTemp");
127 dsTemp.Tables.Add(dtGroup.Copy());
128 DataTable dtTemp = dsTemp.Tables["AccessGroup"];
129 DataView dvGroup = new DataView(dtTemp);
130 DataRowView drv = dvGroup.AddNew();
131 drv["ACCESS_GROUP"]="<Show All Access Types>";
132 cboAccessTypeFilter.DataSource = dvGroup;
133 cboAccessTypeFilter.DisplayMember = "ACCESS_GROUP";
134 cboAccessTypeFilter.SelectedText = "<Show All Access Types>";
135 cboAccessTypeFilter.SelectedIndex = cboAccessTypeFilter.Items.Count - 1;
136 cboAccessTypeFilter.Refresh();
137
138 //Create DataGridTableStyle for Result grid
139 DataGridTableStyle tsResult = new DataGridTableStyle();
140 tsResult.MappingName = "Result";
141 tsResult.ReadOnly = true;
142 // Add START_TIME column style.
143 DataGridTextBoxColumn colStartTime = new DataGridTextBoxColumn();
144 colStartTime.MappingName = "START_TIME";
145 colStartTime.HeaderText = "Start Time";
146 colStartTime.Width = 200;
147 colStartTime.Format = "f";
148 tsResult.GridColumnStyles.Add(colStartTime);
149
150 // Add END_TIME column style.
151 DataGridTextBoxColumn colEndTime = new DataGridTextBoxColumn();
152 colEndTime.MappingName = "END_TIME";
153 colEndTime.HeaderText = "End Time";
154 colEndTime.Width = 75;
155 colEndTime.Format = "h:mm tt";
156 tsResult.GridColumnStyles.Add(colEndTime);
157
158 // Add RESOURCE column style.
159 DataGridTextBoxColumn colResource = new DataGridTextBoxColumn();
160 colResource.MappingName = "RESOURCE";
161 colResource.HeaderText = "Resource";
162 colResource.Width = 200;
163 tsResult.GridColumnStyles.Add(colResource);
164
165 // Add SLOTS column style.
166 DataGridTextBoxColumn colSlots = new DataGridTextBoxColumn();
167 colSlots.MappingName = "SLOTS";
168 colSlots.HeaderText = "Slots";
169 colSlots.Width = 50;
170 tsResult.GridColumnStyles.Add(colSlots);
171
172 // Add AMPM column style.
173 DataGridTextBoxColumn colAccess = new DataGridTextBoxColumn();
174 colAccess.MappingName = "ACCESSNAME";
175 colAccess.HeaderText = "Access Type";
176 colAccess.Width = 200;
177 tsResult.GridColumnStyles.Add(colAccess);
178 grdResult.TableStyles.Add(tsResult);
179
180 this.UpdateDialogData(true);
181
182 }
183
184 /// <summary>
185 /// If b is true, moves member vars into control data
186 /// otherwise, moves control data into member vars
187 /// </summary>
188 /// <param name="b"></param>
189 private void UpdateDialogData(bool b)
190 {
191 if (b == true) //move member vars into controls
192 {
193
194 }
195 else //move control data into member vars
196 {
197
198 //Build AccessType list
199
200 this.m_alAccessTypes.Clear();
201
202 for (int j = 0; j < this.lstAccessTypes.CheckedItems.Count; j++)
203 {
204 DataRowView drv = (DataRowView) lstAccessTypes.CheckedItems[j];
205 int nIndex = (int) lstAccessTypes.Tag;
206 string sItem = drv.Row.ItemArray[nIndex].ToString();
207 m_alAccessTypes.Add(sItem);
208 }
209
210 //AM/PM
211 this.m_sAmpm = (this.rdoAM.Checked == true) ? "AM":"BOTH";
212 if (this.m_sAmpm != "AM")
213 this.m_sAmpm = (this.rdoPM.Checked == true) ? "PM":"BOTH";
214
215
216 //Weekday
217 this.m_sWeekDays = ""; //any
218 if (chkMon.Checked == true)
219 m_sWeekDays += "Monday";
220 if (chkTue.Checked == true)
221 m_sWeekDays += "Tuesday";
222 if (chkWed.Checked == true)
223 m_sWeekDays += "Wednesday";
224 if (chkThu.Checked == true)
225 m_sWeekDays += "Thursday";
226 if (chkFri.Checked == true)
227 m_sWeekDays += "Friday";
228 if (chkSat.Checked == true)
229 m_sWeekDays += "Saturday";
230 if (chkSun.Checked == true)
231 m_sWeekDays += "Sunday";
232
233 //Start
234 this.m_dStart = this.calStartDate.SelectionStart;
235
236 //End
237 m_dEnd = calStartDate.SelectionEnd;
238 m_dEnd = m_dEnd.AddHours(23);
239 m_dEnd = m_dEnd.AddMinutes(59);
240
241 }
242 }
243
244
245 /// <summary>
246 /// Clean up any resources being used.
247 /// </summary>
248 protected override void Dispose( bool disposing )
249 {
250 if( disposing )
251 {
252 if(components != null)
253 {
254 components.Dispose();
255 }
256 }
257 base.Dispose( disposing );
258 }
259
260 #endregion Methods
261
262 #region Windows Form Designer generated code
263 /// <summary>
264 /// Required method for Designer support - do not modify
265 /// the contents of this method with the code editor.
266 /// </summary>
267 private void InitializeComponent()
268 {
269 this.panel1 = new System.Windows.Forms.Panel();
270 this.cmdSearch = new System.Windows.Forms.Button();
271 this.cmdCancel = new System.Windows.Forms.Button();
272 this.cmdOK = new System.Windows.Forms.Button();
273 this.pnlDescription = new System.Windows.Forms.Panel();
274 this.grpDescription = new System.Windows.Forms.GroupBox();
275 this.lblDescription = new System.Windows.Forms.Label();
276 this.groupBox1 = new System.Windows.Forms.GroupBox();
277 this.label3 = new System.Windows.Forms.Label();
278 this.label2 = new System.Windows.Forms.Label();
279 this.lstAccessTypes = new System.Windows.Forms.CheckedListBox();
280 this.cboAccessTypeFilter = new System.Windows.Forms.ComboBox();
281 this.grpDayOfWeek = new System.Windows.Forms.GroupBox();
282 this.chkSun = new System.Windows.Forms.CheckBox();
283 this.chkSat = new System.Windows.Forms.CheckBox();
284 this.chkFri = new System.Windows.Forms.CheckBox();
285 this.chkThu = new System.Windows.Forms.CheckBox();
286 this.chkWed = new System.Windows.Forms.CheckBox();
287 this.chkTue = new System.Windows.Forms.CheckBox();
288 this.chkMon = new System.Windows.Forms.CheckBox();
289 this.grpTimeOfDay = new System.Windows.Forms.GroupBox();
290 this.rdoBoth = new System.Windows.Forms.RadioButton();
291 this.rdoPM = new System.Windows.Forms.RadioButton();
292 this.rdoAM = new System.Windows.Forms.RadioButton();
293 this.label1 = new System.Windows.Forms.Label();
294 this.calStartDate = new System.Windows.Forms.MonthCalendar();
295 this.groupBox2 = new System.Windows.Forms.GroupBox();
296 this.grdResult = new System.Windows.Forms.DataGrid();
297 this.panel1.SuspendLayout();
298 this.pnlDescription.SuspendLayout();
299 this.grpDescription.SuspendLayout();
300 this.groupBox1.SuspendLayout();
301 this.grpDayOfWeek.SuspendLayout();
302 this.grpTimeOfDay.SuspendLayout();
303 this.groupBox2.SuspendLayout();
304 ((System.ComponentModel.ISupportInitialize)(this.grdResult)).BeginInit();
305 this.SuspendLayout();
306 //
307 // panel1
308 //
309 this.panel1.Controls.Add(this.cmdSearch);
310 this.panel1.Controls.Add(this.cmdCancel);
311 this.panel1.Controls.Add(this.cmdOK);
312 this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
313 this.panel1.Location = new System.Drawing.Point(0, 461);
314 this.panel1.Name = "panel1";
315 this.panel1.Size = new System.Drawing.Size(923, 40);
316 this.panel1.TabIndex = 4;
317 //
318 // cmdSearch
319 //
320 this.cmdSearch.Location = new System.Drawing.Point(536, 8);
321 this.cmdSearch.Name = "cmdSearch";
322 this.cmdSearch.Size = new System.Drawing.Size(72, 24);
323 this.cmdSearch.TabIndex = 2;
324 this.cmdSearch.Text = "Search";
325 this.cmdSearch.Click += new System.EventHandler(this.cmdSearch_Click);
326 //
327 // cmdCancel
328 //
329 this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
330 this.cmdCancel.Location = new System.Drawing.Point(616, 8);
331 this.cmdCancel.Name = "cmdCancel";
332 this.cmdCancel.Size = new System.Drawing.Size(64, 24);
333 this.cmdCancel.TabIndex = 1;
334 this.cmdCancel.Text = "Cancel";
335 //
336 // cmdOK
337 //
338 this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK;
339 this.cmdOK.Location = new System.Drawing.Point(128, 8);
340 this.cmdOK.Name = "cmdOK";
341 this.cmdOK.Size = new System.Drawing.Size(64, 24);
342 this.cmdOK.TabIndex = 0;
343 this.cmdOK.Text = "OK";
344 this.cmdOK.Visible = false;
345 this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
346 //
347 // pnlDescription
348 //
349 this.pnlDescription.Controls.Add(this.grpDescription);
350 this.pnlDescription.Dock = System.Windows.Forms.DockStyle.Bottom;
351 this.pnlDescription.Location = new System.Drawing.Point(0, 397);
352 this.pnlDescription.Name = "pnlDescription";
353 this.pnlDescription.Size = new System.Drawing.Size(923, 64);
354 this.pnlDescription.TabIndex = 47;
355 //
356 // grpDescription
357 //
358 this.grpDescription.Controls.Add(this.lblDescription);
359 this.grpDescription.Dock = System.Windows.Forms.DockStyle.Fill;
360 this.grpDescription.Location = new System.Drawing.Point(0, 0);
361 this.grpDescription.Name = "grpDescription";
362 this.grpDescription.Size = new System.Drawing.Size(923, 64);
363 this.grpDescription.TabIndex = 0;
364 this.grpDescription.TabStop = false;
365 this.grpDescription.Text = "Description";
366 //
367 // lblDescription
368 //
369 this.lblDescription.Dock = System.Windows.Forms.DockStyle.Fill;
370 this.lblDescription.Location = new System.Drawing.Point(3, 16);
371 this.lblDescription.Name = "lblDescription";
372 this.lblDescription.Size = new System.Drawing.Size(917, 45);
373 this.lblDescription.TabIndex = 1;
374 this.lblDescription.Text = "Search for available appointment times using this panel. You may narrow your sea" +
375 "rch by selecting an access type or by selecting specific days of the week or tim" +
376 "es of day.";
377 //
378 // groupBox1
379 //
380 this.groupBox1.Controls.Add(this.label3);
381 this.groupBox1.Controls.Add(this.label2);
382 this.groupBox1.Controls.Add(this.lstAccessTypes);
383 this.groupBox1.Controls.Add(this.cboAccessTypeFilter);
384 this.groupBox1.Controls.Add(this.grpDayOfWeek);
385 this.groupBox1.Controls.Add(this.grpTimeOfDay);
386 this.groupBox1.Controls.Add(this.label1);
387 this.groupBox1.Controls.Add(this.calStartDate);
388 this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
389 this.groupBox1.Location = new System.Drawing.Point(0, 0);
390 this.groupBox1.Name = "groupBox1";
391 this.groupBox1.Size = new System.Drawing.Size(923, 208);
392 this.groupBox1.TabIndex = 56;
393 this.groupBox1.TabStop = false;
394 this.groupBox1.Text = "Search Parameters";
395 //
396 // label3
397 //
398 this.label3.Location = new System.Drawing.Point(684, 64);
399 this.label3.Name = "label3";
400 this.label3.Size = new System.Drawing.Size(80, 16);
401 this.label3.TabIndex = 63;
402 this.label3.Text = "Access Type:";
403 //
404 // label2
405 //
406 this.label2.Location = new System.Drawing.Point(684, 21);
407 this.label2.Name = "label2";
408 this.label2.Size = new System.Drawing.Size(104, 16);
409 this.label2.TabIndex = 62;
410 this.label2.Text = "Access Group:";
411 //
412 // lstAccessTypes
413 //
414 this.lstAccessTypes.CheckOnClick = true;
415 this.lstAccessTypes.HorizontalScrollbar = true;
416 this.lstAccessTypes.Location = new System.Drawing.Point(661, 88);
417 this.lstAccessTypes.MultiColumn = true;
418 this.lstAccessTypes.Name = "lstAccessTypes";
419 this.lstAccessTypes.Size = new System.Drawing.Size(250, 109);
420 this.lstAccessTypes.TabIndex = 61;
421 //
422 // cboAccessTypeFilter
423 //
424 this.cboAccessTypeFilter.Location = new System.Drawing.Point(661, 40);
425 this.cboAccessTypeFilter.Name = "cboAccessTypeFilter";
426 this.cboAccessTypeFilter.Size = new System.Drawing.Size(250, 21);
427 this.cboAccessTypeFilter.TabIndex = 60;
428 this.cboAccessTypeFilter.Text = "cboAccessTypeFilter";
429 this.cboAccessTypeFilter.SelectionChangeCommitted += new System.EventHandler(this.cboAccessTypeFilter_SelectionChangeCommitted);
430 //
431 // grpDayOfWeek
432 //
433 this.grpDayOfWeek.Controls.Add(this.chkSun);
434 this.grpDayOfWeek.Controls.Add(this.chkSat);
435 this.grpDayOfWeek.Controls.Add(this.chkFri);
436 this.grpDayOfWeek.Controls.Add(this.chkThu);
437 this.grpDayOfWeek.Controls.Add(this.chkWed);
438 this.grpDayOfWeek.Controls.Add(this.chkTue);
439 this.grpDayOfWeek.Controls.Add(this.chkMon);
440 this.grpDayOfWeek.Location = new System.Drawing.Point(311, 94);
441 this.grpDayOfWeek.Name = "grpDayOfWeek";
442 this.grpDayOfWeek.Size = new System.Drawing.Size(240, 101);
443 this.grpDayOfWeek.TabIndex = 59;
444 this.grpDayOfWeek.TabStop = false;
445 this.grpDayOfWeek.Text = "Day of the Week";
446 //
447 // chkSun
448 //
449 this.chkSun.Location = new System.Drawing.Point(176, 64);
450 this.chkSun.Name = "chkSun";
451 this.chkSun.Size = new System.Drawing.Size(48, 16);
452 this.chkSun.TabIndex = 6;
453 this.chkSun.Text = "Sun";
454 //
455 // chkSat
456 //
457 this.chkSat.Location = new System.Drawing.Point(128, 64);
458 this.chkSat.Name = "chkSat";
459 this.chkSat.Size = new System.Drawing.Size(48, 16);
460 this.chkSat.TabIndex = 5;
461 this.chkSat.Text = "Sat";
462 //
463 // chkFri
464 //
465 this.chkFri.Location = new System.Drawing.Point(72, 64);
466 this.chkFri.Name = "chkFri";
467 this.chkFri.Size = new System.Drawing.Size(48, 16);
468 this.chkFri.TabIndex = 4;
469 this.chkFri.Text = "Fri";
470 //
471 // chkThu
472 //
473 this.chkThu.Location = new System.Drawing.Point(16, 64);
474 this.chkThu.Name = "chkThu";
475 this.chkThu.Size = new System.Drawing.Size(48, 16);
476 this.chkThu.TabIndex = 3;
477 this.chkThu.Text = "Thu";
478 //
479 // chkWed
480 //
481 this.chkWed.Location = new System.Drawing.Point(128, 32);
482 this.chkWed.Name = "chkWed";
483 this.chkWed.Size = new System.Drawing.Size(48, 16);
484 this.chkWed.TabIndex = 2;
485 this.chkWed.Text = "Wed";
486 //
487 // chkTue
488 //
489 this.chkTue.Location = new System.Drawing.Point(72, 32);
490 this.chkTue.Name = "chkTue";
491 this.chkTue.Size = new System.Drawing.Size(48, 16);
492 this.chkTue.TabIndex = 1;
493 this.chkTue.Text = "Tue";
494 //
495 // chkMon
496 //
497 this.chkMon.Location = new System.Drawing.Point(16, 32);
498 this.chkMon.Name = "chkMon";
499 this.chkMon.Size = new System.Drawing.Size(48, 16);
500 this.chkMon.TabIndex = 0;
501 this.chkMon.Text = "Mon";
502 //
503 // grpTimeOfDay
504 //
505 this.grpTimeOfDay.Controls.Add(this.rdoBoth);
506 this.grpTimeOfDay.Controls.Add(this.rdoPM);
507 this.grpTimeOfDay.Controls.Add(this.rdoAM);
508 this.grpTimeOfDay.Location = new System.Drawing.Point(311, 32);
509 this.grpTimeOfDay.Name = "grpTimeOfDay";
510 this.grpTimeOfDay.Size = new System.Drawing.Size(240, 48);
511 this.grpTimeOfDay.TabIndex = 58;
512 this.grpTimeOfDay.TabStop = false;
513 this.grpTimeOfDay.Text = "Time of Day";
514 //
515 // rdoBoth
516 //
517 this.rdoBoth.Checked = true;
518 this.rdoBoth.Location = new System.Drawing.Point(176, 24);
519 this.rdoBoth.Name = "rdoBoth";
520 this.rdoBoth.Size = new System.Drawing.Size(48, 16);
521 this.rdoBoth.TabIndex = 2;
522 this.rdoBoth.TabStop = true;
523 this.rdoBoth.Text = "Both";
524 //
525 // rdoPM
526 //
527 this.rdoPM.Location = new System.Drawing.Point(96, 24);
528 this.rdoPM.Name = "rdoPM";
529 this.rdoPM.Size = new System.Drawing.Size(72, 16);
530 this.rdoPM.TabIndex = 1;
531 this.rdoPM.Text = "PM Only";
532 //
533 // rdoAM
534 //
535 this.rdoAM.Location = new System.Drawing.Point(16, 24);
536 this.rdoAM.Name = "rdoAM";
537 this.rdoAM.Size = new System.Drawing.Size(72, 16);
538 this.rdoAM.TabIndex = 0;
539 this.rdoAM.Text = "AM Only";
540 //
541 // label1
542 //
543 this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
544 this.label1.Location = new System.Drawing.Point(16, 24);
545 this.label1.Name = "label1";
546 this.label1.Size = new System.Drawing.Size(136, 16);
547 this.label1.TabIndex = 57;
548 this.label1.Text = "Date Range:";
549 //
550 // calStartDate
551 //
552 this.calStartDate.Location = new System.Drawing.Point(16, 40);
553 this.calStartDate.MaxSelectionCount = 62;
554 this.calStartDate.Name = "calStartDate";
555 this.calStartDate.TabIndex = 56;
556 //
557 // groupBox2
558 //
559 this.groupBox2.Controls.Add(this.grdResult);
560 this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
561 this.groupBox2.Location = new System.Drawing.Point(0, 208);
562 this.groupBox2.Name = "groupBox2";
563 this.groupBox2.Size = new System.Drawing.Size(923, 189);
564 this.groupBox2.TabIndex = 57;
565 this.groupBox2.TabStop = false;
566 this.groupBox2.Text = "Search Result";
567 //
568 // grdResult
569 //
570 this.grdResult.CaptionVisible = false;
571 this.grdResult.DataMember = "";
572 this.grdResult.Dock = System.Windows.Forms.DockStyle.Fill;
573 this.grdResult.HeaderForeColor = System.Drawing.SystemColors.ControlText;
574 this.grdResult.Location = new System.Drawing.Point(3, 16);
575 this.grdResult.Name = "grdResult";
576 this.grdResult.ReadOnly = true;
577 this.grdResult.Size = new System.Drawing.Size(917, 170);
578 this.grdResult.TabIndex = 0;
579 this.grdResult.DoubleClick += new System.EventHandler(this.grdResult_DoubleClick);
580 this.grdResult.CurrentCellChanged += new System.EventHandler(this.grdResult_CurrentCellChanged);
581 //
582 // DApptSearch
583 //
584 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
585 this.CancelButton = this.cmdCancel;
586 this.ClientSize = new System.Drawing.Size(923, 501);
587 this.Controls.Add(this.groupBox2);
588 this.Controls.Add(this.groupBox1);
589 this.Controls.Add(this.pnlDescription);
590 this.Controls.Add(this.panel1);
591 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
592 this.Name = "DApptSearch";
593 this.Text = "Find Clinic Availability";
594 this.panel1.ResumeLayout(false);
595 this.pnlDescription.ResumeLayout(false);
596 this.grpDescription.ResumeLayout(false);
597 this.groupBox1.ResumeLayout(false);
598 this.grpDayOfWeek.ResumeLayout(false);
599 this.grpTimeOfDay.ResumeLayout(false);
600 this.groupBox2.ResumeLayout(false);
601 ((System.ComponentModel.ISupportInitialize)(this.grdResult)).EndInit();
602 this.ResumeLayout(false);
603
604 }
605 #endregion
606
607 #region Event Handlers
608 private void cmdOK_Click(object sender, System.EventArgs e)
609 {
610
611 }
612
613 private void cmdSearch_Click(object sender, System.EventArgs e)
614 {
615 //Get the control data into local vars
616 UpdateDialogData(false);
617 //Resource array, Begin date, Access type array, MTWTF , AM PM
618 //Assemble |-delimited resource string
619 string sResources = "";
620 for (int j=0; j < m_alResources.Count; j++)
621 {
622 sResources = sResources + m_alResources[j];
623 if (j < (m_alResources.Count - 1))
624 sResources = sResources + "|";
625 }
626
627 //Access Types Array
628 string sTypes = "";
629 if (m_alAccessTypes.Count > 0)
630 {
631 for (int j=0; j < m_alAccessTypes.Count; j++)
632 {
633 sTypes = sTypes + (string) m_alAccessTypes[j];
634 if (j < (m_alAccessTypes.Count-1))
635 sTypes = sTypes + "|";
636 }
637 }
638
639 string sSearchInfo = "1|" + m_sAmpm + "|" + m_sWeekDays;
640 m_dtResult = CGSchedLib.CreateAvailabilitySchedule(m_DocManager, m_alResources, m_dStart, m_dEnd, m_alAccessTypes, ScheduleType.Resource, sSearchInfo);
641
642 if (m_dtResult.Rows.Count == 0)
643 {
644 MessageBox.Show("No availability found.");
645 return;
646 }
647
648 m_dtResult.TableName = "Result";
649 m_dtResult.Columns.Add("AMPM", System.Type.GetType("System.String") ,"Convert(START_TIME, 'System.String')" );
650 m_dtResult.Columns.Add("DAYOFWEEK", System.Type.GetType("System.String"));
651 m_dtResult.Columns.Add("ACCESSNAME", System.Type.GetType("System.String"));
652
653 DataRow drAT;
654 DateTime dt;
655 string sDOW;
656 int nAccessTypeID;
657 string sAccessType;
658
659 foreach (DataRow dr in m_dtResult.Rows)
660 {
661 dt = (DateTime) dr["START_TIME"];
662 sDOW = dt.DayOfWeek.ToString();
663 dr["DAYOFWEEK"] = sDOW;
664 if (dr["ACCESS_TYPE"].ToString() != "")
665 {
666 nAccessTypeID =Convert.ToInt16(dr["ACCESS_TYPE"].ToString());
667 drAT = m_dsGlobal.Tables["AccessTypes"].Rows.Find(nAccessTypeID);
668 if (drAT != null)
669 {
670 sAccessType = drAT["ACCESS_TYPE_NAME"].ToString();
671 dr["ACCESSNAME"] = sAccessType;
672 }
673 }
674 }
675
676
677 m_dvResult = new DataView(m_dtResult);
678
679 string sFilter = "(SLOTS > 0)";
680 if (m_sAmpm != "")
681 {
682 if (m_sAmpm == "AM")
683 sFilter = sFilter + " AND (AMPM LIKE '*AM*')";
684 if (m_sAmpm == "PM")
685 sFilter = sFilter + " AND (AMPM LIKE '*PM*')";
686 }
687
688 bool sOr = false;
689 if (m_sWeekDays != "")
690 {
691 sFilter += " AND (";
692 if (chkMon.Checked == true)
693 {
694 sFilter = sFilter + "(DAYOFWEEK LIKE '*Monday*')";
695 sOr = true;
696 }
697 if (chkTue.Checked == true)
698 {
699 sFilter = (sOr == true)?sFilter + " OR ":sFilter;
700 sFilter = sFilter + "(DAYOFWEEK LIKE '*Tuesday*')";
701 sOr = true;
702 }
703 if (chkWed.Checked == true)
704 {
705 sFilter = (sOr == true)?sFilter + " OR ":sFilter;
706 sFilter = sFilter + "(DAYOFWEEK LIKE '*Wednesday*')";
707 sOr = true;
708 }
709 if (chkThu.Checked == true)
710 {
711 sFilter = (sOr == true)?sFilter + " OR ":sFilter;
712 sFilter = sFilter + "(DAYOFWEEK LIKE '*Thursday*')";
713 sOr = true;
714 }
715 if (chkFri.Checked == true)
716 {
717 sFilter = (sOr == true)?sFilter + " OR ":sFilter;
718 sFilter = sFilter + "(DAYOFWEEK LIKE '*Friday*')";
719 sOr = true;
720 }
721 if (chkSat.Checked == true)
722 {
723 sFilter = (sOr == true)?sFilter + " OR ":sFilter;
724 sFilter = sFilter + "(DAYOFWEEK LIKE '*Saturday*')";
725 sOr = true;
726 }
727 if (chkSun.Checked == true)
728 {
729 sFilter = (sOr == true)?sFilter + " OR ":sFilter;
730 sFilter = sFilter + "(DAYOFWEEK LIKE '*Sunday*')";
731 sOr = true;
732 }
733 sFilter += ")";
734 }
735
736 if (m_alAccessTypes.Count > 0)
737 {
738 sFilter += " AND (";
739 sOr = false;
740 foreach (string sType in m_alAccessTypes)
741 {
742 if (sOr == true)
743 sFilter += " OR ";
744 sOr = true;
745 sFilter += "(ACCESSNAME = '" + sType + "')";
746 }
747 sFilter += ")";
748 }
749
750 m_dvResult.RowFilter = sFilter;
751 this.grdResult.DataSource = m_dvResult;
752
753 }
754
755 private void cboAccessTypeFilter_SelectionChangeCommitted(object sender, System.EventArgs e)
756 {
757 //Load Access Types listbox & filter
758 string sGroup = cboAccessTypeFilter.Text;
759 if (sGroup == "<Show All Access Types>")
760 {
761 LoadListBox("ALL");
762 }
763 else
764 {
765 LoadListBox("SELECTED");
766 }
767
768 }
769
770 private void grdResult_DoubleClick(object sender, System.EventArgs e)
771 {
772 if (grdResult.DataSource == null)
773 return;
774
775 DataGridCell dgCell;
776 dgCell = this.grdResult.CurrentCell;
777 dgCell.ColumnNumber = 2;
778 this.m_sSelectedResource = grdResult[dgCell.RowNumber, dgCell.ColumnNumber].ToString();
779 this.m_sSelectedDate = (DateTime) grdResult[dgCell.RowNumber,0];
780 this.DialogResult = DialogResult.OK;
781 this.Close();
782 }
783
784 private void grdResult_CurrentCellChanged(object sender, System.EventArgs e)
785 {
786 DataGridCell dgCell;
787 dgCell = this.grdResult.CurrentCell;
788 this.grdResult.Select(dgCell.RowNumber);
789
790 }
791
792 #endregion Event Handlers
793
794 #region Properties
795 /// <summary>
796 /// Gets the resource selected by the user
797 /// </summary>
798 public string SelectedResource
799 {
800 get
801 {
802 return this.m_sSelectedResource;
803 }
804 }
805
806 /// <summary>
807 /// Gets the date selected by the user
808 /// </summary>
809 public DateTime SelectedDate
810 {
811 get
812 {
813 return this.m_sSelectedDate;
814 }
815 }
816 #endregion Properties
817
818 }
819}
Note: See TracBrowser for help on using the repository browser.