public static List <ModelTS> getuserprofile() { DateTime DateToday = DateTime.Today; List <ModelTS> ListAPP = new List <ModelTS>(); ModelTS ListinTS; //ดึง list log string queryString = @"SELECT [timesheets].[id],[project].projectname, [userprofile].firstname+' '+[userprofile].lastname as Name ,[timesheets].datework as DateWork, [work_hr] as 'WorkHours', [project].end_date as Enddate ,status,[timesheets].description FROM [timesheets] Inner Join [project] ON [project].[id] = [timesheets].[project_id]Inner Join [userprofile] ON [userprofile].[id] = [timesheets].[employee_id]where [timesheets].[status]='pending'"; con.Open(); /*+เดี่ยวกลับมาแก้ใส่session +*/ SqlCommand command = new SqlCommand(queryString, con); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ListinTS = new ModelTS(); ListinTS.id = (int)reader["ID"]; ListinTS.Projectname = (string)reader["Projectname"]; ListinTS.FristnameLastname = (string)reader["Name"]; ListinTS.Worktime = Convert.ToString(reader["WorkHours"]); ListinTS.DateTS = Convert.ToString(reader["DateWork"]); ListinTS.Description = Convert.ToString(reader["Description"]); ListinTS.Checkstatus = (DateTime)reader["Enddate"]; if (DateToday < ListinTS.Checkstatus || DateToday == ListinTS.Checkstatus) { ListinTS.status = "In Time"; } else { ListinTS.status = "Exceed the deadline"; } ListAPP.Add(ListinTS); } con.Close(); return(ListAPP); }
public static List <ModelTS> getTSHistory() { WebForm6 GS = new WebForm6(); var SSS = GS.getsession(); DateTime DateToday = DateTime.Today; List <ModelTS> ListAPP = new List <ModelTS>(); ModelTS ListinTS; //ดึง list log string queryString = @"SELECT [timesheets].[id] as ID,[project].projectname, [userprofile].firstname+' '+[userprofile].lastname as Name ,[timesheets].datework as DateWork, [work_hr] as 'WorkHours', [project].end_date as Enddate ,status,[timesheets].desciption FROM [timesheets] Inner Join [project] ON [project].[id] = [timesheets].[project_id] Inner Join [userprofile] ON [userprofile].[id] = [timesheets].[employee_id] where [timesheets].[status]='pending'and [timesheets].project_id IN (select Assign.project_id from Assign where Assign.employee_id = '" + SSS + "')"; con.Open(); /*+เดี่ยวกลับมาแก้ใส่session +*/ SqlCommand command = new SqlCommand(queryString, con); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ListinTS = new ModelTS(); ListinTS.id = (int)reader["ID"]; ListinTS.Projectname = (string)reader["Projectname"]; ListinTS.FristnameLastname = (string)reader["Name"]; ListinTS.Worktime = Convert.ToString(reader["WorkHours"]); ListinTS.DateTS = Convert.ToString(((DateTime)reader["DateWork"]).ToString("dd/MM/yyyy")); ListinTS.Description = Convert.ToString(reader["Desciption"]); ListinTS.Checkstatus = (DateTime)reader["Enddate"]; ListinTS.status = Convert.ToString(reader["status"]);; ListAPP.Add(ListinTS); } con.Close(); return(ListAPP); }