Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(textBox1.Text))
            {
                MessageBox.Show("Please enter Course Name");
            }

            else if (!System.Text.RegularExpressions.Regex.IsMatch(textBox1.Text, "^[a-zA-Z]"))
            {
                MessageBox.Show("Please use letters only");
            }

            else
            {
                //Create a new file in the working directory
                XmlTextWriter textWriter = new XmlTextWriter("course.xml", null);

                // Opens the document
                textWriter.WriteStartDocument();

                // Write first element
                textWriter.WriteStartElement("Course Name");
                textWriter.WriteString(textBox1.Text);
                textWriter.WriteEndElement();

                //Ends the document.
                textWriter.WriteEndDocument();

                //Close writer
                textWriter.Close();


                //CourseClass storing name
                CourseClass course = new CourseClass();
                course.CourseName = textBox1.Text;

                Module mod = new Module(course);
                this.Close();
                mod.ShowDialog();

                MySqlConnection con     = new MySqlConnection(connect);
                MySqlCommand    command = con.CreateCommand();

                command.CommandText = "INSERT INTO course(courseName) " + "Values('" + course.CourseName + "')";

                con.Open();
                command.ExecuteNonQuery();
                con.Close();
            }
        }
Beispiel #2
0
        public Module(CourseClass courses)
        {
            InitializeComponent();

            //Start Page
            tab1.Enabled = false;
            tab2.Enabled = false;
            tab3.Enabled = false;

            lvl4sum.Enabled = false;
            lvl5sum.Enabled = false;
            lvl6sum.Enabled = false;

            button2.Enabled = false;
            button3.Enabled = false;
            button7.Enabled = false;

            course = courses;

            modulesList  = new List <ModuleClass>();
            modulesList2 = new List <ModuleClass>();
            modulesList3 = new List <ModuleClass>();

            module  = new ModuleClass();
            module2 = new ModuleClass();
            module3 = new ModuleClass();

            assessmentList  = new List <AssessmentClass>();
            assessmentList2 = new List <AssessmentClass>();
            assessmentList3 = new List <AssessmentClass>();

            assess1 = new AssessmentClass();
            assess2 = new AssessmentClass();
            assess3 = new AssessmentClass();

            module.Assessments  = assessmentList;
            module2.Assessments = assessmentList2;
            module3.Assessments = assessmentList3;

            course.Modules = modulesList;
            course.Modules = modulesList2;
            course.Modules = modulesList3;

            label5.Text = "";
            label7.Text = "";
            label8.Text = "";
        }