updated datatier
This commit is contained in:
parent
1c1f1659e3
commit
d257715541
@ -34,6 +34,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
@ -1,7 +1,94 @@
|
|||||||
namespace Louis__Pharmacy_CNSA212_FP
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
|
||||||
|
namespace Louis__Pharmacy_CNSA212_FP
|
||||||
{
|
{
|
||||||
public class PharmacyDataTier
|
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 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user