示例#1
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            bool check = false;

            if (temp_course_list.SelectedItems.Count >= 1)
            {
                if (course_list_items.Count == 0)
                {
                    MessageBox.Show("This course is already exist in the current schedule");
                    return;
                }
                try
                {
                    hour = Start.Text + "-" + End.Text;
                    ListViewGroup group = new ListViewGroup(temp_course_list.SelectedItems[0].Text);
                    ListViewItem  item  = new ListViewItem(group);
                    item.Text = temp_course_list.SelectedItems[0].Text;
                    Course_list.Items.Add(item);
                    Course_list.Groups.Add(group);
                    DataBase db = new DataBase();
                    check = db.InsertSce(course_list_items[0], Int32.Parse(course_list_items[1]), course_list_items[2], course_list_items[3], course_list_items[4], course_list_items[5], Int32.Parse(course_list_items[6]), Int32.Parse(course_list_items[7]), course_list_items[8], course_list_items[9], course_list_items[10], course_list_items[11], course_list_items[12], course_list_items[13], course_list_items[14], course_list_items[15], course_list_items[16]);
                    course_list_items.Clear();
                    temp_course_list.Clear();
                }
                catch (Exception)

                {
                    MessageBox.Show("Couldn't connect to sql server");
                }
                if (check)
                {
                    MessageBox.Show("The course was successfully added");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error occurred");
                }
            }
            else
            {
                MessageBox.Show("Your Course details list is empty");
            }
        }