private void AddUserBtn_Click(object sender, EventArgs e) { if (!FormValidator.FirstNameValidation(FirstNameBox.Text)) { string invalidMessage = "Invalid first name.\nValid first name contains:" + "\n-letters only\n-one uppercase letter at the beginnig" + "\n-at least one lowercase letter\n-max 25 letters"; errorProvider1.SetError(FirstNameBox, invalidMessage); return; } if (!FormValidator.LastNameValidation(LastNameBox.Text)) { string invalidMessage = "Invalid last name.\nValid last name contains:" + "\n-letters only\n-one uppercase letter at the beginnig\n-max 25 letters"; errorProvider1.SetError(LastNameBox, invalidMessage); return; } errorProvider1.Clear(); _dataBase.AddUser(FirstNameBox.Text, LastNameBox.Text); FirstNameBox.Clear(); LastNameBox.Clear(); UpdateUsersBox(); }
private void EmptyTextBox() { FirstNameBox.Clear(); LastNameBox.Clear(); EmailBox.Clear(); PasswordBox.Clear(); ConPasswordBox.Clear(); }
private void Button_Add(object sender, RoutedEventArgs e) { Contact Contact = new Contact(); Contact.FirstName = FirstNameBox.Text; Contact.LastName = LastNameBox.Text; Contact.Email = EmailAddressBox.Text; Contact.Phone = PhoneNumberBox.Text; Contacts.Add(Contact); FirstNameBox.Clear(); LastNameBox.Clear(); EmailAddressBox.Clear(); PhoneNumberBox.Clear(); }
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); }
//Fonction qui permet d'appeler la page 2 "Principal" private void Submit_Button(object sender, RoutedEventArgs e) { //Vefification si la TextBox est vide if (FirstNameBox.Text.Length < 1 || LastNameBox.Text.Length < 1) { if (FirstNameBox.Text.Length < 1) { FirstNameBox.Text = "Please enter your first name"; FirstNameBox.SetCurrentValue(ForegroundProperty, Brushes.Red); ErrorFN = true; } if (LastNameBox.Text.Length < 1) { LastNameBox.Text = "Please enter your last name"; LastNameBox.SetCurrentValue(ForegroundProperty, Brushes.Red); ErrorLN = true; } } else { if (ErrorFN == false && ErrorLN == false) { try { User.Load(); PageChange?.Invoke(2, User); } catch (Exception) { MessageBoxResult ret = MessageBox.Show("This profile does not exist yet, do you want to create a new one?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (ret == MessageBoxResult.Yes) { User.Save(); PageChange?.Invoke(2, User); } } } } }
private void saveBtn(object sender, RoutedEventArgs e) { try { var suppModel = new supplier { SupplierID = int.Parse(SuppIdBox.Text), FirstName = FirstNameBox.Text, LastName = LastNameBox.Text, Address = AddressBox.Text, City = CityBox.Text, PinCode = int.Parse(PinCodeBox.Text), PhoneNumber = int.Parse(PhoneNrBox.Text), Email = EmailBox.Text, DateJoin = DateJoinPicker.SelectedDate, SupplierOf = SuppBox.Text, }; SuppIdBox.Clear(); FirstNameBox.Clear(); LastNameBox.Clear(); AddressBox.Clear(); CityBox.Clear(); PinCodeBox.Clear(); PhoneNrBox.Clear(); EmailBox.Clear(); SuppBox.Clear(); dc.suppliers.InsertOnSubmit(suppModel); dc.SubmitChanges(); MessageBox.Show("Supplier has been added"); LoadData(); LoadWindow(); } catch { MessageBox.Show("u need to fill out all fields correct"); } }
private void Clear_form() { modify = false; SaveButton.Enabled = false; DeleteButton.Enabled = false; FirstNameBox.Clear(); MiddleNmeBox.Clear(); LastNameBox.Clear(); GenderBox.Clear(); Address1Box.Clear(); Address2Box.Clear(); CityBox.Clear(); StateBox.Clear(); ZipCodeBox.Clear(); EmailBox.Clear(); PhoneNumberBox.Clear(); ResultList.SelectedItems.Clear(); DateReceivedPicker.Value = DateTime.Today; StartTimeBox.Clear(); SaveTimeBox.Clear(); BackNumBox.Clear(); }
private void saveBtn(object sender, RoutedEventArgs e) { try { var empModel = new employee { EmployeeID = int.Parse(EmpIdBox.Text), FirstName = FirstNameBox.Text, LastName = LastNameBox.Text, Address = AddressBox.Text, City = CityBox.Text, PinCode = int.Parse(PinCodeBox.Text), PhoneNumber = int.Parse(PhoneNrBox.Text), Email = EmailBox.Text, JoinDate = DateJoinPicker.SelectedDate }; EmpIdBox.Clear(); FirstNameBox.Clear(); LastNameBox.Clear(); AddressBox.Clear(); CityBox.Clear(); PinCodeBox.Clear(); PhoneNrBox.Clear(); EmailBox.Clear(); dc.employees.InsertOnSubmit(empModel); dc.SubmitChanges(); MessageBox.Show("Employee has been added"); LoadData(); LoadWindow(); } catch { MessageBox.Show("Thats not a valid action"); } }
public void EnterUserDetails(IWebDriver driver, string preferredTitle, string firstName, string lastName, string mobileNumber, string password, string confirmPassword) { // Select Title from dropdown list var title = driver.FindElement(By.Id("title")); var selectElement = new SelectElement(title); selectElement.SelectByValue(preferredTitle); // Enter First Name FirstNameBox.SendKeys(firstName); // Select Last Name LastNameBox.SendKeys(lastName); // Enter mobile number MobileNumberBox.SendKeys(mobileNumber); // Enter password PasswordBox.SendKeys(password); // Confirm password ConfirmPasswordBox.SendKeys(confirmPassword); }
/// <summary> /// Clears all fields and sets necessary enables/disables to /// prepare for new customer entry into database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewCustomerButton_Click(object sender, EventArgs e) { FirstNameBox.Clear(); LastNameBox.Clear(); AddressBox.Clear(); CityBox.Clear(); StateBox.Clear(); ZipBox.Clear(); PhoneBox.Clear(); EmailBox.Clear(); CustomerSelectBox.Enabled = false; CancelButton.Enabled = true; SaveButton.Enabled = true; return; /* * // When add customer button is first clicked, display message and disable box. * if (CustomerSelectBox.Enabled == true) * { * MessageBox.Show("To add a customer, fill in the fields and click Add Customer again", "Add Customer"); * CustomerSelectBox.Enabled = false; * return; * } * * // Once form is in "add customer" mode, add customer normally. * else * { * bool valid = true; // Boolean will be set to false if any tests fail, used to check if customer should be saved. * if (FirstNameBox.Text == "" || Regex.IsMatch(FirstNameBox.Text, name)) * { * MessageBox.Show("Please enter your first name", "First name is a required field"); * FirstNameBox.Focus(); * valid = false; * } * if (LastNameBox.Text == "" || Regex.IsMatch(LastNameBox.Text, name)) * { * MessageBox.Show("Please enter your last name", "Last name is a required field"); * LastNameBox.Focus(); * valid = false; * } * if (AddressBox.Text == "" || Regex.IsMatch(AddressBox.Text, address)) * { * MessageBox.Show("Please enter your address", "Address is a required field"); * AddressBox.Focus(); * valid = false; * } * if (CityBox.Text == "" || Regex.IsMatch(CityBox.Text, name)) * { * MessageBox.Show("Please enter your city", "City is a required field"); * CityBox.Focus(); * valid = false; * } * if (StateBox.Text == "" || Regex.IsMatch(StateBox.Text, name)) * { * MessageBox.Show("Please enter your state", "State is a required field"); * StateBox.Focus(); * valid = false; * } * if (ZipBox.Text == "" || Regex.IsMatch(ZipBox.Text, zip)) * { * MessageBox.Show("Please enter your zip code", "Zip Code is a required field"); * ZipBox.Focus(); * valid = false; * } * if (PhoneBox.Text == "" || Regex.IsMatch(PhoneBox.Text, phone)) * { * MessageBox.Show("Please enter your phone number", "Phone number is a required field"); * PhoneBox.Focus(); * valid = false; * } * if (EmailBox.Text == "" || Regex.IsMatch(EmailBox.Text, email)) * { * MessageBox.Show("Please enter your email address", "Email is a required field"); * EmailBox.Focus(); * valid = false; * } * * // If no issues, add customer to text file and ComboBox. * if (valid) * { * Customer tempCustomer = new Customer(FirstNameBox.Text, LastNameBox.Text, AddressBox.Text, CityBox.Text, StateBox.Text, ZipBox.Text, PhoneBox.Text, EmailBox.Text); * customers.Add(tempCustomer); * * // Close reader and inFile even if exception is thrown. * // SRC:https://stackoverflow.com/questions/86766/how-to-properly-handle-exceptions-when-performing-file-io * try * { * using (FileStream outFile = new FileStream("customers.txt", FileMode.Append, FileAccess.Write)) * using (StreamWriter writer = new StreamWriter(outFile)) * { * // Write info to file. * writer.WriteLine($"{FirstNameBox.Text},{LastNameBox.Text},{AddressBox.Text},{CityBox.Text},{StateBox.Text},{ZipBox.Text},{PhoneBox.Text},{EmailBox.Text}"); * // Clear Text Boxes. * FirstNameBox.Clear(); * LastNameBox.Clear(); * AddressBox.Clear(); * CityBox.Clear(); * StateBox.Clear(); * ZipBox.Clear(); * PhoneBox.Clear(); * EmailBox.Clear(); * CustomerSelectBox.Items.Add(tempCustomer); * CustomerSelectBox.Enabled = true; * } * } * catch (FileNotFoundException) * { * MessageBox.Show("File 'customers.txt' not found to write.", "File Write Error"); * } * // Catch generic I/O exceptions. * catch (IOException ex) * { * MessageBox.Show(ex.ToString(), "Error"); * } * * } * } */ }
/// <summary> /// Clicking button checks if all fields have plausible entires (not empty or wrong format). Then /// updates currently selected customer with new information. Uses email as unique identifier, but /// does not check if email already exists. (Not sure how...) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveButton_Click(object sender, EventArgs e) { bool valid = true; // Boolean will be set to false if any tests fail, used to check if customer should be saved. if (FirstNameBox.Text == "" || !Regex.IsMatch(FirstNameBox.Text, name)) { MessageBox.Show("Please enter your first name", "First name is a required field"); FirstNameBox.Focus(); valid = false; } if (LastNameBox.Text == "" || !Regex.IsMatch(LastNameBox.Text, name)) { MessageBox.Show("Please enter your last name", "Last name is a required field"); LastNameBox.Focus(); valid = false; } if (AddressBox.Text == "" || !Regex.IsMatch(AddressBox.Text, address)) { MessageBox.Show("Please enter your address", "Address is a required field"); AddressBox.Focus(); valid = false; } if (CityBox.Text == "" || !Regex.IsMatch(CityBox.Text, city)) { MessageBox.Show("Please enter your city", "City is a required field"); CityBox.Focus(); valid = false; } if (StateBox.Text == "" || !Regex.IsMatch(StateBox.Text, name)) { MessageBox.Show("Please enter your state", "State is a required field"); StateBox.Focus(); valid = false; } if (ZipBox.Text == "" || !Regex.IsMatch(ZipBox.Text, zip)) { MessageBox.Show("Please enter your zip code", "Zip Code is a required field"); ZipBox.Focus(); valid = false; } if (PhoneBox.Text == "" || !Regex.IsMatch(PhoneBox.Text, phone)) { MessageBox.Show("Please enter your phone number", "Phone number is a required field"); PhoneBox.Focus(); valid = false; } if (EmailBox.Text == "" || !Regex.IsMatch(EmailBox.Text, email)) { MessageBox.Show("Please enter your email address", "Email is a required field"); EmailBox.Focus(); valid = false; } // If invalid entry, do not save. if (!valid) { return; } // Else string ConnectionString = "server=localhost;user=root;database=book store;password="******"Insert into customer values" + $"('null','{FirstNameBox.Text}'," + $"'{LastNameBox.Text}'," + $"'{AddressBox.Text}'," + $"'{CityBox.Text}'," + $"'{StateBox.Text}'," + $"'{ZipBox.Text}'," + $"'{PhoneBox.Text}'," + $"'{EmailBox.Text}')"; cmd.Connection = DBConnect; cmd.ExecuteNonQuery(); DBConnect.Close(); FirstNameBox.Clear(); LastNameBox.Clear(); AddressBox.Clear(); CityBox.Clear(); StateBox.Clear(); ZipBox.Clear(); PhoneBox.Clear(); EmailBox.Clear(); // Call function to update the combobox with new customer added. CustomerSelectBox_Click(sender, e); CustomerSelectBox.Enabled = true; SaveButton.Enabled = false; MessageBox.Show("Customer added to database."); return; } // Else update the currently selected customer with textbox info // Extract first and last name into string array. string[] custName = new string[2]; custName = CustomerSelectBox.Text.Split(); cmd.CommandText = $"Update customer set" + $" first='{FirstNameBox.Text}'," + $"last='{LastNameBox.Text}'," + $"address='{AddressBox.Text}'," + $"city='{CityBox.Text}'," + $"state='{StateBox.Text}'," + $"zip='{ZipBox.Text}'," + $"phone='{PhoneBox.Text}'," + $"email='{EmailBox.Text}'" + $" where first='{custName[0]}' AND last ='{custName[1]}'"; cmd.Connection = DBConnect; cmd.ExecuteNonQuery(); DBConnect.Close(); MessageBox.Show("Customer successfully updated."); return; /* * SaveButton.Enabled = false; // Disable the save button again until new customer is selected from the comboBox. * * // Rewrite the entire file, omitting the line with the email of the customer that is being updated, since email is unique. * // SRC: https://stackoverflow.com/questions/10371630/c-sharp-text-file-search-for-specific-word-and-delete-whole-line-of-text-that-co * Customer tempCustomer = (Customer)(CustomerSelectBox.SelectedItem); * var oldLines = File.ReadAllLines("customers.txt"); * var newLines = oldLines.Where(line => !line.Contains(tempCustomer.email)); * File.WriteAllLines("customers.txt", newLines); * * customers.Remove((Customer)CustomerSelectBox.SelectedItem); // Remove old customer info from customer list. * * // Add new info to list. * tempCustomer = new Customer(FirstNameBox.Text, LastNameBox.Text, AddressBox.Text, CityBox.Text, StateBox.Text, ZipBox.Text, PhoneBox.Text, EmailBox.Text); * customers.Add(tempCustomer); * * // Close reader and inFile even if exception is thrown. * // SRC:https://stackoverflow.com/questions/86766/how-to-properly-handle-exceptions-when-performing-file-io * try * { * using (FileStream outFile = new FileStream("customers.txt", FileMode.Append, FileAccess.Write)) * using (StreamWriter writer = new StreamWriter(outFile)) * { * // Write info to file. * writer.WriteLine($"{FirstNameBox.Text},{LastNameBox.Text},{AddressBox.Text},{CityBox.Text},{StateBox.Text},{ZipBox.Text},{PhoneBox.Text},{EmailBox.Text}"); * } * * // Clear Text Boxes. * FirstNameBox.Clear(); * LastNameBox.Clear(); * AddressBox.Clear(); * CityBox.Clear(); * StateBox.Clear(); * ZipBox.Clear(); * PhoneBox.Clear(); * EmailBox.Clear(); * * // Update comboBox with new info. * CustomerSelectBox.Items.Remove(CustomerSelectBox.SelectedItem); * CustomerSelectBox.Items.Add(tempCustomer); * } * catch (FileNotFoundException) * { * MessageBox.Show("File 'customers.txt' not found to write.", "File Write Error"); * } * // Catch generic I/O exceptions. * catch (IOException ex) * { * MessageBox.Show(ex.ToString(), "Error"); * } */ }
private void SignUp_PrimaryDetails_Load(object sender, EventArgs e) { LastNameBox.Focus(); }
private void RegisterButton_Click(object sender, EventArgs e) { //sets connection var connectionString = ConfigurationManager.ConnectionStrings["EmployeeManagement"].ConnectionString; SqlConnection con = new SqlConnection(connectionString); //opens connection con.Open(); //Creates a command/sql query to select the userid from the database SqlCommand checkUserName = new SqlCommand("Select * from Employees where UserID=@Username", con); SqlCommand checkEmail = new SqlCommand("Select * from Employees where Email=@Email", con); //Trys to add the current data in the UserID text box to the database checkUserName.Parameters.AddWithValue("@Username", this.Username.Text); // same checks for the user id the only diffrence is its the email checkEmail.Parameters.AddWithValue("@Email", this.EmailBox.Text); var result = checkUserName.ExecuteScalar(); var emailResult = checkEmail.ExecuteScalar(); //checks to see if any textboxes are empty if so then it carrys on if (FirstNameBox.Text == "" || LastNameBox.Text == "" || DOBpicker.Text == "" || JobTitleBox.Text == "" || EmailBox.Text == "" || Username.Text == "" || Password.Text == "") { // if a empty a message box shows to ask to enter all fields MessageBox.Show("Please enter all fields!"); //simple return function as we dont want the rest of the code to continue return; } // if both useername and email are not empty and are equal to values in the database it does the following commands if (result != null || emailResult != null) { //if the user name and email is null then set them to red if (result != null && emailResult != null) { Username.BackColor = Color.LightCoral; EmailBox.BackColor = Color.LightCoral; MessageBox.Show("This Username & Email already exist!"); } //if the username is null set the email to green but the username to red else if (result != null) { EmailBox.BackColor = Color.LightGreen; Username.BackColor = Color.LightCoral; MessageBox.Show("This Username already exist!"); } //if the email is null set the email to red and the username to green else if (emailResult != null) { EmailBox.BackColor = Color.LightCoral; Username.BackColor = Color.LightGreen; MessageBox.Show("This Email already exist!"); } //close connection to database con.Close(); } //if no duplicates are found it will move on to adding the data to the database else { // creates a new connection { //creates the new command to insert values into the database but uses values for neater code Random rnd = new Random(); int ID = rnd.Next(2000, 4000); int Employeeid = ID; //SAME AS REGISTER PAGE SqlCommand EmployeeCheck = new SqlCommand("SELECT * from Employees where EmployeeID='" + Employeeid + "'", con); SqlCommand cmd = new SqlCommand("insert into Employees (EmployeeID, FirstName, LastName, DOB, Address, Salary, Department, JobTitle, Role, Email, UserID, Password) " + " values(@EmployeeID, @FirstName, @LastName, @DOB, @Address, @Salary, @Department, @JobTitle, @Role, @Email, @UserID, @Password)", con); SqlDataAdapter da = new SqlDataAdapter(EmployeeCheck); DataSet ds = new DataSet(); da.Fill(ds); int i = ds.Tables[0].Rows.Count; if (i > 0) { MessageBox.Show(i.ToString()); //create a new id int newID = rnd.Next(2000, 10000); cmd.Parameters.AddWithValue("@EmployeeID", newID); cmd.Parameters.AddWithValue("@FirstName", FirstNameBox.Text); cmd.Parameters.AddWithValue("@LastName", LastNameBox.Text); cmd.Parameters.AddWithValue("@DOB", DOBpicker.Text); cmd.Parameters.AddWithValue("@Address", Address.Text); //sets the salary value to the variable based on which role is selected // CLEAN UP ALL IFS STATEMENTS if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Manager") { cmd.Parameters.AddWithValue("@Salary", Manager); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Engineer") { cmd.Parameters.AddWithValue("@Salary", Engineer); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Team Leader") { cmd.Parameters.AddWithValue("@Salary", TeamLeader); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Engineer Scheduler") { cmd.Parameters.AddWithValue("@Salary", EngineerScheduler); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Senior Developer") { cmd.Parameters.AddWithValue("@Salary", SeniorDevelopment); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Programmer") { cmd.Parameters.AddWithValue("@Salary", Programmer); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Anaylst") { cmd.Parameters.AddWithValue("@Salary", Anaylst); } cmd.Parameters.AddWithValue("@Department", DepartmentBox.GetItemText(DepartmentBox.SelectedItem)); cmd.Parameters.AddWithValue("@JobTitle", JobTitleBox.Text); cmd.Parameters.AddWithValue("@Role", RoleBox.GetItemText(RoleBox.SelectedItem)); cmd.Parameters.AddWithValue("@Email", EmailBox.Text); cmd.Parameters.AddWithValue("@UserID", Username.Text); decryptedPassword = Password.Text; //adds the password as normal but adds it as an encrypted value cmd.Parameters.AddWithValue("@Password", PasswordLogin.encryptPassword(Password.Text.Trim())); //passing id cmd.ExecuteNonQuery(); //shows a succesful message MessageBox.Show("Succesfully Registerd!"); FirstNameBox.Clear(); LastNameBox.Clear(); JobTitleBox.Clear(); EmailBox.Clear(); Username.Clear(); Password.Clear(); Address.Clear(); DOBpicker.ResetText(); RoleBox.ResetText(); DepartmentBox.ResetText(); } else { cmd.Parameters.AddWithValue("@EmployeeID", Employeeid); cmd.Parameters.AddWithValue("@FirstName", FirstNameBox.Text); cmd.Parameters.AddWithValue("@LastName", LastNameBox.Text); cmd.Parameters.AddWithValue("@DOB", DOBpicker.Text); cmd.Parameters.AddWithValue("@Address", Address.Text); //sets the salary value to the variable based on which role is selected // CLEAN UP ALL IFS STATEMENTS if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Manager") { cmd.Parameters.AddWithValue("@Salary", Manager); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Engineer") { cmd.Parameters.AddWithValue("@Salary", Engineer); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Team Leader") { cmd.Parameters.AddWithValue("@Salary", TeamLeader); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Engineer Scheduler") { cmd.Parameters.AddWithValue("@Salary", EngineerScheduler); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Senior Developer") { cmd.Parameters.AddWithValue("@Salary", SeniorDevelopment); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Programmer") { cmd.Parameters.AddWithValue("@Salary", Programmer); } else if (RoleBox.GetItemText(RoleBox.SelectedItem) == "Anaylst") { cmd.Parameters.AddWithValue("@Salary", Anaylst); } cmd.Parameters.AddWithValue("@Department", DepartmentBox.GetItemText(DepartmentBox.SelectedItem)); cmd.Parameters.AddWithValue("@JobTitle", JobTitleBox.Text); cmd.Parameters.AddWithValue("@Role", RoleBox.GetItemText(RoleBox.SelectedItem)); cmd.Parameters.AddWithValue("@Email", EmailBox.Text); cmd.Parameters.AddWithValue("@UserID", Username.Text); decryptedPassword = Password.Text; //adds the password as normal but adds it as an encrypted value cmd.Parameters.AddWithValue("@Password", PasswordLogin.encryptPassword(Password.Text.Trim())); cmd.ExecuteNonQuery(); //closes connection con.Close(); //shows a succesful message MessageBox.Show("Succesfully Registerd!"); FirstNameBox.Clear(); LastNameBox.Clear(); JobTitleBox.Clear(); EmailBox.Clear(); Username.Clear(); Password.Clear(); Address.Clear(); DOBpicker.ResetText(); RoleBox.ResetText(); DepartmentBox.ResetText(); } } } }
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); }