Below is the code for inserting data via input boxes into my table, I have used some data validation already but want to know how to verify that an email address input box is in email format (@ .)
private void ECVSavebutton(object sender, RoutedEventArgs e)
{
string EmployeeAvailability;
if (Job1DropDownBox.Text == "True" && Job2DropDownBox.Text == "True" && Job3DropDownBox.Text == "True")
{
EmployeeAvailability = "False";
} else
{
EmployeeAvailability = "True";
}
{
if (PostcodeInputBox.Text.Count() >= 7)
PostcodeInputBox.Text = null;
}
Connection.Open();
SqlCommand Command = new SqlCommand(null, Connection);
Command.CommandText = "Insert into [StaffDetails] (Forename,Surname,DateofBirth,Emailaddress,Country,Address,City,Postcode,Skill1,Skill2,Skill3,Job1,Job2,Job3,EmployeeAvailability,Location) Values(@forename, @surname, @dateofbirth, @emailaddress, @country, @address, @city, @postcode, @skill1, @skill2, @skill3, @job1, @job2, @job3, @employeeavailability,@location)";
Command.Parameters.AddWithValue("@forename", ForenameInputBox.Text);
Command.Parameters.AddWithValue("@surname", SurnameInputBox.Text);
Command.Parameters.AddWithValue("@dateofbirth", DateOfBirthPicker.SelectedDate);
Command.Parameters.AddWithValue("@emailaddress", EmailInputBox.Text);
Command.Parameters.AddWithValue("@country", CountryInputBox.Text);
Command.Parameters.AddWithValue("@address", AddressInputBox.Text);
Command.Parameters.AddWithValue("@city", CityInputBox.Text);
Command.Parameters.AddWithValue("@postcode", PostcodeInputBox.Text);
Command.Parameters.AddWithValue("@skill1", Skill1DropDownBox.Text);
Command.Parameters.AddWithValue("@skill2", Skill2DropDownBox.Text);
Command.Parameters.AddWithValue("@skill3", Skill3DropDownBox.Text);
Command.Parameters.AddWithValue("@job1", Job1DropDownBox.Text);
Command.Parameters.AddWithValue("@job2", Job2DropDownBox.Text);
Command.Parameters.AddWithValue("@job3", Job3DropDownBox.Text);
Command.Parameters.AddWithValue("@employeeavailability", EmployeeAvailability);
Command.Parameters.AddWithValue("@location", LocationDropDownBox.Text);
Command.ExecuteNonQuery();
Connection.Close();