Reapply "worked on search form"

This reverts commit cbef2d4b74.
This commit is contained in:
Adam McCane 2024-02-15 12:26:59 -05:00
parent cbef2d4b74
commit f1e7e5a051
5 changed files with 165 additions and 32 deletions

View File

@ -52,6 +52,42 @@ namespace Louis__Pharmacy_CNSA212_FP
} }
} }
public static DataSet PatientInfoSearch(string id)
{
try
{
// open connection
myConn.Open();
//clear any parameters
cmdString.Parameters.Clear();
// command
cmdString.Connection = myConn;
cmdString.CommandType = CommandType.StoredProcedure;
cmdString.CommandTimeout = 1500;
cmdString.CommandText = "PatientInfoSearch";
// Define input parameter
cmdString.Parameters.Add("@patientID", SqlDbType.VarChar, 6).Value = id;
// adapter and dataset
SqlDataAdapter aAdapter = new SqlDataAdapter();
aAdapter.SelectCommand = cmdString;
DataSet aDataSet = new DataSet();
// fill adapter
aAdapter.Fill(aDataSet);
// return dataSet
return aDataSet;
}
catch (Exception ex)
{
throw new ArgumentException(ex.Message);
}
finally
{
myConn.Close();
}
}
public static DataSet PrescriptionInfoSearch(string rxID, string patientID) public static DataSet PrescriptionInfoSearch(string rxID, string patientID)
{ {
@ -131,5 +167,47 @@ namespace Louis__Pharmacy_CNSA212_FP
} }
} }
public static double GetNextPatientID()
{
try
{
// open connection
myConn.Open();
//clear any parameters
cmdString.Parameters.Clear();
// command
cmdString.Connection = myConn;
cmdString.CommandType = CommandType.StoredProcedure;
cmdString.CommandTimeout = 1500;
cmdString.CommandText = "GetNextPatientID";
// Define input parameter
cmdString.Parameters.Add("@TableName", SqlDbType.NVarChar, 128).Value = "PATIENT";
object result = cmdString.ExecuteScalar();
double value = 0;
try
{
value = Convert.ToDouble(result);
}
catch(Exception e)
{
MessageBox.Show("Error Getting next Patient ID","ERROR",MessageBoxButtons.OK);
}
// return dataSet
return value;
}
catch (Exception ex)
{
throw new ArgumentException(ex.Message);
}
finally
{
myConn.Close();
}
}
} }
} }

View File

@ -265,9 +265,12 @@ namespace Louis__Pharmacy_CNSA212_FP
this.dgvPatient.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvPatient.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvPatient.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.pat_id, this.FirstName, this.LastName, this.MiddleInitials, this.City, this.UsState, this.Zip, this.Ibs, this.Height_feet, this.Height_inches, this.Ailment, this.DOB, this.PhoneNumber, this.Gender, this.Medications }); this.dgvPatient.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.pat_id, this.FirstName, this.LastName, this.MiddleInitials, this.City, this.UsState, this.Zip, this.Ibs, this.Height_feet, this.Height_inches, this.Ailment, this.DOB, this.PhoneNumber, this.Gender, this.Medications });
this.dgvPatient.ContextMenuStrip = this.cmuPatient; this.dgvPatient.ContextMenuStrip = this.cmuPatient;
this.dgvPatient.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
this.dgvPatient.Location = new System.Drawing.Point(3, 3); this.dgvPatient.Location = new System.Drawing.Point(3, 3);
this.dgvPatient.MultiSelect = false;
this.dgvPatient.Name = "dgvPatient"; this.dgvPatient.Name = "dgvPatient";
this.dgvPatient.ReadOnly = true; this.dgvPatient.ReadOnly = true;
this.dgvPatient.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvPatient.Size = new System.Drawing.Size(652, 219); this.dgvPatient.Size = new System.Drawing.Size(652, 219);
this.dgvPatient.TabIndex = 0; this.dgvPatient.TabIndex = 0;
// //

View File

@ -26,6 +26,9 @@ namespace Louis__Pharmacy_CNSA212_FP
KeyPreview = true; KeyPreview = true;
KeyDown += frmInfo_KeyDown; KeyDown += frmInfo_KeyDown;
cmuPatientEdit.Enabled = false;
cmuPatientDelete.Enabled = false;
} }
private void frmInfo_KeyDown(object sender, KeyEventArgs e) private void frmInfo_KeyDown(object sender, KeyEventArgs e)
@ -136,6 +139,10 @@ namespace Louis__Pharmacy_CNSA212_FP
} }
cmuPatientEdit.Enabled = dgvPatient.Rows.Count > 0;
cmuPatientDelete.Enabled = dgvPatient.Rows.Count > 0;
} }
private void btnPrescriptionSearch_Click(object sender, EventArgs e) private void btnPrescriptionSearch_Click(object sender, EventArgs e)
@ -213,6 +220,7 @@ namespace Louis__Pharmacy_CNSA212_FP
private void btnPhysicianSearch_Click(object sender, EventArgs e) private void btnPhysicianSearch_Click(object sender, EventArgs e)
{ {
string fname = ""; string fname = "";
string lname = ""; string lname = "";
string phyID = "";; string phyID = "";;
@ -295,25 +303,34 @@ namespace Louis__Pharmacy_CNSA212_FP
} }
} }
private void cmuPatientNew_Click(object sender, EventArgs e) private void cmuPatientNew_Click(object sender, EventArgs e)
{ {
frmPatientAdd PatientAdd = new frmPatientAdd(true);
PatientAdd.MdiParent = MdiParent; frmPatientAdd PatientAdd = new frmPatientAdd(true);
PatientAdd.StartPosition = FormStartPosition.CenterScreen; PatientAdd.MdiParent = MdiParent;
PatientAdd.Show(); PatientAdd.StartPosition = FormStartPosition.CenterScreen;
PatientAdd.Focus(); PatientAdd.Show();
PatientAdd.Focus();
} }
private void cmuPatientEdit_Click(object sender, EventArgs e) private void cmuPatientEdit_Click(object sender, EventArgs e)
{ {
if (dgvPatient.Rows.Count > 0)
frmPatientAdd PatientAdd = new frmPatientAdd(false); {
PatientAdd.MdiParent = MdiParent; frmPatientAdd PatientAdd = new frmPatientAdd(false);
PatientAdd.StartPosition = FormStartPosition.CenterScreen; PatientAdd.MdiParent = MdiParent;
PatientAdd.Show(); PatientAdd.StartPosition = FormStartPosition.CenterScreen;
PatientAdd.Focus(); PatientAdd.Show();
PatientAdd.Focus();
Console.WriteLine( dgvPatient.SelectedRows.Count);
DataGridViewRow row = dgvPatient.SelectedRows[1];
PatientAdd.FillPatient(row.Cells[0].Value.ToString().Trim());
}
} }
} }
} }

View File

@ -58,6 +58,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtState = new System.Windows.Forms.TextBox(); this.txtState = new System.Windows.Forms.TextBox();
this.txtPhone = new System.Windows.Forms.TextBox(); this.txtPhone = new System.Windows.Forms.TextBox();
this.lblDisPurpose = new System.Windows.Forms.Label(); this.lblDisPurpose = new System.Windows.Forms.Label();
this.btnGO = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
@ -183,91 +184,91 @@ namespace Louis__Pharmacy_CNSA212_FP
this.txtPatientID.Location = new System.Drawing.Point(189, 74); this.txtPatientID.Location = new System.Drawing.Point(189, 74);
this.txtPatientID.Name = "txtPatientID"; this.txtPatientID.Name = "txtPatientID";
this.txtPatientID.Size = new System.Drawing.Size(100, 20); this.txtPatientID.Size = new System.Drawing.Size(100, 20);
this.txtPatientID.TabIndex = 13; this.txtPatientID.TabIndex = 1;
// //
// txtFname // txtFname
// //
this.txtFname.Location = new System.Drawing.Point(189, 97); this.txtFname.Location = new System.Drawing.Point(189, 97);
this.txtFname.Name = "txtFname"; this.txtFname.Name = "txtFname";
this.txtFname.Size = new System.Drawing.Size(100, 20); this.txtFname.Size = new System.Drawing.Size(100, 20);
this.txtFname.TabIndex = 14; this.txtFname.TabIndex = 2;
// //
// txtLname // txtLname
// //
this.txtLname.Location = new System.Drawing.Point(189, 120); this.txtLname.Location = new System.Drawing.Point(189, 120);
this.txtLname.Name = "txtLname"; this.txtLname.Name = "txtLname";
this.txtLname.Size = new System.Drawing.Size(100, 20); this.txtLname.Size = new System.Drawing.Size(100, 20);
this.txtLname.TabIndex = 15; this.txtLname.TabIndex = 3;
// //
// txtMidInit // txtMidInit
// //
this.txtMidInit.Location = new System.Drawing.Point(189, 143); this.txtMidInit.Location = new System.Drawing.Point(189, 143);
this.txtMidInit.Name = "txtMidInit"; this.txtMidInit.Name = "txtMidInit";
this.txtMidInit.Size = new System.Drawing.Size(100, 20); this.txtMidInit.Size = new System.Drawing.Size(100, 20);
this.txtMidInit.TabIndex = 16; this.txtMidInit.TabIndex = 4;
// //
// txtWeight // txtWeight
// //
this.txtWeight.Location = new System.Drawing.Point(189, 166); this.txtWeight.Location = new System.Drawing.Point(189, 166);
this.txtWeight.Name = "txtWeight"; this.txtWeight.Name = "txtWeight";
this.txtWeight.Size = new System.Drawing.Size(100, 20); this.txtWeight.Size = new System.Drawing.Size(100, 20);
this.txtWeight.TabIndex = 17; this.txtWeight.TabIndex = 5;
// //
// txtHeightFt // txtHeightFt
// //
this.txtHeightFt.Location = new System.Drawing.Point(189, 189); this.txtHeightFt.Location = new System.Drawing.Point(189, 189);
this.txtHeightFt.Name = "txtHeightFt"; this.txtHeightFt.Name = "txtHeightFt";
this.txtHeightFt.Size = new System.Drawing.Size(100, 20); this.txtHeightFt.Size = new System.Drawing.Size(100, 20);
this.txtHeightFt.TabIndex = 18; this.txtHeightFt.TabIndex = 6;
// //
// txtHeightIn // txtHeightIn
// //
this.txtHeightIn.Location = new System.Drawing.Point(189, 212); this.txtHeightIn.Location = new System.Drawing.Point(189, 212);
this.txtHeightIn.Name = "txtHeightIn"; this.txtHeightIn.Name = "txtHeightIn";
this.txtHeightIn.Size = new System.Drawing.Size(100, 20); this.txtHeightIn.Size = new System.Drawing.Size(100, 20);
this.txtHeightIn.TabIndex = 19; this.txtHeightIn.TabIndex = 7;
// //
// txtDOB // txtDOB
// //
this.txtDOB.Location = new System.Drawing.Point(189, 235); this.txtDOB.Location = new System.Drawing.Point(189, 235);
this.txtDOB.Name = "txtDOB"; this.txtDOB.Name = "txtDOB";
this.txtDOB.Size = new System.Drawing.Size(100, 20); this.txtDOB.Size = new System.Drawing.Size(100, 20);
this.txtDOB.TabIndex = 20; this.txtDOB.TabIndex = 8;
// //
// txtGender // txtGender
// //
this.txtGender.Location = new System.Drawing.Point(189, 258); this.txtGender.Location = new System.Drawing.Point(189, 258);
this.txtGender.Name = "txtGender"; this.txtGender.Name = "txtGender";
this.txtGender.Size = new System.Drawing.Size(100, 20); this.txtGender.Size = new System.Drawing.Size(100, 20);
this.txtGender.TabIndex = 21; this.txtGender.TabIndex = 9;
// //
// txtCity // txtCity
// //
this.txtCity.Location = new System.Drawing.Point(497, 74); this.txtCity.Location = new System.Drawing.Point(497, 74);
this.txtCity.Name = "txtCity"; this.txtCity.Name = "txtCity";
this.txtCity.Size = new System.Drawing.Size(100, 20); this.txtCity.Size = new System.Drawing.Size(100, 20);
this.txtCity.TabIndex = 22; this.txtCity.TabIndex = 10;
// //
// txtZip // txtZip
// //
this.txtZip.Location = new System.Drawing.Point(497, 97); this.txtZip.Location = new System.Drawing.Point(497, 97);
this.txtZip.Name = "txtZip"; this.txtZip.Name = "txtZip";
this.txtZip.Size = new System.Drawing.Size(100, 20); this.txtZip.Size = new System.Drawing.Size(100, 20);
this.txtZip.TabIndex = 23; this.txtZip.TabIndex = 11;
// //
// txtState // txtState
// //
this.txtState.Location = new System.Drawing.Point(497, 120); this.txtState.Location = new System.Drawing.Point(497, 120);
this.txtState.Name = "txtState"; this.txtState.Name = "txtState";
this.txtState.Size = new System.Drawing.Size(100, 20); this.txtState.Size = new System.Drawing.Size(100, 20);
this.txtState.TabIndex = 24; this.txtState.TabIndex = 12;
// //
// txtPhone // txtPhone
// //
this.txtPhone.Location = new System.Drawing.Point(497, 143); this.txtPhone.Location = new System.Drawing.Point(497, 143);
this.txtPhone.Name = "txtPhone"; this.txtPhone.Name = "txtPhone";
this.txtPhone.Size = new System.Drawing.Size(100, 20); this.txtPhone.Size = new System.Drawing.Size(100, 20);
this.txtPhone.TabIndex = 25; this.txtPhone.TabIndex = 13;
// //
// lblDisPurpose // lblDisPurpose
// //
@ -279,11 +280,21 @@ namespace Louis__Pharmacy_CNSA212_FP
this.lblDisPurpose.Text = "Patient"; this.lblDisPurpose.Text = "Patient";
this.lblDisPurpose.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblDisPurpose.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// btnGO
//
this.btnGO.Location = new System.Drawing.Point(670, 389);
this.btnGO.Name = "btnGO";
this.btnGO.Size = new System.Drawing.Size(75, 23);
this.btnGO.TabIndex = 14;
this.btnGO.UseVisualStyleBackColor = true;
//
// frmPatientAdd // frmPatientAdd
// //
this.AcceptButton = this.btnGO;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.btnGO);
this.Controls.Add(this.lblDisPurpose); this.Controls.Add(this.lblDisPurpose);
this.Controls.Add(this.txtPhone); this.Controls.Add(this.txtPhone);
this.Controls.Add(this.txtState); this.Controls.Add(this.txtState);
@ -318,6 +329,8 @@ namespace Louis__Pharmacy_CNSA212_FP
this.PerformLayout(); this.PerformLayout();
} }
private System.Windows.Forms.Button btnGO;
private System.Windows.Forms.TextBox txtPatientID; private System.Windows.Forms.TextBox txtPatientID;
private System.Windows.Forms.TextBox txtFname; private System.Windows.Forms.TextBox txtFname;
private System.Windows.Forms.TextBox txtLname; private System.Windows.Forms.TextBox txtLname;

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using System.Data;
namespace Louis__Pharmacy_CNSA212_FP namespace Louis__Pharmacy_CNSA212_FP
{ {
@ -14,10 +16,12 @@ namespace Louis__Pharmacy_CNSA212_FP
if (isNew) if (isNew)
{ {
lblDisPurpose.Text = "Add Patient"; lblDisPurpose.Text = "Add Patient";
btnGO.Text = "Create";
} }
else else
{ {
lblDisPurpose.Text = "Edit Patient"; lblDisPurpose.Text = "Edit Patient";
btnGO.Text = "Update";
} }
} }
@ -35,20 +39,38 @@ namespace Louis__Pharmacy_CNSA212_FP
if (isAdd) if (isAdd)
{ {
double nextID = PharmacyDataTier.GetNextPatientID();
//Pull next Patient ID txtPatientID.Text = nextID.ToString();
} }
else else
{ {
//Pull Current Info
} }
} }
public void FillPatient(string patID)
{
DataSet ds = new DataSet();
PharmacyDataTier data = new PharmacyDataTier();
ds = PharmacyDataTier.PatientInfoSearch(patID);
txtPatientID.Text = ds.Tables[0].Rows[0]["Patient_id"].ToString();
txtFname.Text = ds.Tables[0].Rows[0]["FirstName"].ToString();
txtLname.Text = ds.Tables[0].Rows[0]["LastName"].ToString();
txtMidInit.Text = ds.Tables[0].Rows[0]["MiddleInitals"].ToString();
txtWeight.Text = ds.Tables[0].Rows[0]["lbs"].ToString();
txtHeightFt.Text = ds.Tables[0].Rows[0]["Height_feet"].ToString();
txtHeightIn.Text = ds.Tables[0].Rows[0]["Height_inches"].ToString();
txtDOB.Text = ds.Tables[0].Rows[0]["DOB"].ToString();
txtGender.Text = ds.Tables[0].Rows[0]["Gender"].ToString();
txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString();
txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString();
txtState.Text = ds.Tables[0].Rows[0]["UsState"].ToString();
txtPhone.Text = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
}
} }
} }