Ejemplo n.º 1
0
        //Add button
        private void btnSave_Click(object sender, EventArgs e)
        {
            //........................Validation..........................

            if (cmdLecturer1.Text == "")
            {
                MessageBox.Show("Please Select Lecturer!");
            }

            else if (cmdGroup.Text == "")
            {
                MessageBox.Show("Please Select Group!");
            }

            else if (cmdSubject.Text == "")
            {
                MessageBox.Show("Please Select Subject!");
            }

            else if (cmdTag.Text == "")
            {
                MessageBox.Show("Please Select Sub Tag!");
            }

            else if (cmdSubGroup.Text == "")
            {
                MessageBox.Show("Please Select Sub Group!");
            }

            else if (txtNoOfStudent.Text == "")
            {
                MessageBox.Show("Please Insert Number of Student!");
            }

            else if (cmdDuration.Text == "")
            {
                MessageBox.Show("Please Select Time Duration!");
            }

            else if (System.Text.RegularExpressions.Regex.IsMatch(txtNoOfStudent.Text, "[^0-9]"))
            {
                MessageBox.Show("Please Enter Number Only For No Of Students!");
            }

            else
            {
                //get the value from the inpute fileds

                s.LecturerName1   = cmdLecturer1.Text;
                s.LecturerName2   = cmdLecturer2.Text;
                s.StudentGroup    = cmdGroup.Text;
                s.Subject         = cmdSubject.Text;
                s.Tag             = cmdTag.Text;
                s.StudentSubGroup = cmdSubGroup.Text;
                s.NoOfStudent     = int.Parse(txtNoOfStudent.Text);
                s.Duration        = cmdDuration.Text;

                //Insert data into data using the method we created
                bool success = s.Insert(s);
                if (success == true)
                {
                    MessageBox.Show("New Session Successfully Inserted!");
                    Clear();
                }
                else
                {
                    MessageBox.Show("Failed to Add new Session...Try Again!");
                }
            }
        }