public Student CreateStudent() { Student NewStudent = new Student(); NewStudent.FirstName = FirstNameBox.Text; NewStudent.LastName = LastNameBox.Text; double.TryParse(GPABox.Text, out double GPA); NewStudent.GPA = GPA; NewStudent.Major = MajorBox.Text; StudentListBox.Items.Add(NewStudent); FirstNameBox.Clear(); LastNameBox.Clear(); GPABox.Clear(); MajorBox.Clear(); return(NewStudent); }
private void SubmitInfor_Click(object sender, RoutedEventArgs e) { double GPA; bool Success; int streetnumber; if (int.TryParse(streetNumberBox.Text, out streetnumber) == false) { Success = false; MessageBox.Show("Enter a valid Street Number"); } int Zip; if (int.TryParse(ZipcodeBox.Text, out Zip) == false) { Success = false; MessageBox.Show("Enter valid Zip Code"); } Student NewStudent = new Student() { FirstName = FirstNameBox.Text, LastName = LastNameBox.Text, GPA = Convert.ToDouble(GPABox.Text), Major = MajorBox.Text }; Address StudentAddress = new Address() { StreetNumber = streetnumber, StreetName = streetNameBox.Text, State = stateBox.Text, City = cityBox.Text, ZipCode = Zip }; NewStudent.SetAddress( streetnumber, streetNameBox.Text, stateBox.Text, cityBox.Text, Zip ); cityBox.Clear(); FirstNameBox.Clear(); LastNameBox.Clear(); GPABox.Clear(); MajorBox.Clear(); stateBox.Clear(); streetNameBox.Clear(); streetNumberBox.Clear(); ZipcodeBox.Clear(); //Address NewStudentAddress = new Address(); //{ // NewStudentAddress.StreetNumber = streetnumber; // NewStudentAddress.StreetName = streetNameBox.Text; // NewStudentAddress.State = stateBox.Text; // NewStudentAddress.City = cityBox.Text; // NewStudentAddress.ZipCode = Zip; //} ////NewStudentAddress(streetnumber, streetNameBox.Text, stateBox.Text, cityBox.Text, Zip); //NewStudent.SetAddress(NewStudentAddress); StudentListBox.Items.Add(NewStudent); }