2024-02-14 17:40:16 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
|
|
|
|
|
namespace Louis__Pharmacy_CNSA212_FP
|
2024-02-14 17:35:35 -05:00
|
|
|
|
{
|
|
|
|
|
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 17:35:35 -05:00
|
|
|
|
|
2024-02-14 17:40:16 -05:00
|
|
|
|
public DataSet GetStudents(string studid, string lname, DateTime dob)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// open connection
|
|
|
|
|
myConn.Open();
|
|
|
|
|
//clear any parameters
|
|
|
|
|
cmdString.Parameters.Clear();
|
|
|
|
|
// command
|
|
|
|
|
cmdString.Connection = myConn;
|
|
|
|
|
cmdString.CommandType = CommandType.StoredProcedure;
|
|
|
|
|
cmdString.CommandTimeout = 1500;
|
|
|
|
|
cmdString.CommandText = "SearchStudent";
|
|
|
|
|
// Define input parameter
|
|
|
|
|
cmdString.Parameters.Add("@studentid", SqlDbType.VarChar, 6).Value = studid;
|
|
|
|
|
cmdString.Parameters.Add("@lname", SqlDbType.VarChar, 25).Value = lname;
|
|
|
|
|
cmdString.Parameters.Add("@dob", SqlDbType.Date).Value = dob;
|
|
|
|
|
// 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 DataSet GetStudents(string StuID)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// open connection
|
|
|
|
|
myConn.Open();
|
|
|
|
|
//clear any parameters
|
|
|
|
|
cmdString.Parameters.Clear();
|
|
|
|
|
// command
|
|
|
|
|
cmdString.Connection = myConn;
|
|
|
|
|
cmdString.CommandType = CommandType.StoredProcedure;
|
|
|
|
|
cmdString.CommandTimeout = 1500;
|
|
|
|
|
cmdString.CommandText = "GetByStudentIDS";
|
|
|
|
|
// Define input parameter
|
|
|
|
|
cmdString.Parameters.Add("@studentid", SqlDbType.VarChar, 6).Value = StuID;
|
|
|
|
|
// 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:35:35 -05:00
|
|
|
|
}
|
|
|
|
|
}
|