private void PopulateData()
        {
            foreach (var tutor in _tutorDataTable)
            {
                var tutorName = String.Format("{0} {1}", tutor.tutor_firstname, tutor.tutor_lastname);
                ComboBoxHandler.ComboboxItem item = new ComboBoxHandler.ComboboxItem
                {
                    Text  = tutorName,
                    Value = tutor.tutor_id
                };

                tutorComboBox.Items.Add(item);
            }
        }
Beispiel #2
0
        //TODO if null
        public int PopulateGroupComboBox()
        {
            for (int i = 0; i < _tutorSessionGroup.Count; i++)
            {
                ComboBoxHandler.ComboboxItem item = new ComboBoxHandler.ComboboxItem
                {
                    Text  = String.Format("{0}", _tutorSessionGroup.Rows[i].ItemArray[1]),
                    Value = _tutorSessionGroup.Rows[i].ItemArray[0]
                };

                groupComboBox.Items.Add(item);
            }
            groupComboBox.SelectedIndex = 0;
            return(Convert.ToInt32((groupComboBox.SelectedItem as ComboBoxHandler.ComboboxItem).Value.ToString()));
        }
Beispiel #3
0
        //TODO if null
        private int PopulateStudentActivityComboBox()
        {
            for (int i = 0; i < _studentActivity.Count; i++)
            {
                ComboBoxHandler.ComboboxItem item = new ComboBoxHandler.ComboboxItem
                {
                    Text  = String.Format("{0}", _studentActivity.Rows[i].ItemArray[1]),
                    Value = _studentActivity.Rows[i].ItemArray[0]
                };

                activityComboBox.Items.Add(item);
            }
            activityComboBox.SelectedIndex = 0;
            return(Convert.ToInt32((activityComboBox.SelectedItem as ComboBoxHandler.ComboboxItem).Value.ToString()));
        }
        private void dateComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            timeComboBox.Items.Clear();
            timeComboBox.SelectedItem = null;
            timeComboBox.ResetText();
            timeComboBox.Enabled = false;
            var tutorComboboxItem     = tutorComboBox.SelectedItem as ComboBoxHandler.ComboboxItem;
            var selectedDateComboItem = dateComboBox.SelectedItem as ComboBoxHandler.ComboboxItem;

            if (tutorComboboxItem != null && selectedDateComboItem != null)
            {
                var times = (DateTimes)selectedDateComboItem.Value;
                foreach (var time in times.Times)
                {
                    var cmbItem = new ComboBoxHandler.ComboboxItem();
                    cmbItem.Value = time;
                    cmbItem.Text  = time.Time.ToString();
                    var availableTime = _availableTimesTableAdapter.GetData().FindBytutor_time_id(time.TutorTimesId);
                    if (!availableTime.booked)
                    {
                        timeComboBox.Items.Add(cmbItem);
                    }
                }
                if (timeComboBox.Items.Count > 0)
                {
                    timeComboBox.Enabled = true;
                }
                else
                {
                    MessageBox.Show(SSS_Library.Properties.Resources.ConsultationFullyBookedMessage);
                    ClearForm();
                }
            }
            else
            {
                ClearForm();
            }
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            dateComboBox.Items.Clear();
            dateComboBox.ResetText();
            timeComboBox.Items.Clear();
            timeComboBox.ResetText();
            timeComboBox.SelectedIndex = -1;
            dateComboBox.Enabled       = false;
            timeComboBox.Enabled       = false;

            var tutorComboboxItem = tutorComboBox.SelectedItem as ComboBoxHandler.ComboboxItem;

            if (tutorComboboxItem != null)
            {
                var dateDataTable = tutoR_AVAILABLE_TIMES_SEARCH_BY_TUTORTableAdapter1.GetData(Convert.ToInt32(tutorComboboxItem.Value));

                DateTimeCollection datesAndTimes = new DateTimeCollection();
                //add all unique dates
                foreach (var item in dateDataTable.OrderBy(i => i.date_free))
                {
                    var oneDate = new DateTimes {
                        Date = item.date_free
                    };
                    if (datesAndTimes.FindDateCollection(oneDate) != null)
                    {
                        var foundItem = datesAndTimes.FindDateCollection(oneDate);
                        var times     = new Times
                        {
                            Time         = item.date_free.TimeOfDay,
                            TutorTimesId = item.tutor_time_id
                        };
                        foundItem.Times.Add(times);
                    }
                    else
                    {
                        var times = new Times
                        {
                            Time         = item.date_free.TimeOfDay,
                            TutorTimesId = item.tutor_time_id
                        };
                        oneDate.Times.Add(times);
                        datesAndTimes.CollectionOfDateTimes.Add(oneDate);
                    }
                }

                foreach (var date in datesAndTimes.CollectionOfDateTimes)
                {
                    var cmbItem = new ComboBoxHandler.ComboboxItem
                    {
                        Text  = date.Date.ToLongDateString(),
                        Value = date
                    };
                    dateComboBox.Items.Add(cmbItem);
                }

                dateComboBox.Enabled = true;
            }
            else
            {
                ClearForm();
            }
        }