예제 #1
0
        private void btnUpdata_Click(object sender, RoutedEventArgs e)
        {
            //Campus Id validation
            if (clsValidation.ValidateForEmptiness(TxtCampusId.Text) == false)
            {
                MessageBox.Show("Campus id is required");
            }
            else if (clsValidation.ValidateForNumeric(TxtCampusId.Text) == false)
            {
                MessageBox.Show("Campus id is not a number");
            }
            else if (clsValidation.ValidateForLength(TxtCampusId.Text, 5) == false)
            {
                MessageBox.Show("Campus id is not 5 digits");
            }
            //Campus Name validation
            else if (clsValidation.ValidateForEmptiness(TxtCampusName.Text) == false)
            {
                MessageBox.Show("Campus name is required");
            }
            else if (clsValidation.ValidateForEmptiness(TxtCampusAddress.Text) == false)
            {
                MessageBox.Show("Campus address is required");
            }
            else
            {
                //clsTeacher objTeacher = new clsTeacher();
                //objTeacher.TeacherId = int.Parse(TxtTeacherId.Text);


                clsCampus ObjCampus = new clsCampus(int.Parse(TxtCampusId.Text), TxtCampusName.Text, TxtCampusAddress.Text);
                Boolean   Flag      = ObjCampus.UpdateCampus();
            }
        }
예제 #2
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     //Campus Id validation
     if (clsValidation.ValidateForEmptiness(TxtCampusId.Text) == false)
     {
         MessageBox.Show("Campus id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtCampusId.Text) == false)
     {
         MessageBox.Show("Campus id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtCampusId.Text, 5) == false)
     {
         MessageBox.Show("Campus id is not 5 digits");
     }
     //Campus Name validation
     else if (clsValidation.ValidateForEmptiness(TxtCampusName.Text) == false)
     {
         MessageBox.Show("Campus name is required");
     }
     else
     {
         clsCampus ObjCampus = new clsCampus(int.Parse(TxtCampusId.Text), TxtCampusName.Text, TxtCampusAddress.Text);
         int       campusid  = ObjCampus.AddCampus();
         if (campusid == -1)
         {
             MessageBox.Show("Can't add this campus");
         }
         else
         {
             TxtCampusId.Text = campusid.ToString();
         }
     }
 }
예제 #3
0
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     //Campus Id validation
     if (clsValidation.ValidateForEmptiness(TxtCampusId.Text) == false)
     {
         MessageBox.Show("Campus id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtCampusId.Text) == false)
     {
         MessageBox.Show("Campus id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtCampusId.Text, 5) == false)
     {
         MessageBox.Show("Campus id is not 5 digits");
     }
     else
     {
         clsCampus ObjCampus = new clsCampus();
         ObjCampus.CampusId = int.Parse(TxtCampusId.Text);
         ObjCampus.DeleteCampus();
     }
 }
예제 #4
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            //Campus Id validation
            if (clsValidation.ValidateForEmptiness(TxtCampusId.Text) == false)
            {
                MessageBox.Show("Campus id is required");
            }
            else if (clsValidation.ValidateForNumeric(TxtCampusId.Text) == false)
            {
                MessageBox.Show("Campus id is not a number");
            }
            else if (clsValidation.ValidateForLength(TxtCampusId.Text, 5) == false)
            {
                MessageBox.Show("Campus id is not 5 digits");
            }
            else
            {
                clsCampus ObjCampus = new clsCampus();
                ObjCampus.CampusId = int.Parse(TxtCampusId.Text);
                bool found = ObjCampus.SearchCampus();
                if (found)
                {
                    MessageBox.Show("Success to search this campus");
                    TxtCampusId.Text      = ObjCampus.CampusId.ToString();
                    TxtCampusName.Text    = ObjCampus.CampusName.ToString();
                    TxtCampusAddress.Text = ObjCampus.CampusAddress.ToString();
                }
                else
                {
                    MessageBox.Show("This campus id does not exist");

                    TxtCampusName.Text    = "";
                    TxtCampusAddress.Text = "";
                }
            }
        }