コード例 #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (cbCourse.Text == "")
            {
                MessageBox.Show("Please select a course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                tblSelect.DataSource = null;
                List <Dictionary <string, string> > courses = (List <Dictionary <string, string> >)cbCourse.Tag;
                Dictionary <string, string>         course  = courses[cbCourse.SelectedIndex];
                MessageBox.Show(course["link"]);

                // Load list of classes
                this.Cursor = Cursors.WaitCursor;   // show an Hour-Glass cursor

                Scrapper scrapper = new Scrapper();
                List <Dictionary <string, string> > classes = scrapper.GetClassList(course["link"]);

                // Show data in dataGridView
                for (int i = 0; i < 13; i++)
                {
                    tblSelect.Columns.Add("", "");
                }

                foreach (Dictionary <string, string> className in classes)
                {
                    tblSelect.Rows.Add(new object[]
                    {
                        className["dept"],
                        className["code"],
                        className["serial"],
                        className["classNo"],
                        className["year"],
                        className["category"],
                        className["english"],
                        className["course"],
                        className["type"],
                        className["credit"],
                        className["instructor"],
                        className["schedule"],
                        className["classroom"]
                    });
                }
                this.Cursor = Cursors.Default;  // show default cursor pointer

                // Clear database
                ClearDatabase();

                // Put data into the database
                InputData(1);
            }
        }
コード例 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Kevin
            this.Cursor = Cursors.WaitCursor;   // show an Hour-Glass cursor

            Scrapper scrapper = new Scrapper();
            List <Dictionary <string, string> > courses = scrapper.GetCourseList();

            cbDegree.Tag = courses;
            cbCourse.Tag = courses;

            foreach (Dictionary <string, string> course in courses)
            {
                cbDegree.Items.Add(course["name"]);
                cbCourse.Items.Add(course["name"]);
            }

            this.Cursor = Cursors.Default;  // show default cursor pointer

            //end Kevin
        }
コード例 #3
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (cbDegree.Text != "" && cbYear.Text != "" && cbGender.Text != "")
            {
                Degree = cbDegree.SelectedItem.ToString();
                btnOk.PerformClick();
                Year   = cbYear.SelectedItem.ToString();
                Gender = cbGender.SelectedItem.ToString();


                tblTimeTable.DataSource = null;
                List <Dictionary <string, string> > courses = (List <Dictionary <string, string> >)cbDegree.Tag;
                Dictionary <string, string>         course  = courses[cbDegree.SelectedIndex];
                MessageBox.Show(course["link"]);

                // Load list of classes
                this.Cursor = Cursors.WaitCursor;   // show an Hour-Glass cursor

                Scrapper scrapper = new Scrapper();
                List <Dictionary <string, string> > classes = scrapper.GetClassList(course["link"]);

                // Show data in dataGridView
                for (int i = 0; i < 13; i++)
                {
                    tblTimeTable.Columns.Add("", "");
                }

                foreach (Dictionary <string, string> className in classes)
                {
                    tblTimeTable.Rows.Add(new object[]
                    {
                        className["dept"],
                        className["code"],
                        className["serial"],
                        className["classNo"],
                        className["year"],
                        className["category"],
                        className["english"],
                        className["course"],
                        className["type"],
                        className["credit"],
                        className["instructor"],
                        className["schedule"],
                        className["classroom"]
                    });
                }
                this.Cursor = Cursors.Default;  // show default cursor pointer

                // Clear database
                ClearDatabase();

                // Put data into the database
                InputData(0);
                //label4.Text = tblTimeTable.Rows[0].Cells[11].Value.ToString();

                for (int i = 0; i < tblTimeTable.Rows.Count - 1; i++)
                {
                    int             temp = i;
                    DataGridViewRow row  = tblTimeTable.Rows[temp];
                    Selected_Course_Time = row.Cells[11].Value.ToString();
                    Selected_Course_Name = row.Cells[7].Value.ToString();
                    if (Selected_Course_Name != null && Selected_Course_Time != null)
                    {
                        string[] temp_seperate = Selected_Course_Time.Split(']');
                        if (!Int32.TryParse(temp_seperate[0].Remove(0, 1), out Day))
                        {
                            continue;
                        }

                        if (temp_seperate[1][1] == '~' || temp_seperate[1][2] == '~')
                        {
                            temp_seperate = temp_seperate[1].Split('~');
                            if (temp_seperate[0][0] != 'N')
                            {
                                Start_Course = int.Parse(temp_seperate[0]);
                            }
                            else
                            {
                                Start_Course = 5;
                            }
                            if (temp_seperate[1][0] != 'N')
                            {
                                End_Course = int.Parse(temp_seperate[1]);
                            }
                            else
                            {
                                End_Course = 4;
                            }
                        }
                        else
                        {
                            if (temp_seperate[1][0] == 'N')
                            {
                                Start_Course = 5;
                            }
                            else if (!Int32.TryParse(temp_seperate[1], out Start_Course))
                            {
                                continue;
                            }

                            End_Course = Start_Course;
                        }
                        for (int j = Start_Course; j <= End_Course && j > 0; j++)
                        {
                            DataRow temp_row = TimeTable.Rows.Find(Row_Name[j]);
                            temp_row[Col_Name[Day]] = Selected_Course_Name;
                            Available[Day, j]       = 1;
                        }
                    }
                }
                List_of_Panel[1].BringToFront();
                pnlLogin.Visible  = true;
                pnlTime.Visible   = true;
                pnlSelect.Visible = false;
                List_of_Panel[1].BringToFront();
                pnlTime.Visible         = true;
                tblTimeTable.DataSource = TimeTable;
            }
            else
            {
                MessageBox.Show("Combobox cannot be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }