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

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

StartDate for CGAVView, 1st try.
CGDocument uses StartDate from Current thread locale rather than current culture.

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