protected void OnShowMessage(ShowMessageEventArgs e) { ShowMessageEventHandler handler = Events[EventShowMessage] as ShowMessageEventHandler; if (handler != null && e is ShowMessageEventArgs) { handler(this, e); } }
internal bool ValidateRow(int index, DataRowView rowView, InfoNavigator nav) { bool isValidateSuccessful = true; bool continueToValidate = true; DataTable table = rowView.Row.Table; if (this.ValidActive) { foreach (FieldItem fieldItem in this.FieldItems) { if (fieldItem.FieldName == null || fieldItem.FieldName == "") { continue; } DataColumn column = table.Columns[fieldItem.FieldName]; if (column != null) { // Validate funtion Object obj = fieldItem.Validate; if (obj != null) { string validateValue = GetValidateValue(fieldItem.Validate.Trim()); if (continueToValidate && validateValue != null && validateValue != "") { if (OwnerComp is Form) { Type t = OwnerComp.GetType(); MethodInfo method = null; try { method = t.GetMethod(validateValue, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch (AmbiguousMatchException) { MessageBox.Show("More than one " + fieldItem.Validate.Trim() + " Method found, Please Rename the Validate Method of Field " + fieldItem.FieldName); continue; } if (method == null || method.ReturnType.FullName != "System.Boolean" || method.GetParameters().GetLength(0) != 1/* || method.GetParameters()[0].ParameterType.FullName != "System.Object"*/) { //language = CliSysMegLag.GetClientLanguage(); String message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "DefaultValidate", "msg_ValidMethodNotFound"); Exception ex = new Exception(string.Format(message, validateValue + "()")); CliUtils.Application_ThreadException(null, new System.Threading.ThreadExceptionEventArgs(ex)); goto EndValidateField; // add by andy 2006.06.07 } bool isValid = (bool)method.Invoke(OwnerComp, new object[] { rowView.Row[column].ToString() }); if (isValid == false) { isValidateSuccessful = false; ShowMessageEventHandler showMessageHandler = Events[EventShowMessage] as ShowMessageEventHandler; if (showMessageHandler == null) { string message = ""; if (fieldItem.WarningMsg != null && fieldItem.WarningMsg != "") { message = fieldItem.WarningMsg; } else { message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "DefaultValidate", "msg_DefaultValidateCheckMethod"); } this.Warn(message); } else { ShowMessageEventArgs showMessageArgs = new ShowMessageEventArgs(true); showMessageArgs.Collection = this.m_bindingSource.List; showMessageArgs.Index = index; showMessageArgs.FieldName = fieldItem.FieldName; OnShowMessage(showMessageArgs); continueToValidate = showMessageArgs.Continue; } this.BindingSource.CheckSucess = false; //2006/08/01 if (nav != null) { this.BindingSource.bChk = true; this.BindingSource.CheckSucess = false; //modified by lily 2007/4/25 for state if (nav.GetCurrentState() != "Inserting") { nav.SetState("Editing"); } } //2006/08/01 } } EndValidateField: ; } } } } // Invoke OnValidate OnValidate(new ValidateEventArgs(isValidateSuccessful)); } return isValidateSuccessful; }