Edit frmPrescription.cs to add functionality to search button

This commit is contained in:
Noah 2024-02-16 11:34:28 -05:00
parent b594f2ab7f
commit fddacfe6d4
3 changed files with 157 additions and 25 deletions

View File

@ -38,21 +38,31 @@ namespace Louis__Pharmacy_CNSA212_FP
this.lblLastName = new System.Windows.Forms.Label(); this.lblLastName = new System.Windows.Forms.Label();
this.lblRxNumber = new System.Windows.Forms.Label(); this.lblRxNumber = new System.Windows.Forms.Label();
this.lblFirstName = new System.Windows.Forms.Label(); this.lblFirstName = new System.Windows.Forms.Label();
this.txtRxNumber = new System.Windows.Forms.TextBox(); this.txtPatientRx = new System.Windows.Forms.TextBox();
this.txtLastName = new System.Windows.Forms.TextBox(); this.txtPatientLast = new System.Windows.Forms.TextBox();
this.txtFirstName = new System.Windows.Forms.TextBox(); this.txtPatientFirst = new System.Windows.Forms.TextBox();
this.ep1 = new System.Windows.Forms.ErrorProvider(this.components);
this.cmuPrescriptionEdit = new System.Windows.Forms.ToolStripMenuItem();
this.cmuPrescriptionDelete = new System.Windows.Forms.ToolStripMenuItem();
this.cmuPrescriptionAdd = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvPrescriptions)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvPrescriptions)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout(); this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.ep1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// contextMenuStrip1 // contextMenuStrip1
// //
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cmuPrescriptionAdd,
this.cmuPrescriptionEdit,
this.cmuPrescriptionDelete});
this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4); this.contextMenuStrip1.Size = new System.Drawing.Size(123, 76);
// //
// dgvPrescriptions // dgvPrescriptions
// //
@ -76,9 +86,9 @@ namespace Louis__Pharmacy_CNSA212_FP
this.splitContainer1.Panel1.Controls.Add(this.lblLastName); this.splitContainer1.Panel1.Controls.Add(this.lblLastName);
this.splitContainer1.Panel1.Controls.Add(this.lblRxNumber); this.splitContainer1.Panel1.Controls.Add(this.lblRxNumber);
this.splitContainer1.Panel1.Controls.Add(this.lblFirstName); this.splitContainer1.Panel1.Controls.Add(this.lblFirstName);
this.splitContainer1.Panel1.Controls.Add(this.txtRxNumber); this.splitContainer1.Panel1.Controls.Add(this.txtPatientRx);
this.splitContainer1.Panel1.Controls.Add(this.txtLastName); this.splitContainer1.Panel1.Controls.Add(this.txtPatientLast);
this.splitContainer1.Panel1.Controls.Add(this.txtFirstName); this.splitContainer1.Panel1.Controls.Add(this.txtPatientFirst);
// //
// splitContainer1.Panel2 // splitContainer1.Panel2
// //
@ -123,26 +133,48 @@ namespace Louis__Pharmacy_CNSA212_FP
this.lblFirstName.Text = "First Name:"; this.lblFirstName.Text = "First Name:";
this.lblFirstName.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.lblFirstName.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
// //
// txtRxNumber // txtPatientRx
// //
this.txtRxNumber.Location = new System.Drawing.Point(122, 154); this.txtPatientRx.Location = new System.Drawing.Point(122, 154);
this.txtRxNumber.Name = "txtRxNumber"; this.txtPatientRx.Name = "txtPatientRx";
this.txtRxNumber.Size = new System.Drawing.Size(148, 22); this.txtPatientRx.Size = new System.Drawing.Size(148, 22);
this.txtRxNumber.TabIndex = 2; this.txtPatientRx.TabIndex = 2;
// //
// txtLastName // txtPatientLast
// //
this.txtLastName.Location = new System.Drawing.Point(122, 101); this.txtPatientLast.Location = new System.Drawing.Point(122, 101);
this.txtLastName.Name = "txtLastName"; this.txtPatientLast.Name = "txtPatientLast";
this.txtLastName.Size = new System.Drawing.Size(148, 22); this.txtPatientLast.Size = new System.Drawing.Size(148, 22);
this.txtLastName.TabIndex = 1; this.txtPatientLast.TabIndex = 1;
// //
// txtFirstName // txtPatientFirst
// //
this.txtFirstName.Location = new System.Drawing.Point(122, 56); this.txtPatientFirst.Location = new System.Drawing.Point(122, 56);
this.txtFirstName.Name = "txtFirstName"; this.txtPatientFirst.Name = "txtPatientFirst";
this.txtFirstName.Size = new System.Drawing.Size(148, 22); this.txtPatientFirst.Size = new System.Drawing.Size(148, 22);
this.txtFirstName.TabIndex = 0; this.txtPatientFirst.TabIndex = 0;
//
// ep1
//
this.ep1.ContainerControl = this;
//
// cmuPrescriptionEdit
//
this.cmuPrescriptionEdit.Name = "cmuPrescriptionEdit";
this.cmuPrescriptionEdit.Size = new System.Drawing.Size(122, 24);
this.cmuPrescriptionEdit.Text = "Edit";
//
// cmuPrescriptionDelete
//
this.cmuPrescriptionDelete.Name = "cmuPrescriptionDelete";
this.cmuPrescriptionDelete.Size = new System.Drawing.Size(122, 24);
this.cmuPrescriptionDelete.Text = "Delete";
//
// cmuPrescriptionAdd
//
this.cmuPrescriptionAdd.Name = "cmuPrescriptionAdd";
this.cmuPrescriptionAdd.Size = new System.Drawing.Size(122, 24);
this.cmuPrescriptionAdd.Text = "Add";
// //
// frmPrescription // frmPrescription
// //
@ -154,12 +186,14 @@ namespace Louis__Pharmacy_CNSA212_FP
this.Name = "frmPrescription"; this.Name = "frmPrescription";
this.Text = "Louis\' Pharmacy - Add / Update Prescription"; this.Text = "Louis\' Pharmacy - Add / Update Prescription";
this.Load += new System.EventHandler(this.frmPrescription_Load); this.Load += new System.EventHandler(this.frmPrescription_Load);
this.contextMenuStrip1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvPrescriptions)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvPrescriptions)).EndInit();
this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout(); this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false); this.splitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.ep1)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -168,12 +202,16 @@ namespace Louis__Pharmacy_CNSA212_FP
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.DataGridView dgvPrescriptions; private System.Windows.Forms.DataGridView dgvPrescriptions;
private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.TextBox txtFirstName; private System.Windows.Forms.TextBox txtPatientFirst;
private System.Windows.Forms.TextBox txtRxNumber; private System.Windows.Forms.TextBox txtPatientRx;
private System.Windows.Forms.TextBox txtLastName; private System.Windows.Forms.TextBox txtPatientLast;
private System.Windows.Forms.Label lblFirstName; private System.Windows.Forms.Label lblFirstName;
private System.Windows.Forms.Label lblLastName; private System.Windows.Forms.Label lblLastName;
private System.Windows.Forms.Label lblRxNumber; private System.Windows.Forms.Label lblRxNumber;
private System.Windows.Forms.Button btnSearch; private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.ErrorProvider ep1;
private System.Windows.Forms.ToolStripMenuItem cmuPrescriptionEdit;
private System.Windows.Forms.ToolStripMenuItem cmuPrescriptionDelete;
private System.Windows.Forms.ToolStripMenuItem cmuPrescriptionAdd;
} }
} }

View File

@ -19,6 +19,92 @@ namespace Louis__Pharmacy_CNSA212_FP
private void btnPatientSearch_Click(object sender, EventArgs e) private void btnPatientSearch_Click(object sender, EventArgs e)
{ {
string fname = "";
string lname = "";
string id = "";
DataSet ds = new DataSet();
if (txtPatientFirst.Text.Length + txtPatientLast.Text.Length + txtPatientRx.Text.Length > 0)
{
try
{
fname = txtPatientFirst.Text;
try
{
lname = txtPatientLast.Text;
try
{
id = txtPatientRx.Text;
try
{
ds = PharmacyDataTier.PatientInfoSearch(id, lname, fname);
if (ds.Tables[0].Rows.Count > 0) // There is a record.
{
dgvPrescriptions.Visible = true;
// Get data source.
dgvPrescriptions.DataSource = ds.Tables[0];
dgvPrescriptions.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
// Set the row and column header styles.
dgvPrescriptions.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
dgvPrescriptions.ColumnHeadersDefaultCellStyle.BackColor = Color.Green;
}
else
{
dgvPrescriptions.Visible = false; // Hide the DataGridView if no results are found.
MessageBox.Show("No records found.");
}
}
catch (Exception exception)
{
ep1.SetError(btnSearch, "Error Searching");
}
}
catch (Exception exception)
{
ep1.SetError(txtPatientRx, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPatientLast, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPatientFirst, "Invalid Value");
}
}
cmuPrescriptionEdit.Enabled = dgvPrescriptions.Rows.Count > 0;
cmuPrescriptionDelete.Enabled = dgvPrescriptions.Rows.Count > 0;
} }
@ -56,5 +142,10 @@ namespace Louis__Pharmacy_CNSA212_FP
} }
} }
private void addToolStripMenuItem_Click(object sender, EventArgs e)
{
}
} }
} }

View File

@ -120,6 +120,9 @@
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="ep1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>242, 16</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>65</value> <value>65</value>
</metadata> </metadata>