Edit frmPrescription.cs to add functionality to search button
This commit is contained in:
parent
b594f2ab7f
commit
fddacfe6d4
@ -38,21 +38,31 @@ namespace Louis__Pharmacy_CNSA212_FP
|
||||
this.lblLastName = new System.Windows.Forms.Label();
|
||||
this.lblRxNumber = new System.Windows.Forms.Label();
|
||||
this.lblFirstName = new System.Windows.Forms.Label();
|
||||
this.txtRxNumber = new System.Windows.Forms.TextBox();
|
||||
this.txtLastName = new System.Windows.Forms.TextBox();
|
||||
this.txtFirstName = new System.Windows.Forms.TextBox();
|
||||
this.txtPatientRx = new System.Windows.Forms.TextBox();
|
||||
this.txtPatientLast = 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.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ep1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// contextMenuStrip1
|
||||
//
|
||||
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.Size = new System.Drawing.Size(61, 4);
|
||||
this.contextMenuStrip1.Size = new System.Drawing.Size(123, 76);
|
||||
//
|
||||
// dgvPrescriptions
|
||||
//
|
||||
@ -76,9 +86,9 @@ namespace Louis__Pharmacy_CNSA212_FP
|
||||
this.splitContainer1.Panel1.Controls.Add(this.lblLastName);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.lblRxNumber);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.lblFirstName);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.txtRxNumber);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.txtLastName);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.txtFirstName);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.txtPatientRx);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.txtPatientLast);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.txtPatientFirst);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
@ -123,26 +133,48 @@ namespace Louis__Pharmacy_CNSA212_FP
|
||||
this.lblFirstName.Text = "First Name:";
|
||||
this.lblFirstName.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// txtRxNumber
|
||||
// txtPatientRx
|
||||
//
|
||||
this.txtRxNumber.Location = new System.Drawing.Point(122, 154);
|
||||
this.txtRxNumber.Name = "txtRxNumber";
|
||||
this.txtRxNumber.Size = new System.Drawing.Size(148, 22);
|
||||
this.txtRxNumber.TabIndex = 2;
|
||||
this.txtPatientRx.Location = new System.Drawing.Point(122, 154);
|
||||
this.txtPatientRx.Name = "txtPatientRx";
|
||||
this.txtPatientRx.Size = new System.Drawing.Size(148, 22);
|
||||
this.txtPatientRx.TabIndex = 2;
|
||||
//
|
||||
// txtLastName
|
||||
// txtPatientLast
|
||||
//
|
||||
this.txtLastName.Location = new System.Drawing.Point(122, 101);
|
||||
this.txtLastName.Name = "txtLastName";
|
||||
this.txtLastName.Size = new System.Drawing.Size(148, 22);
|
||||
this.txtLastName.TabIndex = 1;
|
||||
this.txtPatientLast.Location = new System.Drawing.Point(122, 101);
|
||||
this.txtPatientLast.Name = "txtPatientLast";
|
||||
this.txtPatientLast.Size = new System.Drawing.Size(148, 22);
|
||||
this.txtPatientLast.TabIndex = 1;
|
||||
//
|
||||
// txtFirstName
|
||||
// txtPatientFirst
|
||||
//
|
||||
this.txtFirstName.Location = new System.Drawing.Point(122, 56);
|
||||
this.txtFirstName.Name = "txtFirstName";
|
||||
this.txtFirstName.Size = new System.Drawing.Size(148, 22);
|
||||
this.txtFirstName.TabIndex = 0;
|
||||
this.txtPatientFirst.Location = new System.Drawing.Point(122, 56);
|
||||
this.txtPatientFirst.Name = "txtPatientFirst";
|
||||
this.txtPatientFirst.Size = new System.Drawing.Size(148, 22);
|
||||
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
|
||||
//
|
||||
@ -154,12 +186,14 @@ namespace Louis__Pharmacy_CNSA212_FP
|
||||
this.Name = "frmPrescription";
|
||||
this.Text = "Louis\' Pharmacy - Add / Update Prescription";
|
||||
this.Load += new System.EventHandler(this.frmPrescription_Load);
|
||||
this.contextMenuStrip1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvPrescriptions)).EndInit();
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel1.PerformLayout();
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.ep1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -168,12 +202,16 @@ namespace Louis__Pharmacy_CNSA212_FP
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||
private System.Windows.Forms.DataGridView dgvPrescriptions;
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.TextBox txtFirstName;
|
||||
private System.Windows.Forms.TextBox txtRxNumber;
|
||||
private System.Windows.Forms.TextBox txtLastName;
|
||||
private System.Windows.Forms.TextBox txtPatientFirst;
|
||||
private System.Windows.Forms.TextBox txtPatientRx;
|
||||
private System.Windows.Forms.TextBox txtPatientLast;
|
||||
private System.Windows.Forms.Label lblFirstName;
|
||||
private System.Windows.Forms.Label lblLastName;
|
||||
private System.Windows.Forms.Label lblRxNumber;
|
||||
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;
|
||||
}
|
||||
}
|
@ -19,6 +19,92 @@ namespace Louis__Pharmacy_CNSA212_FP
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,9 @@
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</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">
|
||||
<value>65</value>
|
||||
</metadata>
|
||||
|
Loading…
Reference in New Issue
Block a user