예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool   check = false;
            string name  = textBox1.Text;

            string credits    = textBox3.Text;
            string lectureH   = textBox4.Text;
            string practiceH  = textBox5.Text;
            string receiptH   = textBox6.Text;
            string semester   = comboBox2.Text;
            string Year       = comboBox4.Text;
            string department = Department_combo.Text;
            string unit       = Unit_combo.Text;
            string PrereqiD   = PreReqID.Text;

            try
            {
                if (name != null && credits != null && lectureH != null && practiceH != null && receiptH != null && Year != null && semester != null && department != null && unit != null)
                {
                    if (Int32.Parse(lectureH) > 0 & Int32.Parse(practiceH) > 0 & Int32.Parse(receiptH) > 0) // & Int32.Parse(Year) > 0)

                    {
                        check = db.InsertCourse(name, credits, lectureH, practiceH, receiptH, semester, Year, department, unit, PrereqiD);
                    }
                }
                if (check)
                {
                    MessageBox.Show("The course" + " " + name + " has been added successfully");
                    ClearAll();
                }
                else
                {
                    MessageBox.Show("Error occured!");
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("Could not insert");
            }
            finally
            {
                if (db.isconnected == true)
                {
                    db.CloseConnection();
                }
            }
        }