Merged github (again).

This commit is contained in:
Adam McCane 2024-02-14 20:06:29 -05:00
commit 6781830dcc
5 changed files with 408 additions and 42 deletions

View File

@ -3,7 +3,7 @@
<configSections>
</configSections>
<connectionStrings>
<add name="ConnString" connectionString ="Data Source = 100.102.137.92; Initial Catalog=FinalProjectOfficialPharmacy; UID=admin; PWD=delirium-purveyor-overall-backboned-approval-amino; connect timeout=30; integrated security=false;"
<add name="ConnString" connectionString ="Data Source = sql.eggtech.net; Initial Catalog=FinalProjectOfficialPharmacy; UID=admin; PWD=delirium-purveyor-overall-backboned-approval-amino; connect timeout=30; integrated security=false;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<startup>

View File

@ -34,6 +34,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -88,6 +89,7 @@
<Compile Include="frmWelcome.Designer.cs">
<DependentUpon>frmWelcome.cs</DependentUpon>
</Compile>
<Compile Include="PharmacyDataTier.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="refillDataTier.cs" />

View File

@ -0,0 +1,135 @@
using System;
using System.Configuration;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.Versioning;
namespace Louis__Pharmacy_CNSA212_FP
{
public class PharmacyDataTier
{
static String connString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
static SqlConnection myConn = new SqlConnection(connString);
static System.Data.SqlClient.SqlCommand cmdString = new System.Data.SqlClient.SqlCommand();
public static DataSet PatientInfoSearch(string id, string lname, string fname)
{
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;
cmdString.Parameters.Add("@lname", SqlDbType.VarChar, 30).Value = lname;
cmdString.Parameters.Add("@fname", SqlDbType.VarChar, 30).Value = fname;
// 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)
{
try
{
// open connection
myConn.Open();
//clear any parameters
cmdString.Parameters.Clear();
// command
cmdString.Connection = myConn;
cmdString.CommandType = CommandType.StoredProcedure;
cmdString.CommandTimeout = 1500;
cmdString.CommandText = "PerscriptionInfoSearch";
// Define input parameter
cmdString.Parameters.Add("@rxID", SqlDbType.VarChar, 11).Value = rxID;
cmdString.Parameters.Add("@patientID", SqlDbType.VarChar, 8).Value = patientID;
// 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 PhysicianInfoSearch(string fname,string lname, string phyID)
{
try
{
// open connection
myConn.Open();
//clear any parameters
cmdString.Parameters.Clear();
// command
cmdString.Connection = myConn;
cmdString.CommandType = CommandType.StoredProcedure;
cmdString.CommandTimeout = 1500;
cmdString.CommandText = "PhysicianInfoSearch";
// Define input parameter
cmdString.Parameters.Add("@fname", SqlDbType.VarChar, 11).Value = fname;
cmdString.Parameters.Add("@lname", SqlDbType.VarChar, 8).Value = lname;
cmdString.Parameters.Add("@phyID", SqlDbType.VarChar, 8).Value = phyID;
// 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();
}
}
}
}

View File

@ -240,28 +240,14 @@ namespace Louis__Pharmacy_CNSA212_FP
this.btnPatientSearch.TabIndex = 4;
this.btnPatientSearch.Text = "Search";
this.btnPatientSearch.UseVisualStyleBackColor = false;
this.btnPatientSearch.Click += new System.EventHandler(this.btnPatientSearch_Click);
//
// dgvPatient
//
this.dgvPatient.AllowUserToAddRows = false;
this.dgvPatient.AllowUserToDeleteRows = false;
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.Location = new System.Drawing.Point(3, 3);
this.dgvPatient.Name = "dgvPatient";
this.dgvPatient.ReadOnly = true;
@ -416,6 +402,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.btnPrescriptionSearch.TabIndex = 4;
this.btnPrescriptionSearch.Text = "Search";
this.btnPrescriptionSearch.UseVisualStyleBackColor = true;
this.btnPrescriptionSearch.Click += new System.EventHandler(this.btnPrescriptionSearch_Click);
//
// txtPrescriptionPatID
//
@ -455,14 +442,7 @@ namespace Louis__Pharmacy_CNSA212_FP
this.dgvPrescription.AllowUserToAddRows = false;
this.dgvPrescription.AllowUserToDeleteRows = false;
this.dgvPrescription.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvPrescription.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.RxNum_id,
this.numRefills,
this.pastNumRefills,
this.PrescribedBy,
this.Physician_id,
this.Medication_id,
this.Patient_id});
this.dgvPrescription.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.RxNum_id, this.numRefills, this.pastNumRefills, this.PrescribedBy, this.Physician_id, this.Medication_id, this.Patient_id });
this.dgvPrescription.Location = new System.Drawing.Point(3, 3);
this.dgvPrescription.Name = "dgvPrescription";
this.dgvPrescription.Size = new System.Drawing.Size(652, 195);
@ -586,24 +566,14 @@ namespace Louis__Pharmacy_CNSA212_FP
this.btnPhysicianSearch.TabIndex = 4;
this.btnPhysicianSearch.Text = "Search";
this.btnPhysicianSearch.UseVisualStyleBackColor = true;
this.btnPhysicianSearch.Click += new System.EventHandler(this.btnPhysicianSearch_Click);
//
// dgvPhysician
//
this.dgvPhysician.AllowUserToAddRows = false;
this.dgvPhysician.AllowUserToDeleteRows = false;
this.dgvPhysician.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvPhysician.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Phys_id,
this.namefirst,
this.namelast,
this.initialsmiddle,
this.cit,
this.state,
this.zipp,
this.dobb,
this.numberphone,
this.gennder,
this.Specialty});
this.dgvPhysician.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Phys_id, this.namefirst, this.namelast, this.initialsmiddle, this.cit, this.state, this.zipp, this.dobb, this.numberphone, this.gennder, this.Specialty });
this.dgvPhysician.Location = new System.Drawing.Point(3, 3);
this.dgvPhysician.Name = "dgvPhysician";
this.dgvPhysician.ReadOnly = true;
@ -724,7 +694,6 @@ namespace Louis__Pharmacy_CNSA212_FP
this.splcPhysician.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvPhysician)).EndInit();
this.ResumeLayout(false);
}
#endregion

View File

@ -8,15 +8,13 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using System.Configuration;
using System.Collections;
using System.Data.SqlClient;
namespace Louis__Pharmacy_CNSA212_FP
{
public partial class frmInfo : Form
{
private ErrorProvider ep1 = new ErrorProvider();
public frmInfo()
{
InitializeComponent();
@ -25,8 +23,24 @@ namespace Louis__Pharmacy_CNSA212_FP
private void frmInfo_Load(object sender, EventArgs e)
{
KeyPreview = true;
KeyDown += frmInfo_KeyDown;
}
private void frmInfo_KeyDown(object sender, KeyEventArgs e)
{
// esc not funtional
if (e.KeyCode == Keys.Escape) // Check if the pressed key is Escape
{this.Close(); // Close the form
}
if (e.KeyCode == Keys.Enter){
btnPatientSearch_Click(sender, e);
}
}
private void addUpdatePatientAndPhysicianToolStripMenuItem_Click(object sender, EventArgs e)
{
@ -36,5 +50,251 @@ 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 + txtPatientID.Text.Length > 0)
{
try
{
fname = txtPatientFirst.Text;
try
{
lname = txtPatientLast.Text;
try
{
id = txtPatientID.Text;
try
{
ds = PharmacyDataTier.PatientInfoSearch(id,lname,fname);
if (ds.Tables[0].Rows.Count > 0) // There is a record.
{
dgvPatient.Visible = true;
// Get data source.
dgvPatient.DataSource = ds.Tables[0];
dgvPatient.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
// Set the row and column header styles.
dgvPatient.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
dgvPatient.ColumnHeadersDefaultCellStyle.BackColor = Color.Green;
}
else
{
dgvPatient.Visible = false; // Hide the DataGridView if no results are found.
MessageBox.Show("No records found.");
}
}
catch (Exception exception)
{
ep1.SetError(btnPatientSearch, "Error Searching");
}
}
catch (Exception exception)
{
ep1.SetError(txtPatientID, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPatientLast, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPatientFirst, "Invalid Value");
}
}
}
private void btnPrescriptionSearch_Click(object sender, EventArgs e)
{
string rxID = "";
string patientID = "";
DataSet ds = new DataSet();
if (txtPrescriptionPatID.Text.Length+txtRxNumber.Text.Length > 0)
{
try
{
patientID = txtPrescriptionPatID.Text;
try
{
rxID = txtRxNumber.Text;
try
{
ds = PharmacyDataTier.PrescriptionInfoSearch(rxID, patientID);
if (ds.Tables[0].Rows.Count > 0) // There is a record.
{
dgvPrescription.Visible = true;
// Get data source.
dgvPrescription.DataSource = ds.Tables[0];
dgvPrescription.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
// Set the row and column header styles.
dgvPrescription.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
dgvPrescription.ColumnHeadersDefaultCellStyle.BackColor = Color.Green;
}
else
{
dgvPatient.Visible = false; // Hide the DataGridView if no results are found.
MessageBox.Show("No records found.");
}
}
catch (Exception exception)
{
ep1.SetError(btnPrescriptionSearch, "Error Searching");
}
}
catch (Exception exception)
{
ep1.SetError(txtRxNumber, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPrescriptionPatID, "Invalid Value");
}
}
}
private void btnPhysicianSearch_Click(object sender, EventArgs e)
{
string fname = "";
string lname = "";
string phyID = "";;
DataSet ds = new DataSet();
if (txtPhysicianFirst.Text.Length+txtPhysicianLast.Text.Length+txtPhysicianID.Text.Length > 0)
{
try
{
fname = txtPhysicianFirst.Text;
try
{
lname = txtPhysicianLast.Text;
try
{
phyID = txtPhysicianID.Text;
try
{
ds = PharmacyDataTier.PhysicianInfoSearch(fname, lname, phyID);
if (ds.Tables[0].Rows.Count > 0) // There is a record.
{
dgvPhysician.Visible = true;
// Get data source.
dgvPhysician.DataSource = ds.Tables[0];
dgvPhysician.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen;
// Set the row and column header styles.
dgvPhysician.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
dgvPhysician.ColumnHeadersDefaultCellStyle.BackColor = Color.Green;
}
else
{
dgvPatient.Visible = false; // Hide the DataGridView if no results are found.
MessageBox.Show("No records found.");
}
}
catch (Exception exception)
{
ep1.SetError(btnPhysicianSearch, "Error Searching");
}
}
catch (Exception exception)
{
ep1.SetError(txtPhysicianID, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPhysicianLast, "Invalid Value");
}
}
catch (Exception exception)
{
ep1.SetError(txtPhysicianFirst, "Invalid Value");
}
}
}
}
}