Exemple #1
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     //Course Name validation
     if (clsValidation.ValidateForEmptiness(CmbCourses.Text) == false)
     {
         MessageBox.Show("Course name is required");
     }
     //Semester Name validation
     else if (clsValidation.ValidateForEmptiness(CmbSemesters.Text) == false)
     {
         MessageBox.Show("Semester name is required");
     }
     //Campus Name validation
     else if (clsValidation.ValidateForEmptiness(CmbCampuses.Text) == false)
     {
         MessageBox.Show("Campus name is required");
     }
     //Class Id validation
     else if (clsValidation.ValidateForEmptiness(TxtClassId.Text) == false)
     {
         MessageBox.Show("Class id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtClassId.Text) == false)
     {
         MessageBox.Show("Class id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtClassId.Text, 5) == false)
     {
         MessageBox.Show("Class id is not 5 digits");
     }
     //Class Name validation
     else if (clsValidation.ValidateForEmptiness(TxtClassName.Text) == false)
     {
         MessageBox.Show("Class name is required");
     }
     //Fee validation
     else if (clsValidation.ValidateForEmptiness(TxtFee.Text) == false)
     {
         MessageBox.Show("Fee is required");
     }
     else
     {
         clsClass ObjClass =
             new clsClass(int.Parse(TxtClassId.Text), TxtClassName.Text,
                          int.Parse(CmbCourses.SelectedValue.ToString()), int.Parse(CmbSemesters.SelectedValue.ToString()),
                          int.Parse(CmbCampuses.SelectedValue.ToString()), double.Parse(TxtFee.Text));
         int classid = ObjClass.AddClass();
         if (classid == -1)
         {
             MessageBox.Show("Can't add this class");
         }
         else
         {
             TxtClassId.Text = classid.ToString();
         }
     }
 }
Exemple #2
0
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     //Class Id validation
     if (clsValidation.ValidateForEmptiness(TxtClassId.Text) == false)
     {
         MessageBox.Show("Class id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtClassId.Text) == false)
     {
         MessageBox.Show("Class id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtClassId.Text, 5) == false)
     {
         MessageBox.Show("Class id is not 5 digits");
     }
     else
     {
         clsClass ObjClass = new clsClass(int.Parse(TxtClassId.Text));
         ObjClass.DeleteClass();
     }
 }