コード例 #1
0
ファイル: Index.cs プロジェクト: keithsullivan3/CIS
 //hides the current form and shows form selected by button
 private void btnSurveyForm_Click(object sender, EventArgs e)
 {
     Survey formSurvey = new Survey();
     formSurvey.Show();
     this.Hide();
     formSurvey.FormClosing += formSurvey_Closing;
 }
コード例 #2
0
ファイル: Survey.cs プロジェクト: keithsullivan3/CIS
 private void btnSubmitStudent_Click(object sender, EventArgs e)
 {
     //gets the value of male or female radio buttons and sets it to string "maleOrFemale"
     string maleOrFemale = "";
     if (rbMale.Checked)
     {
         maleOrFemale = "Male";
     }
     else
     {
         maleOrFemale = "Female";
     }
     //gets the value of education level radio buttons and sets it to int "educationlvl"
     int educationlvl = 0;
     if (rbHighschool.Checked)
     {
         educationlvl = 1;
     }
     else if (rbOnTheJobTraining.Checked)
     {
         educationlvl = 2;
     }
     else if (rbCommunityCollege.Checked)
     {
         educationlvl = 3;
     }
     else if (rbTechnicalSchool.Checked)
     {
         educationlvl = 4;
     }
     else if (rbBachelorDegree.Checked)
     {
         educationlvl = 5;
     }
     else if (rbCollegeAndGraduateSchool.Checked)
     {
         educationlvl = 6;
     }
     //gets the value of married radio buttons and sets it to string "marriedOrSingle"
     string married = "";
     if (rbYes.Checked)
     {
         married = "Yes";
     }
     else
     {
         married = "No";
     }
     //assigns Yes to the value of children if married = Yes and cbChildren is checked
     string children = "";
     if (cbChildren.Checked && married == "Yes")
     {
         children = "Yes";
     }
     else
     {
         children = "No";
     }
     int childrenNumber = 0;
     if (rbYes.Checked && cbChildren.Checked && cbChildrenNumber.SelectedIndex != -1)
     {
         childrenNumber = Int32.Parse(cbChildrenNumber.SelectedItem.ToString());
     }
     //assigns Yes to credit if cbCreditCards is Checked
     string credit = "";
     if (cbCreditCards.Checked)
     {
         credit = "Yes";
     }
     else
     {
         credit = "No";
     }
     //and finally we create a Student
     if (tbFirstName.Text != "" && tbLastName.Text != "" && cbSchool.SelectedIndex != 0 && tbPeriod.Text != "" && tbTeacher.Text != "" && cbGroup.SelectedIndex != -1 && maleOrFemale != ""
         && tbGPA.Text != "" && educationlvl != 0 && cbCluster.SelectedIndex != 0 && married != "" && children != "" && credit != "")
     {
         Student s1 = new Student(tbFirstName.Text, tbLastName.Text, Int32.Parse(cbSchool.SelectedValue.ToString()), tbPeriod.Text, tbTeacher.Text, cbGroup.SelectedItem.ToString(), maleOrFemale, double.Parse(tbGPA.Text),
             educationlvl, Int32.Parse(cbOccupation.SelectedValue.ToString()), married, children, childrenNumber, credit, Int32.Parse(cbCreditCardUse.SelectedValue.ToString()));
         s1.display();
         MessageBox.Show("Student added to group " + cbGroup.SelectedItem.ToString());
         this.Close();
         Survey formSurvey = new Survey();
         formSurvey.Show();
     }
     else
     {
         MessageBox.Show("There is some invalid data on the form.  Please make sure that you have filled in all of the values before you try to submit the student.", "Error");
     }
 }