From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- Gestor.Application/Views/BI/ProspeccaoView.cs | 422 ++++++++++++++++++++++++++ 1 file changed, 422 insertions(+) create mode 100644 Gestor.Application/Views/BI/ProspeccaoView.cs (limited to 'Gestor.Application/Views/BI/ProspeccaoView.cs') diff --git a/Gestor.Application/Views/BI/ProspeccaoView.cs b/Gestor.Application/Views/BI/ProspeccaoView.cs new file mode 100644 index 0000000..b625599 --- /dev/null +++ b/Gestor.Application/Views/BI/ProspeccaoView.cs @@ -0,0 +1,422 @@ +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.BI; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +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; + +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; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ProspeccaoView() + { + base.Tag = "PROSPECTAR"; + this.ViewModel = new ProspeccaoViewModel(); + base.DataContext = this.ViewModel; + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + this.InitializeComponent(); + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if (!await this.ViewModel.BuscaPermissao("Alterar")) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ALTERAR PROSPECÇÃO. CONTATE O ADMINISTRADOR DO SISTEMA.", "OK", "", false); + } + else if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 11).get_Consultar()) + { + Prospeccao dataContext = (Prospeccao)((Button)sender).DataContext; + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(dataContext.get_Id()); + filtroArquivoDigital.set_Tipo(11); + filtroArquivoDigital.set_Parente(dataContext); + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)11), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(33, this.ViewModel.SelectedProspeccao.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(33, this.ViewModel.SelectedProspeccao.get_Id()); + } + + private async Task AbrirProspeccao(Prospeccao data) + { + bool flag; + string str; + ProspeccaoView.u003cu003ec__DisplayClass11_0 variable; + bool id; + Prospeccao prospeccao; + Func func = null; + if (await this.ViewModel.BuscaPermissao("Alterar")) + { + this.InicioBox.Text = ValidationHelper.FormatDate(this.InicioBox.Text); + this.FimBox.Text = ValidationHelper.FormatDate(this.FimBox.Text); + try + { + this.ViewModel.Inicio = Convert.ToDateTime(this.InicioBox.Text); + this.ViewModel.Fim = Convert.ToDateTime(this.FimBox.Text); + } + catch (Exception exception) + { + variable = null; + return; + } + while (true) + { + id = data.get_Id() == (long)0; + prospeccao = await this.ViewModel.ShowProspeccaoDialog(data); + if (prospeccao == null) + { + goto Label1; + } + List> keyValuePairs = await this.ViewModel.Salvar(data); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag) + { + break; + } + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + prospeccao = null; + } + str = (prospeccao.get_Id() == 0 ? "INCLUIU" : "ALTEROU"); + string str1 = str; + this.ViewModel.RegistrarAcao(string.Concat(str1, " PROSPECÇÃO \"", prospeccao.get_Nome(), "\""), prospeccao.get_Id(), new TipoTela?(33), string.Format("CLIENTE \"{0}\", ID: {1}", prospeccao.get_Nome(), prospeccao.get_Id())); + this.ViewModel.ToggleSnackBar("PROSPECÇÃO SALVA COM SUCESSO.", true); + await this.ViewModel.CarregarProspeccoes(); + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ALTERAR PROSPECÇÃO. CONTATE O ADMINISTRADOR DO SISTEMA.", "OK", "", false); + } + variable = null; + return; + Label1: + if (!id) + { + await this.ViewModel.CarregarProspeccoes(); + ProspeccaoViewModel viewModel = this.ViewModel; + ObservableCollection prospeccoesFiltradas = this.ViewModel.ProspeccoesFiltradas; + Func func1 = func; + if (func1 == null) + { + Func id1 = (Prospeccao x) => x.get_Id() == data.get_Id(); + Func func2 = id1; + func = id1; + func1 = func2; + } + viewModel.SelectedProspeccao = prospeccoesFiltradas.FirstOrDefault(func1); + variable = null; + return; + } + else + { + variable = null; + return; + } + } + + private void AutoCompleteBoxDetalhe_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.FiltrarProspecao(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private async void ContentLoad() + { + await this.ViewModel.CarregaProspeccao(); + await this.ViewModel.CarregarPermissao(); + } + + private async void Control_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + Prospeccao prospeccao = (Prospeccao)obj; + this.ViewModel.Loading(true); + await this.AbrirProspeccao(prospeccao); + this.ViewModel.Loading(false); + } + } + + private async void CriarProspeccao_OnClick(object sender, RoutedEventArgs e) + { + if (!await this.ViewModel.BuscaPermissao("Incluir")) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA INCLUIR PROSPECÇÃO. CONTATE O ADMINISTRADOR DO SISTEMA.", "OK", "", false); + } + else if (!this.openProsceccao) + { + this.openProsceccao = true; + Prospeccao prospeccao = new Prospeccao(); + prospeccao.set_Status(new StatusProspeccao?(1)); + prospeccao.set_Renovacao(true); + Prospeccao prospeccao1 = prospeccao; + this.ViewModel.Loading(true); + await this.AbrirProspeccao(prospeccao1); + this.openProsceccao = false; + this.ViewModel.Loading(false); + } + } + + private async void EditarProspeccao_OnClick(object sender, RoutedEventArgs e) + { + Prospeccao dataContext = (Prospeccao)((Button)sender).DataContext; + this.ViewModel.Loading(true); + await this.AbrirProspeccao(dataContext); + this.ViewModel.Loading(false); + } + + private async void Excel_OnClick(object sender, RoutedEventArgs e) + { + this.InicioBox.Text = ValidationHelper.FormatDate(this.InicioBox.Text); + this.FimBox.Text = ValidationHelper.FormatDate(this.FimBox.Text); + try + { + this.ViewModel.Inicio = Convert.ToDateTime(this.InicioBox.Text); + this.ViewModel.Fim = Convert.ToDateTime(this.FimBox.Text); + } + catch (Exception exception) + { + return; + } + await this.ViewModel.GerarExcel(); + } + + private async void ExcluirProspeccao_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.BuscaPermissao("Excluir")) + { + Prospeccao dataContext = (Prospeccao)((Button)sender).DataContext; + this.ViewModel.Excluir(dataContext); + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA EXCLUIR PROSPECÇÃO. CONTATE O ADMINISTRADOR DO SISTEMA.", "OK", "", false); + } + } + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + this.InicioBox.Text = ValidationHelper.FormatDate(this.InicioBox.Text); + this.FimBox.Text = ValidationHelper.FormatDate(this.FimBox.Text); + try + { + this.ViewModel.Inicio = Convert.ToDateTime(this.InicioBox.Text); + this.ViewModel.Fim = Convert.ToDateTime(this.FimBox.Text); + } + catch (Exception exception) + { + return; + } + await this.ViewModel.Print(); + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + public void InitializeComponent() + { + if (this._contentLoaded) + { + return; + } + this._contentLoaded = true; + System.Windows.Application.LoadComponent(this, new Uri("/Gestor.Application;component/views/bi/prospeccaoview.xaml", UriKind.Relative)); + } + + private async void Periodo_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + await this.ViewModel.CarregarProspeccoes(); + } + + private async void StatusProspeccao_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + await this.ViewModel.CarregarProspeccoes(); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Vendedor_OnSelectionChanged); + return; + } + case 2: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.StatusProspeccao_OnSelectionChanged); + return; + } + case 3: + { + this.InicioBox = (DatePicker)target; + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.InicioBox.SelectedDateChanged += new EventHandler(this.Periodo_OnSelectedDateChanged); + return; + } + case 4: + { + this.FimBox = (DatePicker)target; + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.FimBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.FimBox.SelectedDateChanged += new EventHandler(this.Periodo_OnSelectedDateChanged); + return; + } + case 5: + { + this.AutoCompleteFornecedor = (AutoCompleteBox)target; + this.AutoCompleteFornecedor.add_Populating(new PopulatingEventHandler(this, ProspeccaoView.AutoCompleteBoxDetalhe_Populating)); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excel_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CriarProspeccao_OnClick); + return; + } + case 9: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 12: + { + ((DataGrid)target).MouseDoubleClick += new MouseButtonEventHandler(this.Control_OnMouseDoubleClick); + return; + } + } + this._contentLoaded = true; + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 13: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirProspeccao_OnClick); + return; + } + case 14: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 15: + { + ((Button)target).Click += new RoutedEventHandler(this.EditarProspeccao_OnClick); + return; + } + default: + { + return; + } + } + } + + private async void Vendedor_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + await this.ViewModel.CarregarProspeccoes(); + } + } +} \ No newline at end of file -- cgit v1.2.3