private void CreateSession(DateTime date) { pnlSessionList.Controls.Clear(); List <Session> sessionsList = appointmentController.GetDoctorSessions(doctor.DoctorId, date); List <int> completerExaminationList = examinationController.GetRendezvousTimeIdForExamination(doctor.DoctorId, DateTime.Today); DataRowCollection rows = appointmentController.GetAllAppointmentsTimes().Rows; int timeCount = rows.Count; for (int i = 0; i < timeCount / 5; i++) { for (int j = 0; j < timeCount / 3; j++) { Button button = new Button(); button.BackColor = Color.FromArgb(26, 177, 136); button.FlatStyle = FlatStyle.Flat; button.ForeColor = Color.White; button.Width = 65; button.Height = 65; button.Enabled = true; button.Left = button.Width * j; button.Top = button.Height * i; button.Text = rows[i * timeCount / 3 + j].ItemArray[1].ToString(); button.Tag = rows[i * timeCount / 3 + j].ItemArray[0].ToString(); button.Click += GetPatient; foreach (var item in sessionsList) { if (Convert.ToInt32(button.Tag) == item.RendezvousTimeId) { button.Enabled = false; button.BackColor = Color.FromArgb(67, 81, 89); button.ForeColor = Color.White; foreach (int items in completerExaminationList) { if (string.Equals(button.Tag, items.ToString())) { button.Enabled = false; } } } } pnlSessionList.Controls.Add(button); } } }
///private void private void CreateSession(DateTime date) { pnlSessionList.Controls.Clear(); List <Session> sessionsList = appointmentController.GetDoctorSessions(GetDoctorId, date); DataRowCollection rows = appointmentController.GetAllAppointmentsTimes().Rows; int timeCount = rows.Count; for (int i = 0; i < timeCount / 5; i++) { for (int j = 0; j < timeCount / 3; j++) { Button button = new Button(); button.BackColor = Color.FromArgb(26, 177, 136); button.ForeColor = Color.LightGray; button.FlatStyle = FlatStyle.Flat; button.Width = 60; button.Height = 60; button.Left = button.Width * j; button.Top = button.Height * i; button.Text = rows[i * timeCount / 3 + j].ItemArray[1].ToString(); button.Tag = rows[i * timeCount / 3 + j].ItemArray[0].ToString(); button.Click += GetSessionId; foreach (var item in sessionsList) { if (Convert.ToInt32(button.Tag) == item.RendezvousTimeId) { button.Enabled = false; button.BackColor = Color.LightGray; button.ForeColor = Color.Black; } } pnlSessionList.Controls.Add(button); } } }