From 07b4f044b39947736bb55521dfe284faead9bf00 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 30 Aug 2010 18:51:30 +0000 Subject: [PATCH] Changes in handling of Divisions. Now prompts if more than one division assigned to user. --- .../BMX2/BMXNet/BMXNetConnectInfo.cs | 30 ++- cs/bmx_0200scr/BMX2/BMXNet/DSelectDivision.cs | 233 ++++++++++-------- .../BMX2/BMXNet/DSelectDivision.resx | 171 +++---------- 3 files changed, 176 insertions(+), 258 deletions(-) diff --git a/cs/bmx_0200scr/BMX2/BMXNet/BMXNetConnectInfo.cs b/cs/bmx_0200scr/BMX2/BMXNet/BMXNetConnectInfo.cs index 8babfd6..8854c54 100644 --- a/cs/bmx_0200scr/BMX2/BMXNet/BMXNetConnectInfo.cs +++ b/cs/bmx_0200scr/BMX2/BMXNet/BMXNetConnectInfo.cs @@ -971,17 +971,23 @@ namespace IndianHealthService.BMXNet rsDivisions = this.GetUserDivisions(); m_nDivisionCount = rsDivisions.Rows.Count; - //The MOST_RECENT_LOOKUP field contains DUZ(2) - foreach (System.Data.DataRow r in rsDivisions.Rows) - { - string sTemp = r["MOST_RECENT_LOOKUP"].ToString(); - if ((sTemp == "1") || (rsDivisions.Rows.Count == 1)) - { - this.m_sDivision = r["FACILITY_NAME"].ToString(); - this.m_sDUZ2 = r["FACILITY_IEN"].ToString(); - break; - } - } + // Must have at least one division in order for our code to work + // If user has no divisions, M routine will invent one for our sake (get it from kernel). + // + Debug.Assert(m_nDivisionCount > 0, "Must get at least one division from VISTA"); + + // if more than one division, have user pick + // if just one, get the DUZ(2) and then set it via the property DUZ2. + + if (m_nDivisionCount > 1) + { + ChangeDivision(null); + // following true if user cancelled. + if (DUZ2 == null) throw new BMXNetException("No division chosen -- can't log in"); + } + // if just one + else DUZ2 = m_sDUZ2 = rsDivisions.Rows[0]["FACILITY_IEN"].ToString(); + } catch(Exception bmxEx) { @@ -1010,7 +1016,7 @@ namespace IndianHealthService.BMXNet public void ChangeDivision(System.Windows.Forms.Form frmCaller) { DSelectDivision dsd = new DSelectDivision(); - dsd.InitializePage(UserDivisions, DUZ2); + dsd.InitializePage(UserDivisions); if (dsd.ShowDialog(frmCaller) == DialogResult.Cancel) return; diff --git a/cs/bmx_0200scr/BMX2/BMXNet/DSelectDivision.cs b/cs/bmx_0200scr/BMX2/BMXNet/DSelectDivision.cs index 5aa162e..7967f3b 100644 --- a/cs/bmx_0200scr/BMX2/BMXNet/DSelectDivision.cs +++ b/cs/bmx_0200scr/BMX2/BMXNet/DSelectDivision.cs @@ -29,108 +29,109 @@ namespace IndianHealthService.BMXNet /// private void InitializeComponent() { - this.pnlPageBottom = new System.Windows.Forms.Panel(); - this.cmdCancel = new System.Windows.Forms.Button(); - this.cmdOK = new System.Windows.Forms.Button(); - this.pnlDescription = new System.Windows.Forms.Panel(); - this.grpDescriptionResourceGroup = new System.Windows.Forms.GroupBox(); - this.lblDescriptionResourceGroup = new System.Windows.Forms.Label(); - this.lstDivision = new System.Windows.Forms.ListBox(); - this.label1 = new System.Windows.Forms.Label(); - this.pnlPageBottom.SuspendLayout(); - this.pnlDescription.SuspendLayout(); - this.grpDescriptionResourceGroup.SuspendLayout(); - this.SuspendLayout(); - // - // pnlPageBottom - // - this.pnlPageBottom.Controls.Add(this.cmdCancel); - this.pnlPageBottom.Controls.Add(this.cmdOK); - this.pnlPageBottom.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlPageBottom.Location = new System.Drawing.Point(0, 262); - this.pnlPageBottom.Name = "pnlPageBottom"; - this.pnlPageBottom.Size = new System.Drawing.Size(456, 40); - this.pnlPageBottom.TabIndex = 7; - // - // cmdCancel - // - this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cmdCancel.Location = new System.Drawing.Point(376, 8); - this.cmdCancel.Name = "cmdCancel"; - this.cmdCancel.Size = new System.Drawing.Size(56, 24); - this.cmdCancel.TabIndex = 4; - this.cmdCancel.Text = "Cancel"; - // - // cmdOK - // - this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.cmdOK.Location = new System.Drawing.Point(296, 8); - this.cmdOK.Name = "cmdOK"; - this.cmdOK.Size = new System.Drawing.Size(64, 24); - this.cmdOK.TabIndex = 3; - this.cmdOK.Text = "OK"; - this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click); - // - // pnlDescription - // - this.pnlDescription.Controls.Add(this.grpDescriptionResourceGroup); - this.pnlDescription.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlDescription.Location = new System.Drawing.Point(0, 190); - this.pnlDescription.Name = "pnlDescription"; - this.pnlDescription.Size = new System.Drawing.Size(456, 72); - this.pnlDescription.TabIndex = 8; - // - // grpDescriptionResourceGroup - // - this.grpDescriptionResourceGroup.Controls.Add(this.lblDescriptionResourceGroup); - this.grpDescriptionResourceGroup.Dock = System.Windows.Forms.DockStyle.Fill; - this.grpDescriptionResourceGroup.Location = new System.Drawing.Point(0, 0); - this.grpDescriptionResourceGroup.Name = "grpDescriptionResourceGroup"; - this.grpDescriptionResourceGroup.Size = new System.Drawing.Size(456, 72); - this.grpDescriptionResourceGroup.TabIndex = 1; - this.grpDescriptionResourceGroup.TabStop = false; - this.grpDescriptionResourceGroup.Text = "Description"; - // - // lblDescriptionResourceGroup - // - this.lblDescriptionResourceGroup.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblDescriptionResourceGroup.Location = new System.Drawing.Point(3, 16); - this.lblDescriptionResourceGroup.Name = "lblDescriptionResourceGroup"; - this.lblDescriptionResourceGroup.Size = new System.Drawing.Size(450, 53); - this.lblDescriptionResourceGroup.TabIndex = 0; - this.lblDescriptionResourceGroup.Text = "Use this panel to select the Division."; - // - // lstDivision - // - this.lstDivision.Location = new System.Drawing.Point(40, 48); - this.lstDivision.Name = "lstDivision"; - this.lstDivision.Size = new System.Drawing.Size(384, 121); - this.lstDivision.TabIndex = 9; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(40, 24); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(240, 16); - this.label1.TabIndex = 10; - this.label1.Text = "Select Division:"; - // - // DSelectDivision - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(456, 302); - this.Controls.Add(this.label1); - this.Controls.Add(this.lstDivision); - this.Controls.Add(this.pnlDescription); - this.Controls.Add(this.pnlPageBottom); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Name = "DSelectDivision"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Select Division"; - this.pnlPageBottom.ResumeLayout(false); - this.pnlDescription.ResumeLayout(false); - this.grpDescriptionResourceGroup.ResumeLayout(false); - this.ResumeLayout(false); + this.pnlPageBottom = new System.Windows.Forms.Panel(); + this.cmdCancel = new System.Windows.Forms.Button(); + this.cmdOK = new System.Windows.Forms.Button(); + this.pnlDescription = new System.Windows.Forms.Panel(); + this.grpDescriptionResourceGroup = new System.Windows.Forms.GroupBox(); + this.lblDescriptionResourceGroup = new System.Windows.Forms.Label(); + this.lstDivision = new System.Windows.Forms.ListBox(); + this.label1 = new System.Windows.Forms.Label(); + this.pnlPageBottom.SuspendLayout(); + this.pnlDescription.SuspendLayout(); + this.grpDescriptionResourceGroup.SuspendLayout(); + this.SuspendLayout(); + // + // pnlPageBottom + // + this.pnlPageBottom.Controls.Add(this.cmdCancel); + this.pnlPageBottom.Controls.Add(this.cmdOK); + this.pnlPageBottom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlPageBottom.Location = new System.Drawing.Point(0, 262); + this.pnlPageBottom.Name = "pnlPageBottom"; + this.pnlPageBottom.Size = new System.Drawing.Size(456, 40); + this.pnlPageBottom.TabIndex = 7; + // + // cmdCancel + // + this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cmdCancel.Location = new System.Drawing.Point(376, 8); + this.cmdCancel.Name = "cmdCancel"; + this.cmdCancel.Size = new System.Drawing.Size(56, 24); + this.cmdCancel.TabIndex = 4; + this.cmdCancel.Text = "Cancel"; + // + // cmdOK + // + this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.cmdOK.Location = new System.Drawing.Point(296, 8); + this.cmdOK.Name = "cmdOK"; + this.cmdOK.Size = new System.Drawing.Size(64, 24); + this.cmdOK.TabIndex = 3; + this.cmdOK.Text = "OK"; + this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click); + // + // pnlDescription + // + this.pnlDescription.Controls.Add(this.grpDescriptionResourceGroup); + this.pnlDescription.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlDescription.Location = new System.Drawing.Point(0, 190); + this.pnlDescription.Name = "pnlDescription"; + this.pnlDescription.Size = new System.Drawing.Size(456, 72); + this.pnlDescription.TabIndex = 8; + // + // grpDescriptionResourceGroup + // + this.grpDescriptionResourceGroup.Controls.Add(this.lblDescriptionResourceGroup); + this.grpDescriptionResourceGroup.Dock = System.Windows.Forms.DockStyle.Fill; + this.grpDescriptionResourceGroup.Location = new System.Drawing.Point(0, 0); + this.grpDescriptionResourceGroup.Name = "grpDescriptionResourceGroup"; + this.grpDescriptionResourceGroup.Size = new System.Drawing.Size(456, 72); + this.grpDescriptionResourceGroup.TabIndex = 1; + this.grpDescriptionResourceGroup.TabStop = false; + this.grpDescriptionResourceGroup.Text = "Description"; + // + // lblDescriptionResourceGroup + // + this.lblDescriptionResourceGroup.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblDescriptionResourceGroup.Location = new System.Drawing.Point(3, 16); + this.lblDescriptionResourceGroup.Name = "lblDescriptionResourceGroup"; + this.lblDescriptionResourceGroup.Size = new System.Drawing.Size(450, 53); + this.lblDescriptionResourceGroup.TabIndex = 0; + this.lblDescriptionResourceGroup.Text = "Use this panel to select the Division."; + // + // lstDivision + // + this.lstDivision.Location = new System.Drawing.Point(40, 48); + this.lstDivision.Name = "lstDivision"; + this.lstDivision.Size = new System.Drawing.Size(384, 121); + this.lstDivision.TabIndex = 9; + this.lstDivision.DoubleClick += new System.EventHandler(this.lstDivision_DoubleClick); + // + // label1 + // + this.label1.Location = new System.Drawing.Point(40, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(240, 16); + this.label1.TabIndex = 10; + this.label1.Text = "Select Division:"; + // + // DSelectDivision + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(456, 302); + this.Controls.Add(this.label1); + this.Controls.Add(this.lstDivision); + this.Controls.Add(this.pnlDescription); + this.Controls.Add(this.pnlPageBottom); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "DSelectDivision"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Select Division"; + this.pnlPageBottom.ResumeLayout(false); + this.pnlDescription.ResumeLayout(false); + this.grpDescriptionResourceGroup.ResumeLayout(false); + this.ResumeLayout(false); } #endregion @@ -164,10 +165,9 @@ namespace IndianHealthService.BMXNet #region Methods - public void InitializePage(DataTable dtDivisions, string sDUZ2) + public void InitializePage(DataTable dtDivisions) { m_dtDivisions = dtDivisions; - m_sDUZ2 = sDUZ2; UpdateDialogData(true); } @@ -180,10 +180,11 @@ namespace IndianHealthService.BMXNet { if (b == true) //move member vars into controls { - this.lstDivision.DataSource = m_dtDivisions; + m_dtDivisions.DefaultView.Sort="DEFAULT ASC"; + this.lstDivision.DataSource = m_dtDivisions.DefaultView; lstDivision.DisplayMember = "FACILITY_NAME"; lstDivision.ValueMember = "FACILITY_IEN"; - lstDivision.SelectedValue = m_sDUZ2; + lstDivision.SelectedIndex = m_dtDivisions.DefaultView.Find(1); } else //move control data into member vars { @@ -216,8 +217,28 @@ namespace IndianHealthService.BMXNet private void cmdOK_Click(object sender, System.EventArgs e) { + if (lstDivision.SelectedIndex < 0) { + this.lblDescriptionResourceGroup.Text="Must select a division"; + this.lblDescriptionResourceGroup.ForeColor = Color.Red; + this.DialogResult = DialogResult.None; //forestall acceptance. + return; + } this.UpdateDialogData(false); return; } + + private void lstDivision_DoubleClick(object sender, EventArgs e) + { + if (lstDivision.SelectedIndex < 0) { + this.lblDescriptionResourceGroup.Text = "Must select a division"; + this.lblDescriptionResourceGroup.ForeColor = Color.Red; + return; + } + this.UpdateDialogData(false); + this.DialogResult = DialogResult.OK; + return; + } + + } } diff --git a/cs/bmx_0200scr/BMX2/BMXNet/DSelectDivision.resx b/cs/bmx_0200scr/BMX2/BMXNet/DSelectDivision.resx index afac8ac..c7e0d4b 100644 --- a/cs/bmx_0200scr/BMX2/BMXNet/DSelectDivision.resx +++ b/cs/bmx_0200scr/BMX2/BMXNet/DSelectDivision.resx @@ -3,7 +3,7 @@ + + + + + + + + + + + + + + + + + + - + + @@ -89,141 +109,12 @@ text/microsoft-resx - 1.3 + 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - False - - - True - - - Private - - - 8, 8 - - - False - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - True - - - Private - - - 8, 8 - - - True - - - Private - - - Private - - - 8, 8 - - - True - - - False - - - True - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - False - - - (Default) - - - False - - - False - - - 8, 8 - - - True - - - 80 - - - True - - - Private - - - DSelectDivision - \ No newline at end of file