private void btnSave_Click(object sender, EventArgs e) { if (IsValid == false) { MessageBox.Show(AllErrors.ErrorMessageString(), Constants.ALERTMESSAGEHEADER); return; } if (txtEmail.Text != String.Empty && !Regex.IsMatch(txtEmail.Text, Constants.EMAILPATTERN)) { txtEmail.Focus(); MessageBox.Show(Resources.frmFirmMaster_btnSave_Click_Please_Enter_Valid_Email_Address_, Constants.ALERTMESSAGEHEADER); return; } if (!txtTAX.Text.IsEmpty() && !txtTAX.Text.IsDecimal()) { MessageBox.Show(Resources.frmFirmMaster_btnSave_Click_Invalid_TAX_field, Constants.ALERTMESSAGEHEADER); return; } if (!txtOtherTAX.Text.IsEmpty() && !txtOtherTAX.Text.IsDecimal()) { MessageBox.Show(Resources.frmFirmMaster_btnSave_Click_Invalid_Other_TAX_field, Constants.ALERTMESSAGEHEADER); return; } if (!txtLogo.Text.IsEmpty() && !File.Exists(txtLogo.Text)) { MessageBox.Show(Resources.frmFirmMaster_btnSave_Click_Invalid_file_Logo_path_, Constants.ALERTMESSAGEHEADER); return; } var firmInfo = _firmService.GetFrimMaster(); var firmMaster = new FirmMaster { FirmName = txtName.Text, FirmEmail = txtEmail.Text, FirmHeader = txtHeaderOrSlogan.Text, FirmWebsite = txtWebsite.Text, FirmVATNumber = txtVATNumber.Text, FirmTINNumber = txtTINNumber.Text, FirmTopHeader = txtTopHeader.Text, FirmAddress = txtAddress.Text, FirmAdditionalInfo = txtAdditionalInformation.Text, Tax = Convert.ToDecimal(txtTAX.Text), OtherTax = Convert.ToDecimal(txtOtherTAX.Text), }; if (firmInfo != null) { firmMaster.FirmMasterId = firmInfo.FirmMasterId; } if (File.Exists(txtLogo.Text)) { var imageIn = Image.FromFile(txtLogo.Text); File.ReadAllBytes(txtLogo.Text); firmMaster.FirmLogo = ImageConverterHelper.ImageToByteArray(imageIn); } var firmRequest = new FirmMasterRequest { FirmMaster = firmMaster }; _firmService.SaveFirm(firmRequest); BindForm(); }