using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Markup; using System.Windows.Threading; using Gestor.Application.Drawers; using Gestor.Application.Helpers; using Gestor.Application.Servicos; using Gestor.Application.ViewModels.BI; using Gestor.Application.Views.Generic; using Gestor.Common.Validation; using Gestor.Model.Common; using Gestor.Model.Domain.Generic; using Gestor.Model.Domain.Seguros; namespace Gestor.Application.Views.BI; public class ProspeccaoView : BaseUserControl, IComponentConnector, IStyleConnector { private bool openProsceccao; internal DatePicker InicioBox; internal DatePicker FimBox; internal AutoCompleteBox AutoCompleteFornecedor; internal MenuItem MaisOpcoesButton; private bool _contentLoaded; public ProspeccaoViewModel ViewModel { get; set; } public ProspeccaoView() { ((FrameworkElement)this).Tag = "PROSPECTAR"; ViewModel = new ProspeccaoViewModel(); ((FrameworkElement)this).DataContext = ViewModel; Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher; if (dispatcher != null) { dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad)); } InitializeComponent(); } private async void ContentLoad() { await ViewModel.CarregaProspeccao(); await ViewModel.CarregarPermissao(); } private async void Periodo_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) { await ViewModel.CarregarProspeccoes(); } private async void Vendedor_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { await ViewModel.CarregarProspeccoes(); } private async void StatusProspeccao_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { await ViewModel.CarregarProspeccoes(); } private async void CriarProspeccao_OnClick(object sender, RoutedEventArgs e) { if (!(await ViewModel.BuscaPermissao("Incluir"))) { await ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA INCLUIR PROSPECÇÃO. CONTATE O ADMINISTRADOR DO SISTEMA."); } else if (!openProsceccao) { openProsceccao = true; Prospeccao data = new Prospeccao { Status = (StatusProspeccao)1, Renovacao = true }; ViewModel.Loading(isLoading: true); await AbrirProspeccao(data); openProsceccao = false; ViewModel.Loading(isLoading: false); } } private async Task AbrirProspeccao(Prospeccao data) { if (!(await ViewModel.BuscaPermissao("Alterar"))) { await ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ALTERAR PROSPECÇÃO. CONTATE O ADMINISTRADOR DO SISTEMA."); return; } InicioBox.Text = ValidationHelper.FormatDate(InicioBox.Text); FimBox.Text = ValidationHelper.FormatDate(FimBox.Text); try { ViewModel.Inicio = Convert.ToDateTime(InicioBox.Text); ViewModel.Fim = Convert.ToDateTime(FimBox.Text); } catch (Exception) { return; } Prospeccao tarefa; while (true) { bool inclusao = ((DomainBase)data).Id == 0; tarefa = await ViewModel.ShowProspeccaoDialog(data); if (tarefa == null) { if (!inclusao) { await ViewModel.CarregarProspeccoes(); ViewModel.SelectedProspeccao = ((IEnumerable)ViewModel.ProspeccoesFiltradas).FirstOrDefault((Func)((Prospeccao x) => ((DomainBase)x).Id == ((DomainBase)data).Id)); } return; } List> list = await ViewModel.Salvar(data); if (list == null || list.Count == 0) { break; } await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK"); } string text = ((((DomainBase)tarefa).Id == 0L) ? "INCLUIU" : "ALTEROU"); ViewModel.RegistrarAcao(text + " PROSPECÇÃO \"" + tarefa.Nome + "\"", ((DomainBase)tarefa).Id, (TipoTela)33, $"CLIENTE \"{tarefa.Nome}\", ID: {((DomainBase)tarefa).Id}"); ViewModel.ToggleSnackBar("PROSPECÇÃO SALVA COM SUCESSO."); await ViewModel.CarregarProspeccoes(); } private void AutoCompleteBoxDetalhe_Populating(object sender, PopulatingEventArgs e) { e.Cancel = true; ViewModel.FiltrarProspecao(ValidationHelper.RemoveDiacritics(e.Parameter.Trim())).ContinueWith(delegate(Task> searchResult) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (searchResult.Result != null) { AutoCompleteBox val = (AutoCompleteBox)sender; val.ItemsSource = searchResult.Result; val.PopulateComplete(); } }, TaskScheduler.FromCurrentSynchronizationContext()); } private async void Control_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { DataGrid val = (DataGrid)sender; if (val == null || ((Selector)val).SelectedIndex >= 0) { Prospeccao data = (Prospeccao)((val != null) ? ((ItemsControl)val).Items[((Selector)val).SelectedIndex] : null); ViewModel.Loading(isLoading: true); await AbrirProspeccao(data); ViewModel.Loading(isLoading: false); } } private async void EditarProspeccao_OnClick(object sender, RoutedEventArgs e) { Prospeccao data = (Prospeccao)((FrameworkElement)(Button)sender).DataContext; ViewModel.Loading(isLoading: true); await AbrirProspeccao(data); ViewModel.Loading(isLoading: false); } private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) { if (!(await ViewModel.BuscaPermissao("Alterar"))) { await ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ALTERAR PROSPECÇÃO. CONTATE O ADMINISTRADOR DO SISTEMA."); return; } if (!new PermissaoArquivoDigitalServico().BuscarPermissao(Recursos.Usuario, (TipoArquivoDigital)11).Consultar) { await ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE " + ValidationHelper.GetDescription((Enum)(object)(TipoArquivoDigital)11) + "."); return; } Prospeccao val = (Prospeccao)((FrameworkElement)(Button)sender).DataContext; FiltroArquivoDigital filtro = new FiltroArquivoDigital { Id = ((DomainBase)val).Id, Tipo = (TipoArquivoDigital)11, Parente = val }; ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtro), 0, close: false); } private async void ExcluirProspeccao_OnClick(object sender, RoutedEventArgs e) { if (!(await ViewModel.BuscaPermissao("Excluir"))) { await ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA EXCLUIR PROSPECÇÃO. CONTATE O ADMINISTRADOR DO SISTEMA."); return; } Prospeccao prospeccao = (Prospeccao)((FrameworkElement)(Button)sender).DataContext; ViewModel.Excluir(prospeccao); } private void AbrirLog_OnClick(object sender, RoutedEventArgs e) { ViewModel.AbrirLog((TipoTela)33, ((DomainBase)ViewModel.SelectedProspeccao).Id); } private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) { ViewModel.AbrirLogEmail((TipoTela)33, ((DomainBase)ViewModel.SelectedProspeccao).Id); } private async void Imprimir_OnClick(object sender, RoutedEventArgs e) { InicioBox.Text = ValidationHelper.FormatDate(InicioBox.Text); FimBox.Text = ValidationHelper.FormatDate(FimBox.Text); try { ViewModel.Inicio = Convert.ToDateTime(InicioBox.Text); ViewModel.Fim = Convert.ToDateTime(FimBox.Text); } catch (Exception) { return; } await ViewModel.Print(); } private async void Excel_OnClick(object sender, RoutedEventArgs e) { InicioBox.Text = ValidationHelper.FormatDate(InicioBox.Text); FimBox.Text = ValidationHelper.FormatDate(FimBox.Text); try { ViewModel.Inicio = Convert.ToDateTime(InicioBox.Text); ViewModel.Fim = Convert.ToDateTime(FimBox.Text); } catch (Exception) { return; } await ViewModel.GerarExcel(); } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] public void InitializeComponent() { if (!_contentLoaded) { _contentLoaded = true; Uri uri = new Uri("/Gestor.Application;component/views/bi/prospeccaoview.xaml", UriKind.Relative); Application.LoadComponent((object)this, uri); } } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] internal Delegate _CreateDelegate(Type delegateType, string handler) { return Delegate.CreateDelegate(delegateType, this, handler); } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] [EditorBrowsable(EditorBrowsableState.Never)] void IComponentConnector.Connect(int connectionId, object target) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown switch (connectionId) { case 1: ((Selector)(ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(Vendedor_OnSelectionChanged); break; case 2: ((Selector)(ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(StatusProspeccao_OnSelectionChanged); break; case 3: InicioBox = (DatePicker)target; ((UIElement)InicioBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); ((UIElement)InicioBox).PreviewKeyDown += new KeyEventHandler(base.DatePicker_PreviewKeyDown); ((Control)InicioBox).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick); InicioBox.SelectedDateChanged += Periodo_OnSelectedDateChanged; break; case 4: FimBox = (DatePicker)target; ((UIElement)FimBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); ((UIElement)FimBox).PreviewKeyDown += new KeyEventHandler(base.DatePicker_PreviewKeyDown); ((Control)FimBox).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick); FimBox.SelectedDateChanged += Periodo_OnSelectedDateChanged; break; case 5: AutoCompleteFornecedor = (AutoCompleteBox)target; AutoCompleteFornecedor.Populating += new PopulatingEventHandler(AutoCompleteBoxDetalhe_Populating); break; case 6: ((MenuItem)target).Click += new RoutedEventHandler(Imprimir_OnClick); break; case 7: ((MenuItem)target).Click += new RoutedEventHandler(Excel_OnClick); break; case 8: ((MenuItem)target).Click += new RoutedEventHandler(CriarProspeccao_OnClick); break; case 9: MaisOpcoesButton = (MenuItem)target; break; case 10: ((MenuItem)target).Click += new RoutedEventHandler(AbrirLog_OnClick); break; case 11: ((MenuItem)target).Click += new RoutedEventHandler(AbrirLogEmail_OnClick); break; case 12: ((Control)(DataGrid)target).MouseDoubleClick += new MouseButtonEventHandler(Control_OnMouseDoubleClick); break; default: _contentLoaded = true; break; } } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] [EditorBrowsable(EditorBrowsableState.Never)] void IStyleConnector.Connect(int connectionId, object target) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown switch (connectionId) { case 13: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(ExcluirProspeccao_OnClick); break; case 14: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(AbrirAquivoDigital_Click); break; case 15: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(EditarProspeccao_OnClick); break; } } }