CNSA-212-FP/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs

135 lines
4.8 KiB
C#
Raw Normal View History

2024-02-14 17:40:16 -05:00
using System;
using System.Configuration;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlClient;
2024-02-14 19:43:07 -05:00
using System.Runtime.Versioning;
2024-02-14 17:40:16 -05:00
namespace Louis__Pharmacy_CNSA212_FP
{
public class PharmacyDataTier
{
2024-02-14 17:40:16 -05:00
static String connString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
static SqlConnection myConn = new SqlConnection(connString);
static System.Data.SqlClient.SqlCommand cmdString = new System.Data.SqlClient.SqlCommand();
2024-02-14 18:21:17 -05:00
public static DataSet PatientInfoSearch(string id, string lname, string fname)
2024-02-14 17:40:16 -05:00
{
try
{
// open connection
myConn.Open();
//clear any parameters
cmdString.Parameters.Clear();
// command
cmdString.Connection = myConn;
cmdString.CommandType = CommandType.StoredProcedure;
cmdString.CommandTimeout = 1500;
2024-02-14 18:21:17 -05:00
cmdString.CommandText = "PatientInfoSearch";
2024-02-14 17:40:16 -05:00
// Define input parameter
2024-02-14 18:21:17 -05:00
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;
2024-02-14 17:40:16 -05:00
// 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();
}
}
2024-02-14 19:27:21 -05:00
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();
}
}
2024-02-14 17:40:16 -05:00
2024-02-14 19:43:07 -05:00
public static DataSet PhysicianInfoSearch(string fname,string lname, string phyID)
2024-02-14 17:40:16 -05:00
{
try
{
// open connection
myConn.Open();
//clear any parameters
cmdString.Parameters.Clear();
// command
cmdString.Connection = myConn;
cmdString.CommandType = CommandType.StoredProcedure;
cmdString.CommandTimeout = 1500;
2024-02-14 19:43:07 -05:00
cmdString.CommandText = "PhysicianInfoSearch";
2024-02-14 17:40:16 -05:00
// Define input parameter
2024-02-14 19:43:07 -05:00
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;
2024-02-14 17:40:16 -05:00
// 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();
}
}
}
}