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/AcompanhamentoView.cs | 339 ++++++++++++ Gestor.Application/Views/BI/AgendaBIView.cs | 81 +++ Gestor.Application/Views/BI/NotasView.cs | 298 ++++++++++ Gestor.Application/Views/BI/PainelBiView.cs | 502 +++++++++++++++++ Gestor.Application/Views/BI/ProspeccaoView.cs | 422 +++++++++++++++ Gestor.Application/Views/BI/TarefaView.cs | 628 ++++++++++++++++++++++ 6 files changed, 2270 insertions(+) create mode 100644 Gestor.Application/Views/BI/AcompanhamentoView.cs create mode 100644 Gestor.Application/Views/BI/AgendaBIView.cs create mode 100644 Gestor.Application/Views/BI/NotasView.cs create mode 100644 Gestor.Application/Views/BI/PainelBiView.cs create mode 100644 Gestor.Application/Views/BI/ProspeccaoView.cs create mode 100644 Gestor.Application/Views/BI/TarefaView.cs (limited to 'Gestor.Application/Views/BI') diff --git a/Gestor.Application/Views/BI/AcompanhamentoView.cs b/Gestor.Application/Views/BI/AcompanhamentoView.cs new file mode 100644 index 0000000..a509fdf --- /dev/null +++ b/Gestor.Application/Views/BI/AcompanhamentoView.cs @@ -0,0 +1,339 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Model.Domain.Ferramentas; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +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.Input; +using System.Windows.Markup; +using System.Windows.Media; + +namespace Gestor.Application.Views.BI +{ + public class AcompanhamentoView : BaseUserControl, IComponentConnector, IStyleConnector + { + private ListBox _dragSource; + + private object _data; + + internal ListBox FasesListBox; + + private bool _contentLoaded; + + public TrilhaViewModel ViewModel + { + get; + set; + } + + public AcompanhamentoView() + { + base.Tag = "CADASTRO DE TRILHAS"; + this.ViewModel = new TrilhaViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + this.FasesListBox.DataContext = this.ViewModel; + } + + private async Task AbrirTarefa(Tarefa data) + { + while (true) + { + Tarefa tarefa = await this.ViewModel.ShowTarefaDialog(data, false, false); + if (tarefa == null) + { + return; + } + List> keyValuePairs = await this.ViewModel.Salvar(tarefa); + this.ViewModel.Loading(false); + if (keyValuePairs == null || keyValuePairs.Count == 0) + { + break; + } + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + this.ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.", true); + this.ViewModel.Alterar(false); + return; + } + + private async void AdicionarTarefa_OnClick(object sender, RoutedEventArgs e) + { + Fase dataContext = ((Button)sender).DataContext as Fase; + Tarefa tarefa = new Tarefa(); + tarefa.set_Agendamento(Funcoes.GetNetworkTime()); + tarefa.set_Titulo("NOVA TAREFA"); + tarefa.set_Usuario(Recursos.Usuario); + tarefa.set_Trilha(this.ViewModel.SelectedTrilha); + tarefa.set_Status(0); + tarefa.set_Fase(dataContext); + Tarefa tarefa1 = tarefa; + this.ViewModel.Loading(true); + while (true) + { + Tarefa tarefa2 = await this.ViewModel.ShowTarefaDialog(tarefa1, false, false); + if (tarefa2 == null) + { + tarefa1 = null; + return; + } + List> keyValuePairs = await this.ViewModel.Salvar(tarefa2); + this.ViewModel.Loading(false); + if (keyValuePairs == null || keyValuePairs.Count == 0) + { + break; + } + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + this.ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.", true); + this.ViewModel.Alterar(false); + tarefa1 = null; + return; + tarefa1 = null; + } + + private async void EditarTarefa_OnClick(object sender, RoutedEventArgs e) + { + await this.AbrirTarefa(((Button)sender).DataContext as Tarefa); + } + + private async void ExcluirTarefa_OnClick(object sender, RoutedEventArgs e) + { + Tarefa dataContext = ((Button)sender).DataContext as Tarefa; + await this.ViewModel.Excluir(dataContext); + } + + private void FasesListBox_OnDragOver(object sender, DragEventArgs e) + { + ListBox listBox = sender as ListBox; + ScrollViewer scrollViewer = AcompanhamentoView.FindVisualChild(this.FasesListBox); + if (listBox != null) + { + double x = e.GetPosition(listBox).X; + if (x < 100) + { + scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset - 30); + return; + } + if (x > listBox.ActualWidth - 100) + { + scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + 30); + } + } + } + + public static TChildItem FindVisualChild(DependencyObject obj) + where TChildItem : DependencyObject + { + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) + { + DependencyObject child = VisualTreeHelper.GetChild(obj, i); + TChildItem tChildItem = (TChildItem)(child as TChildItem); + if (tChildItem != null) + { + return tChildItem; + } + TChildItem tChildItem1 = AcompanhamentoView.FindVisualChild(child); + if (tChildItem1 != null) + { + return tChildItem1; + } + } + return default(TChildItem); + } + + private static object GetDataFromListBox(ItemsControl source, Point point) + { + UIElement parent = source.InputHitTest(point) as UIElement; + if (parent != null) + { + object unsetValue = DependencyProperty.UnsetValue; + while (unsetValue == DependencyProperty.UnsetValue) + { + if (parent == null) + { + continue; + } + unsetValue = source.ItemContainerGenerator.ItemFromContainer(parent); + if (unsetValue == DependencyProperty.UnsetValue) + { + parent = VisualTreeHelper.GetParent(parent) as UIElement; + } + if (parent != source) + { + continue; + } + return null; + } + if (unsetValue != DependencyProperty.UnsetValue) + { + return unsetValue; + } + } + return null; + } + + private void Info_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + bool isOpen = !((System.Windows.Controls.ToolTip)button.ToolTip).IsOpen; + ((System.Windows.Controls.ToolTip)button.ToolTip).IsOpen = isOpen; + } + + [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/acompanhamentoview.xaml", UriKind.Relative)); + } + + private static bool IsMouseOverTarget(Visual target, Point point) + { + return VisualTreeHelper.GetDescendantBounds(target).Contains(point); + } + + private void ListBox_Drop(object sender, DragEventArgs e) + { + ListBox listBox = (ListBox)sender; + object data = e.Data.GetData(this._data.GetType()); + int num = -1; + int num1 = 0; + while (num1 < listBox.Items.Count) + { + ListBoxItem listBoxItem = listBox.ItemContainerGenerator.ContainerFromIndex(num1) as ListBoxItem; + if (listBoxItem == null || !AcompanhamentoView.IsMouseOverTarget(listBoxItem, e.GetPosition(listBoxItem))) + { + num1++; + } + else + { + num = num1; + break; + } + } + Fase dataContext = this._dragSource.DataContext as Fase; + Fase fase = listBox.DataContext as Fase; + this.ViewModel.Excluir(dataContext, (Tarefa)data); + this.ViewModel.Inserir(fase, (Tarefa)data, num, false); + this.ViewModel.Update(); + } + + private async void ListBox_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + ListBox listBox = (ListBox)sender; + object dataFromListBox = AcompanhamentoView.GetDataFromListBox(listBox, e.GetPosition(listBox)); + if (dataFromListBox != null) + { + await this.AbrirTarefa((Tarefa)dataFromListBox); + } + } + + private void ListBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (!(sender is Button)) + { + return; + } + Button button = (Button)sender; + this._dragSource = ViewHelper.FindAncestor(button).FirstOrDefault(); + this._data = AcompanhamentoView.GetDataFromListBox(this._dragSource, e.GetPosition(button)); + if (this._data == null) + { + return; + } + DragDrop.DoDragDrop(button, this._data, DragDropEffects.Move); + e.Handled = true; + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + if (connectionId != 1) + { + this._contentLoaded = true; + return; + } + this.FasesListBox = (ListBox)target; + this.FasesListBox.DragOver += new DragEventHandler(this.FasesListBox_OnDragOver); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 2: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarTarefa_OnClick); + return; + } + case 3: + { + ((Button)target).Click += new RoutedEventHandler(this.Info_OnClick); + return; + } + case 4: + { + ((ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(this.ListBox_OnPreviewMouseDoubleClick); + ((ListBox)target).MouseLeftButtonDown += new MouseButtonEventHandler(this.ListBox_PreviewMouseLeftButtonDown); + ((ListBox)target).Drop += new DragEventHandler(this.ListBox_Drop); + return; + } + case 5: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirTarefa_OnClick); + return; + } + case 6: + { + ((Button)target).PreviewMouseLeftButtonDown += new MouseButtonEventHandler(this.ListBox_PreviewMouseLeftButtonDown); + return; + } + case 7: + { + ((Button)target).Click += new RoutedEventHandler(this.EditarTarefa_OnClick); + return; + } + case 8: + { + ((Button)target).Click += new RoutedEventHandler(this.TarefaConcluida_OnClick); + return; + } + default: + { + return; + } + } + } + + private async void TarefaConcluida_OnClick(object sender, RoutedEventArgs e) + { + Tarefa dataContext = ((Button)sender).DataContext as Tarefa; + if (dataContext != null) + { + dataContext.set_Conclusao(new DateTime?(Funcoes.GetNetworkTime())); + dataContext.set_Status(2); + await this.ViewModel.Salvar(dataContext); + await this.ViewModel.CarregarTrilha(this.ViewModel.SelectedTrilha); + } + } + } +} \ No newline at end of file diff --git a/Gestor.Application/Views/BI/AgendaBIView.cs b/Gestor.Application/Views/BI/AgendaBIView.cs new file mode 100644 index 0000000..33865eb --- /dev/null +++ b/Gestor.Application/Views/BI/AgendaBIView.cs @@ -0,0 +1,81 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.BI +{ + public class AgendaBIView : UserControl, IComponentConnector + { + internal ContentControl NotasControl; + + internal ContentControl TarefaControl; + + internal ContentControl BiControl; + + private bool _contentLoaded; + + public AgendaBIView() + { + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + + private void ContentLoad() + { + NotasView notasView = new NotasView(); + this.NotasControl.Content = notasView; + this.NotasControl.DataContext = notasView.DataContext; + TarefaView tarefaView = new TarefaView(); + this.TarefaControl.Content = tarefaView; + this.TarefaControl.DataContext = tarefaView.DataContext; + } + + [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/agendabiview.xaml", UriKind.Relative)); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + this.NotasControl = (ContentControl)target; + return; + } + case 2: + { + this.TarefaControl = (ContentControl)target; + return; + } + case 3: + { + this.BiControl = (ContentControl)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Gestor.Application/Views/BI/NotasView.cs b/Gestor.Application/Views/BI/NotasView.cs new file mode 100644 index 0000000..1386592 --- /dev/null +++ b/Gestor.Application/Views/BI/NotasView.cs @@ -0,0 +1,298 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.BI; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +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.Input; +using System.Windows.Markup; +using System.Windows.Media; + +namespace Gestor.Application.Views.BI +{ + public class NotasView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal ProgressBar ProgressRing; + + private bool _contentLoaded; + + public NotasViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public NotasView() + { + this.ViewModel = new NotasViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private async Task AbrirNota(Tarefa data, bool notaBool = false, bool agendamento = false) + { + while (true) + { + Tarefa tarefa = await this.ViewModel.ShowTarefaDialog(data, notaBool, agendamento); + Tarefa tarefa1 = tarefa; + if (tarefa1 == null) + { + return; + } + if (tarefa1.get_Usuario() == null) + { + tarefa1.set_Usuario(tarefa1.get_UsuariosVinculados().FirstOrDefault()); + } + List list = tarefa1.get_UsuariosVinculados().Select((Usuario x) => { + ResponsavelTarefa responsavelTarefa = new ResponsavelTarefa(); + responsavelTarefa.set_IdTarefa(tarefa1.get_Id()); + responsavelTarefa.set_Usuario(x); + return responsavelTarefa; + }).ToList(); + tarefa1.set_Responsaveis(list); + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(tarefa1); + this.ViewModel.Loading(false); + if (keyValuePairs == null || keyValuePairs.Count == 0) + { + break; + } + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + this.ViewModel.ToggleSnackBar("NOTA SALVA COM SUCESSO.", true); + await this.ViewModel.CarregarNotas(); + return; + } + + private async void AdicionarNota_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.AdicionarNota(); + } + + private async void ExcluirNota_OnClick(object sender, RoutedEventArgs e) + { + Tarefa dataContext = ((Button)sender).DataContext as Tarefa; + if (dataContext != null) + { + await this.ViewModel.ExcluirNota(dataContext); + await this.ViewModel.CarregarNotas(); + } + } + + private static object GetDataFromListBox(ItemsControl source, Point point) + { + UIElement parent = source.InputHitTest(point) as UIElement; + if (parent == null) + { + return null; + } + object unsetValue = DependencyProperty.UnsetValue; + while (unsetValue == DependencyProperty.UnsetValue) + { + if (parent == null) + { + continue; + } + unsetValue = source.ItemContainerGenerator.ItemFromContainer(parent); + if (unsetValue == DependencyProperty.UnsetValue) + { + parent = VisualTreeHelper.GetParent(parent) as UIElement; + } + if (parent != source) + { + continue; + } + return null; + } + if (unsetValue == DependencyProperty.UnsetValue) + { + return null; + } + return unsetValue; + } + + [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/notasview.xaml", UriKind.Relative)); + } + + private async void ListBox_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + List list; + ListBox listBox = (ListBox)sender; + object dataFromListBox = NotasView.GetDataFromListBox(listBox, e.GetPosition(listBox)); + if (dataFromListBox != null) + { + Tarefa tarefa = new Tarefa(); + DomainBase.Copy(tarefa, (Tarefa)dataFromListBox); + Tarefa tarefa1 = tarefa; + List responsaveis = tarefa.get_Responsaveis(); + if (responsaveis != null) + { + list = ( + from x in responsaveis + select x.get_Usuario()).ToList(); + } + else + { + list = null; + } + tarefa1.set_UsuariosVinculados(list); + await this.AbrirNota(tarefa, tarefa.get_Entidade() == 1, tarefa.get_Entidade() == 1); + } + } + + private async void NotaConcluida_OnClick(object sender, RoutedEventArgs e) + { + Tarefa dataContext = ((Button)sender).DataContext as Tarefa; + if (dataContext != null) + { + dataContext.set_Conclusao(new DateTime?(Funcoes.GetNetworkTime())); + dataContext.set_Status(2); + await this.ViewModel.SalvarNota(dataContext); + await this.ViewModel.CarregarNotas(); + } + } + + private async void SarvarNota_OnClick(object sender, RoutedEventArgs e) + { + Tarefa dataContext = ((Button)sender).DataContext as Tarefa; + if (dataContext != null) + { + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(dataContext); + this.ViewModel.Loading(false); + if (keyValuePairs == null || keyValuePairs.Count == 0) + { + this.ViewModel.ToggleSnackBar("NOTA SALVA COM SUCESSO.", true); + } + else + { + await this.ViewModel.CarregarNotas(); + } + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + this.ProgressRing = (ProgressBar)target; + return; + } + case 2: + { + ((ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(this.ListBox_OnPreviewMouseDoubleClick); + return; + } + case 3: + case 4: + case 5: + { + this._contentLoaded = true; + return; + } + case 6: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarNota_OnClick); + return; + } + case 7: + { + ((Button)target).Click += new RoutedEventHandler(this.ToggleNotasConcluidas_OnClick); + return; + } + case 8: + { + ((ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(this.ListBox_OnPreviewMouseDoubleClick); + return; + } + default: + { + this._contentLoaded = true; + return; + } + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 3: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirNota_OnClick); + return; + } + case 4: + { + ((Button)target).Click += new RoutedEventHandler(this.NotaConcluida_OnClick); + return; + } + case 5: + { + ((Button)target).Click += new RoutedEventHandler(this.SarvarNota_OnClick); + return; + } + case 6: + case 7: + case 8: + { + return; + } + case 9: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirNota_OnClick); + return; + } + case 10: + { + ((Button)target).Click += new RoutedEventHandler(this.SarvarNota_OnClick); + return; + } + default: + { + return; + } + } + } + + private void ToggleNotasConcluidas_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ToggleNotasConcluidas(); + } + } +} \ No newline at end of file diff --git a/Gestor.Application/Views/BI/PainelBiView.cs b/Gestor.Application/Views/BI/PainelBiView.cs new file mode 100644 index 0000000..1886b4f --- /dev/null +++ b/Gestor.Application/Views/BI/PainelBiView.cs @@ -0,0 +1,502 @@ +using Gestor.Application.ViewModels.BI; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using LiveCharts.Wpf; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Markup; + +namespace Gestor.Application.Views.BI +{ + public class PainelBiView : BaseUserControl, IComponentConnector + { + public PainelBiViewModel ViewModel; + + internal ProgressBar ProgressProducao; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal Button Anterior; + + internal Button Gerada; + + internal Button Apolices; + + internal Button Endossos; + + internal Button NovosNegocios; + + internal Button Faturas; + + internal Button Renovacoes; + + internal Button Cancelamentos; + + internal ProgressBar ProgressClientes; + + internal DatePicker InicioClientesBox; + + internal DatePicker FimClientesBox; + + internal Button Aniversariantes; + + internal Button VencimentoCnh; + + internal ProgressBar ProgressPendencia; + + internal DatePicker InicioPendenciaBox; + + internal DatePicker FimPendenciaBox; + + internal Button VencimentoApolices; + + internal Button ParcelasAVencer; + + internal Button ApolicesPendentes; + + internal Button ParcelasPendentes; + + private bool _contentLoaded; + + public PainelBiView() + { + this.ViewModel = new PainelBiViewModel(); + base.DataContext = this.ViewModel; + base.Tag = "PAINEL B.I."; + this.InitializeComponent(); + } + + private async void Atualizar_Click(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.GerarProducao(); + } + + private async void AtualizarClientes_OnClick(object sender, RoutedEventArgs e) + { + this.InicioClientesBox.Text = ValidationHelper.FormatDate(this.InicioClientesBox.Text); + this.FimClientesBox.Text = ValidationHelper.FormatDate(this.FimClientesBox.Text); + try + { + this.ViewModel.Inicio = Convert.ToDateTime(this.InicioClientesBox.Text); + this.ViewModel.Fim = Convert.ToDateTime(this.FimClientesBox.Text); + } + catch (Exception exception) + { + return; + } + await this.ViewModel.GerarClientes(); + } + + private async void AtualizarPendencias_OnClick(object sender, RoutedEventArgs e) + { + this.InicioPendenciaBox.Text = ValidationHelper.FormatDate(this.InicioPendenciaBox.Text); + this.FimPendenciaBox.Text = ValidationHelper.FormatDate(this.FimPendenciaBox.Text); + try + { + this.ViewModel.Inicio = Convert.ToDateTime(this.InicioPendenciaBox.Text); + this.ViewModel.Fim = Convert.ToDateTime(this.FimPendenciaBox.Text); + } + catch (Exception exception) + { + return; + } + await this.ViewModel.GerarVencimento(); + } + + private void DetalharProducao_OnClick(object sender, RoutedEventArgs e) + { + char chr; + string name = ((Button)sender).Name; + if (name != null) + { + switch (name.Length) + { + case 7: + { + if (name == "Faturas") + { + this.ViewModel.Detalhar(12); + return; + } + break; + } + case 8: + { + chr = name[2]; + if (chr == 'd') + { + if (name == "Endossos") + { + this.ViewModel.Detalhar(11); + return; + } + break; + } + else if (chr == 'o') + { + if (name == "Apolices") + { + this.ViewModel.Detalhar(13); + return; + } + break; + } + else if (chr == 't') + { + if (name != "Anterior") + { + break; + } + this.ViewModel.Detalhar(14); + return; + } + else + { + break; + } + } + case 10: + { + if (name == "Renovacoes") + { + this.ViewModel.Detalhar(3); + return; + } + break; + } + case 13: + { + chr = name[0]; + if (chr == 'C') + { + if (name == "Cancelamentos") + { + this.ViewModel.Detalhar(4); + return; + } + break; + } + else if (chr == 'N') + { + if (name == "NovosNegocios") + { + this.ViewModel.Detalhar(2); + return; + } + break; + } + else if (chr == 'V') + { + if (name == "VencimentoCnh") + { + this.ViewModel.Detalhar(6); + return; + } + break; + } + else + { + break; + } + } + case 15: + { + chr = name[0]; + if (chr == 'A') + { + if (name == "Aniversariantes") + { + this.ViewModel.Detalhar(5); + return; + } + break; + } + else if (chr == 'P') + { + if (name == "ParcelasAVencer") + { + this.ViewModel.Detalhar(8); + return; + } + break; + } + else + { + break; + } + } + case 17: + { + chr = name[0]; + if (chr == 'A') + { + if (name == "ApolicesPendentes") + { + this.ViewModel.Detalhar(9); + return; + } + break; + } + else if (chr == 'P') + { + if (name == "ParcelasPendentes") + { + this.ViewModel.Detalhar(10); + return; + } + break; + } + else + { + break; + } + } + case 18: + { + if (name == "VencimentoApolices") + { + this.ViewModel.Detalhar(7); + return; + } + break; + } + } + } + this.ViewModel.Detalhar(0); + } + + private void Fechamento_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + this.ViewModel.Detalhar(1); + } + + private void Grafico_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + this.ViewModel.Detalhar(0); + } + + [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/painelbiview.xaml", UriKind.Relative)); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + this.ProgressProducao = (ProgressBar)target; + return; + } + case 2: + { + this.InicioBox = (DatePicker)target; + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 3: + { + this.FimBox = (DatePicker)target; + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 4: + { + ((CartesianChart)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(this.Grafico_OnPreviewMouseDoubleClick); + return; + } + case 5: + { + ((Button)target).Click += new RoutedEventHandler(this.Atualizar_Click); + return; + } + case 6: + { + ((Button)target).Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 7: + { + this.Anterior = (Button)target; + this.Anterior.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 8: + { + this.Gerada = (Button)target; + this.Gerada.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 9: + { + this.Apolices = (Button)target; + this.Apolices.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 10: + { + this.Endossos = (Button)target; + this.Endossos.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 11: + { + this.NovosNegocios = (Button)target; + this.NovosNegocios.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 12: + { + this.Faturas = (Button)target; + this.Faturas.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 13: + { + this.Renovacoes = (Button)target; + this.Renovacoes.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 14: + { + this.Cancelamentos = (Button)target; + this.Cancelamentos.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 15: + { + ((PieChart)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(this.Grafico_OnPreviewMouseDoubleClick); + return; + } + case 16: + { + ((PieChart)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(this.Grafico_OnPreviewMouseDoubleClick); + return; + } + case 17: + { + ((CartesianChart)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(this.Fechamento_OnPreviewMouseDoubleClick); + return; + } + case 18: + { + this.ProgressClientes = (ProgressBar)target; + return; + } + case 19: + { + this.InicioClientesBox = (DatePicker)target; + this.InicioClientesBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioClientesBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 20: + { + this.FimClientesBox = (DatePicker)target; + this.FimClientesBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimClientesBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 21: + { + ((Button)target).Click += new RoutedEventHandler(this.AtualizarClientes_OnClick); + return; + } + case 22: + { + this.Aniversariantes = (Button)target; + this.Aniversariantes.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 23: + { + this.VencimentoCnh = (Button)target; + this.VencimentoCnh.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 24: + { + this.ProgressPendencia = (ProgressBar)target; + return; + } + case 25: + { + this.InicioPendenciaBox = (DatePicker)target; + this.InicioPendenciaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioPendenciaBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 26: + { + this.FimPendenciaBox = (DatePicker)target; + this.FimPendenciaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimPendenciaBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 27: + { + ((Button)target).Click += new RoutedEventHandler(this.AtualizarPendencias_OnClick); + return; + } + case 28: + { + this.VencimentoApolices = (Button)target; + this.VencimentoApolices.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 29: + { + this.ParcelasAVencer = (Button)target; + this.ParcelasAVencer.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 30: + { + this.ApolicesPendentes = (Button)target; + this.ApolicesPendentes.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + case 31: + { + this.ParcelasPendentes = (Button)target; + this.ParcelasPendentes.Click += new RoutedEventHandler(this.DetalharProducao_OnClick); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file 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 diff --git a/Gestor.Application/Views/BI/TarefaView.cs b/Gestor.Application/Views/BI/TarefaView.cs new file mode 100644 index 0000000..7ca7f68 --- /dev/null +++ b/Gestor.Application/Views/BI/TarefaView.cs @@ -0,0 +1,628 @@ +using Gestor.Application.Actions; +using Gestor.Application.Componentes; +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.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.MalaDireta; +using Gestor.Model.Domain.Seguros; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +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; +using Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.BI +{ + public class TarefaView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal ComboBox UsuarioBox; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal TextBox TituloTarefaLabel; + + internal DatePicker AgendamentoBox; + + internal ComboBox ResponsavelBox; + + internal RadioButton AnotacoesButton; + + internal RadioButton AnotacoesInternasButton; + + internal WebEditor Anotacoes; + + internal WebEditor Historico; + + internal WebEditor AnotacoesInternas; + + internal WebEditor HistoricoInterno; + + private bool _contentLoaded; + + public TarefaBIViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public TarefaView() + { + this.ViewModel = new TarefaBIViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(38, this.ViewModel.SelectedTarefa.get_Id()); + } + + private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdcionarFiltro(); + } + + private void AdicionarResponsavel_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdcionarResponsavel(); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AlterarTarefa(); + this.Anotacoes.Initialize(null); + this.AnotacoesInternas.Initialize(null); + } + + private async void AnexoTarefa_OnClick(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 15).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedTarefa.get_Id()); + filtroArquivoDigital.set_Tipo(15); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedTarefa); + 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)15), "."), "OK", "", false); + } + } + + private void Anotacoes_OnChecked(object sender, RoutedEventArgs e) + { + this.ViewModel.IsAnotacoes = true; + } + + private void AnotacoesInternas_OnChecked(object sender, RoutedEventArgs e) + { + this.ViewModel.IsAnotacoes = false; + } + + private void Apolice_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Abrir((this.ViewModel.SelectedTarefa.get_Entidade() == 3 ? 3 : 0)); + } + + private void ArquivoDigital_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirArquivoDigital(); + } + + private async void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Cancelar(); + } + + private void Cliente_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Abrir(2); + } + + private async void Concluida_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedTarefa == null) + { + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR UMA TAREFA ANTES DE CONCLUIR.", "OK", "", false); + } + else if (await this.ViewModel.ValidaPermissaoParaEditarTarefa()) + { + this.ViewModel.SelectedTarefa.set_Conclusao(new DateTime?(Funcoes.GetNetworkTime())); + this.ViewModel.SelectedTarefa.set_Status(2); + await this.ViewModel.ConcluirTarefa(this.ViewModel.SelectedTarefa); + await this.ViewModel.CarregarTarefas(); + } + else + { + await this.ViewModel.ShowMessage(string.Format("APENAS O USUÁRIO {0} (ID: {1}) PODE CONCLUIR ESSA TAREFA.", this.ViewModel.SelectedTarefa.get_UsuarioCadastro().get_Nome(), this.ViewModel.SelectedTarefa.get_UsuarioCadastro().get_Id()), "OK", "", false); + } + } + + private void ContentLoad() + { + this.AnotacoesButton.IsChecked = new bool?(this.ViewModel.IsAnotacoes); + this.AnotacoesInternasButton.IsChecked = new bool?(!this.ViewModel.IsAnotacoes); + this.AnotacoesButton.Checked += new RoutedEventHandler(this.Anotacoes_OnChecked); + this.AnotacoesInternasButton.Checked += new RoutedEventHandler(this.AnotacoesInternas_OnChecked); + } + + private void CopyTelefoneToClipBoard_Click(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button.DataContext != null) + { + TelefoneBase dataContext = button.DataContext as TelefoneBase; + if (dataContext != null) + { + string.Concat(dataContext.get_Prefixo(), ValidationHelper.OnlyNumber(dataContext.get_Numero())).CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", dataContext.get_Prefixo(), ValidationHelper.OnlyNumber(dataContext.get_Numero())), true); + return; + } + } + } + + private async void Email_OnClick(object sender, RoutedEventArgs e) + { + MalaDireta malaDiretum = await this.ViewModel.CriarMalaDireta(this.ViewModel.SelectedTarefa.get_Entidade()); + if (malaDiretum != null) + { + if (Funcoes.IsWindowOpen("ENVIO DE E-MAIL")) + { + Funcoes.Destroy("ENVIO DE E-MAIL"); + } + string str = string.Concat("Cliente: ", this.ViewModel.SelectedTarefa.get_Cliente(), "
"); + str = string.Concat(str, string.Format("Número do Atendimento: {0}
", this.ViewModel.SelectedTarefa.get_Id())); + str = string.Concat(str, string.Format("Data/Hora da Solicitação: {0}
", this.ViewModel.SelectedTarefa.get_Agendamento())); + if (this.ViewModel.SelectedTarefa.get_Conclusao().HasValue) + { + str = string.Concat(str, string.Format("Data/Hora da Conclusão: {0}
", this.ViewModel.SelectedTarefa.get_Conclusao())); + } + if (this.ViewModel.SelectedTarefa.get_Usuario() != null) + { + str = string.Concat(str, "Atendente: ", this.ViewModel.SelectedTarefa.get_Usuario().get_Nome(), "
"); + } + if (this.ViewModel.SelectedTarefa.get_TipoDeTarefa() != null) + { + str = string.Concat(str, "Tipo: ", this.ViewModel.SelectedTarefa.get_TipoDeTarefa().get_Nome(), "
"); + } + str = string.Concat(str, "Assunto: ", this.ViewModel.SelectedTarefa.get_Titulo(), "
"); + str = string.Concat(str, "Situação do Atendimento: ", ValidationHelper.GetDescription(this.ViewModel.SelectedTarefa.get_Status()), "

"); + str = string.Concat(str, "Prezado cliente,
"); + str = string.Concat(str, "Segue, abaixo, a descrição do seu atendimento prestado pela corretora.

"); + List malaDiretas = new List() + { + malaDiretum + }; + (new HosterWindow(new MalaDiretaView(malaDiretas, this.ViewModel.SelectedTarefa.get_Titulo(), string.Concat(str, this.ViewModel.Descricao), null), "ENVIO DE E-MAIL", new double?((double)1200), new double?((double)600), true)).Show(); + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR.", "OK", "", false); + } + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (!this.ViewModel.SelectedTarefa.get_Restrito().HasValue || !this.ViewModel.SelectedTarefa.get_Restrito().Value || this.ViewModel.SelectedTarefa.get_UsuarioCadastro().get_Id() == Recursos.Usuario.get_Id() || Recursos.Usuario.get_Administrador()) + { + await this.ViewModel.Excluir(); + } + else + { + await this.ViewModel.ShowMessage(string.Format("APENAS O USUÁRIO {0} (ID: {1}) PODE EXCLUIR ESSA TAREFA.", this.ViewModel.SelectedTarefa.get_UsuarioCadastro().get_Nome(), this.ViewModel.SelectedTarefa.get_UsuarioCadastro().get_Id()), "OK", "", false); + } + } + + private void ExcluirFiltro_onClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(chip); + string item = (string)listBox.Items[listBox.Items.IndexOf(chip.DataContext)]; + if (item == null) + { + return; + } + this.ViewModel.ExcluirFiltro(item); + } + + private void ExcluirResponsavel_OnClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + ResponsavelTarefa dataContext = (ResponsavelTarefa)chip.DataContext; + if (dataContext == null) + { + return; + } + this.ViewModel.Responsaveis.Remove(dataContext); + this.ViewModel.Usuarios.Add(dataContext.get_Usuario()); + this.ViewModel.Usuarios = new ObservableCollection( + from x in this.ViewModel.Usuarios + orderby x.get_Nome() + select x); + } + + private async void ExcluirTarefa_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.ValidaPermissaoParaExcluirTarefa(null)) + { + await this.ViewModel.Excluir(); + } + else + { + await this.ViewModel.ShowMessage(string.Format("APENAS O USUÁRIO {0} (ID: {1}) PODE EXCLUIR ESSA TAREFA.", this.ViewModel.SelectedTarefa.get_UsuarioCadastro().get_Nome(), this.ViewModel.SelectedTarefa.get_UsuarioCadastro().get_Id()), "OK", "", false); + } + } + + private void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedTarefa.get_Id() == 0) + { + return; + } + 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/tarefaview.xaml", UriKind.Relative)); + } + + private async void NaoConcluida_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedTarefa != null) + { + this.ViewModel.SelectedTarefa.set_Conclusao(null); + this.ViewModel.SelectedTarefa.set_Status(0); + await this.ViewModel.ConcluirTarefa(this.ViewModel.SelectedTarefa); + await this.ViewModel.CarregarTarefas(); + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR UMA TAREFA ANTES DE MARCAR COMO NÃO CONCLUÍDO.", "OK", "", false); + } + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.SelectedTarefa.set_Anotacoes(this.Anotacoes.GetHtml()); + this.ViewModel.SelectedTarefa.set_AnotacoesInternas(this.AnotacoesInternas.GetHtml()); + this.ViewModel.SelectedTarefa.set_Usuario((Usuario)this.ResponsavelBox.SelectedItem); + List> keyValuePairs = await this.ViewModel.Salvar(this.TituloTarefaLabel.Text); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.", true); + this.ViewModel.Alterar(false); + } + } + + private void Sinistro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Abrir(4); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + this.UsuarioBox = (ComboBox)target; + return; + } + case 2: + { + this.InicioBox = (DatePicker)target; + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 3: + { + this.FimBox = (DatePicker)target; + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 4: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltro_OnClick); + return; + } + case 5: + case 6: + case 7: + case 22: + case 23: + case 28: + { + this._contentLoaded = true; + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Concluida_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.NaoConcluida_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AnexoTarefa_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cliente_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Apolice_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ArquivoDigital_OnClick); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Sinistro_OnClick); + return; + } + case 19: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 20: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Email_OnClick); + return; + } + case 21: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 24: + { + this.TituloTarefaLabel = (TextBox)target; + return; + } + case 25: + { + this.AgendamentoBox = (DatePicker)target; + this.AgendamentoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + return; + } + case 26: + { + this.ResponsavelBox = (ComboBox)target; + return; + } + case 27: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarResponsavel_OnClick); + return; + } + case 29: + { + this.AnotacoesButton = (RadioButton)target; + return; + } + case 30: + { + this.AnotacoesInternasButton = (RadioButton)target; + return; + } + case 31: + { + this.Anotacoes = (WebEditor)target; + return; + } + case 32: + { + this.Historico = (WebEditor)target; + return; + } + case 33: + { + this.AnotacoesInternas = (WebEditor)target; + return; + } + case 34: + { + this.HistoricoInterno = (WebEditor)target; + return; + } + default: + { + this._contentLoaded = true; + return; + } + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) + { + if (connectionId > 22) + { + if (connectionId == 23) + { + ((Button)target).Click += new RoutedEventHandler(this.WhatsAppMessage_Click); + return; + } + if (connectionId != 28) + { + return; + } + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirResponsavel_OnClick)); + return; + } + switch (connectionId) + { + case 5: + { + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_onClick)); + return; + } + case 6: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirTarefa_OnClick); + return; + } + case 7: + { + ((Button)target).Click += new RoutedEventHandler(this.TarefaConcluida_OnClick); + return; + } + default: + { + if (connectionId == 22) + { + break; + } + else + { + return; + } + } + } + ((Button)target).Click += new RoutedEventHandler(this.CopyTelefoneToClipBoard_Click); + } + + private async void TarefaConcluida_OnClick(object sender, RoutedEventArgs e) + { + Tarefa dataContext = ((Button)sender).DataContext as Tarefa; + if (dataContext != null) + { + if (await this.ViewModel.ValidaPermissaoParaEditarTarefa()) + { + dataContext.set_Conclusao(new DateTime?(Funcoes.GetNetworkTime())); + dataContext.set_Status(2); + await this.ViewModel.ConcluirTarefa(dataContext); + await this.ViewModel.CarregarTarefas(); + Action atualizaTrilhas = Gestor.Application.Actions.Actions.AtualizaTrilhas; + if (atualizaTrilhas != null) + { + atualizaTrilhas(); + } + else + { + } + } + else + { + await this.ViewModel.ShowMessage(string.Format("APENAS O USUÁRIO {0} (ID: {1}) PODE CONCLUIR ESSA TAREFA.", this.ViewModel.SelectedTarefa.get_UsuarioCadastro().get_Nome(), this.ViewModel.SelectedTarefa.get_UsuarioCadastro().get_Id()), "OK", "", false); + } + } + dataContext = null; + } + + private async void WhatsAppMessage_Click(object sender, RoutedEventArgs e) + { + string str; + Button button = (Button)sender; + if (button.DataContext != null) + { + TelefoneBase dataContext = button.DataContext as TelefoneBase; + if (dataContext != null) + { + str = (!dataContext.get_Tipo().HasValue || dataContext.get_Tipo().GetValueOrDefault() != 8 ? string.Concat("55", dataContext.get_Prefixo(), dataContext.get_Numero().Clear()) : string.Concat(dataContext.get_Prefixo(), dataContext.get_Numero()).Clear()); + if (!str.EnviarWhatsapp(null)) + { + await this.ViewModel.ShowMessage("HOUVE UM PROBLEMA AO ABRIR LINK DO WHATSAPP, O LINK FOI COPIADO EM SUA MAQUINA, BASTA ABRIR O NAVEGADOR DE INTERNET E COLAR NA BARRA DE ENDEREÇOS", "OK", "", false); + } + return; + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3