public static DataTable getByMonth(int month, int year) { var lst = DAL_ATTENDANCE.getByMonth(month, year); var lstName = DAL_EMPLOYEE.GetAll().Select(x => x.ID).Distinct().ToList(); if (lst != null) { DataTable rs = new DataTable(); DataColumn STT = new DataColumn(); STT.ColumnName = "STT"; rs.Columns.Add(STT); DataColumn ID = new DataColumn(); ID.ColumnName = "ID"; rs.Columns.Add(ID); DataColumn Name = new DataColumn(); Name.ColumnName = "Name"; rs.Columns.Add(Name); for (int i = 0; i < DateTime.DaysInMonth(year, month); i++) { string name = (i + 1).ToString(); DataColumn cl = new DataColumn(); cl.ColumnName = name; rs.Columns.Add(cl); } DataColumn Tong = new DataColumn(); Tong.ColumnName = "Tong"; rs.Columns.Add(Tong); for (int i = 0; i < lstName.Count; i++) { DataRow row = rs.NewRow(); int tong = 0; row[0] = i + 1; row[1] = lstName[i]; row[2] = DAL_EMPLOYEE.GetFullName(int.Parse(lstName[i].ToString())); for (int j = 2; j < DateTime.DaysInMonth(year, month) + 2; j++) { if (Check(lst, lstName[i], j, month, year)) { row[j] = "x"; tong++; } } row["Tong"] = tong.ToString(); rs.Rows.Add(row); } return(rs); } return(null); }
public static DataTable getAll() { var lst = DAL_EMPLOYEE.GetAll(); var dt = new DataTable(); dt = BLL_ExtendList.ToDataTable(lst); DataColumn STT = new DataColumn(); STT.ColumnName = "STT"; dt.Columns.Add(STT); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["STT"] = i + 1; } dt.Columns.Remove("ATTENDANCEs"); dt.Columns.Remove("PERSONAL"); dt.Columns.Remove("ISDELETE"); return(dt); }