public List <SubmitedApplicationInfo> GetUserEmailAndName(int?id) { string query = @"select EmployeeName, Email from tb_Employee where Id = '" + id + "'"; try { SqlCommand command = new SqlCommand(query, con); con.Open(); SqlDataReader reader = command.ExecuteReader(); List <SubmitedApplicationInfo> ListOfEmployee = new List <SubmitedApplicationInfo>(); while (reader.Read()) { SubmitedApplicationInfo employee = new SubmitedApplicationInfo(); employee.EmployeeName = reader["EmployeeName"].ToString(); employee.Email = reader["Email"].ToString(); ListOfEmployee.Add(employee); } reader.Close(); return(ListOfEmployee); } catch (Exception exception) { throw new Exception("Unable to connect Server", exception); } finally { con.Close(); } }
public List <SubmitedApplicationInfo> GetUserEmail(int?id) { string query = @"select p.EmployeeName, p.Email, p.Id,e.Reason,CONVERT(NVARCHAR,e.StartDate, 100) AS[StartDate], CONVERT(NVARCHAR,e.EndDate, 100) AS[EndDate], e.TotalDay, CONVERT(NVARCHAR,e.EntryDate, 100) AS[EntryDate] From EmployeeLeaveRequest e inner join Employee p on e.EmployeeId=p.Id where e.Id = '" + id + "' "; try { var command = new SqlCommand(query, Connection); Connection.Open(); SqlDataReader reader = command.ExecuteReader(); var ListOfEmployee = new List <SubmitedApplicationInfo>(); while (reader.Read()) { var employee = new SubmitedApplicationInfo { Id = (int)reader["Id"], EmployeeName = reader["EmployeeName"].ToString(), Email = reader["Email"].ToString(), Reason = reader["Reason"].ToString(), StartDate = reader["StartDate"].ToString(), EndDate = reader["EndDate"].ToString(), EntryDate = reader["EntryDate"].ToString(), TotalDay = reader["TotalDay"].ToString() }; ListOfEmployee.Add(employee); } reader.Close(); return(ListOfEmployee); } catch (Exception exception) { throw new Exception("Unable to connect Server", exception); } finally { Connection.Close(); } }