source: Scheduling/trunk/cs/bsdx0200GUISourceCode/DResourceUser.cs@ 1445

Last change on this file since 1445 was 899, checked in by Sam Habiel, 14 years ago
  1. Make combo boxes in DManagement searchable (in MS Lingo AutoComplete).
  2. Make sure that all DManagement lists and combo boxes are sorted.
File size: 14.0 KB
Line 
1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Data;
7using IndianHealthService.BMXNet;
8using System.Diagnostics;
9
10namespace IndianHealthService.ClinicalScheduling
11{
12 /// <summary>
13 /// Summary description for DResourceUser.
14 /// </summary>
15 public class DResourceUser : System.Windows.Forms.Form
16 {
17 private System.Windows.Forms.Label label1;
18 private System.Windows.Forms.Panel pnlPageBottom;
19 private System.Windows.Forms.Panel pnlDescription;
20 private System.Windows.Forms.GroupBox grpDescriptionResourceGroup;
21 private System.Windows.Forms.Label lblDescriptionResourceGroup;
22 private System.Windows.Forms.Button cmdOK;
23 private System.Windows.Forms.ComboBox cboScheduleUser;
24 private System.Windows.Forms.CheckBox chkModifySchedule;
25 private System.Windows.Forms.CheckBox chkOverbook;
26 private System.Windows.Forms.Button cmdCancel;
27 private System.Windows.Forms.CheckBox chkAppointments;
28 /// <summary>
29 /// Required designer variable.
30 /// </summary>
31 private System.ComponentModel.Container components = null;
32
33 public DResourceUser()
34 {
35 //
36 // Required for Windows Form Designer support
37 //
38 InitializeComponent();
39
40 //
41 // TODO: Add any constructor code after InitializeComponent call
42 //
43 }
44
45 /// <summary>
46 /// Clean up any resources being used.
47 /// </summary>
48 protected override void Dispose( bool disposing )
49 {
50 if( disposing )
51 {
52 if(components != null)
53 {
54 components.Dispose();
55 }
56 }
57 base.Dispose( disposing );
58 }
59
60 #region Windows Form Designer generated code
61 /// <summary>
62 /// Required method for Designer support - do not modify
63 /// the contents of this method with the code editor.
64 /// </summary>
65 private void InitializeComponent()
66 {
67 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DResourceUser));
68 this.cboScheduleUser = new System.Windows.Forms.ComboBox();
69 this.label1 = new System.Windows.Forms.Label();
70 this.pnlPageBottom = new System.Windows.Forms.Panel();
71 this.cmdCancel = new System.Windows.Forms.Button();
72 this.cmdOK = new System.Windows.Forms.Button();
73 this.pnlDescription = new System.Windows.Forms.Panel();
74 this.grpDescriptionResourceGroup = new System.Windows.Forms.GroupBox();
75 this.lblDescriptionResourceGroup = new System.Windows.Forms.Label();
76 this.chkModifySchedule = new System.Windows.Forms.CheckBox();
77 this.chkOverbook = new System.Windows.Forms.CheckBox();
78 this.chkAppointments = new System.Windows.Forms.CheckBox();
79 this.pnlPageBottom.SuspendLayout();
80 this.pnlDescription.SuspendLayout();
81 this.grpDescriptionResourceGroup.SuspendLayout();
82 this.SuspendLayout();
83 //
84 // cboScheduleUser
85 //
86 this.cboScheduleUser.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
87 this.cboScheduleUser.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
88 this.cboScheduleUser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
89 this.cboScheduleUser.Location = new System.Drawing.Point(144, 32);
90 this.cboScheduleUser.Name = "cboScheduleUser";
91 this.cboScheduleUser.Size = new System.Drawing.Size(248, 21);
92 this.cboScheduleUser.TabIndex = 0;
93 this.cboScheduleUser.SelectedIndexChanged += new System.EventHandler(this.cboScheduleUser_SelectedIndexChanged);
94 //
95 // label1
96 //
97 this.label1.Location = new System.Drawing.Point(16, 32);
98 this.label1.Name = "label1";
99 this.label1.Size = new System.Drawing.Size(120, 16);
100 this.label1.TabIndex = 1;
101 this.label1.Text = "Select Resource User:";
102 this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
103 //
104 // pnlPageBottom
105 //
106 this.pnlPageBottom.Controls.Add(this.cmdCancel);
107 this.pnlPageBottom.Controls.Add(this.cmdOK);
108 this.pnlPageBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
109 this.pnlPageBottom.Location = new System.Drawing.Point(0, 254);
110 this.pnlPageBottom.Name = "pnlPageBottom";
111 this.pnlPageBottom.Size = new System.Drawing.Size(448, 40);
112 this.pnlPageBottom.TabIndex = 4;
113 //
114 // cmdCancel
115 //
116 this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
117 this.cmdCancel.Location = new System.Drawing.Point(376, 8);
118 this.cmdCancel.Name = "cmdCancel";
119 this.cmdCancel.Size = new System.Drawing.Size(56, 24);
120 this.cmdCancel.TabIndex = 6;
121 this.cmdCancel.Text = "Cancel";
122 //
123 // cmdOK
124 //
125 this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK;
126 this.cmdOK.Location = new System.Drawing.Point(296, 8);
127 this.cmdOK.Name = "cmdOK";
128 this.cmdOK.Size = new System.Drawing.Size(64, 24);
129 this.cmdOK.TabIndex = 5;
130 this.cmdOK.Text = "OK";
131 this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
132 //
133 // pnlDescription
134 //
135 this.pnlDescription.Controls.Add(this.grpDescriptionResourceGroup);
136 this.pnlDescription.Dock = System.Windows.Forms.DockStyle.Bottom;
137 this.pnlDescription.Location = new System.Drawing.Point(0, 182);
138 this.pnlDescription.Name = "pnlDescription";
139 this.pnlDescription.Size = new System.Drawing.Size(448, 72);
140 this.pnlDescription.TabIndex = 5;
141 //
142 // grpDescriptionResourceGroup
143 //
144 this.grpDescriptionResourceGroup.Controls.Add(this.lblDescriptionResourceGroup);
145 this.grpDescriptionResourceGroup.Dock = System.Windows.Forms.DockStyle.Fill;
146 this.grpDescriptionResourceGroup.Location = new System.Drawing.Point(0, 0);
147 this.grpDescriptionResourceGroup.Name = "grpDescriptionResourceGroup";
148 this.grpDescriptionResourceGroup.Size = new System.Drawing.Size(448, 72);
149 this.grpDescriptionResourceGroup.TabIndex = 1;
150 this.grpDescriptionResourceGroup.TabStop = false;
151 this.grpDescriptionResourceGroup.Text = "Description";
152 //
153 // lblDescriptionResourceGroup
154 //
155 this.lblDescriptionResourceGroup.Dock = System.Windows.Forms.DockStyle.Fill;
156 this.lblDescriptionResourceGroup.Location = new System.Drawing.Point(3, 16);
157 this.lblDescriptionResourceGroup.Name = "lblDescriptionResourceGroup";
158 this.lblDescriptionResourceGroup.Size = new System.Drawing.Size(442, 53);
159 this.lblDescriptionResourceGroup.TabIndex = 0;
160 this.lblDescriptionResourceGroup.Text = resources.GetString("lblDescriptionResourceGroup.Text");
161 //
162 // chkModifySchedule
163 //
164 this.chkModifySchedule.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
165 this.chkModifySchedule.Location = new System.Drawing.Point(96, 136);
166 this.chkModifySchedule.Name = "chkModifySchedule";
167 this.chkModifySchedule.Size = new System.Drawing.Size(152, 16);
168 this.chkModifySchedule.TabIndex = 4;
169 this.chkModifySchedule.Text = "Modify Clinic Availability:";
170 this.chkModifySchedule.CheckedChanged += new System.EventHandler(this.chkModifySchedule_CheckedChanged);
171 //
172 // chkOverbook
173 //
174 this.chkOverbook.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
175 this.chkOverbook.Location = new System.Drawing.Point(160, 104);
176 this.chkOverbook.Name = "chkOverbook";
177 this.chkOverbook.Size = new System.Drawing.Size(88, 16);
178 this.chkOverbook.TabIndex = 3;
179 this.chkOverbook.Text = "Overbook:";
180 this.chkOverbook.CheckedChanged += new System.EventHandler(this.chkOverbook_CheckedChanged);
181 //
182 // chkAppointments
183 //
184 this.chkAppointments.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
185 this.chkAppointments.Location = new System.Drawing.Point(40, 72);
186 this.chkAppointments.Name = "chkAppointments";
187 this.chkAppointments.Size = new System.Drawing.Size(208, 16);
188 this.chkAppointments.TabIndex = 2;
189 this.chkAppointments.Text = "Add, Edit and Delete appointments:";
190 this.chkAppointments.CheckedChanged += new System.EventHandler(this.chkAppointments_CheckedChanged);
191 //
192 // DResourceUser
193 //
194 this.AcceptButton = this.cmdOK;
195 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
196 this.CancelButton = this.cmdCancel;
197 this.ClientSize = new System.Drawing.Size(448, 294);
198 this.Controls.Add(this.chkAppointments);
199 this.Controls.Add(this.chkOverbook);
200 this.Controls.Add(this.chkModifySchedule);
201 this.Controls.Add(this.pnlDescription);
202 this.Controls.Add(this.pnlPageBottom);
203 this.Controls.Add(this.label1);
204 this.Controls.Add(this.cboScheduleUser);
205 this.Name = "DResourceUser";
206 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
207 this.Text = "DResourceUser";
208 this.pnlPageBottom.ResumeLayout(false);
209 this.pnlDescription.ResumeLayout(false);
210 this.grpDescriptionResourceGroup.ResumeLayout(false);
211 this.ResumeLayout(false);
212
213 }
214 #endregion
215
216 #region Fields
217
218 private DataTable m_dtResourceUser;
219 private int m_nUserID;
220 private bool m_bModifySchedule;
221 private bool m_bOverbook;
222 private bool m_bAppointments;
223
224 #endregion Fields
225
226 #region Properties
227
228 /// <summary>
229 /// The ID of the Resource User in the NEW PERSON file.
230 /// </summary>
231 public int UserID
232 {
233 get
234 {
235 return m_nUserID;
236 }
237 }
238
239 /// <summary>
240 /// True if the user is allowed to modify the resource's scheduled availability
241 /// </summary>
242 public bool ModifySchedule
243 {
244 get
245 {
246 return m_bModifySchedule;
247 }
248 }
249
250 /// <summary>
251 /// True if the user is allowed to overbook beyond the resource's scheduled availability
252 /// </summary>
253 public bool Overbook
254 {
255 get
256 {
257 return m_bOverbook;
258 }
259 }
260
261 /// <summary>
262 /// True if the user is allowed to create, edit and delete appointments
263 /// </summary>
264 public bool Appoinmtments
265 {
266 get
267 {
268 return m_bAppointments;
269 }
270 }
271 #endregion Properties
272
273
274 public void InitializePage(int nSelectedRUID, DataSet dsGlobal)
275 {
276
277 m_dtResourceUser = dsGlobal.Tables["ResourceUser"];
278
279 //Datasource the SCHEDULE USER combo box
280 DataTable dtSchedUser = dsGlobal.Tables["ScheduleUser"];
281 DataView dvSchedUser = new DataView(dtSchedUser);
282 dvSchedUser.Sort = "USERNAME ASC";
283
284
285 cboScheduleUser.DataSource = dvSchedUser;
286 cboScheduleUser.DisplayMember = "USERNAME";
287 cboScheduleUser.ValueMember = "USERID";
288
289 if (nSelectedRUID < 0) //then we're in ADD mode
290 {
291 this.Text = "Add New Resource User";
292 m_nUserID = 0;
293 m_bModifySchedule = false;
294 m_bOverbook = false;
295 m_bAppointments = false;
296 this.cmdOK.Enabled = false;
297 }
298 else //we're in EDIT mode
299 {
300 this.Text = "Edit Scheduling Resource";
301 this.cboScheduleUser.Enabled = false;
302 DataRow dr = m_dtResourceUser.Rows.Find(nSelectedRUID);
303 m_nUserID = Convert.ToInt16(dr["USERID"]);//CHANGED FROM USERID1
304 string sOverbook = dr["OVERBOOK"].ToString();
305 m_bOverbook = (sOverbook == "YES")?true:false;
306 string sModify = dr["MODIFY_SCHEDULE"].ToString();
307 m_bModifySchedule = (sModify == "YES")?true:false;
308 string sAppts = dr["MODIFY_APPOINTMENTS"].ToString();
309 m_bAppointments = (sAppts == "YES")?true:false;
310
311 }
312 UpdateDialogData(true);
313 }
314
315 /// <summary>
316 /// If b is true, moves member vars into control data
317 /// otherwise, moves control data into member vars
318 /// </summary>
319 /// <param name="b"></param>
320 private void UpdateDialogData(bool b)
321 {
322 if (b == true)
323 {
324 this.chkOverbook.Checked = m_bOverbook;
325 this.chkModifySchedule.Checked = m_bModifySchedule;
326 this.cboScheduleUser.SelectedValue = m_nUserID;
327 this.chkAppointments.Checked = m_bAppointments;
328 }
329 else
330 {
331 m_bOverbook = this.chkOverbook.Checked;
332 m_bModifySchedule = this.chkModifySchedule.Checked;
333 m_bAppointments = this.chkAppointments.Checked;
334 m_nUserID = Convert.ToInt16(this.cboScheduleUser.SelectedValue);
335 }
336 }
337
338 private void cmdOK_Click(object sender, System.EventArgs e)
339 {
340 this.UpdateDialogData(false);
341 }
342
343 private void cboScheduleUser_SelectedIndexChanged(object sender, System.EventArgs e)
344 {
345 this.cmdOK.Enabled = true;
346 }
347
348 private void chkModifySchedule_CheckedChanged(object sender, System.EventArgs e)
349 {
350 if (chkModifySchedule.Checked == true)
351 {
352 this.chkAppointments.Checked = true;
353 this.chkOverbook.Checked = true;
354 }
355 }
356
357 private void chkOverbook_CheckedChanged(object sender, System.EventArgs e)
358 {
359 if (chkOverbook.Checked == true)
360 {
361 chkAppointments.Checked = true;
362 }
363 if (chkOverbook.Checked == false)
364 {
365 chkModifySchedule.Checked = false;
366 }
367 }
368
369 private void chkAppointments_CheckedChanged(object sender, System.EventArgs e)
370 {
371 if (chkAppointments.Checked == false)
372 {
373 chkOverbook.Checked = false;
374 chkModifySchedule.Checked = false;
375 }
376 }
377
378 }
379}
Note: See TracBrowser for help on using the repository browser.