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

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

CGAVDocument contains changes for start day of grid based on weekday locale and colummns
CGAVView: Shortcut keys; correct updating when number of columns is changed in grid
CGDocument: changes for start day of grid. Modified algorithm.
DAccessTemplate: Takes any weekday now for applying a template, not just Monday. Then calculation of start day is done in CGAVView based on locale in the same algorithm that the rest of the GUI uses.
DAppointPage: Now says Mobile/Cell instead of Cell Phone.

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