public virtual void ButtonActive_Click(object sender, System.Windows.RoutedEventArgs e) { if (!IsValid()) { return; } var nameMethod = InvokeMethod.Methods.FirstOrDefault(c => c.Key == TypeExecute.InsertOrUpdate).Value; if (string.IsNullOrEmpty(nameMethod)) { MessageBox.Show("Método InsertOrUpdate não configurado\nController: " + InvokeMethod.TypeController.Name, "ESR Softwares", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } var obj = CurrentControl; // Via reflexão executa método crud, passando o registro atual. if (!SReflection.ExecuteContext(InvokeMethod.TypeController, nameMethod, obj)) { MessageBox.Show("Não foi possível executar a função.", "ESR Softwares", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { MessageBox.Show("Processo concluído.", "ESR Softwares", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Método responsável em executar o crud da tela. /// </summary> /// <param name="typeAction"></param> private bool ExecuteApp(TypeAction typeAction) { var nameMethod = string.Empty; object obj = null; if (typeAction != TypeAction.Insert) { if (typeAction == TypeAction.Remove) { nameMethod = InvokeMethod.Methods.FirstOrDefault(c => c.Key == TypeExecute.Remove).Value; if (string.IsNullOrEmpty(nameMethod)) { MessageBox.Show("Método Remove não configurado\nController: " + InvokeMethod.TypeController.Name, "ESR Softwares", MessageBoxButtons.OK, MessageBoxIcon.Stop); } obj = CurrentControl.Id; } } else { nameMethod = InvokeMethod.Methods.FirstOrDefault(c => c.Key == TypeExecute.InsertOrUpdate).Value; if (string.IsNullOrEmpty(nameMethod)) { MessageBox.Show("Método InsertOrUpdate não configurado\nController: " + InvokeMethod.TypeController.Name, "ESR Softwares", MessageBoxButtons.OK, MessageBoxIcon.Stop); } obj = CurrentControl; } // Via reflexão executa método crud, passando o registro atual. var lReturn = SReflection.ExecuteContext(InvokeMethod.TypeController, nameMethod, obj); return(lReturn); }