bool gGender = false;
if (radioBtnMale.Checked == true)
gGender = true;
if (!string.IsNullOrEmpty(txtboxName.Text))
{
if (imageToByteArray(Image.FromFile(openFileDialogPhoto.FileName)) == null)
{
repository.WorkflowsRepository.AddEmployee(txtboxName.Text, dateTimePickerBirthDate.Value, dateTimePickerHireDate.Value, gGender, txtboxMobile.Text, txtboxAddress.Text, txtboxEmail.Text,null);
}
repository.WorkflowsRepository.AddEmployee(txtboxName.Text, dateTimePickerBirthDate.Value, dateTimePickerHireDate.Value, gGender, txtboxMobile.Text, txtboxAddress.Text, txtboxEmail.Text, imageToByteArray(Image.FromFile(openFileDialogPhoto.FileName)));
Information WFNameInfo = new Information("Massege", "The Employee " + txtboxName.Text + " was Added successfully");
WFNameInfo.ShowDialog();
}
else
{
Error err = new Error("The Employee must have a name, please try again");
err.ShowDialog();
}
In this example I want to add an employee, but when an employee don't have a photo I mean the OpenFileDialog
don't have any value it returns an exception at add operation.
I need to be able to add an employee without a photo!!