Empty;
public DataManager()
{
connectionString = ConfigurationManager.ConnectionStrings
["joydipConnectionString"].
ConnectionString.Trim();
}
public ArrayList GetAllEmployees()
{
SqlConnection conn = null;
ArrayList employeeList = null;
try
{
conn = new SqlConnection(connectionString);
conn.Open();
string sql = "select EmpCode, EmpName, Basic,
JoiningDate, DeptCode from employee e, Department
d where e.DeptID = d.DeptID";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
employeeList = new ArrayList();
while (dr.Read())
{
Employee emp = new Employee();
if (dr["EmpCode"] != DBNull.Value)
emp.EmpCode = dr["EmpCode"].ToString();
if (dr["EmpName"] != DBNull.Value)
emp.EmpName = dr["EmpName"].ToString();
if (dr["Basic"] != DBNull.Value)
emp.Basic = Convert.ToDouble(dr["Basic"].
ToString());
if (dr["JoiningDate"] != DBNull.Value)
emp.JoiningDate =
Convert.ToDateTime(dr["JoiningDate"].
ToString());
if (dr["DeptCode"] != DBNull.Value)
emp.DeptCode = dr["DeptCode"].ToString();
Introduction to Data Binding in ASP.NET
[ 12 ]
employeeList.Add(emp);
emp = null;
}
}
catch
{
throw;
}
finally
{
conn.Close();
}
return employeeList;
}
public ArrayList GetEmployeeByDept(string deptCode)
{
SqlConnection conn = null;
ArrayList employeeList = null;
try
{
conn = new SqlConnection(connectionString); conn.
Pages:
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