public DataTable GetDataSource() { DataTable dt = new DataTable(); dt = new DataTable(); dt.Columns.Add("Id"); dt.Columns.Add("Day"); dt.Columns.Add("WorkingDay"); dt.Columns.Add("Vacation"); dt.Columns.Add("Holyday"); var employeeStatus = ctx.EmployeeStatus.Where(a => a.Month == selectedMonth); int daysCount = DateTime.DaysInMonth(DateTime.Now.Year, selectedMonth); for (int i = 1; i <= daysCount; i++) { DataRow dr = dt.NewRow(); dr["Day"] = i.ToString(); foreach (var item in employeeStatus) { if (item.Day == i) { dr["Id"] = item.Id; if (item.DayType == 0) { dr["WorkingDay"] = "1"; dr["Vacation"] = "0"; dr["Holyday"] = "0"; } else if (item.DayType == 1) { dr["WorkingDay"] = "0"; dr["Vacation"] = "1"; dr["Holyday"] = "0"; } else { dr["WorkingDay"] = "0"; dr["Vacation"] = "0"; dr["Holyday"] = "1"; } break; } } if (string.IsNullOrEmpty(dr["WorkingDay"].ToString()) && string.IsNullOrEmpty(dr["Vacation"].ToString()) && string.IsNullOrEmpty(dr["Holyday"].ToString())) { dr["Id"] = "0"; dr["WorkingDay"] = "0"; dr["Vacation"] = "0"; dr["Holyday"] = "0"; } dt.Rows.Add(dr); } return dt; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)