private void FillGrid() { DateCopyStart = DateTime.MinValue; DateCopyEnd = DateTime.MinValue; textClipboard.Text = ""; if (textDateFrom.errorProvider1.GetError(textDateFrom) != "" || textDateTo.errorProvider1.GetError(textDateTo) != "") { //MsgBox.Show(this,"Please fix errors first."); return; } ProvsChanged = false; List <int> provNums = new List <int>(); for (int i = 0; i < listProv.SelectedIndices.Count; i++) { provNums.Add(Providers.List[listProv.SelectedIndices[i]].ProvNum); } List <int> empNums = new List <int>(); for (int i = 0; i < listEmp.SelectedIndices.Count; i++) { empNums.Add(Employees.ListShort[listEmp.SelectedIndices[i]].EmployeeNum); } DataTable table = Schedules.GetPeriod(PIn.PDate(textDateFrom.Text), PIn.PDate(textDateTo.Text), provNums.ToArray(), empNums.ToArray(), checkPractice.Checked); gridMain.BeginUpdate(); gridMain.Columns.Clear(); int colW; if (checkWeekend.Checked) { colW = (gridMain.Width - 20) / 7; } else { colW = (gridMain.Width - 20) / 5; } ODGridColumn col; if (checkWeekend.Checked) { col = new ODGridColumn(Lan.g("TableSchedule", "Sunday"), colW); gridMain.Columns.Add(col); } col = new ODGridColumn(Lan.g("TableSchedule", "Monday"), colW); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedule", "Tuesday"), colW); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedule", "Wednesday"), colW); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedule", "Thursday"), colW); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedule", "Friday"), colW); gridMain.Columns.Add(col); if (checkWeekend.Checked) { col = new ODGridColumn(Lan.g("TableSchedule", "Saturday"), colW); gridMain.Columns.Add(col); } gridMain.Rows.Clear(); ODGridRow row; for (int i = 0; i < table.Rows.Count; i++) { row = new ODGridRow(); if (checkWeekend.Checked) { row.Cells.Add(table.Rows[i][0].ToString()); } row.Cells.Add(table.Rows[i][1].ToString()); row.Cells.Add(table.Rows[i][2].ToString()); row.Cells.Add(table.Rows[i][3].ToString()); row.Cells.Add(table.Rows[i][4].ToString()); row.Cells.Add(table.Rows[i][5].ToString()); if (checkWeekend.Checked) { row.Cells.Add(table.Rows[i][6].ToString()); } gridMain.Rows.Add(row); } gridMain.EndUpdate(); //Set today red if (!checkWeekend.Checked && (DateTime.Today.DayOfWeek == DayOfWeek.Sunday || DateTime.Today.DayOfWeek == DayOfWeek.Saturday)) { return; } if (DateTime.Today > PIn.PDate(textDateTo.Text) || DateTime.Today < PIn.PDate(textDateFrom.Text)) { return; } int colI = (int)DateTime.Today.DayOfWeek; if (!checkWeekend.Checked) { colI--; } gridMain.Rows[Schedules.GetRowCal(PIn.PDate(textDateFrom.Text), DateTime.Today)].Cells[colI].ColorText = Color.Red; }