-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnect.cs
42 lines (40 loc) · 1.42 KB
/
Connect.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PharmacyAutomation
{
public static class Connect
{
public static SqlConnection connection = new SqlConnection("Data Source=DESKTOP-2H5V0KB\\SQLEXPRESS;Initial Catalog=DbPharmacy;Integrated Security=True");
public static string AdminID()
{
string adminID = null;
connection.Open();
SqlCommand command1 = new SqlCommand("Select AuthorityID From TblAuthority Where AuthorityName = 'admin'", connection);
SqlDataReader dataReader1 = command1.ExecuteReader();
if (dataReader1.Read())
{
adminID = dataReader1[0].ToString();
}
connection.Close();
return adminID;
}
public static string IsAdmin(string personID)
{
string adminID = null;
connection.Open();
SqlCommand command = new SqlCommand("Select AuthorityID From TblPersonAuthority Where PersonID=@p1", connection);
command.Parameters.AddWithValue("@p1", personID);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.Read())
{
adminID = dataReader[0].ToString();
}
connection.Close();
return adminID;
}
}
}