source: Scheduling/branches/GUI1.2/DSelectSchedules.cs@ 1295

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

Initial committ of scheduling package

File size: 11.5 KB
Line 
1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Data;
7
8namespace IndianHealthService.ClinicalScheduling
9{
10 /// <summary>
11 /// Summary description for DSelectSchedules.
12 /// </summary>
13 public class DSelectSchedules : System.Windows.Forms.Form
14 {
15 private System.Windows.Forms.Panel pnlOkCancel;
16 private System.Windows.Forms.Button cmdCancel;
17 private System.Windows.Forms.Button cmdOK;
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.Label label2;
22 private System.Windows.Forms.CheckedListBox lstResource;
23 private System.Windows.Forms.CheckBox chkOneWindow;
24 private System.Windows.Forms.Label label1;
25 private System.Windows.Forms.ComboBox cboResourceGroup;
26 private System.Windows.Forms.TextBox txtGroupWindow;
27 private System.Windows.Forms.Label label3;
28 /// <summary>
29 /// Required designer variable.
30 /// </summary>
31 private System.ComponentModel.Container components = null;
32
33 public DSelectSchedules()
34 {
35 //
36 // Required for Windows Form Designer support
37 //
38 InitializeComponent();
39
40 }
41
42 /// <summary>
43 /// Clean up any resources being used.
44 /// </summary>
45 protected override void Dispose( bool disposing )
46 {
47 if( disposing )
48 {
49 if(components != null)
50 {
51 components.Dispose();
52 }
53 }
54 base.Dispose( disposing );
55 }
56
57 #region Windows Form Designer generated code
58 /// <summary>
59 /// Required method for Designer support - do not modify
60 /// the contents of this method with the code editor.
61 /// </summary>
62 private void InitializeComponent()
63 {
64 this.pnlOkCancel = new System.Windows.Forms.Panel();
65 this.cmdCancel = new System.Windows.Forms.Button();
66 this.cmdOK = new System.Windows.Forms.Button();
67 this.pnlDescription = new System.Windows.Forms.Panel();
68 this.grpDescription = new System.Windows.Forms.GroupBox();
69 this.lblDescription = new System.Windows.Forms.Label();
70 this.label2 = new System.Windows.Forms.Label();
71 this.lstResource = new System.Windows.Forms.CheckedListBox();
72 this.chkOneWindow = new System.Windows.Forms.CheckBox();
73 this.label1 = new System.Windows.Forms.Label();
74 this.cboResourceGroup = new System.Windows.Forms.ComboBox();
75 this.txtGroupWindow = new System.Windows.Forms.TextBox();
76 this.label3 = new System.Windows.Forms.Label();
77 this.pnlOkCancel.SuspendLayout();
78 this.pnlDescription.SuspendLayout();
79 this.grpDescription.SuspendLayout();
80 this.SuspendLayout();
81 //
82 // pnlOkCancel
83 //
84 this.pnlOkCancel.Controls.Add(this.cmdCancel);
85 this.pnlOkCancel.Controls.Add(this.cmdOK);
86 this.pnlOkCancel.Dock = System.Windows.Forms.DockStyle.Bottom;
87 this.pnlOkCancel.Location = new System.Drawing.Point(0, 478);
88 this.pnlOkCancel.Name = "pnlOkCancel";
89 this.pnlOkCancel.Size = new System.Drawing.Size(512, 40);
90 this.pnlOkCancel.TabIndex = 5;
91 //
92 // cmdCancel
93 //
94 this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
95 this.cmdCancel.Location = new System.Drawing.Point(416, 8);
96 this.cmdCancel.Name = "cmdCancel";
97 this.cmdCancel.Size = new System.Drawing.Size(64, 24);
98 this.cmdCancel.TabIndex = 30;
99 this.cmdCancel.Text = "Cancel";
100 //
101 // cmdOK
102 //
103 this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK;
104 this.cmdOK.Location = new System.Drawing.Point(336, 8);
105 this.cmdOK.Name = "cmdOK";
106 this.cmdOK.Size = new System.Drawing.Size(64, 24);
107 this.cmdOK.TabIndex = 25;
108 this.cmdOK.Text = "OK";
109 //
110 // pnlDescription
111 //
112 this.pnlDescription.Controls.Add(this.grpDescription);
113 this.pnlDescription.Dock = System.Windows.Forms.DockStyle.Bottom;
114 this.pnlDescription.Location = new System.Drawing.Point(0, 398);
115 this.pnlDescription.Name = "pnlDescription";
116 this.pnlDescription.Size = new System.Drawing.Size(512, 80);
117 this.pnlDescription.TabIndex = 48;
118 //
119 // grpDescription
120 //
121 this.grpDescription.Controls.Add(this.lblDescription);
122 this.grpDescription.Dock = System.Windows.Forms.DockStyle.Fill;
123 this.grpDescription.Location = new System.Drawing.Point(0, 0);
124 this.grpDescription.Name = "grpDescription";
125 this.grpDescription.Size = new System.Drawing.Size(512, 80);
126 this.grpDescription.TabIndex = 0;
127 this.grpDescription.TabStop = false;
128 this.grpDescription.Text = "Description";
129 //
130 // lblDescription
131 //
132 this.lblDescription.Dock = System.Windows.Forms.DockStyle.Fill;
133 this.lblDescription.Location = new System.Drawing.Point(3, 16);
134 this.lblDescription.Name = "lblDescription";
135 this.lblDescription.Size = new System.Drawing.Size(506, 61);
136 this.lblDescription.TabIndex = 1;
137 this.lblDescription.Text = "Use this panel to open a group of resource schedules. You can open each schedule" +
138 " in a separate window or open all schedules in one single group window. If you " +
139 "use a group window, you can assign a name to identify the window.";
140 //
141 // label2
142 //
143 this.label2.Location = new System.Drawing.Point(16, 80);
144 this.label2.Name = "label2";
145 this.label2.Size = new System.Drawing.Size(240, 16);
146 this.label2.TabIndex = 53;
147 this.label2.Text = "Resource:";
148 //
149 // lstResource
150 //
151 this.lstResource.HorizontalScrollbar = true;
152 this.lstResource.Location = new System.Drawing.Point(16, 104);
153 this.lstResource.MultiColumn = true;
154 this.lstResource.Name = "lstResource";
155 this.lstResource.Size = new System.Drawing.Size(448, 184);
156 this.lstResource.TabIndex = 10;
157 //
158 // chkOneWindow
159 //
160 this.chkOneWindow.Checked = true;
161 this.chkOneWindow.CheckState = System.Windows.Forms.CheckState.Checked;
162 this.chkOneWindow.Location = new System.Drawing.Point(24, 304);
163 this.chkOneWindow.Name = "chkOneWindow";
164 this.chkOneWindow.Size = new System.Drawing.Size(328, 24);
165 this.chkOneWindow.TabIndex = 15;
166 this.chkOneWindow.Text = "Open Schedules in a Single Group Window";
167 this.chkOneWindow.CheckedChanged += new System.EventHandler(this.chkOneWindow_CheckedChanged);
168 //
169 // label1
170 //
171 this.label1.Location = new System.Drawing.Point(16, 16);
172 this.label1.Name = "label1";
173 this.label1.Size = new System.Drawing.Size(208, 16);
174 this.label1.TabIndex = 58;
175 this.label1.Text = "Resource Group:";
176 //
177 // cboResourceGroup
178 //
179 this.cboResourceGroup.Location = new System.Drawing.Point(16, 40);
180 this.cboResourceGroup.Name = "cboResourceGroup";
181 this.cboResourceGroup.Size = new System.Drawing.Size(448, 21);
182 this.cboResourceGroup.TabIndex = 5;
183 this.cboResourceGroup.SelectionChangeCommitted += new System.EventHandler(this.cboResourceGroup_SelectionChangeCommitted);
184 //
185 // txtGroupWindow
186 //
187 this.txtGroupWindow.Location = new System.Drawing.Point(160, 344);
188 this.txtGroupWindow.Name = "txtGroupWindow";
189 this.txtGroupWindow.Size = new System.Drawing.Size(304, 20);
190 this.txtGroupWindow.TabIndex = 20;
191 this.txtGroupWindow.Text = "";
192 //
193 // label3
194 //
195 this.label3.Location = new System.Drawing.Point(32, 344);
196 this.label3.Name = "label3";
197 this.label3.Size = new System.Drawing.Size(120, 16);
198 this.label3.TabIndex = 58;
199 this.label3.Text = "Group Window Name:";
200 //
201 // DSelectSchedules
202 //
203 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
204 this.ClientSize = new System.Drawing.Size(512, 518);
205 this.Controls.Add(this.txtGroupWindow);
206 this.Controls.Add(this.label1);
207 this.Controls.Add(this.cboResourceGroup);
208 this.Controls.Add(this.chkOneWindow);
209 this.Controls.Add(this.label2);
210 this.Controls.Add(this.lstResource);
211 this.Controls.Add(this.pnlDescription);
212 this.Controls.Add(this.pnlOkCancel);
213 this.Controls.Add(this.label3);
214 this.Name = "DSelectSchedules";
215 this.Text = "Open Selected Schedules";
216 this.pnlOkCancel.ResumeLayout(false);
217 this.pnlDescription.ResumeLayout(false);
218 this.grpDescription.ResumeLayout(false);
219 this.ResumeLayout(false);
220
221 }
222 #endregion
223
224 #region Fields
225 private DataTable m_dtGroups;
226 private DataView m_dvGroups;
227 private DataTable m_dtResources;
228 private DataView m_dvResources;
229 private DataSet m_dsGlobal;
230
231 #endregion Fields
232
233 #region Properties
234
235 /// <summary>
236 /// Returns the an ArrayList of selected resource names
237 /// </summary>
238 public ArrayList SelectedClinics
239 {
240
241 get
242 {
243 System.Collections.ArrayList al = new System.Collections.ArrayList();
244 foreach(DataRowView s in this.lstResource.CheckedItems)
245 {
246 al.Add(s["RESOURCE_NAME"].ToString());
247 }
248 return al;
249 }
250 }
251
252 public bool SingleWindow
253 {
254 get
255 {
256 return this.chkOneWindow.Checked;
257 }
258 }
259
260 public string GroupWindowName
261 {
262 get
263 {
264 return this.txtGroupWindow.Text;
265 }
266 }
267 #endregion Properties
268
269
270 public void InitializePage(DataSet dsGlobal, string sWindowText)
271 {
272 try
273 {
274 m_dsGlobal = dsGlobal;
275 this.Text = sWindowText;
276 m_dtResources = dsGlobal.Tables["Resources"];
277 m_dvResources = new DataView(m_dtResources);
278 m_dvResources.Sort = "RESOURCE_NAME ASC";
279 m_dvResources.RowFilter = "INACTIVE <> 1 AND VIEW = 1";
280 lstResource.DataSource = m_dvResources;
281 lstResource.DisplayMember = "RESOURCE_NAME";
282 lstResource.ValueMember = "RESOURCE_NAME";
283
284 m_dtGroups = dsGlobal.Tables["ResourceGroup"].Copy();
285 m_dvGroups = new DataView(m_dtGroups);
286 m_dvGroups.Sort = "RESOURCE_GROUP ASC";
287 this.cboResourceGroup.Items.Add("<Show All Resources & Clinics>");
288 foreach (DataRowView drvG in m_dvGroups)
289 {
290 this.cboResourceGroup.Items.Add(drvG["RESOURCE_GROUP"]);
291 }
292 this.cboResourceGroup.Text = "<Show All Resources & Clinics>";
293 return;
294 }
295 catch(Exception ex)
296 {
297 throw ex;
298 }
299
300 }
301
302 private void cboResourceGroup_SelectionChangeCommitted(object sender, System.EventArgs e)
303 {
304 string sGroup = cboResourceGroup.SelectedItem.ToString();
305 if (sGroup == "<Show All Resources & Clinics>")
306 {
307 LoadListBox("ALL");
308 }
309 else
310 {
311 LoadListBox("SELECTED");
312 }
313
314 }
315
316 private void LoadListBox(string sGroup)
317 {
318 if (sGroup == "ALL")
319 {
320 //Load the Resources list box with ALL resources
321 m_dtResources = m_dsGlobal.Tables["Resources"];
322 m_dvResources = new DataView(m_dtResources);
323 m_dvResources = new DataView(m_dtResources);
324 m_dvResources.Sort = "RESOURCE_NAME ASC";
325 m_dvResources.RowFilter = "INACTIVE <> 1 AND VIEW = 1";
326 lstResource.DataSource = m_dvResources;
327 lstResource.DisplayMember = "RESOURCE_NAME";
328 lstResource.ValueMember = "RESOURCE_NAME";
329 }
330 else
331 {
332 //Load the Resources list box with active resources belonging
333 //to group sGroup
334
335 //Build Resource Group table containing *active* Resources and their Groups
336 m_dtResources = m_dsGlobal.Tables["GroupResources"];
337 //Create a view that is filterable on ResourceGroup
338 m_dvResources = new DataView(m_dtResources);
339 m_dvResources.RowFilter = "RESOURCE_GROUP = '" + this.cboResourceGroup.SelectedItem.ToString() + "'";
340 lstResource.DataSource = m_dvResources;
341 lstResource.DisplayMember = "RESOURCE_NAME";
342 lstResource.ValueMember = "RESOURCE_NAME";
343 }
344 }
345
346 private void chkOneWindow_CheckedChanged(object sender, System.EventArgs e)
347 {
348 this.txtGroupWindow.Enabled = this.chkOneWindow.Checked;
349 }
350
351 }
352}
Note: See TracBrowser for help on using the repository browser.