private void txtCode_Leave(object sender, EventArgs e) { // Check if entered code already exists if (txtCode.ReadOnly) { return; } if (LocationFacade.Exists(txtCode.Text.Trim())) { MessageFacade.Show(this, ref fMsg, LabelFacade.sy_msg_prefix + MessageFacade.code_already_exists, LabelFacade.sy_location); } }
private bool IsValidated() { var sMsg = new StringBuilder(); Control cFocus = null; string Code = txtCode.Text.Trim(); if (Code.Length == 0) { sMsg.AppendLine(LabelFacade.sy_msg_prefix + MessageFacade.code_not_empty); cFocus = txtCode; } else if (LocationFacade.Exists(Code, Id)) { sMsg.AppendLine(LabelFacade.sy_msg_prefix + MessageFacade.code_already_exists); cFocus = txtCode; } if (cboType.SelectedIndex == -1) { sMsg.AppendLine(LabelFacade.sy_msg_prefix + MessageFacade.location_type_not_empty); if (cFocus == null) { cFocus = cboType; } } if (txtEmail.Text.Length > 0 && !Util.IsEmailValid(txtEmail.Text)) { sMsg.AppendLine(LabelFacade.sy_msg_prefix + MessageFacade.email_not_valid); if (cFocus == null) { cFocus = txtEmail; } } if (sMsg.Length > 0) { MessageFacade.Show(this, ref fMsg, sMsg.ToString(), LabelFacade.sy_save); //fMsg.Show(sMsg.ToString(), LabelFacade.sy_save, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cFocus.Focus(); return(false); } return(true); }