Пример #1
0
        private void Lecture_CheckedChanged(object sender, EventArgs e)
        {
            //the function checks if the checkbox that was checked is lecture
            //if it does, the function will load the lectures info into the listboxes accordingly
            int Count = 0, val = 0;

            if (Lecture.Checked && Practice.Checked)
            {
                Practice.Checked = false;
            }
            if (!Lecture.Checked)
            {
                Lecture_Select.Enabled = false;
                Lecture_Select.Enabled = false;
                ID.ResetText();
                ID.Items.Clear();
                Start_Time.ResetText();
                Start_Time.Items.Clear();
                End_Time.ResetText();
                End_Time.Items.Clear();
                Courses.ResetText();
                Courses.Items.Clear();
                Days.ResetText();
                Days.Items.Clear();
                Day.Text = "";
                Teacher_ID.ResetText();
                Teacher_ID.Items.Clear();
                Lecture_Select.Enabled = true;
                Lecture_Select.Items.Clear();
                Lecture_Select.ResetText();
                Search.Enabled = false;
                StartTime.ResetText();
                StartTime.Items.Clear();
                EndTime.ResetText();
                EndTime.Items.Clear();
                Teacher.ResetText();
                Teacher.Items.Clear();
                ClassCombobox.ResetText();
                ClassCombobox.Items.Clear();
                ClassCombobox.Enabled = false;
                Teacher.Enabled       = false;
                StartTime.Enabled     = false;
                EndTime.Enabled       = false;
                Day.Enabled           = false;
            }
            else
            {
                ID.ResetText();
                ID.Items.Clear();
                Start_Time.ResetText();
                Start_Time.Items.Clear();
                End_Time.ResetText();
                End_Time.Items.Clear();
                Courses.ResetText();
                Courses.Items.Clear();
                Days.ResetText();
                Days.Items.Clear();
                Day.Text = "";
                Teacher_ID.ResetText();
                Teacher_ID.Items.Clear();
                Lecture_Select.Enabled = true;
                Lecture_Select.Items.Clear();
                Lecture_Select.ResetText();
                Search.Enabled = false;
                StartTime.ResetText();
                StartTime.Items.Clear();
                EndTime.ResetText();
                EndTime.Items.Clear();
                Teacher.ResetText();
                Teacher.Items.Clear();
                ClassCombobox.ResetText();
                ClassCombobox.Items.Clear();
                ClassCombobox.Enabled = false;
                Teacher.Enabled       = false;
                StartTime.Enabled     = false;
                EndTime.Enabled       = false;
                Day.Enabled           = false;
                if (StartTime.Items.Count == 0)
                {
                    for (int i = 8; i < 21; i++)
                    {
                        StartTime.Items.Add(i + ":00");
                    }
                }
                Lesson = "Lecture";

                if (!SqlWorker.CheckForInternetConnection())
                {
                    MessageBox.Show("There is no internet connection.\nPlease try again later.", "Error"
                                    , MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DataSet TableShow = SqlWorker.GetDataSet("SELECT CourseName , StartTime , Day ,EndTime , Lecturer, ID From Lecture");
                val = TableShow.Tables[0].Rows.Count;
                while (val > Count)
                {
                    Lecture_Select.Items.Add(TableShow.Tables[0].Rows[Count]["ID"].ToString());
                    ID.Items.Add(TableShow.Tables[0].Rows[Count]["ID"].ToString());
                    Courses.Items.Add(TableShow.Tables[0].Rows[Count]["CourseName"].ToString());
                    Start_Time.Items.Add(TableShow.Tables[0].Rows[Count]["StartTime"].ToString());
                    End_Time.Items.Add(TableShow.Tables[0].Rows[Count]["EndTime"].ToString());
                    Days.Items.Add(TableShow.Tables[0].Rows[Count]["Day"].ToString());
                    Teacher_ID.Items.Add(TableShow.Tables[0].Rows[Count]["Lecturer"].ToString());
                    Count++;
                }
            }
        }
        private void Lecture_CheckedChanged(object sender, EventArgs e)
        {
            //the function checks if the checkbox that was checked is lecture
            //if it does, the function will load the lectures info into the listboxes accordingly
            int Count = 0, val = 0;

            if (Lecture.Checked && Practice.Checked)
            {
                Practice.Checked = false;
            }
            if (!Lecture.Checked)
            {
                Lecture_Select.Enabled = false;
                Class_Search.Enabled   = false;
                UpdateDB.Visible       = false;
                Current_Class.Visible  = false;
                Classes.Visible        = false;
                Classes.ResetText();
                Classes.Items.Clear();
            }
            else
            {
                ID.ResetText();
                ID.Items.Clear();
                Start_Time.ResetText();
                Start_Time.Items.Clear();
                End_Time.ResetText();
                End_Time.Items.Clear();
                Courses.ResetText();
                Courses.Items.Clear();
                Days.ResetText();
                Days.Items.Clear();
                Lecture_Select.Enabled = true;
                Lecture_Select.Items.Clear();
                Lecture_Select.ResetText();
                Lesson = "Lecture";

                if (!SqlWorker.CheckForInternetConnection())
                {
                    MessageBox.Show("There is no internet connection.\nPlease try again later.", "Error"
                                    , MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DataSet TableShow = SqlWorker.GetDataSet("SELECT CourseName , StartTime , Day ,EndTime , ID From Lecture");
                val = TableShow.Tables[0].Rows.Count;
                while (val > Count)
                {
                    Lecture_Select.Items.Add(TableShow.Tables[0].Rows[Count]["ID"].ToString());
                    ID.Items.Add(TableShow.Tables[0].Rows[Count]["ID"].ToString());
                    Courses.Items.Add(TableShow.Tables[0].Rows[Count]["CourseName"].ToString());
                    Start_Time.Items.Add(TableShow.Tables[0].Rows[Count]["StartTime"].ToString());
                    End_Time.Items.Add(TableShow.Tables[0].Rows[Count]["EndTime"].ToString());
                    Days.Items.Add(TableShow.Tables[0].Rows[Count]["Day"].ToString());
                    Count++;
                    progressBar1.Value += 100 / val;
                }
                progressBar1.Value = 100;
                MessageBox.Show("Loading completed.", "Load", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                progressBar1.Value = 0;
            }
        }