source: Scheduling/trunk/cs/bsdx0200GUISourceCode/DAccessTemplate.cs@ 872

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

Initial committ of scheduling package

File size: 12.2 KB
RevLine 
[614]1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6
7namespace IndianHealthService.ClinicalScheduling
8{
9 /// <summary>
10 /// Summary description for DAccessTemplate.
11 /// </summary>
12 public class DAccessTemplate : System.Windows.Forms.Form
13 {
14 private System.Windows.Forms.Panel pnlPageBottom;
15 private System.Windows.Forms.Button cmdCancel;
16 private System.Windows.Forms.Button cmdOK;
17 private System.Windows.Forms.Panel pnlDescription;
18 private System.Windows.Forms.GroupBox grpDescriptionResourceGroup;
19 private System.Windows.Forms.Label lblDescriptionResourceGroup;
20 private System.Windows.Forms.Button cmdSelectTemplate;
21 private System.Windows.Forms.TextBox txtTemplate;
22 private System.Windows.Forms.DateTimePicker dtpStartDate;
23 private System.Windows.Forms.NumericUpDown udWeeksToApply;
24 private System.Windows.Forms.Label label1;
25 private System.Windows.Forms.Label label2;
26 /// <summary>
27 /// Required designer variable.
28 /// </summary>
29 private System.ComponentModel.Container components = null;
30
31
32 #region Methods
33
34 public void InitializePage()
35 {
36
37 UpdateDialogData(true);
38
39 }
40
41 /// <summary>
42 /// If b is true, moves member vars into control data
43 /// otherwise, moves control data into member vars
44 /// </summary>
45 /// <param name="b"></param>
46 private void UpdateDialogData(bool b)
47 {
48 if (b == true)
49 {
50 udWeeksToApply.Value = 1;
51 }
52 else
53 {
54 //
55 m_nWeeksToApply = (int) udWeeksToApply.Value;
56 m_dtStart = dtpStartDate.Value;
57 }
58 }
59
60 public DAccessTemplate()
61 {
62 InitializeComponent();
63 }
64
65 /// <summary>
66 /// Clean up any resources being used.
67 /// </summary>
68 protected override void Dispose( bool disposing )
69 {
70 if( disposing )
71 {
72 if(components != null)
73 {
74 components.Dispose();
75 }
76 }
77 base.Dispose( disposing );
78 }
79
80 private void cmdOK_Click(object sender, System.EventArgs e)
81 {
82 //assure that it's a monday in the future
83 DateTime dtStart = dtpStartDate.Value;
84 if ((dtStart.DayOfWeek != System.DayOfWeek.Monday) ||
85 (dtStart < DateTime.Today))
86 {
87 MessageBox.Show("Please select a future Monday.");
88 m_bCancelOK = true;
89 return;
90 }
91
92 if (m_bSelectedFile == false)
93 {
94 MessageBox.Show("Please select a valid template file.");
95 m_bCancelOK = true;
96 return;
97 }
98
99 if ((this.udWeeksToApply.Value > 52)||(this.udWeeksToApply.Value < 1))
100 {
101 MessageBox.Show("For the number of weeks to apply the template, please select a number between 1 and 52.");
102 m_bCancelOK = true;
103 return;
104 }
105 m_bCancelOK = false;
106
107 //Send the values from the controls to the fields
108 this.UpdateDialogData(false);
109
110 }
111
112 private void cmdSelectTemplate_Click(object sender, System.EventArgs e)
113 {
114 //Open the file dialog and pick a file
115 m_bSelectedFile = false;
116 OpenFileDialog openFileDialog1 = new OpenFileDialog();
117 string sPath = "";
118 sPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
119
120 openFileDialog1.InitialDirectory = "c:\\" ;
121 openFileDialog1.InitialDirectory = sPath ;
122 openFileDialog1.Filter = "Schedule Template Files (*.bsdxa)|*.bsdxa|All files (*.*)|*.*" ;
123 openFileDialog1.FilterIndex = 0 ;
124 openFileDialog1.RestoreDirectory = true ;
125
126 if(openFileDialog1.ShowDialog() == DialogResult.OK)
127 {
128 m_bSelectedFile = true;
129 m_ofDialog = openFileDialog1;
130 this.txtTemplate.Text = openFileDialog1.FileName;
131
132 }
133 }
134
135
136 #endregion Methods
137
138 #region Fields
139 private OpenFileDialog m_ofDialog;
140 private DateTime m_dtStart;
141 private int m_nWeeksToApply;
142 private bool m_bCancelOK = false;
143 private bool m_bSelectedFile = false;
144
145 #endregion Fields
146
147 #region Windows Form Designer generated code
148 /// <summary>
149 /// Required method for Designer support - do not modify
150 /// the contents of this method with the code editor.
151 /// </summary>
152 private void InitializeComponent()
153 {
154 this.pnlPageBottom = new System.Windows.Forms.Panel();
155 this.cmdCancel = new System.Windows.Forms.Button();
156 this.cmdOK = new System.Windows.Forms.Button();
157 this.pnlDescription = new System.Windows.Forms.Panel();
158 this.grpDescriptionResourceGroup = new System.Windows.Forms.GroupBox();
159 this.lblDescriptionResourceGroup = new System.Windows.Forms.Label();
160 this.cmdSelectTemplate = new System.Windows.Forms.Button();
161 this.txtTemplate = new System.Windows.Forms.TextBox();
162 this.dtpStartDate = new System.Windows.Forms.DateTimePicker();
163 this.udWeeksToApply = new System.Windows.Forms.NumericUpDown();
164 this.label1 = new System.Windows.Forms.Label();
165 this.label2 = new System.Windows.Forms.Label();
166 this.pnlPageBottom.SuspendLayout();
167 this.pnlDescription.SuspendLayout();
168 this.grpDescriptionResourceGroup.SuspendLayout();
169 ((System.ComponentModel.ISupportInitialize)(this.udWeeksToApply)).BeginInit();
170 this.SuspendLayout();
171 //
172 // pnlPageBottom
173 //
174 this.pnlPageBottom.Controls.Add(this.cmdCancel);
175 this.pnlPageBottom.Controls.Add(this.cmdOK);
176 this.pnlPageBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
177 this.pnlPageBottom.Location = new System.Drawing.Point(0, 264);
178 this.pnlPageBottom.Name = "pnlPageBottom";
179 this.pnlPageBottom.Size = new System.Drawing.Size(440, 40);
180 this.pnlPageBottom.TabIndex = 7;
181 //
182 // cmdCancel
183 //
184 this.cmdCancel.CausesValidation = false;
185 this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
186 this.cmdCancel.Location = new System.Drawing.Point(360, 8);
187 this.cmdCancel.Name = "cmdCancel";
188 this.cmdCancel.Size = new System.Drawing.Size(56, 24);
189 this.cmdCancel.TabIndex = 2;
190 this.cmdCancel.Text = "Cancel";
191 //
192 // cmdOK
193 //
194 this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK;
195 this.cmdOK.Location = new System.Drawing.Point(280, 8);
196 this.cmdOK.Name = "cmdOK";
197 this.cmdOK.Size = new System.Drawing.Size(64, 24);
198 this.cmdOK.TabIndex = 1;
199 this.cmdOK.Text = "OK";
200 this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
201 //
202 // pnlDescription
203 //
204 this.pnlDescription.Controls.Add(this.grpDescriptionResourceGroup);
205 this.pnlDescription.Dock = System.Windows.Forms.DockStyle.Bottom;
206 this.pnlDescription.Location = new System.Drawing.Point(0, 184);
207 this.pnlDescription.Name = "pnlDescription";
208 this.pnlDescription.Size = new System.Drawing.Size(440, 80);
209 this.pnlDescription.TabIndex = 8;
210 //
211 // grpDescriptionResourceGroup
212 //
213 this.grpDescriptionResourceGroup.Controls.Add(this.lblDescriptionResourceGroup);
214 this.grpDescriptionResourceGroup.Dock = System.Windows.Forms.DockStyle.Fill;
215 this.grpDescriptionResourceGroup.Location = new System.Drawing.Point(0, 0);
216 this.grpDescriptionResourceGroup.Name = "grpDescriptionResourceGroup";
217 this.grpDescriptionResourceGroup.Size = new System.Drawing.Size(440, 80);
218 this.grpDescriptionResourceGroup.TabIndex = 1;
219 this.grpDescriptionResourceGroup.TabStop = false;
220 this.grpDescriptionResourceGroup.Text = "Description";
221 //
222 // lblDescriptionResourceGroup
223 //
224 this.lblDescriptionResourceGroup.Dock = System.Windows.Forms.DockStyle.Fill;
225 this.lblDescriptionResourceGroup.Location = new System.Drawing.Point(3, 16);
226 this.lblDescriptionResourceGroup.Name = "lblDescriptionResourceGroup";
227 this.lblDescriptionResourceGroup.Size = new System.Drawing.Size(434, 61);
228 this.lblDescriptionResourceGroup.TabIndex = 0;
229 this.lblDescriptionResourceGroup.Text = "Use this panel to define an access pattern for future clinic availability.";
230 //
231 // cmdSelectTemplate
232 //
233 this.cmdSelectTemplate.Location = new System.Drawing.Point(24, 40);
234 this.cmdSelectTemplate.Name = "cmdSelectTemplate";
235 this.cmdSelectTemplate.Size = new System.Drawing.Size(136, 32);
236 this.cmdSelectTemplate.TabIndex = 9;
237 this.cmdSelectTemplate.Text = "Select Access Template";
238 this.cmdSelectTemplate.Click += new System.EventHandler(this.cmdSelectTemplate_Click);
239 //
240 // txtTemplate
241 //
242 this.txtTemplate.Location = new System.Drawing.Point(176, 32);
243 this.txtTemplate.Multiline = true;
244 this.txtTemplate.Name = "txtTemplate";
245 this.txtTemplate.ReadOnly = true;
246 this.txtTemplate.Size = new System.Drawing.Size(248, 48);
247 this.txtTemplate.TabIndex = 10;
248 this.txtTemplate.Text = "";
249 //
250 // dtpStartDate
251 //
252 this.dtpStartDate.AllowDrop = true;
253 this.dtpStartDate.Checked = false;
254 this.dtpStartDate.Location = new System.Drawing.Point(176, 104);
255 this.dtpStartDate.Name = "dtpStartDate";
256 this.dtpStartDate.Size = new System.Drawing.Size(184, 20);
257 this.dtpStartDate.TabIndex = 11;
258 //
259 // udWeeksToApply
260 //
261 this.udWeeksToApply.Location = new System.Drawing.Point(176, 144);
262 this.udWeeksToApply.Maximum = new System.Decimal(new int[] {
263 52,
264 0,
265 0,
266 0});
267 this.udWeeksToApply.Minimum = new System.Decimal(new int[] {
268 1,
269 0,
270 0,
271 0});
272 this.udWeeksToApply.Name = "udWeeksToApply";
273 this.udWeeksToApply.Size = new System.Drawing.Size(96, 20);
274 this.udWeeksToApply.TabIndex = 12;
275 this.udWeeksToApply.Value = new System.Decimal(new int[] {
276 1,
277 0,
278 0,
279 0});
280 //
281 // label1
282 //
283 this.label1.Location = new System.Drawing.Point(16, 104);
284 this.label1.Name = "label1";
285 this.label1.Size = new System.Drawing.Size(152, 16);
286 this.label1.TabIndex = 13;
287 this.label1.Text = "Starting Week (Monday):";
288 this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
289 //
290 // label2
291 //
292 this.label2.Location = new System.Drawing.Point(16, 144);
293 this.label2.Name = "label2";
294 this.label2.Size = new System.Drawing.Size(152, 16);
295 this.label2.TabIndex = 13;
296 this.label2.Text = "Number of Weeks to Apply:";
297 this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
298 //
299 // DAccessTemplate
300 //
301 this.AcceptButton = this.cmdOK;
302 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
303 this.CancelButton = this.cmdCancel;
304 this.ClientSize = new System.Drawing.Size(440, 304);
305 this.Controls.Add(this.label1);
306 this.Controls.Add(this.udWeeksToApply);
307 this.Controls.Add(this.dtpStartDate);
308 this.Controls.Add(this.txtTemplate);
309 this.Controls.Add(this.cmdSelectTemplate);
310 this.Controls.Add(this.pnlDescription);
311 this.Controls.Add(this.pnlPageBottom);
312 this.Controls.Add(this.label2);
313 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
314 this.Name = "DAccessTemplate";
315 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
316 this.Text = "Apply Access Template";
317 this.Closing += new System.ComponentModel.CancelEventHandler(this.DAccessTemplate_Closing);
318 this.pnlPageBottom.ResumeLayout(false);
319 this.pnlDescription.ResumeLayout(false);
320 this.grpDescriptionResourceGroup.ResumeLayout(false);
321 ((System.ComponentModel.ISupportInitialize)(this.udWeeksToApply)).EndInit();
322 this.ResumeLayout(false);
323
324 }
325 #endregion
326
327
328 private void DAccessTemplate_Closing(object sender, System.ComponentModel.CancelEventArgs e)
329 {
330 if (m_bCancelOK == true)
331 {
332 e.Cancel = true;
333 m_bCancelOK = false;
334 }
335 else
336 {
337 e.Cancel = false;
338 }
339 }
340
341
342 #region Properties
343
344
345 /// <summary>
346 /// Returns the open file dialog object
347 /// </summary>
348 public OpenFileDialog FileDialog
349 {
350 get
351 {
352 return m_ofDialog;
353 }
354 }
355
356 /// <summary>
357 /// Sets or returns the start date to apply the template
358 /// </summary>
359 public DateTime StartDate
360 {
361 get
362 {
363 return m_dtStart;
364 }
365 set
366 {
367 m_dtStart = value;
368 }
369 }
370
371 /// <summary>
372 /// Sets or returns the number of weeks to apply the template
373 /// </summary>
374 public int WeeksToApply
375 {
376 get
377 {
378 return m_nWeeksToApply;
379 }
380 set
381 {
382 m_nWeeksToApply = value;
383 }
384 }
385 #endregion Properties
386
387
388
389
390
391 }
392}
Note: See TracBrowser for help on using the repository browser.