From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Views/Ajuda/AtendimentosView.cs | 302 ++ .../Views/BI/AcompanhamentoView.cs | 339 ++ .../Gestor.Application/Views/BI/AgendaBIView.cs | 81 + Codemerx/Gestor.Application/Views/BI/NotasView.cs | 298 ++ .../Gestor.Application/Views/BI/PainelBiView.cs | 502 +++ .../Gestor.Application/Views/BI/ProspeccaoView.cs | 422 +++ Codemerx/Gestor.Application/Views/BI/TarefaView.cs | 628 ++++ .../Views/ConnectionRetryView.cs | 218 ++ .../Views/Ferramentas/CadastroEmailView.cs | 400 +++ .../Views/Ferramentas/CadastroParceiroView.cs | 387 +++ .../Views/Ferramentas/DownloadWindow.cs | 171 + .../Views/Ferramentas/EmpresaView.cs | 424 +++ .../Views/Ferramentas/EstipulanteView.cs | 395 +++ .../Views/Ferramentas/EtiquetaView.cs | 157 + .../Views/Ferramentas/IncluirRamoView.cs | 133 + .../Views/Ferramentas/IncluirSeguradoraView.cs | 133 + .../Views/Ferramentas/MalaDiretaView.cs | 301 ++ .../Views/Ferramentas/ManutencaoPagamentosView.cs | 252 ++ .../Views/Ferramentas/NotaFiscalView.cs | 327 ++ .../Views/Ferramentas/ProdutoView.cs | 215 ++ .../Views/Ferramentas/ProtocoloDocumentosView.cs | 209 ++ .../Views/Ferramentas/QualificacaoView.cs | 197 ++ .../Views/Ferramentas/RamoView.cs | 282 ++ .../Views/Ferramentas/ReciboView.cs | 280 ++ .../Views/Ferramentas/SeguradoraView.cs | 643 ++++ .../Views/Ferramentas/SocioView.cs | 266 ++ .../Views/Ferramentas/StatusProspeccaoView.cs | 213 ++ .../Views/Ferramentas/StatusView.cs | 232 ++ .../Views/Ferramentas/TipoTarefaView.cs | 213 ++ .../Views/Ferramentas/TipoVendedorView.cs | 225 ++ .../Views/Ferramentas/UsuarioView.cs | 545 +++ .../Views/Ferramentas/VendedorView.cs | 927 +++++ .../Views/Financeiro/BancosContasView.cs | 371 ++ .../Views/Financeiro/CentroDeCustoView.cs | 199 ++ .../Views/Financeiro/ExtratoWindow.cs | 511 +++ .../Views/Financeiro/FinanceiroView.cs | 1560 +++++++++ .../Views/Financeiro/FornecedorView.cs | 419 +++ .../Views/Financeiro/InfoExtratoView.cs | 127 + .../Views/Financeiro/PlanoView.cs | 117 + .../Views/Financeiro/PlanosView.cs | 262 ++ .../Relatorios/FechamentoFinanceiroView.cs | 285 ++ .../Views/Generic/BaseUserControl.cs | 104 + .../Views/Generic/DragOverPopup.cs | 57 + .../Views/Generic/ErrorWindow.cs | 101 + .../Views/Generic/HosterWindow.cs | 460 +++ Codemerx/Gestor.Application/Views/ImportView.cs | 69 + Codemerx/Gestor.Application/Views/LoginWindow.cs | 825 +++++ .../Views/Menus/DashboardView.cs | 1002 ++++++ .../Views/Menus/MenuItensView.cs | 375 ++ .../Views/Relatorios/RelatorioView.cs | 1167 +++++++ .../Views/Relatorios/SinteticoView.cs | 509 +++ .../Views/Seguros/ApoliceView.cs | 3609 ++++++++++++++++++++ .../Views/Seguros/ClienteView.cs | 1307 +++++++ .../Views/Seguros/ComissaoView.cs | 1336 ++++++++ .../Views/Seguros/ConsultaOriginalView.cs | 1502 ++++++++ .../Views/Seguros/CriticaApoliceView.cs | 2010 +++++++++++ .../Views/Seguros/Itens/AeronauticoView.cs | 373 ++ .../Views/Seguros/Itens/AutoView.cs | 718 ++++ .../Views/Seguros/Itens/BuscarModeloView.cs | 85 + .../Views/Seguros/Itens/ConsorcioView.cs | 320 ++ .../Views/Seguros/Itens/GranizoView.cs | 383 +++ .../Views/Seguros/Itens/PatrimonialView.cs | 466 +++ .../Views/Seguros/Itens/RiscosDiversosView.cs | 683 ++++ .../Views/Seguros/Itens/VidaView.cs | 705 ++++ .../Views/Seguros/PerfilEmpresaView.cs | 267 ++ .../Gestor.Application/Views/Seguros/PerfilView.cs | 320 ++ .../Views/Seguros/SinistroView.cs | 1003 ++++++ .../Views/Seguros/TrocarClienteView.cs | 154 + Codemerx/Gestor.Application/Views/TutorialView.cs | 369 ++ 69 files changed, 34447 insertions(+) create mode 100644 Codemerx/Gestor.Application/Views/Ajuda/AtendimentosView.cs create mode 100644 Codemerx/Gestor.Application/Views/BI/AcompanhamentoView.cs create mode 100644 Codemerx/Gestor.Application/Views/BI/AgendaBIView.cs create mode 100644 Codemerx/Gestor.Application/Views/BI/NotasView.cs create mode 100644 Codemerx/Gestor.Application/Views/BI/PainelBiView.cs create mode 100644 Codemerx/Gestor.Application/Views/BI/ProspeccaoView.cs create mode 100644 Codemerx/Gestor.Application/Views/BI/TarefaView.cs create mode 100644 Codemerx/Gestor.Application/Views/ConnectionRetryView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/CadastroEmailView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/CadastroParceiroView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/DownloadWindow.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/EmpresaView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/EstipulanteView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/EtiquetaView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/IncluirRamoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/IncluirSeguradoraView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/MalaDiretaView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/ManutencaoPagamentosView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/NotaFiscalView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/ProdutoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/ProtocoloDocumentosView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/QualificacaoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/RamoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/ReciboView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/SeguradoraView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/SocioView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/StatusProspeccaoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/StatusView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/TipoTarefaView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/TipoVendedorView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/UsuarioView.cs create mode 100644 Codemerx/Gestor.Application/Views/Ferramentas/VendedorView.cs create mode 100644 Codemerx/Gestor.Application/Views/Financeiro/BancosContasView.cs create mode 100644 Codemerx/Gestor.Application/Views/Financeiro/CentroDeCustoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Financeiro/ExtratoWindow.cs create mode 100644 Codemerx/Gestor.Application/Views/Financeiro/FinanceiroView.cs create mode 100644 Codemerx/Gestor.Application/Views/Financeiro/FornecedorView.cs create mode 100644 Codemerx/Gestor.Application/Views/Financeiro/InfoExtratoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Financeiro/PlanoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Financeiro/PlanosView.cs create mode 100644 Codemerx/Gestor.Application/Views/Financeiro/Relatorios/FechamentoFinanceiroView.cs create mode 100644 Codemerx/Gestor.Application/Views/Generic/BaseUserControl.cs create mode 100644 Codemerx/Gestor.Application/Views/Generic/DragOverPopup.cs create mode 100644 Codemerx/Gestor.Application/Views/Generic/ErrorWindow.cs create mode 100644 Codemerx/Gestor.Application/Views/Generic/HosterWindow.cs create mode 100644 Codemerx/Gestor.Application/Views/ImportView.cs create mode 100644 Codemerx/Gestor.Application/Views/LoginWindow.cs create mode 100644 Codemerx/Gestor.Application/Views/Menus/DashboardView.cs create mode 100644 Codemerx/Gestor.Application/Views/Menus/MenuItensView.cs create mode 100644 Codemerx/Gestor.Application/Views/Relatorios/RelatorioView.cs create mode 100644 Codemerx/Gestor.Application/Views/Relatorios/SinteticoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/ApoliceView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/ClienteView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/ComissaoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/ConsultaOriginalView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/CriticaApoliceView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/AeronauticoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/AutoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/BuscarModeloView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/ConsorcioView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/GranizoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/PatrimonialView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/RiscosDiversosView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/VidaView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/PerfilEmpresaView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/PerfilView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/SinistroView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs create mode 100644 Codemerx/Gestor.Application/Views/TutorialView.cs (limited to 'Codemerx/Gestor.Application/Views') diff --git a/Codemerx/Gestor.Application/Views/Ajuda/AtendimentosView.cs b/Codemerx/Gestor.Application/Views/Ajuda/AtendimentosView.cs new file mode 100644 index 0000000..9cf46c0 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ajuda/AtendimentosView.cs @@ -0,0 +1,302 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Drawer.Ajuda; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Model.API; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Seguros; +using MaterialDesignThemes.Wpf; +using mshtml; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +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 Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.Ajuda +{ + public class AtendimentosView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal AtendimentosViewModel ViewModel; + + internal ComboBox StatusCbo; + + internal DataGrid AtendimentosGrid; + + internal DataGridTextColumn SolucaoColumn; + + internal TextBox NomeBox; + + internal TextBox Ddd; + + internal TextBox TelefoneBox; + + internal TextBox ValorBox; + + internal TextBox AssuntoBox; + + internal TextBox IdAcessoBox; + + internal TextBox SenhaBox; + + internal Gestor.Application.Componentes.WebEditor WebEditor; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public AtendimentosView() + { + this.ViewModel = new AtendimentosViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + this.ViewModel.Head = string.Concat(Recursos.Usuario.get_Nome(), " - ", Recursos.Empresa.get_Nome(), ", VOCÊ ESTÁ EM ATENDIMENTOS"); + this.StatusCbo.SelectedIndex = 0; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + } + + private void AbrirAntendimento_OnClick(object sender, RoutedEventArgs e) + { + this.AtendimentosGrid.SelectedItem = null; + this.ViewModel.LimparComponentes(); + if (this.WebEditor.WebBrowserEditor.HtmlDocument.body != null) + { + this.WebEditor.WebBrowserEditor.HtmlDocument.body.innerHTML = string.Empty; + } + this.ViewModel.AtendimentoVisibility = System.Windows.Visibility.Collapsed; + this.ViewModel.EnvioEmailVisibility = System.Windows.Visibility.Visible; + this.ViewModel.IsEnabled = false; + } + + private void AcessoRemoto_OnClick(object sender, RoutedEventArgs e) + { + string str = "c:\\AggerSeguros\\Remoto.exe"; + if (File.Exists(str)) + { + Process.Start(str); + return; + } + Parameters parameter = new Parameters(); + parameter.set_Beta(false); + parameter.set_Type(99); + parameter.set_Application("Remoto.exe"); + parameter.set_Directory(""); + parameter.set_Run(true); + (new DownloadWindow(parameter)).Show(); + } + + private void AnexarArquivos_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Anexar(); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IsEnabled = true; + this.ViewModel.SelecionaAtendimento(); + } + + private void DeleteArquivo_OnDeleteClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(chip); + Gestor.Model.Domain.Common.ArquivoDigital item = (Gestor.Model.Domain.Common.ArquivoDigital)listBox.Items[listBox.Items.IndexOf(chip.DataContext)]; + if (item == null) + { + return; + } + this.ViewModel.Delete(item); + } + + private async void Enviar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.ViewModel.Corpo = this.WebEditor.GetHtml(); + List> keyValuePairs = await this.ViewModel.Enviar(); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (keyValuePairs != null) + { + List> keyValuePairs1 = keyValuePairs; + if (keyValuePairs1.Any>((KeyValuePair x) => x.Key == "fail")) + { + List> keyValuePairs2 = keyValuePairs; + List> keyValuePairs3 = keyValuePairs; + keyValuePairs2.Remove(keyValuePairs3.First>((KeyValuePair x) => x.Key == "fail")); + } + } + this.ValidateFields(keyValuePairs, true); + this.ViewModel.Loading(false); + if (flag) + { + await this.ViewModel.ShowMessage("SOLICITAÇÃO ENVIADA PARA AGGER, POR FAVOR AGUARDE NOSSO RETORNO!", "OK", "", false); + this.WebEditor.Body = ""; + } + else + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [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/ajuda/atendimentosview.xaml", UriKind.Relative)); + } + + private void SelectedStatus_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (this.StatusCbo.SelectedItem == null) + { + return; + } + this.ViewModel.WorkOnSelectedStatus(this.StatusCbo.SelectedItem.ToString()); + this.SolucaoColumn.Visibility = (this.StatusCbo.SelectedItem.ToString() == "PENDENTES" ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + } + + [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.StatusCbo = (ComboBox)target; + this.StatusCbo.SelectionChanged += new SelectionChangedEventHandler(this.SelectedStatus_OnSelectionChanged); + return; + } + case 2: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAntendimento_OnClick); + return; + } + case 3: + { + this.AtendimentosGrid = (DataGrid)target; + return; + } + case 4: + { + this.SolucaoColumn = (DataGridTextColumn)target; + return; + } + case 5: + { + ((Button)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 6: + { + ((Button)target).Click += new RoutedEventHandler(this.AnexarArquivos_OnClick); + return; + } + case 7: + { + ((Button)target).Click += new RoutedEventHandler(this.Enviar_OnClick); + return; + } + case 8: + { + this.NomeBox = (TextBox)target; + return; + } + case 9: + { + this.Ddd = (TextBox)target; + AtendimentosView atendimentosView = this; + this.Ddd.PreviewTextInput += new TextCompositionEventHandler(atendimentosView.SomenteNumeros); + return; + } + case 10: + { + this.TelefoneBox = (TextBox)target; + AtendimentosView atendimentosView1 = this; + this.TelefoneBox.LostFocus += new RoutedEventHandler(atendimentosView1.FormatarTelefone); + AtendimentosView atendimentosView2 = this; + this.TelefoneBox.PreviewTextInput += new TextCompositionEventHandler(atendimentosView2.SomenteNumeros); + return; + } + case 11: + { + this.ValorBox = (TextBox)target; + return; + } + case 12: + { + this.AssuntoBox = (TextBox)target; + return; + } + case 13: + { + this.IdAcessoBox = (TextBox)target; + return; + } + case 14: + { + this.SenhaBox = (TextBox)target; + return; + } + case 15: + { + ((Button)target).Click += new RoutedEventHandler(this.AcessoRemoto_OnClick); + return; + } + case 16: + { + this._contentLoaded = true; + return; + } + case 17: + { + this.WebEditor = (Gestor.Application.Componentes.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 == 16) + { + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.DeleteArquivo_OnDeleteClick)); + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/BI/AcompanhamentoView.cs b/Codemerx/Gestor.Application/Views/BI/AcompanhamentoView.cs new file mode 100644 index 0000000..a509fdf --- /dev/null +++ b/Codemerx/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/Codemerx/Gestor.Application/Views/BI/AgendaBIView.cs b/Codemerx/Gestor.Application/Views/BI/AgendaBIView.cs new file mode 100644 index 0000000..33865eb --- /dev/null +++ b/Codemerx/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/Codemerx/Gestor.Application/Views/BI/NotasView.cs b/Codemerx/Gestor.Application/Views/BI/NotasView.cs new file mode 100644 index 0000000..1386592 --- /dev/null +++ b/Codemerx/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/Codemerx/Gestor.Application/Views/BI/PainelBiView.cs b/Codemerx/Gestor.Application/Views/BI/PainelBiView.cs new file mode 100644 index 0000000..1886b4f --- /dev/null +++ b/Codemerx/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/Codemerx/Gestor.Application/Views/BI/ProspeccaoView.cs b/Codemerx/Gestor.Application/Views/BI/ProspeccaoView.cs new file mode 100644 index 0000000..b625599 --- /dev/null +++ b/Codemerx/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/Codemerx/Gestor.Application/Views/BI/TarefaView.cs b/Codemerx/Gestor.Application/Views/BI/TarefaView.cs new file mode 100644 index 0000000..7ca7f68 --- /dev/null +++ b/Codemerx/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 diff --git a/Codemerx/Gestor.Application/Views/ConnectionRetryView.cs b/Codemerx/Gestor.Application/Views/ConnectionRetryView.cs new file mode 100644 index 0000000..94d0947 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/ConnectionRetryView.cs @@ -0,0 +1,218 @@ +using Gestor.Application; +using Gestor.Application.Helpers; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Reflection; +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.Media; +using System.Windows.Shapes; +using System.Windows.Shell; + +namespace Gestor.Application.Views +{ + public class ConnectionRetryView : Window, IComponentConnector + { + public TaskCompletionSource CloseTask = new TaskCompletionSource(); + + private bool _buttonClickable; + + internal System.Windows.Shell.WindowChrome WindowChrome; + + internal Grid MinimizeButton; + + internal Grid CloseButton; + + internal ProgressBar ProgressRing; + + internal ItemsControl Controls; + + private bool _contentLoaded; + + public UnitOfWork UnitOfWOrk + { + get; + set; + } + + public ConnectionRetryView() + { + this.InitializeComponent(); + this.MinimizeButton.MouseEnter += new MouseEventHandler(ConnectionRetryView.TopControls_OnMouseEnter); + this.MinimizeButton.MouseLeave += new MouseEventHandler(this.TopControls_OnMouseLeave); + this.CloseButton.MouseEnter += new MouseEventHandler(ConnectionRetryView.TopControls_OnMouseEnter); + this.CloseButton.MouseLeave += new MouseEventHandler(this.TopControls_OnMouseLeave); + base.Closed += new EventHandler((object s, EventArgs a) => this.CloseTask.SetResult(null)); + } + + private void btnRestart_OnClick(object sender, RoutedEventArgs e) + { + Instancia.App.Restart(); + } + + private async void btnRetry_Click(object sender, RoutedEventArgs e) + { + this.Loading(true); + UnitOfWork unitOfWork1 = await Task.Run(() => { + UnitOfWork unitOfWork; + try + { + Instancia.Conexao = Instancia.Conexao ?? Connection.GetConnection(true); + unitOfWork = new UnitOfWork(Instancia.Conexao, true); + } + catch (Exception exception) + { + unitOfWork = null; + } + return unitOfWork; + }); + this.Loading(false); + if (unitOfWork1 != null && unitOfWork1.get_HasSession()) + { + this.UnitOfWOrk = unitOfWork1; + base.Close(); + } + } + + public void CloseButton_Click() + { + base.Close(); + } + + [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/connectionretryview.xaml", UriKind.Relative)); + } + + private void Loading(bool isLoading) + { + this.Controls.Visibility = (!isLoading ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ProgressRing.Visibility = (isLoading ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + base.IsEnabled = !isLoading; + } + + public void MinimizeButton_Click() + { + base.WindowState = System.Windows.WindowState.Minimized; + } + + [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.WindowChrome = (System.Windows.Shell.WindowChrome)target; + return; + } + case 2: + { + this.MinimizeButton = (Grid)target; + this.MinimizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.MinimizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 3: + { + this.CloseButton = (Grid)target; + this.CloseButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.CloseButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 4: + { + this.ProgressRing = (ProgressBar)target; + return; + } + case 5: + { + this.Controls = (ItemsControl)target; + return; + } + case 6: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.btnRetry_Click); + return; + } + case 7: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.btnRestart_OnClick); + return; + } + } + this._contentLoaded = true; + } + + private static void TopControls_OnMouseEnter(object sender, MouseEventArgs e) + { + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Color.FromRgb(232, 17, 35)) : new SolidColorBrush(Colors.Blue)); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeave(object sender, MouseEventArgs e) + { + this._buttonClickable = false; + ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + this._buttonClickable = true; + if (((Grid)sender).Name != "CloseButton") + { + ((Grid)sender).Background = new SolidColorBrush(Colors.Blue); + } + else + { + ((Grid)sender).Background = new SolidColorBrush(Color.FromRgb(241, 112, 123)); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.Black); + return; + } + } + } + + private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + if (this._buttonClickable) + { + MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click")); + if (method == null) + { + return; + } + method.Invoke(this, null); + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/CadastroEmailView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/CadastroEmailView.cs new file mode 100644 index 0000000..d4691ca --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/CadastroEmailView.cs @@ -0,0 +1,400 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; +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.Ferramentas +{ + public class CadastroEmailView : UserControl, IComponentConnector + { + internal DataGrid CredenciaisGrid; + + internal MenuItem SalvarApoliceButton; + + internal MenuItem CancelarApoliceButton; + + internal MenuItem MaisOpcoesButton; + + internal TextBox DescricaoBox; + + internal TextBox HeaderBox; + + internal ComboBox TipoBox; + + internal TextBox PortaBox; + + internal TextBox DominioBox; + + internal TextBox EmailBox; + + internal CustomPasswordBox SenhaBox; + + internal TextBox LoginBox; + + internal TextBlock CabecalhoTitulo; + + internal WebEditor Cabecalho; + + internal TextBlock AssinaturaTitulo; + + internal WebEditor Assinatura; + + private bool _contentLoaded; + + public CadastroEmailViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public CadastroEmailView() + { + base.Tag = "CADASTRO DE E-MAIL"; + this.ViewModel = new CadastroEmailViewModel(); + 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(17, this.ViewModel.SelectedCredencial.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.Assinatura.Visibility = System.Windows.Visibility.Visible; + this.AssinaturaTitulo.Visibility = System.Windows.Visibility.Visible; + this.Cabecalho.Visibility = System.Windows.Visibility.Visible; + this.CabecalhoTitulo.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.ViewModel.SelectedCredencial.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarCredenciais(""); + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 ButtonBase_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + bool flag = await this.ViewModel.EnviarTesteEmail(); + this.ViewModel.Loading(false); + if (flag) + { + this.ViewModel.ToggleSnackBar("E-MAIL ENVIADO COM SUCESSO.", true); + } + } + + private async void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + await this.ViewModel.CancelarAlteracao(); + this.Assinatura.Initialize(null); + this.Assinatura.Visibility = System.Windows.Visibility.Collapsed; + this.AssinaturaTitulo.Visibility = System.Windows.Visibility.Collapsed; + this.Cabecalho.Initialize(null); + this.Cabecalho.Visibility = System.Windows.Visibility.Collapsed; + this.CabecalhoTitulo.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.Loading(false); + this.ScrollToItem(); + } + + private async void ContentLoad() + { + this.ViewModel.Loading(true); + await this.ViewModel.SelecionaCredenciais(); + this.ViewModel.Loading(false); + } + + private void EmailBox_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + if (((TextBox)sender).Text.Contains("@gmail.com")) + { + this.TipoBox.SelectedItem = (TipoEmail)1; + } + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Excluir(); + this.ScrollToItem(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.Assinatura.Visibility = System.Windows.Visibility.Visible; + this.AssinaturaTitulo.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/ferramentas/cadastroemailview.xaml", UriKind.Relative)); + } + + public string ReplaceLocalImages(string mailBody) + { + string[] array = ( + from Match m in Regex.Matches(mailBody, "", RegexOptions.IgnoreCase) + select m.Groups[0].Value).ToArray(); + for (int i = 0; i < (int)array.Length; i++) + { + string value = Regex.Match(array[i], "(?<=src=\")(.*?)(?=\")", RegexOptions.IgnoreCase).Value; + string str = Regex.Match(value, "file:(///).*\\.(.*)", RegexOptions.IgnoreCase).Groups[2].Value; + if (str == "jpg") + { + str = "jpeg"; + } + if (Uri.IsWellFormedUriString(value, UriKind.Absolute)) + { + Uri uri = new Uri(value); + if (File.Exists(uri.LocalPath)) + { + mailBody = mailBody.Replace(value, string.Concat("data:image/", str, ";base64,", Convert.ToBase64String(File.ReadAllBytes(uri.LocalPath)))); + } + } + } + return mailBody; + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.ViewModel.SelectedCredencial.set_Assinatura(this.ReplaceLocalImages(this.Assinatura.GetHtml())); + this.ViewModel.SelectedCredencial.set_Cabecalho(this.ReplaceLocalImages(this.Cabecalho.GetHtml())); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.Assinatura.Visibility = System.Windows.Visibility.Collapsed; + this.AssinaturaTitulo.Visibility = System.Windows.Visibility.Collapsed; + this.Cabecalho.Visibility = System.Windows.Visibility.Collapsed; + this.CabecalhoTitulo.Visibility = System.Windows.Visibility.Collapsed; + this.ScrollToItem(); + } + } + + private void ScrollToItem() + { + if (this.CredenciaisGrid.SelectedItem == null) + { + return; + } + this.CredenciaisGrid.UpdateLayout(); + this.CredenciaisGrid.ScrollIntoView(this.CredenciaisGrid.SelectedItem); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, CadastroEmailView.AutoCompleteBox_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.CredenciaisGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + this.SalvarApoliceButton = (MenuItem)target; + this.SalvarApoliceButton.Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + this.CancelarApoliceButton = (MenuItem)target; + this.CancelarApoliceButton.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 8: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ButtonBase_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 11: + { + this.DescricaoBox = (TextBox)target; + return; + } + case 12: + { + this.HeaderBox = (TextBox)target; + return; + } + case 13: + { + this.TipoBox = (ComboBox)target; + this.TipoBox.SelectionChanged += new SelectionChangedEventHandler(this.Tipo_OnSelectionChanged); + return; + } + case 14: + { + this.PortaBox = (TextBox)target; + return; + } + case 15: + { + this.DominioBox = (TextBox)target; + return; + } + case 16: + { + this.EmailBox = (TextBox)target; + this.EmailBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.EmailBox_OnLostKeyboardFocus); + return; + } + case 17: + { + this.SenhaBox = (CustomPasswordBox)target; + return; + } + case 18: + { + this.LoginBox = (TextBox)target; + return; + } + case 19: + { + this.CabecalhoTitulo = (TextBlock)target; + return; + } + case 20: + { + this.Cabecalho = (WebEditor)target; + return; + } + case 21: + { + this.AssinaturaTitulo = (TextBlock)target; + return; + } + case 22: + { + this.Assinatura = (WebEditor)target; + return; + } + } + this._contentLoaded = true; + } + + private void Tipo_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + TipoEmail? selectedItem = (TipoEmail?)((ComboBox)sender).SelectedItem; + if (selectedItem.GetValueOrDefault() == 0 & selectedItem.HasValue && this.ViewModel.SelectedCredencial.get_Email() != null && this.ViewModel.SelectedCredencial.get_Email().Contains("@gmail.com")) + { + this.EmailBox.Text = ""; + } + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedCredencial == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedCredencial.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/CadastroParceiroView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/CadastroParceiroView.cs new file mode 100644 index 0000000..ae3bfde --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/CadastroParceiroView.cs @@ -0,0 +1,387 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +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.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.Ferramentas +{ + public class CadastroParceiroView : BaseUserControl, IComponentConnector + { + internal DataGrid ParceiroGrid; + + internal MenuItem MaisOpcoesButton; + + internal TextBox NomeBox; + + internal TextBox DocumentoPrincipalBox; + + internal TextBox PrimeiroPrefixo; + + internal TextBox PrimeiroTelefone; + + internal TextBox SegundoPrefixo; + + internal TextBox SegundoTelefone; + + internal TextBox TerceiroPrefixo; + + internal TextBox TerceiroTelefone; + + internal TextBox EmailBox; + + internal TextBox CepBox; + + internal TextBox EnderecoBox; + + internal TextBox NumeroBox; + + internal TextBox BairroBox; + + internal TextBox CidadeBox; + + internal TextBox EstadoBox; + + private bool _contentLoaded; + + public CadastroParceiroViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public CadastroParceiroView(Parceiro parceiro = null) + { + CadastroParceiroView cadastroParceiroView = this; + base.Tag = "CADASTRO DE PARCEIROS"; + this.ViewModel = new CadastroParceiroViewModel(parceiro); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() => cadastroParceiroView.ContentLoad(parceiro))); + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(22, this.ViewModel.SelectedParceiro.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelParceiro = (Parceiro)this.ViewModel.SelectedParceiro.Clone(); + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.ViewModel.SelectedParceiro.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarParceiro(""); + } + + private void AutoCompleteBoxParceiro_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad(Parceiro parceiro) + { + if (parceiro == null) + { + this.ParceiroGrid.SelectedIndex = -1; + } + this.ParceiroGrid.SelectionChanged += new SelectionChangedEventHandler(this.ParceiroGrid_OnSelectionChanged); + this.ParceiroGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + } + + private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e) + { + if (((TextBox)sender).IsReadOnly) + { + return; + } + string str = ValidationHelper.Clear(this.DocumentoPrincipalBox.Text); + if (string.IsNullOrEmpty(str)) + { + return; + } + this.DocumentoPrincipalBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14))); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/ferramentas/cadastroparceiroview.xaml", UriKind.Relative)); + } + + private void ParceiroGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionarParceiro((Parceiro)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + string str = ValidationHelper.FormatPostCode(((TextBox)sender).Text); + this.CepBox.Text = str; + if (ValidationHelper.ValidatePostCode(str)) + { + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + this.EnderecoBox.Text = enderecoBase.get_Endereco(); + this.CidadeBox.Text = enderecoBase.get_Cidade(); + this.EstadoBox.Text = enderecoBase.get_Estado(); + this.BairroBox.Text = enderecoBase.get_Bairro(); + } + } + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.NomeBox.Focus(); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, CadastroParceiroView.AutoCompleteBoxParceiro_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.ParceiroGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 8: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + this.NomeBox = (TextBox)target; + return; + } + case 11: + { + this.DocumentoPrincipalBox = (TextBox)target; + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + CadastroParceiroView cadastroParceiroView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(cadastroParceiroView.SomenteNumeros); + return; + } + case 12: + { + this.PrimeiroPrefixo = (TextBox)target; + CadastroParceiroView cadastroParceiroView1 = this; + this.PrimeiroPrefixo.PreviewTextInput += new TextCompositionEventHandler(cadastroParceiroView1.SomenteNumeros); + return; + } + case 13: + { + this.PrimeiroTelefone = (TextBox)target; + CadastroParceiroView cadastroParceiroView2 = this; + this.PrimeiroTelefone.LostFocus += new RoutedEventHandler(cadastroParceiroView2.FormatarTelefone); + CadastroParceiroView cadastroParceiroView3 = this; + this.PrimeiroTelefone.PreviewTextInput += new TextCompositionEventHandler(cadastroParceiroView3.SomenteNumeros); + return; + } + case 14: + { + this.SegundoPrefixo = (TextBox)target; + CadastroParceiroView cadastroParceiroView4 = this; + this.SegundoPrefixo.PreviewTextInput += new TextCompositionEventHandler(cadastroParceiroView4.SomenteNumeros); + return; + } + case 15: + { + this.SegundoTelefone = (TextBox)target; + CadastroParceiroView cadastroParceiroView5 = this; + this.SegundoTelefone.LostFocus += new RoutedEventHandler(cadastroParceiroView5.FormatarTelefone); + CadastroParceiroView cadastroParceiroView6 = this; + this.SegundoTelefone.PreviewTextInput += new TextCompositionEventHandler(cadastroParceiroView6.SomenteNumeros); + return; + } + case 16: + { + this.TerceiroPrefixo = (TextBox)target; + CadastroParceiroView cadastroParceiroView7 = this; + this.TerceiroPrefixo.PreviewTextInput += new TextCompositionEventHandler(cadastroParceiroView7.SomenteNumeros); + return; + } + case 17: + { + this.TerceiroTelefone = (TextBox)target; + CadastroParceiroView cadastroParceiroView8 = this; + this.TerceiroTelefone.LostFocus += new RoutedEventHandler(cadastroParceiroView8.FormatarTelefone); + CadastroParceiroView cadastroParceiroView9 = this; + this.TerceiroTelefone.PreviewTextInput += new TextCompositionEventHandler(cadastroParceiroView9.SomenteNumeros); + return; + } + case 18: + { + this.EmailBox = (TextBox)target; + return; + } + case 19: + { + this.CepBox = (TextBox)target; + this.CepBox.LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + CadastroParceiroView cadastroParceiroView10 = this; + this.CepBox.PreviewTextInput += new TextCompositionEventHandler(cadastroParceiroView10.SomenteNumeros); + return; + } + case 20: + { + this.EnderecoBox = (TextBox)target; + return; + } + case 21: + { + this.NumeroBox = (TextBox)target; + return; + } + case 22: + { + this.BairroBox = (TextBox)target; + return; + } + case 23: + { + this.CidadeBox = (TextBox)target; + return; + } + case 24: + { + this.EstadoBox = (TextBox)target; + return; + } + } + this._contentLoaded = true; + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedParceiro == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedParceiro.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/DownloadWindow.cs b/Codemerx/Gestor.Application/Views/Ferramentas/DownloadWindow.cs new file mode 100644 index 0000000..1fd4776 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/DownloadWindow.cs @@ -0,0 +1,171 @@ +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.API; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Reflection; +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; +using System.Windows.Shapes; +using System.Windows.Shell; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Ferramentas +{ + public class DownloadWindow : Window, IComponentConnector + { + internal DownloadViewModel ViewModel; + + private bool _buttonClickable; + + internal System.Windows.Shell.WindowChrome WindowChrome; + + internal Grid MinimizeButton; + + internal Grid MaximizeButton; + + internal Grid CloseButton; + + private bool _contentLoaded; + + public DownloadWindow(Parameters parameters) + { + this.ViewModel = new DownloadViewModel(parameters); + 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)); + } + + public void CloseButton_Click() + { + base.Close(); + } + + private void ContentLoad() + { + this.MinimizeButton.MouseEnter += new MouseEventHandler(DownloadWindow.TopControls_OnMouseEnter); + this.MinimizeButton.MouseLeave += new MouseEventHandler(this.TopControls_OnMouseLeave); + this.MaximizeButton.MouseEnter += new MouseEventHandler(DownloadWindow.TopControls_OnMouseEnter); + this.MaximizeButton.MouseLeave += new MouseEventHandler(this.TopControls_OnMouseLeave); + this.CloseButton.MouseEnter += new MouseEventHandler(DownloadWindow.TopControls_OnMouseEnter); + this.CloseButton.MouseLeave += new MouseEventHandler(this.TopControls_OnMouseLeave); + } + + private async void DownloadWindow_OnLoaded(object sender, RoutedEventArgs e) + { + this.ViewModel.IsEnabled = false; + await this.ViewModel.Atualizar(); + } + + [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/ferramentas/downloadwindow.xaml", UriKind.Relative)); + } + + public void MinimizeButton_Click() + { + base.WindowState = System.Windows.WindowState.Minimized; + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((DownloadWindow)target).Loaded += new RoutedEventHandler(this.DownloadWindow_OnLoaded); + return; + } + case 2: + { + this.WindowChrome = (System.Windows.Shell.WindowChrome)target; + return; + } + case 3: + { + this.MinimizeButton = (Grid)target; + this.MinimizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.MinimizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 4: + { + this.MaximizeButton = (Grid)target; + this.MaximizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.MaximizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 5: + { + this.CloseButton = (Grid)target; + this.CloseButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.CloseButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + } + this._contentLoaded = true; + } + + private static void TopControls_OnMouseEnter(object sender, MouseEventArgs e) + { + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray)); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeave(object sender, MouseEventArgs e) + { + this._buttonClickable = false; + ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + this._buttonClickable = true; + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.DimGray)); + } + + private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + if (this._buttonClickable) + { + MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click")); + if (method == null) + { + return; + } + method.Invoke(this, null); + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/EmpresaView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/EmpresaView.cs new file mode 100644 index 0000000..f431ae6 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/EmpresaView.cs @@ -0,0 +1,424 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Drawers.Configuracoes; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +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.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.Ferramentas +{ + public class EmpresaView : BaseUserControl, IComponentConnector + { + internal DataGrid EmpresaGrid; + + internal MenuItem Alterar; + + internal TextBox DocumentoPrincipalBox; + + internal TextBox NomeBox; + + internal TextBox CepBox; + + internal TextBox EnderecoBox; + + internal TextBox BairroBox; + + internal TextBox CidadeBox; + + internal TextBox EstadoBox; + + internal CustomPasswordBox SenhaBox; + + private bool _contentLoaded; + + public EmpresaViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public EmpresaView() + { + base.Tag = "CADASTRO DE EMPRESA E FILIAIS"; + this.ViewModel = new EmpresaViewModel(); + 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 async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 13).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedEmpresa.get_Id()); + filtroArquivoDigital.set_Tipo(13); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedEmpresa); + 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)13), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(18, this.ViewModel.SelectedEmpresa.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(18, this.ViewModel.SelectedEmpresa.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelEmpresa = (Empresa)this.ViewModel.SelectedEmpresa.Clone(); + this.ViewModel.Alterar(true); + this.PermissaoAuteracao(); + this.ViewModel.PassWordReadOnly = this.ViewModel.EnableFields; + this.ViewModel.ConfirmacaoSenha = (this.ViewModel.SelectedEmpresa.get_Id() == (long)1 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private async void AnexarLogo_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + await this.ViewModel.AnexarLogo(); + this.ViewModel.Loading(false); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarEmpresa(""); + } + + private void AutoCompleteBoxEmpresa_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + if (Recursos.Usuario.get_Id() == 0) + { + this.Alterar.IsEnabled = true; + } + this.NomeBox.IsReadOnly = true; + this.DocumentoPrincipalBox.IsReadOnly = true; + this.ViewModel.PassWordReadOnly = this.ViewModel.EnableFields; + this.ViewModel.ConfirmacaoSenha = System.Windows.Visibility.Collapsed; + } + + private async void Configuracoes_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.VerificarRestricao(64, false, true)) + { + this.ViewModel.ShowDrawer(new ConfiguracoesDrawer(), 0, false); + } + } + + private void ContentLoad() + { + this.EmpresaGrid.SelectedIndex = 0; + this.EmpresaGrid.SelectionChanged += new SelectionChangedEventHandler(this.EmpresaGrid_OnSelectionChanged); + this.EmpresaGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + if (Recursos.Usuario.get_Id() == 0) + { + this.Alterar.IsEnabled = true; + } + } + + private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e) + { + if (((TextBox)sender).IsReadOnly) + { + return; + } + string str = this.DocumentoPrincipalBox.Text.Clear(); + if (string.IsNullOrEmpty(str)) + { + return; + } + this.DocumentoPrincipalBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14))); + } + + private void EmpresaGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaEmpresa((Empresa)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + [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/ferramentas/empresaview.xaml", UriKind.Relative)); + } + + public void PermissaoAuteracao() + { + if (Recursos.Usuario.get_Id() != 0) + { + this.DocumentoPrincipalBox.IsReadOnly = true; + this.NomeBox.IsReadOnly = true; + return; + } + this.ViewModel.ConfirmacaoSenha = (this.ViewModel.SelectedEmpresa.get_Id() == (long)1 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ViewModel.PassWordReadOnly = true; + this.Alterar.IsEnabled = false; + this.DocumentoPrincipalBox.IsReadOnly = false; + this.NomeBox.IsReadOnly = false; + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + if (this.ViewModel.EnableFields) + { + string str = ValidationHelper.FormatPostCode(((TextBox)sender).Text); + this.CepBox.Text = str; + if (ValidationHelper.ValidatePostCode(str)) + { + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + this.EnderecoBox.Text = enderecoBase.get_Endereco(); + this.CidadeBox.Text = enderecoBase.get_Cidade(); + this.EstadoBox.Text = enderecoBase.get_Estado(); + this.BairroBox.Text = enderecoBase.get_Bairro(); + } + } + } + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + System.Windows.Visibility visibility; + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + this.ViewModel.PassWordReadOnly = this.ViewModel.EnableFields; + EmpresaViewModel viewModel = this.ViewModel; + visibility = (keyValuePairs == null || keyValuePairs.Count <= 0 ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + viewModel.ConfirmacaoSenha = visibility; + if (Recursos.Usuario.get_Id() == 0) + { + this.Alterar.IsEnabled = true; + this.NomeBox.IsReadOnly = true; + this.DocumentoPrincipalBox.IsReadOnly = true; + } + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, EmpresaView.AutoCompleteBoxEmpresa_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.EmpresaGrid = (DataGrid)target; + return; + } + case 3: + { + this.Alterar = (MenuItem)target; + this.Alterar.Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AnexarLogo_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Configuracoes_OnClick); + return; + } + case 11: + { + this.DocumentoPrincipalBox = (TextBox)target; + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + EmpresaView empresaView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(empresaView.SomenteNumeros); + return; + } + case 12: + { + this.NomeBox = (TextBox)target; + return; + } + case 13: + { + this.CepBox = (TextBox)target; + this.CepBox.LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + EmpresaView empresaView1 = this; + this.CepBox.PreviewTextInput += new TextCompositionEventHandler(empresaView1.SomenteNumeros); + return; + } + case 14: + { + this.EnderecoBox = (TextBox)target; + return; + } + case 15: + { + this.BairroBox = (TextBox)target; + return; + } + case 16: + { + this.CidadeBox = (TextBox)target; + return; + } + case 17: + { + this.EstadoBox = (TextBox)target; + return; + } + case 18: + { + this.SenhaBox = (CustomPasswordBox)target; + return; + } + case 19: + { + EmpresaView empresaView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(empresaView2.SomenteNumeros); + return; + } + case 20: + { + EmpresaView empresaView3 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(empresaView3.FormatarTelefone); + EmpresaView empresaView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(empresaView4.SomenteNumeros); + return; + } + case 21: + { + EmpresaView empresaView5 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(empresaView5.SomenteNumeros); + return; + } + case 22: + { + EmpresaView empresaView6 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(empresaView6.FormatarTelefone); + EmpresaView empresaView7 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(empresaView7.SomenteNumeros); + return; + } + case 23: + { + EmpresaView empresaView8 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(empresaView8.SomenteNumeros); + return; + } + case 24: + { + EmpresaView empresaView9 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(empresaView9.SomenteNumeros); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/EstipulanteView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/EstipulanteView.cs new file mode 100644 index 0000000..b546879 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/EstipulanteView.cs @@ -0,0 +1,395 @@ +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Ferramentas; +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.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; + +namespace Gestor.Application.Views.Ferramentas +{ + public class EstipulanteView : BaseUserControl, IComponentConnector + { + public EstipulanteViewModel ViewModel; + + internal DataGrid EstipulanteGrid; + + internal MenuItem MaisOpcoesButton; + + internal TextBox EmpresaBox; + + internal TextBox NomeBox; + + internal TextBox DocumentoPrincipalBox; + + internal ToggleButton AtivoBox; + + internal TextBox PrimeiroPrefixo; + + internal TextBox PrimeiroTelefone; + + internal TextBox SegundoPrefixo; + + internal TextBox SegundoTelefone; + + internal TextBox EmailBox; + + internal TextBox CepBox; + + internal TextBox EnderecoBox; + + internal TextBox NumeroBox; + + internal TextBox BairroBox; + + internal TextBox CidadeBox; + + internal TextBox EstadoBox; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public EstipulanteView() + { + base.Tag = "CADASTRO DE ESTIPULANTE"; + this.ViewModel = new EstipulanteViewModel(); + 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(9, this.ViewModel.SelectedEstipulante.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelEstipulante = (Estipulante)this.ViewModel.SelectedEstipulante.Clone(); + this.ViewModel.Alterar(true); + this.ValidarTela(); + } + + private async void ArquivoDigital_OnClick(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 5).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedEstipulante.get_Id()); + filtroArquivoDigital.set_Tipo(17); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedEstipulante); + 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)17), "."), "OK", "", false); + } + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarEstipulante(""); + } + + private void AutoCompleteBoxEstipulante_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.EstipulanteGrid.SelectedIndex = 0; + this.EstipulanteGrid.SelectionChanged += new SelectionChangedEventHandler(this.EstipulanteGrid_OnSelectionChanged); + this.EstipulanteGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + } + + private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e) + { + if (((TextBox)sender).IsReadOnly) + { + return; + } + string str = ValidationHelper.Clear(this.DocumentoPrincipalBox.Text); + if (string.IsNullOrEmpty(str)) + { + return; + } + this.DocumentoPrincipalBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14))); + } + + private void EstipulanteGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaEstipulante((Estipulante)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/ferramentas/estipulanteview.xaml", UriKind.Relative)); + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + string str = ValidationHelper.FormatPostCode(((TextBox)sender).Text); + this.CepBox.Text = str; + if (ValidationHelper.ValidatePostCode(str)) + { + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + this.EnderecoBox.Text = enderecoBase.get_Endereco(); + this.CidadeBox.Text = enderecoBase.get_Cidade(); + this.EstadoBox.Text = enderecoBase.get_Estado(); + this.BairroBox.Text = enderecoBase.get_Bairro(); + } + } + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, EstipulanteView.AutoCompleteBoxEstipulante_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.EstipulanteGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 8: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ArquivoDigital_OnClick); + return; + } + case 11: + { + this.EmpresaBox = (TextBox)target; + return; + } + case 12: + { + this.NomeBox = (TextBox)target; + return; + } + case 13: + { + this.DocumentoPrincipalBox = (TextBox)target; + EstipulanteView estipulanteView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(estipulanteView.SomenteNumeros); + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + return; + } + case 14: + { + this.AtivoBox = (ToggleButton)target; + return; + } + case 15: + { + this.PrimeiroPrefixo = (TextBox)target; + EstipulanteView estipulanteView1 = this; + this.PrimeiroPrefixo.PreviewTextInput += new TextCompositionEventHandler(estipulanteView1.SomenteNumeros); + return; + } + case 16: + { + this.PrimeiroTelefone = (TextBox)target; + EstipulanteView estipulanteView2 = this; + this.PrimeiroTelefone.LostFocus += new RoutedEventHandler(estipulanteView2.FormatarTelefone); + EstipulanteView estipulanteView3 = this; + this.PrimeiroTelefone.PreviewTextInput += new TextCompositionEventHandler(estipulanteView3.SomenteNumeros); + return; + } + case 17: + { + this.SegundoPrefixo = (TextBox)target; + EstipulanteView estipulanteView4 = this; + this.SegundoPrefixo.PreviewTextInput += new TextCompositionEventHandler(estipulanteView4.SomenteNumeros); + return; + } + case 18: + { + this.SegundoTelefone = (TextBox)target; + EstipulanteView estipulanteView5 = this; + this.SegundoTelefone.LostFocus += new RoutedEventHandler(estipulanteView5.FormatarTelefone); + EstipulanteView estipulanteView6 = this; + this.SegundoTelefone.PreviewTextInput += new TextCompositionEventHandler(estipulanteView6.SomenteNumeros); + return; + } + case 19: + { + this.EmailBox = (TextBox)target; + return; + } + case 20: + { + this.CepBox = (TextBox)target; + this.CepBox.LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + EstipulanteView estipulanteView7 = this; + this.CepBox.PreviewTextInput += new TextCompositionEventHandler(estipulanteView7.SomenteNumeros); + return; + } + case 21: + { + this.EnderecoBox = (TextBox)target; + return; + } + case 22: + { + this.NumeroBox = (TextBox)target; + return; + } + case 23: + { + this.BairroBox = (TextBox)target; + return; + } + case 24: + { + this.CidadeBox = (TextBox)target; + return; + } + case 25: + { + this.EstadoBox = (TextBox)target; + return; + } + } + this._contentLoaded = true; + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedEstipulante == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedEstipulante.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/EtiquetaView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/EtiquetaView.cs new file mode 100644 index 0000000..985ed97 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/EtiquetaView.cs @@ -0,0 +1,157 @@ +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +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.Ferramentas +{ + public class EtiquetaView : BaseUserControl, IComponentConnector + { + internal EtiquetaViewModel ViewModel; + + internal System.Windows.Controls.AutoCompleteBox AutoCompleteBox; + + internal ProgressBar ProgressRing; + + internal System.Windows.Controls.DataGrid DataGrid; + + internal Grid Botoes; + + internal ComboBox CboTipoEtiqueta; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public EtiquetaView(List list, bool apenasCliente) + { + this.ViewModel = new EtiquetaViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + this.CboTipoEtiqueta.IsEnabled = !apenasCliente; + this.CarregarClientes(list, apenasCliente); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((System.Windows.Controls.AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarApolice(""); + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.Filtrar(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + System.Windows.Controls.AutoCompleteBox autoCompleteBox = (System.Windows.Controls.AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private async void CarregarClientes(List list, bool apenasCliente) + { + this.ProgressRing.Visibility = System.Windows.Visibility.Visible; + this.DataGrid.Visibility = System.Windows.Visibility.Collapsed; + this.Botoes.IsEnabled = false; + this.AutoCompleteBox.IsEnabled = false; + await this.ViewModel.CarregarDados(list, apenasCliente); + this.ProgressRing.Visibility = System.Windows.Visibility.Collapsed; + this.DataGrid.Visibility = System.Windows.Visibility.Visible; + this.Botoes.IsEnabled = true; + this.AutoCompleteBox.IsEnabled = true; + } + + private void Emitir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EmitirEtiquetas(); + } + + [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/ferramentas/etiquetaview.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.AutoCompleteBox = (System.Windows.Controls.AutoCompleteBox)target; + this.AutoCompleteBox.add_Populating(new PopulatingEventHandler(this, EtiquetaView.AutoCompleteBox_Populating)); + this.AutoCompleteBox.add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.ProgressRing = (ProgressBar)target; + return; + } + case 3: + { + this.DataGrid = (System.Windows.Controls.DataGrid)target; + return; + } + case 4: + { + this.Botoes = (Grid)target; + return; + } + case 5: + { + EtiquetaView etiquetaView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(etiquetaView.SomenteNumeros); + return; + } + case 6: + { + this.CboTipoEtiqueta = (ComboBox)target; + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Emitir_OnClick); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/IncluirRamoView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/IncluirRamoView.cs new file mode 100644 index 0000000..c9c8d4b --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/IncluirRamoView.cs @@ -0,0 +1,133 @@ +using Gestor.Application.Actions; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +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.Ferramentas +{ + public class IncluirRamoView : BaseUserControl, IComponentConnector + { + public IncluirRamoViewModel ViewModel; + + internal DataGrid RamoGrid; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public IncluirRamoView(List ramos) + { + this.ViewModel = new IncluirRamoViewModel(ramos); + 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 ContentLoad() + { + this.RamoGrid.SelectionChanged += new SelectionChangedEventHandler(this.RamoGrid_OnSelectionChanged); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedRamo == null) + { + return; + } + this.ViewModel.AdicionarRamo = this.ViewModel.SelectedRamo; + Action closeHoster = Gestor.Application.Actions.Actions.CloseHoster; + if (closeHoster == null) + { + return; + } + closeHoster(); + } + + [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/ferramentas/incluirramoview.xaml", UriKind.Relative)); + } + + private void Pesquisar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Pesquisar(); + } + + private void Pesquisar_OnPreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Return) + { + this.ViewModel.Pesquisar(); + } + } + + private void RamoGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelectedRamo = (Ramo)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null)); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((TextBox)target).PreviewKeyDown += new KeyEventHandler(this.Pesquisar_OnPreviewKeyDown); + return; + } + case 2: + { + ((Button)target).Click += new RoutedEventHandler(this.Pesquisar_OnClick); + return; + } + case 3: + { + this.RamoGrid = (DataGrid)target; + return; + } + case 4: + { + ((Button)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/IncluirSeguradoraView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/IncluirSeguradoraView.cs new file mode 100644 index 0000000..e76969b --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/IncluirSeguradoraView.cs @@ -0,0 +1,133 @@ +using Gestor.Application.Actions; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +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.Ferramentas +{ + public class IncluirSeguradoraView : BaseUserControl, IComponentConnector + { + public IncluirSeguradoraViewModel ViewModel; + + internal DataGrid SeguradoraGrid; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public IncluirSeguradoraView(List seguradoras) + { + this.ViewModel = new IncluirSeguradoraViewModel(seguradoras); + 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 ContentLoad() + { + this.SeguradoraGrid.SelectionChanged += new SelectionChangedEventHandler(this.SeguradoraGrid_OnSelectionChanged); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedSeguradora == null) + { + return; + } + this.ViewModel.AdicionarSeguradora = this.ViewModel.SelectedSeguradora; + Action closeHoster = Gestor.Application.Actions.Actions.CloseHoster; + if (closeHoster == null) + { + return; + } + closeHoster(); + } + + [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/ferramentas/incluirseguradoraview.xaml", UriKind.Relative)); + } + + private void Pesquisar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Pesquisar(); + } + + private void Pesquisar_OnPreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Return) + { + this.ViewModel.Pesquisar(); + } + } + + private void SeguradoraGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelectedSeguradora = (Seguradora)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null)); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((TextBox)target).PreviewKeyDown += new KeyEventHandler(this.Pesquisar_OnPreviewKeyDown); + return; + } + case 2: + { + ((Button)target).Click += new RoutedEventHandler(this.Pesquisar_OnClick); + return; + } + case 3: + { + this.SeguradoraGrid = (DataGrid)target; + return; + } + case 4: + { + ((Button)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/MalaDiretaView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/MalaDiretaView.cs new file mode 100644 index 0000000..1bb9312 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/MalaDiretaView.cs @@ -0,0 +1,301 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.MalaDireta; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +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.Markup; +using Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.Ferramentas +{ + public class MalaDiretaView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal MalaDiretaViewModel ViewModel; + + internal DataGrid Grid; + + internal TextBox AssuntoBox; + + internal Gestor.Application.Componentes.WebEditor WebEditor; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public MalaDiretaView(List maladireta, string assunto = null, string corpo = null, FiltroArquivoDigital filtro = null) + { + this.ViewModel = new MalaDiretaViewModel(filtro); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + this.CarregarClientes(maladireta, assunto, corpo); + } + + private async void AdicionarCC_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button.DataContext != null) + { + this.WebEditor.Visibility = System.Windows.Visibility.Collapsed; + Copia copium = await this.ViewModel.ShowCopiaDialog(((MalaDireta)button.DataContext).get_Copia()); + this.WebEditor.Visibility = System.Windows.Visibility.Visible; + if (copium != null) + { + ((MalaDireta)button.DataContext).set_Copia(copium); + } + } + button = null; + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void AnexarArquivos_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Anexar(); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private async void CarregarClientes(List maladireta, string assunto = null, string corpo = null) + { + this.ViewModel.IsEnabled = false; + await this.ViewModel.CarregarEmails(maladireta, assunto, corpo); + this.ViewModel.IsEnabled = true; + } + + private void CheckBox_Checked(object sender, RoutedEventArgs e) + { + this.ViewModel.Selecionar(); + } + + private void DeleteArquivo_OnDeleteClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(chip); + Gestor.Model.Domain.Common.ArquivoDigital item = (Gestor.Model.Domain.Common.ArquivoDigital)listBox.Items[listBox.Items.IndexOf(chip.DataContext)]; + if (item == null) + { + return; + } + this.ViewModel.Delete(item); + } + + private async void Enviar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IsEnabled = false; + this.ViewModel.Corpo = this.WebEditor.GetHtml(); + await this.ViewModel.Enviar(); + this.ViewModel.IsEnabled = true; + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void Fechar_OnClick(object sender, RoutedEventArgs e) + { + Funcoes.Destroy("ENVIO DE E-MAIL"); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.AssuntoBox.Focus(); + } + + [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/ferramentas/maladiretaview.xaml", UriKind.Relative)); + } + + private void ModelosBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + ModeloMalaDireta modeloMalaDireta = ((ComboModelo)comboBox.SelectedItem).ModeloMalaDireta; + if (modeloMalaDireta.get_Id() == 0) + { + return; + } + this.ViewModel.Corpo = modeloMalaDireta.get_Corpo(); + this.ViewModel.Assunto = modeloMalaDireta.get_Assunto(); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.ViewModel.Corpo = this.WebEditor.GetHtml(); + List> keyValuePairs = await this.ViewModel.Salvar(); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [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.Grid = (DataGrid)target; + return; + } + case 2: + case 3: + case 12: + { + this._contentLoaded = true; + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 9: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.ModelosBox_SelectionChanged); + return; + } + case 10: + { + this.AssuntoBox = (TextBox)target; + return; + } + case 11: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.VariaveisBox_SelectionChanged); + return; + } + case 13: + { + this.WebEditor = (Gestor.Application.Componentes.WebEditor)target; + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AnexarArquivos_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Enviar_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Fechar_OnClick); + 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 == 2) + { + ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBox_Checked); + ((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBox_Checked); + return; + } + if (connectionId == 3) + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarCC_OnClick); + return; + } + if (connectionId != 12) + { + return; + } + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.DeleteArquivo_OnDeleteClick)); + } + + private void VariaveisBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + VariaveisMalaDireta variaveisMalaDireta = ((ComboVariavel)comboBox.SelectedItem).VariaveisMalaDireta; + this.WebEditor.InsertText(string.Concat(ValidationHelper.GetEntity(variaveisMalaDireta), " ")); + comboBox.SelectedItem = null; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/ManutencaoPagamentosView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/ManutencaoPagamentosView.cs new file mode 100644 index 0000000..f57ac7c --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/ManutencaoPagamentosView.cs @@ -0,0 +1,252 @@ +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +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.Input; +using System.Windows.Markup; +using Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.Ferramentas +{ + public class ManutencaoPagamentosView : BaseUserControl, IComponentConnector, IStyleConnector + { + private bool _contentLoaded; + + public ManutencaoPagamentosViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ManutencaoPagamentosView() + { + base.Tag = "MANUTENÇÃO DE PAGAMENTOS"; + this.ViewModel = new ManutencaoPagamentosViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdcionarFiltroPersonalizado(); + } + + private async void Apolice_OnClick(object sender, RoutedEventArgs e) + { + ManutencaoPagamentos dataContext = (ManutencaoPagamentos)((Button)sender).DataContext; + if (dataContext != null) + { + this.ViewModel.Loading(true); + long idDocumento = dataContext.get_IdDocumento(); + Documento documento = await (new ApoliceServico()).BuscarApoliceAsync(idDocumento, false, false); + if (documento != null) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ApoliceView(documento, true, false, 1, dataContext.get_IdParcela(), false), string.Concat("CADASTRO DE APÓLICES - ", documento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).Show(); + this.ViewModel.Loading(false); + } + else + { + this.ViewModel.Loading(false); + } + } + dataContext = null; + } + + private async void Buscar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + await this.ViewModel.Buscar(); + this.ViewModel.Loading(false); + } + + private void CheckBox_Checked(object sender, RoutedEventArgs e) + { + this.ViewModel.Selecionar(true); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.Pagamentos != null) + { + ObservableCollection pagamentos = this.ViewModel.Pagamentos; + if (!pagamentos.All((ManutencaoPagamentos x) => !x.get_Selecionado())) + { + bool? nullable = await this.ViewModel.ShowSenha("DESEJA REALMENTE EXCLUIR OS PAGAMENTOS SELECIONADOS?\nESSE PROCEDIMENTO É IRREVERSÍVEL."); + if (!nullable.HasValue) + { + return; + } + else if (!nullable.GetValueOrDefault()) + { + await this.ViewModel.ShowMessage("SENHA INVÁLIDA", "OK", "", false); + return; + } + else + { + this.ViewModel.Loading(true); + await this.ViewModel.Excluir(); + this.ViewModel.Loading(false); + return; + } + } + } + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR OS PAGAMENTOS QUE DESEJA EXCLUIR ANTES DE PROSSEGUIR", "OK", "", false); + } + + private void ExcluirFiltro_OnClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(chip); + FiltroPersonalizado item = (FiltroPersonalizado)listBox.Items[listBox.Items.IndexOf(chip.DataContext)]; + if (item == null) + { + return; + } + this.ViewModel.FiltroPersonalizadoSelecionado.Remove(item); + this.ViewModel.PesquisaPersonalizada(); + } + + private void FecharFiltro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.VisibilityFiltroPersonalizado = (this.ViewModel.VisibilityFiltroPersonalizado == System.Windows.Visibility.Collapsed ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + [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/ferramentas/manutencaopagamentosview.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: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 2: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 3: + { + ((Button)target).Click += new RoutedEventHandler(this.Buscar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.FecharFiltro_OnClick); + return; + } + case 6: + { + ((Button)target).Click += new RoutedEventHandler(this.FecharFiltro_OnClick); + return; + } + case 7: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 8: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 9: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltro_OnClick); + 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 10: + { + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_OnClick)); + return; + } + case 11: + { + ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBox_Checked); + ((CheckBox)target).Unchecked += new RoutedEventHandler(this.UnCheckBox_Checked); + return; + } + case 12: + { + ((Button)target).Click += new RoutedEventHandler(this.Apolice_OnClick); + return; + } + default: + { + return; + } + } + } + + private void UnCheckBox_Checked(object sender, RoutedEventArgs e) + { + this.ViewModel.Selecionar(false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/NotaFiscalView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/NotaFiscalView.cs new file mode 100644 index 0000000..a4928ce --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/NotaFiscalView.cs @@ -0,0 +1,327 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +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.Threading; + +namespace Gestor.Application.Views.Ferramentas +{ + public class NotaFiscalView : BaseUserControl, IComponentConnector + { + public NotaFiscalViewModel ViewModel; + + internal DataGrid NotaFiscalGrid; + + internal DataGridTextColumn NomeField; + + internal DataGridTextColumn ApelidoField; + + internal MenuItem MaisOpcoesButton; + + internal DatePicker DataPicker; + + internal CurrencyTextBox ValorBrutoBox; + + internal CurrencyTextBox ValorIssBox; + + internal CurrencyTextBox ValorIrBox; + + internal CurrencyTextBox ValorLiquidoBox; + + internal TextBox ExtratoBox; + + internal ComboBox EstipulanteBox; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public NotaFiscalView() + { + base.Tag = "CADASTRO DE NOTA FISCAL"; + this.ViewModel = new NotaFiscalViewModel(); + 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(55, this.ViewModel.SelectedNotaFiscal.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelNotaFiscal = (NotaFiscal)this.ViewModel.SelectedNotaFiscal.Clone(); + this.ViewModel.Alterar(true); + this.ViewModel.SelectedNotaFiscal.Initialize(); + } + + private async void ArquivoDigital_OnClick(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 16).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedNotaFiscal.get_Id()); + filtroArquivoDigital.set_Tipo(16); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedNotaFiscal); + 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)16), "."), "OK", "", false); + } + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarNotaFiscal(""); + } + + private void AutoCompleteBoxNotaFiscal_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.NomeField.Visibility = (this.ViewModel.Apelido ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ApelidoField.Visibility = (!this.ViewModel.Apelido ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private async void Importar_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.IsEnabled = false; + this.ViewModel.EnableMenu = false; + this.ViewModel.EnableMainMenu = false; + List notaFiscals = await this.ViewModel.ShowExtratoComissaoDialog(this.ViewModel.Seguradoras); + if (notaFiscals != null) + { + await this.ViewModel.SalvarLote(notaFiscals); + } + this.ViewModel.EnableMainMenu = true; + this.ViewModel.EnableMenu = true; + this.ViewModel.IsEnabled = true; + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + } + + [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/ferramentas/notafiscalview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.DataPicker.SelectedDate = new DateTime?(Convert.ToDateTime(this.DataPicker.Text)); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, NotaFiscalView.AutoCompleteBoxNotaFiscal_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.NotaFiscalGrid = (DataGrid)target; + return; + } + case 3: + { + this.NomeField = (DataGridTextColumn)target; + return; + } + case 4: + { + this.ApelidoField = (DataGridTextColumn)target; + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Importar_Click); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 11: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ArquivoDigital_OnClick); + return; + } + case 14: + { + this.DataPicker = (DatePicker)target; + this.DataPicker.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.DataPicker.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.DataPicker.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 15: + { + this.ValorBrutoBox = (CurrencyTextBox)target; + this.ValorBrutoBox.LostFocus += new RoutedEventHandler(this.UIElement_OnLostFocus); + return; + } + case 16: + { + this.ValorIssBox = (CurrencyTextBox)target; + this.ValorIssBox.LostFocus += new RoutedEventHandler(this.UIElement_OnLostFocus); + return; + } + case 17: + { + this.ValorIrBox = (CurrencyTextBox)target; + this.ValorIrBox.LostFocus += new RoutedEventHandler(this.UIElement_OnLostFocus); + return; + } + case 18: + { + this.ValorLiquidoBox = (CurrencyTextBox)target; + this.ValorLiquidoBox.LostFocus += new RoutedEventHandler(this.UIElement_OnLostFocus); + return; + } + case 19: + { + this.ExtratoBox = (TextBox)target; + return; + } + case 20: + { + this.EstipulanteBox = (ComboBox)target; + return; + } + } + this._contentLoaded = true; + } + + private async void UIElement_OnLostFocus(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedNotaFiscal != null && this.ViewModel.EnableFields) + { + List configuracoes = Recursos.Configuracoes; + bool flag = configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5); + if ((((CurrencyTextBox)sender).Name == "ValorBrutoBox") & flag && this.ValorIssBox.get_Number() == decimal.Zero) + { + decimal num = await this.ViewModel.BuscarImposto(); + this.ValorIssBox.set_Number(this.ValorBrutoBox.get_Number() * num); + } + this.ValorLiquidoBox.set_Number((this.ValorBrutoBox.get_Number() - this.ValorIssBox.get_Number()) - this.ValorIrBox.get_Number()); + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/ProdutoView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/ProdutoView.cs new file mode 100644 index 0000000..8c61f17 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/ProdutoView.cs @@ -0,0 +1,215 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +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.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.Ferramentas +{ + public class ProdutoView : BaseUserControl, IComponentConnector + { + public ProdutoViewModel ViewModel; + + internal DataGrid ProdutoGrid; + + internal MenuItem MaisOpcoesButton; + + internal ToggleButton AtivoBox; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ProdutoView() + { + base.Tag = "CADASTRO DE PRODUTOS"; + this.ViewModel = new ProdutoViewModel(); + 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(10, this.ViewModel.SelectedProduto.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelProduto = (Produto)this.ViewModel.SelectedProduto.Clone(); + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.ViewModel.SelectedProduto.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarProduto(""); + } + + private void AutoCompleteBoxProduto_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.ProdutoGrid.SelectedIndex = 0; + this.ProdutoGrid.SelectionChanged += new SelectionChangedEventHandler(this.EstipulanteGrid_OnSelectionChanged); + this.ProdutoGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + } + + private void EstipulanteGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaProduto((Produto)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/ferramentas/produtoview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, ProdutoView.AutoCompleteBoxProduto_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.ProdutoGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 9: + { + this.AtivoBox = (ToggleButton)target; + return; + } + } + this._contentLoaded = true; + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedProduto == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedProduto.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/ProtocoloDocumentosView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/ProtocoloDocumentosView.cs new file mode 100644 index 0000000..06943cf --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/ProtocoloDocumentosView.cs @@ -0,0 +1,209 @@ +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Markup; + +namespace Gestor.Application.Views.Ferramentas +{ + public class ProtocoloDocumentosView : UserControl, IComponentConnector, IStyleConnector + { + private bool _contentLoaded; + + public ProtocoloDocumentosViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ProtocoloDocumentosView() + { + base.Tag = "PROTOCOLOS E ETIQUETAS"; + this.ViewModel = new ProtocoloDocumentosViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private void AdicionarEtiqueta_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + this.ViewModel.AdicionarEtiqueta((Documento)button.DataContext); + } + + private void AdicionarEtiquetaCliente_OnClick(object sender, RoutedEventArgs e) + { + MenuItem menuItem = sender as MenuItem; + if (menuItem == null) + { + return; + } + if (menuItem.DataContext == null) + { + return; + } + this.ViewModel.AdicionarEtiquetaCliente(); + } + + private void AdicionarEtiquetaCorretora_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdicionarEtiquetaCorretora(); + } + + private void AdicionarProtocolo_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + this.ViewModel.AdicionarProtocolo((Documento)button.DataContext); + } + + private void AutoCompleteClienteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarCliente(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim()), null, 2).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void ImprimirEtiqueta_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Imprimir(1); + } + + private void ImprimirProtocolo_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Imprimir(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/ferramentas/protocolodocumentosview.xaml", UriKind.Relative)); + } + + private void Remover_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + this.ViewModel.Remover((ProtocoloEtiqueta)button.DataContext); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, ProtocoloDocumentosView.AutoCompleteClienteBox_Populating)); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AdicionarEtiquetaCliente_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AdicionarEtiquetaCorretora_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ImprimirProtocolo_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ImprimirEtiqueta_OnClick); + 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 6: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarProtocolo_OnClick); + return; + } + case 7: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarEtiqueta_OnClick); + return; + } + case 8: + { + ((Button)target).Click += new RoutedEventHandler(this.Remover_OnClick); + return; + } + default: + { + return; + } + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/QualificacaoView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/QualificacaoView.cs new file mode 100644 index 0000000..e3a334c --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/QualificacaoView.cs @@ -0,0 +1,197 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +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.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Markup; + +namespace Gestor.Application.Views.Ferramentas +{ + public class QualificacaoView : BaseUserControl, IComponentConnector + { + public QualificacaoViewModel ViewModel; + + internal MenuItem MaisOpcoesButton; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public QualificacaoView() + { + base.Tag = "CADASTRO DE QUALIFICAÇÃO"; + this.ViewModel = new QualificacaoViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(48, this.ViewModel.SelectedQualificacao.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelQualificacao = (Qualificacao)this.ViewModel.SelectedQualificacao.Clone(); + this.ViewModel.Alterar(true); + this.ViewModel.SelectedQualificacao.Initialize(); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void CurrencyTextBox_OnLostFocus(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedQualificacao.get_Liquido2() <= this.ViewModel.SelectedQualificacao.get_Liquido1()) + { + this.ViewModel.SelectedQualificacao.set_Liquido2(this.ViewModel.SelectedQualificacao.get_Liquido1() + new decimal(1, 0, 0, false, 2)); + } + if (this.ViewModel.SelectedQualificacao.get_Liquido3() <= this.ViewModel.SelectedQualificacao.get_Liquido2()) + { + this.ViewModel.SelectedQualificacao.set_Liquido3(this.ViewModel.SelectedQualificacao.get_Liquido2() + new decimal(1, 0, 0, false, 2)); + } + if (this.ViewModel.SelectedQualificacao.get_Comissao2() <= this.ViewModel.SelectedQualificacao.get_Comissao1()) + { + this.ViewModel.SelectedQualificacao.set_Comissao2(this.ViewModel.SelectedQualificacao.get_Comissao1() + new decimal(1, 0, 0, false, 2)); + } + if (this.ViewModel.SelectedQualificacao.get_Comissao3() <= this.ViewModel.SelectedQualificacao.get_Comissao2()) + { + this.ViewModel.SelectedQualificacao.set_Comissao3(this.ViewModel.SelectedQualificacao.get_Comissao2() + new decimal(1, 0, 0, false, 2)); + } + if (this.ViewModel.SelectedQualificacao.get_Resultado2() <= this.ViewModel.SelectedQualificacao.get_Resultado1()) + { + this.ViewModel.SelectedQualificacao.set_Resultado2(this.ViewModel.SelectedQualificacao.get_Resultado1() + new decimal(1, 0, 0, false, 2)); + } + if (this.ViewModel.SelectedQualificacao.get_Resultado3() <= this.ViewModel.SelectedQualificacao.get_Resultado2()) + { + this.ViewModel.SelectedQualificacao.set_Resultado3(this.ViewModel.SelectedQualificacao.get_Resultado2() + new decimal(1, 0, 0, false, 2)); + } + this.ViewModel.SelectedQualificacao = this.ViewModel.SelectedQualificacao; + } + + [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/ferramentas/qualificacaoview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 4: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 6: + { + ((CurrencyTextBox)target).LostFocus += new RoutedEventHandler(this.CurrencyTextBox_OnLostFocus); + return; + } + case 7: + { + ((CurrencyTextBox)target).LostFocus += new RoutedEventHandler(this.CurrencyTextBox_OnLostFocus); + return; + } + case 8: + { + ((CurrencyTextBox)target).LostFocus += new RoutedEventHandler(this.CurrencyTextBox_OnLostFocus); + return; + } + case 9: + { + ((CurrencyTextBox)target).LostFocus += new RoutedEventHandler(this.CurrencyTextBox_OnLostFocus); + return; + } + case 10: + { + ((CurrencyTextBox)target).LostFocus += new RoutedEventHandler(this.CurrencyTextBox_OnLostFocus); + return; + } + case 11: + { + ((CurrencyTextBox)target).LostFocus += new RoutedEventHandler(this.CurrencyTextBox_OnLostFocus); + return; + } + case 12: + { + ((CurrencyTextBox)target).LostFocus += new RoutedEventHandler(this.CurrencyTextBox_OnLostFocus); + return; + } + case 13: + { + ((CurrencyTextBox)target).LostFocus += new RoutedEventHandler(this.CurrencyTextBox_OnLostFocus); + return; + } + case 14: + { + ((CurrencyTextBox)target).LostFocus += new RoutedEventHandler(this.CurrencyTextBox_OnLostFocus); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/RamoView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/RamoView.cs new file mode 100644 index 0000000..ee06d21 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/RamoView.cs @@ -0,0 +1,282 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Configuracoes; +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.Controls.Primitives; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Ferramentas +{ + public class RamoView : BaseUserControl, IComponentConnector + { + internal DataGrid RamoGrid; + + internal MenuItem MaisOpcoesButton; + + internal TextBox ApoliceBox; + + internal CurrencyTextBox IofBox; + + internal DataGrid CoberturaGrid; + + private bool _contentLoaded; + + public RamoViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public RamoView() + { + base.Tag = "RAMOS"; + this.ViewModel = new RamoViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + this.RamoGrid.DataContext = base.DataContext; + this.CoberturaGrid.DataContext = base.DataContext; + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(12, this.ViewModel.SelectedRamo.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelRamo = (Ramo)this.ViewModel.SelectedRamo.Clone(); + this.ViewModel.Alterar(true); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarRamo(""); + } + + private void AutoCompleteBoxCobertura_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarCoberturaRamo(""); + } + + private void AutoCompleteBoxCobertura_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.FiltrarCobertura(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 void AutoCompleteBoxRamo_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.RamoGrid.SelectedIndex = 0; + this.RamoGrid.SelectionChanged += new SelectionChangedEventHandler(this.RamoGrid_OnSelectionChanged); + this.RamoGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + this.CoberturaGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + } + + private async void Impostos_OnClick(object sender, RoutedEventArgs e) + { + List configuracoes = Recursos.Configuracoes; + if (configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 5)) + { + await this.ViewModel.ShowMessage("RECURSO NÃO HABILITADO, ACESSE AS CONFIGURAÇÕES DENTRO DO CADASTRO DE EMPRESAS E FILIAIS PARA HABILITAR O RECURSO.", "OK", "", false); + } + else if (await this.ViewModel.VerificarPermissao(56, false)) + { + this.ViewModel.ShowDrawer(new ImpostoDrawer(1, this.ViewModel.SelectedRamo.get_Id()), 0, false); + } + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + IncluirRamoView incluirRamoView = new IncluirRamoView(this.ViewModel.Ramos); + (new HosterWindow(incluirRamoView, "INCLUIR RAMO", new double?((double)500), new double?((double)600), false)).ShowDialog(); + if (incluirRamoView.ViewModel.AdicionarRamo != null) + { + this.ViewModel.Incluir(incluirRamoView.ViewModel.AdicionarRamo); + } + } + + [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/ferramentas/ramoview.xaml", UriKind.Relative)); + } + + private void RamoGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaRamo((Ramo)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, RamoView.AutoCompleteBoxRamo_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.RamoGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Impostos_OnClick); + return; + } + case 10: + { + this.ApoliceBox = (TextBox)target; + return; + } + case 11: + { + this.IofBox = (CurrencyTextBox)target; + return; + } + case 12: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, RamoView.AutoCompleteBoxCobertura_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBoxCobertura_OnTextChanged)); + return; + } + case 13: + { + this.CoberturaGrid = (DataGrid)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/ReciboView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/ReciboView.cs new file mode 100644 index 0000000..d807ef3 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/ReciboView.cs @@ -0,0 +1,280 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +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.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.Ferramentas +{ + public class ReciboView : BaseUserControl, IComponentConnector + { + public ReciboViewModel ViewModel; + + internal DataGrid ReciboGrid; + + internal MenuItem MaisOpcoesButton; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ReciboView() + { + base.Tag = "CADASTRO DE RECIBOS"; + this.ViewModel = new ReciboViewModel(); + 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(42, this.ViewModel.SelectedRecibo.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelRecibo = (Recibo)this.ViewModel.SelectedRecibo.Clone(); + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.ViewModel.SelectedRecibo.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarRecibo(""); + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Trim().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarClienteEmpresa(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 void AutoCompleteBoxRecibo_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.ReciboGrid.SelectedIndex = 0; + this.ReciboGrid.SelectionChanged += new SelectionChangedEventHandler(this.ReciboGrid_OnSelectionChanged); + this.ReciboGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Print(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/ferramentas/reciboview.xaml", UriKind.Relative)); + } + + private void ReciboGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelectedRecibo = (Recibo)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.ReciboGrid.ScrollIntoView(this.ReciboGrid.SelectedItem); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, ReciboView.AutoCompleteBoxRecibo_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.ReciboGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 8: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 11: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 12: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, ReciboView.AutoCompleteBox_Populating)); + return; + } + case 13: + { + ReciboView reciboView = this; + ((TextBox)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(reciboView.FormatarDocumento); + return; + } + case 14: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, ReciboView.AutoCompleteBox_Populating)); + return; + } + case 15: + { + ReciboView reciboView1 = this; + ((TextBox)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(reciboView1.FormatarDocumento); + return; + } + } + this._contentLoaded = true; + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedRecibo == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedRecibo.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/SeguradoraView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/SeguradoraView.cs new file mode 100644 index 0000000..68421cd --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/SeguradoraView.cs @@ -0,0 +1,643 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +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.Controls.Primitives; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; +using Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.Ferramentas +{ + public class SeguradoraView : BaseUserControl, IComponentConnector, IStyleConnector + { + public SeguradoraViewModel ViewModel; + + internal DataGrid SeguradoraGrid; + + internal DataGridTextColumn NomeField; + + internal DataGridTextColumn ApelidoField; + + internal MenuItem MaisOpcoesButton; + + internal ToggleButton AtivoBox; + + internal TextBox DocumentoPrincipalBox; + + internal TextBox AssistenciaBox; + + internal TextBox SusepBox; + + internal TextBox CodigoCiaBox; + + internal TextBox LinkAppAndroidBox; + + internal TextBox LinkAppIosBox; + + internal CurrencyTextBox ToleranciaComissaoBox; + + internal CurrencyTextBox ToleranciaPremioBox; + + internal TextBox ObservacaoBox; + + internal ListBox ContatosListBox; + + internal ListBox EnderecoSeguradoraBox; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public SeguradoraView() + { + base.Tag = "CADASTRO DE SEGURADORA"; + this.Tela = 13; + this.ViewModel = new SeguradoraViewModel(); + 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 async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 8).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedSeguradora.get_Id()); + filtroArquivoDigital.set_Tipo(8); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedSeguradora); + 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 ", EnumHelper.GetDescription(8), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(13, this.ViewModel.SelectedSeguradora.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(13, this.ViewModel.SelectedSeguradora.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Clonar(); + this.ViewModel.Alterar(true); + this.ValidarTela(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarSeguradora(""); + } + + private void AutoCompleteBoxDescricao_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarDescricao(""); + } + + private void AutoCompleteBoxDescricao_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.FiltrarConfig(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 void AutoCompleteBoxSeguradora_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.SeguradoraGrid.SelectedIndex = 0; + this.SeguradoraGrid.SelectionChanged += new SelectionChangedEventHandler(this.SeguradoraGrid_OnSelectionChanged); + this.SeguradoraGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + this.NomeField.Visibility = (this.ViewModel.Apelido ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ApelidoField.Visibility = (!this.ViewModel.Apelido ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + } + + private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e) + { + if (((TextBox)sender).IsReadOnly) + { + return; + } + string str = ValidationHelper.Clear(this.DocumentoPrincipalBox.Text); + if (string.IsNullOrEmpty(str)) + { + return; + } + this.DocumentoPrincipalBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14))); + } + + private void ExcluirEndereco_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(button); + SeguradoraEndereco item = (SeguradoraEndereco)listBox.Items[listBox.Items.IndexOf(button.DataContext)]; + this.ViewModel.ExcluirEndereco(item); + } + + private void ExcluirTelefone_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(button); + SeguradoraContato item = (SeguradoraContato)listBox.Items[listBox.Items.IndexOf(button.DataContext)]; + this.ViewModel.ExcluirTelefone(item); + } + + private async void Impostos_OnClick(object sender, RoutedEventArgs e) + { + List configuracoes = Recursos.Configuracoes; + if (configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 5)) + { + await this.ViewModel.ShowMessage("RECURSO NÃO HABILITADO, ACESSE AS CONFIGURAÇÕES DENTRO DO CADASTRO DE EMPRESAS E FILIAIS PARA HABILITAR O RECURSO.", "OK", "", false); + } + else if (await this.ViewModel.VerificarPermissao(56, false)) + { + this.ViewModel.ShowDrawer(new ImpostoDrawer(0, this.ViewModel.SelectedSeguradora.get_Id()), 0, false); + } + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + IncluirSeguradoraView incluirSeguradoraView = new IncluirSeguradoraView(this.ViewModel.Seguradoras); + (new HosterWindow(incluirSeguradoraView, "INCLUIR SEGURADORA", new double?((double)500), new double?((double)600), false)).ShowDialog(); + if (incluirSeguradoraView.ViewModel.AdicionarSeguradora != null) + { + this.ViewModel.Incluir(incluirSeguradoraView.ViewModel.AdicionarSeguradora); + } + } + + private void IncluirEndereco_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirEndereco(); + this.ValidarTela(); + } + + private void IncluirTelefone_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirTelefone(); + this.ValidarTela(); + } + + [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/ferramentas/seguradoraview.xaml", UriKind.Relative)); + } + + public async void Metas_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + if (await this.ViewModel.VerificarPermissao(31, false)) + { + this.ViewModel.ShowDrawer(new MetaSeguradoraView(this.ViewModel.SelectedSeguradora), 0, false); + this.ViewModel.Loading(false); + } + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + ContentPresenter contentPresenter; + DataTemplate contentTemplate; + TextBox textBox = (TextBox)sender; + string str = ValidationHelper.FormatPostCode(textBox.Text); + if (ValidationHelper.ValidatePostCode(str)) + { + ListBox listBox = Extentions.FindVisualAncestor(textBox); + ListBoxItem listBoxItem = (ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(listBox.Items.IndexOf(textBox.DataContext)); + contentPresenter = FindVisualChild.Find(listBoxItem); + contentTemplate = contentPresenter.ContentTemplate; + ((TextBox)contentTemplate.FindName("CepBox", contentPresenter)).Text = str; + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + TextBox endereco = (TextBox)contentTemplate.FindName("EnderecoBox", contentPresenter); + TextBox cidade = (TextBox)contentTemplate.FindName("CidadeBox", contentPresenter); + TextBox estado = (TextBox)contentTemplate.FindName("EstadoBox", contentPresenter); + TextBox bairro = (TextBox)contentTemplate.FindName("BairroBox", contentPresenter); + endereco.Text = enderecoBase.get_Endereco(); + cidade.Text = enderecoBase.get_Cidade(); + estado.Text = enderecoBase.get_Estado(); + bairro.Text = enderecoBase.get_Bairro(); + } + } + contentPresenter = null; + contentTemplate = null; + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.ViewModel.SelectedSeguradora.set_NomeSocial(this.ViewModel.SelectedSeguradora.get_NomeSocialBanco().Trim()); + if ((this.ToleranciaComissaoBox.get_Number() > new decimal(2) || this.ToleranciaPremioBox.get_Number() > new decimal(2)) && (this.ViewModel.Tolerancia != this.ToleranciaComissaoBox.get_Number() || this.ViewModel.Tolerancia != this.ToleranciaPremioBox.get_Number())) + { + bool? nullable = await this.ViewModel.ShowSenha("TOLERÂNCIA DE COMISSÃO, DIFERENÇA IMPORTAÇÃO OU REPASSE MAIOR QUE R$2,00, PREENCHA A SENHA ADM PARA PROSSEGUIR."); + if (!nullable.HasValue) + { + this.ViewModel.Loading(false); + return; + } + else if (!nullable.GetValueOrDefault()) + { + await this.ViewModel.ShowMessage("SENHA INVÁLIDA", "OK", "", false); + this.ViewModel.Loading(false); + return; + } + } + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + private void SeguradoraGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaSeguradora((Seguradora)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + public void Selector_ContactChanged(object sender, SelectionChangedEventArgs e) + { + this.ViewModel.TipoTelefoneVisibility = System.Windows.Visibility.Visible; + this.ViewModel.TelefoneVisibility = System.Windows.Visibility.Visible; + this.ViewModel.PrefixoVisibility = System.Windows.Visibility.Visible; + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, SeguradoraView.AutoCompleteBoxSeguradora_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, SeguradoraView.AutoCompleteBoxSeguradora_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 3: + { + this.SeguradoraGrid = (DataGrid)target; + return; + } + case 4: + { + this.NomeField = (DataGridTextColumn)target; + return; + } + case 5: + { + this.ApelidoField = (DataGridTextColumn)target; + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 11: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Metas_Click); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Impostos_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 16: + { + this.AtivoBox = (ToggleButton)target; + return; + } + case 17: + { + this.DocumentoPrincipalBox = (TextBox)target; + SeguradoraView seguradoraView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(seguradoraView.SomenteNumeros); + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + return; + } + case 18: + { + this.AssistenciaBox = (TextBox)target; + return; + } + case 19: + { + this.SusepBox = (TextBox)target; + return; + } + case 20: + { + this.CodigoCiaBox = (TextBox)target; + return; + } + case 21: + { + this.LinkAppAndroidBox = (TextBox)target; + return; + } + case 22: + { + this.LinkAppIosBox = (TextBox)target; + return; + } + case 23: + { + this.ToleranciaComissaoBox = (CurrencyTextBox)target; + return; + } + case 24: + { + this.ToleranciaPremioBox = (CurrencyTextBox)target; + return; + } + case 25: + { + this.ObservacaoBox = (TextBox)target; + return; + } + case 26: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTelefone_OnClick); + return; + } + case 27: + { + this.ContatosListBox = (ListBox)target; + return; + } + case 28: + case 29: + case 30: + case 31: + case 34: + case 35: + case 36: + { + this._contentLoaded = true; + return; + } + case 32: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirEndereco_OnClick); + return; + } + case 33: + { + this.EnderecoSeguradoraBox = (ListBox)target; + return; + } + case 37: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, SeguradoraView.AutoCompleteBoxDescricao_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBoxDescricao_OnTextChanged)); + 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 28: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Selector_ContactChanged); + return; + } + case 29: + { + SeguradoraView seguradoraView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(seguradoraView.SomenteNumeros); + return; + } + case 30: + { + SeguradoraView seguradoraView1 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(seguradoraView1.FormatarTelefone); + SeguradoraView seguradoraView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(seguradoraView2.SomenteNumeros); + return; + } + case 31: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirTelefone_OnClick); + return; + } + case 32: + case 33: + { + return; + } + case 34: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + SeguradoraView seguradoraView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(seguradoraView3.SomenteNumeros); + return; + } + case 35: + { + SeguradoraView seguradoraView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(seguradoraView4.SomenteNumeros); + return; + } + case 36: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirEndereco_OnClick); + return; + } + default: + { + return; + } + } + } + + private void ValidarTela() + { + object keyValuePairs; + object obj; + if (this.ViewModel.SelectedSeguradora == null) + { + return; + } + List> keyValuePairs1 = this.ViewModel.SelectedSeguradora.Validate(); + List> keyValuePairs2 = keyValuePairs1; + SeguradoraContato seguradoraContato = this.ViewModel.Contatos.FirstOrDefault(); + if (seguradoraContato != null) + { + keyValuePairs = seguradoraContato.Validate(); + } + else + { + keyValuePairs = null; + } + if (keyValuePairs == null) + { + keyValuePairs = new List>(); + } + keyValuePairs2.AddRange((IEnumerable)keyValuePairs); + List> keyValuePairs3 = keyValuePairs1; + SeguradoraEndereco seguradoraEndereco = this.ViewModel.Enderecos.FirstOrDefault(); + if (seguradoraEndereco != null) + { + obj = seguradoraEndereco.Validate(); + } + else + { + obj = null; + } + if (obj == null) + { + obj = new List>(); + } + keyValuePairs3.AddRange((IEnumerable)obj); + this.ValidateFields(keyValuePairs1, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/SocioView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/SocioView.cs new file mode 100644 index 0000000..08f3460 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/SocioView.cs @@ -0,0 +1,266 @@ +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +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.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.Ferramentas +{ + public class SocioView : BaseUserControl, IComponentConnector + { + internal ComboBox EmpresaFilialBox; + + internal DataGrid SocioGrid; + + internal MenuItem MaisOpcoesButton; + + internal TextBox NomeBox; + + internal TextBox PrimeiroPrefixo; + + internal TextBox PrimeiroTelefone; + + internal TextBox EmailBox; + + private bool _contentLoaded; + + public SocioViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public SocioView() + { + base.Tag = "CADASTRO DE SÓCIOS"; + this.ViewModel = new SocioViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if (!(new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 14).get_Consultar()) + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)14), "."), "OK", "", false); + } + else if (this.ViewModel.SelectedSocio != null) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedSocio.get_Id()); + filtroArquivoDigital.set_Tipo(14); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedSocio); + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + } + else + { + await this.ViewModel.ShowMessage("É NECESSÁRIO SELECIONAR UM SÓCIO PARA ABRIR SEU ARQUIVO DIGITAL", "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(19, this.ViewModel.SelectedSocio.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelSocio = (Socio)this.ViewModel.SelectedSocio.Clone(); + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.ViewModel.SelectedSocio.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarSocio(""); + } + + private void AutoCompleteBoxSocio_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/ferramentas/socioview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [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.EmpresaFilialBox = (ComboBox)target; + return; + } + case 2: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, SocioView.AutoCompleteBoxSocio_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 3: + { + this.SocioGrid = (DataGrid)target; + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 10: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 12: + { + this.NomeBox = (TextBox)target; + return; + } + case 13: + { + this.PrimeiroPrefixo = (TextBox)target; + SocioView socioView = this; + this.PrimeiroPrefixo.PreviewTextInput += new TextCompositionEventHandler(socioView.SomenteNumeros); + return; + } + case 14: + { + this.PrimeiroTelefone = (TextBox)target; + SocioView socioView1 = this; + this.PrimeiroTelefone.LostFocus += new RoutedEventHandler(socioView1.FormatarTelefone); + SocioView socioView2 = this; + this.PrimeiroTelefone.PreviewTextInput += new TextCompositionEventHandler(socioView2.SomenteNumeros); + return; + } + case 15: + { + this.EmailBox = (TextBox)target; + return; + } + } + this._contentLoaded = true; + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedSocio == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedSocio.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/StatusProspeccaoView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/StatusProspeccaoView.cs new file mode 100644 index 0000000..5fee7d6 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/StatusProspeccaoView.cs @@ -0,0 +1,213 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +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.Markup; + +namespace Gestor.Application.Views.Ferramentas +{ + public class StatusProspeccaoView : BaseUserControl, IComponentConnector + { + public StatusProspeccaoViewModel ViewModel; + + internal DataGrid StatusProspeccaoGrid; + + internal MenuItem MaisOpcoesButton; + + internal TextBox NomeBox; + + internal ToggleButton AtivoBox; + + internal TextBox ObsBox; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public StatusProspeccaoView() + { + base.Tag = "CADASTRO DE STATUS DE PROSPECÇÃO"; + this.ViewModel = new StatusProspeccaoViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(57, this.ViewModel.SelectedStatusProspeccao.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelStatusProspeccao = (StatusDeProspeccao)this.ViewModel.SelectedStatusProspeccao.Clone(); + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.ViewModel.SelectedStatusProspeccao.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarStatusProspeccao(""); + } + + private void AutoCompleteBoxStatusProspeccao_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/ferramentas/statusprospeccaoview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, StatusProspeccaoView.AutoCompleteBoxStatusProspeccao_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.StatusProspeccaoGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 8: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + this.NomeBox = (TextBox)target; + return; + } + case 11: + { + this.AtivoBox = (ToggleButton)target; + return; + } + case 12: + { + this.ObsBox = (TextBox)target; + return; + } + } + this._contentLoaded = true; + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedStatusProspeccao == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedStatusProspeccao.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/StatusView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/StatusView.cs new file mode 100644 index 0000000..0d1c8fe --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/StatusView.cs @@ -0,0 +1,232 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +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.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.Ferramentas +{ + public class StatusView : BaseUserControl, IComponentConnector + { + public StatusViewModel ViewModel; + + internal DataGrid StatusGrid; + + internal MenuItem MaisOpcoesButton; + + internal TextBox NomeBox; + + internal ToggleButton AtivoBox; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public StatusView() + { + base.Tag = "CADASTRO DE STATUS"; + this.ViewModel = new StatusViewModel(); + 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(11, this.ViewModel.SelectedStatus.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelStatus = (Status)this.ViewModel.SelectedStatus.Clone(); + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.ViewModel.SelectedStatus.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarStatus(""); + } + + private void AutoCompleteBoxStatus_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.StatusGrid.SelectedIndex = 0; + this.StatusGrid.SelectionChanged += new SelectionChangedEventHandler(this.EstipulanteGrid_OnSelectionChanged); + this.StatusGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + } + + private void EstipulanteGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaStatus((Status)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/ferramentas/statusview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, StatusView.AutoCompleteBoxStatus_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.StatusGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 8: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + this.NomeBox = (TextBox)target; + return; + } + case 11: + { + this.AtivoBox = (ToggleButton)target; + return; + } + } + this._contentLoaded = true; + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedStatus == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedStatus.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/TipoTarefaView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/TipoTarefaView.cs new file mode 100644 index 0000000..8d97ee7 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/TipoTarefaView.cs @@ -0,0 +1,213 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +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.Markup; + +namespace Gestor.Application.Views.Ferramentas +{ + public class TipoTarefaView : BaseUserControl, IComponentConnector + { + public TipoTarefaViewModel ViewModel; + + internal DataGrid TipoTarefaGrid; + + internal MenuItem MaisOpcoesButton; + + internal TextBox NomeBox; + + internal ToggleButton AtivoBox; + + internal TextBox ObsBox; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public TipoTarefaView() + { + base.Tag = "CADASTRO DO TIPO DE TAREFA"; + this.ViewModel = new TipoTarefaViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(52, this.ViewModel.SelectedTipoTarefa.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelTipoTarefa = (TipoDeTarefa)this.ViewModel.SelectedTipoTarefa.Clone(); + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.ViewModel.SelectedTipoTarefa.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarTipoTarefa(""); + } + + private void AutoCompleteBoxTipoTarefa_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/ferramentas/tipotarefaview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, TipoTarefaView.AutoCompleteBoxTipoTarefa_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.TipoTarefaGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 8: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + this.NomeBox = (TextBox)target; + return; + } + case 11: + { + this.AtivoBox = (ToggleButton)target; + return; + } + case 12: + { + this.ObsBox = (TextBox)target; + return; + } + } + this._contentLoaded = true; + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedTipoTarefa == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedTipoTarefa.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/TipoVendedorView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/TipoVendedorView.cs new file mode 100644 index 0000000..a8a150b --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/TipoVendedorView.cs @@ -0,0 +1,225 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +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.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.Ferramentas +{ + public class TipoVendedorView : BaseUserControl, IComponentConnector + { + public TipoVendedorViewModel ViewModel; + + internal DataGrid TipoVendedorGrid; + + internal MenuItem MaisOpcoesButton; + + internal ToggleButton AtivoBox; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public TipoVendedorView() + { + base.Tag = "CADASTRO DE TIPO DE VENDEDOR"; + this.ViewModel = new TipoVendedorViewModel(); + 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(14, this.ViewModel.SelectedTipoVendedor.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelTipoVendedor = (TipoVendedor)this.ViewModel.SelectedTipoVendedor.Clone(); + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.ViewModel.SelectedTipoVendedor.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarTipoVendedor(""); + } + + private void AutoCompleteBoxTipoVendedor_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.TipoVendedorGrid.SelectedIndex = 0; + this.TipoVendedorGrid.SelectionChanged += new SelectionChangedEventHandler(this.TipoVendedorGrid_OnSelectionChanged); + this.TipoVendedorGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/ferramentas/tipovendedorview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, TipoVendedorView.AutoCompleteBoxTipoVendedor_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.TipoVendedorGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 8: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + this.AtivoBox = (ToggleButton)target; + return; + } + } + this._contentLoaded = true; + } + + private void TipoVendedorGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaTipoVendedor((TipoVendedor)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedTipoVendedor == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedTipoVendedor.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/UsuarioView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/UsuarioView.cs new file mode 100644 index 0000000..3946e16 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/UsuarioView.cs @@ -0,0 +1,545 @@ +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; +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.Controls.Primitives; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Ferramentas +{ + public class UsuarioView : BaseUserControl, IComponentConnector + { + private bool _abrindoPermissao; + + private bool _firstTime = true; + + private bool _setting; + + internal DataGrid UsuarioGrid; + + internal MenuItem CancelarApoliceButton; + + internal TextBox NomeBox; + + internal TextBox CepBox; + + internal TextBox EnderecoBox; + + internal TextBox NumeroBox; + + internal TextBox BairroBox; + + internal TextBox CidadeBox; + + internal TextBox EstadoBox; + + private bool _contentLoaded; + + public UsuarioViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public UsuarioView() + { + base.Tag = "CADASTRO DE USUÁRIOS"; + this.ViewModel = new UsuarioViewModel(); + 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 async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 12).get_Consultar()) + { + this.ViewModel.EnableAlterar = false; + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedUsuario.get_Id()); + filtroArquivoDigital.set_Tipo(12); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedUsuario); + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + this.ViewModel.EnableAlterar = true; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)12), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(16, this.ViewModel.SelectedUsuario.get_Id()); + } + + private async void AbrirLogAcesso_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.ShowLogAcessoDialog(49, this.ViewModel.SelectedUsuario); + } + + private async void Alterar_OnClick(object sender, RoutedEventArgs e) + { + List produtos = LicenseHelper.Produtos; + if (!produtos.Any((Licenca produto) => produto.get_Produto() == 91) || !this.ViewModel.SelectedUsuario.get_Login().Contains("@")) + { + await this.ViewModel.AlterarUsuario(); + this.ViewModel.SelectedUsuario.Initialize(); + this.ViewModel.CancelUsuario = (Usuario)this.ViewModel.SelectedUsuario.Clone(); + this.ViewModel.Alterar(true); + this.ViewModel.IsExpanded = false; + this.NomeBox.Focus(); + } + else + { + await this.ViewModel.ShowMessage("ALTERAÇÃO DESSE USUARIO TEM QUE SER FEITO NO PAINEL DO AGGILIZADOR.", "OK", "", false); + } + } + + private void AutoCompleteBancoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarBanco(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 void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarUsuario(""); + } + + private void AutoCompleteBoxUsuario_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + await this.ViewModel.CancelarAlteracao(); + this.ViewModel.Loading(false); + this.ScrollToItem(); + } + + private async void Click_VerificaAdmCentralSegurado(object sender, RoutedEventArgs e) + { + await this.ViewModel.VerificaUsuarioAdmCentralSegurado(); + } + + private async void ContentLoad() + { + this.ViewModel.Loading(true); + await this.ViewModel.Seleciona(); + this.ViewModel.Loading(false); + } + + private void CpfBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + } + + private async void CriarCartao_OnClick(object sender, RoutedEventArgs e) + { + List configuracoes = Recursos.Configuracoes; + bool flag = configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 30); + await this.ViewModel.CriarCartao(flag); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + List produtos = LicenseHelper.Produtos; + if (!produtos.Any((Licenca produto) => produto.get_Produto() == 91) || !this.ViewModel.SelectedUsuario.get_Login().Contains("@")) + { + await this.ViewModel.Excluir(); + this.ScrollToItem(); + } + else + { + await this.ViewModel.ShowMessage("EXCLUSÃO DESSE USUARIO TEM QUE SER FEITO NO PAINEL DO AGGILIZADOR.", "OK", "", false); + } + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + List> keyValuePairs = this.ViewModel.SelectedUsuario.Validate(); + this.ValidateFields(keyValuePairs, true); + this.ViewModel.IsExpanded = false; + this.NomeBox.Focus(); + } + + [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/ferramentas/usuarioview.xaml", UriKind.Relative)); + } + + private async void Permissoes_OnClick(object sender, RoutedEventArgs e) + { + bool consultar; + if (!this._abrindoPermissao) + { + List permissaoUsuario = this.ViewModel.PermissaoUsuario; + PermissaoUsuario permissaoUsuario1 = permissaoUsuario.FirstOrDefault((PermissaoUsuario permissao) => permissao.get_Tela() == 43); + if (Recursos.Usuario.get_Administrador() || Recursos.Usuario.get_Id() == 0 || Recursos.Usuario.get_Nome().Contains("ACESSO AGGER") || permissaoUsuario1 == null) + { + consultar = false; + } + else + { + permissaoUsuario1.get_Consultar(); + consultar = !permissaoUsuario1.get_Consultar(); + } + bool flag = consultar; + if (flag) + { + flag = await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR PERMISSÕES.", "OK", "", false); + } + if (!flag) + { + this._abrindoPermissao = true; + await this.ViewModel.OpenPermissao(); + await Task.Delay(1000); + this._abrindoPermissao = false; + } + } + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + string str = ValidationHelper.FormatPostCode(((TextBox)sender).Text); + this.CepBox.Text = str; + if (ValidationHelper.ValidatePostCode(str)) + { + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + this.EnderecoBox.Text = enderecoBase.get_Endereco(); + this.CidadeBox.Text = enderecoBase.get_Cidade(); + this.EstadoBox.Text = enderecoBase.get_Estado(); + this.BairroBox.Text = enderecoBase.get_Bairro(); + } + } + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.ScrollToItem(); + } + } + + private void ScrollToItem() + { + if (this.UsuarioGrid.SelectedItem == null) + { + return; + } + this.UsuarioGrid.UpdateLayout(); + this.UsuarioGrid.ScrollIntoView(this.UsuarioGrid.SelectedItem); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, UsuarioView.AutoCompleteBoxUsuario_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.UsuarioGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + this.CancelarApoliceButton = (MenuItem)target; + this.CancelarApoliceButton.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Permissoes_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Vinculo_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CriarCartao_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogAcesso_OnClick); + return; + } + case 14: + { + this.NomeBox = (TextBox)target; + return; + } + case 15: + { + UsuarioView usuarioView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(usuarioView.SomenteNumeros); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.CpfBox_OnLostFocus); + return; + } + case 16: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TelaInicial_OnSelectionChanged); + return; + } + case 17: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 18: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 19: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, UsuarioView.AutoCompleteBancoBox_Populating)); + return; + } + case 20: + { + this.CepBox = (TextBox)target; + this.CepBox.LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + UsuarioView usuarioView1 = this; + this.CepBox.PreviewTextInput += new TextCompositionEventHandler(usuarioView1.SomenteNumeros); + return; + } + case 21: + { + this.EnderecoBox = (TextBox)target; + return; + } + case 22: + { + this.NumeroBox = (TextBox)target; + return; + } + case 23: + { + this.BairroBox = (TextBox)target; + return; + } + case 24: + { + this.CidadeBox = (TextBox)target; + return; + } + case 25: + { + this.EstadoBox = (TextBox)target; + return; + } + case 26: + { + UsuarioView usuarioView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(usuarioView2.SomenteNumeros); + return; + } + case 27: + { + UsuarioView usuarioView3 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(usuarioView3.FormatarTelefone); + UsuarioView usuarioView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(usuarioView4.SomenteNumeros); + return; + } + case 28: + { + UsuarioView usuarioView5 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(usuarioView5.SomenteNumeros); + return; + } + case 29: + { + UsuarioView usuarioView6 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(usuarioView6.FormatarTelefone); + UsuarioView usuarioView7 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(usuarioView7.SomenteNumeros); + return; + } + case 30: + { + ((ToggleButton)target).Click += new RoutedEventHandler(this.Click_VerificaAdmCentralSegurado); + return; + } + } + this._contentLoaded = true; + } + + private async void TelaInicial_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (!this._setting) + { + if (((ComboBox)sender).SelectedItem != null) + { + if ((TipoTelaInicial)((ComboBox)sender).SelectedItem == 1 && this.ViewModel.Restricao(47)) + { + this._setting = true; + ((ComboBox)sender).SelectedItem = (TipoTelaInicial)0; + this._setting = false; + if (!this._firstTime) + { + await this.ViewModel.ShowMessage("FAVOR DESABILITAR A RESTRIÇÃO AO PAINEL B.I. ANTES.", "OK", "", false); + } + else + { + this._firstTime = false; + return; + } + } + this._firstTime = false; + } + } + } + + private async void UsuarioGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + object obj; + if (this.ViewModel.EnableGrid) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + this.ViewModel.EnableGrid = false; + UsuarioViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaUsuario((Usuario)obj); + this.ViewModel.EnableGrid = true; + } + } + } + + private async void Vinculo_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.OpenVinculo(); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Ferramentas/VendedorView.cs b/Codemerx/Gestor.Application/Views/Ferramentas/VendedorView.cs new file mode 100644 index 0000000..1c2d4b4 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Ferramentas/VendedorView.cs @@ -0,0 +1,927 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.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 Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.Ferramentas +{ + public class VendedorView : BaseUserControl, IComponentConnector, IStyleConnector + { + public VendedorViewModel ViewModel; + + internal DataGrid VendedorGrid; + + internal MenuItem IncluirButton; + + internal MenuItem AlterarButton; + + internal MenuItem SalvarButton; + + internal MenuItem CancelarButton; + + internal MenuItem MaisOpcoesButton; + + internal TextBox EmpresaBox; + + internal TextBox IdBox; + + internal TextBox NomeBox; + + internal TextBox DocumentoPrincipalBox; + + internal AutoCompleteBox AutoCompleteBanco; + + internal TextBox AgenciaBox; + + internal ComboBox TipoBox; + + internal TextBox ContaBox; + + internal TextBox TitularBox; + + internal TextBox TitularDocBox; + + internal ComboBox TipoIncidenciaDescontoBox; + + internal ToggleButton AtivoBox; + + internal Grid GridContatos; + + private bool _contentLoaded; + + public bool UpdatingScroll + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public VendedorView() + { + base.Tag = "CADASTRO DE VENDEDOR"; + this.ViewModel = new VendedorViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 6).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedVendedor.get_Id()); + filtroArquivoDigital.set_Tipo(6); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedVendedor); + 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 ", EnumHelper.GetDescription(6), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(15, this.ViewModel.SelectedVendedor.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(15, this.ViewModel.SelectedVendedor.get_Id()); + } + + private void AbrirLogRepasse_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button == null || button.DataContext == null) + { + return; + } + Repasse dataContext = (Repasse)button.DataContext; + this.ViewModel.AbrirLog(54, dataContext.get_Id()); + } + + private async void Adiantamento_Click(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedVendedor == null || !this.ViewModel.SelectedVendedor.get_Corretora()) + { + this.ViewModel.ShowDrawer(new AdiantamentoDrawerView(this.ViewModel.SelectedVendedor), 0, false); + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ADICIONAR ADIANTAMENTOS PARA O VENDEDOR PRÓPRIA CORRETORA.", "OK", "", false); + } + } + + private async void Alterar_OnClick(object sender, RoutedEventArgs e) + { + bool corretora; + object obj; + Vendedor selectedVendedor = this.ViewModel.SelectedVendedor; + if (selectedVendedor != null) + { + corretora = selectedVendedor.get_Corretora(); + } + else + { + corretora = false; + } + bool flag = corretora; + if (flag) + { + if (Recursos.Usuario.get_Id() == 0) + { + this.AlterarPropriaCorretora(true); + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ALTERAR O VENDEDOR PRÓPRIA CORRETORA.", "OK", "", false); + return; + } + } + this.ViewModel.IsExpanded = false; + VendedorViewModel viewModel = this.ViewModel; + Vendedor vendedor = this.ViewModel.SelectedVendedor; + if (vendedor != null) + { + obj = vendedor.Clone(); + } + else + { + obj = null; + } + viewModel.CancelVendedor = (Vendedor)obj; + if (!flag) + { + this.ViewModel.Alterar(true); + } + this.ValidarTela(); + } + + public void AlterarPropriaCorretora(bool habilitar = false) + { + if (habilitar) + { + this.NomeBox.IsReadOnly = false; + this.DocumentoPrincipalBox.IsReadOnly = false; + this.AlterarButton.IsEnabled = false; + this.SalvarButton.IsEnabled = true; + this.CancelarButton.IsEnabled = true; + this.IncluirButton.IsEnabled = false; + return; + } + this.NomeBox.IsReadOnly = true; + this.DocumentoPrincipalBox.IsReadOnly = true; + this.AlterarButton.IsEnabled = true; + this.SalvarButton.IsEnabled = false; + this.CancelarButton.IsEnabled = false; + this.IncluirButton.IsEnabled = false; + } + + private async void AtivarInativarRepasse_OnClick(object sender, RoutedEventArgs e) + { + if (!this.ViewModel.SelectedVendedor.get_Corretora()) + { + Repasse dataContext = (Repasse)((Button)sender).DataContext; + if (dataContext != null) + { + this.ViewModel.Loading(true); + await this.ViewModel.AtivarInativarRepasse(dataContext); + this.ScrollVendedor(); + this.ViewModel.Loading(false); + } + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ALTERAR O VENDEDOR PRÓPRIA CORRETORA.", "OK", "", false); + } + } + + private async void AtivarInativarVendedor_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedVendedor != null) + { + if (this.ViewModel.SelectedVendedor.get_Corretora()) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ALTERAR O VENDEDOR PRÓPRIA CORRETORA.", "OK", "", false); + } + else if (!await this.BuscaVinculo(this.ViewModel.SelectedVendedor)) + { + this.ViewModel.Loading(true); + await this.ViewModel.AtivarInativarVendedor(this.ViewModel.SelectedVendedor); + this.ScrollVendedor(); + this.ViewModel.Loading(false); + } + } + } + + private void AutoCompleteBanco_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + VendedorView.SetValid(autoCompleteBox, (string.IsNullOrWhiteSpace(autoCompleteBox.get_Text()) ? true : this.ViewModel.SelectedVendedor.get_Banco() != null)); + } + + private void AutoCompleteBancoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarBanco(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 void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarVendedor(""); + } + + private void AutoCompleteBoxVendedor_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 Task BuscaVinculo(Vendedor vendedor) + { + bool flag; + if (await (new VendedorUsuarioServico()).FindVinculo(vendedor)) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL INATIVAR VENDEDOR QUE POSSUI VINCULO DE USUÁRIO.", "OK", "", false); + this.ViewModel.Loading(false); + flag = true; + } + else + { + flag = false; + } + return flag; + } + + public async void Button_Click(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedVendedor == null || !this.ViewModel.SelectedVendedor.get_Corretora()) + { + this.ViewModel.Loading(true); + if (await this.ViewModel.VerificarPermissao(30, false)) + { + this.ViewModel.ShowDrawer(new MetaVendedorView(this.ViewModel.SelectedVendedor), 0, false); + this.ViewModel.Loading(false); + } + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL CRIAR METAS DE VENDEDOR PARA O VENDEDOR PRÓPRIA CORRETORA.", "OK", "", false); + } + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + this.ViewModel.IsExpanded = true; + if (Recursos.Usuario.get_Id() == 0) + { + this.AlterarPropriaCorretora(false); + } + } + + private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e) + { + if (((TextBox)sender).IsReadOnly) + { + return; + } + string str = ValidationHelper.Clear(this.DocumentoPrincipalBox.Text); + if (string.IsNullOrEmpty(str)) + { + return; + } + this.DocumentoPrincipalBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14))); + } + + private void ExcluirTelefone_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(button); + VendedorTelefone item = (VendedorTelefone)listBox.Items[listBox.Items.IndexOf(button.DataContext)]; + this.ViewModel.ExcluirTelefone(item); + } + + private async void ExcluirVinculo_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button != null && button.DataContext != null) + { + VinculoRepasse dataContext = (VinculoRepasse)button.DataContext; + this.ViewModel.Loading(true); + await this.ViewModel.ExcluirVinculo(dataContext); + this.ViewModel.Loading(false); + } + } + + private void FormaPagtoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + Grid grid = ViewHelper.FindAncestor(comboBox).FirstOrDefault(); + if (grid == null) + { + return; + } + ComboBox comboBox1 = (ComboBox)FindVisualChild.Find(grid).FindName("BasePagtoBox"); + FormaRepasse selectedItem = (FormaRepasse)comboBox.SelectedItem; + if (comboBox1 == null) + { + return; + } + comboBox1.IsEnabled = true; + switch (selectedItem) + { + case 1: + { + comboBox1.SelectedItem = null; + return; + } + case 2: + { + comboBox1.SelectedItem = (BaseRepasse)1; + return; + } + case 3: + { + comboBox1.SelectedItem = (BaseRepasse)3; + comboBox1.IsEnabled = false; + return; + } + default: + { + return; + } + } + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.AutoCompleteBanco.set_Text(""); + this.ValidarTela(); + } + + private void IncluirRepasse_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirRepasse(); + this.ValidarTela(); + } + + private void IncluirTelefone_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirTelefone(); + this.ValidarTela(); + } + + private async void IncluirVinculo_OnClick(object sender, RoutedEventArgs e) + { + bool dataContext; + List repasses; + Repasse repasse; + VinculoRepasse vinculoRepasse; + Button button = (Button)sender; + Button button1 = button; + if (button1 != null) + { + dataContext = button1.DataContext; + } + else + { + dataContext = false; + } + if (dataContext) + { + this.ViewModel.Loading(true); + repasses = await (new VendedorServico()).BuscaRepasses(); + repasse = (Repasse)button.DataContext; + VinculoRepasse vinculoRepasse1 = new VinculoRepasse(); + vinculoRepasse1.set_IdRepasse(repasse.get_Id()); + VinculoRepasse vinculoRepasse2 = vinculoRepasse1; + if (repasse.get_Ativo()) + { + vinculoRepasse = await this.ViewModel.ShowVinculoDialog(vinculoRepasse2, repasses, repasse); + if (vinculoRepasse != null) + { + List> keyValuePairs = vinculoRepasse.Validate(repasse.get_Vinculo(), repasse); + while (keyValuePairs != null && keyValuePairs.Count > 0) + { + await this.ViewModel.ShowMessage(keyValuePairs, "OS CAMPOS ABAIXO ESTÃO INVÁLIDOS.", "OK", ""); + vinculoRepasse = await this.ViewModel.ShowVinculoDialog(vinculoRepasse, repasses, repasse); + if (vinculoRepasse != null) + { + keyValuePairs = vinculoRepasse.Validate(repasse.get_Vinculo(), repasse); + } + else + { + this.ViewModel.Loading(false); + button = null; + repasses = null; + repasse = null; + vinculoRepasse = null; + return; + } + } + await this.ViewModel.SalvarVinculo(vinculoRepasse); + this.ViewModel.Loading(false); + } + else + { + this.ViewModel.Loading(false); + } + } + else + { + await this.ViewModel.ShowMessage("POR FAVOR, ATIVE O REPASSE PARA VINCULÁ-LO", "OK", "", false); + this.ViewModel.Loading(false); + } + } + button = null; + repasses = null; + repasse = null; + vinculoRepasse = null; + } + + [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/ferramentas/vendedorview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.ViewModel.IsExpanded = true; + if (!this.ViewModel.SelectedVendedor.get_Ativo()) + { + if (await this.BuscaVinculo(this.ViewModel.SelectedVendedor)) + { + return; + } + } + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + if (Recursos.Usuario.get_Id() == 0) + { + this.AlterarPropriaCorretora(false); + } + this.ScrollVendedor(); + } + } + + private void ScrollVendedor() + { + if (!this.UpdatingScroll && this.VendedorGrid.SelectedItem != null) + { + this.VendedorGrid.ScrollIntoView(this.VendedorGrid.SelectedItem); + } + this.UpdatingScroll = false; + } + + private static void SetValid(AutoCompleteBox autocomplete, bool valid) + { + ViewHelper.SetInvalid(autocomplete, "BANCO INVÁLIDO", valid); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, VendedorView.AutoCompleteBoxVendedor_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.VendedorGrid = (DataGrid)target; + return; + } + case 3: + { + this.IncluirButton = (MenuItem)target; + this.IncluirButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + this.AlterarButton = (MenuItem)target; + this.AlterarButton.Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + this.SalvarButton = (MenuItem)target; + this.SalvarButton.Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + this.CancelarButton = (MenuItem)target; + this.CancelarButton.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Adiantamento_Click); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Button_Click); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 10: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 13: + { + this.EmpresaBox = (TextBox)target; + return; + } + case 14: + { + this.IdBox = (TextBox)target; + return; + } + case 15: + { + this.NomeBox = (TextBox)target; + return; + } + case 16: + { + this.DocumentoPrincipalBox = (TextBox)target; + VendedorView vendedorView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(vendedorView.SomenteNumeros); + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + return; + } + case 17: + { + this.AutoCompleteBanco = (AutoCompleteBox)target; + this.AutoCompleteBanco.add_Populating(new PopulatingEventHandler(this, VendedorView.AutoCompleteBancoBox_Populating)); + this.AutoCompleteBanco.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.AutoCompleteBanco_OnLostKeyboardFocus); + return; + } + case 18: + { + this.AgenciaBox = (TextBox)target; + return; + } + case 19: + { + this.TipoBox = (ComboBox)target; + return; + } + case 20: + { + this.ContaBox = (TextBox)target; + return; + } + case 21: + { + this.TitularBox = (TextBox)target; + return; + } + case 22: + { + this.TitularDocBox = (TextBox)target; + VendedorView vendedorView1 = this; + this.TitularDocBox.PreviewTextInput += new TextCompositionEventHandler(vendedorView1.SomenteNumeros); + return; + } + case 23: + { + this.TipoIncidenciaDescontoBox = (ComboBox)target; + return; + } + case 24: + { + this.AtivoBox = (ToggleButton)target; + return; + } + case 25: + { + ((Button)target).Click += new RoutedEventHandler(this.AtivarInativarVendedor_OnClick); + return; + } + case 26: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirRepasse_OnClick); + return; + } + case 27: + case 28: + case 29: + case 30: + case 31: + case 32: + { + this._contentLoaded = true; + return; + } + case 33: + { + this.GridContatos = (Grid)target; + return; + } + case 34: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTelefone_OnClick); + 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 27: + { + ((Button)target).Click += new RoutedEventHandler(this.IncluirVinculo_OnClick); + return; + } + case 28: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirLogRepasse_OnClick); + return; + } + case 29: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoBox_OnSelectionChanged); + return; + } + case 30: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.FormaPagtoBox_OnSelectionChanged); + return; + } + case 31: + { + ((Button)target).Click += new RoutedEventHandler(this.AtivarInativarRepasse_OnClick); + return; + } + case 32: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirVinculo_OnClick); + return; + } + case 33: + case 34: + { + return; + } + case 35: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirTelefone_OnClick); + return; + } + case 36: + { + VendedorView vendedorView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(vendedorView.SomenteNumeros); + return; + } + case 37: + { + VendedorView vendedorView1 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(vendedorView1.FormatarTelefone); + VendedorView vendedorView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(vendedorView2.SomenteNumeros); + return; + } + default: + { + return; + } + } + } + + private void TipoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + ListBoxItem listBoxItem = ViewHelper.FindAncestor(comboBox).FirstOrDefault(); + if (listBoxItem == null) + { + return; + } + ComboBox comboBox1 = (ComboBox)FindVisualChild.Find(listBoxItem).FindName("FormaPagtoBox"); + if (comboBox1 == null) + { + return; + } + CurrencyTextBox currencyTextBox = (CurrencyTextBox)FindVisualChild.Find(listBoxItem).FindName("ValorBox"); + CurrencyTextBox currencyTextBox1 = (CurrencyTextBox)FindVisualChild.Find(listBoxItem).FindName("RenovacoesBox"); + TipoRepasse selectedItem = (TipoRepasse)comboBox.SelectedItem; + comboBox1.SelectedItem = (FormaRepasse)1; + if (selectedItem == 1) + { + if (currencyTextBox != null) + { + currencyTextBox.set_MaximumValue(new decimal(10000)); + } + if (currencyTextBox1 != null) + { + currencyTextBox1.set_MaximumValue(new decimal(10000)); + } + } + else if (selectedItem == 2) + { + if (currencyTextBox != null) + { + currencyTextBox.set_MaximumValue(new decimal(100)); + } + if (currencyTextBox1 != null) + { + currencyTextBox1.set_MaximumValue(new decimal(100)); + return; + } + } + } + + private void ValidarTela() + { + object keyValuePairs; + object obj; + if (this.ViewModel.SelectedVendedor == null) + { + return; + } + List> keyValuePairs1 = this.ViewModel.SelectedVendedor.Validate(); + List> keyValuePairs2 = keyValuePairs1; + List telefones = this.ViewModel.SelectedVendedor.get_Telefones(); + if (telefones != null) + { + VendedorTelefone vendedorTelefone = telefones.FirstOrDefault(); + if (vendedorTelefone != null) + { + keyValuePairs = vendedorTelefone.Validate(); + } + else + { + keyValuePairs = null; + } + } + else + { + keyValuePairs = null; + } + if (keyValuePairs == null) + { + keyValuePairs = new List>(); + } + keyValuePairs2.AddRange((IEnumerable)keyValuePairs); + List> keyValuePairs3 = keyValuePairs1; + ObservableCollection repasses = this.ViewModel.Repasses; + if (repasses != null) + { + Repasse repasse = repasses.FirstOrDefault(); + if (repasse != null) + { + obj = repasse.Validate(); + } + else + { + obj = null; + } + } + else + { + obj = null; + } + if (obj == null) + { + obj = new List>(); + } + keyValuePairs3.AddRange((IEnumerable)obj); + this.ValidateFields(keyValuePairs1, false); + } + + private void VendedorView_SizeChanged(object sender, SizeChangedEventArgs e) + { + if (e.NewSize.Width > 1260) + { + this.ViewModel.GridHeight2 = new GridLength(0); + Grid.SetRow(this.GridContatos, 0); + Grid.SetColumn(this.GridContatos, 1); + return; + } + this.ViewModel.GridHeight2 = new GridLength(1, GridUnitType.Star); + Grid.SetRow(this.GridContatos, 1); + Grid.SetColumn(this.GridContatos, 0); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Financeiro/BancosContasView.cs b/Codemerx/Gestor.Application/Views/Financeiro/BancosContasView.cs new file mode 100644 index 0000000..fa40fe7 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Financeiro/BancosContasView.cs @@ -0,0 +1,371 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Financeiro; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +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; + +namespace Gestor.Application.Views.Financeiro +{ + public class BancosContasView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal DataGrid BancosContasGrid; + + internal AutoCompleteBox AutoCompleteBanco; + + internal CurrencyTextBox ValorSaldoBox; + + private bool _contentLoaded; + + public BancosContasViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public BancosContasView() + { + base.Tag = "BANCOS E CONTAS"; + this.ViewModel = new BancosContasViewModel(); + base.DataContext = this.ViewModel; + this.ViewModel.Alterar(false); + 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(26, this.ViewModel.SelectedBancosContas.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelBancosContas = (BancosContas)this.ViewModel.SelectedBancosContas.Clone(); + this.ViewModel.Alterar(true); + this.ViewModel.SelectedBancosContas.Initialize(); + } + + private void AutoCompleteBancoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarBanco(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 void AutoCompleteBancosContasBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarBancosContas(""); + } + + private void BancosContasGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelectedBancosContas = (BancosContas)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null)); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.BancosContasGrid.SelectedIndex = 0; + this.BancosContasGrid.SelectionChanged += new SelectionChangedEventHandler(this.BancosContasGrid_OnSelectionChanged); + this.BancosContasGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void ExcluirSaldo_OnClick(object sender, RoutedEventArgs e) + { + ((MenuItem)sender).Click -= new RoutedEventHandler(this.ExcluirSaldo_OnClick); + this.ViewModel.ExcluirSaldo(); + ((MenuItem)sender).Click += new RoutedEventHandler(this.ExcluirSaldo_OnClick); + } + + private async void FechamentoBox_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DateTime dateTime; + DatePicker datePicker = (DatePicker)sender; + datePicker.Text = ValidationHelper.FormatDate(datePicker.Text); + if (DateTime.TryParse(datePicker.Text, out dateTime)) + { + CurrencyTextBox valorSaldoBox = this.ValorSaldoBox; + valorSaldoBox.set_Number(await this.ViewModel.CalcularValor()); + valorSaldoBox = null; + } + } + + private async void FecharSaldo_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + TimeSpan? nullable; + bool flag1; + DateTime? dataFinal = this.ViewModel.SelectedSaldo.get_DataFinal(); + if (dataFinal.HasValue) + { + dataFinal = this.ViewModel.SelectedSaldo.get_DataInicio(); + DateTime? dataFinal1 = this.ViewModel.SelectedSaldo.get_DataFinal(); + DateTime value = dataFinal1.Value; + flag = (dataFinal.HasValue ? dataFinal.GetValueOrDefault() >= value : false); + if (!flag) + { + dataFinal1 = this.ViewModel.SelectedSaldo.get_DataFinal(); + value = dataFinal1.Value; + dataFinal = this.ViewModel.SelectedSaldo.get_DataInicio(); + if (dataFinal.HasValue) + { + nullable = new TimeSpan?(value - dataFinal.GetValueOrDefault()); + } + else + { + nullable = null; + } + TimeSpan? nullable1 = nullable; + if (!nullable1.HasValue) + { + flag1 = false; + } + else + { + flag1 = (nullable1.Value.TotalDays < 28 ? true : nullable1.Value.TotalDays > 31); + } + bool flag2 = flag1; + if (flag2) + { + flag2 = !await this.ViewModel.ShowMessage("O INTERVALO DE FECHAMENTO É RECOMENDADO 1 MÊS. DESEJA CONTINUAR?", "SIM", "NÃO", false); + } + if (!flag2) + { + this.ViewModel.Loading(true); + await this.ViewModel.FecharSaldo(); + this.ViewModel.Loading(false); + } + } + else + { + await this.ViewModel.ShowMessage("A DATA DE FECHAMENTO DEVE SER MAIOR QUE A DATA DE ABERTURA DO SALDO.", "OK", "", false); + } + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIO PREENCHER A DATA DE FECHAMENTO.", "OK", "", false); + } + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.AutoCompleteBanco.set_Text(""); + List> keyValuePairs = this.ViewModel.SelectedBancosContas.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + private void InfoExtrato_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button == null || button.DataContext == null) + { + return; + } + (new HosterWindow(new InfoExtratoView((Saldo)button.DataContext, true), "INFORMAÇÕES DO EXTRATO", new double?((double)800), new double?((double)450), false)).ShowDialog(); + this.ViewModel.Loading(true); + this.ViewModel.CarregarSaldos(this.ViewModel.SelectedBancosContas); + this.ViewModel.Loading(false); + } + + [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/financeiro/bancoscontasview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, BancosContasView.AutoCompleteBancosContasBox_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.BancosContasGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 9: + { + this.AutoCompleteBanco = (AutoCompleteBox)target; + this.AutoCompleteBanco.add_Populating(new PopulatingEventHandler(this, BancosContasView.AutoCompleteBancoBox_Populating)); + return; + } + case 10: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 11: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.FechamentoBox_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 12: + { + this.ValorSaldoBox = (CurrencyTextBox)target; + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.FecharSaldo_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirSaldo_OnClick); + return; + } + } + this._contentLoaded = true; + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) + { + if (connectionId == 15) + { + ((Button)target).Click += new RoutedEventHandler(this.InfoExtrato_OnClick); + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Financeiro/CentroDeCustoView.cs b/Codemerx/Gestor.Application/Views/Financeiro/CentroDeCustoView.cs new file mode 100644 index 0000000..02dd796 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Financeiro/CentroDeCustoView.cs @@ -0,0 +1,199 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Financeiro; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +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; + +namespace Gestor.Application.Views.Financeiro +{ + public class CentroDeCustoView : UserControl, IComponentConnector + { + private bool _seleciona = true; + + internal DataGrid CentroDeCustoGrid; + + private bool _contentLoaded; + + private CentroDeCustoViewmodel ViewModel + { + get; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public CentroDeCustoView() + { + base.Tag = "CENTRO DE CUSTO"; + this.ViewModel = new CentroDeCustoViewmodel(); + 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(29, this.ViewModel.SelectedCentro.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelCentro = (Centro)this.ViewModel.SelectedCentro.Clone(); + this.ViewModel.Alterar(true); + this.ViewModel.SelectedCentro.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarCentro(""); + } + + private void AutoCompleteBoxCentro_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task> searchResult) => { + if (searchResult == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void CentroDeCustoGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (!this._seleciona) + { + return; + } + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaCentroDeCusto((Centro)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private void ContentLoad() + { + this.CentroDeCustoGrid.SelectedIndex = 0; + this.CentroDeCustoGrid.SelectionChanged += new SelectionChangedEventHandler(this.CentroDeCustoGrid_OnSelectionChanged); + this.CentroDeCustoGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + List> keyValuePairs = this.ViewModel.SelectedCentro.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + [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/financeiro/centrodecustoview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, CentroDeCustoView.AutoCompleteBoxCentro_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.CentroDeCustoGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Financeiro/ExtratoWindow.cs b/Codemerx/Gestor.Application/Views/Financeiro/ExtratoWindow.cs new file mode 100644 index 0000000..9f75243 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Financeiro/ExtratoWindow.cs @@ -0,0 +1,511 @@ +using Gestor.Application; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Financeiro; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Seguros; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Interop; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Shapes; +using System.Windows.Shell; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Financeiro +{ + public class ExtratoWindow : Window, IComponentConnector + { + private bool _buttonClickable; + + public ExtratoContaViewModel ViewModel; + + internal System.Windows.Shell.WindowChrome WindowChrome; + + internal Grid MinimizeButton; + + internal Grid MaximizeButton; + + internal Grid CloseButton; + + internal System.Windows.Controls.ProgressBar ProgressRing; + + internal System.Windows.Controls.ComboBox ContaBox; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal System.Windows.Controls.DataGrid LancamentoGrid; + + internal TextBlock NaoHaDados; + + internal MaterialDesignThemes.Wpf.Snackbar Snackbar; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ExtratoWindow(long id = 0L) + { + this.ViewModel = new ExtratoContaViewModel(id); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + string str = ApplicationHelper.Versao.ToString(); + this.ViewModel.Head = string.Concat(new string[] { Recursos.Usuario.get_Nome(), " - ", Recursos.Empresa.get_Nome(), ", VOCÊ ESTÁ EM RELATÓRIOS DE CONTA CORRENTE | VERSÃO GESTOR ", str }); + } + + public void CloseButton_Click() + { + base.Close(); + } + + private void CloseSlackBar() + { + Thread.Sleep(3000); + System.Windows.Threading.Dispatcher dispatcher = App.ProgressRing.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => this.ToggleSnackBar("", false))); + } + + private void ContentLoad() + { + this.MinimizeButton.MouseEnter += new System.Windows.Input.MouseEventHandler(ExtratoWindow.TopControls_OnMouseEnter); + this.MinimizeButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave); + this.MaximizeButton.MouseEnter += new System.Windows.Input.MouseEventHandler(ExtratoWindow.TopControls_OnMouseEnter); + this.MaximizeButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave); + this.CloseButton.MouseEnter += new System.Windows.Input.MouseEventHandler(ExtratoWindow.TopControls_OnMouseEnter); + this.CloseButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave); + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.SelectedDateChanged += new EventHandler(this.Periodo_OnSelectedDateChanged); + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.FimBox.SelectedDateChanged += new EventHandler(this.Periodo_OnSelectedDateChanged); + } + + private void DataAtual_OnDoubleClick(object sender, RoutedEventArgs e) + { + ((DatePicker)sender).SelectedDate = new DateTime?(Funcoes.GetNetworkTime().Date); + } + + private void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DatePicker datePicker = (DatePicker)sender; + datePicker.Text = ValidationHelper.FormatDate(datePicker.Text); + } + + private void DatePicker_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (e.Key != Key.Return) + { + return; + } + DatePicker str = (DatePicker)sender; + DateTime date = Funcoes.GetNetworkTime().Date; + str.Text = date.ToString("dd/MM/yyyy"); + } + + private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.GerarExcel(); + } + + private async void GerarResultados_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + if (ValidationHelper.ValidateDate(ValidationHelper.FormatDate(this.InicioBox.Text))) + { + this.InicioBox.SelectedDate = new DateTime?(DateTime.Parse(ValidationHelper.FormatDate(this.InicioBox.Text))); + } + if (ValidationHelper.ValidateDate(ValidationHelper.FormatDate(this.FimBox.Text))) + { + this.FimBox.SelectedDate = new DateTime?(DateTime.Parse(ValidationHelper.FormatDate(this.FimBox.Text))); + } + DateTime? selectedDate = this.InicioBox.SelectedDate; + if (selectedDate.HasValue) + { + selectedDate = this.FimBox.SelectedDate; + if (selectedDate.HasValue) + { + selectedDate = this.InicioBox.SelectedDate; + DateTime? nullable = this.FimBox.SelectedDate; + flag = (selectedDate.HasValue & nullable.HasValue ? selectedDate.GetValueOrDefault() > nullable.GetValueOrDefault() : false); + if (!flag) + { + this.ProgressRing.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.IsEnabled = false; + await this.ViewModel.GerarRelatorio(); + this.ViewModel.IsEnabled = true; + this.ProgressRing.Visibility = System.Windows.Visibility.Collapsed; + return; + } + else + { + await this.ViewModel.ShowMessage("A DATA FINAL NÃO PODE SER MENOR QUE A DATA INICIAL DO FILTRO.", "OK", "", false); + return; + } + } + } + await this.ViewModel.ShowMessage("NECESSÁRIO PREENCHER O PERIODO INICIAL E FINAL PARA O FILTRO.", "OK", "", false); + } + + [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)] + private static extern bool GetCursorPos(out MainWindow.Point lpPoint); + + [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)] + private static extern bool GetMonitorInfo(IntPtr hMonitor, ExtratoWindow.Monitorinfo lpmi); + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + 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/financeiro/extratowindow.xaml", UriKind.Relative)); + } + + public void MaximizeButton_Click() + { + base.WindowState = (base.WindowState == System.Windows.WindowState.Normal ? System.Windows.WindowState.Maximized : System.Windows.WindowState.Normal); + } + + public void MinimizeButton_Click() + { + base.WindowState = System.Windows.WindowState.Minimized; + } + + [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false, SetLastError=true)] + private static extern IntPtr MonitorFromPoint(MainWindow.Point pt, ExtratoWindow.MonitorOptions dwFlags); + + protected sealed override void OnStateChanged(EventArgs e) + { + object obj; + base.BorderThickness = new Thickness((double)(base.WindowState != System.Windows.WindowState.Maximized)); + System.Windows.Shell.WindowChrome windowChrome = this.WindowChrome; + if (base.WindowState == System.Windows.WindowState.Maximized) + { + obj = null; + } + else + { + obj = 4; + } + windowChrome.ResizeBorderThickness = new Thickness((double)obj); + this.WindowChrome.CaptionHeight = (double)((base.WindowState == System.Windows.WindowState.Maximized ? 33 : 30)); + this.ViewModel.MaximizeRestore = (base.WindowState == System.Windows.WindowState.Maximized ? Geometry.Parse((string)System.Windows.Application.Current.Resources["Restore"]) : Geometry.Parse((string)System.Windows.Application.Current.Resources["Maximize"])); + base.OnStateChanged(e); + } + + private void Periodo_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + this.ViewModel.LimparRelatorio(); + } + + private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e) + { + this.Snackbar.set_IsActive(false); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((ExtratoWindow)target).Initialized += new EventHandler(this.Window_OnInitialized); + return; + } + case 2: + { + this.WindowChrome = (System.Windows.Shell.WindowChrome)target; + return; + } + case 3: + { + this.MinimizeButton = (Grid)target; + this.MinimizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.MinimizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 4: + { + this.MaximizeButton = (Grid)target; + this.MaximizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.MaximizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 5: + { + this.CloseButton = (Grid)target; + this.CloseButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.CloseButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 6: + { + this.ProgressRing = (System.Windows.Controls.ProgressBar)target; + return; + } + case 7: + { + this.ContaBox = (System.Windows.Controls.ComboBox)target; + return; + } + case 8: + { + this.InicioBox = (DatePicker)target; + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 9: + { + this.FimBox = (DatePicker)target; + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 10: + { + ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.GerarResultados_OnClick); + return; + } + case 11: + { + ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 12: + { + ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.ExportarExcel_OnClick); + return; + } + case 13: + { + this.LancamentoGrid = (System.Windows.Controls.DataGrid)target; + return; + } + case 14: + { + this.NaoHaDados = (TextBlock)target; + return; + } + case 15: + { + this.Snackbar = (MaterialDesignThemes.Wpf.Snackbar)target; + return; + } + case 16: + { + ((SnackbarMessage)target).add_ActionClick(new RoutedEventHandler(this.SnackbarMessage_ActionClick)); + return; + } + } + this._contentLoaded = true; + } + + public void ToggleSnackBar(string message, bool active = true) + { + this.Snackbar.get_Message().Content = message; + this.Snackbar.set_IsActive(active); + if (!active) + { + return; + } + Task.Factory.StartNew(new Action(this.CloseSlackBar)); + } + + private static void TopControls_OnMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) + { + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray)); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeave(object sender, System.Windows.Input.MouseEventArgs e) + { + this._buttonClickable = false; + ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + this._buttonClickable = true; + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.DimGray)); + } + + private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + if (this._buttonClickable) + { + MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click")); + if (method == null) + { + return; + } + method.Invoke(this, null); + } + } + + private void Window_OnInitialized(object sender, EventArgs e) + { + WindowInteropHelper windowInteropHelper = new WindowInteropHelper(this); + windowInteropHelper.EnsureHandle(); + HwndSource hwndSource = HwndSource.FromHwnd(windowInteropHelper.Handle); + if (hwndSource == null) + { + return; + } + hwndSource.AddHook(new HwndSourceHook(this.WindowProc)); + } + + private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) + { + if (msg == 36) + { + this.WmGetMinMaxInfo(lParam); + } + return IntPtr.Zero; + } + + private void WmGetMinMaxInfo(IntPtr lParam) + { + MainWindow.Point point; + System.Drawing.Rectangle workingArea = Screen.FromHandle((new WindowInteropHelper(this)).Handle).WorkingArea; + base.MaxHeight = (double)workingArea.Height; + ExtratoWindow.GetCursorPos(out point); + IntPtr intPtr = ExtratoWindow.MonitorFromPoint(new MainWindow.Point(0, 0), ExtratoWindow.MonitorOptions.MonitorDefaulttoprimary); + ExtratoWindow.Monitorinfo monitorinfo = new ExtratoWindow.Monitorinfo(); + if (!ExtratoWindow.GetMonitorInfo(intPtr, monitorinfo)) + { + return; + } + IntPtr intPtr1 = ExtratoWindow.MonitorFromPoint(point, ExtratoWindow.MonitorOptions.MonitorDefaulttonearest); + ExtratoWindow.Minmaxinfo structure = (ExtratoWindow.Minmaxinfo)Marshal.PtrToStructure(lParam, typeof(ExtratoWindow.Minmaxinfo)); + if (!intPtr.Equals(intPtr1)) + { + structure.ptMaxPosition.X = monitorinfo.rcMonitor.Left; + structure.ptMaxPosition.Y = monitorinfo.rcMonitor.Top; + structure.ptMaxSize.X = monitorinfo.rcMonitor.Right - monitorinfo.rcMonitor.Left; + structure.ptMaxSize.Y = monitorinfo.rcMonitor.Bottom - monitorinfo.rcMonitor.Top; + } + else + { + structure.ptMaxPosition.X = monitorinfo.rcWork.Left; + structure.ptMaxPosition.Y = monitorinfo.rcWork.Top; + structure.ptMaxSize.X = monitorinfo.rcWork.Right - monitorinfo.rcWork.Left; + structure.ptMaxSize.Y = monitorinfo.rcWork.Bottom - monitorinfo.rcWork.Top; + } + Marshal.StructureToPtr(structure, lParam, true); + } + + private struct Minmaxinfo + { + private readonly MainWindow.Point ptReserved; + + public ExtratoWindow.Point ptMaxSize; + + public ExtratoWindow.Point ptMaxPosition; + + private readonly MainWindow.Point ptMinTrackSize; + + private readonly MainWindow.Point ptMaxTrackSize; + } + + private class Monitorinfo + { + private readonly int cbSize; + + public readonly ExtratoWindow.Rect rcMonitor; + + public readonly ExtratoWindow.Rect rcWork; + + private readonly int dwFlags; + + public Monitorinfo() + { + } + } + + private enum MonitorOptions : uint + { + MonitorDefaulttoprimary = 1, + MonitorDefaulttonearest = 2 + } + + public struct Point + { + public int X; + + public int Y; + + public Point(int x, int y) + { + this.X = x; + this.Y = y; + } + } + + public struct Rect + { + public int Left; + + public int Top; + + public int Right; + + public int Bottom; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Financeiro/FinanceiroView.cs b/Codemerx/Gestor.Application/Views/Financeiro/FinanceiroView.cs new file mode 100644 index 0000000..431e1d1 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Financeiro/FinanceiroView.cs @@ -0,0 +1,1560 @@ +using Gestor.Application.Actions; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Financeiro; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +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.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Input; +using System.Windows.Markup; +using Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.Financeiro +{ + public class FinanceiroView : BaseUserControl, IComponentConnector, IStyleConnector + { + private bool _selecionando; + + private List _sortDirections; + + private List _sortDescriptions; + + internal AutoCompleteBox AutoCompleteFornecedor; + + internal MenuItem MenuFiltros; + + internal Grid GridFiltros; + + internal DataGrid LancamentoGrid; + + internal AutoCompleteBox AutoCompleteFornecedorInclusao; + + private bool _contentLoaded; + + private string OriginalValue + { + get; + set; + } + + private TipoPagamento? tipoPagamento + { + get; + set; + } + + public FinanceiroViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public FinanceiroView() + { + base.Tag = "CONSULTA DE FINANÇAS"; + this.ViewModel = new FinanceiroViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + Gestor.Application.Actions.Actions.SortLancamentos = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.SortLancamentos, new Action(this.SortLancamentos)); + Gestor.Application.Actions.Actions.SaveSortLancamentos = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.SaveSortLancamentos, new Action(this.SaveSortLancamentos)); + } + + private async void AbrirLancamento(Lancamento lancamento) + { + if (this.ViewModel.SelectedLancamento == null) + { + await this.ViewModel.ShowMessage("SELECIONE UM LANCAMENTO ANTES DE PROSSEGUIR", "OK", "", false); + } + else if (lancamento.get_Id() <= (long)0 || lancamento.get_Controle().get_Plano() != null) + { + this.ViewModel.SelectedLancamento = lancamento; + this.ViewModel.VencimentoAlterado = false; + this.ViewModel.VencimentoAnt = this.ViewModel.SelectedLancamento.get_Vencimento(); + if (lancamento.get_Id() <= (long)0) + { + this.ViewModel.FiltrarLancamento(lancamento); + } + else + { + this.ViewModel.FiltrarLancamento(lancamento.get_Id()); + } + this.ViewModel.Alterando = System.Windows.Visibility.Visible; + this.ViewModel.BuscaHabilitada = false; + this.ValidarLancamento(); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(25, this.ViewModel.SelectedLancamento.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(25, this.ViewModel.SelectedLancamento.get_Id()); + } + + private async Task AbrirVinculo() + { + Lancamento lancamento; + if (this.ViewModel.LancamentosVinculo.Count != 0) + { + lancamento = await this.ViewModel.ShowVinculo(this.ViewModel); + if (lancamento != null) + { + if (!await this.ViewModel.ShowMessage(string.Format("DESEJA VINCULAR O LANÇAMENTO {0} A MOVIMENTAÇÃO SELECIONADA?", this.ViewModel.LancamentoVinculo.get_Id()), "SIM", "NÃO", false)) + { + await this.AbrirVinculo(); + } + this.ViewModel.FeedImportando(lancamento); + this.ViewModel.BindImportando(); + } + } + else + { + await this.ViewModel.ShowMessage("NÃO HÁ LANÇAMENTOS CRIADOS PARA O FORNECEDOR SELECIONADO.", "OK", "", false); + } + lancamento = null; + } + + private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdcionarFiltroPersonalizado(); + } + + private void AdicionarFiltros_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.LimparFiltros(); + this.ViewModel.AdicionarFiltros(); + this.ViewModel.IsExpanded = !this.ViewModel.IsExpanded; + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + Lancamento dataContext = (Lancamento)((Button)sender).DataContext; + this.ViewModel.VisibilityFornecedor = (this.ViewModel.Importando ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ViewModel.BotaoSalvarVisibility = (this.ViewModel.Importando ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.AbrirLancamento(dataContext); + this.ViewModel.Loading(false); + } + + private async void ArquivoDigital_OnClick(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 9).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedLancamento.get_Id()); + filtroArquivoDigital.set_Tipo(9); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedLancamento); + 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)9), "."), "OK", "", false); + } + } + + private void AutoCompleteBoxDetalhe_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.FiltroPersonalizadoTask(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 void AutoCompleteFornecedor_OnPopulating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarFornecedor(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 void AutoCompleteFornecedorAtivo_OnPopulating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarFornecedorAtivo(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 void AutoCompleteLancamento_OnPopulating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.FiltrarLancamento(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 void AutoCompleteLancamento_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.Filtrar(""); + } + + private void Baixados_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.SelectedStatusImportacao = 1; + this.ViewModel.FiltroImportacao(); + } + + private async void Buscar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + await this.ViewModel.Buscar(); + this.ViewModel.Loading(false); + } + + private async void BuscarLancamentos_Click(object sender, RoutedEventArgs e) + { + if (this.ViewModel.FornecedorInclusao == null || this.ViewModel.FornecedorInclusao.get_Id() == 0) + { + await this.ViewModel.ShowMessage("É NECESSÁRIO PESQUISAR O FORNECEDOR AO LADO PARA VINCULAR UM LANÇAMENTO A ESSA MOVIMENTAÇÃO.", "OK", "", false); + } + else + { + this.ViewModel.Loading(true); + await this.ViewModel.BuscarLancamentosVinculo(); + this.ViewModel.Loading(false); + await this.AbrirVinculo(); + } + } + + private void CancelarAlteracao_OnClick(object sender, RoutedEventArgs e) + { + this.AutoCompleteFornecedorInclusao.set_Text(string.Empty); + this.ViewModel.Alterando = System.Windows.Visibility.Collapsed; + this.ViewModel.BuscaHabilitada = true; + this.ViewModel.CancelarAlteracao(); + this.ViewModel.EnableIncluirNovo = false; + } + + private async void CancelarImportacao_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + this.ViewModel.Importando = false; + await this.ViewModel.Buscar(); + this.ViewModel.Loading(false); + } + + private void CheckBox_Checked(object sender, RoutedEventArgs e) + { + if (this._selecionando) + { + return; + } + this._selecionando = true; + ((CheckBox)sender).IsChecked = new bool?(false); + this.ViewModel.SelecionarTodos(); + this._selecionando = false; + } + + private void CheckBoxFiltros_Checked(object sender, RoutedEventArgs e) + { + string name = ((CheckBox)sender).Name; + if (name == "GridPlanos") + { + this.ViewModel.PlanosFiltro.ForEach((Planos x) => x.set_Selecionado(!x.get_Selecionado())); + this.ViewModel.PlanosFiltro = new List(this.ViewModel.PlanosFiltro); + return; + } + if (name == "GridCentro") + { + this.ViewModel.CentroFiltro.ForEach((Centro x) => x.set_Selecionado(!x.get_Selecionado())); + this.ViewModel.CentroFiltro = new List(this.ViewModel.CentroFiltro); + return; + } + if (name != "GridConta") + { + return; + } + this.ViewModel.ContaFiltro.ForEach((BancosContas x) => x.set_Selecionado(!x.get_Selecionado())); + this.ViewModel.ContaFiltro = new List(this.ViewModel.ContaFiltro); + } + + private async void DataGrid_OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e) + { + string sortMemberPath; + DateTime vencimento; + DateTime? nullable; + string str; + DateTime? nullable1; + DateTime? nullable2; + string shortDateString; + string text; + TextBox editingElement; + if (e.EditingElement is TextBox) + { + editingElement = e.EditingElement as TextBox; + bool flag = true; + string stringFormat = e.Column.ClipboardContentBinding.StringFormat; + if (stringFormat == "d") + { + if (editingElement != null) + { + TextBox textBox = editingElement; + if (string.IsNullOrEmpty(editingElement.Text)) + { + str = null; + } + else + { + str = ValidationHelper.FormatDate(editingElement.Text); + } + textBox.Text = str; + if (e.Column.SortMemberPath == "Vencimento" && string.IsNullOrWhiteSpace(editingElement.Text)) + { + TextBox shortDateString1 = editingElement; + vencimento = this.ViewModel.SelectedLancamento.get_Vencimento(); + shortDateString1.Text = vencimento.ToShortDateString(); + await this.ViewModel.ShowMessage("VENCIMENTO NÃO PODE SER EM BRANCO", "OK", "", false); + editingElement = null; + return; + } + else if (string.IsNullOrWhiteSpace(editingElement.Text) || ValidationHelper.ValidateDate(editingElement.Text)) + { + sortMemberPath = e.Column.SortMemberPath; + if (sortMemberPath != "Baixa") + { + if (sortMemberPath == "Pagamento") + { + if (this.OriginalValue != editingElement.Text) + { + if (!await this.ViewModel.ShowMessage("DESEJA REPLICAR PARA OS DEMAIS LANÇAMENTOS FILTRADOS?", "SIM", "NÃO", false)) + { + flag = false; + } + foreach (Lancamento lancamento in this.LancamentoGrid.Items.Cast()) + { + if (!(lancamento.get_Id() == ((Lancamento)this.LancamentoGrid.SelectedItem).get_Id() | flag)) + { + continue; + } + Lancamento lancamento1 = lancamento; + if (string.IsNullOrEmpty(editingElement.Text)) + { + nullable = null; + nullable2 = nullable; + } + else + { + nullable2 = new DateTime?(DateTime.Parse(editingElement.Text)); + } + lancamento1.set_Pagamento(nullable2); + } + this.LancamentoGrid.Items.Refresh(); + } + else + { + editingElement = null; + return; + } + } + } + else if (this.OriginalValue != editingElement.Text) + { + if (!await this.ViewModel.ShowMessage("DESEJA REPLICAR PARA OS DEMAIS LANÇAMENTOS FILTRADOS?", "SIM", "NÃO", false)) + { + flag = false; + } + foreach (Lancamento lancamento2 in this.LancamentoGrid.Items.Cast()) + { + if (!(lancamento2.get_Id() == ((Lancamento)this.LancamentoGrid.SelectedItem).get_Id() | flag)) + { + continue; + } + Lancamento lancamento3 = lancamento2; + if (string.IsNullOrEmpty(editingElement.Text)) + { + nullable = null; + nullable1 = nullable; + } + else + { + nullable1 = new DateTime?(DateTime.Parse(editingElement.Text)); + } + lancamento3.set_Baixa(nullable1); + } + this.LancamentoGrid.Items.Refresh(); + } + else + { + editingElement = null; + return; + } + } + else + { + TextBox textBox1 = editingElement; + if (e.Column.SortMemberPath == "Vencimento") + { + vencimento = this.ViewModel.SelectedLancamento.get_Vencimento(); + shortDateString = vencimento.ToShortDateString(); + } + else + { + shortDateString = null; + } + textBox1.Text = shortDateString; + await this.ViewModel.ShowMessage("DATA INVÁLIDA", "OK", "", false); + editingElement = null; + return; + } + } + else + { + editingElement = null; + return; + } + } + else if (stringFormat != "c") + { + TextBox textBox2 = editingElement; + if (textBox2 != null) + { + text = textBox2.Text; + } + else + { + text = null; + } + if (!string.IsNullOrEmpty(text)) + { + sortMemberPath = e.Column.SortMemberPath; + if (sortMemberPath != "Documento") + { + if (sortMemberPath != "Competencia") + { + if (sortMemberPath == "Complemento") + { + if (editingElement.Text.Length > 15) + { + editingElement.Text = ""; + await this.ViewModel.ShowMessage("LIMITE DE CARACTERES: 15", "OK", "", false); + } + else + { + editingElement = null; + return; + } + } + } + else if (editingElement.Text.Length > 7) + { + editingElement.Text = ""; + await this.ViewModel.ShowMessage("LIMITE DE CARACTERES: 7", "OK", "", false); + } + else + { + editingElement.Text = ValidationHelper.FormatCompetencia(editingElement.Text); + editingElement = null; + return; + } + } + else if (editingElement.Text.Length > 50) + { + editingElement.Text = string.Empty; + await this.ViewModel.ShowMessage("LIMITE DE CARACTERES: 50", "OK", "", false); + } + else if (this.OriginalValue != editingElement.Text) + { + if (!await this.ViewModel.ShowMessage("DESEJA REPLICAR PARA OS DEMAIS LANÇAMENTOS FILTRADOS?", "SIM", "NÃO", false)) + { + flag = false; + } + foreach (Lancamento lancamento4 in this.LancamentoGrid.Items.Cast()) + { + if (!(lancamento4.get_Id() == ((Lancamento)this.LancamentoGrid.SelectedItem).get_Id() | flag)) + { + continue; + } + lancamento4.set_Documento(editingElement.Text); + } + this.LancamentoGrid.Items.Refresh(); + editingElement = null; + return; + } + else + { + editingElement = null; + return; + } + } + } + else if (editingElement != null) + { + editingElement.Text = ValidationHelper.FormatCurrency(editingElement.Text); + } + } + editingElement = null; + } + + public new void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DatePicker datePicker = (DatePicker)sender; + datePicker.Text = ValidationHelper.FormatDate(datePicker.Text); + } + + private new void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key != Key.Return) + { + return; + } + DatePicker str = (DatePicker)sender; + DateTime date = Funcoes.GetNetworkTime().Date; + str.Text = date.ToString("dd/MM/yyyy"); + } + + private void EsconderFiltros_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.VisibleFiltros = System.Windows.Visibility.Collapsed; + this.ViewModel.VisibleOlho = System.Windows.Visibility.Visible; + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Excluir(); + this.ViewModel.Alterando = System.Windows.Visibility.Collapsed; + this.ViewModel.BuscaHabilitada = true; + this.ViewModel.CancelarAlteracao(); + } + + private async void ExcluirBaixa_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.ExcluirBaixa(); + } + + private async void ExcluirBaixaRange_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.ExcluirBaixaRange(); + } + + private void ExcluirFiltro_OnClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(chip); + Gestor.Model.Domain.Relatorios.FiltroPersonalizado item = (Gestor.Model.Domain.Relatorios.FiltroPersonalizado)listBox.Items[listBox.Items.IndexOf(chip.DataContext)]; + if (item == null) + { + return; + } + this.ViewModel.PersonalizadoSelecionado.Remove(item); + this.ViewModel.PesquisaPersonalizada(); + } + + private void ExcluirFiltro_onDeleteClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(chip); + Gestor.Model.Domain.Financeiro.FiltroPersonalizado item = (Gestor.Model.Domain.Financeiro.FiltroPersonalizado)listBox.Items[listBox.Items.IndexOf(chip.DataContext)]; + if (item == null) + { + return; + } + this.ViewModel.ExcluirFiltro(item); + } + + private async void ExcluirRange_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.ExcluirRange(); + } + + private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e) + { + List list = this.LancamentoGrid.Items.Cast().ToList(); + await this.ViewModel.GerarExcel(list); + } + + private void ExtratoConta_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button == null || button.DataContext == null) + { + return; + } + (new ExtratoWindow(((Saldo)button.DataContext).get_Conta().get_Id())).Show(); + } + + private void Fechar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IsExpanded = !this.ViewModel.IsExpanded; + } + + private void Filtrar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IsExpanded = !this.ViewModel.IsExpanded; + } + + private void FiltroDetalhes_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + if (autoCompleteBox == null || autoCompleteBox.get_SelectedItem() == null) + { + return; + } + if (!autoCompleteBox.get_IsDropDownOpen()) + { + return; + } + this.ViewModel.AdicionarFiltro((Gestor.Model.Domain.Financeiro.FiltroPersonalizado)autoCompleteBox.get_SelectedItem()); + autoCompleteBox.set_Text(string.Empty); + } + + private async Task ImportarOfx() + { + BancosContas bancosConta; + if (this.ViewModel.ContasFiltradas == null || this.ViewModel.ContasFiltradas.Count == 0) + { + await this.ViewModel.ShowMessage("NÃO HÁ CONTAS CADASTRADAS PARA REALIZAR A IMPORTAÇÃO.", "OK", "", false); + } + else + { + if (this.ViewModel.ContasFiltradas.Count <= 1) + { + bancosConta = this.ViewModel.ContasFiltradas.First(); + } + else + { + bancosConta = await this.ViewModel.ShowContas(this.ViewModel.ContasFiltradas.ToList()); + } + BancosContas bancosConta1 = bancosConta; + if (bancosConta1 != null) + { + this.ViewModel.Loading(true); + await this.ViewModel.ParseOfx(bancosConta1); + this.ViewModel.Loading(false); + } + } + } + + private async void ImportarOfx_Click(object sender, RoutedEventArgs e) + { + await this.ImportarOfx(); + } + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + List list = this.LancamentoGrid.Items.Cast().ToList(); + if (await this.ViewModel.ShowMessage("DESEJA CONTINUAR COM A IMPRESSÃO?", "SIM", "NÃO", false)) + { + bool flag = await this.ViewModel.ShowMessage("EM QUAL POSIÇÂO DESEJA IMPRIMIR?", "PAISAGEM (horizontal)", "RETRATO (vertical)", false); + await this.ViewModel.Print(list, flag); + } + list = null; + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirLancamento(); + this.ViewModel.IdLancamento = (long)0; + this.ValidarLancamento(); + } + + private void IncluirParcela_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirParcela(); + this.ValidarLancamento(); + } + + [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/financeiro/financeiroview.xaml", UriKind.Relative)); + } + + private void LancamentoGrid_OnPreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e) + { + if (e.Column.GetType().Name != "DataGridTextColumn") + { + this.LancamentoGrid.CancelEdit(); + this.LancamentoGrid.CancelEdit(); + } + TextBox editingElement = e.EditingElement as TextBox; + if (editingElement != null) + { + this.OriginalValue = editingElement.Text; + } + } + + private void LimparFiltros_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.LimparFiltros(); + this.ViewModel.FiltrarPersonalizado(); + } + + private void MostrarFiltros_Click(object sender, RoutedEventArgs e) + { + MenuItem menuItem = (MenuItem)sender; + this.GridFiltros.Visibility = (this.GridFiltros.Visibility == System.Windows.Visibility.Collapsed ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + menuItem.Header = (this.GridFiltros.Visibility == System.Windows.Visibility.Collapsed ? "MOSTRAR FILTROS" : "ESCONDER FILTROS"); + } + + private void MostrarFiltros_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.VisibleFiltros = System.Windows.Visibility.Visible; + this.ViewModel.VisibleOlho = System.Windows.Visibility.Collapsed; + } + + private void OnChecked_OnHandler(object sender, RoutedEventArgs e) + { + DataGridCell dataGridCell = (DataGridCell)sender; + if (this.LancamentoGrid.SelectedItem == null) + { + return; + } + Lancamento dataContext = dataGridCell.DataContext as Lancamento; + if (dataContext != null) + { + if (dataContext.get_Selecionado()) + { + return; + } + this.ViewModel.SelecionarLancamento(dataContext); + this.LancamentoGrid.CommitEdit(); + this.LancamentoGrid.CommitEdit(); + CollectionViewSource.GetDefaultView(this.LancamentoGrid.ItemsSource).Refresh(); + } + } + + private void Pendentes_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.SelectedStatusImportacao = 0; + this.ViewModel.FiltroImportacao(); + } + + private void Saldos_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + if (this.ViewModel.SelectedSaldo == null) + { + return; + } + string str = string.Concat("INFORMAÇÕES DO EXTRATO - ", this.ViewModel.SelectedSaldo.get_Conta().get_Descricao()); + Window window = Funcoes.IsHosterOpen(str); + if (window == null) + { + (new HosterWindow(new InfoExtratoView(this.ViewModel.SelectedSaldo, false), str, new double?((double)800), new double?((double)450), true)).Show(); + return; + } + window.WindowState = (window.WindowState == WindowState.Minimized ? WindowState.Maximized : window.WindowState); + window.Activate(); + } + + private async Task Salvar(bool fechar) + { + bool flag; + bool flag1; + DatePickerTextBox focusedElement = Keyboard.FocusedElement as DatePickerTextBox; + if (focusedElement != null) + { + ((DatePicker)focusedElement.TemplatedParent).SelectedDate = new DateTime?(ValidationHelper.ToDateTime(ValidationHelper.FormatDate(focusedElement.Text))); + DateTime? selectedDate = ((DatePicker)focusedElement.TemplatedParent).SelectedDate; + if (selectedDate.ToString() == "01/01/0001 00:00:00") + { + selectedDate = null; + ((DatePicker)focusedElement.TemplatedParent).SelectedDate = selectedDate; + } + } + flag = (!this.ViewModel.Importando ? false : this.ViewModel.Parcelas > 1); + bool flag2 = flag; + if (flag2) + { + flag2 = !await this.ViewModel.ShowMessage(string.Format("SERÁ CRIADO COM {0} PARCELAS, INICIADO POR ESSE LANÇAMENTO, DESEJA PROSSEGUIR?", this.ViewModel.Parcelas), "SIM", "NÃO", false); + } + if (!flag2) + { + this.ViewModel.Loading(true); + if (!this.ViewModel.Importando) + { + this.ViewModel.Bind(); + List> keyValuePairs = await this.ViewModel.Salvar(); + flag1 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag1) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (!fechar) + { + Fornecedor fornecedorInclusao = this.ViewModel.FornecedorInclusao; + string historico = this.ViewModel.Historico; + string documento = this.ViewModel.Documento; + string competencia = this.ViewModel.Competencia; + string complemento = this.ViewModel.Complemento; + Planos plano = this.ViewModel.Plano; + Centro centro = this.ViewModel.Centro; + BancosContas conta = this.ViewModel.Conta; + Sinal sinal = this.ViewModel.Sinal; + int parcelas = this.ViewModel.Parcelas; + int parcela = this.ViewModel.Parcela; + DateTime vencimento = this.ViewModel.Vencimento; + decimal valor = this.ViewModel.Valor; + DateTime? baixa = this.ViewModel.Baixa; + decimal? valorPago = this.ViewModel.ValorPago; + DateTime? pagamento = this.ViewModel.Pagamento; + TipoPagamento tipoPagamento = this.ViewModel.TipoPagamento; + string observacao = this.ViewModel.Observacao; + this.ViewModel.FornecedorInclusao = fornecedorInclusao; + this.ViewModel.Historico = historico; + this.ViewModel.Documento = documento; + this.ViewModel.Competencia = competencia; + this.ViewModel.Complemento = complemento; + this.ViewModel.Plano = plano; + this.ViewModel.Centro = centro; + this.ViewModel.Conta = conta; + this.ViewModel.Sinal = sinal; + this.ViewModel.Parcelas = parcelas; + this.ViewModel.Parcela = parcela; + this.ViewModel.Vencimento = vencimento; + this.ViewModel.Valor = valor; + this.ViewModel.Baixa = baixa; + this.ViewModel.ValorPago = valorPago; + this.ViewModel.Pagamento = pagamento; + this.ViewModel.TipoPagamento = tipoPagamento; + this.ViewModel.Observacao = observacao; + this.ViewModel.EnableIncluirNovo = true; + } + else + { + this.AutoCompleteFornecedorInclusao.set_Text(string.Empty); + this.ViewModel.Alterando = System.Windows.Visibility.Collapsed; + this.ViewModel.BuscaHabilitada = true; + await this.ViewModel.Buscar(); + } + } + else + { + this.ViewModel.BindImportando(); + List> keyValuePairs1 = this.ViewModel.SelectedLancamento.Validate(); + if (keyValuePairs1 == null) + { + keyValuePairs1 = new List>(); + } + List> keyValuePairs2 = keyValuePairs1; + if (keyValuePairs2.Count <= 0) + { + this.ViewModel.LancamentosFiltrados = this.ViewModel.Lancamentos; + this.AutoCompleteFornecedorInclusao.set_Text(string.Empty); + this.ViewModel.Alterando = System.Windows.Visibility.Collapsed; + this.ViewModel.BuscaHabilitada = true; + this.ViewModel.Loading(false); + } + else + { + this.ViewModel.Loading(false); + await this.ViewModel.ShowMessage(keyValuePairs2, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + } + } + + private async void SalvarImportacao_Click(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.ShowMessage(string.Concat("DESEJA PROSSEGUIR COM A IMPORTAÇÃO?", Environment.NewLine, Environment.NewLine, "SOMENTE OS LANÇAMENTOS VÁLIDOS SERÃO ALTERADOS OU INCLUÍDOS"), "SIM", "NÃO", false)) + { + this.ViewModel.Loading(true); + ObservableCollection lancamentos = this.ViewModel.Lancamentos; + List list = ( + from x in lancamentos + where x.Validate().Count == 0 + select x).ToList(); + if (await this.ViewModel.SalvarImportacao(list)) + { + this.ViewModel.Importando = false; + } + this.ViewModel.Loading(false); + } + } + + private async void SalvarInclusao_Click(object sender, RoutedEventArgs e) + { + await this.Salvar(false); + } + + private async void SalvarLancamento_OnClick(object sender, RoutedEventArgs e) + { + await this.Salvar(true); + } + + private async void SalvarRange_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Atualizar(this.LancamentoGrid.Items.Cast().ToList()); + this.LancamentoGrid.CommitEdit(); + this.LancamentoGrid.CommitEdit(); + CollectionViewSource.GetDefaultView(this.LancamentoGrid.ItemsSource).Refresh(); + } + + public void SaveSortLancamentos() + { + this._sortDirections = new List(); + this._sortDescriptions = new List(); + foreach (DataGridColumn column in this.LancamentoGrid.Columns) + { + this._sortDirections.Add(column.SortDirection); + } + foreach (SortDescription sortDescription in this.LancamentoGrid.Items.SortDescriptions) + { + this._sortDescriptions.Add(sortDescription); + } + } + + private void Sintetizar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Sintetizar(); + } + + public void SortLancamentos() + { + if (this._sortDirections == null || this._sortDirections.Count != this.LancamentoGrid.Columns.Count) + { + return; + } + foreach (DataGridColumn column in this.LancamentoGrid.Columns) + { + column.SortDirection = this._sortDirections[this.LancamentoGrid.Columns.IndexOf(column)]; + } + this.LancamentoGrid.Items.SortDescriptions.Clear(); + foreach (SortDescription _sortDescription in this._sortDescriptions) + { + this.LancamentoGrid.Items.SortDescriptions.Add(_sortDescription); + } + } + + [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.TipoFiltrosBox_OnSelectionChanged); + return; + } + case 2: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 3: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 4: + { + this.AutoCompleteFornecedor = (AutoCompleteBox)target; + this.AutoCompleteFornecedor.add_Populating(new PopulatingEventHandler(this, FinanceiroView.AutoCompleteFornecedor_OnPopulating)); + return; + } + case 5: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, FinanceiroView.AutoCompleteBoxDetalhe_Populating)); + ((AutoCompleteBox)target).add_SelectionChanged(new SelectionChangedEventHandler(this.FiltroDetalhes_OnSelectionChanged)); + return; + } + case 6: + { + ((Button)target).Click += new RoutedEventHandler(this.MostrarFiltros_OnClick); + return; + } + case 7: + { + this.MenuFiltros = (MenuItem)target; + this.MenuFiltros.Click += new RoutedEventHandler(this.MostrarFiltros_Click); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Pendentes_Click); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Baixados_Click); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Todos_Click); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.SalvarImportacao_Click); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CancelarImportacao_Click); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Buscar_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExportarExcel_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Sintetizar_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.TrocarFornecedor_OnClick); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.SalvarRange_OnClick); + return; + } + case 19: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 20: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirParcela_OnClick); + return; + } + case 21: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirBaixaRange_OnClick); + return; + } + case 22: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirRange_OnClick); + return; + } + case 23: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Transferir_OnClick); + return; + } + case 24: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 25: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 26: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ImportarOfx_Click); + return; + } + case 27: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Filtrar_OnClick); + return; + } + case 28: + { + this.GridFiltros = (Grid)target; + return; + } + case 29: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 30: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 31: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltro_OnClick); + return; + } + case 32: + case 33: + case 37: + case 38: + case 39: + case 40: + case 41: + case 44: + case 45: + case 46: + case 60: + { + this._contentLoaded = true; + return; + } + case 34: + { + ((Button)target).Click += new RoutedEventHandler(this.LimparFiltros_OnClick); + return; + } + case 35: + { + ((Button)target).Click += new RoutedEventHandler(this.EsconderFiltros_OnClick); + return; + } + case 36: + { + this.LancamentoGrid = (DataGrid)target; + this.LancamentoGrid.CellEditEnding += new EventHandler(this.DataGrid_OnCellEditEnding); + this.LancamentoGrid.PreparingCellForEdit += new EventHandler(this.LancamentoGrid_OnPreparingCellForEdit); + return; + } + case 42: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltros_OnClick); + return; + } + case 43: + { + ((Button)target).Click += new RoutedEventHandler(this.Fechar_OnClick); + return; + } + case 47: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 48: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.SalvarInclusao_Click); + return; + } + case 49: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.SalvarLancamento_OnClick); + return; + } + case 50: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CancelarAlteracao_OnClick); + return; + } + case 51: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirBaixa_OnClick); + return; + } + case 52: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 53: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ArquivoDigital_OnClick); + return; + } + case 54: + { + this.AutoCompleteFornecedorInclusao = (AutoCompleteBox)target; + this.AutoCompleteFornecedorInclusao.add_Populating(new PopulatingEventHandler(this, FinanceiroView.AutoCompleteFornecedorAtivo_OnPopulating)); + return; + } + case 55: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.BuscarLancamentos_Click); + return; + } + case 56: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 57: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 58: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 59: + { + ((DataGrid)target).MouseDoubleClick += new MouseButtonEventHandler(this.Saldos_OnMouseDoubleClick); + return; + } + case 61: + { + ((DataGrid)target).CellEditEnding += new EventHandler(this.DataGrid_OnCellEditEnding); + 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 32: + { + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_OnClick)); + return; + } + case 33: + { + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_onDeleteClick)); + return; + } + case 34: + case 35: + case 36: + case 42: + case 43: + { + return; + } + case 37: + { + ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBox_Checked); + ((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBox_Checked); + return; + } + case 38: + { + EventSetter eventSetter = new EventSetter() + { + Event = ToggleButton.CheckedEvent, + Handler = new RoutedEventHandler(this.OnChecked_OnHandler) + }; + ((System.Windows.Style)target).Setters.Add(eventSetter); + eventSetter = new EventSetter() + { + Event = ToggleButton.UncheckedEvent, + Handler = new RoutedEventHandler(this.Unchecked_OnHandler) + }; + ((System.Windows.Style)target).Setters.Add(eventSetter); + return; + } + case 39: + { + ((Button)target).Click += new RoutedEventHandler(this.ArquivoDigital_OnClick); + return; + } + case 40: + { + ((Button)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 41: + { + ((ComboBox)target).DropDownOpened += new EventHandler(this.TipoPagamento_DropDownOpened); + ((ComboBox)target).DropDownClosed += new EventHandler(this.TipoPagamento_OnDropDownClosed); + return; + } + case 44: + { + ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBoxFiltros_Checked); + ((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBoxFiltros_Checked); + return; + } + case 45: + { + ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBoxFiltros_Checked); + ((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBoxFiltros_Checked); + return; + } + case 46: + { + ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBoxFiltros_Checked); + ((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBoxFiltros_Checked); + return; + } + default: + { + if (connectionId != 60) + { + return; + } + ((Button)target).Click += new RoutedEventHandler(this.ExtratoConta_OnClick); + return; + } + } + } + + private void TipoFiltrosBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox == null || comboBox.SelectedItem == null) + { + return; + } + this.ViewModel.IsvisibleStatus = System.Windows.Visibility.Visible; + this.ViewModel.IsVisibleData = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleFornecedor = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisiblePersonalizado = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleFiltros = System.Windows.Visibility.Visible; + this.ViewModel.LimparFiltros(); + this.ViewModel.SelectedFornecedor = null; + if (this.AutoCompleteFornecedor != null) + { + this.AutoCompleteFornecedor.set_Text(string.Empty); + } + this.ViewModel.DropDownHeight = 0; + switch ((FiltroLancamento)comboBox.SelectedItem) + { + case 1: + case 2: + { + this.ViewModel.IsvisibleStatus = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleData = System.Windows.Visibility.Visible; + return; + } + case 3: + { + this.ViewModel.IsVisibleFornecedor = System.Windows.Visibility.Visible; + return; + } + case 5: + { + this.ViewModel.IsVisiblePersonalizado = System.Windows.Visibility.Visible; + this.ViewModel.IsVisibleFiltros = System.Windows.Visibility.Collapsed; + this.GridFiltros.Visibility = System.Windows.Visibility.Collapsed; + this.MenuFiltros.Header = "MOSTRAR FILTROS"; + this.ViewModel.IsVisibleData = System.Windows.Visibility.Visible; + this.ViewModel.DropDownHeight = 200; + return; + } + default: + { + this.ViewModel.IsVisibleData = System.Windows.Visibility.Visible; + return; + } + } + } + + private void TipoPagamento_DropDownOpened(object sender, EventArgs e) + { + if (((ComboBox)sender).SelectedItem == null) + { + this.tipoPagamento = null; + return; + } + this.tipoPagamento = new TipoPagamento?((TipoPagamento)((ComboBox)sender).SelectedItem); + } + + private async void TipoPagamento_OnDropDownClosed(object sender, EventArgs e) + { + TipoPagamento? nullable = this.tipoPagamento; + TipoPagamento selectedItem = (TipoPagamento)((ComboBox)sender).SelectedItem; + if (nullable.GetValueOrDefault() == selectedItem & nullable.HasValue) + { + nullable = null; + this.tipoPagamento = nullable; + } + else if (await this.ViewModel.ShowMessage("DESEJA REPLICAR PARA OS DEMAIS LANÇAMENTOS FILTRADOS?", "SIM", "NÃO", false)) + { + nullable = null; + this.tipoPagamento = nullable; + foreach (Lancamento lancamento in this.LancamentoGrid.Items.Cast()) + { + lancamento.set_TipoPagamento((TipoPagamento)((ComboBox)sender).SelectedItem); + } + this.LancamentoGrid.CommitEdit(); + this.LancamentoGrid.CommitEdit(); + this.LancamentoGrid.Items.Refresh(); + } + } + + private void Todos_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.SelectedStatusImportacao = 2; + this.ViewModel.FiltroImportacao(); + } + + private async void Transferir_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + Transferencia transferencium = new Transferencia(); + transferencium.set_Data(Funcoes.GetNetworkTime().Date); + Transferencia transferencium1 = transferencium; + while (true) + { + transferencium1 = await this.ViewModel.ShowTransferencia(transferencium1); + if (transferencium1 == null) + { + transferencium1 = null; + return; + } + List> keyValuePairs = await this.ViewModel.Salvar(transferencium1); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (flag) + { + break; + } + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + this.ViewModel.ToggleSnackBar("TRANSFERÊNCIA SALVA COM SUCESSO.", true); + this.ViewModel.Alterar(false); + transferencium1 = null; + return; + transferencium1 = null; + } + + private void TrocarFornecedor_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + this.AbrirLancamento(this.ViewModel.SelectedLancamento); + this.ViewModel.VisibilityFornecedor = System.Windows.Visibility.Visible; + this.ViewModel.Loading(false); + } + + private void Unchecked_OnHandler(object sender, RoutedEventArgs e) + { + DataGridCell dataGridCell = (DataGridCell)sender; + if (this.LancamentoGrid.SelectedItem == null) + { + return; + } + Lancamento dataContext = dataGridCell.DataContext as Lancamento; + if (dataContext != null) + { + if (!dataContext.get_Selecionado()) + { + return; + } + this.ViewModel.DeSelecionarLancamento(dataContext); + this.LancamentoGrid.CommitEdit(); + this.LancamentoGrid.CommitEdit(); + CollectionViewSource.GetDefaultView(this.LancamentoGrid.ItemsSource).Refresh(); + } + } + + private void ValidarLancamento() + { + if (this.ViewModel.SelectedLancamento == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedLancamento.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Financeiro/FornecedorView.cs b/Codemerx/Gestor.Application/Views/Financeiro/FornecedorView.cs new file mode 100644 index 0000000..6825a38 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Financeiro/FornecedorView.cs @@ -0,0 +1,419 @@ +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels.Financeiro; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Financeiro; +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.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; + +namespace Gestor.Application.Views.Financeiro +{ + public class FornecedorView : BaseUserControl, IComponentConnector + { + internal DataGrid FornecedorGrid; + + internal TextBox NomeBox; + + internal TextBox DocumentoPrincipalBox; + + internal ToggleButton AtivoBox; + + internal TextBox CepBox; + + internal ProgressBar ProgressCep; + + internal TextBox EnderecoBox; + + internal TextBox BairroBox; + + internal TextBox CidadeBox; + + internal TextBox EstadoBox; + + internal ComboBox PlanoBox; + + internal ComboBox CentroBox; + + internal ComboBox ContaBox; + + internal ComboBox TipoPagamentoBox; + + private bool _contentLoaded; + + public FornecedorViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public FornecedorView() + { + base.Tag = "CADASTRO DE FORNECEDORES"; + this.ViewModel = new FornecedorViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 10).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedFornecedor.get_Id()); + filtroArquivoDigital.set_Tipo(10); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedFornecedor); + 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)10), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(24, this.ViewModel.SelectedFornecedor.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(24, this.ViewModel.SelectedFornecedor.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + this.ViewModel.SelectedFornecedor.Initialize(); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarFornecedor(""); + } + + private void AutoCompleteFornecedor_OnPopulating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelProduto = (Fornecedor)this.ViewModel.SelectedFornecedor.Clone(); + this.ViewModel.CancelarAlteracao(); + this.ScrollToItem(); + } + + private async void CopiarDados_OnClick(object sender, RoutedEventArgs e) + { + Cliente cliente = await this.ViewModel.ShowCopiarCliente(); + if (cliente != null) + { + this.ViewModel.Incluir(); + Cliente cliente1 = cliente; + ObservableCollection observableCollection = await (new ClienteServico()).BuscarEnderecosAsync(cliente.get_Id()); + cliente1.set_Enderecos(observableCollection); + cliente1 = null; + cliente1 = cliente; + ObservableCollection observableCollection1 = await (new ClienteServico()).BuscarTelefonesAsync(cliente.get_Id()); + cliente1.set_Telefones(observableCollection1); + cliente1 = null; + cliente1 = cliente; + ObservableCollection observableCollection2 = await (new ClienteServico()).BuscarEmailsAsync(cliente.get_Id()); + cliente1.set_Emails(observableCollection2); + cliente1 = null; + this.ViewModel.Copiar(cliente); + } + cliente = null; + } + + private void DocumentoPrincipalBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + } + + private void Excel_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excel(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Delete(); + this.ScrollToItem(); + } + + private void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Imprimir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + } + + [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/financeiro/fornecedorview.xaml", UriKind.Relative)); + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + if (!string.IsNullOrWhiteSpace(textBox.Text)) + { + string str = ValidationHelper.FormatPostCode(textBox.Text); + if (ValidationHelper.ValidatePostCode(str)) + { + this.CepBox.Text = str; + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + this.EnderecoBox.Text = enderecoBase.get_Endereco(); + this.CidadeBox.Text = enderecoBase.get_Cidade(); + this.EstadoBox.Text = enderecoBase.get_Estado(); + this.BairroBox.Text = enderecoBase.get_Bairro(); + } + } + } + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.ScrollToItem(); + } + } + + private void ScrollToItem() + { + if (this.FornecedorGrid.SelectedItem == null) + { + return; + } + this.FornecedorGrid.UpdateLayout(); + this.FornecedorGrid.ScrollIntoView(this.FornecedorGrid.SelectedItem); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, FornecedorView.AutoCompleteFornecedor_OnPopulating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excel_OnClick); + return; + } + case 4: + { + this.FornecedorGrid = (DataGrid)target; + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CopiarDados_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 14: + { + this.NomeBox = (TextBox)target; + return; + } + case 15: + { + this.DocumentoPrincipalBox = (TextBox)target; + FornecedorView fornecedorView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(fornecedorView.SomenteNumeros); + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_OnLostFocus); + return; + } + case 16: + { + this.AtivoBox = (ToggleButton)target; + return; + } + case 17: + { + this.CepBox = (TextBox)target; + this.CepBox.LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + FornecedorView fornecedorView1 = this; + this.CepBox.PreviewTextInput += new TextCompositionEventHandler(fornecedorView1.SomenteNumeros); + return; + } + case 18: + { + this.ProgressCep = (ProgressBar)target; + return; + } + case 19: + { + this.EnderecoBox = (TextBox)target; + return; + } + case 20: + { + this.BairroBox = (TextBox)target; + return; + } + case 21: + { + this.CidadeBox = (TextBox)target; + return; + } + case 22: + { + this.EstadoBox = (TextBox)target; + return; + } + case 23: + { + FornecedorView fornecedorView2 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(fornecedorView2.FormatarTelefone); + return; + } + case 24: + { + FornecedorView fornecedorView3 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(fornecedorView3.FormatarTelefone); + return; + } + case 25: + { + this.PlanoBox = (ComboBox)target; + return; + } + case 26: + { + this.CentroBox = (ComboBox)target; + return; + } + case 27: + { + this.ContaBox = (ComboBox)target; + return; + } + case 28: + { + this.TipoPagamentoBox = (ComboBox)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Financeiro/InfoExtratoView.cs b/Codemerx/Gestor.Application/Views/Financeiro/InfoExtratoView.cs new file mode 100644 index 0000000..a666da9 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Financeiro/InfoExtratoView.cs @@ -0,0 +1,127 @@ +using Gestor.Application.ViewModels.Financeiro; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Model.Domain.Financeiro; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Reflection; +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; +using System.Windows.Shapes; + +namespace Gestor.Application.Views.Financeiro +{ + public class InfoExtratoView : BaseUserControl, IComponentConnector + { + private bool _buttonClickable; + + private bool _contentLoaded; + + public InfoExtratoViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public InfoExtratoView(Saldo saldo, bool telaBancos = false) + { + this.ViewModel = new InfoExtratoViewModel(telaBancos); + base.DataContext = this.ViewModel; + this.ViewModel.SelectedSaldo = saldo; + this.InitializeComponent(); + } + + [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/financeiro/infoextratoview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [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; + } + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + } + + private static void TopControls_OnMouseEnter(object sender, MouseEventArgs e) + { + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray)); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeave(object sender, MouseEventArgs e) + { + this._buttonClickable = false; + ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + this._buttonClickable = true; + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.DimGray)); + } + + private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + if (this._buttonClickable) + { + MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click")); + if (method == null) + { + return; + } + method.Invoke(this, null); + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Financeiro/PlanoView.cs b/Codemerx/Gestor.Application/Views/Financeiro/PlanoView.cs new file mode 100644 index 0000000..5d4bff5 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Financeiro/PlanoView.cs @@ -0,0 +1,117 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Financeiro; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Markup; + +namespace Gestor.Application.Views.Financeiro +{ + public class PlanoView : BaseUserControl, IComponentConnector + { + private bool _contentLoaded; + + public PlanoViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public PlanoView(Plano plano) + { + this.ViewModel = new PlanoViewModel(plano); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Cancel = (Plano)this.ViewModel.SelectedPlano.Clone(); + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Cancelar(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + } + + [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/financeiro/planoview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Financeiro/PlanosView.cs b/Codemerx/Gestor.Application/Views/Financeiro/PlanosView.cs new file mode 100644 index 0000000..e9b9fef --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Financeiro/PlanosView.cs @@ -0,0 +1,262 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Financeiro; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +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.Financeiro +{ + public class PlanosView : BaseUserControl, IComponentConnector + { + private bool _seleciona = true; + + public PlanosViewModel ViewModel; + + internal DataGrid PlanosGrid; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public PlanosView() + { + base.Tag = "PLANO DE CONTAS"; + this.ViewModel = new PlanosViewModel(); + 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(28, this.ViewModel.SelectedPlanos.get_Id()); + } + + private void AlterarPlanos_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + this.ViewModel.SelectedPlanos.Initialize(); + } + + private void AutoCompleteBoxPlanos_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarPlanos(""); + } + + private void AutoCompleteBoxPlanos_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task> searchResult) => { + if (searchResult == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void CancelarPlanos_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private async void ContentLoad() + { + this.PlanosGrid.SelectedIndex = 0; + this.PlanosGrid.SelectionChanged += new SelectionChangedEventHandler(this.PlanosGrid_OnSelectionChanged); + this.PlanosGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + PlanosViewModel viewModel = this.ViewModel; + List planos = await (new BaseServico()).BuscarPlanoAsync(); + PlanosViewModel observableCollection = viewModel; + List planos1 = planos; + IOrderedEnumerable ativo = + from x in planos1 + orderby x.get_Ativo() descending + select x; + observableCollection.Plano = new ObservableCollection(ativo.ThenBy((Plano x) => x.get_Descricao()).ToList()); + viewModel = null; + } + + private void IncluirPlanos_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + } + + [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/financeiro/planosview.xaml", UriKind.Relative)); + } + + private async void PlanoButton_OnClick(object sender, RoutedEventArgs e) + { + PlanoView planoView = new PlanoView(this.ViewModel.SelectedPlanos.get_Plano()); + (new HosterWindow(planoView, "PLANO", new double?((double)500), new double?((double)200), false)).ShowDialog(); + this.ViewModel.Loading(true); + if (planoView.ViewModel.SelectedPlano.get_Id() != 0) + { + PlanosViewModel viewModel = this.ViewModel; + List planos = await (new BaseServico()).BuscarPlanoAsync(); + PlanosViewModel observableCollection = viewModel; + List planos1 = planos; + IOrderedEnumerable ativo = + from x in planos1 + orderby x.get_Ativo() descending + select x; + observableCollection.Plano = new ObservableCollection(ativo.ThenBy((Plano x) => x.get_Descricao()).ToList()); + viewModel = null; + List planos2 = await (new BaseServico()).BuscarPlanosAsync(); + PlanosViewModel list = this.ViewModel; + List planos3 = planos2; + IOrderedEnumerable ativo1 = + from x in planos3 + orderby x.get_Ativo() descending + select x; + IOrderedEnumerable planos4 = ativo1.ThenBy((Planos x) => { + Plano plano = x.get_Plano(); + if (plano != null) + { + return plano.get_Descricao(); + } + return null; + }); + list.Planos = planos4.ThenBy((Planos x) => x.get_Descricao()).ToList(); + ObservableCollection planosFiltrados = this.ViewModel.PlanosFiltrados; + List nums = ( + from p in planosFiltrados + select p.get_Id()).ToList(); + this.ViewModel.PlanosFiltrados = new ObservableCollection( + from x in this.ViewModel.Planos + where nums.Contains(x.get_Id()) + select x); + this._seleciona = false; + this.PlanosGrid.SelectedItem = this.ViewModel.SelectedPlanos; + this.ViewModel.SelectedPlano = this.ViewModel.Plano.First((Plano x) => x.get_Id() == planoView.ViewModel.SelectedPlano.get_Id()); + this._seleciona = true; + } + this.ViewModel.Loading(false); + } + + private async void PlanosGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + object obj; + if (this._seleciona) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + PlanosViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaPlanos((Planos)obj); + } + } + } + + private async void SalvarPlanos_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, PlanosView.AutoCompleteBoxPlanos_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBoxPlanos_OnTextChanged)); + return; + } + case 2: + { + this.PlanosGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirPlanos_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AlterarPlanos_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.SalvarPlanos_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CancelarPlanos_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 8: + { + ((Button)target).Click += new RoutedEventHandler(this.PlanoButton_OnClick); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Financeiro/Relatorios/FechamentoFinanceiroView.cs b/Codemerx/Gestor.Application/Views/Financeiro/Relatorios/FechamentoFinanceiroView.cs new file mode 100644 index 0000000..3c04339 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Financeiro/Relatorios/FechamentoFinanceiroView.cs @@ -0,0 +1,285 @@ +using Gestor.Application.Componentes; +using Gestor.Application.ViewModels.Financeiro.Relatorios; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Financeiro.Relatorios; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +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; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Financeiro.Relatorios +{ + public class FechamentoFinanceiroView : BaseUserControl, IComponentConnector, IStyleConnector + { + public FechamentoFinanceiroViewModel ViewModel; + + internal ProgressBar ProgressRing; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal Gestor.Application.Componentes.WebEditor WebEditor; + + internal TextBlock NaoHaDados; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public FechamentoFinanceiroView() + { + this.ViewModel = new FechamentoFinanceiroViewModel(); + 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 CheckBox_Checked(object sender, RoutedEventArgs e) + { + string name = ((CheckBox)sender).Name; + if (name == "GridPlanos") + { + this.ViewModel.Planos.ForEach((Planos x) => x.set_Selecionado(!x.get_Selecionado())); + this.ViewModel.Planos = new List(this.ViewModel.Planos); + return; + } + if (name == "GridCentro") + { + this.ViewModel.Centro.ForEach((Centro x) => x.set_Selecionado(!x.get_Selecionado())); + this.ViewModel.Centro = new List(this.ViewModel.Centro); + return; + } + if (name != "GridConta") + { + this.ViewModel.Plano.ForEach((Plano x) => x.set_Selecionado(!x.get_Selecionado())); + this.ViewModel.Plano = new List(this.ViewModel.Plano); + return; + } + this.ViewModel.Conta.ForEach((BancosContas x) => x.set_Selecionado(!x.get_Selecionado())); + this.ViewModel.Conta = new List(this.ViewModel.Conta); + } + + private void ContentLoad() + { + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.SelectedDateChanged += new EventHandler(this.Periodo_OnSelectedDateChanged); + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.FimBox.SelectedDateChanged += new EventHandler(this.Periodo_OnSelectedDateChanged); + } + + private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e) + { + this.ProgressRing.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.IsEnabled = false; + await this.ViewModel.GerarExcel(); + this.ProgressRing.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsEnabled = true; + } + + private void Fechar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IsExpanded = !this.ViewModel.IsExpanded; + } + + private void Filtros_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IsExpanded = !this.ViewModel.IsExpanded; + } + + private async void GerarResultados_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.InicioBox.Text = ValidationHelper.FormatDate(this.InicioBox.Text); + this.FimBox.Text = ValidationHelper.FormatDate(this.FimBox.Text); + try + { + this.ViewModel.Inicio = new DateTime?(Convert.ToDateTime(this.InicioBox.Text)); + this.ViewModel.Fim = new DateTime?(Convert.ToDateTime(this.FimBox.Text)); + } + catch (Exception exception) + { + return; + } + DateTime? inicio = this.ViewModel.Inicio; + DateTime? fim = this.ViewModel.Fim; + flag = (inicio.HasValue & fim.HasValue ? inicio.GetValueOrDefault() > fim.GetValueOrDefault() : false); + if (!flag) + { + this.ProgressRing.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.IsEnabled = false; + this.ViewModel.HtmlContent = string.Empty; + this.ViewModel.Fechamento = new List(); + await this.ViewModel.GerarRelatorio(); + if (this.ViewModel.HtmlContent == string.Empty) + { + this.NaoHaDados.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.IsEnabled = true; + this.ProgressRing.Visibility = System.Windows.Visibility.Collapsed; + } + this.WebEditor.Initialize(this.ViewModel.HtmlContent); + this.NaoHaDados.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsEnabled = true; + this.ProgressRing.Visibility = System.Windows.Visibility.Collapsed; + } + else + { + await this.ViewModel.ShowMessage("A DATA FINAL NÃO PODE SER MENOR QUE A DATA INICIAL DO FILTRO.", "OK", "", false); + } + } + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + this.ProgressRing.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.IsEnabled = false; + await this.ViewModel.Print(); + this.ProgressRing.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsEnabled = true; + } + + [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/financeiro/relatorios/fechamentofinanceiroview.xaml", UriKind.Relative)); + } + + private void Periodo_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + this.ViewModel.Fechamento = new List(); + this.ViewModel.HtmlContent = string.Empty; + this.WebEditor.Initialize(""); + } + + [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: + { + 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: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.GerarResultados_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Filtros_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExportarExcel_OnClick); + return; + } + case 8: + { + this.WebEditor = (Gestor.Application.Componentes.WebEditor)target; + return; + } + case 9: + { + this.NaoHaDados = (TextBlock)target; + return; + } + case 10: + { + ((Button)target).Click += new RoutedEventHandler(this.Fechar_OnClick); + 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 11: + { + ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBox_Checked); + ((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBox_Checked); + return; + } + case 12: + { + ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBox_Checked); + ((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBox_Checked); + return; + } + case 13: + { + ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBox_Checked); + ((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBox_Checked); + return; + } + case 14: + { + ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBox_Checked); + ((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBox_Checked); + return; + } + default: + { + return; + } + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Generic/BaseUserControl.cs b/Codemerx/Gestor.Application/Views/Generic/BaseUserControl.cs new file mode 100644 index 0000000..a389f17 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Generic/BaseUserControl.cs @@ -0,0 +1,104 @@ +using Gestor.Application.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using System; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; + +namespace Gestor.Application.Views.Generic +{ + public class BaseUserControl : UserControl + { + public virtual TipoTela Tela + { + get; + set; + } + + public BaseUserControl() + { + } + + public void DataAtual_OnDoubleClick(object sender, RoutedEventArgs e) + { + ((DatePicker)sender).SelectedDate = new DateTime?(Funcoes.GetNetworkTime().Date); + } + + public void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DatePicker today = (DatePicker)sender; + today.Text = ValidationHelper.FormatDate(today.Text); + if (string.IsNullOrEmpty(today.Text)) + { + today.DisplayDate = DateTime.Today; + } + } + + public void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key != Key.Return) + { + return; + } + DatePicker str = (DatePicker)sender; + DateTime date = Funcoes.GetNetworkTime().Date; + str.Text = date.ToString("dd/MM/yyyy"); + } + + public virtual void FormatarDocumento(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + } + + public virtual void FormatarTelefone(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + if (string.IsNullOrWhiteSpace(textBox.Text)) + { + return; + } + textBox.Text = ValidationHelper.FormatarTelefone(textBox.Text); + } + + public virtual void LetrasHabilitacao(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("[^a-eA-E]+"); + e.Handled = regex.IsMatch(e.Text); + } + + public virtual void Placa(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("[^a-zA-Z0-9]+"); + e.Handled = regex.IsMatch(e.Text); + } + + public void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) + { + ScrollViewer scrollViewer = (ScrollViewer)sender; + scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset - (double)e.Delta); + e.Handled = true; + } + + public void SomenteCaracteres(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("[^a-zA-Z]+$"); + e.Handled = regex.IsMatch(e.Text); + } + + public void SomenteData(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("[^0-9/-]+"); + e.Handled = regex.IsMatch(e.Text); + } + + public virtual void SomenteNumeros(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("[^0-9]+"); + e.Handled = regex.IsMatch(e.Text); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Generic/DragOverPopup.cs b/Codemerx/Gestor.Application/Views/Generic/DragOverPopup.cs new file mode 100644 index 0000000..234ab52 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Generic/DragOverPopup.cs @@ -0,0 +1,57 @@ +using Gestor.Model.Domain.Ferramentas; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Markup; + +namespace Gestor.Application.Views.Generic +{ + public class DragOverPopup : UserControl, IComponentConnector + { + internal TextBlock Titulo; + + internal TextBlock Descricao; + + private bool _contentLoaded; + + public DragOverPopup(Tarefa tarefa) + { + this.InitializeComponent(); + this.Titulo.Text = tarefa.get_Titulo(); + this.Descricao.Text = tarefa.get_Descricao(); + } + + [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/generic/dragoverpopup.xaml", UriKind.Relative)); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + if (connectionId == 1) + { + this.Titulo = (TextBlock)target; + return; + } + if (connectionId != 2) + { + this._contentLoaded = true; + return; + } + this.Descricao = (TextBlock)target; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Generic/ErrorWindow.cs b/Codemerx/Gestor.Application/Views/Generic/ErrorWindow.cs new file mode 100644 index 0000000..e1b7df0 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Generic/ErrorWindow.cs @@ -0,0 +1,101 @@ +using Gestor.Application.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.API; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Reflection; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Markup; + +namespace Gestor.Application.Views.Generic +{ + public class ErrorWindow : Window, IComponentConnector + { + internal TextBlock DescricaoErro; + + internal RepeatButton ContinuarButton; + + private bool _contentLoaded; + + public ErrorWindow(TipoErro tipo, bool fecharSistema = false) + { + this.InitializeComponent(); + this.HanddleErro(tipo); + if (fecharSistema) + { + this.ContinuarButton.Visibility = System.Windows.Visibility.Collapsed; + } + } + + private void ContinuarButton_OnClick(object sender, RoutedEventArgs e) + { + base.Close(); + } + + private void HanddleErro(TipoErro tipo) + { + this.DescricaoErro.Text = ValidationHelper.GetCategory(tipo); + if (tipo != 3) + { + this.ContinuarButton.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContinuarButton.Visibility = System.Windows.Visibility.Collapsed; + } + + [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/generic/errorwindow.xaml", UriKind.Relative)); + } + + private void Reiniciar_OnClick(object sender, RoutedEventArgs e) + { + this.Shutdown(); + } + + private void Shutdown() + { + Instancia.ExcluirCfg(); + Process.Start(System.Windows.Application.ResourceAssembly.Location, (ApplicationHelper.Conectado ? "INICIAR CONECTADO" : "INICIAR")); + System.Windows.Application.Current.Shutdown(); + } + + [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.DescricaoErro = (TextBlock)target; + return; + } + case 2: + { + this.ContinuarButton = (RepeatButton)target; + this.ContinuarButton.Click += new RoutedEventHandler(this.ContinuarButton_OnClick); + return; + } + case 3: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.Reiniciar_OnClick); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Generic/HosterWindow.cs b/Codemerx/Gestor.Application/Views/Generic/HosterWindow.cs new file mode 100644 index 0000000..01fa146 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Generic/HosterWindow.cs @@ -0,0 +1,460 @@ +using Gestor.Application.Actions; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Interop; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Shapes; +using System.Windows.Shell; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Generic +{ + public class HosterWindow : Window, IComponentConnector + { + private bool _buttonClickable; + + internal System.Windows.Shell.WindowChrome WindowChrome; + + internal Grid Menu; + + internal Grid MinimizeButton; + + internal Path MinimizeButtonPath; + + internal Grid MaximizeButton; + + internal Path MaximizeButtonPath; + + internal Grid CloseButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal DialogHost HosterDialog; + + internal MaterialDesignThemes.Wpf.DrawerHost DrawerHost; + + internal MaterialDesignThemes.Wpf.Snackbar Snackbar; + + private bool _contentLoaded; + + public string Tela + { + get; + set; + } + + public HosterWindow(System.Windows.Controls.ContentControl control, string titulo, double? x = null, double? y = null, bool canMaximize = false) + { + this.InitializeComponent(); + Gestor.Application.Actions.Actions.EnableMainMenu = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.EnableMainMenu, new Action(this.HabilitarMenu)); + Gestor.Application.Actions.Actions.CloseHoster = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.CloseHoster, new Action(this.Close)); + this.MinimizeButton.MouseEnter += new System.Windows.Input.MouseEventHandler(HosterWindow.TopControls_OnMouseEnter); + this.MinimizeButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave); + this.MaximizeButton.MouseEnter += new System.Windows.Input.MouseEventHandler(HosterWindow.TopControls_OnMouseEnter); + this.MaximizeButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave); + this.CloseButton.MouseEnter += new System.Windows.Input.MouseEventHandler(HosterWindow.TopControls_OnMouseEnter); + this.CloseButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave); + this.ContentControl.Content = control.Content; + this.ContentControl.DataContext = control.DataContext; + this.ContentControl.Tag = titulo; + this.MaximizeButtonPath.Data = Geometry.Parse((string)System.Windows.Application.Current.Resources["Restore"]); + if ((x.HasValue || y.HasValue) && !canMaximize) + { + base.WindowState = System.Windows.WindowState.Normal; + base.BorderThickness = new Thickness(1); + this.WindowChrome.ResizeBorderThickness = new Thickness(4); + this.WindowChrome.CaptionHeight = 30; + this.MaximizeButtonPath.Data = Geometry.Parse((string)System.Windows.Application.Current.Resources["Maximize"]); + } + if (x.HasValue) + { + if (x.Value >= base.Width) + { + if (!canMaximize) + { + base.MaxWidth = x.Value; + base.Width = x.Value; + } + base.MinWidth = x.Value; + } + else + { + base.MinWidth = x.Value; + if (!canMaximize) + { + base.Width = x.Value; + base.MaxWidth = x.Value; + } + } + } + if (y.HasValue) + { + if (y.Value >= base.Height) + { + if (!canMaximize) + { + base.MaxHeight = y.Value; + base.Height = y.Value; + } + base.MinHeight = y.Value; + } + else + { + base.MinHeight = y.Value; + if (!canMaximize) + { + base.Height = y.Value; + base.MaxHeight = y.Value; + } + } + } + if (!x.HasValue || !y.HasValue || canMaximize) + { + base.ResizeMode = System.Windows.ResizeMode.CanResize; + } + else + { + this.MaximizeButton.IsEnabled = false; + this.MinimizeButton.IsEnabled = false; + this.MaximizeButtonPath.Stroke = new SolidColorBrush(Colors.Gray); + this.MinimizeButtonPath.Stroke = new SolidColorBrush(Colors.Gray); + } + base.Title = titulo; + this.Tela = control.GetType().Name; + this.HosterDialog.set_Identifier(string.Format("Dialog{0}{1}", this.Tela, Guid.NewGuid())); + } + + public void CloseButton_Click() + { + base.Close(); + } + + [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)] + private static extern bool GetCursorPos(out HosterWindow.Point lpPoint); + + [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)] + private static extern bool GetMonitorInfo(IntPtr hMonitor, HosterWindow.Monitorinfo lpmi); + + private void HabilitarMenu(bool enable) + { + this.Menu.IsEnabled = enable; + } + + private void HosterWindow_OnLoaded(object sender, RoutedEventArgs e) + { + Task.Run(() => { + Thread.Sleep(500); + System.Windows.Application.Current.Dispatcher.Invoke(() => base.Topmost = false); + }); + } + + [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/generic/hosterwindow.xaml", UriKind.Relative)); + } + + public void MaximizeButton_Click() + { + base.WindowState = (base.WindowState == System.Windows.WindowState.Normal ? System.Windows.WindowState.Maximized : System.Windows.WindowState.Normal); + } + + public void MinimizeButton_Click() + { + base.WindowState = System.Windows.WindowState.Minimized; + } + + [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false, SetLastError=true)] + private static extern IntPtr MonitorFromPoint(HosterWindow.Point pt, HosterWindow.MonitorOptions dwFlags); + + protected sealed override void OnStateChanged(EventArgs e) + { + object obj; + base.BorderThickness = new Thickness((double)(base.WindowState != System.Windows.WindowState.Maximized)); + System.Windows.Shell.WindowChrome windowChrome = this.WindowChrome; + if (base.WindowState == System.Windows.WindowState.Maximized) + { + obj = null; + } + else + { + obj = 4; + } + windowChrome.ResizeBorderThickness = new Thickness((double)obj); + this.WindowChrome.CaptionHeight = (double)((base.WindowState == System.Windows.WindowState.Maximized ? 32 : 29)); + this.MaximizeButtonPath.Data = (base.WindowState == System.Windows.WindowState.Maximized ? Geometry.Parse((string)System.Windows.Application.Current.Resources["Restore"]) : Geometry.Parse((string)System.Windows.Application.Current.Resources["Maximize"])); + base.OnStateChanged(e); + } + + private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e) + { + this.Snackbar.set_IsActive(false); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((HosterWindow)target).Initialized += new EventHandler(this.Window_OnInitialized); + ((HosterWindow)target).Loaded += new RoutedEventHandler(this.HosterWindow_OnLoaded); + return; + } + case 2: + { + this.WindowChrome = (System.Windows.Shell.WindowChrome)target; + return; + } + case 3: + { + this.Menu = (Grid)target; + return; + } + case 4: + { + this.MinimizeButton = (Grid)target; + this.MinimizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.MinimizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 5: + { + this.MinimizeButtonPath = (Path)target; + return; + } + case 6: + { + this.MaximizeButton = (Grid)target; + this.MaximizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.MaximizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 7: + { + this.MaximizeButtonPath = (Path)target; + return; + } + case 8: + { + this.CloseButton = (Grid)target; + this.CloseButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.CloseButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 9: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 10: + { + this.HosterDialog = (DialogHost)target; + return; + } + case 11: + { + this.DrawerHost = (MaterialDesignThemes.Wpf.DrawerHost)target; + return; + } + case 12: + { + this.Snackbar = (MaterialDesignThemes.Wpf.Snackbar)target; + return; + } + case 13: + { + ((SnackbarMessage)target).add_ActionClick(new RoutedEventHandler(this.SnackbarMessage_ActionClick)); + return; + } + } + this._contentLoaded = true; + } + + private static void TopControls_OnMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) + { + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray)); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeave(object sender, System.Windows.Input.MouseEventArgs e) + { + this._buttonClickable = false; + ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + this._buttonClickable = true; + if (((Grid)sender).Name != "CloseButton") + { + ((Grid)sender).Background = new SolidColorBrush(Colors.DimGray); + } + else + { + ((Grid)sender).Background = new SolidColorBrush(Colors.Red); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.Black); + return; + } + } + } + + private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + if (this._buttonClickable) + { + MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click")); + if (method == null) + { + return; + } + method.Invoke(this, null); + } + } + + private void Window_OnInitialized(object sender, EventArgs e) + { + WindowInteropHelper windowInteropHelper = new WindowInteropHelper(this); + windowInteropHelper.EnsureHandle(); + HwndSource hwndSource = HwndSource.FromHwnd(windowInteropHelper.Handle); + if (hwndSource == null) + { + return; + } + hwndSource.AddHook(new HwndSourceHook(this.WindowProc)); + } + + private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) + { + if (msg == 36) + { + this.WmGetMinMaxInfo(lParam); + } + return IntPtr.Zero; + } + + private void WmGetMinMaxInfo(IntPtr lParam) + { + HosterWindow.Point point; + System.Drawing.Rectangle workingArea = Screen.FromHandle((new WindowInteropHelper(this)).Handle).WorkingArea; + base.MaxHeight = (double)workingArea.Height; + HosterWindow.GetCursorPos(out point); + IntPtr intPtr = HosterWindow.MonitorFromPoint(new HosterWindow.Point(0, 0), HosterWindow.MonitorOptions.MonitorDefaulttoprimary); + HosterWindow.Monitorinfo monitorinfo = new HosterWindow.Monitorinfo(); + if (!HosterWindow.GetMonitorInfo(intPtr, monitorinfo)) + { + return; + } + IntPtr intPtr1 = HosterWindow.MonitorFromPoint(point, HosterWindow.MonitorOptions.MonitorDefaulttonearest); + HosterWindow.Minmaxinfo structure = (HosterWindow.Minmaxinfo)Marshal.PtrToStructure(lParam, typeof(HosterWindow.Minmaxinfo)); + if (!intPtr.Equals(intPtr1)) + { + structure.ptMaxPosition.X = monitorinfo.rcMonitor.Left; + structure.ptMaxPosition.Y = monitorinfo.rcMonitor.Top; + structure.ptMaxSize.X = monitorinfo.rcMonitor.Right - monitorinfo.rcMonitor.Left; + structure.ptMaxSize.Y = monitorinfo.rcMonitor.Bottom - monitorinfo.rcMonitor.Top; + } + else + { + structure.ptMaxPosition.X = monitorinfo.rcWork.Left; + structure.ptMaxPosition.Y = monitorinfo.rcWork.Top; + structure.ptMaxSize.X = monitorinfo.rcWork.Right - monitorinfo.rcWork.Left; + structure.ptMaxSize.Y = monitorinfo.rcWork.Bottom - monitorinfo.rcWork.Top; + } + Marshal.StructureToPtr(structure, lParam, true); + } + + private struct Minmaxinfo + { + private readonly HosterWindow.Point ptReserved; + + public HosterWindow.Point ptMaxSize; + + public HosterWindow.Point ptMaxPosition; + + private readonly HosterWindow.Point ptMinTrackSize; + + private readonly HosterWindow.Point ptMaxTrackSize; + } + + private class Monitorinfo + { + private readonly int cbSize; + + public readonly HosterWindow.Rect rcMonitor; + + public readonly HosterWindow.Rect rcWork; + + private readonly int dwFlags; + + public Monitorinfo() + { + } + } + + private enum MonitorOptions : uint + { + MonitorDefaulttoprimary = 1, + MonitorDefaulttonearest = 2 + } + + public struct Point + { + public int X; + + public int Y; + + public Point(int x, int y) + { + this.X = x; + this.Y = y; + } + } + + public struct Rect + { + public int Left; + + public int Top; + + public int Right; + + public int Bottom; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/ImportView.cs b/Codemerx/Gestor.Application/Views/ImportView.cs new file mode 100644 index 0000000..f7411e2 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/ImportView.cs @@ -0,0 +1,69 @@ +using Gestor.Application.ViewModels; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Markup; + +namespace Gestor.Application.Views +{ + public class ImportView : UserControl, IComponentConnector + { + private bool _contentLoaded; + + private ImportViewModel ViewModel + { + get; + } + + public ImportView() + { + this.ViewModel = new ImportViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private void ButtonBase_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Importar(); + } + + private void ButtonBase2_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CarregarArquivos(); + } + + [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/importview.xaml", UriKind.Relative)); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + if (connectionId == 1) + { + ((Button)target).Click += new RoutedEventHandler(this.ButtonBase2_OnClick); + return; + } + if (connectionId != 2) + { + this._contentLoaded = true; + return; + } + ((Button)target).Click += new RoutedEventHandler(this.ButtonBase_OnClick); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/LoginWindow.cs b/Codemerx/Gestor.Application/Views/LoginWindow.cs new file mode 100644 index 0000000..96cac36 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/LoginWindow.cs @@ -0,0 +1,825 @@ +using Agger.Registro; +using Gestor.Application; +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Ajuda; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Ferramentas; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.API; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; +using Newtonsoft.Json.Linq; +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.Net; +using System.Net.Http; +using System.Net.Sockets; +using System.Reflection; +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.Media; +using System.Windows.Shapes; +using System.Windows.Threading; + +namespace Gestor.Application.Views +{ + public class LoginWindow : Window, IComponentConnector + { + internal LoginViewModel ViewModel; + + private bool _buttonClickable; + + private DispatcherTimer _carouselTimer; + + internal Image ProgressRing; + + internal TextBox UserBox; + + internal CustomSenhaLoginBox PasswordBox; + + internal TextBlock TrocaSenha; + + internal CustomSenhaLoginBox SenhaBox; + + internal CustomSenhaLoginBox ConfirmacaoBox; + + internal TextBox ChaveBox; + + internal Grid MinimizeButton; + + internal Grid CloseButton; + + private bool _contentLoaded; + + public bool Bloquear + { + get; + set; + } + + private JArray LoginSettings + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public LoginWindow() + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + this.ViewModel = new LoginViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + this.MinimizeButton.MouseEnter += new MouseEventHandler(LoginWindow.TopControls_OnMouseEnter); + this.MinimizeButton.MouseLeave += new MouseEventHandler(this.TopControls_OnMouseLeave); + this.CloseButton.MouseEnter += new MouseEventHandler(LoginWindow.TopControls_OnMouseEnter); + this.CloseButton.MouseLeave += new MouseEventHandler(this.TopControls_OnMouseLeave); + this.ViewModel.Head = string.Concat("AGGER GESTOR ", this.ViewModel.Version, " - AGUARDE ESTAMOS INICIALIZANDO"); + } + + private async Task Access(bool error = true) + { + string str; + if (string.IsNullOrEmpty(this.ViewModel.Login) || string.IsNullOrEmpty(this.ViewModel.Senha)) + { + if (error) + { + this.ViewModel.ErrorLoginVisibility = System.Windows.Visibility.Visible; + } + this.UserBox.Focus(); + } + else + { + this.Loading(true); + if (await this.ViewModel.Validate(this.ViewModel.Login, this.ViewModel.Senha)) + { + bool bloquear = this.Bloquear; + if (!bloquear) + { + bloquear = await this.VerificarAcesso(); + } + this.Bloquear = bloquear; + if (!this.Bloquear) + { + DateTime networkTime = Funcoes.GetNetworkTime(); + if (Recursos.Usuario.get_Id() > (long)0) + { + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(0); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + registroLog.set_Descricao(string.Format("O USUÁRIO {0} LOGOU NO SISTEMA, EM {1}.", Recursos.Usuario.get_Nome(), networkTime)); + registroLog.set_EntidadeId(Recursos.Usuario.get_Id()); + registroLog.set_Tela(49); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = Dns.GetHostEntry(Dns.GetHostName()).AddressList; + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + RegistroLog registroLog1 = registroLog; + using (UnitOfWork commited = Instancia.Commited) + { + (new BaseServico()).SaveLog(registroLog1, commited); + commited.Commit(); + } + } + Parameters parameter = new Parameters(); + parameter.set_Beta(ApplicationHelper.Beta); + parameter.set_Type(7); + parameter.set_Application("Agger.Gestor.exe"); + parameter.set_Directory(""); + parameter.set_Run(false); + (new DownloadWindow(parameter)).Show(); + (new MainWindow()).Show(); + base.Close(); + } + } + else + { + this.Loading(false); + this.UserBox.Focus(); + } + } + } + + private async void Acessar_Click(object sender, RoutedEventArgs e) + { + ((RepeatButton)sender).Click -= new RoutedEventHandler(this.Acessar_Click); + await this.Access(true); + ((RepeatButton)sender).Click += new RoutedEventHandler(this.Acessar_Click); + } + + private void CancelarRegistro(object sender, RoutedEventArgs e) + { + this.ViewModel.FecharRegistro(); + } + + private void CancelarTrocaSenha_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.TrocaSenhaVisibility = System.Windows.Visibility.Collapsed; + this.ViewModel.LoginVisibility = System.Windows.Visibility.Visible; + } + + private void CentralAtendimento_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) + { + Process.Start(new ProcessStartInfo() + { + FileName = this.ViewModel.CentralAtendimento, + UseShellExecute = true + }); + } + + public void CloseButton_Click() + { + base.Close(); + } + + [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/loginwindow.xaml", UriKind.Relative)); + } + + private void LinkImage_MouseDown(object sender, MouseButtonEventArgs e) + { + Process.Start(new ProcessStartInfo() + { + FileName = this.ViewModel.ImagemLink, + UseShellExecute = true + }); + } + + private void Loading(bool isLoading) + { + this.ViewModel.EnableFields = !isLoading; + this.ViewModel.LoadingVisibility = isLoading; + this.ViewModel.FieldsVisibility = !isLoading; + base.IsEnabled = !isLoading; + } + + private async void LoginWindow_OnLoaded(object sender, RoutedEventArgs e) + { + this.Loading(true); + await this.ViewModel.GetCfgJson(); + await this.SearchImage(); + this.ViewModel.EnableButtons = false; + LicenseHelper licenseHelper = new LicenseHelper(); + bool flag = await licenseHelper.VerificarRegistro(); + if (!flag) + { + string str = await licenseHelper.FindKey(); + bool flag1 = false; + if (str != null) + { + await licenseHelper.Registrar(str); + flag1 = true; + } + if (str == null && !string.IsNullOrWhiteSpace(Recursos.Registrar)) + { + await licenseHelper.Registrar(Recursos.Registrar); + flag1 = true; + } + if (flag1) + { + flag = await licenseHelper.VerificarRegistro(); + } + str = null; + } + if (!flag) + { + this.Loading(false); + this.ViewModel.AbrirRegistro(); + this.ViewModel.EnableButtons = true; + } + else + { + Tuple tuple = await licenseHelper.VerificarAcesso(); + if (tuple.Item1) + { + ConnectionHelper connectionHelper = new ConnectionHelper(); + Tuple tuple1 = await connectionHelper.PrimeiroAcesso(); + if (Gestor.Application.Helpers.Connection.ConnectionAddress == null || Gestor.Application.Helpers.Connection.ConnectionAddress.get_Type() == 4) + { + this.Loading(false); + this.ViewModel.AcessoNegado("Erro de conexão com Banco Gestor.\nEntre em contato com Suporte!"); + } + else if (!tuple1.Item1 || !tuple1.Item2) + { + (new TutorialView(tuple1)).Show(); + base.Close(); + } + else + { + Tuple tuple2 = await licenseHelper.VerificarVersao(); + if (tuple2.Item1) + { + Task.Run(() => { + try + { + if (!connectionHelper.BDConvertido()) + { + (new BaseServico()).BuscarEmpresa((long)1); + } + } + catch + { + } + }); + this.Loading(false); + if (!string.IsNullOrWhiteSpace(this.UserBox.Text)) + { + this.PasswordBox.PasswordBox.Focus(); + } + else + { + this.UserBox.Focus(); + } + this.ViewModel.EnableButtons = true; + string result = Gestor.Application.Helpers.Connection.Get(string.Concat("Customer/Name/", ApplicationHelper.NumeroSerial), true, false).Result; + this.ViewModel.Head = result; + } + else + { + this.Loading(false); + this.ViewModel.AcessoNegado(tuple2.Item2); + } + } + } + else + { + this.Loading(false); + this.ViewModel.AcessoNegado(tuple.Item2); + } + } + licenseHelper = null; + } + + public void MinimizeButton_Click() + { + base.WindowState = System.Windows.WindowState.Minimized; + } + + private void NovoPerfil_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) + { + this.ViewModel.AbrirRegistro(); + this.ViewModel.EnableButtons = true; + } + + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + Size newSize; + base.OnRenderSizeChanged(sizeInfo); + if (sizeInfo.HeightChanged) + { + double top = base.Top; + double height = sizeInfo.PreviousSize.Height; + newSize = sizeInfo.NewSize; + base.Top = top + (height - newSize.Height) / 2; + } + if (sizeInfo.WidthChanged) + { + double left = base.Left; + double width = sizeInfo.PreviousSize.Width; + newSize = sizeInfo.NewSize; + base.Left = left + (width - newSize.Width) / 2; + } + } + + private async void PasswordBox_OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Return) + { + await this.Access(true); + } + } + + private async void Registrar_OnClick(object sender, RoutedEventArgs e) + { + this.Loading(true); + LicenseHelper licenseHelper = new LicenseHelper(); + string str = await licenseHelper.Registrar(this.ViewModel.Chave); + if (str != "false") + { + if (str == "root") + { + await this.ViewModel.ShowMessage("CHAVE JÁ REGISTRADA ANTERIORMENTE.", "OK", "", false); + } + this.ViewModel.FecharRegistro(); + string result = Gestor.Application.Helpers.Connection.Get(string.Concat("Customer/Name/", ApplicationHelper.NumeroSerial), true, false).Result; + this.ViewModel.Head = result; + Tuple tuple = await licenseHelper.VerificarAcesso(); + if (tuple.Item1) + { + Tuple tuple1 = await (new ConnectionHelper()).PrimeiroAcesso(); + if (!tuple1.Item1 || !tuple1.Item2) + { + (new TutorialView(tuple1)).Show(); + base.Close(); + } + else + { + this.Loading(false); + await this.Access(false); + } + } + else + { + this.Loading(false); + this.ViewModel.AcessoNegado(tuple.Item2); + } + } + else + { + await this.ViewModel.ShowMessage("CHAVE INVÁLIDA", "OK", "", false); + this.Loading(false); + this.ViewModel.AbrirRegistro(); + } + licenseHelper = null; + } + + private async Task SearchImage() + { + string str2; + string str3; + try + { + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + httpClient.set_Timeout(TimeSpan.FromSeconds(30)); + string stringAsync = await httpClient.GetStringAsync(Address.get_LoginJsonV2()); + this.LoginSettings = JArray.Parse(stringAsync); + DateTime now = DateTime.Now; + foreach (JToken jToken2 in this.LoginSettings.Where((JToken x) => { + DateTime dateTime; + DateTime dateTime1; + bool flag; + List list; + string str; + string str1; + JToken item = x.get_Item("Ativo"); + flag = (item != null ? Extensions.Value(item) : false); + if (!flag) + { + return false; + } + JToken jToken = x.get_Item("Produto"); + if (jToken != null) + { + list = jToken.Values().ToList(); + } + else + { + list = null; + } + List nums = list; + if (nums != null) + { + List nums1 = nums; + Func u003cu003e9_201 = LoginWindow.u003cu003ec.u003cu003e9__20_1; + if (u003cu003e9_201 == null) + { + u003cu003e9_201 = (int p) => { + if (p == 0) + { + return true; + } + return p == 3; + }; + LoginWindow.u003cu003ec.u003cu003e9__20_1 = u003cu003e9_201; + } + if (nums1.Any(u003cu003e9_201)) + { + JToken item1 = x.get_Item("Inicio"); + if (item1 != null) + { + str = item1.ToString(); + } + else + { + str = null; + } + bool flag1 = DateTime.TryParse(str, out dateTime); + JToken jToken1 = x.get_Item("Fim"); + if (jToken1 != null) + { + str1 = jToken1.ToString(); + } + else + { + str1 = null; + } + bool flag2 = DateTime.TryParse(str1, out dateTime1); + if (flag1 & flag2) + { + if (now < dateTime) + { + return false; + } + return now <= dateTime1; + } + if (flag1) + { + return now >= dateTime; + } + if (!flag2) + { + return true; + } + return now <= dateTime1; + } + } + return false; + })) + { + ObservableCollection loginImages = this.ViewModel.LoginImages; + LoginImageModel loginImageModel = new LoginImageModel(); + JToken jToken3 = jToken2.get_Item("Imagem"); + if (jToken3 != null) + { + str2 = jToken3.ToString(); + } + else + { + str2 = null; + } + loginImageModel.Imagem = str2; + JToken jToken4 = jToken2.get_Item("UrlFixa"); + if (jToken4 != null) + { + str3 = jToken4.ToString(); + } + else + { + str3 = null; + } + loginImageModel.UrlFixa = str3; + loginImages.Add(loginImageModel); + } + this.ViewModel.SelectedImage = this.ViewModel.LoginImages.FirstOrDefault(); + base.Dispatcher.Invoke(new Action(this.StartCarousel)); + } + httpClient = null; + } + catch + { + } + } + + private void StartCarousel() + { + if (this.ViewModel.LoginImages.Count <= 1) + { + return; + } + this._carouselTimer = new DispatcherTimer() + { + Interval = TimeSpan.FromSeconds(10) + }; + this._carouselTimer.Tick += new EventHandler((object s, EventArgs e) => { + int num = (this.ViewModel.LoginImages.IndexOf(this.ViewModel.SelectedImage) + 1) % this.ViewModel.LoginImages.Count; + this.ViewModel.SelectedImage = this.ViewModel.LoginImages[num]; + }); + this._carouselTimer.Start(); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((LoginWindow)target).Loaded += new RoutedEventHandler(this.LoginWindow_OnLoaded); + return; + } + case 2: + { + this.ProgressRing = (Image)target; + return; + } + case 3: + { + this.UserBox = (TextBox)target; + return; + } + case 4: + { + this.PasswordBox = (CustomSenhaLoginBox)target; + return; + } + case 5: + { + this.TrocaSenha = (TextBlock)target; + this.TrocaSenha.PreviewMouseDown += new MouseButtonEventHandler(this.TrocarSenha_OnPreviewMouseDown); + return; + } + case 6: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.Acessar_Click); + return; + } + case 7: + { + ((TextBlock)target).PreviewMouseDown += new MouseButtonEventHandler(this.NovoPerfil_OnPreviewMouseDown); + return; + } + case 8: + { + this.SenhaBox = (CustomSenhaLoginBox)target; + return; + } + case 9: + { + this.ConfirmacaoBox = (CustomSenhaLoginBox)target; + return; + } + case 10: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.CancelarTrocaSenha_OnClick); + return; + } + case 11: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.TrocarSenha_OnClick); + return; + } + case 12: + { + ((TextBlock)target).PreviewMouseDown += new MouseButtonEventHandler(this.CentralAtendimento_OnPreviewMouseDown); + return; + } + case 13: + { + this.ChaveBox = (TextBox)target; + return; + } + case 14: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.CancelarRegistro); + return; + } + case 15: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.Registrar_OnClick); + return; + } + case 16: + { + this.MinimizeButton = (Grid)target; + this.MinimizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.MinimizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 17: + { + this.CloseButton = (Grid)target; + this.CloseButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.CloseButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + } + this._contentLoaded = true; + } + + private static void TopControls_OnMouseEnter(object sender, MouseEventArgs e) + { + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush((Color)System.Windows.Application.Current.Resources["AggerYellow100"]) : new SolidColorBrush(Colors.Gray)); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeave(object sender, MouseEventArgs e) + { + this._buttonClickable = false; + ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush((Color)System.Windows.Application.Current.Resources["AggerYellow100"]) : new SolidColorBrush(Colors.DimGray)); + } + } + + private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + this._buttonClickable = true; + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.DarkGoldenrod) : new SolidColorBrush(Colors.DimGray)); + } + + private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + if (this._buttonClickable) + { + MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click")); + if (method == null) + { + return; + } + method.Invoke(this, null); + } + } + + private async void TrocarSenha_OnClick(object sender, RoutedEventArgs e) + { + this.Loading(true); + bool flag = await this.ViewModel.TrocaSenha(); + this.Loading(false); + if (flag) + { + await this.Access(true); + } + } + + private async void TrocarSenha_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) + { + this.Loading(true); + await this.ViewModel.AbrirTrocaSenha(); + this.Loading(false); + } + + private async Task VerificarAcesso() + { + bool flag; + Instalacao instalacao; + LicenseHelper licenseHelper = new LicenseHelper(); + Tuple tuple = await licenseHelper.VerificarAcesso(); + if (tuple.Item1) + { + if (!this.ViewModel.Login.Contains("AGGER@")) + { + bool flag1 = false; + if (!await licenseHelper.VerificarMaquina()) + { + this.Loading(false); + while (!flag1) + { + List instalacoes = await licenseHelper.GetInstalacoes(); + if (instalacoes.Count != 0) + { + List instalacaos = instalacoes; + IOrderedEnumerable ultimoAcesso = + from x in instalacaos + orderby x.get_UltimoAcesso() descending + select x; + Instalacao instalacao1 = ultimoAcesso.FirstOrDefault((Instalacao x) => x.get_UsuarioId() == Recursos.Usuario.get_Id()); + bool flag2 = instalacao1 != null; + if (flag2) + { + flag2 = await this.ViewModel.ShowMessage(string.Concat("SEU ULTIMO ACESSO FOI NA MAQUINA ", instalacao1.get_NomeMaquina(), ". DESEJA SUBSTITUIR A LICENÇA PARA ESSA MAQUINA?"), "SIM", "NÃO", false); + } + if (!flag2) + { + instalacao = await this.ViewModel.ShowInstalacoes(instalacoes); + } + else + { + instalacao = instalacao1; + } + Instalacao instalacao2 = instalacao; + if (instalacao2 != null) + { + this.Loading(true); + await (new AjudaServico()).ExcluirInstalacao(instalacao2.get_Id()); + await Task.Delay(15000); + flag2 = await licenseHelper.VerificarMaquina(); + flag1 = flag2; + this.Loading(false); + instalacoes = null; + instalacao1 = null; + } + else + { + this.ViewModel.AcessoNegado("MÁQUINA NÃO REGISTRADA"); + flag = true; + licenseHelper = null; + return flag; + } + } + else + { + this.ViewModel.AcessoNegado("ACESSO NEGADO, NÃO EXISTEM LICENÇAS VÁLIDAS."); + flag = true; + licenseHelper = null; + return flag; + } + } + } + } + Tuple tuple1 = await licenseHelper.VerificarVersao(); + if (tuple1.Item1) + { + string str = await (new ConnectionHelper()).AtualizarBanco(); + if (str == null) + { + if (!await this.ViewModel.Load()) + { + base.Close(); + } + flag = false; + } + else + { + await this.ViewModel.ShowMessage(str, "OK", "", false); + flag = false; + } + } + else + { + this.Loading(false); + this.ViewModel.AcessoNegado(tuple1.Item2); + flag = true; + } + } + else + { + this.Loading(false); + this.ViewModel.AcessoNegado(tuple.Item2); + flag = true; + } + licenseHelper = null; + return flag; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Menus/DashboardView.cs b/Codemerx/Gestor.Application/Views/Menus/DashboardView.cs new file mode 100644 index 0000000..1b130e6 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Menus/DashboardView.cs @@ -0,0 +1,1002 @@ +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Relatorios.Dashboard; +using Gestor.Model.Domain.Relatorios.Renovacao; +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.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.Menus +{ + public class DashboardView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal Chip UsuarioChip; + + internal Button TileRenovacao; + + internal Button TileAniversariantes; + + internal Button TileTarefas; + + internal Button TileSinistro; + + internal Button TileProspeccao; + + internal TextBox TituloBox; + + internal TextBox DescricaoBox; + + internal Grid RenovacaoGrid; + + internal Grid AniversariantesGrid; + + internal Grid TarefasGrid; + + internal Grid ProspeccaoGrid; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal ComboBox FiltroDocumento; + + internal Grid SinistroGrid; + + internal DatePicker InicioBox2; + + internal DatePicker FimBox2; + + private bool _contentLoaded; + + public DashboardViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public DashboardView(DashboardViewModel viewModel) + { + base.Tag = "DASHBOARD"; + this.ViewModel = viewModel; + 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 async void AbrirAniversariante_OnClick(object sender, RoutedEventArgs e) + { + ClientesAtivosInativos dataContext = (ClientesAtivosInativos)((Button)sender).DataContext; + Cliente cliente = await (new ClienteServico()).BuscarClienteAsync(dataContext.get_EntidadeCliente().get_Id()); + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ClienteView(cliente, true, null), string.Concat("CADASTRO DE CLIENTES - ", cliente.get_Nome()), nullable1, nullable, false)).ShowDialog(); + } + + private async Task AbrirProspeccao(Prospeccao data) + { + bool flag; + this.InicioBox.Text = ValidationHelper.FormatDate(this.InicioBox.Text); + this.FimBox.Text = ValidationHelper.FormatDate(this.FimBox.Text); + while (true) + { + data = await this.ViewModel.ShowProspeccaoDialog(data); + if (data == null) + { + return; + } + List> keyValuePairs = await this.ViewModel.SalvarProspeccao(data); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag) + { + break; + } + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + this.ViewModel.ToggleSnackBar("PROSPECÇÃO SALVA COM SUCESSO.", true); + await this.CarregarForce(); + return; + } + + private async void AbrirRenovacao_OnClick(object sender, RoutedEventArgs e) + { + Renovacao dataContext = (Renovacao)((Button)sender).DataContext; + if (dataContext.get_Documento() != null) + { + Documento documento = await (new ApoliceServico()).BuscarApoliceAsync(dataContext.get_Documento().get_Id(), false, false); + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ApoliceView(documento, true, false, 0, (long)0, false), string.Concat("CADASTRO DE APÓLICES - ", documento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).Show(); + } + else + { + this.ViewModel.Loading(true); + await this.AbrirProspeccao(dataContext.get_Prospeccao()); + this.ViewModel.Loading(false); + } + } + + private async void AbrirSinistro_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button.DataContext != null) + { + Sinistro dataContext = (Sinistro)button.DataContext; + if (dataContext != null) + { + dataContext = await this.ViewModel.CarregaSinistroApolice(dataContext.get_Id()); + Item item = dataContext.get_ControleSinistro().get_Item(); + SinistroView sinistroView = new SinistroView(item, false); + string[] nome = new string[] { "CADASTRO DE SINISTROS - ", item.get_Documento().get_Controle().get_Cliente().get_Nome(), " - ", item.get_Documento().get_Apolice(), " ", item.get_Documento().get_Endosso() }; + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(sinistroView, string.Concat(nome), nullable1, nullable, false)).Show(); + } + } + } + + private void AbrirTarefa_OnClick(object sender, RoutedEventArgs e) + { + Tarefa dataContext = (Tarefa)((Button)sender).DataContext; + this.ViewModel.ShowDrawer(new TarefaDrawer(dataContext, true), 0, false); + } + + private void AdicionarNota_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EnableFields = true; + this.TituloBox.Text = string.Empty; + this.DescricaoBox.Text = string.Empty; + this.ViewModel.Publica = false; + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EnableFields = false; + } + + private async Task Carregar() + { + this.ViewModel.Loading(true); + this.RenovacaoGrid.Visibility = System.Windows.Visibility.Collapsed; + this.AniversariantesGrid.Visibility = System.Windows.Visibility.Collapsed; + this.TarefasGrid.Visibility = System.Windows.Visibility.Collapsed; + this.ProspeccaoGrid.Visibility = System.Windows.Visibility.Collapsed; + this.SinistroGrid.Visibility = System.Windows.Visibility.Collapsed; + if (this.ViewModel.Filtros == null) + { + await this.ViewModel.CarregarFiltros(); + } + await this.ViewModel.CarregarNotas(); + switch (this.ViewModel.SelectedTile) + { + case 1: + { + await this.ViewModel.CarregarRenovacoes(false); + this.RenovacaoGrid.Visibility = System.Windows.Visibility.Visible; + break; + } + case 2: + { + await this.ViewModel.CarregarAniversariantes(false); + this.AniversariantesGrid.Visibility = System.Windows.Visibility.Visible; + break; + } + case 3: + { + await this.ViewModel.CarregarTarefas(false); + this.TarefasGrid.Visibility = System.Windows.Visibility.Visible; + break; + } + case 4: + { + DashboardViewModel viewModel = this.ViewModel; + DateTime value = this.InicioBox.SelectedDate.Value; + await viewModel.CarregarProspect(value, this.FimBox.SelectedDate.Value); + this.ProspeccaoGrid.Visibility = System.Windows.Visibility.Visible; + break; + } + case 5: + { + await this.ViewModel.CarregarSinistros(false); + this.SinistroGrid.Visibility = System.Windows.Visibility.Visible; + break; + } + } + this.ViewModel.Loading(false); + } + + private async Task CarregarForce() + { + this.ViewModel.Loading(true); + this.RenovacaoGrid.Visibility = System.Windows.Visibility.Collapsed; + this.AniversariantesGrid.Visibility = System.Windows.Visibility.Collapsed; + this.TarefasGrid.Visibility = System.Windows.Visibility.Collapsed; + this.ProspeccaoGrid.Visibility = System.Windows.Visibility.Collapsed; + this.SinistroGrid.Visibility = System.Windows.Visibility.Collapsed; + await this.ViewModel.CarregarFiltros(); + List restricoes = this.ViewModel.Restricoes; + bool flag = restricoes.Any((RestricaoUsuario x) => { + if (x.get_Tipo() != 24) + { + return false; + } + return x.get_Restricao(); + }); + List restricaoUsuarios = this.ViewModel.Restricoes; + bool flag1 = restricaoUsuarios.Any((RestricaoUsuario x) => { + if (x.get_Tipo() != 49) + { + return false; + } + return x.get_Restricao(); + }); + List restricoes1 = this.ViewModel.Restricoes; + bool flag2 = restricoes1.Any((RestricaoUsuario x) => { + if (x.get_Tipo() != 19) + { + return false; + } + return x.get_Restricao(); + }); + List restricaoUsuarios1 = this.ViewModel.Restricoes; + bool flag3 = restricaoUsuarios1.Any((RestricaoUsuario x) => { + if (x.get_Tipo() != 25) + { + return false; + } + return x.get_Restricao(); + }); + if (!flag) + { + await this.ViewModel.CarregarRenovacoes(true); + } + if (!flag1) + { + await this.ViewModel.CarregarAniversariantes(true); + } + if (!flag2) + { + await this.ViewModel.CarregarTarefas(true); + } + if (!flag3) + { + await this.ViewModel.CarregarSinistros(true); + } + await this.ViewModel.CarregarNotas(); + switch (this.ViewModel.SelectedTile) + { + case 1: + { + this.RenovacaoGrid.Visibility = System.Windows.Visibility.Visible; + break; + } + case 2: + { + this.AniversariantesGrid.Visibility = System.Windows.Visibility.Visible; + break; + } + case 3: + { + this.TarefasGrid.Visibility = System.Windows.Visibility.Visible; + break; + } + case 4: + { + this.ProspeccaoGrid.Visibility = System.Windows.Visibility.Visible; + break; + } + case 5: + { + this.SinistroGrid.Visibility = System.Windows.Visibility.Visible; + break; + } + } + this.ViewModel.Loading(false); + } + + private async void ContentLoad() + { + DateTime? selectedDate; + this.UsuarioChip.Content = Recursos.Usuario.get_Nome(); + await this.ViewModel.BuscarRestricoes(); + await this.ViewModel.CarregarNotas(); + await this.ViewModel.CarregarFiltros(); + List restricoes = this.ViewModel.Restricoes; + bool flag = restricoes.Any((RestricaoUsuario x) => { + if (x.get_Tipo() != 24) + { + return false; + } + return x.get_Restricao(); + }); + List restricaoUsuarios = this.ViewModel.Restricoes; + bool flag1 = restricaoUsuarios.Any((RestricaoUsuario x) => { + if (x.get_Tipo() != 49) + { + return false; + } + return x.get_Restricao(); + }); + List permissoes = this.ViewModel.Permissoes; + bool flag2 = permissoes.Any((PermissaoUsuario x) => { + if (x.get_Tela() != 38) + { + return false; + } + return !x.get_Consultar(); + }); + bool hasValue = !Recursos.Usuario.get_PermissaoAggilizador().HasValue; + List restricoes1 = this.ViewModel.Restricoes; + bool flag3 = restricoes1.Any((RestricaoUsuario x) => { + if (x.get_Tipo() != 25) + { + return false; + } + return x.get_Restricao(); + }); + this.FiltroDocumento.SelectedIndex = 0; + List tasks = new List(); + if (hasValue) + { + this.TileProspeccao.Visibility = System.Windows.Visibility.Collapsed; + } + else + { + this.ViewModel.CarregarRamos(); + this.TileProspeccao.Visibility = System.Windows.Visibility.Visible; + if (!this.InicioBox.SelectedDate.HasValue) + { + this.InicioBox.SelectedDate = new DateTime?(DateTime.Today); + } + if (!this.FimBox.SelectedDate.HasValue) + { + DatePicker fimBox = this.FimBox; + selectedDate = this.InicioBox.SelectedDate; + fimBox.SelectedDate = new DateTime?(selectedDate.Value); + } + DashboardViewModel viewModel = this.ViewModel; + DateTime value = this.InicioBox.SelectedDate.Value; + selectedDate = this.FimBox.SelectedDate; + tasks.Add(viewModel.CarregarProspect(value, selectedDate.Value)); + } + if (flag2) + { + this.TileTarefas.Visibility = System.Windows.Visibility.Collapsed; + } + else + { + this.TileTarefas.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.SelectedTile = 3; + tasks.Add(this.ViewModel.CarregarTarefas(false)); + } + if (flag1) + { + this.TileAniversariantes.Visibility = System.Windows.Visibility.Collapsed; + } + else + { + this.TileAniversariantes.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.SelectedTile = 2; + tasks.Add(this.ViewModel.CarregarAniversariantes(false)); + } + if (flag3) + { + this.TileSinistro.Visibility = System.Windows.Visibility.Collapsed; + } + else + { + this.TileSinistro.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.SelectedTile = 5; + tasks.Add(this.ViewModel.CarregarSinistros(false)); + } + if (flag) + { + this.TileRenovacao.Visibility = System.Windows.Visibility.Collapsed; + } + else + { + this.TileRenovacao.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.SelectedTile = 1; + tasks.Add(this.ViewModel.CarregarRenovacoes(false)); + } + await Task.WhenAll(tasks); + this.ViewModel.Load = false; + } + + private void DatePicker_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + this.ViewModel.LimparProspeccao(); + } + + private async void EnviarPorWhatsApp_OnClick(object sender, RoutedEventArgs e) + { + string str; + if (!this.ViewModel.Restricao(32)) + { + Button button = (Button)sender; + if (button.DataContext != null) + { + ClienteTelefone dataContext = button.DataContext as ClienteTelefone; + 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(this.ViewModel.Anotacoes)) + { + 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; + } + } + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR O WHATSAPP", "OK", "", false); + } + } + + 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 void FiltroCliente_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + this.ViewModel.LimparProspeccao(); + } + + private async void GerarCsv_OnClick(object sender, RoutedEventArgs e) + { + DateTime date = DateTime.Now.Date; + string.Concat("NovosNegocios", date.ToString("d").Replace("/", ""), ".csv"); + if (this.ViewModel.Prospeccoes.Count != 0) + { + this.ViewModel.Loading(true); + await this.ViewModel.GerarCsv(); + this.ViewModel.Loading(false); + } + else + { + await this.ViewModel.ShowMessage("NÃO HÁ DADOS A SEREM EXPORTADOS NO .CSV", "OK", "", false); + } + } + + [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/menus/dashboardview.xaml", UriKind.Relative)); + } + + 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 void PopupBox_OnClosed(object sender, RoutedEventArgs e) + { + this.ViewModel.Anotacoes = ""; + } + + private void PopupBoxAniversariante_OnOpened(object sender, RoutedEventArgs e) + { + ClientesAtivosInativos dataContext = (ClientesAtivosInativos)((PopupBox)sender).DataContext; + this.ViewModel.Telefones = dataContext.get_EntidadeCliente().get_Telefones(); + } + + private void PopupBoxProspeccao_OnOpened(object sender, RoutedEventArgs e) + { + Prospectar dataContext = (Prospectar)((PopupBox)sender).DataContext; + this.ViewModel.Telefones = dataContext.get_EntidadeCliente().get_Telefones(); + } + + private void PopupBoxRenovacao_OnOpened(object sender, RoutedEventArgs e) + { + PopupBox popupBox = (PopupBox)sender; + ObservableCollection observableCollection = new ObservableCollection(); + Renovacao dataContext = (Renovacao)popupBox.DataContext; + if (dataContext.get_Documento() == null) + { + if (!string.IsNullOrEmpty(dataContext.get_Prospeccao().get_Telefone1())) + { + ClienteTelefone clienteTelefone = new ClienteTelefone(); + clienteTelefone.set_Prefixo(dataContext.get_Prospeccao().get_Prefixo1()); + clienteTelefone.set_Numero(dataContext.get_Prospeccao().get_Telefone1()); + observableCollection.Add(clienteTelefone); + } + if (!string.IsNullOrEmpty(dataContext.get_Prospeccao().get_Telefone2())) + { + ClienteTelefone clienteTelefone1 = new ClienteTelefone(); + clienteTelefone1.set_Prefixo(dataContext.get_Prospeccao().get_Prefixo2()); + clienteTelefone1.set_Numero(dataContext.get_Prospeccao().get_Telefone2()); + observableCollection.Add(clienteTelefone1); + } + } + else + { + observableCollection = dataContext.get_Documento().get_Controle().get_Cliente().get_Telefones(); + } + this.ViewModel.Telefones = observableCollection; + } + + private void Ramo_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + this.ViewModel.LimparProspeccao(); + } + + private void Referencia_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + this.ViewModel.LimparProspeccao(); + } + + private async void Refresh_OnClick(object sender, RoutedEventArgs e) + { + await this.CarregarForce(); + } + + private async void RefreshProspectar_OnClick(object sender, RoutedEventArgs e) + { + if (!this.InicioBox.SelectedDate.HasValue || !this.FimBox.SelectedDate.HasValue) + { + await this.ViewModel.ShowMessage("INÍCIO E FIM DEVEM ESTAR PREENCHIDOS.", "OK", "", false); + } + else if (this.InicioBox.SelectedDate.Value > this.FimBox.SelectedDate.Value) + { + await this.ViewModel.ShowMessage("INÍCIO NÃO DEVE SER MAIOR QUE O FIM.", "OK", "", false); + } + else if ((this.FimBox.SelectedDate.Value - this.InicioBox.SelectedDate.Value).TotalDays <= 31) + { + this.ViewModel.Loading(true); + DashboardViewModel viewModel = this.ViewModel; + DateTime value = this.InicioBox.SelectedDate.Value; + await viewModel.CarregarProspect(value, this.FimBox.SelectedDate.Value); + this.ProspeccaoGrid.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.Loading(false); + } + else + { + await this.ViewModel.ShowMessage("O PERIODO TOTAL DO RELATÓRIO NÃO PODE SER MAIOR QUE 30 DIAS.", "OK", "", false); + } + } + + private async void RefreshSinsitro_OnClick(object sender, RoutedEventArgs e) + { + if (!this.InicioBox2.SelectedDate.HasValue || !this.FimBox2.SelectedDate.HasValue) + { + await this.ViewModel.ShowMessage("INÍCIO E FIM DEVEM ESTAR PREENCHIDOS.", "OK", "", false); + } + else if (this.InicioBox2.SelectedDate.Value > this.FimBox2.SelectedDate.Value) + { + await this.ViewModel.ShowMessage("INÍCIO NÃO DEVE SER MAIOR QUE O FIM.", "OK", "", false); + } + else if ((this.FimBox2.SelectedDate.Value - this.InicioBox2.SelectedDate.Value).TotalDays <= 31) + { + this.ViewModel.Loading(true); + DashboardViewModel viewModel = this.ViewModel; + DateTime value = this.InicioBox2.SelectedDate.Value; + await viewModel.CarregarSinistros(value, this.FimBox2.SelectedDate.Value); + this.SinistroGrid.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.Loading(false); + } + else + { + await this.ViewModel.ShowMessage("O PERIODO TOTAL DO RELATÓRIO NÃO PODE SER MAIOR QUE 30 DIAS.", "OK", "", false); + } + } + + private async void SalvarNota_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + Tarefa tarefa = new Tarefa(); + tarefa.set_Agendamento(Funcoes.GetNetworkTime()); + tarefa.set_Titulo(this.TituloBox.Text); + tarefa.set_Anotacoes(this.DescricaoBox.Text); + tarefa.set_Usuario(Recursos.Usuario); + tarefa.set_UsuarioCadastro(Recursos.Usuario); + tarefa.set_Entidade(1); + tarefa.set_Status(0); + List> keyValuePairs = await this.ViewModel.Salvar(tarefa); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.ViewModel.ToggleSnackBar("NOTA SALVA COM SUCESSO.", true); + this.ViewModel.EnableFields = false; + await this.ViewModel.CarregarNotas(); + } + } + + private async void SarvarNota_OnClick(object sender, RoutedEventArgs e) + { + Tarefa dataContext = ((Button)sender).DataContext as Tarefa; + if (dataContext != null) + { + List> keyValuePairs = await this.ViewModel.Salvar(dataContext); + if (keyValuePairs != null && keyValuePairs.Count != 0) + { + 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.UsuarioChip = (Chip)target; + return; + } + case 2: + { + ((Button)target).Click += new RoutedEventHandler(this.Refresh_OnClick); + return; + } + case 3: + { + this.TileRenovacao = (Button)target; + this.TileRenovacao.Click += new RoutedEventHandler(this.TileRenovacao_OnClick); + return; + } + case 4: + { + this.TileAniversariantes = (Button)target; + this.TileAniversariantes.Click += new RoutedEventHandler(this.TileAniversariantes_OnClick); + return; + } + case 5: + { + this.TileTarefas = (Button)target; + this.TileTarefas.Click += new RoutedEventHandler(this.TileTarefas_OnClick); + return; + } + case 6: + { + this.TileSinistro = (Button)target; + this.TileSinistro.Click += new RoutedEventHandler(this.TileSinistro_OnClick); + return; + } + case 7: + { + this.TileProspeccao = (Button)target; + this.TileProspeccao.Click += new RoutedEventHandler(this.TileProspeccao_OnClick); + return; + } + case 8: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarNota_OnClick); + return; + } + case 9: + { + ((Button)target).Click += new RoutedEventHandler(this.SalvarNota_OnClick); + return; + } + case 10: + { + ((Button)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 11: + { + this.TituloBox = (TextBox)target; + return; + } + case 12: + { + this.DescricaoBox = (TextBox)target; + return; + } + case 13: + case 14: + case 16: + case 17: + case 18: + case 20: + case 21: + case 22: + case 24: + case 33: + case 34: + { + this._contentLoaded = true; + return; + } + case 15: + { + this.RenovacaoGrid = (Grid)target; + return; + } + case 19: + { + this.AniversariantesGrid = (Grid)target; + return; + } + case 23: + { + this.TarefasGrid = (Grid)target; + return; + } + case 25: + { + this.ProspeccaoGrid = (Grid)target; + return; + } + case 26: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Ramo_OnSelectionChanged); + return; + } + case 27: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Referencia_OnSelectionChanged); + return; + } + case 28: + { + this.InicioBox = (DatePicker)target; + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.InicioBox.SelectedDateChanged += new EventHandler(this.DatePicker_OnSelectedDateChanged); + return; + } + case 29: + { + this.FimBox = (DatePicker)target; + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.FimBox.SelectedDateChanged += new EventHandler(this.DatePicker_OnSelectedDateChanged); + return; + } + case 30: + { + this.FiltroDocumento = (ComboBox)target; + this.FiltroDocumento.SelectionChanged += new SelectionChangedEventHandler(this.FiltroCliente_OnSelectionChanged); + return; + } + case 31: + { + ((Button)target).Click += new RoutedEventHandler(this.RefreshProspectar_OnClick); + return; + } + case 32: + { + ((Button)target).Click += new RoutedEventHandler(this.GerarCsv_OnClick); + return; + } + case 35: + { + this.SinistroGrid = (Grid)target; + return; + } + case 36: + { + this.InicioBox2 = (DatePicker)target; + this.InicioBox2.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox2.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.InicioBox2.SelectedDateChanged += new EventHandler(this.DatePicker_OnSelectedDateChanged); + return; + } + case 37: + { + this.FimBox2 = (DatePicker)target; + this.FimBox2.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox2.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.FimBox2.SelectedDateChanged += new EventHandler(this.DatePicker_OnSelectedDateChanged); + return; + } + case 38: + { + ((Button)target).Click += new RoutedEventHandler(this.RefreshSinsitro_OnClick); + 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 > 33) + { + if (connectionId == 34) + { + ((Button)target).Click += new RoutedEventHandler(this.EnviarPorWhatsApp_OnClick); + return; + } + if (connectionId != 39) + { + return; + } + ((Button)target).Click += new RoutedEventHandler(this.AbrirSinistro_OnClick); + } + else + { + switch (connectionId) + { + case 13: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirNota_OnClick); + return; + } + case 14: + { + ((Button)target).Click += new RoutedEventHandler(this.NotaConcluida_OnClick); + return; + } + case 15: + case 19: + case 23: + { + return; + } + case 16: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirRenovacao_OnClick); + return; + } + case 17: + { + ((PopupBox)target).add_Opened(new RoutedEventHandler(this.PopupBoxRenovacao_OnOpened)); + ((PopupBox)target).add_Closed(new RoutedEventHandler(this.PopupBox_OnClosed)); + return; + } + case 18: + { + ((Button)target).Click += new RoutedEventHandler(this.EnviarPorWhatsApp_OnClick); + return; + } + case 20: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAniversariante_OnClick); + return; + } + case 21: + { + ((PopupBox)target).add_Opened(new RoutedEventHandler(this.PopupBoxAniversariante_OnOpened)); + ((PopupBox)target).add_Closed(new RoutedEventHandler(this.PopupBox_OnClosed)); + return; + } + case 22: + { + ((Button)target).Click += new RoutedEventHandler(this.EnviarPorWhatsApp_OnClick); + return; + } + case 24: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirTarefa_OnClick); + return; + } + default: + { + if (connectionId == 33) + { + break; + } + else + { + return; + } + } + } + ((PopupBox)target).add_Opened(new RoutedEventHandler(this.PopupBoxProspeccao_OnOpened)); + ((PopupBox)target).add_Closed(new RoutedEventHandler(this.PopupBox_OnClosed)); + return; + } + } + + private async void TileAniversariantes_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.SelectedTile = 2; + await this.Carregar(); + } + + private async void TileProspeccao_OnClick(object sender, RoutedEventArgs e) + { + if (!this.InicioBox.SelectedDate.HasValue) + { + this.InicioBox.SelectedDate = new DateTime?(DateTime.Today); + } + if (!this.FimBox.SelectedDate.HasValue) + { + DatePicker fimBox = this.FimBox; + fimBox.SelectedDate = new DateTime?(this.InicioBox.SelectedDate.Value); + } + this.ViewModel.SelectedTile = 4; + await this.Carregar(); + } + + private async void TileRenovacao_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.SelectedTile = 1; + await this.Carregar(); + } + + private async void TileSinistro_OnClick(object sender, RoutedEventArgs e) + { + if (!this.InicioBox2.SelectedDate.HasValue) + { + this.InicioBox2.SelectedDate = new DateTime?(DateTime.Today); + } + if (!this.FimBox2.SelectedDate.HasValue) + { + this.FimBox2.SelectedDate = new DateTime?(DateTime.Today); + } + this.ViewModel.SelectedTile = 5; + await this.Carregar(); + } + + private async void TileTarefas_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.SelectedTile = 3; + await this.Carregar(); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Menus/MenuItensView.cs b/Codemerx/Gestor.Application/Views/Menus/MenuItensView.cs new file mode 100644 index 0000000..b47ecd5 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Menus/MenuItensView.cs @@ -0,0 +1,375 @@ +using Gestor.Application.Actions; +using Gestor.Application.ViewModels; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +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.Media; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Menus +{ + public class MenuItensView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal MenuItem ManterTodosButton; + + internal DataGrid ItemGrid; + + internal DataGridCheckBoxColumn CheckBoxColumn; + + internal DataGridTemplateColumn RenovarColumn; + + internal DataGridTemplateColumn CancelarColumn; + + internal DataGridTemplateColumn SubstituirColumn; + + internal DataGridTemplateColumn ReativarColumn; + + private bool _contentLoaded; + + public MenuItemViewModel ViewModel + { + get; + set; + } + + public MenuItensView(long ramo, ManutencaoItem manutencao = null) + { + base.Tag = "CADASTRO DE ITEM"; + this.ViewModel = new MenuItemViewModel(ramo, manutencao); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + this.ItemGrid.DataContext = base.DataContext; + this.HabilitarManutencao(manutencao); + Gestor.Application.Actions.Actions.ScrollToItem = (Action)Delegate.Remove(Gestor.Application.Actions.Actions.ScrollToItem, new Action(this.ScrollToIndex)); + Gestor.Application.Actions.Actions.ScrollToItem = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.ScrollToItem, new Action(this.ScrollToIndex)); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarItem(""); + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void CancelarItem_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + this.ViewModel.CancelarItem((Item)button.DataContext); + } + + private void ContentLoad() + { + this.ItemGrid.SelectionChanged += new SelectionChangedEventHandler(this.ItemGrid_OnSelectionChanged); + this.ItemGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + } + + public Visual GetDescendantByType(Visual element, Type type) + { + if (element == null) + { + return null; + } + if (element.GetType() == type) + { + return element; + } + Visual descendantByType = null; + FrameworkElement frameworkElement = element as FrameworkElement; + if (frameworkElement != null) + { + frameworkElement.ApplyTemplate(); + } + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++) + { + Visual child = VisualTreeHelper.GetChild(element, i) as Visual; + descendantByType = this.GetDescendantByType(child, type); + if (descendantByType != null) + { + break; + } + } + return descendantByType; + } + + private void HabilitarManutencao(ManutencaoItem manutencao) + { + this.RenovarColumn.Visibility = System.Windows.Visibility.Collapsed; + this.CancelarColumn.Visibility = System.Windows.Visibility.Collapsed; + this.SubstituirColumn.Visibility = System.Windows.Visibility.Collapsed; + this.ReativarColumn.Visibility = System.Windows.Visibility.Collapsed; + this.CheckBoxColumn.Visibility = System.Windows.Visibility.Collapsed; + this.ManterTodosButton.Visibility = System.Windows.Visibility.Collapsed; + if (manutencao == null) + { + return; + } + switch (manutencao.get_Tipo()) + { + case 0: + { + this.RenovarColumn.Visibility = System.Windows.Visibility.Visible; + this.CheckBoxColumn.Visibility = System.Windows.Visibility.Visible; + this.ManterTodosButton.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.EndossoRenovacao = true; + return; + } + case 1: + { + this.RenovarColumn.Visibility = System.Windows.Visibility.Visible; + this.CancelarColumn.Visibility = System.Windows.Visibility.Visible; + this.SubstituirColumn.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.EndossoRenovacao = true; + return; + } + case 2: + { + this.CancelarColumn.Visibility = System.Windows.Visibility.Visible; + this.ReativarColumn.Visibility = System.Windows.Visibility.Visible; + return; + } + default: + { + return; + } + } + } + + [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/menus/menuitensview.xaml", UriKind.Relative)); + } + + private void ItemGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + if (!this.ViewModel.AlterandoSelectedItem) + { + this.ViewModel.SelecionaItem((Item)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + } + + private void ManterItem_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + this.ViewModel.Manter((Item)button.DataContext); + } + + private void ManterItens_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ManterItens(); + } + + private void ReativarItem_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + this.ViewModel.Reativar((Item)button.DataContext); + } + + public void ScrollToIndex() + { + this.ScrollToIndex(this.ItemGrid, this.ItemGrid.SelectedIndex); + } + + public void ScrollToIndex(DataGrid grid, int index) + { + ScrollViewer descendantByType = this.GetDescendantByType(grid, typeof(ScrollViewer)) as ScrollViewer; + int num = (index - 5 > 0 ? index - 5 : 0); + if (descendantByType == null) + { + return; + } + descendantByType.ScrollToVerticalOffset((double)num); + } + + private void SubstituirItem_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + this.ViewModel.Substituir((Item)button.DataContext); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, MenuItensView.AutoCompleteBox_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.ManterTodosButton = (MenuItem)target; + this.ManterTodosButton.Click += new RoutedEventHandler(this.ManterItens_OnClick); + return; + } + case 3: + { + this.ItemGrid = (DataGrid)target; + return; + } + case 4: + { + this.CheckBoxColumn = (DataGridCheckBoxColumn)target; + return; + } + case 5: + { + this.RenovarColumn = (DataGridTemplateColumn)target; + return; + } + case 6: + case 8: + case 10: + { + this._contentLoaded = true; + return; + } + case 7: + { + this.CancelarColumn = (DataGridTemplateColumn)target; + return; + } + case 9: + { + this.SubstituirColumn = (DataGridTemplateColumn)target; + return; + } + case 11: + { + this.ReativarColumn = (DataGridTemplateColumn)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) + { + switch (connectionId) + { + case 6: + { + ((Button)target).Click += new RoutedEventHandler(this.ManterItem_OnClick); + return; + } + case 7: + case 9: + case 11: + { + return; + } + case 8: + { + ((Button)target).Click += new RoutedEventHandler(this.CancelarItem_OnClick); + return; + } + case 10: + { + ((Button)target).Click += new RoutedEventHandler(this.SubstituirItem_OnClick); + return; + } + case 12: + { + ((Button)target).Click += new RoutedEventHandler(this.ReativarItem_OnClick); + return; + } + default: + { + return; + } + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Relatorios/RelatorioView.cs b/Codemerx/Gestor.Application/Views/Relatorios/RelatorioView.cs new file mode 100644 index 0000000..69fdf01 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Relatorios/RelatorioView.cs @@ -0,0 +1,1167 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Actions; +using Gestor.Application.Componentes; +using Gestor.Application.Drawers.Relatorios; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Relatorios; +using Gestor.Application.Views.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Common.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.MalaDireta; +using Gestor.Model.Domain.Relatorios; +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.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; +using Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.Relatorios +{ + public class RelatorioView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal RelatorioViewModel ViewModel; + + internal Image ProgressRing; + + internal ComboBox RelatorioBox; + + internal CurrencyTextBox ValorInicioBox; + + internal CurrencyTextBox ValorFimBox; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal ToggleButton VisualizarRamosVendedoresTooltip; + + internal MenuItem GerarRelatorioButton; + + internal ComboBox RamoBox; + + internal ContentControl ReportControl; + + internal Gestor.Application.Componentes.WebEditor WebEditor; + + internal PopupBox HelpPopup; + + internal TextBlock NaoHaDados; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public RelatorioView(string opcao) + { + this.ViewModel = new RelatorioViewModel(opcao); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + this.ViewModel.Head = string.Concat(Recursos.Usuario.get_Nome(), ", VOCÊ ESTÁ EM RELATÓRIOS"); + Gestor.Application.Actions.Actions.RecarregarRelatorios = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.RecarregarRelatorios, new Action(this.Recarregar)); + } + + private void AbrirInfo_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.InfoVisibility = (this.ViewModel.InfoVisibility == System.Windows.Visibility.Collapsed ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private async Task AbrirTarefa(Tarefa data) + { + Tarefa tarefa; + this.ViewModel.IsEnabled = false; + this.ViewModel.Carregando = true; + while (true) + { + Tarefa tarefa1 = await this.ViewModel.ShowTarefaDialog(data, true, false); + tarefa = tarefa1; + if (tarefa == null) + { + this.ViewModel.IsEnabled = true; + this.ViewModel.Carregando = false; + return; + } + if (tarefa.get_Usuario() == null) + { + tarefa.set_Usuario(tarefa.get_UsuariosVinculados().FirstOrDefault()); + } + List list = tarefa.get_UsuariosVinculados().Select((Usuario x) => { + ResponsavelTarefa responsavelTarefa = new ResponsavelTarefa(); + responsavelTarefa.set_IdTarefa(tarefa.get_Id()); + responsavelTarefa.set_Usuario(x); + return responsavelTarefa; + }).ToList(); + tarefa.set_Responsaveis(list); + tarefa.set_Anotacoes(string.Concat("

", tarefa.get_Anotacoes(), "

")); + Tarefa tarefa2 = tarefa; + List configuracoes = Recursos.Configuracoes; + tarefa2.set_AgendamentoRetroativo(configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 45)); + List> keyValuePairs = tarefa.Validate(); + if (string.IsNullOrWhiteSpace(tarefa.get_Anotacoes())) + { + keyValuePairs.Add(new KeyValuePair("ANOTAÇÕES", "OBRIGATÓRIO")); + } + if (keyValuePairs == null || keyValuePairs.Count == 0) + { + break; + } + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + List tarefas = this.ViewModel.GerarTarefas(tarefa); + if (tarefas == null || tarefas.Count == 0) + { + this.ViewModel.IsEnabled = true; + this.ViewModel.Carregando = false; + await this.ViewModel.ShowMessage("FALHA AO CRIAR TAREFA.", "OK", "", false); + } + else + { + await this.ViewModel.SalvarTarefas(tarefas); + this.ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.", true); + this.ViewModel.Alterar(false); + this.ViewModel.IsEnabled = true; + this.ViewModel.Carregando = false; + } + return; + this.ViewModel.IsEnabled = true; + this.ViewModel.Carregando = false; + } + + private async void Acompanhamento_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Acompanhamento(); + } + + private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdcionarFiltroPersonalizado(); + } + + private void AdicionarRamo_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdicionarRamo(); + } + + private async void Apolice_OnClick(object sender, RoutedEventArgs e) + { + List malaDiretas; + this.ViewModel.Loading(true); + List malaDiretas1 = await this.ViewModel.CriarLista(); + if (malaDiretas1 == null) + { + malaDiretas = new List(); + } + else + { + List malaDiretas2 = malaDiretas1; + malaDiretas = malaDiretas2.Where((MalaDireta x) => { + if (x.get_Apolice().get_Tipo() == 0 && !string.IsNullOrWhiteSpace(x.get_Apolice().get_Apolice())) + { + return true; + } + if (x.get_Apolice().get_Tipo() != 1) + { + return false; + } + return !string.IsNullOrWhiteSpace(x.get_Apolice().get_Endosso()); + }).ToList(); + } + malaDiretas1 = malaDiretas; + if (malaDiretas1.Count != 0) + { + if (Funcoes.IsWindowOpen("ENVIO DE E-MAIL")) + { + Funcoes.Destroy("ENVIO DE E-MAIL"); + } + this.ViewModel.Loading(false); + (new HosterWindow(new MalaDiretaView(malaDiretas1, null, null, 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); + this.ViewModel.Loading(false); + } + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarUsuario(""); + } + + private void AutoCompleteBoxUsuario_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.Filtrar(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 void ConfigurarRelatorio_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ShowDrawer(new ConfiguracaoRelatorio(this.ViewModel), 0, false); + } + + private void ContentLoad() + { + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.SelectedDateChanged += new EventHandler(this.Periodo_OnSelectedDateChanged); + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.FimBox.SelectedDateChanged += new EventHandler(this.Periodo_OnSelectedDateChanged); + this.RelatorioBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoRelatorio_OnSelectionChanged); + } + + private void CopyLink_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button == null || button.DataContext == null) + { + return; + } + AjudaTela dataContext = (AjudaTela)button.DataContext; + string str = ""; + if (dataContext.get_Minuto() > 0 || dataContext.get_Segundo() > 0) + { + str = string.Format("&start={0}", dataContext.get_Minuto() * 60 + dataContext.get_Segundo()); + } + string.Concat(dataContext.get_Link(), str).CopyToClipboard(); + this.ViewModel.ToggleSnackBar("LINK COPIADO", true); + } + + private async void Email_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + List malaDiretas = await this.ViewModel.CriarLista(); + if (malaDiretas == null || malaDiretas.Count == 0) + { + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR.", "OK", "", false); + this.ViewModel.Loading(false); + } + else + { + if (Funcoes.IsWindowOpen("ENVIO DE E-MAIL")) + { + Funcoes.Destroy("ENVIO DE E-MAIL"); + } + this.ViewModel.Loading(false); + (new HosterWindow(new MalaDiretaView(malaDiretas, null, null, null), "ENVIO DE E-MAIL", new double?((double)1200), new double?((double)600), true)).Show(); + } + } + + private async void Etiquetas_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List documentos = await this.ViewModel.CriarListaEtiqueta(); + if (documentos == null || documentos.Count == 0) + { + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR.", "OK", "", false); + this.ViewModel.Loading(false); + } + else if (!Funcoes.IsWindowOpen("ETIQUETAS")) + { + flag = (this.ViewModel.Relatorio == null ? true : this.ViewModel.Relatorio == 1); + bool flag1 = flag; + this.ViewModel.Loading(false); + (new HosterWindow(new EtiquetaView(documentos, flag1), "ETIQUETAS", new double?((double)900), new double?((double)600), false)).Show(); + } + } + + private void ExcluirFiltro_OnClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(chip); + FiltroPersonalizado item = (FiltroPersonalizado)listBox.Items[listBox.Items.IndexOf(chip.DataContext)]; + if (item == null) + { + return; + } + this.ViewModel.FiltroPersonalizadoSelecionado.Remove(item); + this.ViewModel.PesquisaPersonalizada(); + } + + private void ExcluirRamo_onClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + Ramo dataContext = (Ramo)chip.DataContext; + if (dataContext == null) + { + return; + } + this.ViewModel.RemoverRamo(dataContext); + } + + private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Carregando = true; + this.ViewModel.IsEnabled = false; + await this.ViewModel.GerarExcel(); + this.ViewModel.IsEnabled = true; + this.ViewModel.Carregando = false; + } + + private void Extrato_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ExibirExtratoDrawer(); + } + + private void Fechar_OnClick(object sender, RoutedEventArgs e) + { + this.HelpPopup.set_IsPopupOpen(!this.HelpPopup.get_IsPopupOpen()); + } + + private void FecharFiltro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.VisibilityFiltroPersonalizado = (this.ViewModel.VisibilityFiltroPersonalizado == System.Windows.Visibility.Collapsed ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private void FecharFiltroUsuario_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.VisibilityUsuarios = false; + } + + private void FecharInfo_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.InfoVisibility = (this.ViewModel.InfoVisibility == System.Windows.Visibility.Collapsed ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private async void GerarResultados_OnClick(object sender, RoutedEventArgs e) + { + object obj; + bool flag; + GridRelatorio gridRelatorio; + 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) + { + gridRelatorio = null; + return; + } + if (this.ViewModel.Inicio > this.ViewModel.Fim) + { + await this.ViewModel.ShowMessage("A DATA FINAL NÃO PODE SER MENOR QUE A DATA INICIAL DO FILTRO.", "OK", "", false); + } + else if (this.RelatorioBox.Items.Count == 0) + { + await this.ViewModel.ShowMessage("NÃO HÁ RELATÓRIOS QUE VOCÊ POSSA GERAR.", "OK", "", false); + } + else if (this.ViewModel.InicioValor <= this.ViewModel.FimValor) + { + this.ViewModel.Carregando = true; + this.ViewModel.IsEnabled = false; + this.ViewModel.VisibilityHtml = false; + if (this.ViewModel.Report != null) + { + this.ViewModel.Report = null; + } + this.ViewModel.LimparRelatorio(); + if (await this.ViewModel.GerarRelatorio(new DateTime?(this.ViewModel.Inicio), new DateTime?(this.ViewModel.Fim))) + { + this.ReportControl.DataContext = this.ViewModel; + Relatorio relatorio = this.ViewModel.Relatorio; + gridRelatorio = new GridRelatorio(this.ViewModel); + switch (relatorio) + { + case 0: + case 1: + { + this.ViewModel.NovosNegocios = relatorio == 0; + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ClientesAtivosInativosFiltrado; + goto case 22; + } + case 2: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ProducaoFiltrado; + goto case 22; + } + case 3: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ApolicePendenteFiltrado; + goto case 22; + } + case 4: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.RenovacaoFiltrado; + goto case 22; + } + case 5: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ComissaoFiltrado; + goto case 22; + } + case 6: + case 16: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.PendenteFiltrado; + goto case 22; + } + case 7: + case 11: + case 20: + { + this.WebEditor.Initialize(this.ViewModel.HtmlContent); + goto case 22; + } + case 8: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.AuditoriaFiltrado; + goto case 22; + } + case 9: + case 10: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.SinistroFiltrado; + goto case 22; + } + case 12: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.FaturaPendenteFiltrado; + goto case 22; + } + case 13: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ExtratosFiltrado; + goto case 22; + } + case 14: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.MetaSeguradoraFiltrado; + goto case 22; + } + case 15: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.MetaVendedorFiltrado; + goto case 22; + } + case 17: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.LicenciamentoFiltrado; + goto case 22; + } + case 18: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.TarefaFiltrado; + goto case 22; + } + case 19: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.NotaFiscalFiltrado; + goto case 22; + } + case 21: + case 22: + { + gridRelatorio.SinteticoGrid.ItemsSource = this.ViewModel.Sintetic; + RelatorioViewModel viewModel = this.ViewModel; + if (relatorio == 11 || relatorio == 7 || relatorio == 20) + { + obj = null; + } + else + { + obj = gridRelatorio; + } + viewModel.Report = obj; + RelatorioViewModel relatorioViewModel = this.ViewModel; + flag = (relatorio == 11 || relatorio == 7 ? true : relatorio == 20); + relatorioViewModel.VisibilityHtml = flag; + this.NaoHaDados.Visibility = System.Windows.Visibility.Collapsed; + this.ReportControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.RelatorioVisibility = true; + this.ViewModel.IsEnabled = true; + this.ViewModel.ExtratosEnabled = true; + this.ViewModel.Carregando = false; + break; + } + case 23: + { + gridRelatorio.Totalizacao.Visibility = System.Windows.Visibility.Collapsed; + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.LogsEnvioFiltrado; + goto case 22; + } + case 24: + case 25: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.LogUtilizacaoFiltrado; + goto case 22; + } + case 26: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ApoliceCriticaFiltrado; + goto case 22; + } + case 27: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.PlacaFiltrado; + goto case 22; + } + case 28: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.EndossoFiltrado; + goto case 22; + } + case 29: + { + await Funcoes.ContruirLista(gridRelatorio.DataGrid, this.ViewModel.Relatorio); + gridRelatorio.DataGrid.ItemsSource = this.ViewModel.Classificacao; + goto case 22; + } + default: + { + goto case 22; + } + } + } + else + { + this.NaoHaDados.Visibility = System.Windows.Visibility.Visible; + this.ReportControl.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsEnabled = true; + this.ViewModel.ExtratosEnabled = false; + this.ViewModel.Carregando = false; + this.ViewModel.VisibilityHtml = false; + } + } + else + { + await this.ViewModel.ShowMessage("O VALOR FINAL NÃO PODE SER MENOR QUE O VALOR INICIAL DO FILTRO.", "OK", "", false); + } + gridRelatorio = null; + } + + private async void HelpPopup_Opened(object sender, RoutedEventArgs e) + { + await this.ViewModel.CarregarAjuda(); + } + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + flag = (this.ViewModel.VisibilityAgrupamento != System.Windows.Visibility.Visible || this.ViewModel.Agrupamento == null ? this.ViewModel.NotaFiscalPorSeguradora : true); + bool flag1 = flag; + if (flag1) + { + flag1 = await this.ViewModel.ShowMessage("DESEJA SEPARAR GRUPOS POR PÁGINA?", "SIM", "NÃO", false); + } + bool flag2 = flag1; + this.ViewModel.Carregando = true; + this.ViewModel.IsEnabled = false; + bool visibilityHtml = this.ViewModel.VisibilityHtml; + if (visibilityHtml) + { + this.ViewModel.VisibilityHtml = false; + } + await this.ViewModel.Print(flag2); + if (visibilityHtml) + { + this.ViewModel.VisibilityHtml = true; + } + this.ViewModel.Carregando = false; + this.ViewModel.IsEnabled = true; + if (this.ViewModel.Relatorio == 7 || this.ViewModel.Relatorio == 20) + { + this.WebEditor.Visibility = System.Windows.Visibility.Visible; + } + } + + [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/relatorios/relatorioview.xaml", UriKind.Relative)); + } + + private void LimparRelatorio() + { + this.ViewModel.LimparRelatorio(); + if (this.ReportControl == null) + { + return; + } + this.ReportControl.Content = null; + this.ReportControl.DataContext = null; + } + + private void MaisFiltros_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.Relatorio == 24 || this.ViewModel.Relatorio == 25) + { + this.ViewModel.VisibilityUsuarios = true; + return; + } + this.ViewModel.Seguradoras = new List(this.ViewModel.Seguradoras); + this.ViewModel.Ramos = new List(this.ViewModel.Ramos); + this.ViewModel.Vendedores = new List(this.ViewModel.Vendedores); + this.ViewModel.Produtos = new List(this.ViewModel.Produtos); + this.ViewModel.Estipulantes = new List(this.ViewModel.Estipulantes); + this.ViewModel.TipoSeguros = new List(this.ViewModel.TipoSeguros); + this.ViewModel.RecheckAllLists(); + this.ViewModel.ShowDrawer(new Gestor.Application.Drawers.Relatorios.FiltroRelatorio(this.ViewModel, this.ViewModel.Relatorio), 0, false); + } + + private void OcultarAjuda_OnClick(object sender, RoutedEventArgs e) + { + this.HelpPopup.Visibility = System.Windows.Visibility.Collapsed; + } + + private void Periodo_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + this.LimparRelatorio(); + } + + private async void PlanilhaCompleta_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Carregando = true; + await this.ViewModel.GerarPlanilhaCompleta(); + this.ViewModel.Carregando = false; + } + + private void Play_Click(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button == null || button.DataContext == null) + { + return; + } + AjudaTela dataContext = (AjudaTela)button.DataContext; + string str = ""; + if (dataContext.get_Minuto() > 0 || dataContext.get_Segundo() > 0) + { + str = string.Format("&start={0}", dataContext.get_Minuto() * 60 + dataContext.get_Segundo()); + } + Process.Start(string.Concat(dataContext.get_Link(), str)); + } + + private void Protocolo_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.MostrarProtocolo(); + } + + private void Recarregar(string sessao) + { + if (this.ViewModel.Sessao != sessao) + { + return; + } + this.GerarResultados_OnClick(this.GerarRelatorioButton, new RoutedEventArgs()); + } + + private void ReloadWindow_Click(object sender, RoutedEventArgs e) + { + this.LimparRelatorio(); + } + + private async void ShowHelp(Relatorio relatorio) + { + if (await this.ViewModel.VerificarRestricao(61, true, false)) + { + bool flag = true; + if (this.HelpPopup != null) + { + this.HelpPopup.Visibility = (flag ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + } + else + { + this.HelpPopup.Visibility = System.Windows.Visibility.Collapsed; + } + } + + private async void Sincronizar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Carregando = true; + this.ViewModel.IsEnabled = false; + await this.ViewModel.Sincronizar(); + this.ViewModel.IsEnabled = true; + this.ViewModel.Carregando = false; + } + + private async void Sintetico_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.Relatorio == 7 || this.ViewModel.Agrupamento != null || this.ViewModel.Relatorio == 11) + { + await this.ViewModel.Sintetico(); + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR UM AGRUPAMENTO PARA SINTETIZAR OS RESULTADOS.", "OK", "", false); + } + } + + [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 = (Image)target; + return; + } + case 2: + { + this.RelatorioBox = (ComboBox)target; + this.RelatorioBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoRelatorio_OnSelectionChanged); + return; + } + case 3: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirInfo_Click); + return; + } + case 4: + { + this.ValorInicioBox = (CurrencyTextBox)target; + return; + } + case 5: + { + this.ValorFimBox = (CurrencyTextBox)target; + return; + } + case 6: + { + this.InicioBox = (DatePicker)target; + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 7: + { + this.FimBox = (DatePicker)target; + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 8: + { + this.VisualizarRamosVendedoresTooltip = (ToggleButton)target; + this.VisualizarRamosVendedoresTooltip.Click += new RoutedEventHandler(this.ReloadWindow_Click); + return; + } + case 9: + { + this.GerarRelatorioButton = (MenuItem)target; + this.GerarRelatorioButton.Click += new RoutedEventHandler(this.GerarResultados_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExportarExcel_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.PlanilhaCompleta_OnClick); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Extrato_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MaisFiltros_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ConfigurarRelatorio_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Sintetico_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Tarefas_OnClick); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Etiquetas_OnClick); + return; + } + case 19: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Acompanhamento_OnClick); + return; + } + case 20: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Email_OnClick); + return; + } + case 21: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Apolice_OnClick); + return; + } + case 22: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Protocolo_OnClick); + return; + } + case 23: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Sincronizar_OnClick); + return; + } + case 24: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.FecharFiltro_OnClick); + return; + } + case 25: + { + ((Button)target).Click += new RoutedEventHandler(this.FecharFiltro_OnClick); + return; + } + case 26: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 27: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 28: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltro_OnClick); + return; + } + case 29: + case 32: + case 38: + case 39: + { + this._contentLoaded = true; + return; + } + case 30: + { + this.RamoBox = (ComboBox)target; + return; + } + case 31: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarRamo_OnClick); + return; + } + case 33: + { + this.ReportControl = (ContentControl)target; + return; + } + case 34: + { + this.WebEditor = (Gestor.Application.Componentes.WebEditor)target; + return; + } + case 35: + { + this.HelpPopup = (PopupBox)target; + this.HelpPopup.add_Opened(new RoutedEventHandler(this.HelpPopup_Opened)); + return; + } + case 36: + { + ((Button)target).Click += new RoutedEventHandler(this.OcultarAjuda_OnClick); + return; + } + case 37: + { + ((Button)target).Click += new RoutedEventHandler(this.Fechar_OnClick); + return; + } + case 40: + { + ((Button)target).Click += new RoutedEventHandler(this.FecharFiltroUsuario_OnClick); + return; + } + case 41: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, RelatorioView.AutoCompleteBoxUsuario_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 42: + { + ((Button)target).Click += new RoutedEventHandler(this.FecharInfo_Click); + return; + } + case 43: + { + this.NaoHaDados = (TextBlock)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 <= 32) + { + if (connectionId == 29) + { + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_OnClick)); + return; + } + if (connectionId != 32) + { + return; + } + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirRamo_onClick)); + return; + } + if (connectionId == 38) + { + ((Button)target).Click += new RoutedEventHandler(this.CopyLink_OnClick); + return; + } + if (connectionId != 39) + { + return; + } + ((Button)target).Click += new RoutedEventHandler(this.Play_Click); + } + + private async void Tarefas_OnClick(object sender, RoutedEventArgs e) + { + if (!await this.ViewModel.ValidateTarefa()) + { + Tarefa tarefa = new Tarefa(); + tarefa.set_Entidade(1); + tarefa.set_Titulo(EnumHelper.GetDescription(this.ViewModel.Relatorio)); + tarefa.set_Usuario(Recursos.Usuario); + tarefa.set_Agendamento(Funcoes.GetNetworkTime()); + await this.AbrirTarefa(tarefa); + } + } + + private void TipoRelatorio_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + this.LimparRelatorio(); + this.VisualizarRamosVendedoresTooltip.IsChecked = new bool?(false); + Relatorio relatorio = this.ViewModel.Relatorio; + if (this.NaoHaDados != null) + { + this.NaoHaDados.Visibility = System.Windows.Visibility.Collapsed; + } + this.ShowHelp(relatorio); + switch (relatorio) + { + case 0: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 1: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 2: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Visible; + return; + } + case 3: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 4: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Visible; + return; + } + case 5: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 6: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 7: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 8: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 9: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 10: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 11: + { + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + this.ViewModel.Info = ""; + this.ViewModel.InfoVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 12: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + { + return; + } + case 13: + { + this.ViewModel.VisibilityAgrupamento = System.Windows.Visibility.Collapsed; + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + case 23: + { + this.ViewModel.VisibilityAgrupamento = System.Windows.Visibility.Collapsed; + this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed; + return; + } + default: + { + return; + } + } + } + + private async void ToggleComparativo_OnChecked(object sender, RoutedEventArgs e) + { + if (this.ViewModel.Relatorio == 11) + { + this.ViewModel.Carregando = true; + this.ViewModel.IsEnabled = false; + RelatorioViewModel viewModel = this.ViewModel; + string str = await this.ViewModel.GerarHtml(true, false, null, false); + viewModel.HtmlContent = str; + viewModel = null; + this.WebEditor.Initialize(this.ViewModel.HtmlContent); + this.ViewModel.IsEnabled = true; + this.ViewModel.Carregando = false; + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Relatorios/SinteticoView.cs b/Codemerx/Gestor.Application/Views/Relatorios/SinteticoView.cs new file mode 100644 index 0000000..9ae559f --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Relatorios/SinteticoView.cs @@ -0,0 +1,509 @@ +using Gestor.Application; +using Gestor.Application.Helpers; +using Gestor.Application.Model; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Relatorios; +using Gestor.Model.Domain.Relatorios; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Interop; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Shapes; +using System.Windows.Shell; + +namespace Gestor.Application.Views.Relatorios +{ + public class SinteticoView : Window, IComponentConnector, IStyleConnector + { + internal SinteticoViewModel ViewModel; + + private bool _buttonClickable; + + private ListSortDirection _ascending; + + private string _member; + + internal System.Windows.Shell.WindowChrome WindowChrome; + + internal TextBlock SubTitulo; + + internal Grid MinimizeButton; + + internal Grid MaximizeButton; + + internal Grid CloseButton; + + internal System.Windows.Controls.TabControl Tab; + + private bool _contentLoaded; + + public DateTime? DateFinal + { + get; + set; + } + + public DateTime? DateStart + { + get; + set; + } + + public SinteticoView(List sintetico, string relatorio, DateTime? inicio, DateTime? fim) + { + DateTime valueOrDefault; + string str; + string str1; + this.ViewModel = new SinteticoViewModel(sintetico, relatorio); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + TextBlock subTitulo = this.SubTitulo; + if (inicio.HasValue) + { + valueOrDefault = inicio.GetValueOrDefault(); + str = valueOrDefault.ToString("dd/MM/yyyy"); + } + else + { + str = null; + } + if (fim.HasValue) + { + valueOrDefault = fim.GetValueOrDefault(); + str1 = valueOrDefault.ToString("dd/MM/yyyy"); + } + else + { + str1 = null; + } + subTitulo.Text = string.Concat("VALORES BASEADOS NA RELAÇÃO EMITIDA ANTERIORMENTE - INICIO: ", str, " FIM: ", str1); + DateTime? nullable = inicio; + this.DateStart = new DateTime?((nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.MinValue)); + nullable = fim; + this.DateFinal = new DateTime?((nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.MinValue)); + this.MinimizeButton.MouseEnter += new System.Windows.Input.MouseEventHandler(SinteticoView.TopControls_OnMouseEnter); + this.MinimizeButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave); + this.MaximizeButton.MouseEnter += new System.Windows.Input.MouseEventHandler(SinteticoView.TopControls_OnMouseEnter); + this.MaximizeButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave); + this.CloseButton.MouseEnter += new System.Windows.Input.MouseEventHandler(SinteticoView.TopControls_OnMouseEnter); + this.CloseButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave); + } + + private void AjustaNome(SinteticoSource source) + { + foreach (ValorSintetico listum in source.Lista) + { + if (string.IsNullOrEmpty(listum.get_Porcentagem()) || listum.get_Indice().Contains(listum.get_Porcentagem())) + { + continue; + } + ValorSintetico valorSintetico = listum; + valorSintetico.set_Indice(string.Concat(valorSintetico.get_Indice(), " - ", listum.get_Porcentagem(), "%")); + } + } + + public void CloseButton_Click() + { + base.Close(); + } + + private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e) + { + System.Windows.Controls.DataGrid dataGrid = (System.Windows.Controls.DataGrid)sender; + if (dataGrid == null || dataGrid.DataContext == null) + { + return; + } + if (this._member != e.Column.SortMemberPath) + { + this._ascending = ListSortDirection.Ascending; + } + else + { + this._ascending = (this._ascending == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending); + } + ObservableCollection itemsSource = dataGrid.ItemsSource as ObservableCollection; + if (itemsSource == null) + { + return; + } + IQueryable valorSinteticos = itemsSource.AsQueryable(); + List list = ( + from x in (this._ascending == ListSortDirection.Ascending ? valorSinteticos.OrderBy(e.Column.SortMemberPath).ToList() : valorSinteticos.OrderByDescending(e.Column.SortMemberPath).ToList()) + orderby x.get_Indice() == "TOTAL" + select x).ToList(); + itemsSource.Clear(); + foreach (ValorSintetico valorSintetico in list) + { + itemsSource.Add(valorSintetico); + } + this.ViewModel.OnPropertyChanged("DataGrid_Sorting"); + this._member = e.Column.SortMemberPath; + e.Handled = true; + } + + private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e) + { + System.Windows.Controls.MenuItem menuItem = (System.Windows.Controls.MenuItem)sender; + if (menuItem != null && menuItem.DataContext != null) + { + SinteticoSource dataContext = (SinteticoSource)menuItem.DataContext; + await this.ViewModel.GerarExcel(dataContext); + } + } + + private async void ExportarPdf_OnClick(object sender, RoutedEventArgs e) + { + System.Windows.Controls.MenuItem menuItem = (System.Windows.Controls.MenuItem)sender; + if (menuItem != null && menuItem.DataContext != null) + { + SinteticoSource dataContext = (SinteticoSource)menuItem.DataContext; + await this.ViewModel.GerarPdf(dataContext); + } + } + + [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)] + private static extern bool GetCursorPos(out MainWindow.Point lpPoint); + + [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)] + private static extern bool GetMonitorInfo(IntPtr hMonitor, SinteticoView.Monitorinfo lpmi); + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + System.Windows.Controls.MenuItem menuItem = (System.Windows.Controls.MenuItem)sender; + if (menuItem != null && menuItem.DataContext != null) + { + SinteticoSource dataContext = (SinteticoSource)menuItem.DataContext; + DateTime? dateStart = this.DateStart; + DateTime minValue = DateTime.MinValue; + flag = (dateStart.HasValue ? dateStart.GetValueOrDefault() != minValue : true); + if (flag) + { + dataContext.DateStart = this.DateStart; + dataContext.DateFinal = this.DateFinal; + } + await this.ViewModel.Print(dataContext); + } + } + + private async void ImprimirUnicaPagina_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + System.Windows.Controls.MenuItem menuItem = (System.Windows.Controls.MenuItem)sender; + if (menuItem != null && menuItem.DataContext != null) + { + SinteticoSource dataContext = (SinteticoSource)menuItem.DataContext; + DateTime? dateStart = this.DateStart; + DateTime minValue = DateTime.MinValue; + flag = (dateStart.HasValue ? dateStart.GetValueOrDefault() != minValue : true); + if (flag) + { + dataContext.DateStart = this.DateStart; + dataContext.DateFinal = this.DateFinal; + } + await this.ViewModel.PrintUnica(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/relatorios/sinteticoview.xaml", UriKind.Relative)); + } + + public void MaximizeButton_Click() + { + base.WindowState = (base.WindowState == System.Windows.WindowState.Normal ? System.Windows.WindowState.Maximized : System.Windows.WindowState.Normal); + } + + public void MinimizeButton_Click() + { + base.WindowState = System.Windows.WindowState.Minimized; + } + + [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false, SetLastError=true)] + private static extern IntPtr MonitorFromPoint(MainWindow.Point pt, SinteticoView.MonitorOptions dwFlags); + + protected sealed override void OnStateChanged(EventArgs e) + { + object obj; + base.BorderThickness = new Thickness((double)(base.WindowState != System.Windows.WindowState.Maximized)); + System.Windows.Shell.WindowChrome windowChrome = this.WindowChrome; + if (base.WindowState == System.Windows.WindowState.Maximized) + { + obj = null; + } + else + { + obj = 4; + } + windowChrome.ResizeBorderThickness = new Thickness((double)obj); + this.WindowChrome.CaptionHeight = (double)((base.WindowState == System.Windows.WindowState.Maximized ? 33 : 30)); + this.ViewModel.MaximizeRestore = (base.WindowState == System.Windows.WindowState.Maximized ? Geometry.Parse((string)System.Windows.Application.Current.Resources["Restore"]) : Geometry.Parse((string)System.Windows.Application.Current.Resources["Maximize"])); + base.OnStateChanged(e); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((SinteticoView)target).Initialized += new EventHandler(this.Window_OnInitialized); + return; + } + case 2: + { + this.WindowChrome = (System.Windows.Shell.WindowChrome)target; + return; + } + case 3: + { + this.SubTitulo = (TextBlock)target; + return; + } + case 4: + { + this.MinimizeButton = (Grid)target; + this.MinimizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.MinimizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 5: + { + this.MaximizeButton = (Grid)target; + this.MaximizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.MaximizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 6: + { + this.CloseButton = (Grid)target; + this.CloseButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.CloseButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 7: + { + this.Tab = (System.Windows.Controls.TabControl)target; + 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 8: + { + ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 9: + { + ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.ExportarPdf_OnClick); + return; + } + case 10: + { + ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.ExportarExcel_OnClick); + return; + } + case 11: + { + ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.ImprimirUnicaPagina_OnClick); + return; + } + case 12: + { + ((System.Windows.Controls.DataGrid)target).Sorting += new DataGridSortingEventHandler(this.DataGrid_Sorting); + return; + } + default: + { + return; + } + } + } + + private static void TopControls_OnMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) + { + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray)); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeave(object sender, System.Windows.Input.MouseEventArgs e) + { + this._buttonClickable = false; + ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + this._buttonClickable = true; + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.DimGray)); + } + + private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + if (this._buttonClickable) + { + MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click")); + if (method == null) + { + return; + } + method.Invoke(this, null); + } + } + + private void Window_OnInitialized(object sender, EventArgs e) + { + WindowInteropHelper windowInteropHelper = new WindowInteropHelper(this); + windowInteropHelper.EnsureHandle(); + HwndSource hwndSource = HwndSource.FromHwnd(windowInteropHelper.Handle); + if (hwndSource == null) + { + return; + } + hwndSource.AddHook(new HwndSourceHook(this.WindowProc)); + } + + private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) + { + if (msg == 36) + { + this.WmGetMinMaxInfo(lParam); + } + return IntPtr.Zero; + } + + private void WmGetMinMaxInfo(IntPtr lParam) + { + MainWindow.Point point; + System.Drawing.Rectangle workingArea = Screen.FromHandle((new WindowInteropHelper(this)).Handle).WorkingArea; + base.MaxHeight = (double)workingArea.Height; + SinteticoView.GetCursorPos(out point); + IntPtr intPtr = SinteticoView.MonitorFromPoint(new MainWindow.Point(0, 0), SinteticoView.MonitorOptions.MonitorDefaulttoprimary); + SinteticoView.Monitorinfo monitorinfo = new SinteticoView.Monitorinfo(); + if (!SinteticoView.GetMonitorInfo(intPtr, monitorinfo)) + { + return; + } + IntPtr intPtr1 = SinteticoView.MonitorFromPoint(point, SinteticoView.MonitorOptions.MonitorDefaulttonearest); + SinteticoView.Minmaxinfo structure = (SinteticoView.Minmaxinfo)Marshal.PtrToStructure(lParam, typeof(SinteticoView.Minmaxinfo)); + if (!intPtr.Equals(intPtr1)) + { + structure.ptMaxPosition.X = monitorinfo.rcMonitor.Left; + structure.ptMaxPosition.Y = monitorinfo.rcMonitor.Top; + structure.ptMaxSize.X = monitorinfo.rcMonitor.Right - monitorinfo.rcMonitor.Left; + structure.ptMaxSize.Y = monitorinfo.rcMonitor.Bottom - monitorinfo.rcMonitor.Top; + } + else + { + structure.ptMaxPosition.X = monitorinfo.rcWork.Left; + structure.ptMaxPosition.Y = monitorinfo.rcWork.Top; + structure.ptMaxSize.X = monitorinfo.rcWork.Right - monitorinfo.rcWork.Left; + structure.ptMaxSize.Y = monitorinfo.rcWork.Bottom - monitorinfo.rcWork.Top; + } + Marshal.StructureToPtr(structure, lParam, true); + } + + private struct Minmaxinfo + { + private readonly MainWindow.Point ptReserved; + + public SinteticoView.Point ptMaxSize; + + public SinteticoView.Point ptMaxPosition; + + private readonly MainWindow.Point ptMinTrackSize; + + private readonly MainWindow.Point ptMaxTrackSize; + } + + private class Monitorinfo + { + private readonly int cbSize; + + public readonly SinteticoView.Rect rcMonitor; + + public readonly SinteticoView.Rect rcWork; + + private readonly int dwFlags; + + public Monitorinfo() + { + } + } + + private enum MonitorOptions : uint + { + MonitorDefaulttoprimary = 1, + MonitorDefaulttonearest = 2 + } + + public struct Point + { + public int X; + + public int Y; + + public Point(int x, int y) + { + this.X = x; + this.Y = y; + } + } + + public struct Rect + { + public int Left; + + public int Top; + + public int Right; + + public int Bottom; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/ApoliceView.cs b/Codemerx/Gestor.Application/Views/Seguros/ApoliceView.cs new file mode 100644 index 0000000..60dd854 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/ApoliceView.cs @@ -0,0 +1,3609 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Actions; +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Configuracoes; +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.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; +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.Seguros +{ + public class ApoliceView : BaseUserControl, IComponentConnector, IStyleConnector + { + private string _vencimentoCartaoOld = ""; + + private bool _calculando; + + internal DockPanel MenuApolice; + + internal MenuItem IncluirpoliceButton; + + internal MenuItem AlterarApoliceButton; + + internal MenuItem SalvarApoliceButton; + + internal MenuItem CancelarApoliceButton; + + internal MenuItem ExcluirpoliceButton; + + internal Button ButtonImportado; + + internal MenuItem ArquivoDigitalButton; + + internal MenuItem MaisOpcoesButton; + + internal MenuItem EditarParcelasButton; + + internal WrapPanel ApoliceControl1; + + internal ComboBox ProdutoBox; + + internal ComboBox SituacaoBox; + + internal ComboBox NegocioCorretoraBox; + + internal ComboBox TipoRecebimentoBox; + + internal ComboBox TipoEndossoBox; + + internal TextBox ApoliceBox; + + internal TextBox EndossoBox; + + internal DatePicker Vigencia2Box; + + internal DatePicker TransmissaoBox; + + internal DatePicker EmissaoBox; + + internal ComboBox FormaPagamentoBox; + + internal Grid PremiosBox; + + internal ToggleButton AdicionalBox; + + internal CustomIsReadOnlyControl Comissao; + + internal CurrencyTextBox ComissaoBox; + + internal CurrencyTextBox PremioLiquidoBox; + + internal CurrencyTextBox PremioAdicionalBox; + + internal CurrencyTextBox IofBox; + + internal CurrencyTextBox DiferencaBox; + + internal CurrencyTextBox PremioTotalBox; + + internal CurrencyTextBox ParcelasBox; + + internal CustomIsReadOnlyControl ComissaoOriginal; + + internal CustomIsReadOnlyControl Gerada; + + internal CustomIsReadOnlyControl Recebida; + + internal CustomIsReadOnlyControl Pendente; + + internal CustomIsReadOnlyControl Repasse; + + internal Menu BaixarParcelaButton; + + internal Menu SalvarParcelaButton; + + internal StackPanel EditarParcelasFields; + + internal CustomItemValidation TipoParcelaField; + + internal ComboBox TipoParcelaBox; + + internal CustomItemControl QuantidadeFaturaField; + + internal CurrencyTextBox QuantidadeFaturaBox; + + internal CustomItemValidation FaturaField; + + internal TextBox FaturaBox; + + internal CustomItemValidation VigenciaInicialField; + + internal CustomItemValidation VigenciaFinalField; + + internal DatePicker VigenciaFinalParcelaBox; + + internal CustomItemValidation VencimentoField; + + internal CustomItemControl EmissaoField; + + internal DatePicker EmissaoParcelaBox; + + internal CustomItemValidation PercentualComissaoField; + + internal CurrencyTextBox ComissaoParcelaBox; + + internal TextBlock ComissaoIcon; + + internal CustomItemControl ValorLiquidoField; + + internal CurrencyTextBox ValorLiquidoParcelaBox; + + internal CustomItemControl ValorField; + + internal CurrencyTextBox ValorParcelaBox; + + internal CustomItemValidation RecebimentoField; + + internal DatePicker RecebimentoParcelaBox; + + internal CustomItemControl QuitacaoField; + + internal CustomItemControl DataControleParcelaField; + + internal CustomItemValidation CreditoField; + + internal DatePicker CreditoParcelaBox; + + internal CustomItemValidation ValorRealizadoField; + + internal CurrencyTextBox ValorRealizadoParcelaBox; + + internal CustomItemValidation ValorComissaoField; + + internal CurrencyTextBox ValorComissaoParcelaBox; + + internal WrapPanel ImpostosField; + + internal CustomItemControl PorcentagemIrField; + + internal CurrencyTextBox PorcentagemIrBox; + + internal CustomItemControl ValorIrField; + + internal CurrencyTextBox ValorIrBox; + + internal CustomItemControl PorcentagemIssField; + + internal CurrencyTextBox PorcentagemIssBox; + + internal CustomItemControl ValorIssField; + + internal CurrencyTextBox ValorIssBox; + + internal CustomItemControl ValorOutrosField; + + internal CurrencyTextBox ValorOutrosBox; + + internal CustomItemControl ValorDescontoField; + + internal CurrencyTextBox ValorDescontoBox; + + internal CustomItemControl ValorComDescField; + + internal CurrencyTextBox ValorComDescBox; + + internal DataGrid ParcelaGrid; + + internal DataGridTextColumn ParcelaColumn; + + internal DataGridTextColumn FaturaColumn; + + internal DataGridTextColumn VigenciaInicialColumn; + + internal DataGridTextColumn VigenciaFinalColumn; + + internal DataGridTextColumn ParcelasComissaoColumn; + + internal DataGridTextColumn ParcelasValorComissaoColumn; + + internal DataGridTextColumn ParcelasValorComissaoDescColumn; + + internal DataGridTemplateColumn MaisInformacoesColumn; + + internal MenuItem EditarVendedorButton; + + internal MenuItem SalvarVendedorButton; + + internal MenuItem CancelarVendedorButton; + + internal WrapPanel EditarVendedorFields; + + internal ToggleButton CoCorretagemToogle; + + internal ComboBox TipoVendedorBox; + + internal ComboBox VendedorBox; + + internal CustomItemValidation ComissaoNovoBox; + + internal ComboBox ComissaoNovoComboBox; + + internal CustomItemValidation ComissaoRenovacaoBox; + + internal ComboBox ComissaoRenovacaoComboBox; + + internal CurrencyTextBox ValorRepasseBox; + + internal TextBox FormaRecebidaBox; + + internal TextBox FormaIncidenciaBox; + + internal DataGrid VendedorGrid; + + internal DataGridTextColumn VendedorGridColumn; + + internal DataGridTextColumn PagamentosPorcentagemRepasseColumn; + + internal DataGridTextColumn PagamentosValorRepasseColumn; + + internal TextBox ProponenteBox; + + internal AutoCompleteBox AutoCompleteBanco; + + internal TextBox AgenciaBox; + + internal TextBox ContaBox; + + internal TextBox CartaoBox; + + internal ComboBox BandeiraBox; + + internal TextBox VencimentoCartaoBox; + + internal DatePicker DataBox; + + internal TextBox PastaBox; + + private bool _contentLoaded; + + private Gestor.Model.Common.AcessoApolice AcessoApolice + { + get; + } + + private int EditarParcelaTipo + { + get; + set; + } + + public ApoliceViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ApoliceView(Documento documentoSelecionado, bool lockInsert = false, bool invoke = true, Gestor.Model.Common.AcessoApolice acesso = 0, long idparcela = 0L, bool consultaTela = false) + { + string str; + base.Tag = "CADASTRO DE APÓLICE"; + this.AcessoApolice = acesso; + Gestor.Application.Actions.Actions.Redimencionar = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.Redimencionar, new Action(this.Redimencionar)); + this.ViewModel = new ApoliceViewModel(acesso, documentoSelecionado, invoke, idparcela); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + this.ParcelaGrid.DataContext = this.ViewModel; + if (consultaTela) + { + this.ExcluirpoliceButton.IsEnabled = false; + } + this.Restricao(false); + if (lockInsert) + { + this.IncluirpoliceButton.IsEnabled = false; + } + if (documentoSelecionado != null) + { + if (documentoSelecionado.get_Tipo() == 0 && string.IsNullOrEmpty(documentoSelecionado.get_Apolice())) + { + str = string.Concat("PROPOSTA \"", documentoSelecionado.get_Proposta(), "\""); + } + else if (documentoSelecionado.get_Tipo() != 0 || string.IsNullOrEmpty(documentoSelecionado.get_Apolice())) + { + str = (string.IsNullOrEmpty(documentoSelecionado.get_Endosso()) ? string.Concat("PROPOSTA DE ENDOSSO \"", documentoSelecionado.get_PropostaEndosso(), "\"") : string.Concat("ENDOSSO \"", documentoSelecionado.get_Endosso(), "\"")); + } + else + { + str = string.Concat("APÓLICE \"", documentoSelecionado.get_Apolice(), "\""); + } + string str1 = str; + this.ViewModel.RegistrarAcao(string.Concat("ACESSOU ", str1), documentoSelecionado.get_Id(), new TipoTela?(2), this.ViewModel.GerarObs(documentoSelecionado)); + } + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + FiltroArquivoDigital filtroArquivoDigital = null; + string name = ""; + Button button = sender as Button; + if (button != null) + { + name = button.Name; + } + else + { + MenuItem menuItem = sender as MenuItem; + if (menuItem != null) + { + name = menuItem.Name; + } + } + if (name != "ArquivoDigitalButton") + { + if (name == "Parcela") + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 3).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital1 = new FiltroArquivoDigital(); + filtroArquivoDigital1.set_Id(this.ViewModel.SelectedParcela.get_Id()); + filtroArquivoDigital1.set_IdApolice(this.ViewModel.SelectedParcela.get_Documento().get_Id()); + filtroArquivoDigital1.set_Tipo(3); + filtroArquivoDigital1.set_Parente(this.ViewModel.SelectedParcela); + filtroArquivoDigital = filtroArquivoDigital1; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)3), "."), "OK", "", false); + return; + } + } + } + else if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital2 = new FiltroArquivoDigital(); + filtroArquivoDigital2.set_Id(this.ViewModel.SelectedDocumento.get_Id()); + filtroArquivoDigital2.set_Tipo(2); + filtroArquivoDigital2.set_Parente(this.ViewModel.SelectedDocumento); + filtroArquivoDigital = filtroArquivoDigital2; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)2), "."), "OK", "", false); + return; + } + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + } + + private async void AbrirImportacao() + { + await this.ViewModel.Importacao(); + ((System.Windows.Controls.ToolTip)this.ButtonImportado.ToolTip).PlacementTarget = this.ButtonImportado; + ((System.Windows.Controls.ToolTip)this.ButtonImportado.ToolTip).Placement = PlacementMode.Center; + ((System.Windows.Controls.ToolTip)this.ButtonImportado.ToolTip).IsOpen = true; + await Task.Run(async () => await Task.Delay(5000)); + ((System.Windows.Controls.ToolTip)this.ButtonImportado.ToolTip).IsOpen = false; + } + + private void AbrirInfo_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirInfo(); + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Id() != 0) + { + this.ViewModel.AbrirLog(2, this.ViewModel.SelectedDocumento.get_Id()); + } + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Id() != 0) + { + this.ViewModel.AbrirLogEmail(2, this.ViewModel.SelectedDocumento.get_Id()); + } + } + + private void AbrirLogEmailPF_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedParcela != null && this.ViewModel.SelectedParcela.get_Id() != 0) + { + this.ViewModel.AbrirLogEmail(5, this.ViewModel.SelectedParcela.get_Id()); + } + } + + private void AbrirLogParcelaAntigo_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogAntigoParcela(); + } + + private async void AbrirLogParcelas_OnClick(object sender, RoutedEventArgs e) + { + bool count; + ApoliceView apoliceView = this; + if (apoliceView.ViewModel.SelectedDocumento != null) + { + ApoliceViewModel viewModel = apoliceView.ViewModel; + if (viewModel != null) + { + count = viewModel.Parcelas.Count > 0; + } + else + { + count = false; + } + if (count) + { + List nums = new List(); + apoliceView.ViewModel.Parcelas.ToList().ForEach((Parcela x) => nums.Add(x.get_Id())); + apoliceView.ViewModel.AbrirLogParcela(nums, apoliceView.ViewModel.SelectedDocumento.get_Id(), 0); + } + } + } + + private void AbrirLogParcelaSelecionada_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedParcela != null && this.ViewModel.SelectedParcela.get_Id() != 0) + { + List nums = new List() + { + this.ViewModel.SelectedParcela.get_Id() + }; + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Id() != 0) + { + this.ViewModel.AbrirLogParcela(nums, this.ViewModel.SelectedDocumento.get_Id(), this.ViewModel.SelectedParcela.get_NumeroParcela()); + } + } + } + + private void AbrirLogTrocaCliente_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Id() != 0) + { + this.ViewModel.AbrirLog(41, this.ViewModel.SelectedDocumento.get_Id()); + } + } + + private void AbrirLogVendedor_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedParcela != null && this.ViewModel.SelectedParcela.get_Id() != 0) + { + this.ViewModel.AbrirLog(37, this.ViewModel.SelectedParcela.get_Id()); + } + } + + private async void AbrirPerfil_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.VerificarPermissao(32, false)) + { + if (this.ViewModel.SelectedDocumento.get_Controle().get_Ramo().get_Id() != (long)5) + { + (new HosterWindow(new PerfilEmpresaView(this.ViewModel.SelectedDocumento.get_Controle()), "QUESTIONÁRIO EMPRESA", new double?((double)900), new double?((double)500), false)).ShowDialog(); + } + else + { + (new HosterWindow(new PerfilView(this.ViewModel.SelectedDocumento.get_Controle()), "PERFIL", new double?((double)900), new double?((double)500), false)).ShowDialog(); + } + this.ViewModel.Alterar(false); + } + } + + private async Task AbrirProspeccao(Prospeccao data) + { + do + { + Label1: + if (await this.ViewModel.ShowProspeccaoDialog(data) != null) + { + List> keyValuePairs = await this.ViewModel.SalvarProspeccao(data); + if (keyValuePairs == null || keyValuePairs.Count == 0) + { + this.ViewModel.ToggleSnackBar("PROSPECÇÃO SALVA COM SUCESSO.", true); + return; + } + else + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + goto Label1; + } + } + else + { + } + } + while (!await this.ViewModel.ShowMessage("DESEJA REALMENTE NÃO CADASTRAR UMA PROSPECÇÃO PARA ESSE DOCUMENTO?", "SIM", "NÃO", false)); + } + + private void AcessarApolice(Gestor.Model.Common.AcessoApolice acesso) + { + if (acesso == 2) + { + this.Endossar_OnClick(this, new RoutedEventArgs()); + this.Restricao(true); + return; + } + if (acesso != 3) + { + return; + } + this.Renovar_OnClick(this, new RoutedEventArgs()); + this.Restricao(true); + } + + private void AdicionalBox_OnChecked(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + this.AlteracaoDePremio_LostFocus(this.PremioAdicionalBox, new RoutedEventArgs()); + } + + private void AdicionarCoCorretagem_OnClick(object sender, RoutedEventArgs e) + { + bool valueOrDefault; + bool selectedItem; + bool flag; + ToggleButton toggleButton = (ToggleButton)sender; + if (toggleButton != null) + { + valueOrDefault = toggleButton.IsChecked.GetValueOrDefault(); + } + else + { + valueOrDefault = false; + } + bool flag1 = valueOrDefault; + ComboBox comissaoNovoComboBox = this.ComissaoNovoComboBox; + if (comissaoNovoComboBox != null) + { + selectedItem = comissaoNovoComboBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (selectedItem) + { + this.ComissaoNovoComboBox.SelectedItem = null; + } + if (flag1) + { + this.TipoVendedorBox.SelectedIndex = 0; + } + else if (this.TipoVendedorBox.SelectedItem != null) + { + this.TipoVendedorBox.SelectedItem = null; + } + ComboBox vendedorBox = this.VendedorBox; + if (vendedorBox != null) + { + flag = vendedorBox.SelectedItem; + } + else + { + flag = false; + } + if (flag) + { + this.VendedorBox.SelectedItem = null; + } + if (ValidationHelper.IsNotNullOrEmpty(this.ValorRepasseBox.Text)) + { + this.ValorRepasseBox.Text = ""; + } + this.ViewModel.VendedorCoCorretagem(flag1); + } + + private void AlteracaoDePremio_LostFocus(object sender, RoutedEventArgs e) + { + decimal iof; + if (!this.ViewModel.AllowEditApolice) + { + return; + } + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + CurrencyTextBox currencyTextBox = (CurrencyTextBox)sender; + if (currencyTextBox == null) + { + return; + } + string name = currencyTextBox.Name; + if ((name == "PremioLiquidoBox" || name == "PremioAdicionalBox") && this.IofBox.get_Number() == decimal.Zero) + { + decimal number = this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number(); + Ramo ramo = this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(); + if (ramo != null) + { + iof = ramo.get_Iof(); + } + else + { + iof = decimal.Zero; + } + decimal num = number * iof; + this.IofBox.set_Number(num); + CurrencyTextBox premioTotalBox = this.PremioTotalBox; + premioTotalBox.set_Number(premioTotalBox.get_Number() + num); + } + this.PremioTotalBox.set_Number(((this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number()) + this.IofBox.get_Number()) + this.DiferencaBox.get_Number()); + name = currencyTextBox.Name; + if ((name == "PremioLiquidoBox" || name == "PremioAdicionalBox" || name == "ComissaoBox") && this.ViewModel.HabilitarVendedor(0).Count == 0) + { + this.ViewModel.RecalculaRepasses(); + } + this.ValidarDocumento(); + } + + private void AlteracaoParcela_LostFocus(object sender, RoutedEventArgs e) + { + this.ValidarDocumento(); + } + + public void AlterandoDocumento(bool alterando) + { + PermissaoUsuario permissaoUsuario = this.ViewModel.ServicoPermissUsuario.BuscarPermissao(Recursos.Usuario, 2); + this.EditarVendedorButton.IsEnabled = ((permissaoUsuario != null ? permissaoUsuario.get_Incluir() : true) ? !alterando : false); + } + + private async void Alterar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.UpdatePremio = false; + this.Restricao(false); + ApoliceViewModel viewModel = this.ViewModel; + List configuracoes = Recursos.Configuracoes; + if (configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 34)) + { + flag = true; + } + else + { + List repasses = this.ViewModel.Repasses; + flag = repasses.All((VendedorParcela x) => !x.get_DataPagamento().HasValue); + } + viewModel.EnableControle = flag; + ApoliceViewModel apoliceViewModel = this.ViewModel; + List vendedorParcelas = this.ViewModel.Repasses; + apoliceViewModel.CoCorretagem = vendedorParcelas.Any((VendedorParcela x) => { + Gestor.Model.Domain.Seguros.Repasse repasse = x.get_Repasse(); + if (repasse == null) + { + return false; + } + return repasse.get_Tipo().GetValueOrDefault() == 3; + }); + this.ViewModel.VerificaCoCorretagem(); + await this.ViewModel.Alteracao(true); + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.AlterandoDocumento(true); + this.ExcluirpoliceButton.IsEnabled = false; + this.IncluirpoliceButton.IsEnabled = false; + this.AlterarApoliceButton.IsEnabled = false; + this.ViewModel.Inclusao = false; + } + + private void AlterarParcela() + { + this.FaturaField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.QuantidadeFaturaField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaInicialField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaFinalField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ValorLiquidoField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.PercentualComissaoField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ComissaoIcon.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.EmissaoField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.RecebimentoField.Visibility = System.Windows.Visibility.Collapsed; + this.QuitacaoField.Visibility = System.Windows.Visibility.Visible; + this.DataControleParcelaField.Visibility = System.Windows.Visibility.Visible; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Collapsed; + this.CreditoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.VencimentoField.Visibility = System.Windows.Visibility.Visible; + this.ValorField.Visibility = System.Windows.Visibility.Visible; + this.TipoParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.VencimentoField.Visibility = System.Windows.Visibility.Visible; + this.ValorField.Visibility = System.Windows.Visibility.Visible; + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Visible; + this.ValidarParcela(); + } + + private void AlterarParcela_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.QuantidadeFaturas = 1; + if (this.ViewModel.Parcelas.Count == 0) + { + return; + } + this.ToggleBotoesParcela(true); + this.EditarParcelaTipo = 1; + this.ViewModel.SelecionaPrimeiraParcela(); + this.AlterarParcela(); + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.AllowEditVendedor = this.ViewModel.IsFatura; + } + + private void ApoliceControl_SizeChanged(object sender, SizeChangedEventArgs e) + { + bool flag; + if (e != null) + { + Size newSize = e.NewSize; + flag = false; + } + else + { + flag = true; + } + if (flag) + { + return; + } + this.Redimencionar(e.NewSize.Width); + } + + private async void ApoliceView_OnLoaded(object sender, RoutedEventArgs e) + { + while (!this.ViewModel.Loaded) + { + await Task.Delay(100); + } + this.AcessarApolice(this.AcessoApolice); + } + + private void AutoCompleteBanco_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + ApoliceView.SetValid(autoCompleteBox, (string.IsNullOrWhiteSpace(autoCompleteBox.get_Text()) ? true : this.ViewModel.SelectedDocumento.get_Banco() != null)); + } + + private void AutoCompleteBancoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarBanco(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 void BaixarParcelas() + { + this.FaturaField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaInicialField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaFinalField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.PercentualComissaoField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ComissaoIcon.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.QuantidadeFaturaField.Visibility = System.Windows.Visibility.Collapsed; + this.QuitacaoField.Visibility = System.Windows.Visibility.Collapsed; + this.DataControleParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.EmissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorLiquidoField.Visibility = System.Windows.Visibility.Visible; + this.VencimentoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorField.Visibility = System.Windows.Visibility.Collapsed; + this.TipoParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.RecebimentoField.Visibility = System.Windows.Visibility.Visible; + this.CreditoField.Visibility = System.Windows.Visibility.Visible; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Visible; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Visible; + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Visible; + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5)) + { + this.ImpostosField.Visibility = System.Windows.Visibility.Visible; + } + this.ParcelaGrid.IsEnabled = false; + this.ValidarParcela(); + this.RecebimentoParcelaBox.Focus(); + } + + private async void BaixarParcelas_Click(object sender, RoutedEventArgs e) + { + this.ParcelaGrid.IsEnabled = false; + ((MenuItem)sender).Click -= new RoutedEventHandler(this.BaixarParcelas_Click); + this.ViewModel.QuantidadeFaturas = 1; + if (await this.ViewModel.SelecionarParcelaBaixa()) + { + this.ToggleBotoesParcela(true); + this.ViewModel.BaixarParcelas = true; + await this.ViewModel.CarregarImposto(); + this.EditarParcelaTipo = 2; + this.BaixarParcelas(); + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarParcelas_Click); + this.ViewModel.AllowEditVendedor = false; + } + } + + private async void Button_Click(object sender, RoutedEventArgs e) + { + bool flag = this.ViewModel.Restricao(97); + if (!flag) + { + Documento documento = this.ViewModel.AbrirDetalhes(); + this.ViewModel.ShowDrawer(new ValoresApoliceDrawer(documento), 0, true); + } + if (flag) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR MAIS INFORMAÇÕES.", "OK", "", false); + } + } + + private void CalculoComissao_OnNumberChanged(object sender, EventArgs e) + { + bool id; + bool flag; + bool id1; + bool flag1; + bool id2; + bool flag2; + if (!this.ViewModel.BaixarParcelas || this._calculando) + { + return; + } + this._calculando = true; + decimal number = this.ValorComissaoParcelaBox.get_Number(); + this.PorcentagemIrBox.remove_NumberChanged(new EventHandler(this.PorcentagemIrBox_OnNumberChanged)); + this.PorcentagemIssBox.remove_NumberChanged(new EventHandler(this.PorcentagemIssBox_OnNumberChanged)); + Imposto imposto = this.ViewModel.Imposto; + if (imposto != null) + { + id = imposto.get_Id() > (long)0; + } + else + { + id = false; + } + if (id) + { + this.PorcentagemIrBox.set_Number(this.ViewModel.Imposto.get_Ir() * new decimal(100)); + } + Imposto imposto1 = this.ViewModel.Imposto; + if (imposto1 != null) + { + flag = imposto1.get_Id() > (long)0; + } + else + { + flag = false; + } + if (flag) + { + this.PorcentagemIssBox.set_Number(this.ViewModel.Imposto.get_Iss() * new decimal(100)); + } + this.PorcentagemIrBox.add_NumberChanged(new EventHandler(this.PorcentagemIrBox_OnNumberChanged)); + this.PorcentagemIssBox.add_NumberChanged(new EventHandler(this.PorcentagemIssBox_OnNumberChanged)); + Imposto imposto2 = this.ViewModel.Imposto; + if (imposto2 != null) + { + id1 = imposto2.get_Id() > (long)0; + } + else + { + id1 = false; + } + decimal num = (id1 ? number * this.ViewModel.Imposto.get_Ir() : this.ValorIrBox.get_Number()); + if (this.ValorIrBox.get_Number() != num) + { + this.ViewModel.SelectedParcela.set_Irr(num); + } + Imposto imposto3 = this.ViewModel.Imposto; + if (imposto3 != null) + { + flag1 = imposto3.get_Id() > (long)0; + } + else + { + flag1 = false; + } + decimal num1 = (flag1 ? number * this.ViewModel.Imposto.get_Iss() : this.ValorIssBox.get_Number()); + if (this.ValorIssBox.get_Number() != num1) + { + this.ViewModel.SelectedParcela.set_Iss(num1); + } + Imposto imposto4 = this.ViewModel.Imposto; + if (imposto4 != null) + { + id2 = imposto4.get_Id() > (long)0; + } + else + { + id2 = false; + } + decimal num2 = (id2 ? number * this.ViewModel.Imposto.get_Outros() : this.ValorOutrosBox.get_Number()); + if (this.ValorOutrosBox.get_Number() != num2) + { + this.ViewModel.SelectedParcela.set_Outros(num2); + } + Imposto imposto5 = this.ViewModel.Imposto; + if (imposto5 != null) + { + flag2 = imposto5.get_Id() > (long)0; + } + else + { + flag2 = false; + } + decimal num3 = (flag2 ? number * this.ViewModel.Imposto.get_Desconto() : this.ValorDescontoBox.get_Number()); + if (this.ValorDescontoBox.get_Number() != num3) + { + this.ViewModel.SelectedParcela.set_Desconto(num3); + } + this.ValorComDescBox.set_Number((((number - num) - num1) - num2) - num3); + this.ViewModel.OnPropertyChanged("SelectedParcela"); + this._calculando = false; + } + + private void CancelarAlteracao() + { + ApoliceView.SetValid(this.AutoCompleteBanco, true); + this.AutoCompleteBanco.set_Text(string.Empty); + this.ViewModel.BotoesParcelaEnabled = true; + this.ViewModel.AlteracaoEnabled = true; + this.EditarVendedor(false); + this.ValidarDocumento(); + } + + private async void CancelarApolice_OnClick(object sender, RoutedEventArgs e) + { + this.CancelarAlteracao(); + await this.ViewModel.CancelarAlteracao(); + this.AlterandoDocumento(false); + this.EditandoVendedor(false); + this.Restricao(false); + } + + private void CancelarParcela_Click(object sender, RoutedEventArgs e) + { + this.ToggleBotoesParcela(false); + this.ViewModel.BaixarParcelas = false; + this.ViewModel.CancelPagamento(); + this.ValidarDocumento(); + this.EditarVendedor(false); + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(true); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(true); + } + else + { + } + this.EditandoParcela(false); + } + + private void CancelarVendedor_Click(object sender, RoutedEventArgs e) + { + this.EditarVendedor(false); + this.ViewModel.SelectedPagamento = null; + this.ViewModel.AllowEditParcela = true; + this.EditandoVendedor(false); + } + + private void ComissaoVendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + decimal? valorRepasse; + bool valueOrDefault; + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + Gestor.Model.Domain.Seguros.Repasse selectedItem = (Gestor.Model.Domain.Seguros.Repasse)comboBox.SelectedItem; + if (selectedItem != null && selectedItem.get_Tipo().GetValueOrDefault() == 3) + { + this.ViewModel.SelectedPagamento.set_ValorRepasse(new decimal?(new decimal(0, 0, 0, false, 2))); + CurrencyTextBox valorRepasseBox = this.ValorRepasseBox; + valorRepasse = this.ViewModel.SelectedPagamento.get_ValorRepasse(); + valorRepasseBox.set_Number(valorRepasse.Value); + return; + } + if (this.ViewModel.SelectedDocumento.get_NegocioCorretora().HasValue) + { + NegocioCorretora? negocioCorretora = this.ViewModel.SelectedDocumento.get_NegocioCorretora(); + valueOrDefault = negocioCorretora.GetValueOrDefault() == 1; + } + else if (this.ViewModel.SelectedDocumento.get_Situacao() != 2 || !this.ViewModel.SelectedDocumento.get_Negocio().HasValue) + { + valueOrDefault = false; + } + else + { + Negocio? negocio = this.ViewModel.SelectedDocumento.get_Negocio(); + valueOrDefault = negocio.GetValueOrDefault() == 1; + } + bool flag = valueOrDefault; + this.ViewModel.SelectedPagamento.set_Repasse(selectedItem); + this.ViewModel.SelectedPagamento.set_PorcentagemRepasse(new decimal?((flag ? selectedItem.get_ValorRenovacao() : selectedItem.get_ValorNovo()))); + if (this.ViewModel.SelectedParcela == null) + { + ApoliceViewModel viewModel = this.ViewModel; + Parcela parcela = new Parcela(); + parcela.set_SubTipo(1); + viewModel.SelectedParcela = parcela; + } + this.ViewModel.SelectedParcela.set_Documento(this.ViewModel.SelectedDocumento); + this.ViewModel.SelectedPagamento.set_ValorRepasse(new decimal?(Funcoes.CalculaRepasse(selectedItem, this.ViewModel.SelectedParcela, (this.ViewModel.SelectedParcela == null ? true : this.ViewModel.SelectedParcela.get_SubTipo() == 1)))); + this.ViewModel.SelectedPagamento.set_ValorTotal(this.ViewModel.SelectedPagamento.get_ValorRepasse()); + CurrencyTextBox currencyTextBox = this.ValorRepasseBox; + valorRepasse = this.ViewModel.SelectedPagamento.get_ValorRepasse(); + currencyTextBox.set_Number(valorRepasse.Value); + this.FormaRecebidaBox.Text = ValidationHelper.GetDescription(selectedItem.get_Forma()); + this.FormaIncidenciaBox.Text = ValidationHelper.GetDescription(selectedItem.get_Incidencia()); + } + + private void ContentLoad() + { + string nome; + this.ParcelaGrid.SelectionChanged += new SelectionChangedEventHandler(this.ParcelaGrid_OnSelectionChanged); + this.ApoliceBox.LostFocus += new RoutedEventHandler(this.ValidacaoDocumento); + this.EndossoBox.LostFocus += new RoutedEventHandler(this.ValidacaoDocumento); + this.TipoEndossoBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoEndossoBox_OnSelectionChanged); + this.TipoRecebimentoBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoRecebimentoBox_OnSelectionChanged); + this.SituacaoBox.SelectionChanged += new SelectionChangedEventHandler(this.SituacaoBox_OnSelectionChanged); + this.PremioLiquidoBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.PremioAdicionalBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.IofBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.DiferencaBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.AdicionalBox.Unchecked += new RoutedEventHandler(this.AdicionalBox_OnChecked); + this.AdicionalBox.Checked += new RoutedEventHandler(this.AdicionalBox_OnChecked); + this.ParcelasBox.LostFocus += new RoutedEventHandler(this.AlteracaoParcela_LostFocus); + this.NegocioCorretoraBox.SelectionChanged += new SelectionChangedEventHandler(this.NegocioCorretoraBox_OnSelectionChanged); + this.ComissaoBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.DataBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.DataBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.VendedorBox.SelectionChanged += new SelectionChangedEventHandler(this.VendedorBox_OnSelectionChanged); + this.TipoVendedorBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoVendedorBox_OnSelectionChanged); + this.ValorLiquidoParcelaBox.LostFocus += new RoutedEventHandler(this.ValorParcelaBox_OnLostFocus); + this.ComissaoParcelaBox.LostFocus += new RoutedEventHandler(this.Recalcula); + this.ValorLiquidoParcelaBox.LostFocus += new RoutedEventHandler(this.Recalcula); + this.ValorComissaoParcelaBox.LostFocus += new RoutedEventHandler(this.Recalcula); + this.ValorRealizadoParcelaBox.LostFocus += new RoutedEventHandler(this.Recalcula); + this.ValorParcelaBox.LostFocus += new RoutedEventHandler(this.Recalcula); + bool flag = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5); + this.ValorDescontoField.Visibility = (flag ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + base.SizeChanged += new SizeChangedEventHandler(this.ApoliceControl_SizeChanged); + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + AutoCompleteBox autoCompleteBanco = this.AutoCompleteBanco; + Banco banco = this.ViewModel.SelectedDocumento.get_Banco(); + if (banco != null) + { + nome = banco.get_Nome(); + } + else + { + nome = null; + } + autoCompleteBanco.set_Text(nome); + ApoliceViewModel viewModel = this.ViewModel; + TipoRecebimento? tipoRecebimento = this.ViewModel.SelectedDocumento.get_TipoRecebimento(); + viewModel.IsFatura = tipoRecebimento.GetValueOrDefault(1) == 2; + this.Parcelas(!this.ViewModel.IsFatura); + } + + public void EditandoParcela(bool enable) + { + PermissaoUsuario permissaoUsuario = this.ViewModel.ServicoPermissUsuario.BuscarPermissao(Recursos.Usuario, 2); + this.ViewModel.AllowEditVendedor = ((permissaoUsuario != null ? permissaoUsuario.get_Incluir() : true) ? !enable : false); + } + + public void EditandoVendedor(bool enable) + { + PermissaoUsuario permissaoUsuario = this.ViewModel.ServicoPermissUsuario.BuscarPermissao(Recursos.Usuario, 2); + this.IncluirpoliceButton.IsEnabled = ((permissaoUsuario != null ? permissaoUsuario.get_Incluir() : true) ? !enable : false); + this.AlterarApoliceButton.IsEnabled = ((permissaoUsuario != null ? permissaoUsuario.get_Alterar() : true) ? !enable : false); + this.ExcluirpoliceButton.IsEnabled = ((permissaoUsuario != null ? permissaoUsuario.get_Excluir() : true) ? !enable : false); + } + + private async void EditarParcelas_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.EditarParcelas(); + } + + private void EditarVendedor(bool editar) + { + bool valueOrDefault; + bool flag; + this.SalvarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.CancelarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.EditarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.EditarVendedorFields.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VendedorGrid.IsEnabled = !editar; + if (editar) + { + if (Recursos.Configuracoes.Any((ConfiguracaoSistema config) => config.get_Configuracao() == 56)) + { + if (this.ViewModel.Pagamentos.Count == 1) + { + if (!this.ViewModel.Pagamentos.Any((VendedorParcela vendedor) => vendedor.get_Repasse() == null)) + { + goto Label1; + } + flag = !this.IsFatura(); + goto Label0; + } + Label1: + flag = false; + Label0: + this.CoCorretagemToogle.IsEnabled = flag; + } + } + if (this.ViewModel.SelectedDocumento.get_NegocioCorretora().HasValue) + { + NegocioCorretora? negocioCorretora = this.ViewModel.SelectedDocumento.get_NegocioCorretora(); + valueOrDefault = negocioCorretora.GetValueOrDefault() == 1; + } + else if (this.ViewModel.SelectedDocumento.get_Situacao() != 2 || !this.ViewModel.SelectedDocumento.get_Negocio().HasValue) + { + valueOrDefault = false; + } + else + { + Negocio? negocio = this.ViewModel.SelectedDocumento.get_Negocio(); + valueOrDefault = negocio.GetValueOrDefault() == 1; + } + bool flag1 = valueOrDefault; + this.ComissaoNovoBox.Visibility = (!editar || flag1 ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ComissaoRenovacaoBox.Visibility = (editar & flag1 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.CoCorretagemToogle.IsChecked = new bool?(false); + } + + private void Endossar() + { + this.ViewModel.AlteracaoEnabled = false; + this.ViewModel.Situacao.Add(3); + this.ValidarDocumento(); + } + + private async void Endossar_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.Restricao(33)) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ENDOSSAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + else if (!this.ViewModel.EnableEndossar) + { + List> keyValuePairs = this.ViewModel.SelectedDocumento.ValidateEndossar(); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (await this.ViewModel.IncluirEndosso()) + { + this.ViewModel.BotoesParcelaEnabled = false; + this.Endossar(); + this.Restricao(true); + } + } + + private async void ExcluirDocumento_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.ExcluirApolice(); + } + + private async void ExcluirParcela_Click(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.PagamentoVendedor(this.ViewModel.SelectedParcela)) + { + bool? nullable = await this.ViewModel.ShowSenha("HÁ PAGAMENTOS DE VENDEDORES REALIZADOS PARA ESSA PARCELA. DESEJA PROSSEGUIR COM A EXCLUSÃO?"); + if (!nullable.HasValue) + { + return; + } + else if (!nullable.GetValueOrDefault()) + { + await this.ViewModel.ShowMessage("SENHA INVÁLIDA", "OK", "", false); + return; + } + } + if (!this.ViewModel.SelectedParcela.get_DataRecebimento().HasValue) + { + await this.ViewModel.ExcluirParcela(); + } + else + { + await this.ViewModel.ExcluirBaixa(); + } + this.EditandoParcela(true); + } + + private async void ExcluirVendedor_Click(object sender, RoutedEventArgs e) + { + TipoRepasse? nullable; + TipoRepasse? tipo; + bool flag; + System.Windows.Visibility visibility; + bool flag1; + VendedorParcela dataContext; + ((Button)sender).Click -= new RoutedEventHandler(this.ExcluirVendedor_Click); + Button button = (Button)sender; + if (button != null && button.DataContext != null) + { + dataContext = (VendedorParcela)button.DataContext; + VendedorParcela vendedorParcela = dataContext; + if (vendedorParcela != null) + { + Gestor.Model.Domain.Seguros.Repasse repasse1 = vendedorParcela.get_Repasse(); + if (repasse1 != null) + { + tipo = repasse1.get_Tipo(); + } + else + { + nullable = null; + tipo = nullable; + } + nullable = tipo; + flag = nullable.GetValueOrDefault() == 3; + } + else + { + flag = false; + } + bool flag2 = flag; + if (this.AlterarApoliceButton.IsEnabled || !this.SalvarApoliceButton.IsEnabled) + { + if (dataContext != null && !dataContext.get_DataPagamento().HasValue) + { + if (this.ViewModel._excluirPermissEnabled) + { + if (dataContext.get_CoCorretagem()) + { + ObservableCollection pagamentos = this.ViewModel.Pagamentos; + IEnumerable vendedorParcelas = pagamentos.Where((VendedorParcela pgt) => { + bool valueOrDefault; + Gestor.Model.Domain.Seguros.Repasse repasse = pgt.get_Repasse(); + valueOrDefault = (repasse != null ? repasse.get_Tipo().GetValueOrDefault() != 3 : true); + if (!valueOrDefault) + { + return false; + } + return !pgt.get_Vendedor().get_Corretora(); + }); + if (vendedorParcelas != null) + { + flag1 = vendedorParcelas.Count() >= 1; + } + else + { + flag1 = false; + } + if (flag1) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL EXCLUIR O VENDEDOR CO-CORRETAGEM. HÁ VENDEDORES CADASTRADOS NO DOCUMENTO", "OK", "", false); + dataContext = null; + return; + } + } + await this.ViewModel.ExcluirVendedor(dataContext, true); + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA EXCLUIR VENDEDORES. ENTRE EM CONTATO COM O ADMINISTRADOR DO SISTEMA.", "OK", "", false); + dataContext = null; + return; + } + } + else if (await this.ViewModel.ShowSenha(string.Format("DESEJA REALMENTE EXCLUIR O PAGAMENTO DO VENDEDOR {0} {1:d}?\nESSE PROCEDIMENTO É IRREVERSÍVEL.", dataContext.get_Vendedor().get_Nome(), dataContext.get_DataPagamento())).GetValueOrDefault()) + { + await this.ViewModel.ExcluirPagamento(dataContext); + } + this.ComissaoBox.IsReadOnly = this.ViewModel.VerificaCoCorretagem(); + ApoliceViewModel viewModel = this.ViewModel; + visibility = (this.ComissaoBox.IsReadOnly ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + viewModel.ComissOriginalVisibility = visibility; + if (flag2) + { + await this.ViewModel.AjusteComissãoCoCorretagem(true); + } + ((Button)sender).Click += new RoutedEventHandler(this.ExcluirVendedor_Click); + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL EXCLUIR VENDEDOR DURANTE ALTERAÇÃO DE DOCUMENTO.", "OK", "", false); + } + } + dataContext = null; + } + + private void ExecutarValidacaoDataApolice() + { + DateTime dateTime; + DateTime? nullable; + DateTime? nullable1; + DateTime? nullable2; + DateTime? nullable3; + DateTime? nullable4; + Documento selectedDocumento = this.ViewModel.SelectedDocumento; + if (DateTime.TryParse(ValidationHelper.FormatDate(this.Vigencia2Box.Text), out dateTime)) + { + nullable1 = new DateTime?(dateTime); + } + else + { + nullable = null; + nullable1 = nullable; + } + selectedDocumento.set_Vigencia2(nullable1); + Documento documento = this.ViewModel.SelectedDocumento; + if (DateTime.TryParse(ValidationHelper.FormatDate(this.TransmissaoBox.Text), out dateTime)) + { + nullable2 = new DateTime?(dateTime); + } + else + { + nullable = null; + nullable2 = nullable; + } + documento.set_Remessa(nullable2); + Documento selectedDocumento1 = this.ViewModel.SelectedDocumento; + if (DateTime.TryParse(ValidationHelper.FormatDate(this.EmissaoBox.Text), out dateTime)) + { + nullable3 = new DateTime?(dateTime); + } + else + { + nullable = null; + nullable3 = nullable; + } + selectedDocumento1.set_Emissao(nullable3); + Documento documento1 = this.ViewModel.SelectedDocumento; + if (DateTime.TryParse(ValidationHelper.FormatDate(this.DataBox.Text), out dateTime)) + { + nullable4 = new DateTime?(dateTime); + } + else + { + nullable = null; + nullable4 = nullable; + } + documento1.set_DataControle(nullable4); + } + + private void FocusPremios(object sender, RoutedEventArgs e) + { + this.ViewModel.UpdatePremio = true; + } + + private void Importacao_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Id() != 0) + { + this.AbrirImportacao(); + } + } + + private async void IncluirApolice_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.IncluirApolice(false); + this.ViewModel.BotoesParcelaEnabled = false; + this.ViewModel.AllowEditEmissao = true; + this.ValidarDocumento(); + this.Restricao(true); + this.ValidarTela(); + this.IncluirpoliceButton.IsEnabled = false; + this.AlterarApoliceButton.IsEnabled = false; + this.ExcluirpoliceButton.IsEnabled = false; + this.AlterandoDocumento(true); + } + + private async void IncluirNovaFatura_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.QuantidadeFaturas = 1; + bool flag = this.IsFatura(); + if (!flag || this.ViewModel.SelectedDocumento.get_Ordem() <= 0) + { + this.ToggleBotoesParcela(true); + this.EditarParcelaTipo = 3; + this.ViewModel.QuantidadeFaturas = 1; + this.NovaFatura(); + this.ViewModel.AllowEditVendedor = flag; + this.ViewModel.BaixarParcelas = true; + this.ViewModel.VisibilityAlterarVencimento = System.Windows.Visibility.Visible; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ADICIONAR FATURAS AO ENDOSSO, TODAS AS FATURAS DEVEM SER ADICIONADAS SOBRE A APÓLICE.", "OK", "", false); + } + } + + private void IncluirParcelaEspecial_Click(object sender, RoutedEventArgs e) + { + ((MenuItem)sender).Click -= new RoutedEventHandler(this.IncluirParcelaEspecial_Click); + this.ViewModel.QuantidadeFaturas = 1; + this.ToggleBotoesParcela(true); + this.EditarParcelaTipo = 4; + this.NovaParcelaEspecial(); + this.ViewModel.EditarParcelaEspecial(); + this.ViewModel.BaixarParcelas = true; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + ((MenuItem)sender).Click += new RoutedEventHandler(this.IncluirParcelaEspecial_Click); + this.EditandoParcela(true); + } + + private async void IncluirVendedor_Click(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.AllowEditParcela = false; + List> keyValuePairs = this.ViewModel.HabilitarVendedor(this.EditarParcelaTipo); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag) + { + this.ViewModel.IncluirVendedor(); + this.EditarVendedor(true); + this.ValidarVendedor(); + this.EditandoVendedor(true); + this.ViewModel.VendedorCoCorretagem(false); + } + else + { + this.ValidateFields(keyValuePairs, true); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + private void Initial_DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DateTime now; + bool flag; + base.DatePicker_OnLostKeyboardFocus(sender, e); + if (string.IsNullOrEmpty(((DatePicker)sender).Text)) + { + ((DatePicker)sender).SelectedDate = new DateTime?(DateTime.MinValue); + this.ViewModel.SelectedDocumento.set_Vigencia1(DateTime.MinValue); + Documento selectedDocumento = this.ViewModel.SelectedDocumento; + if (selectedDocumento != null) + { + selectedDocumento.get_Vigencia1(); + flag = true; + } + else + { + flag = false; + } + if (flag && this.ViewModel.SelectedDocumento.get_Vigencia1() == DateTime.MinValue) + { + DatePicker nullable = (DatePicker)sender; + now = DateTime.Now; + nullable.SelectedDate = new DateTime?(now.Date); + this.ViewModel.SelectedDocumento.set_Vigencia1(DateTime.Now.Date); + } + } + if (string.IsNullOrWhiteSpace(this.Vigencia2Box.Text)) + { + DatePicker vigencia2Box = this.Vigencia2Box; + now = ValidationHelper.ToDateTime(((DatePicker)sender).Text); + vigencia2Box.DisplayDate = now.AddYears(1); + DatePicker shortDateString = this.Vigencia2Box; + now = this.Vigencia2Box.DisplayDate; + shortDateString.Text = now.ToShortDateString(); + } + } + + [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/seguros/apoliceview.xaml", UriKind.Relative)); + } + + private bool IsFatura() + { + TipoRecebimento? tipoRecebimento = this.ViewModel.SelectedDocumento.get_TipoRecebimento(); + return tipoRecebimento.GetValueOrDefault() == 2; + } + + private void LostFocusValorRealizado() + { + if (this.ValorRealizadoParcelaBox.get_Number() == decimal.Zero || this.ViewModel.SelectedParcela == null || !this.ValorRealizadoParcelaBox.IsFocused) + { + return; + } + decimal number = this.ValorRealizadoParcelaBox.get_Number(); + decimal comissao = this.ViewModel.SelectedParcela.get_Comissao() * new decimal(1, 0, 0, false, 2); + this.ValorComissaoParcelaBox.set_Number(number * comissao); + } + + private void ManutecaoItens_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ManutecaoItens(); + } + + private void MenuItem_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogAntigo(); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + Tarefa tarefa = new Tarefa(); + tarefa.set_IdCliente(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Id()); + tarefa.set_Cliente(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()); + tarefa.set_Entidade(0); + tarefa.set_IdEntidade(this.ViewModel.SelectedDocumento.get_Id()); + tarefa.set_Titulo(string.Concat(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome(), " APÓLICE ", this.ViewModel.SelectedDocumento.get_Apolice())); + Tarefa tarefa1 = tarefa; + this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa1, true), 0, false); + } + + private void NegocioCorretoraBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool selectedItem; + if (!this.ViewModel.EnableFields) + { + return; + } + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null) + { + selectedItem = comboBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (!selectedItem) + { + return; + } + this.AlteracaoDePremio_LostFocus(this.PremioLiquidoBox, new RoutedEventArgs()); + if (this.SalvarVendedorButton.Visibility != System.Windows.Visibility.Visible) + { + return; + } + this.EditarVendedor(true); + this.ComissaoVendedorBox_OnSelectionChanged((this.ComissaoNovoBox.Visibility == System.Windows.Visibility.Visible ? this.ComissaoNovoComboBox : this.ComissaoRenovacaoComboBox), e); + } + + private void NovaFatura() + { + this.VigenciaInicialField.Visibility = System.Windows.Visibility.Visible; + this.VigenciaFinalField.Visibility = System.Windows.Visibility.Visible; + this.EmissaoField.Visibility = System.Windows.Visibility.Visible; + this.ValorLiquidoField.Visibility = System.Windows.Visibility.Visible; + this.QuantidadeFaturaField.Visibility = System.Windows.Visibility.Visible; + this.RecebimentoField.Visibility = System.Windows.Visibility.Visible; + this.QuitacaoField.Visibility = System.Windows.Visibility.Visible; + this.DataControleParcelaField.Visibility = System.Windows.Visibility.Visible; + this.CreditoField.Visibility = System.Windows.Visibility.Visible; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Visible; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Visible; + this.VencimentoField.Visibility = System.Windows.Visibility.Visible; + this.ValorField.Visibility = System.Windows.Visibility.Visible; + this.TipoParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.PercentualComissaoField.Visibility = System.Windows.Visibility.Visible; + this.ComissaoIcon.Visibility = System.Windows.Visibility.Visible; + this.FaturaField.Visibility = System.Windows.Visibility.Visible; + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Visible; + this.ParcelaGrid.IsEnabled = false; + if (this.ViewModel.Restricao(15)) + { + this.RecebimentoField.Visibility = System.Windows.Visibility.Collapsed; + this.QuitacaoField.Visibility = System.Windows.Visibility.Collapsed; + this.CreditoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Collapsed; + } + this.ViewModel.IncluirFatura(); + this.ValidarParcela(); + this.QuantidadeFaturaBox.Focus(); + this.EditandoParcela(true); + } + + private void NovaParcelaEspecial() + { + this.FaturaField.Visibility = System.Windows.Visibility.Collapsed; + this.VigenciaInicialField.Visibility = System.Windows.Visibility.Collapsed; + this.VigenciaFinalField.Visibility = System.Windows.Visibility.Collapsed; + this.EmissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorLiquidoField.Visibility = System.Windows.Visibility.Collapsed; + this.QuantidadeFaturaField.Visibility = (this.ViewModel.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.TipoParcelaField.Visibility = System.Windows.Visibility.Visible; + this.VencimentoField.Visibility = System.Windows.Visibility.Visible; + this.ValorField.Visibility = System.Windows.Visibility.Visible; + this.RecebimentoField.Visibility = System.Windows.Visibility.Visible; + this.QuitacaoField.Visibility = System.Windows.Visibility.Visible; + this.CreditoField.Visibility = System.Windows.Visibility.Visible; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Visible; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Visible; + this.PercentualComissaoField.Visibility = System.Windows.Visibility.Visible; + this.ComissaoIcon.Visibility = System.Windows.Visibility.Visible; + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Visible; + this.ParcelaGrid.IsEnabled = false; + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5)) + { + this.ImpostosField.Visibility = System.Windows.Visibility.Visible; + } + this.ViewModel.IncluirParcelaEspecial(); + this.ValidarParcela(); + this.ValorParcelaBox.Focus(); + } + + private async void ParcelaGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + ApoliceViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaParcela((Parcela)obj); + } + } + + private void Parcelas(bool premios) + { + DateTime? selectedDate; + this.ViewModel.AllowEditVendedor = this.ViewModel.SelectedDocumento.get_Id() == (long)0; + this.PremiosBox.Visibility = (premios ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.FaturaColumn.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaInicialColumn.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaFinalColumn.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ValidarDocumento(); + if (premios) + { + return; + } + this.ParcelasBox.set_Number(decimal.Zero); + this.ComissaoBox.set_Number(decimal.Zero); + this.PremioLiquidoBox.set_Number(decimal.Zero); + this.PremioTotalBox.set_Number(decimal.Zero); + this.IofBox.set_Number(decimal.Zero); + this.DiferencaBox.set_Number(decimal.Zero); + this.PremioAdicionalBox.set_Number(decimal.Zero); + this.FormaPagamentoBox.SelectedItem = (FormaPagamento)4; + DatePicker vigencia2Box = this.Vigencia2Box; + if (this.ViewModel.SelectedDocumento.get_Id() != 0 || this.ViewModel.SelectedDocumento.get_Tipo() != 0) + { + selectedDate = this.Vigencia2Box.SelectedDate; + } + else + { + selectedDate = null; + } + vigencia2Box.SelectedDate = selectedDate; + this.ViewModel.AllowEditVendedor = this.ViewModel.SelectedDocumento.get_Id() != (long)0; + } + + private async void Perdido_OnClick(object sender, RoutedEventArgs e) + { + object prefixo; + object numero; + string str; + string numero1; + object email; + DateTime dateTime; + string descricao; + bool count; + Cliente cliente; + ObservableCollection observableCollection; + if (this.ViewModel.SelectedDocumento.get_Situacao() == 7) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ALTERAR O STATUS PARA PERDIDO DE UM DOCUMENTO RECUSADO.", "OK", "", false); + } + else if (await this.ViewModel.ShowMessage("DESEJA REALMENTE ALTERAR O STATUS DO SEGURO PARA PERDIDO?", "SIM", "NÃO", false)) + { + this.ViewModel.Loading(true); + cliente = await (new ClienteServico()).BuscarCliente(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Id()); + Cliente cliente1 = cliente; + ObservableCollection observableCollection1 = await (new ClienteServico()).BuscarTelefonesAsync(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Id()); + cliente1.set_Telefones(observableCollection1); + cliente1 = null; + cliente1 = cliente; + ObservableCollection observableCollection2 = await (new ClienteServico()).BuscarEmailsAsync(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Id()); + cliente1.set_Emails(observableCollection2); + cliente1 = null; + observableCollection = await (new ItemServico()).BuscarItems(this.ViewModel.SelectedDocumento.get_Controle().get_Id(), 0, false); + if (await (new ApoliceServico()).Perdido(this.ViewModel.SelectedDocumento.get_Controle().get_Id())) + { + Prospeccao prospeccao = new Prospeccao(); + prospeccao.set_Nome(cliente.get_Nome()); + prospeccao.set_Documento(cliente.get_Documento()); + prospeccao.set_Nascimento(cliente.get_Nascimento()); + ObservableCollection telefones = cliente.get_Telefones(); + if (telefones != null) + { + ClienteTelefone clienteTelefone = telefones.FirstOrDefault(); + if (clienteTelefone != null) + { + prefixo = clienteTelefone.get_Prefixo(); + } + else + { + prefixo = null; + } + } + else + { + prefixo = null; + } + if (prefixo == null) + { + prefixo = ""; + } + prospeccao.set_Prefixo1((string)prefixo); + ObservableCollection telefones1 = cliente.get_Telefones(); + if (telefones1 != null) + { + ClienteTelefone clienteTelefone1 = telefones1.FirstOrDefault(); + if (clienteTelefone1 != null) + { + numero = clienteTelefone1.get_Numero(); + } + else + { + numero = null; + } + } + else + { + numero = null; + } + if (numero == null) + { + numero = ""; + } + prospeccao.set_Telefone1((string)numero); + str = (cliente.get_Telefones() == null || cliente.get_Telefones().Count <= 1 ? "" : cliente.get_Telefones()[1].get_Prefixo()); + prospeccao.set_Prefixo2(str); + if (cliente.get_Telefones() != null) + { + ObservableCollection telefones2 = cliente.get_Telefones(); + if (telefones2 != null) + { + count = telefones2.Count > 1; + } + else + { + count = false; + } + if (!count) + { + goto Label1; + } + numero1 = cliente.get_Telefones()[1].get_Numero(); + goto Label0; + } + Label1: + numero1 = ""; + Label0: + prospeccao.set_Telefone2(numero1); + ObservableCollection emails = cliente.get_Emails(); + if (emails != null) + { + ClienteEmail clienteEmail = emails.FirstOrDefault(); + if (clienteEmail != null) + { + email = clienteEmail.get_Email(); + } + else + { + email = null; + } + } + else + { + email = null; + } + if (email == null) + { + email = ""; + } + prospeccao.set_Email((string)email); + DateTime? vigencia2 = this.ViewModel.SelectedDocumento.get_Vigencia2(); + dateTime = (vigencia2.HasValue ? vigencia2.GetValueOrDefault() : Funcoes.GetNetworkTime().Date); + prospeccao.set_VigenciaFinal(new DateTime?(dateTime.AddYears(1))); + prospeccao.set_Vendedor(this.ViewModel.SelectedDocumento.get_VendedorPrincipal()); + Item item = observableCollection.FirstOrDefault(); + if (item != null) + { + descricao = item.get_Descricao(); + } + else + { + descricao = null; + } + prospeccao.set_Item(descricao); + prospeccao.set_Tipo("SEGURO PERDIDO"); + prospeccao.set_Observacao(string.Concat("SEGURO PERDIDO: PROPOSTA: ", this.ViewModel.SelectedDocumento.get_Proposta(), ", APÓLICE: ", this.ViewModel.SelectedDocumento.get_Apolice())); + prospeccao.set_Status(new StatusProspeccao?(1)); + prospeccao.set_Renovacao(true); + await this.AbrirProspeccao(prospeccao); + await this.ViewModel.SelecionaDocumento(this.ViewModel.SelectedDocumento); + this.ViewModel.Loading(false); + } + else + { + this.ViewModel.Loading(false); + } + } + cliente = null; + observableCollection = null; + } + + private void PorcentagemIrBox_OnNumberChanged(object sender, EventArgs e) + { + if (!this.ViewModel.BaixarParcelas || this._calculando) + { + return; + } + this._calculando = true; + this.ValorIrBox.set_Number(this.ValorComissaoParcelaBox.get_Number() * (this.PorcentagemIrBox.get_Number() / new decimal(100))); + this._calculando = false; + this.ValorImposto_OnNumberChanged(this.ValorIrBox, new EventArgs()); + } + + private void PorcentagemIssBox_OnNumberChanged(object sender, EventArgs e) + { + if (!this.ViewModel.BaixarParcelas || this._calculando) + { + return; + } + this._calculando = true; + this.ValorIssBox.set_Number(this.ValorComissaoParcelaBox.get_Number() * (this.PorcentagemIssBox.get_Number() / new decimal(100))); + this._calculando = false; + this.ValorImposto_OnNumberChanged(this.ValorIssBox, new EventArgs()); + } + + private async void Ramo_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + List configuracoes = Recursos.Configuracoes; + if (!configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 20) && this.ViewModel.SelectedDocumento != null) + { + this.EditarVendedor(false); + this.ViewModel.SelectedPagamento = null; + await this.ViewModel.BuscarVendedores(true); + await this.ViewModel.LimparRepasses(); + } + } + + private void Recalcula(object sender, RoutedEventArgs e) + { + this.ViewModel.RecalculaRepasse(); + } + + private async void RecusarDocumento_OnClick(object sender, RoutedEventArgs e) + { + if (!this.ViewModel.Restricao(18)) + { + await this.ViewModel.RecusarApolice(); + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA RECUSAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + } + + private void Redimencionar(bool invoke) + { + double actualWidth; + object obj; + Window window = System.Windows.Application.Current.Windows.OfType().SingleOrDefault((Window x) => x.IsActive); + if (window != null) + { + actualWidth = window.ActualWidth; + } + else + { + actualWidth = 1366; + } + double num = actualWidth; + if (invoke) + { + obj = 40; + } + else + { + obj = null; + } + this.Redimencionar(num - (double)obj); + Gestor.Application.Actions.Actions.Redimencionar = (Action)Delegate.Remove(Gestor.Application.Actions.Actions.Redimencionar, new Action(this.Redimencionar)); + } + + private void Redimencionar(double width) + { + this.ViewModel.TamanhoGrid = (width - 17) / 2; + if (this.ViewModel.TamanhoGrid < (double)((this.ViewModel.IsFatura ? 620 : 450))) + { + this.ViewModel.TamanhoGrid = width; + } + } + + private async void Renovar_OnClick(object sender, RoutedEventArgs e) + { + if (!this.ViewModel.Restricao(17)) + { + if (!this.ViewModel.EnableRenovar) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL RENOVAR UM DOCUMENTO SEM EMISSÃO OU SEM FINAL DE VIGÊNCIA.", "OK", "", false); + } + if (await this.ViewModel.IncluirApolice(true)) + { + this.ViewModel.BotoesParcelaEnabled = false; + this.ViewModel.AllowEditEmissao = true; + this.Restricao(true); + } + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA RENOVAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + } + + private void ReplicarFatura() + { + this.VigenciaInicialField.Visibility = System.Windows.Visibility.Visible; + this.VigenciaFinalField.Visibility = System.Windows.Visibility.Visible; + this.EmissaoField.Visibility = System.Windows.Visibility.Visible; + this.ValorLiquidoField.Visibility = System.Windows.Visibility.Visible; + this.QuantidadeFaturaField.Visibility = System.Windows.Visibility.Visible; + this.RecebimentoField.Visibility = System.Windows.Visibility.Visible; + this.QuitacaoField.Visibility = System.Windows.Visibility.Visible; + this.DataControleParcelaField.Visibility = System.Windows.Visibility.Visible; + this.CreditoField.Visibility = System.Windows.Visibility.Visible; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Visible; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Visible; + this.VencimentoField.Visibility = System.Windows.Visibility.Visible; + this.ValorField.Visibility = System.Windows.Visibility.Visible; + this.TipoParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.PercentualComissaoField.Visibility = System.Windows.Visibility.Visible; + this.ComissaoIcon.Visibility = System.Windows.Visibility.Visible; + this.FaturaField.Visibility = System.Windows.Visibility.Visible; + if (!this.ViewModel.Restricao(15)) + { + this.ViewModel.BaixarParcelas = true; + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5)) + { + this.ImpostosField.Visibility = System.Windows.Visibility.Visible; + } + } + if (( + from x in this.ViewModel.Parcelas + orderby x.get_NumeroParcela() + select x).LastOrDefault((Parcela x) => x.get_SubTipo() == 1).get_NumeroParcela() != 999) + { + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Visible; + this.ParcelaGrid.IsEnabled = false; + } + this.ViewModel.ReplicarFatura(); + this.ValidarParcela(); + this.QuantidadeFaturaBox.Focus(); + } + + private void ReplicarFatura_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.QuantidadeFaturas = 1; + this.ToggleBotoesParcela(true); + this.EditarParcelaTipo = 3; + this.ReplicarFatura(); + this.ViewModel.QuantidadeFaturas = 1; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu == null) + { + return; + } + enableMenu(false); + } + + private void Restricao(bool insert = false) + { + bool flag = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5); + if (insert) + { + this.Comissao.Visibility = System.Windows.Visibility.Visible; + this.Gerada.Visibility = System.Windows.Visibility.Visible; + this.Recebida.Visibility = System.Windows.Visibility.Visible; + this.Pendente.Visibility = System.Windows.Visibility.Visible; + this.Repasse.Visibility = System.Windows.Visibility.Visible; + this.ParcelasComissaoColumn.Visibility = System.Windows.Visibility.Visible; + this.ParcelasValorComissaoColumn.Visibility = (flag ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ParcelasValorComissaoDescColumn.Visibility = (flag ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.PagamentosPorcentagemRepasseColumn.Visibility = System.Windows.Visibility.Visible; + this.PagamentosValorRepasseColumn.Visibility = System.Windows.Visibility.Visible; + return; + } + System.Windows.Visibility visibility = (this.ViewModel.Restricao(14) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + bool flag1 = this.ViewModel.Restricao(95); + this.Comissao.Visibility = (flag1 ? System.Windows.Visibility.Visible : visibility); + this.Gerada.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.Recebida.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.Pendente.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.Repasse.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.ParcelasComissaoColumn.Visibility = (flag1 ? System.Windows.Visibility.Visible : visibility); + this.ParcelasValorComissaoColumn.Visibility = (flag | flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.ParcelasValorComissaoDescColumn.Visibility = (flag ? visibility : System.Windows.Visibility.Collapsed); + this.MaisInformacoesColumn.Visibility = visibility; + this.PagamentosPorcentagemRepasseColumn.Visibility = visibility; + this.PagamentosValorRepasseColumn.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + } + + private async void SalvarApolice_OnClick(object sender, RoutedEventArgs e) + { + this.SalvarApoliceButton.Click -= new RoutedEventHandler(this.SalvarApolice_OnClick); + if (this.ViewModel.CompararValores()) + { + this.PremioTotalBox.set_Number(((this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number()) + this.IofBox.get_Number()) + this.DiferencaBox.get_Number()); + } + this.ExecutarValidacaoDataApolice(); + if (await this.SalvarDocumento()) + { + try + { + await this.ViewModel.CreateLinkAssistencia(this.ViewModel.SelectedDocumento, null, false); + } + catch (Exception exception) + { + } + this.AlterandoDocumento(false); + this.EditandoVendedor(false); + this.ViewModel.BotoesParcelaEnabled = true; + this.Restricao(false); + this.SalvarApoliceButton.Click += new RoutedEventHandler(this.SalvarApolice_OnClick); + } + else + { + this.SalvarApoliceButton.Click += new RoutedEventHandler(this.SalvarApolice_OnClick); + } + } + + private async Task SalvarDocumento() + { + bool flag; + bool flag1; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(false); + flag1 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag1) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + flag = false; + } + else + { + this.EditarVendedor(false); + ApoliceView.SetValid(this.AutoCompleteBanco, true); + flag = true; + } + return flag; + } + + private async Task SalvarParcela() + { + bool flag; + bool flag1; + flag = (this.EditarParcelaTipo != 3 ? false : this.ViewModel.QuantidadeFaturas > 1); + bool flag2 = flag; + if (flag2) + { + flag2 = !await this.ViewModel.ShowMessage(string.Format("O SISTEMA IRÁ INCLUIR/REPLICAR A FATURA {0} VEZES. DESEJA PROSSEGUIR?", this.ViewModel.QuantidadeFaturas), "SIM", "NÃO", false); + } + if (!flag2) + { + List> keyValuePairs = await this.ViewModel.SalvarParcelas(this.EditarParcelaTipo); + this.ValidateFields(keyValuePairs, true); + flag1 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag1) + { + this.EditarVendedor(false); + this.SalvarParcelaButton.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.EditandoParcela = false; + this.BaixarParcelaButton.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.BaixarParcelas = false; + this.EditarParcelaTipo = 0; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(true); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(true); + } + else + { + } + this.ToggleBotoesParcela(false); + if (this.ViewModel.UltimaFatura) + { + this.ViewModel.UltimaFatura = false; + this.ToggleBotoesParcela(true); + this.EditarParcelaTipo = 3; + this.ReplicarFatura(); + this.ViewModel.QuantidadeFaturas = 0; + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(false); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(false); + } + else + { + } + this.EditandoParcela(!this.ViewModel.UltimaFatura); + } + } + else + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + } + + private async void SalvarParcela_Click(object sender, RoutedEventArgs e) + { + ((MenuItem)this.SalvarParcelaButton.Items[0]).Click -= new RoutedEventHandler(this.SalvarParcela_Click); + this.LostFocusValorRealizado(); + this.ViewModel.Loading(true); + if (!this.ViewModel.CriandoParcelaEspecial) + { + await this.SalvarParcela(); + } + this.ViewModel.Loading(false); + this.SalvarParcelaButton.IsEnabled = true; + ((MenuItem)this.SalvarParcelaButton.Items[0]).Click += new RoutedEventHandler(this.SalvarParcela_Click); + } + + private async void SalvarVendedor_Click(object sender, RoutedEventArgs e) + { + bool? isChecked; + List> keyValuePairs; + bool valueOrDefault; + bool flag; + bool valueOrDefault1; + bool? nullable; + this.ViewModel.Loading(true); + if (this.ViewModel.SelectedParcela == null) + { + valueOrDefault = true; + } + else if (this.ViewModel.SelectedParcela.get_SubTipo() != 1) + { + valueOrDefault = false; + } + else + { + TipoRecebimento? tipoRecebimento = this.ViewModel.SelectedDocumento.get_TipoRecebimento(); + valueOrDefault = tipoRecebimento.GetValueOrDefault() == 1; + } + List configuracoes = Recursos.Configuracoes; + if (configuracoes.Any((ConfiguracaoSistema config) => config.get_Configuracao() == 56)) + { + ToggleButton coCorretagemToogle = this.CoCorretagemToogle; + if (coCorretagemToogle != null) + { + isChecked = coCorretagemToogle.IsChecked; + valueOrDefault1 = isChecked.GetValueOrDefault(); + } + else + { + valueOrDefault1 = false; + } + if (valueOrDefault1) + { + VendedorParcela selectedPagamento = this.ViewModel.SelectedPagamento; + ToggleButton toggleButton = this.CoCorretagemToogle; + if (toggleButton != null) + { + nullable = toggleButton.IsChecked; + } + else + { + isChecked = null; + nullable = isChecked; + } + isChecked = nullable; + selectedPagamento.set_CoCorretagem(isChecked.GetValueOrDefault(true)); + } + } + keyValuePairs = (!valueOrDefault ? await this.ViewModel.AdicionarVendedorParcelaEspecial() : await this.ViewModel.AdicionarVendedor()); + List> keyValuePairs1 = keyValuePairs; + flag = (keyValuePairs1 == null ? true : keyValuePairs1.Count == 0); + bool flag1 = flag; + this.ViewModel.Loading(false); + if (!flag1) + { + this.ViewModel.AllowEditParcela = flag1; + await this.ViewModel.ShowMessage(keyValuePairs1, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.EditarVendedor(false); + this.EditandoVendedor(false); + if (this.ViewModel.VerificaCoCorretagem()) + { + this.ComissaoBox.IsReadOnly = true; + this.ViewModel.ComissOriginalVisibility = System.Windows.Visibility.Visible; + } + this.ViewModel.AllowEditParcela = flag1; + } + } + + private static void SetValid(AutoCompleteBox autocomplete, bool valid) + { + ViewHelper.SetInvalid(autocomplete, "BANCO INVÁLIDO", valid); + } + + private void SituacaoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + TipoSeguro selectedItem = (TipoSeguro)comboBox.SelectedItem; + this.ViewModel.ToggleSeguradoraAnterior(selectedItem); + } + + [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.MenuApolice = (DockPanel)target; + return; + } + case 2: + { + this.IncluirpoliceButton = (MenuItem)target; + this.IncluirpoliceButton.Click += new RoutedEventHandler(this.IncluirApolice_OnClick); + return; + } + case 3: + { + this.AlterarApoliceButton = (MenuItem)target; + this.AlterarApoliceButton.Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 4: + { + this.SalvarApoliceButton = (MenuItem)target; + this.SalvarApoliceButton.Click += new RoutedEventHandler(this.SalvarApolice_OnClick); + return; + } + case 5: + { + this.CancelarApoliceButton = (MenuItem)target; + this.CancelarApoliceButton.Click += new RoutedEventHandler(this.CancelarApolice_OnClick); + return; + } + case 6: + { + this.ExcluirpoliceButton = (MenuItem)target; + this.ExcluirpoliceButton.Click += new RoutedEventHandler(this.ExcluirDocumento_OnClick); + return; + } + case 7: + { + this.ButtonImportado = (Button)target; + this.ButtonImportado.Click += new RoutedEventHandler(this.Importacao_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirPerfil_OnClick); + return; + } + case 9: + { + this.ArquivoDigitalButton = (MenuItem)target; + this.ArquivoDigitalButton.Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 10: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 11: + { + this.EditarParcelasButton = (MenuItem)target; + this.EditarParcelasButton.Click += new RoutedEventHandler(this.EditarParcelas_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Renovar_OnClick); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Perdido_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Endossar_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.RecusarDocumento_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ManutecaoItens_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 19: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 20: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmailPF_OnClick); + return; + } + case 21: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogTrocaCliente_OnClick); + return; + } + case 22: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MenuItem_Click); + return; + } + case 23: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirInfo_OnClick); + return; + } + case 24: + { + this.ApoliceControl1 = (WrapPanel)target; + return; + } + case 25: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Ramo_OnSelectionChanged); + return; + } + case 26: + { + this.ProdutoBox = (ComboBox)target; + return; + } + case 27: + { + this.SituacaoBox = (ComboBox)target; + return; + } + case 28: + { + this.NegocioCorretoraBox = (ComboBox)target; + return; + } + case 29: + { + this.TipoRecebimentoBox = (ComboBox)target; + return; + } + case 30: + { + this.TipoEndossoBox = (ComboBox)target; + return; + } + case 31: + { + this.ApoliceBox = (TextBox)target; + return; + } + case 32: + { + this.EndossoBox = (TextBox)target; + return; + } + case 33: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Initial_DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).SelectedDateChanged += new EventHandler(this.ValidacaoDocumento); + return; + } + case 34: + { + this.Vigencia2Box = (DatePicker)target; + this.Vigencia2Box.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.Vigencia2Box.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.Vigencia2Box.SelectedDateChanged += new EventHandler(this.ValidacaoDocumento); + return; + } + case 35: + { + this.TransmissaoBox = (DatePicker)target; + this.TransmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.TransmissaoBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.TransmissaoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 36: + { + this.EmissaoBox = (DatePicker)target; + this.EmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.EmissaoBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.EmissaoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.EmissaoBox.SelectedDateChanged += new EventHandler(this.ValidacaoDocumento); + return; + } + case 37: + { + this.FormaPagamentoBox = (ComboBox)target; + return; + } + case 38: + { + this.PremiosBox = (Grid)target; + return; + } + case 39: + { + this.AdicionalBox = (ToggleButton)target; + return; + } + case 40: + { + this.Comissao = (CustomIsReadOnlyControl)target; + return; + } + case 41: + { + this.ComissaoBox = (CurrencyTextBox)target; + return; + } + case 42: + { + this.PremioLiquidoBox = (CurrencyTextBox)target; + return; + } + case 43: + { + this.PremioAdicionalBox = (CurrencyTextBox)target; + this.PremioAdicionalBox.GotFocus += new RoutedEventHandler(this.FocusPremios); + return; + } + case 44: + { + this.IofBox = (CurrencyTextBox)target; + return; + } + case 45: + { + this.DiferencaBox = (CurrencyTextBox)target; + return; + } + case 46: + { + this.PremioTotalBox = (CurrencyTextBox)target; + return; + } + case 47: + { + this.ParcelasBox = (CurrencyTextBox)target; + return; + } + case 48: + { + this.ComissaoOriginal = (CustomIsReadOnlyControl)target; + return; + } + case 49: + { + this.Gerada = (CustomIsReadOnlyControl)target; + return; + } + case 50: + { + this.Recebida = (CustomIsReadOnlyControl)target; + return; + } + case 51: + { + this.Pendente = (CustomIsReadOnlyControl)target; + return; + } + case 52: + { + this.Repasse = (CustomIsReadOnlyControl)target; + return; + } + case 53: + { + ((Button)target).Click += new RoutedEventHandler(this.Button_Click); + return; + } + case 54: + { + this.BaixarParcelaButton = (Menu)target; + return; + } + case 55: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.BaixarParcelas_Click); + return; + } + case 56: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AlterarParcela_Click); + return; + } + case 57: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirNovaFatura_Click); + return; + } + case 58: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ReplicarFatura_Click); + return; + } + case 59: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirParcelaEspecial_Click); + return; + } + case 60: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirParcela_Click); + return; + } + case 61: + { + this.SalvarParcelaButton = (Menu)target; + return; + } + case 62: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.SalvarParcela_Click); + return; + } + case 63: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CancelarParcela_Click); + return; + } + case 64: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogParcelas_OnClick); + return; + } + case 65: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogParcelaSelecionada_OnClick); + return; + } + case 66: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogParcelaAntigo_OnClick); + return; + } + case 67: + { + this.EditarParcelasFields = (StackPanel)target; + return; + } + case 68: + { + this.TipoParcelaField = (CustomItemValidation)target; + return; + } + case 69: + { + this.TipoParcelaBox = (ComboBox)target; + return; + } + case 70: + { + this.QuantidadeFaturaField = (CustomItemControl)target; + return; + } + case 71: + { + this.QuantidadeFaturaBox = (CurrencyTextBox)target; + return; + } + case 72: + { + this.FaturaField = (CustomItemValidation)target; + return; + } + case 73: + { + this.FaturaBox = (TextBox)target; + return; + } + case 74: + { + this.VigenciaInicialField = (CustomItemValidation)target; + return; + } + case 75: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Vigencia_DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 76: + { + this.VigenciaFinalField = (CustomItemValidation)target; + return; + } + case 77: + { + this.VigenciaFinalParcelaBox = (DatePicker)target; + this.VigenciaFinalParcelaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.VigenciaFinalParcelaBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.VigenciaFinalParcelaBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 78: + { + this.VencimentoField = (CustomItemValidation)target; + return; + } + case 79: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Vencimento_DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 80: + { + this.EmissaoField = (CustomItemControl)target; + return; + } + case 81: + { + this.EmissaoParcelaBox = (DatePicker)target; + this.EmissaoParcelaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.EmissaoParcelaBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.EmissaoParcelaBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 82: + { + this.PercentualComissaoField = (CustomItemValidation)target; + return; + } + case 83: + { + this.ComissaoParcelaBox = (CurrencyTextBox)target; + return; + } + case 84: + { + this.ComissaoIcon = (TextBlock)target; + return; + } + case 85: + { + this.ValorLiquidoField = (CustomItemControl)target; + return; + } + case 86: + { + this.ValorLiquidoParcelaBox = (CurrencyTextBox)target; + return; + } + case 87: + { + this.ValorField = (CustomItemControl)target; + return; + } + case 88: + { + this.ValorParcelaBox = (CurrencyTextBox)target; + return; + } + case 89: + { + this.RecebimentoField = (CustomItemValidation)target; + return; + } + case 90: + { + this.RecebimentoParcelaBox = (DatePicker)target; + this.RecebimentoParcelaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Vencimento_OnLostKeyboardFocus); + this.RecebimentoParcelaBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.RecebimentoParcelaBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.RecebimentoParcelaBox.SelectedDateChanged += new EventHandler(this.ValidacaoParcela); + return; + } + case 91: + { + this.QuitacaoField = (CustomItemControl)target; + return; + } + case 92: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).SelectedDateChanged += new EventHandler(this.ValidacaoParcela); + return; + } + case 93: + { + this.DataControleParcelaField = (CustomItemControl)target; + return; + } + case 94: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).SelectedDateChanged += new EventHandler(this.ValidacaoParcela); + return; + } + case 95: + { + this.CreditoField = (CustomItemValidation)target; + return; + } + case 96: + { + this.CreditoParcelaBox = (DatePicker)target; + this.CreditoParcelaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.CreditoParcelaBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.CreditoParcelaBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.CreditoParcelaBox.SelectedDateChanged += new EventHandler(this.ValidacaoParcela); + return; + } + case 97: + { + this.ValorRealizadoField = (CustomItemValidation)target; + return; + } + case 98: + { + this.ValorRealizadoParcelaBox = (CurrencyTextBox)target; + this.ValorRealizadoParcelaBox.LostFocus += new RoutedEventHandler(this.ValorRealizadoParcelaBox_OnLostFocus); + return; + } + case 99: + { + this.ValorComissaoField = (CustomItemValidation)target; + return; + } + case 100: + { + this.ValorComissaoParcelaBox = (CurrencyTextBox)target; + this.ValorComissaoParcelaBox.add_NumberChanged(new EventHandler(this.CalculoComissao_OnNumberChanged)); + return; + } + case 101: + { + this.ImpostosField = (WrapPanel)target; + return; + } + case 102: + { + this.PorcentagemIrField = (CustomItemControl)target; + return; + } + case 103: + { + this.PorcentagemIrBox = (CurrencyTextBox)target; + this.PorcentagemIrBox.add_NumberChanged(new EventHandler(this.PorcentagemIrBox_OnNumberChanged)); + return; + } + case 104: + { + this.ValorIrField = (CustomItemControl)target; + return; + } + case 105: + { + this.ValorIrBox = (CurrencyTextBox)target; + this.ValorIrBox.add_NumberChanged(new EventHandler(this.ValorImposto_OnNumberChanged)); + return; + } + case 106: + { + this.PorcentagemIssField = (CustomItemControl)target; + return; + } + case 107: + { + this.PorcentagemIssBox = (CurrencyTextBox)target; + this.PorcentagemIssBox.add_NumberChanged(new EventHandler(this.PorcentagemIssBox_OnNumberChanged)); + return; + } + case 108: + { + this.ValorIssField = (CustomItemControl)target; + return; + } + case 109: + { + this.ValorIssBox = (CurrencyTextBox)target; + this.ValorIssBox.add_NumberChanged(new EventHandler(this.ValorImposto_OnNumberChanged)); + return; + } + case 110: + { + this.ValorOutrosField = (CustomItemControl)target; + return; + } + case 111: + { + this.ValorOutrosBox = (CurrencyTextBox)target; + this.ValorOutrosBox.add_NumberChanged(new EventHandler(this.ValorImposto_OnNumberChanged)); + return; + } + case 112: + { + this.ValorDescontoField = (CustomItemControl)target; + return; + } + case 113: + { + this.ValorDescontoBox = (CurrencyTextBox)target; + this.ValorDescontoBox.add_NumberChanged(new EventHandler(this.ValorImposto_OnNumberChanged)); + return; + } + case 114: + { + this.ValorComDescField = (CustomItemControl)target; + return; + } + case 115: + { + this.ValorComDescBox = (CurrencyTextBox)target; + this.ValorComDescBox.add_NumberChanged(new EventHandler(this.ValorImposto_OnNumberChanged)); + return; + } + case 116: + { + this.ParcelaGrid = (DataGrid)target; + return; + } + case 117: + { + this.ParcelaColumn = (DataGridTextColumn)target; + return; + } + case 118: + { + this.FaturaColumn = (DataGridTextColumn)target; + return; + } + case 119: + { + this.VigenciaInicialColumn = (DataGridTextColumn)target; + return; + } + case 120: + { + this.VigenciaFinalColumn = (DataGridTextColumn)target; + return; + } + case 121: + { + this.ParcelasComissaoColumn = (DataGridTextColumn)target; + return; + } + case 122: + { + this.ParcelasValorComissaoColumn = (DataGridTextColumn)target; + return; + } + case 123: + { + this.ParcelasValorComissaoDescColumn = (DataGridTextColumn)target; + return; + } + case 124: + { + this.MaisInformacoesColumn = (DataGridTemplateColumn)target; + return; + } + case 125: + case 126: + case 146: + { + this._contentLoaded = true; + return; + } + case 127: + { + this.EditarVendedorButton = (MenuItem)target; + this.EditarVendedorButton.Click += new RoutedEventHandler(this.IncluirVendedor_Click); + return; + } + case 128: + { + this.SalvarVendedorButton = (MenuItem)target; + this.SalvarVendedorButton.Click += new RoutedEventHandler(this.SalvarVendedor_Click); + return; + } + case 129: + { + this.CancelarVendedorButton = (MenuItem)target; + this.CancelarVendedorButton.Click += new RoutedEventHandler(this.CancelarVendedor_Click); + return; + } + case 130: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogVendedor_OnClick); + return; + } + case 131: + { + this.EditarVendedorFields = (WrapPanel)target; + return; + } + case 132: + { + this.CoCorretagemToogle = (ToggleButton)target; + this.CoCorretagemToogle.Click += new RoutedEventHandler(this.AdicionarCoCorretagem_OnClick); + return; + } + case 133: + { + this.TipoVendedorBox = (ComboBox)target; + return; + } + case 134: + { + this.VendedorBox = (ComboBox)target; + return; + } + case 135: + { + this.ComissaoNovoBox = (CustomItemValidation)target; + return; + } + case 136: + { + this.ComissaoNovoComboBox = (ComboBox)target; + this.ComissaoNovoComboBox.SelectionChanged += new SelectionChangedEventHandler(this.ComissaoVendedorBox_OnSelectionChanged); + return; + } + case 137: + { + this.ComissaoRenovacaoBox = (CustomItemValidation)target; + return; + } + case 138: + { + this.ComissaoRenovacaoComboBox = (ComboBox)target; + this.ComissaoRenovacaoComboBox.SelectionChanged += new SelectionChangedEventHandler(this.ComissaoVendedorBox_OnSelectionChanged); + return; + } + case 139: + { + this.ValorRepasseBox = (CurrencyTextBox)target; + this.ValorRepasseBox.add_NumberChanged(new EventHandler(this.CalculoComissao_OnNumberChanged)); + return; + } + case 140: + { + this.FormaRecebidaBox = (TextBox)target; + return; + } + case 141: + { + this.FormaIncidenciaBox = (TextBox)target; + return; + } + case 142: + { + this.VendedorGrid = (DataGrid)target; + return; + } + case 143: + { + this.VendedorGridColumn = (DataGridTextColumn)target; + return; + } + case 144: + { + this.PagamentosPorcentagemRepasseColumn = (DataGridTextColumn)target; + return; + } + case 145: + { + this.PagamentosValorRepasseColumn = (DataGridTextColumn)target; + return; + } + case 147: + { + this.ProponenteBox = (TextBox)target; + return; + } + case 148: + { + this.AutoCompleteBanco = (AutoCompleteBox)target; + this.AutoCompleteBanco.add_Populating(new PopulatingEventHandler(this, ApoliceView.AutoCompleteBancoBox_Populating)); + this.AutoCompleteBanco.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.AutoCompleteBanco_OnLostKeyboardFocus); + return; + } + case 149: + { + this.AgenciaBox = (TextBox)target; + return; + } + case 150: + { + this.ContaBox = (TextBox)target; + return; + } + case 151: + { + this.CartaoBox = (TextBox)target; + return; + } + case 152: + { + this.BandeiraBox = (ComboBox)target; + return; + } + case 153: + { + this.VencimentoCartaoBox = (TextBox)target; + ApoliceView apoliceView = this; + this.VencimentoCartaoBox.PreviewTextInput += new TextCompositionEventHandler(apoliceView.SomenteNumeros); + this.VencimentoCartaoBox.TextChanged += new TextChangedEventHandler(this.VencimentoCartaoBox_OnTextChanged); + this.VencimentoCartaoBox.GotFocus += new RoutedEventHandler(this.VencimentoCartaoBox_OnGotFocus); + return; + } + case 154: + { + this.DataBox = (DatePicker)target; + this.DataBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 155: + { + this.PastaBox = (TextBox)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 == 125) + { + ((Button)target).Click += new RoutedEventHandler(this.ValoresParcelaInfo_OnClick); + return; + } + if (connectionId == 126) + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + if (connectionId != 146) + { + return; + } + ((Button)target).Click += new RoutedEventHandler(this.ExcluirVendedor_Click); + } + + private void TipoEndossoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + decimal comissao; + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Tipo() == 0) + { + return; + } + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + bool flag = (this.ViewModel.IsFatura ? false : (TipoEndosso)comboBox.SelectedItem != 1); + if (this.ViewModel.EnableFields) + { + if ((TipoEndosso)comboBox.SelectedItem != null && (TipoEndosso)comboBox.SelectedItem != 4) + { + if (this.ViewModel.SelectedDocumento != null) + { + this.ViewModel.SelectedDocumento.set_Comissao(decimal.Zero); + } + } + else if (this.ViewModel.SelectedDocumento != null) + { + Documento selectedDocumento = this.ViewModel.SelectedDocumento; + Documento cancelDocumento = this.ViewModel.CancelDocumento; + if (cancelDocumento != null) + { + comissao = cancelDocumento.get_Comissao(); + } + else + { + comissao = decimal.Zero; + } + selectedDocumento.set_Comissao(comissao); + } + this.ViewModel.OnPropertyChanged("SelectedDocumento"); + } + this.Parcelas(flag); + } + + private void TipoRecebimentoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + this.ViewModel.IsFatura = (TipoRecebimento)comboBox.SelectedItem == 2; + this.Parcelas(!this.ViewModel.IsFatura); + if (!this.ViewModel.EnableFields) + { + return; + } + this.FormaPagamentoBox.SelectedItem = (this.ViewModel.IsFatura ? new FormaPagamento?(5) : this.ViewModel.SelectedDocumento.get_FormaPagamento()); + } + + private void TipoVendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + if (this.ViewModel.SelectedPagamento == null) + { + this.ViewModel.SelectedPagamento = new VendedorParcela(); + } + this.ViewModel.SelectedPagamento.set_TipoVendedor((TipoVendedor)comboBox.SelectedItem); + } + + private void ToggleBotoesParcela(bool habilitar) + { + this.SalvarParcelaButton.Visibility = (habilitar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ViewModel.EditandoParcela = habilitar; + this.BaixarParcelaButton.Visibility = (habilitar ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.MenuApolice.IsEnabled = !habilitar; + this.ViewModel.IsEnabled = !habilitar; + this.PremiosBox.IsEnabled = !habilitar; + this.DataControleParcelaField.Visibility = System.Windows.Visibility.Collapsed; + if (habilitar) + { + return; + } + this.QuantidadeFaturaField.Visibility = System.Windows.Visibility.Collapsed; + this.TipoParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.VencimentoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorField.Visibility = System.Windows.Visibility.Collapsed; + this.RecebimentoField.Visibility = System.Windows.Visibility.Collapsed; + this.QuitacaoField.Visibility = System.Windows.Visibility.Collapsed; + this.CreditoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.PercentualComissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.ComissaoIcon.Visibility = System.Windows.Visibility.Collapsed; + this.EmissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorLiquidoField.Visibility = System.Windows.Visibility.Collapsed; + this.FaturaField.Visibility = System.Windows.Visibility.Collapsed; + this.VigenciaInicialField.Visibility = System.Windows.Visibility.Collapsed; + this.VigenciaFinalField.Visibility = System.Windows.Visibility.Collapsed; + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Collapsed; + this.ImpostosField.Visibility = System.Windows.Visibility.Collapsed; + this.ParcelaGrid.IsEnabled = true; + } + + private void ValidacaoDocumento(object sender, RoutedEventArgs e) + { + this.ValidarDocumento(); + } + + private void ValidacaoParcela(object sender, RoutedEventArgs e) + { + this.ValidarParcela(); + } + + private void ValidarDocumento() + { + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedDocumento.Validate(this.ViewModel.IsEndosso, Recursos.Configuracoes.Any((ConfiguracaoSistema c) => c.get_Configuracao() == 11)); + this.ValidateFields(keyValuePairs, false); + } + + private void ValidarParcela() + { + if (this.ViewModel.SelectedParcela == null) + { + return; + } + if (this.ViewModel.SelectedParcela.get_Documento() == null) + { + this.ViewModel.SelectedParcela.set_Documento(this.ViewModel.SelectedDocumento); + } + this.ViewModel.SelectedParcela.get_Documento().set_Parcelas(this.ViewModel.Parcelas); + List> keyValuePairs = this.ViewModel.SelectedParcela.Validate(Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 9), Recursos.Configuracoes.Any((ConfiguracaoSistema y) => y.get_Configuracao() == 11), this.ViewModel.EditandoParcela, Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 16)); + this.ValidateFields(keyValuePairs, false); + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedDocumento.Validate(); + this.ValidateFields(keyValuePairs, false); + } + + private void ValidarVendedor() + { + if (this.ViewModel.SelectedPagamento == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedPagamento.Validate(); + this.ValidateFields(keyValuePairs, false); + } + + private void ValoresParcelaInfo_OnClick(object sender, RoutedEventArgs e) + { + Parcela parcela = this.ViewModel.AbrirDetalhesParcela(); + this.ViewModel.ShowDrawer(new ValoresParcelaDrawer(parcela, this.ViewModel.SelectedDocumento), 0, true); + } + + private void ValorImposto_OnNumberChanged(object sender, EventArgs e) + { + if (!this.ViewModel.BaixarParcelas || this._calculando) + { + return; + } + this._calculando = true; + CurrencyTextBox currencyTextBox = (CurrencyTextBox)sender; + decimal num = (this.ValorComissaoParcelaBox.get_Number() == decimal.Zero ? decimal.One : this.ValorComissaoParcelaBox.get_Number()); + decimal number = this.ValorComissaoParcelaBox.get_Number(); + string name = currencyTextBox.Name; + if (name == "ValorIrBox") + { + this.PorcentagemIrBox.set_Number((this.ValorIrBox.get_Number() * new decimal(100)) / num); + number = (((num - currencyTextBox.get_Number()) - this.ValorIssBox.get_Number()) - this.ValorOutrosBox.get_Number()) - this.ValorDescontoBox.get_Number(); + } + else if (name == "ValorIssBox") + { + this.PorcentagemIssBox.set_Number((this.ValorIssBox.get_Number() * new decimal(100)) / num); + number = (((num - currencyTextBox.get_Number()) - this.ValorIrBox.get_Number()) - this.ValorOutrosBox.get_Number()) - this.ValorDescontoBox.get_Number(); + } + else if (name == "ValorOutrosBox") + { + number = (((num - currencyTextBox.get_Number()) - this.ValorIrBox.get_Number()) - this.ValorIrBox.get_Number()) - this.ValorDescontoBox.get_Number(); + } + else if (name == "ValorDescontoBox") + { + number = (((num - currencyTextBox.get_Number()) - this.ValorIrBox.get_Number()) - this.ValorIrBox.get_Number()) - this.ValorOutrosBox.get_Number(); + } + this.ValorComDescBox.set_Number(number); + this._calculando = false; + } + + private void ValorParcelaBox_OnLostFocus(object sender, RoutedEventArgs e) + { + decimal iof; + if (!this.ViewModel.IsFatura) + { + return; + } + CurrencyTextBox currencyTextBox = (CurrencyTextBox)sender; + if (this.ValorParcelaBox.get_Number() > decimal.Zero) + { + return; + } + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 46)) + { + Ramo ramo = this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(); + if (ramo != null) + { + iof = ramo.get_Iof(); + } + else + { + iof = decimal.Zero; + } + } + else + { + iof = decimal.Zero; + } + decimal one = iof + decimal.One; + this.ValorParcelaBox.set_Number(currencyTextBox.get_Number() * one); + this.ValorParcelaBox.Focus(); + } + + private void ValorRealizadoParcelaBox_OnLostFocus(object sender, RoutedEventArgs e) + { + CurrencyTextBox currencyTextBox = (CurrencyTextBox)sender; + if (currencyTextBox != null && currencyTextBox.get_Number() != decimal.Zero && this.ViewModel.SelectedParcela != null) + { + decimal number = currencyTextBox.get_Number(); + decimal comissao = this.ViewModel.SelectedParcela.get_Comissao() * new decimal(1, 0, 0, false, 2); + this.ValorComissaoParcelaBox.set_Number(number * comissao); + } + } + + private void Vencimento_DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + base.DatePicker_OnLostKeyboardFocus(sender, e); + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + if (string.IsNullOrEmpty(((DatePicker)sender).Text)) + { + ((DatePicker)sender).SelectedDate = new DateTime?(this.ViewModel.SelectedDocumento.get_Vigencia1()); + DatePicker str = (DatePicker)sender; + DateTime vigencia1 = this.ViewModel.SelectedDocumento.get_Vigencia1(); + str.Text = vigencia1.ToString("dd/MM/yyyy"); + } + base.DatePicker_OnLostKeyboardFocus(sender, e); + } + + private void Vencimento_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DateTime dateTime; + base.DatePicker_OnLostKeyboardFocus(sender, e); + DatePicker datePicker = (DatePicker)sender; + if (string.IsNullOrEmpty(datePicker.Text)) + { + return; + } + if (!DateTime.TryParse(ValidationHelper.FormatDate(datePicker.Text), out dateTime)) + { + return; + } + this.CreditoParcelaBox.SelectedDate = new DateTime?(dateTime); + } + + private void VencimentoCartaoBox_OnGotFocus(object sender, RoutedEventArgs e) + { + string str = ((TextBox)sender).Text.Replace("/", ""); + this._vencimentoCartaoOld = str.Substring(0, (str.Length > 4 ? 4 : str.Length)); + } + + private void VencimentoCartaoBox_OnTextChanged(object sender, TextChangedEventArgs e) + { + int caretIndex = ((TextBox)sender).CaretIndex; + TextBox textBox = (TextBox)sender; + if (textBox.Text.Contains("/") && (new Regex("/")).Match(textBox.Text).Index < caretIndex) + { + caretIndex--; + } + string str = textBox.Text.Replace("/", ""); + string str1 = str.Substring(0, (str.Length > 4 ? 4 : str.Length)); + if ((new Regex("^0")).IsMatch(str1)) + { + if ((new Regex("^00")).IsMatch(str1)) + { + textBox.Text = this._vencimentoCartaoOld; + textBox.CaretIndex = caretIndex; + return; + } + } + else if ((new Regex("^1")).IsMatch(str1)) + { + if ((new Regex("^1[^0-2]")).IsMatch(str1)) + { + textBox.Text = this._vencimentoCartaoOld; + textBox.CaretIndex = caretIndex; + return; + } + } + else if ((new Regex("^[^01]")).IsMatch(str1)) + { + textBox.Text = this._vencimentoCartaoOld; + textBox.CaretIndex = caretIndex; + return; + } + if (str1.Length > 2) + { + textBox.Text = str1.Insert(2, "/"); + caretIndex++; + } + else if (textBox.Text.Contains("/")) + { + textBox.Text = str1; + } + textBox.CaretIndex = caretIndex; + this._vencimentoCartaoOld = str1; + } + + private void VendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + this.ViewModel.FiltrarRepasse((Vendedor)comboBox.SelectedItem); + if (this.ViewModel.CoCorretagem) + { + this.ComissaoNovoBox.Visibility = System.Windows.Visibility.Visible; + this.ComissaoRenovacaoBox.Visibility = System.Windows.Visibility.Collapsed; + } + } + + private void Vigencia_DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DateTime dateTime; + base.DatePicker_OnLostKeyboardFocus(sender, e); + DatePicker datePicker = (DatePicker)sender; + if (string.IsNullOrEmpty(datePicker.Text)) + { + return; + } + if (!DateTime.TryParse(ValidationHelper.FormatDate(datePicker.Text), out dateTime)) + { + return; + } + this.VigenciaFinalParcelaBox.SelectedDate = new DateTime?(dateTime.AddMonths(1)); + this.EmissaoParcelaBox.SelectedDate = new DateTime?(dateTime); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/ClienteView.cs b/Codemerx/Gestor.Application/Views/Seguros/ClienteView.cs new file mode 100644 index 0000000..5426996 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/ClienteView.cs @@ -0,0 +1,1307 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Generic; +using Gestor.Common.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Configuracoes; +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.Controls.Primitives; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; +using Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.Seguros +{ + public class ClienteView : BaseUserControl, IComponentConnector, IStyleConnector + { + public ClienteViewModel ViewModel; + + internal Grid MainGrid; + + internal MenuItem IncluirClienteButton; + + internal ComboBox TipoDocumentoPrincipalBox; + + internal TextBox DocumentoPrincipalBox; + + internal TextBox NomeBox; + + internal TextBox NomeSocialBox; + + internal TextBox CaepfBox; + + internal TextBox RneBox; + + internal TextBox CeiBox; + + internal TextBox IdentidadeBox; + + internal TextBox EmissorBox; + + internal TextBox EstadoEmissorBox; + + internal TextBox HabilitacaoBox; + + internal TextBox CategoriaHabilitacaooBox; + + internal ComboBox SexoBox; + + internal ComboBox EstadoCivilBox; + + internal AutoCompleteBox AutoCompleteProfissao; + + internal AutoCompleteBox AutoCompleteAtividade; + + internal TextBox ResponsavelBox; + + internal TextBox DocumentoResponsavel; + + internal TextBox EmailBox; + + internal TextBox PastaBox; + + internal AutoCompleteBox AutoCompleteBanco; + + internal TextBox AgenciaBox; + + internal TextBox TipoContaBox; + + internal TextBox ContaBox; + + internal CurrencyTextBox RendaMensalBox; + + internal ListBox TelefoneListBox; + + internal ListBox EmailListBox; + + internal ListBox EnderecoListBox; + + internal AutoCompleteBox VinculoBox; + + internal TextBox NomeOrigemBox; + + internal ListBox ContatosListBox; + + private bool _contentLoaded; + + private static int Ordem + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ClienteView(Cliente cliente = null, bool lockInsert = false, ClienteViewModel viewModel = null) + { + base.Tag = "CADASTRO DE CLIENTES"; + this.ViewModel = viewModel ?? new ClienteViewModel(cliente, !lockInsert); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + if (lockInsert) + { + this.IncluirClienteButton.IsEnabled = false; + } + if (cliente != null) + { + this.ViewModel.RegistrarAcao(string.Concat("ACESSOU CLIENTE \"", cliente.get_Nome(), "\""), cliente.get_Id(), new TipoTela?(1), string.Format("ID CLIENTE: {0}", cliente.get_Id())); + } + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 1).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedCliente.get_Id()); + filtroArquivoDigital.set_Tipo(1); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedCliente); + 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 ", EnumHelper.GetDescription(1), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(1, this.ViewModel.SelectedCliente.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(1, this.ViewModel.SelectedCliente.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + this.ClearInputFields(); + this.ValidarTela(); + this.ViewModel.SelectedCliente.Initialize(); + this.InitializeResponsavelAssinatura(); + this.ViewModel.Salvando = false; + } + + private void AutoCompleteAtividadeBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 1) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarAtividade(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 void AutoCompleteBanco_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + ClienteView.SetValid(autoCompleteBox, (string.IsNullOrWhiteSpace(autoCompleteBox.get_Text()) ? true : this.ViewModel.SelectedCliente.get_Banco() != null)); + } + + private void AutoCompleteBancoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarBanco(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 void AutoCompleteParentescoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarClienteVinculo(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim()), this.ViewModel.SelectedCliente.get_Id()).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void AutoCompleteProfissaoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 1) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarProfissao(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ClearInputFields(); + ClienteView.SetValid(this.AutoCompleteBanco, true); + this.ViewModel.CancelarAlteracao(); + } + + private void ClearInputFields() + { + object nome; + object empty; + object obj; + object nome1; + AutoCompleteBox autoCompleteBanco = this.AutoCompleteBanco; + Banco banco = this.ViewModel.SelectedCliente.get_Banco(); + if (banco != null) + { + nome = banco.get_Nome(); + } + else + { + nome = null; + } + if (nome == null) + { + nome = string.Empty; + } + autoCompleteBanco.set_Text((string)nome); + AutoCompleteBox autoCompleteProfissao = this.AutoCompleteProfissao; + Profissao profissao = this.ViewModel.SelectedCliente.get_Profissao(); + if (profissao != null) + { + empty = profissao.get_Nome(); + } + else + { + empty = null; + } + if (empty == null) + { + empty = string.Empty; + } + autoCompleteProfissao.set_Text((string)empty); + AutoCompleteBox autoCompleteBox = this.AutoCompleteProfissao; + Profissao profissao1 = this.ViewModel.SelectedCliente.get_Profissao(); + if (profissao1 != null) + { + obj = profissao1.get_Nome(); + } + else + { + obj = null; + } + if (obj == null) + { + obj = string.Empty; + } + autoCompleteBox.set_Text((string)obj); + AutoCompleteBox autoCompleteAtividade = this.AutoCompleteAtividade; + Atividade atividade = this.ViewModel.SelectedCliente.get_Atividade(); + if (atividade != null) + { + nome1 = atividade.get_Nome(); + } + else + { + nome1 = null; + } + if (nome1 == null) + { + nome1 = string.Empty; + } + autoCompleteAtividade.set_Text((string)nome1); + } + + private void ContentLoad() + { + string nome; + string str; + string nome1; + this.TelefoneListBox.DataContext = this.ViewModel; + this.EmailListBox.DataContext = this.ViewModel; + this.EnderecoListBox.DataContext = this.ViewModel; + this.ContatosListBox.DataContext = this.ViewModel; + this.DocumentoResponsavel.LostFocus += new RoutedEventHandler(this.Validar_LostFocus); + if (this.ViewModel.SelectedCliente == null) + { + return; + } + AutoCompleteBox autoCompleteBanco = this.AutoCompleteBanco; + Banco banco = this.ViewModel.SelectedCliente.get_Banco(); + if (banco != null) + { + nome = banco.get_Nome(); + } + else + { + nome = null; + } + autoCompleteBanco.set_Text(nome); + AutoCompleteBox autoCompleteAtividade = this.AutoCompleteAtividade; + Atividade atividade = this.ViewModel.SelectedCliente.get_Atividade(); + if (atividade != null) + { + str = atividade.get_Nome(); + } + else + { + str = null; + } + autoCompleteAtividade.set_Text(str); + AutoCompleteBox autoCompleteProfissao = this.AutoCompleteProfissao; + Profissao profissao = this.ViewModel.SelectedCliente.get_Profissao(); + if (profissao != null) + { + nome1 = profissao.get_Nome(); + } + else + { + nome1 = null; + } + autoCompleteProfissao.set_Text(nome1); + } + + private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e) + { + if (((TextBox)sender).IsReadOnly) + { + return; + } + TextBox textBox = (TextBox)sender; + string str = ValidationHelper.Clear(textBox.Text); + if (string.IsNullOrEmpty(str)) + { + return; + } + textBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14))); + if (textBox.Name == "DocumentoPrincipalBox") + { + this.ViewModel.JuridicaouFisica(this.DocumentoPrincipalBox.Text); + if (this.ViewModel.VisibilityFisica == System.Windows.Visibility.Visible) + { + this.ResponsavelBox.Text = string.Empty; + this.DocumentoResponsavel.Text = string.Empty; + this.EmailBox.Text = string.Empty; + } + } + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void ExcluirEmail_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(button); + ClienteEmail item = (ClienteEmail)listBox.Items[listBox.Items.IndexOf(button.DataContext)]; + this.ViewModel.ExcluirEmail(item); + } + + private void ExcluirEndereco_OnClick(object sender, RoutedEventArgs e) + { + Grid grid = Extentions.FindVisualAncestor((Button)sender); + ListBox listBox = Extentions.FindVisualAncestor(grid); + ClienteEndereco item = (ClienteEndereco)listBox.Items[listBox.Items.IndexOf(grid.DataContext)]; + this.ViewModel.ExcluirEndereco(item); + } + + private void ExcluirMaisContatos_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button == null || button.DataContext == null) + { + return; + } + MaisContato dataContext = (MaisContato)button.DataContext; + this.ViewModel.ExcluirContato(dataContext); + } + + private async void ExcluirOrigem_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button.DataContext != null) + { + this.ViewModel.Loading(true); + await this.ViewModel.ExcluirOrigem((OrigemCliente)button.DataContext); + this.ViewModel.Loading(false); + } + } + + private void ExcluirTelefone_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(button); + ClienteTelefone item = (ClienteTelefone)listBox.Items[listBox.Items.IndexOf(button.DataContext)]; + this.ViewModel.ExcluirTelefone(item); + } + + private void ExcluirVinculo_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button == null || button.DataContext == null) + { + return; + } + ClienteVinculo dataContext = (ClienteVinculo)button.DataContext; + this.ViewModel.ExcluirVinculo(dataContext); + } + + public override void FormatarDocumento(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + this.ViewModel.JuridicaouFisica(textBox.Text); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirCliente(); + this.DocumentoPrincipalBox.Text = ""; + this.AutoCompleteBanco.set_Text(""); + this.AutoCompleteProfissao.set_Text(""); + this.AutoCompleteAtividade.set_Text(""); + this.DocumentoPrincipalBox.Focus(); + this.ValidarTela(); + } + + private void IncluirEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirEmail(); + this.ValidarTela(); + } + + private void IncluirEndereco_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirEndereco(); + this.ValidarTela(); + } + + private void IncluirMaisContatos_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirContato(); + } + + private async void IncluirOrigem_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + await this.ViewModel.IncluirOrigem(this.NomeOrigemBox.Text.Trim()); + this.NomeOrigemBox.Text = string.Empty; + this.ViewModel.Loading(false); + } + + private void IncluirTelefone_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirTelefone(); + } + + private void IncluirVinculo_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.IncluirVinculo()) + { + this.VinculoBox.set_Text(""); + } + } + + [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/seguros/clienteview.xaml", UriKind.Relative)); + } + + private void InitializeResponsavelAssinatura() + { + object nomeResponsavel; + object documentoResponsavel; + object emailResponsavel; + TextBox responsavelBox = this.ResponsavelBox; + ResponsavelAssinatura responsavelAssinatura = this.ViewModel.SelectedCliente.get_ResponsavelAssinatura(); + if (responsavelAssinatura != null) + { + nomeResponsavel = responsavelAssinatura.get_NomeResponsavel(); + } + else + { + nomeResponsavel = null; + } + if (nomeResponsavel == null) + { + nomeResponsavel = string.Empty; + } + responsavelBox.Text = (string)nomeResponsavel; + TextBox textBox = this.DocumentoResponsavel; + ResponsavelAssinatura responsavelAssinatura1 = this.ViewModel.SelectedCliente.get_ResponsavelAssinatura(); + if (responsavelAssinatura1 != null) + { + documentoResponsavel = responsavelAssinatura1.get_DocumentoResponsavel(); + } + else + { + documentoResponsavel = null; + } + if (documentoResponsavel == null) + { + documentoResponsavel = string.Empty; + } + textBox.Text = (string)documentoResponsavel; + TextBox emailBox = this.EmailBox; + ResponsavelAssinatura responsavelAssinatura2 = this.ViewModel.SelectedCliente.get_ResponsavelAssinatura(); + if (responsavelAssinatura2 != null) + { + emailResponsavel = responsavelAssinatura2.get_EmailResponsavel(); + } + else + { + emailResponsavel = null; + } + if (emailResponsavel == null) + { + emailResponsavel = string.Empty; + } + emailBox.Text = (string)emailResponsavel; + } + + private void MenuItem_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogAntigo(); + } + + private void OrdemBox_OnLostFocus(object sender, RoutedEventArgs e) + { + int num; + int num1; + TextBox textBox = sender as TextBox; + if (textBox == null) + { + return; + } + if (textBox.IsReadOnly) + { + return; + } + if (!int.TryParse(textBox.Text, out num)) + { + return; + } + WrapPanel wrapPanel = Extentions.FindVisualAncestor(Extentions.FindVisualAncestor(textBox)); + ListBox listBox = Extentions.FindVisualAncestor(wrapPanel); + if (listBox != null) + { + for (int i = 0; i < listBox.Items.Count; i++) + { + if (i != listBox.Items.IndexOf(wrapPanel.DataContext)) + { + ContentPresenter contentPresenter = FindVisualChild.Find((ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(i)); + TextBox str = (TextBox)contentPresenter.ContentTemplate.FindName("OrdemBox", contentPresenter); + if (int.TryParse(str.Text, out num1) && num1 == num) + { + str.Text = ClienteView.Ordem.ToString(); + } + } + } + } + } + + private void OrdemBox_OnPreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + int num; + TextBox textBox = sender as TextBox; + if (textBox == null) + { + return; + } + if (!int.TryParse(textBox.Text, out num)) + { + return; + } + ClienteView.Ordem = num; + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + ContentPresenter contentPresenter; + DataTemplate contentTemplate; + ProgressBar progressBar; + TextBox textBox = (TextBox)sender; + if (!textBox.IsReadOnly) + { + if (!string.IsNullOrWhiteSpace(textBox.Text)) + { + string str = ValidationHelper.FormatPostCode(textBox.Text); + WrapPanel wrapPanel = Extentions.FindVisualAncestor(textBox); + ListBox listBox = Extentions.FindVisualAncestor(wrapPanel); + ListBoxItem listBoxItem = (ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(listBox.Items.IndexOf(wrapPanel.DataContext)); + contentPresenter = FindVisualChild.Find(listBoxItem); + contentTemplate = contentPresenter.ContentTemplate; + TextBox textBox1 = (TextBox)contentTemplate.FindName("CepBox", contentPresenter); + progressBar = (ProgressBar)contentTemplate.FindName("ProgressCep", contentPresenter); + progressBar.Visibility = System.Windows.Visibility.Visible; + textBox1.Text = str; + if (ValidationHelper.ValidatePostCode(str)) + { + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + TextBox endereco = (TextBox)contentTemplate.FindName("EnderecoBox", contentPresenter); + TextBox cidade = (TextBox)contentTemplate.FindName("CidadeBox", contentPresenter); + TextBox estado = (TextBox)contentTemplate.FindName("EstadoBox", contentPresenter); + TextBox bairro = (TextBox)contentTemplate.FindName("BairroBox", contentPresenter); + endereco.Text = enderecoBase.get_Endereco(); + cidade.Text = enderecoBase.get_Cidade(); + estado.Text = enderecoBase.get_Estado(); + bairro.Text = enderecoBase.get_Bairro(); + progressBar.Visibility = System.Windows.Visibility.Collapsed; + } + else + { + progressBar.Visibility = System.Windows.Visibility.Collapsed; + } + } + else + { + progressBar.Visibility = System.Windows.Visibility.Collapsed; + } + } + } + contentPresenter = null; + contentTemplate = null; + progressBar = null; + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.ViewModel.ProfissaoText = this.AutoCompleteProfissao.get_Text(); + this.ViewModel.AtividadeText = this.AutoCompleteAtividade.get_Text(); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs.Distinct>().ToList>(), this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + ClienteView.SetValid(this.AutoCompleteBanco, true); + } + } + + private static void SetValid(AutoCompleteBox autocomplete, bool valid) + { + ViewHelper.SetInvalid(autocomplete, "BANCO INVÁLIDO", valid); + } + + [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.MainGrid = (Grid)target; + return; + } + case 2: + { + this.IncluirClienteButton = (MenuItem)target; + this.IncluirClienteButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Tarefa_Click); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MenuItem_Click); + return; + } + case 12: + { + this.TipoDocumentoPrincipalBox = (ComboBox)target; + return; + } + case 13: + { + this.DocumentoPrincipalBox = (TextBox)target; + ClienteView clienteView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(clienteView.SomenteNumeros); + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + return; + } + case 14: + { + this.NomeBox = (TextBox)target; + return; + } + case 15: + { + this.NomeSocialBox = (TextBox)target; + return; + } + case 16: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewTextInput += new TextCompositionEventHandler(this.SomenteData); + return; + } + case 17: + { + this.CaepfBox = (TextBox)target; + return; + } + case 18: + { + this.RneBox = (TextBox)target; + return; + } + case 19: + { + this.CeiBox = (TextBox)target; + return; + } + case 20: + { + this.IdentidadeBox = (TextBox)target; + return; + } + case 21: + { + this.EmissorBox = (TextBox)target; + this.EmissorBox.PreviewTextInput += new TextCompositionEventHandler(this.SomenteCaracteres); + return; + } + case 22: + { + this.EstadoEmissorBox = (TextBox)target; + this.EstadoEmissorBox.PreviewTextInput += new TextCompositionEventHandler(this.SomenteCaracteres); + return; + } + case 23: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewTextInput += new TextCompositionEventHandler(this.SomenteData); + return; + } + case 24: + { + this.HabilitacaoBox = (TextBox)target; + ClienteView clienteView1 = this; + this.HabilitacaoBox.PreviewTextInput += new TextCompositionEventHandler(clienteView1.SomenteNumeros); + return; + } + case 25: + { + this.CategoriaHabilitacaooBox = (TextBox)target; + ClienteView clienteView2 = this; + this.CategoriaHabilitacaooBox.PreviewTextInput += new TextCompositionEventHandler(clienteView2.LetrasHabilitacao); + return; + } + case 26: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 27: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 28: + { + this.SexoBox = (ComboBox)target; + return; + } + case 29: + { + this.EstadoCivilBox = (ComboBox)target; + return; + } + case 30: + { + this.AutoCompleteProfissao = (AutoCompleteBox)target; + this.AutoCompleteProfissao.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteProfissaoBox_Populating)); + return; + } + case 31: + { + this.AutoCompleteAtividade = (AutoCompleteBox)target; + this.AutoCompleteAtividade.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteAtividadeBox_Populating)); + return; + } + case 32: + { + this.ResponsavelBox = (TextBox)target; + this.ResponsavelBox.LostFocus += new RoutedEventHandler(this.Validar_LostFocus); + return; + } + case 33: + { + this.DocumentoResponsavel = (TextBox)target; + ClienteView clienteView3 = this; + this.DocumentoResponsavel.PreviewTextInput += new TextCompositionEventHandler(clienteView3.SomenteNumeros); + this.DocumentoResponsavel.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + return; + } + case 34: + { + this.EmailBox = (TextBox)target; + this.EmailBox.LostFocus += new RoutedEventHandler(this.Validar_LostFocus); + return; + } + case 35: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 36: + { + this.PastaBox = (TextBox)target; + return; + } + case 37: + { + this.AutoCompleteBanco = (AutoCompleteBox)target; + this.AutoCompleteBanco.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteBancoBox_Populating)); + this.AutoCompleteBanco.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.AutoCompleteBanco_OnLostKeyboardFocus); + return; + } + case 38: + { + this.AgenciaBox = (TextBox)target; + return; + } + case 39: + { + this.TipoContaBox = (TextBox)target; + return; + } + case 40: + { + this.ContaBox = (TextBox)target; + return; + } + case 41: + { + this.RendaMensalBox = (CurrencyTextBox)target; + return; + } + case 42: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTelefone_OnClick); + return; + } + case 43: + { + this.TelefoneListBox = (ListBox)target; + return; + } + case 44: + case 45: + case 46: + case 47: + case 48: + case 51: + case 52: + case 55: + case 56: + case 57: + case 60: + case 63: + { + this._contentLoaded = true; + return; + } + case 49: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirEmail_OnClick); + return; + } + case 50: + { + this.EmailListBox = (ListBox)target; + return; + } + case 53: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirEndereco_OnClick); + return; + } + case 54: + { + this.EnderecoListBox = (ListBox)target; + return; + } + case 58: + { + this.VinculoBox = (AutoCompleteBox)target; + this.VinculoBox.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteParentescoBox_Populating)); + return; + } + case 59: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirVinculo_OnClick); + return; + } + case 61: + { + this.NomeOrigemBox = (TextBox)target; + return; + } + case 62: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirOrigem_OnClick); + return; + } + case 64: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirMaisContatos_OnClick); + return; + } + case 65: + { + this.ContatosListBox = (ListBox)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) + { + switch (connectionId) + { + case 44: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBox_OnSelectionChanged); + return; + } + case 45: + { + ClienteView clienteView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView.SomenteNumeros); + return; + } + case 46: + { + ClienteView clienteView1 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(clienteView1.FormatarTelefone); + ClienteView clienteView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView2.SomenteNumeros); + return; + } + case 47: + { + ((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus); + ClienteView clienteView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView3.SomenteNumeros); + return; + } + case 48: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirTelefone_OnClick); + return; + } + case 49: + case 50: + case 53: + case 54: + case 58: + case 59: + case 61: + case 62: + case 64: + case 65: + { + return; + } + case 51: + { + ((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus); + ClienteView clienteView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView4.SomenteNumeros); + return; + } + case 52: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirEmail_OnClick); + return; + } + case 55: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + ClienteView clienteView5 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView5.SomenteNumeros); + return; + } + case 56: + { + ((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus); + ClienteView clienteView6 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView6.SomenteNumeros); + return; + } + case 57: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirEndereco_OnClick); + return; + } + case 60: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirVinculo_OnClick); + return; + } + case 63: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirOrigem_OnClick); + return; + } + case 66: + { + ClienteView clienteView7 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(clienteView7.FormatarDocumento); + return; + } + case 67: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewTextInput += new TextCompositionEventHandler(this.SomenteData); + return; + } + case 68: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBox_OnSelectionChanged); + return; + } + case 69: + { + ClienteView clienteView8 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView8.SomenteNumeros); + return; + } + case 70: + { + ClienteView clienteView9 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(clienteView9.FormatarTelefone); + ClienteView clienteView10 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView10.SomenteNumeros); + return; + } + case 71: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirMaisContatos_OnClick); + return; + } + default: + { + return; + } + } + } + + private void Tarefa_Click(object sender, RoutedEventArgs e) + { + Tarefa tarefa = new Tarefa(); + tarefa.set_IdCliente(this.ViewModel.SelectedCliente.get_Id()); + tarefa.set_Cliente(this.ViewModel.SelectedCliente.get_Nome()); + tarefa.set_Entidade(2); + tarefa.set_IdEntidade(this.ViewModel.SelectedCliente.get_Id()); + tarefa.set_Titulo(this.ViewModel.SelectedCliente.get_Nome()); + this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa, true), 0, false); + } + + private void TipoComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + int num; + ComboBox comboBox = (ComboBox)sender; + CustomIsReadOnlyControl customIsReadOnlyControl = Extentions.FindVisualAncestor(comboBox); + if (customIsReadOnlyControl == null) + { + return; + } + WrapPanel wrapPanel = Extentions.FindVisualAncestor(customIsReadOnlyControl); + ListBox listBox = Extentions.FindVisualAncestor(wrapPanel); + ContentPresenter contentPresenter = FindVisualChild.Find((ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(listBox.Items.IndexOf(wrapPanel.DataContext))); + DataTemplate contentTemplate = contentPresenter.ContentTemplate; + CustomItemValidation customItemValidation = (CustomItemValidation)contentTemplate.FindName("Prefixo", contentPresenter); + CustomItemValidation customItemValidation1 = (CustomItemValidation)contentTemplate.FindName("Telefone", contentPresenter); + TextBox textBox = ViewHelper.FindChildren(customItemValidation).FirstOrDefault(); + TextBox textBox1 = ViewHelper.FindChildren(customItemValidation1).FirstOrDefault(); + if (textBox == null || textBox1 == null) + { + return; + } + if ((TipoTelefone)comboBox.SelectedValue == 8) + { + customItemValidation.Visibility = System.Windows.Visibility.Collapsed; + textBox1.MaxLength = 20; + return; + } + customItemValidation.Visibility = System.Windows.Visibility.Visible; + textBox1.MaxLength = 10; + num = (textBox1.Text.Length >= 10 ? 10 : textBox1.Text.Length); + textBox1.Text = textBox1.Text.Substring(0, num); + } + + private void Validar_LostFocus(object sender, RoutedEventArgs e) + { + this.ValidarTela(); + } + + private void ValidarTela() + { + object keyValuePairs; + object obj; + object keyValuePairs1; + if (this.ViewModel.SelectedCliente == null) + { + return; + } + List> keyValuePairs2 = this.ViewModel.SelectedCliente.Validate(); + if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 29)) + { + List> keyValuePairs3 = keyValuePairs2; + ClienteEmail clienteEmail = this.ViewModel.Emails.FirstOrDefault(); + if (clienteEmail != null) + { + keyValuePairs1 = clienteEmail.Validate(); + } + else + { + keyValuePairs1 = null; + } + if (keyValuePairs1 == null) + { + keyValuePairs1 = new List>(); + } + keyValuePairs3.AddRange((IEnumerable)keyValuePairs1); + } + List> keyValuePairs4 = keyValuePairs2; + ClienteTelefone clienteTelefone = this.ViewModel.Telefones.FirstOrDefault(); + if (clienteTelefone != null) + { + keyValuePairs = clienteTelefone.Validate(); + } + else + { + keyValuePairs = null; + } + if (keyValuePairs == null) + { + keyValuePairs = new List>(); + } + keyValuePairs4.AddRange((IEnumerable)keyValuePairs); + List> keyValuePairs5 = keyValuePairs2; + ClienteEndereco clienteEndereco = this.ViewModel.Enderecos.FirstOrDefault(); + if (clienteEndereco != null) + { + obj = clienteEndereco.Validate(); + } + else + { + obj = null; + } + if (obj == null) + { + obj = new List>(); + } + keyValuePairs5.AddRange((IEnumerable)obj); + this.ValidateFields(keyValuePairs2, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/ComissaoView.cs b/Codemerx/Gestor.Application/Views/Seguros/ComissaoView.cs new file mode 100644 index 0000000..7bbf613 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/ComissaoView.cs @@ -0,0 +1,1336 @@ +using Gestor.Application.Actions; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Comissao; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Text; +using System.Text.RegularExpressions; +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.Seguros +{ + public class ComissaoView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal ComboBox UsuarioBox; + + internal ComboBox StatusBox; + + internal ComboBox SeguradoraBox; + + internal ComboBox Seguradora2Box; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal DataGrid ExtratoGrid; + + internal Card ProgressBar2; + + internal Card ProgressBar; + + internal MenuItem DesfazerExtratoButton; + + internal DatePicker DataBaixaBox; + + internal TextBox FiltroDetalhes; + + internal DataGrid DetalhesGrid; + + internal Grid PainelCritica; + + internal AutoCompleteBox AutoCompleteCliente; + + internal TextBox TipoDocumentoPrincipalBox; + + internal TextBox DocumentoPrincipalBox; + + internal TextBox FiltroApoliceBox; + + internal DataGrid ApoliceGrid; + + internal DataGrid ParcelaGrid; + + internal DataGridTextColumn ParcelaColumn; + + internal DataGrid FaturaGrid; + + private bool _contentLoaded; + + public SubTipo _previousSubTipo { get; set; } = 2; + + public ComissaoViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ComissaoView() + { + base.Tag = "COMISSÃO AUTOMÁTICA"; + this.ViewModel = new ComissaoViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + this.ExtratoGrid.DataContext = base.DataContext; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if (!(new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 7).get_Consultar()) + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)7), "."), "OK", "", false); + } + else if (this.ViewModel.SelectedExtrato != null) + { + List indiceArquivoDigitals = await (new ArquivoDigitalServico()).BuscarPorTipo(7, this.ViewModel.SelectedExtrato.get_Id()); + if (indiceArquivoDigitals.Count != 1) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedExtrato.get_Id()); + filtroArquivoDigital.set_Tipo(7); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedExtrato); + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + } + else + { + this.ViewModel.Download(indiceArquivoDigitals.First(), true); + } + } + else + { + await this.ViewModel.ShowMessage("SELECIONE ALGUM EXTRATO PARA VISUALIZAR O ARQUIVO DIGITAL", "OK", "", false); + } + } + + private async Task AbrirCritica(DetalheExtrato detalhe) + { + List statusParcelas = new List() + { + 1, + 10, + 12, + 13 + }; + if (!detalhe.get_Status().HasValue || !statusParcelas.Contains(detalhe.get_Status().Value)) + { + this.ViewModel.FiltrarDetalheExtrato(detalhe.get_Id()); + await this.ViewModel.BuscarCriticado(detalhe); + if (!detalhe.get_Parcela().HasValue && !detalhe.get_Documento().HasValue) + { + this.AutoCompleteCliente.set_Text(detalhe.get_Cliente().Trim()); + } + this.ViewModel.Criticando = true; + this.PainelCritica.Visibility = System.Windows.Visibility.Visible; + this.FiltroDetalhes.Visibility = System.Windows.Visibility.Collapsed; + this.DetalhesGrid.Visibility = System.Windows.Visibility.Collapsed; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.FiltroApolice = string.Empty; + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL CRITICAR UMA PARCELA JÁ BAIXADA", "OK", "", false); + } + } + + private async void AbrirCritica_OnClick(object sender, RoutedEventArgs e) + { + object item; + if (this.DetalhesGrid.SelectedIndex >= 0) + { + DataGrid detalhesGrid = this.DetalhesGrid; + if (detalhesGrid != null) + { + item = detalhesGrid.Items[this.DetalhesGrid.SelectedIndex]; + } + else + { + item = null; + } + DetalheExtrato detalheExtrato = (DetalheExtrato)item; + if (detalheExtrato != null) + { + this.ViewModel.Loading(true); + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + await this.AbrirCritica(detalheExtrato); + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.Loading(false); + } + } + else + { + await this.ViewModel.ShowMessage("PARA CRITICAR O DOCUMENTO É NECESSÁRIO SELECIONAR UMA PARCELA", "OK", "", false); + } + } + + private async void AcessarApolice_OnClick(object sender, RoutedEventArgs e) + { + long? parcela; + Documento documento; + Documento documento1; + bool flag; + bool flag1; + Button button = (Button)sender; + if (button.DataContext != null && button.DataContext.GetType().Name.Equals("DetalheExtrato")) + { + DetalheExtrato dataContext = (DetalheExtrato)button.DataContext; + flag = (dataContext != null ? !dataContext.get_Documento().HasValue : true); + if (flag) + { + flag1 = (dataContext != null ? !dataContext.get_Parcela().HasValue : true); + if (flag1) + { + return; + } + } + if (!dataContext.get_Documento().HasValue) + { + if (!dataContext.get_Parcela().HasValue) + { + documento1 = null; + } + else + { + ComissaoViewModel viewModel = this.ViewModel; + parcela = dataContext.get_Parcela(); + documento1 = await viewModel.CarregaApoliceParcela(parcela.Value); + } + documento = documento1; + } + else + { + ComissaoViewModel comissaoViewModel = this.ViewModel; + parcela = dataContext.get_Documento(); + documento = await comissaoViewModel.CarregaApolice(parcela.Value); + } + Documento documento2 = documento; + if (documento2 != null) + { + if (!documento2.get_Excluido()) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ApoliceView(documento2, true, false, 0, (long)0, true), string.Concat("CADASTRO DE APÓLICE - ", documento2.get_Controle().get_Cliente().get_Nome(), " - ", documento2.get_Apolice()), nullable1, nullable, false)).Show(); + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSIVE VISUALIZAR UM DOCUMENTO EXCLUIDO.", "OK", "", false); + } + } + } + } + + private async void AcessarApoliceCritica_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ApoliceView(await this.ViewModel.CarregaApolice(this.ViewModel.SelectedDocumento.get_Id()), true, false, 0, (long)0, false), string.Concat("CADASTRO DE APÓLICE - ", this.ViewModel.SelectedCliente.get_Nome(), " - ", this.ViewModel.SelectedDocumento.get_Apolice()), nullable1, nullable, false)).Show(); + } + + private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdcionarFiltro(); + } + + private async void ApoliceGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + ComissaoViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaDocumento((Documento)obj); + } + } + + private async void ArquivoDigitalButton_OnClick(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + this.ViewModel.SelectedDocumento.get_Controle().set_Cliente(this.ViewModel.SelectedCliente); + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedDocumento.get_Id()); + filtroArquivoDigital.set_Tipo(2); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedDocumento); + 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)2), "."), "OK", "", false); + } + } + + private void Atualizar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.SelecionaSeguradora(this.ViewModel.SelectedSeguradora, this.ViewModel.SelectedStatusExtrato, this.ViewModel.SelectedExtrato); + } + + private async void AtualizarExtrato_OnClick(object sender, RoutedEventArgs e) + { + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.EnableButtons = false; + await this.ViewModel.AtualizarExtrato(); + await this.ViewModel.SelecionaExtrato(this.ViewModel.SelectedExtrato); + this.ViewModel.EnableButtons = true; + Action action = Gestor.Application.Actions.Actions.EnableMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMainMenu1 = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu1 != null) + { + enableMainMenu1(true); + } + else + { + } + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarCliente(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim()), null, 2).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private async void AutoCompleteBoxDetalhe_OnTextChanged(object sender, RoutedEventArgs e) + { + object text; + TextBox textBox = (TextBox)sender; + ComissaoViewModel viewModel = this.ViewModel; + if (textBox != null) + { + text = textBox.Text; + } + else + { + text = null; + } + if (text == null) + { + text = ""; + } + await viewModel.FiltrarDetalhe((string)text); + } + + private async void AutoCompleteBoxDocumento_OnTextChanged(object sender, RoutedEventArgs e) + { + object text; + TextBox textBox = (TextBox)sender; + ComissaoViewModel viewModel = this.ViewModel; + if (textBox != null) + { + text = textBox.Text; + } + else + { + text = null; + } + if (text == null) + { + text = ""; + } + await viewModel.FiltrarApolices((string)text); + } + + private async void BaixarParcelasSelecionadas_OnClick(object sender, RoutedEventArgs e) + { + ((MenuItem)sender).Click -= new RoutedEventHandler(this.BaixarParcelasSelecionadas_OnClick); + if (this.ViewModel.SelectedExtrato == null) + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarParcelasSelecionadas_OnClick); + } + else if (await this.ViewModel.ShowMessage(string.Concat("DESEJA BAIXAR TODAS AS PARCELAS SELECIONADAS DO EXTRATO ", this.ViewModel.SelectedExtrato.get_Numero(), "?"), "SIM", "NÃO", false)) + { + this.ViewModel.IsVisible = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.EnableButtons = false; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.EnableButtons = false; + await this.ViewModel.BaixarExtrato(true); + this.ViewModel.EnableButtons = true; + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ViewModel.EnableButtons = true; + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + this.ViewModel.WorkOnSelectedStatus(); + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarParcelasSelecionadas_OnClick); + } + else + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarParcelasSelecionadas_OnClick); + } + } + + private async void BaixarSelecionado_OnClick(object sender, RoutedEventArgs e) + { + ((MenuItem)sender).Click -= new RoutedEventHandler(this.BaixarSelecionado_OnClick); + if (this.ViewModel.SelectedExtrato == null) + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarSelecionado_OnClick); + } + else if (await this.ViewModel.ShowMessage(string.Concat("DESEJA BAIXAR TODAS AS PARCELAS PENDENTES DO EXTRATO ", this.ViewModel.SelectedExtrato.get_Numero(), "?"), "SIM", "NÃO", false)) + { + this.ViewModel.IsVisible = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.EnableButtons = false; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.EnableButtons = false; + await this.ViewModel.BaixarExtrato(false); + this.ViewModel.EnableButtons = true; + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ViewModel.EnableButtons = true; + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarSelecionado_OnClick); + } + else + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarSelecionado_OnClick); + } + } + + private void CancelarCritica_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDetalhe != null) + { + this.ViewModel.SelectedDetalhe.set_Corrigir(false); + } + this.LimparFiltros(); + } + + private void ContentLoad() + { + this.DataBaixaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.DataBaixaBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.SelectedDateChanged += new EventHandler(this.FiltroDataBox_OnSelectedDateChanged); + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.FimBox.SelectedDateChanged += new EventHandler(this.FiltroDataBox_OnSelectedDateChanged); + this.ExtratoGrid.SelectionChanged += new SelectionChangedEventHandler(this.Grid_OnSelectionChanged); + this.ExtratoGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + this.DetalhesGrid.MouseDoubleClick += new MouseButtonEventHandler(this.DetalhesGrid_OnMouseDoubleClick); + this.ApoliceGrid.SelectionChanged += new SelectionChangedEventHandler(this.ApoliceGrid_OnSelectionChanged); + } + + private async void CriticarDocumento_OnClick(object sender, RoutedEventArgs e) + { + DetalheExtrato selectedDetalhe; + int? nullable; + object item; + if (this.DetalhesGrid.SelectedIndex >= 0) + { + SubTipo? subTipo = this.ViewModel.SelectedDetalhe.get_SubTipo(); + if (subTipo.HasValue && subTipo.GetValueOrDefault() == 1) + { + if (this.ViewModel.SelectedParcela == null || this.ViewModel.SelectedParcela.get_Id() == 0) + { + await this.ViewModel.ShowMessage("PARA CRITICAR ESSE DOCUMENTO É NECESSÁRIO SELECIONAR UMA PARCELA", "OK", "", false); + return; + } + } + else if (this.ViewModel.SelectedDocumento == null || this.ViewModel.SelectedDocumento.get_Id() == 0) + { + await this.ViewModel.ShowMessage("PARA CRITICAR ESSE DOCUMENTO É NECESSÁRIO SELECIONAR UM DOCUMENTO", "OK", "", false); + return; + } + if (this.DetalhesGrid.SelectedIndex < 0) + { + DataGrid detalhesGrid = this.DetalhesGrid; + if (detalhesGrid != null) + { + nullable = new int?(detalhesGrid.Items.Count); + } + else + { + nullable = null; + } + int? nullable1 = nullable; + int selectedIndex = this.DetalhesGrid.SelectedIndex; + if (nullable1.GetValueOrDefault() < selectedIndex | !nullable1.HasValue) + { + goto Label2; + } + DataGrid dataGrid = this.DetalhesGrid; + if (dataGrid != null) + { + item = dataGrid.Items[this.DetalhesGrid.SelectedIndex]; + } + else + { + item = null; + } + selectedDetalhe = (DetalheExtrato)item; + goto Label1; + } + Label2: + selectedDetalhe = this.ViewModel.SelectedDetalhe; + Label1: + DetalheExtrato detalheExtrato = selectedDetalhe; + if (detalheExtrato != null) + { + await this.ViewModel.Criticar(detalheExtrato, true); + this.LimparFiltros(); + } + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR UMA PARCELA PARA CRITICAR.", "OK", "", false); + } + } + + private async void Desconsiderar_OnClick(object sender, RoutedEventArgs e) + { + object item; + if (this.DetalhesGrid.SelectedIndex >= 0) + { + DataGrid detalhesGrid = this.DetalhesGrid; + if (detalhesGrid != null) + { + item = detalhesGrid.Items[this.DetalhesGrid.SelectedIndex]; + } + else + { + item = null; + } + DetalheExtrato detalheExtrato = (DetalheExtrato)item; + if (detalheExtrato != null) + { + await this.ViewModel.Criticar(detalheExtrato, false); + this.LimparFiltros(); + } + } + else + { + await this.ViewModel.ShowMessage("PARA DESCONSIDERAR O DOCUMENTO É NECESSÁRIO SELECIONAR UMA PARCELA", "OK", "", false); + } + } + + private async void DesconsiderarSelacionadas_Click(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.ShowMessage(string.Concat("ESSA OPÇÃO DESCONSIDERA TODAS AS PARCELAS QUE FORAM SELECIONADAS, COLOCANDO STATUS DE DESCONSIDERADA PELO USUÁRIO", Environment.NewLine, "DESEJA CONTINUAR?"), "SIM", "NÃO", false)) + { + await this.ViewModel.DesconsiderarSelecionadas(); + } + } + + private async void DesconsiderarTodas_Click(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.ShowMessage(string.Concat("ESSA OPÇÃO DESCONSIDERA TODAS AS PARCELAS COM O STATUS DE DOCUMENTO NÃO ENCONTRADO OU PARCELA NÃO ENCONTRADA DO EXTRATO.", Environment.NewLine, "DESEJA CONTINUAR?"), "SIM", "NÃO", false)) + { + await this.ViewModel.CriticarTodos(this.ViewModel.SelectedExtrato.get_Id()); + this.LimparFiltros(); + } + } + + private async void DesfazerExtrato_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedExtrato != null) + { + if (await this.ViewModel.ShowMessage(string.Concat("DESEJA DESFAZER A BAIXA DO EXTRATO ", this.ViewModel.SelectedExtrato.get_Numero(), "?"), "SIM", "NÃO", false)) + { + this.ViewModel.IsVisible = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.EnableButtons = false; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + await this.ViewModel.DesfazerExtrato(); + this.ViewModel.EnableButtons = true; + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + } + } + } + + private async void DesfazerParcela_OnClick(object sender, RoutedEventArgs e) + { + object item; + DataGrid detalhesGrid = this.DetalhesGrid; + if (detalhesGrid != null) + { + item = detalhesGrid.Items[this.DetalhesGrid.SelectedIndex]; + } + else + { + item = null; + } + DetalheExtrato detalheExtrato = (DetalheExtrato)item; + if (detalheExtrato != null) + { + if (await this.ViewModel.ShowMessage(string.Concat("DESEJA DESFAZER A BAIXA DA PARCELA DO CLIENTE ", detalheExtrato.get_Cliente(), "?"), "SIM", "NÃO", false)) + { + this.ViewModel.Loading(true); + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.EnableButtons = false; + bool flag = await this.ViewModel.DesfazerParcela(detalheExtrato); + await this.ViewModel.CarregaDetalhes(this.ViewModel.SelectedExtrato); + ComissaoViewModel viewModel = this.ViewModel; + viewModel.ToggleSnackBar((flag ? "PARCELA DESFEITA COM SUCESSO" : "NÃO FOI POSSÍVEL DESFAZER A BAIXA DA PARCELA"), true); + if (flag && detalheExtrato.get_Parcela().HasValue) + { + ComissaoViewModel comissaoViewModel = this.ViewModel; + string str = string.Format("DESFEZ PARCELA DE ID \"{0}\"", detalheExtrato.get_Parcela()); + long? parcela = detalheExtrato.get_Parcela(); + comissaoViewModel.RegistrarAcao(str, parcela.Value, new TipoTela?(35), null); + } + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ViewModel.EnableButtons = true; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.Loading(false); + } + } + detalheExtrato = null; + } + + private async void DetalhesGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + this.ViewModel.Loading(true); + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + DetalheExtrato detalheExtrato = (DetalheExtrato)obj; + if (detalheExtrato != null) + { + await this.AbrirCritica(detalheExtrato); + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.Loading(false); + } + } + } + + private async void ExcluirExtrato_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedExtrato != null) + { + if (await this.ViewModel.ShowMessage(string.Concat("DESEJA EXCLUIR O EXTRATO ", this.ViewModel.SelectedExtrato.get_Numero(), "?"), "SIM", "NÃO", false)) + { + this.ViewModel.IsVisible = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.EnableButtons = false; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + await this.ViewModel.ExcluirExtrato(); + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ViewModel.EnableButtons = true; + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + } + } + } + + 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 FiltroDataBox_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + bool hasValue; + DatePicker datePicker = (DatePicker)sender; + if (datePicker != null) + { + hasValue = !datePicker.SelectedDate.HasValue; + } + else + { + hasValue = true; + } + if (hasValue) + { + return; + } + this.ViewModel.SelecionaSeguradora(this.ViewModel.SelectedSeguradora, this.ViewModel.SelectedStatusExtrato, null); + } + + private async void FinalizarSelecionado_OnClick(object sender, RoutedEventArgs e) + { + ((MenuItem)sender).Click -= new RoutedEventHandler(this.FinalizarSelecionado_OnClick); + if (this.ViewModel.SelectedExtrato != null) + { + ComissaoViewModel viewModel = this.ViewModel; + string[] numero = new string[] { "DESEJA FINALIZAR O EXTRATO ", this.ViewModel.SelectedExtrato.get_Numero(), "?", Environment.NewLine, "O EXTRATO SERÁ MARCADO COMO BAIXADO." }; + if (await viewModel.ShowMessage(string.Concat(numero), "SIM", "NÃO", false)) + { + this.ViewModel.IsVisible = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.EnableButtons = false; + await this.ViewModel.FinalizarExtrato(); + this.ViewModel.EnableButtons = true; + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + ((MenuItem)sender).Click += new RoutedEventHandler(this.FinalizarSelecionado_OnClick); + } + else + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.FinalizarSelecionado_OnClick); + } + } + else + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.FinalizarSelecionado_OnClick); + } + } + + private async void Grid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null) + { + if (dataGrid.SelectedIndex >= 0) + { + await this.ViewModel.SelecionaExtrato((Extrato)dataGrid.Items[dataGrid.SelectedIndex]); + } + } + } + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedExtrato != null) + { + string str = await this.ViewModel.GerarHtml(); + if (!string.IsNullOrEmpty(str)) + { + string tempPath = Path.GetTempPath(); + string str1 = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, (new Regex(string.Concat("[", Regex.Escape(string.Concat(new string(Path.GetInvalidFileNameChars()), new string(Path.GetInvalidPathChars()))), "]"))).Replace("EXTRATO COMISSÃO", ""), Funcoes.GetNetworkTime()); + StreamWriter streamWriter = new StreamWriter(str1, true, Encoding.UTF8); + streamWriter.Write(str); + streamWriter.Close(); + Process.Start(str1); + this.ViewModel.RegistrarAcao(string.Format("IMPRIMIU EXTRATO DE ID \"{0}\"", this.ViewModel.SelectedExtrato.get_Id()), this.ViewModel.SelectedExtrato.get_Id(), new TipoTela?(35), null); + } + } + } + + [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/seguros/comissaoview.xaml", UriKind.Relative)); + } + + private void LimparFiltros() + { + this.ViewModel.Criticando = false; + this.ViewModel.FiltrarDetalheExtrato(""); + this.PainelCritica.Visibility = System.Windows.Visibility.Collapsed; + this.FiltroDetalhes.Visibility = System.Windows.Visibility.Visible; + this.AutoCompleteCliente.set_Text(string.Empty); + this.DetalhesGrid.Visibility = System.Windows.Visibility.Visible; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(true); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu == null) + { + return; + } + enableMenu(true); + } + + private void Subtipo_OnDropDownOpened(object sender, EventArgs e) + { + this._previousSubTipo = (SubTipo)((ComboBox)sender).SelectedItem; + } + + private void Subtipo_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (!this.ViewModel.IsEnabled) + { + return; + } + ComboBox comboBox = (ComboBox)sender; + if ((SubTipo)comboBox.SelectedItem != 1) + { + return; + } + DetalheExtrato dataContext = (DetalheExtrato)comboBox.DataContext; + if ((SubTipo)comboBox.SelectedItem == 1 && dataContext.get_NumeroParcela() == "999" || !dataContext.IsNormal && dataContext.get_SubTipo().GetValueOrDefault() == 1) + { + comboBox.SelectedItem = this._previousSubTipo; + } + } + + [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.StatusBox = (ComboBox)target; + return; + } + case 3: + { + this.SeguradoraBox = (ComboBox)target; + return; + } + case 4: + { + this.Seguradora2Box = (ComboBox)target; + return; + } + case 5: + { + this.InicioBox = (DatePicker)target; + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + return; + } + case 6: + { + this.FimBox = (DatePicker)target; + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + return; + } + case 7: + { + ((Button)target).Click += new RoutedEventHandler(this.Atualizar_OnClick); + return; + } + case 8: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltro_OnClick); + return; + } + case 9: + case 29: + case 30: + case 31: + case 32: + case 33: + case 40: + case 41: + { + this._contentLoaded = true; + return; + } + case 10: + { + this.ExtratoGrid = (DataGrid)target; + return; + } + case 11: + { + this.ProgressBar2 = (Card)target; + return; + } + case 12: + { + this.ProgressBar = (Card)target; + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AtualizarExtrato_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.FinalizarSelecionado_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.BaixarParcelasSelecionadas_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.BaixarSelecionado_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.DesconsiderarTodas_Click); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.DesconsiderarSelacionadas_Click); + return; + } + case 19: + { + this.DesfazerExtratoButton = (MenuItem)target; + this.DesfazerExtratoButton.Click += new RoutedEventHandler(this.DesfazerExtrato_OnClick); + return; + } + case 20: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirExtrato_OnClick); + return; + } + case 21: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CriticarDocumento_OnClick); + return; + } + case 22: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Desconsiderar_OnClick); + return; + } + case 23: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CancelarCritica_OnClick); + return; + } + case 24: + { + this.DataBaixaBox = (DatePicker)target; + this.DataBaixaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + return; + } + case 25: + { + this.FiltroDetalhes = (TextBox)target; + this.FiltroDetalhes.TextChanged += new TextChangedEventHandler(this.AutoCompleteBoxDetalhe_OnTextChanged); + return; + } + case 26: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 27: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 28: + { + this.DetalhesGrid = (DataGrid)target; + return; + } + case 34: + { + this.PainelCritica = (Grid)target; + return; + } + case 35: + { + this.AutoCompleteCliente = (AutoCompleteBox)target; + this.AutoCompleteCliente.add_Populating(new PopulatingEventHandler(this, ComissaoView.AutoCompleteBox_Populating)); + return; + } + case 36: + { + this.TipoDocumentoPrincipalBox = (TextBox)target; + return; + } + case 37: + { + this.DocumentoPrincipalBox = (TextBox)target; + return; + } + case 38: + { + this.FiltroApoliceBox = (TextBox)target; + this.FiltroApoliceBox.TextChanged += new TextChangedEventHandler(this.AutoCompleteBoxDocumento_OnTextChanged); + return; + } + case 39: + { + this.ApoliceGrid = (DataGrid)target; + return; + } + case 42: + { + this.ParcelaGrid = (DataGrid)target; + return; + } + case 43: + { + this.ParcelaColumn = (DataGridTextColumn)target; + return; + } + case 44: + { + this.FaturaGrid = (DataGrid)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 == 9) + { + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_onClick)); + return; + } + switch (connectionId) + { + case 29: + { + ((Button)target).Click += new RoutedEventHandler(this.AcessarApolice_OnClick); + return; + } + case 30: + { + ((ComboBox)target).DropDownOpened += new EventHandler(this.Subtipo_OnDropDownOpened); + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Subtipo_OnSelectionChanged); + return; + } + case 31: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirCritica_OnClick); + return; + } + case 32: + { + ((Button)target).Click += new RoutedEventHandler(this.Desconsiderar_OnClick); + return; + } + case 33: + { + ((Button)target).Click += new RoutedEventHandler(this.DesfazerParcela_OnClick); + return; + } + case 34: + case 35: + case 36: + case 37: + case 38: + case 39: + { + return; + } + case 40: + { + ((Button)target).Click += new RoutedEventHandler(this.AcessarApoliceCritica_OnClick); + return; + } + case 41: + { + ((Button)target).Click += new RoutedEventHandler(this.ArquivoDigitalButton_OnClick); + return; + } + default: + { + return; + } + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/ConsultaOriginalView.cs b/Codemerx/Gestor.Application/Views/Seguros/ConsultaOriginalView.cs new file mode 100644 index 0000000..0e5096d --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/ConsultaOriginalView.cs @@ -0,0 +1,1502 @@ +using Gestor.Application.Actions; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.MalaDireta; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +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.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.Media; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros +{ + public class ConsultaOriginalView : BaseUserControl, IComponentConnector, IStyleConnector + { + public ConsultaViewModel ViewModel; + + private bool _carregarDocumetos = true; + + internal RadioButton ApoliceRadioButton; + + internal RadioButton EndossoRadioButton; + + internal MenuItem AcessarDocumentoMenuItem; + + internal DataGrid ApoliceGrid; + + internal DataGridTextColumn NomeField; + + internal DataGridTextColumn ApelidoField; + + internal DataGridTextColumn ApolicesComissaoColumn; + + internal DataGrid EndossoGrid; + + internal DataGridTextColumn EndossosComissaoColumn; + + internal WrapPanel Comissao; + + internal DataGrid ParcelaGrid; + + internal DataGridTextColumn ParcelasTotalColumn; + + internal DataGridTextColumn ParcelasRealizadoColumn; + + internal DataGridTextColumn ParcelasComissaoColumn; + + internal DataGridTextColumn ParcelasReciboColumn; + + internal DataGridTextColumn ParcelasValorComissaoDescColumn; + + internal DataGridTemplateColumn MaisInformacoesColumn; + + internal RadioButton AtivosRadioButton; + + internal RadioButton ApoliceItensRadioButton; + + internal RadioButton EndossoItensRadioButton; + + internal RadioButton InativosRadioButton; + + internal DataGrid ItemGrid; + + private bool _contentLoaded; + + private Documento _documentoAssistencia + { + get; + set; + } + + private string _linkAssistencia + { + get; + set; + } + + public ConsultaOriginalView(ConsultaViewModel viewModel) + { + base.Tag = "CONSULTA DE DOCUMENTOS"; + this.ViewModel = viewModel ?? new ConsultaViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + Gestor.Application.Actions.Actions.UpdateRadioApolice = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.UpdateRadioApolice, new Action(this.SelecionarRadios)); + Gestor.Application.Actions.Actions.ScrollDocumento = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.ScrollDocumento, new Action(this.ScrollDocumento)); + Gestor.Application.Actions.Actions.ScrollToItem = new Action(this.ScrollToItem); + Gestor.Application.Actions.Actions.ScrollToItem = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.ScrollToItem, new Action(this.ScrollToItem)); + this.ItemGrid.DataContext = this.ViewModel; + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + FiltroArquivoDigital filtroArquivoDigital = null; + ConsultaViewModel.DocumentoSelecionado.get_Controle().set_Cliente(this.ViewModel.SelectedCliente); + string name = ((Button)sender).Name; + if (name == "Apolice") + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + this.ViewModel.SelectedControle.get_Controle().set_Cliente(this.ViewModel.SelectedCliente); + FiltroArquivoDigital filtroArquivoDigital1 = new FiltroArquivoDigital(); + filtroArquivoDigital1.set_Id(this.ViewModel.SelectedControle.get_Id()); + filtroArquivoDigital1.set_Tipo(2); + filtroArquivoDigital1.set_Parente(this.ViewModel.SelectedControle); + filtroArquivoDigital = filtroArquivoDigital1; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)2), "."), "OK", "", false); + return; + } + } + else if (name == "Endosso") + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + this.ViewModel.SelectedEndosso.get_Controle().set_Cliente(this.ViewModel.SelectedCliente); + FiltroArquivoDigital filtroArquivoDigital2 = new FiltroArquivoDigital(); + filtroArquivoDigital2.set_Id(this.ViewModel.SelectedEndosso.get_Id()); + filtroArquivoDigital2.set_Tipo(2); + filtroArquivoDigital2.set_Parente(this.ViewModel.SelectedEndosso); + filtroArquivoDigital = filtroArquivoDigital2; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)2), "."), "OK", "", false); + return; + } + } + else if (name != "Parcela") + { + if (name == "Item") + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + this.ViewModel.SelectedItem.set_Documento(ConsultaViewModel.DocumentoSelecionado); + FiltroArquivoDigital filtroArquivoDigital3 = new FiltroArquivoDigital(); + filtroArquivoDigital3.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital3.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital3.set_Tipo(4); + filtroArquivoDigital3.set_Parente(this.ViewModel.SelectedItem); + filtroArquivoDigital = filtroArquivoDigital3; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)4), "."), "OK", "", false); + return; + } + } + } + else if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 3).get_Consultar()) + { + this.ViewModel.SelectedParcela.set_Documento(ConsultaViewModel.DocumentoSelecionado); + FiltroArquivoDigital filtroArquivoDigital4 = new FiltroArquivoDigital(); + filtroArquivoDigital4.set_Id(this.ViewModel.SelectedParcela.get_Id()); + filtroArquivoDigital4.set_IdApolice(this.ViewModel.SelectedParcela.get_Documento().get_Id()); + filtroArquivoDigital4.set_Tipo(3); + filtroArquivoDigital4.set_Parente(this.ViewModel.SelectedParcela); + filtroArquivoDigital = filtroArquivoDigital4; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)3), "."), "OK", "", false); + return; + } + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + } + + private async Task AbrirProspeccao(Prospeccao data) + { + do + { + Label1: + if (await this.ViewModel.ShowProspeccaoDialog(data) != null) + { + List> keyValuePairs = await this.ViewModel.SalvarProspeccao(data); + if (keyValuePairs == null || keyValuePairs.Count == 0) + { + this.ViewModel.ToggleSnackBar("PROSPECÇÃO SALVA COM SUCESSO.", true); + return; + } + else + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + goto Label1; + } + } + else + { + } + } + while (!await this.ViewModel.ShowMessage("DESEJA REALMENTE NÃO CADASTRAR UMA PROSPECÇÃO PARA ESSE DOCUMENTO?", "SIM", "NÃO", false)); + } + + private void AjustaItem() + { + this.AtivosRadioButton.IsChecked = new bool?(this.ViewModel.FilterItens == 0); + this.ApoliceItensRadioButton.IsChecked = new bool?(this.ViewModel.FilterItens == 1); + this.EndossoItensRadioButton.IsChecked = new bool?(this.ViewModel.FilterItens == 2); + this.InativosRadioButton.IsChecked = new bool?(this.ViewModel.FilterItens == 3); + } + + private async void ApoliceGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + object obj; + long? nullable; + object obj1; + DataGridRow dataGridRow = (DataGridRow)sender; + if (dataGridRow != null) + { + if (dataGridRow.DataContext.GetType() == typeof(Documento)) + { + this.AtivosRadioButton.IsChecked = new bool?(true); + obj = (dataGridRow != null ? dataGridRow.Item : null); + Documento documento = (Documento)obj; + if (documento != null) + { + nullable = new long?(documento.get_Id()); + } + else + { + nullable = null; + } + long? nullable1 = nullable; + long id = this.ViewModel.SelectedControle.get_Id(); + if (nullable1.GetValueOrDefault() != id | !nullable1.HasValue) + { + ConsultaViewModel viewModel = this.ViewModel; + obj1 = (dataGridRow != null ? dataGridRow.Item : null); + await viewModel.SelecionaDocumento(0, (Documento)obj1); + } + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela != null) + { + acessaTela(2, ""); + } + else + { + } + } + } + } + + private async void ApoliceGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + ConsultaViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaDocumento(0, (Documento)obj); + this.VisibilityValorPago(); + } + } + + private void ApoliceView_Click(object sender, RoutedEventArgs e) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(2, ""); + } + + private void ClienteView_Click(object sender, RoutedEventArgs e) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(1, ""); + } + + private void ContentLoad() + { + if (ConsultaViewModel.DocumentoSelecionado != null && ConsultaViewModel.DocumentoSelecionado.get_Tipo() != 0) + { + this.ViewModel.FilterDocumento = 1; + } + this.NomeField.Visibility = (this.ViewModel.Apelido ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ApelidoField.Visibility = (!this.ViewModel.Apelido ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ApoliceRadioButton.IsChecked = new bool?(this.ViewModel.FilterDocumento == 0); + this.EndossoRadioButton.IsChecked = new bool?(this.ViewModel.FilterDocumento == 1); + this.AjustaItem(); + this.ApoliceGrid.SelectionChanged += new SelectionChangedEventHandler(this.ApoliceGrid_OnSelectionChanged); + this.ParcelaGrid.MouseDoubleClick += new MouseButtonEventHandler(ConsultaOriginalView.ParcelaGrid_OnMouseDoubleClick); + this.EndossoGrid.SelectionChanged += new SelectionChangedEventHandler(this.EndossoGrid_OnSelectionChanged); + this.EndossoGrid.MouseDoubleClick += new MouseButtonEventHandler(this.EndossoGrid_OnMouseDoubleClick); + this.AtivosRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.ApoliceItensRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.EndossoItensRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.InativosRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.ApoliceRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.EndossoRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.ItemGrid.SelectionChanged += new SelectionChangedEventHandler(this.ItemGrid_OnSelectionChanged); + this.ItemGrid.MouseDoubleClick += new MouseButtonEventHandler(this.ItemGrid_OnMouseDoubleClick); + System.Windows.Visibility visibility = (this.ViewModel.Restricao(14) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ViewModel.ComissaoValorVisibility = (this.ViewModel.Restricao(14) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + bool flag = this.ViewModel.Restricao(95); + this.ApolicesComissaoColumn.Visibility = (flag ? System.Windows.Visibility.Visible : visibility); + this.EndossosComissaoColumn.Visibility = (flag ? System.Windows.Visibility.Visible : visibility); + this.Comissao.Visibility = visibility; + bool flag1 = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5); + this.ParcelasRealizadoColumn.Visibility = visibility; + this.ParcelasComissaoColumn.Visibility = (flag ? System.Windows.Visibility.Visible : visibility); + this.ParcelasReciboColumn.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.ParcelasValorComissaoDescColumn.Visibility = (flag1 ? visibility : System.Windows.Visibility.Collapsed); + this.MaisInformacoesColumn.Visibility = visibility; + } + + private async void Documento_OnChecked(object sender, RoutedEventArgs e) + { + object obj; + object obj1; + MenuItem acessarDocumentoMenuItem = this.AcessarDocumentoMenuItem; + obj = (this.ViewModel.FilterDocumento == 0 ? "ACESSAR APÓLICE" : "ACESSAR ENDOSSO"); + acessarDocumentoMenuItem.Header = obj; + MenuItem menuItem = this.AcessarDocumentoMenuItem; + obj1 = (this.ViewModel.FilterDocumento == 0 ? "CLIQUE PARA ACESSAR A TELA DA APÓLICE" : "CLIQUE PARA ACESSAR A TELA DE ENDOSSO"); + menuItem.ToolTip = obj1; + RadioButton radioButton = (RadioButton)sender; + if (!string.IsNullOrEmpty(radioButton.GroupName)) + { + string groupName = radioButton.GroupName; + if (groupName != "Apolices") + { + if (groupName == "Itens") + { + string name = radioButton.Name; + if (name == "ApoliceItensRadioButton") + { + await this.ViewModel.SelecionaItens(1, null, (long)0, false); + } + else if (name == "EndossoItensRadioButton") + { + await this.ViewModel.SelecionaItens(2, null, (long)0, false); + } + else if (name == "InativosRadioButton") + { + await this.ViewModel.SelecionaItens(3, null, (long)0, false); + } + else + { + await this.ViewModel.SelecionaItens(0, null, (long)0, false); + } + } + } + else if (!this._carregarDocumetos) + { + return; + } + else if (radioButton.Name == "EndossoRadioButton") + { + this.AcessarDocumentoMenuItem.Header = "ACESSAR ENDOSSO"; + this.AcessarDocumentoMenuItem.ToolTip = "CLIQUE PARA ACESSAR A TELA DE ENDOSSO"; + this.ViewModel.CarregaDocumentos(1); + if (this.EndossoGrid.SelectedItem == null && this.EndossoGrid.Items.Count > 0) + { + this.EndossoGrid.SelectedItem = this.EndossoGrid.Items[0]; + } + if (this.EndossoGrid.SelectedItem != null) + { + await this.ViewModel.SelecionaDocumento(1, (Documento)this.EndossoGrid.SelectedItem); + } + } + else + { + this.AcessarDocumentoMenuItem.Header = "ACESSAR APÓLICE"; + this.AcessarDocumentoMenuItem.ToolTip = "CLIQUE PARA ACESSAR A TELA DA APÓLICE"; + this.ViewModel.CarregaDocumentos(0); + if (this.ApoliceGrid.SelectedItem == null && this.ApoliceGrid.Items.Count > 0) + { + this.ApoliceGrid.SelectedItem = this.ApoliceGrid.Items[0]; + } + if (this.ApoliceGrid.SelectedItem != null) + { + await this.ViewModel.SelecionaDocumento(0, (Documento)this.ApoliceGrid.SelectedItem); + } + } + } + } + + private async void EditarParcelas_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.EditarParcelas(); + } + + private async void Endossar_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.Restricao(33)) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ENDOSSAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + else if (!this.ViewModel.EnableEndossar) + { + List> keyValuePairs = this.ViewModel.SelectedControle.ValidateEndossar(); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (ConsultaViewModel.DocumentoSelecionado.get_Situacao() != 7) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela != null) + { + acessaTela(2, "Endossar"); + } + else + { + } + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ENDOSSAR UM DOCUMENTO RECUSADO.", "OK", "", false); + } + } + + private async void EndossoGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + this.AtivosRadioButton.IsChecked = new bool?(true); + ConsultaViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaDocumento(1, (Documento)obj); + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela != null) + { + acessaTela(2, ""); + } + else + { + } + } + } + + private async void EndossoGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + ConsultaViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaDocumento(1, (Documento)obj); + this.VisibilityValorPago(); + } + } + + private void EnviarPorEmail_OnClick(object sender, RoutedEventArgs e) + { + if (this._documentoAssistencia == null) + { + return; + } + MalaDireta malaDiretum = new MalaDireta(); + malaDiretum.set_Cliente(this.ViewModel.SelectedCliente); + malaDiretum.set_Apolice(this._documentoAssistencia); + MalaDireta malaDiretum1 = malaDiretum; + if (Funcoes.IsWindowOpen("ENVIO DE E-MAIL")) + { + Funcoes.Destroy("ENVIO DE E-MAIL"); + } + (new HosterWindow(new MalaDiretaView(new List() + { + malaDiretum1 + }, string.Concat("CARTÃO ASSISTÊNCIA 24 HORAS - ", malaDiretum1.get_Cliente().get_Nome(), " ", malaDiretum1.get_Apolice().get_Apolice()), string.Concat(new string[] { "

Prezado(a) ", ValidationHelper.Captalize(this.ViewModel.SelectedCliente.get_Nome()), ", segue o link do seu Cartão Assistência 24 horas.

LINK CARTÃO ASSITÊNCIA

" }), null), "ENVIO DE E-MAIL", new double?((double)1200), new double?((double)600), true)).ShowDialog(); + } + + private async void EnviarPorWhatsApp_OnClick(object sender, RoutedEventArgs e) + { + string str; + if (!this.ViewModel.Restricao(32)) + { + Button button = (Button)sender; + if (button.DataContext != null) + { + ClienteTelefone dataContext = button.DataContext as ClienteTelefone; + 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(this.ViewModel.Anotacoes)) + { + 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; + } + } + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR O WHATSAPP", "OK", "", false); + } + } + + private async void ExpedicaoInfo_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.VerificarPermissao(46, false)) + { + if (ConsultaViewModel.DocumentoSelecionado != null) + { + this.ViewModel.ShowDrawer(new ExpedicaoDrawer(ConsultaViewModel.DocumentoSelecionado), 0, false); + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR UM DOCUMENTO PARA EXIBIR AS INFORMAÇÕES DE EXPEDIÇÃO.", "OK", "", false); + } + } + } + + private async void Extratos_OnClick(object sender, RoutedEventArgs e) + { + Relatorio? nullable; + if (await this.ViewModel.VerificarRestricao(13, false, true) && this.ViewModel.SelectedCliente.get_Id() != 0) + { + this.ViewModel.Loading(true); + if (this.ViewModel.SelectedControle != null) + { + int filterDocumento = this.ViewModel.FilterDocumento; + if (filterDocumento != 0) + { + if (filterDocumento == 1) + { + if (this.ViewModel.SelectedEndosso != null) + { + ConsultaViewModel viewModel = this.ViewModel; + List documentos = new List() + { + this.ViewModel.SelectedEndosso + }; + nullable = null; + List nums = new List() + { + this.ViewModel.SelectedEndosso.get_Id() + }; + viewModel.ShowDrawer(new ExtratosDrawer(null, documentos, nullable, nums, null, null), 0, false); + } + } + } + else if (this.ViewModel.SelectedControle != null) + { + ConsultaViewModel consultaViewModel = this.ViewModel; + List documentos1 = new List() + { + this.ViewModel.SelectedControle + }; + nullable = null; + List nums1 = new List() + { + this.ViewModel.SelectedControle.get_Id() + }; + consultaViewModel.ShowDrawer(new ExtratosDrawer(null, documentos1, nullable, nums1, null, null), 0, false); + } + this.ViewModel.Loading(false); + } + else + { + ConsultaViewModel viewModel1 = this.ViewModel; + List clientesAtivosInativos = new List(); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Selecionado(true); + clientesAtivosInativo.set_EntidadeCliente(this.ViewModel.SelectedCliente); + clientesAtivosInativo.set_Id(this.ViewModel.SelectedCliente.get_Id()); + clientesAtivosInativo.set_Nome(this.ViewModel.SelectedCliente.get_Nome()); + clientesAtivosInativo.set_Documento(this.ViewModel.SelectedCliente.get_Documento()); + clientesAtivosInativos.Add(clientesAtivosInativo); + viewModel1.ShowDrawer(new ExtratosDrawer(clientesAtivosInativos, null, new Relatorio?(0), null, null, null), 0, false); + this.ViewModel.Loading(false); + } + } + } + + public Visual GetDescendantByType(Visual element, Type type) + { + if (element == null) + { + return null; + } + if (element.GetType() == type) + { + return element; + } + Visual descendantByType = null; + FrameworkElement frameworkElement = element as FrameworkElement; + if (frameworkElement != null) + { + frameworkElement.ApplyTemplate(); + } + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++) + { + Visual child = VisualTreeHelper.GetChild(element, i) as Visual; + descendantByType = this.GetDescendantByType(child, type); + if (descendantByType != null) + { + break; + } + } + return descendantByType; + } + + [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/seguros/consultaoriginalview.xaml", UriKind.Relative)); + } + + private void Item_Click(object sender, RoutedEventArgs e) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(3, ""); + } + + private void ItemGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaItem((Item)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(3, ""); + } + + private void ItemGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + Item selectedItem = (Item)dataGrid.SelectedItem; + if (!selectedItem.get_Cancelado() && !selectedItem.get_Substituido().HasValue && selectedItem.get_Status() != null) + { + this.AjustaItem(); + } + this.ViewModel.SelecionaItem((Item)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private async void ManutecaoItens_OnClick(object sender, RoutedEventArgs e) + { + if ((this.ViewModel.FilterDocumento != 0 || this.ViewModel.SelectedControle.get_Situacao() != 7) && (this.ViewModel.FilterDocumento != 1 || this.ViewModel.SelectedEndosso.get_Situacao() != 7)) + { + this.ViewModel.ManutecaoItens(); + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL FAZER A MANUTENÇÃO DE ITENS DE UM DOCUMENTO RECUSADO.", "OK", "", false); + } + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + Tarefa tarefa = new Tarefa(); + tarefa.set_IdCliente(this.ViewModel.SelectedCliente.get_Id()); + tarefa.set_Cliente(this.ViewModel.SelectedCliente.get_Nome()); + tarefa.set_Entidade(0); + tarefa.set_IdEntidade(this.ViewModel.SelectedControle.get_Id()); + tarefa.set_Titulo(string.Concat(this.ViewModel.SelectedCliente.get_Nome(), " APÓLICE ", this.ViewModel.SelectedControle.get_Apolice())); + this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa, true), 0, false); + } + + private async void MostrarItens_Click(object sender, RoutedEventArgs e) + { + bool valueOrDefault; + bool flag; + int num = 0; + if (!this.ApoliceRadioButton.IsFocused) + { + RadioButton apoliceItensRadioButton = this.ApoliceItensRadioButton; + if (apoliceItensRadioButton != null) + { + flag = apoliceItensRadioButton.IsChecked.GetValueOrDefault(); + } + else + { + flag = false; + } + if (!flag) + { + goto Label0; + } + } + num = 1; + Label0: + if (!this.EndossoRadioButton.IsFocused) + { + RadioButton endossoItensRadioButton = this.EndossoItensRadioButton; + if (endossoItensRadioButton != null) + { + valueOrDefault = endossoItensRadioButton.IsChecked.GetValueOrDefault(); + } + else + { + valueOrDefault = false; + } + if (!valueOrDefault) + { + if (this.InativosRadioButton.IsFocused) + { + num = 3; + } + await this.ViewModel.MostrarItens(num); + return; + } + } + num = 2; + if (this.InativosRadioButton.IsFocused) + { + num = 3; + } + await this.ViewModel.MostrarItens(num); + } + + private void Observacoes_OnClick(object sender, RoutedEventArgs e) + { + long id = (long)0; + TipoTela tipoTela = 0; + string name = ((Button)sender).Name; + if (name == "ObservacaoApolice") + { + id = this.ViewModel.SelectedControle.get_Id(); + tipoTela = 2; + } + else if (name == "EndossoInfo") + { + id = this.ViewModel.SelectedEndosso.get_Id(); + tipoTela = 2; + } + else if (name == "ObservacaoParcela") + { + id = this.ViewModel.SelectedParcela.get_Id(); + tipoTela = 5; + } + this.ViewModel.ShowDrawer(new ObservacoesDrawer(id, tipoTela), 0, true); + } + + private void Parcela_Click(object sender, RoutedEventArgs e) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(2, "Parcela"); + } + + private static void ParcelaGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + ConsultaViewModel.ParcelaSelecionada = (Parcela)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null)); + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(2, "Parcela"); + } + + private async void Perdido_OnClick(object sender, RoutedEventArgs e) + { + object prefixo; + object numero; + string str; + string numero1; + object email; + DateTime dateTime; + string descricao; + object selectedItem; + bool count; + Cliente cliente; + if (ConsultaViewModel.DocumentoSelecionado.get_Situacao() == 7) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ALTERAR O STATUS PARA PERDIDO DE UM DOCUMENTO RECUSADO.", "OK", "", false); + } + else if (await this.ViewModel.ShowMessage("DESEJA REALMENTE ALTERAR O STATUS DO SEGURO PARA PERDIDO?", "SIM", "NÃO", false)) + { + this.ViewModel.Loading(true); + cliente = await (new ClienteServico()).BuscarCliente(this.ViewModel.SelectedControle.get_Controle().get_Cliente().get_Id()); + Cliente cliente1 = cliente; + ObservableCollection observableCollection = await (new ClienteServico()).BuscarTelefonesAsync(this.ViewModel.SelectedControle.get_Controle().get_Cliente().get_Id()); + cliente1.set_Telefones(observableCollection); + cliente1 = null; + cliente1 = cliente; + ObservableCollection observableCollection1 = await (new ClienteServico()).BuscarEmailsAsync(this.ViewModel.SelectedControle.get_Controle().get_Cliente().get_Id()); + cliente1.set_Emails(observableCollection1); + cliente1 = null; + if (await (new ApoliceServico()).Perdido(this.ViewModel.SelectedControle.get_Controle().get_Id())) + { + Prospeccao prospeccao = new Prospeccao(); + prospeccao.set_Nome(cliente.get_Nome()); + prospeccao.set_Documento(cliente.get_Documento()); + prospeccao.set_Nascimento(cliente.get_Nascimento()); + ObservableCollection telefones = cliente.get_Telefones(); + if (telefones != null) + { + ClienteTelefone clienteTelefone = telefones.FirstOrDefault(); + if (clienteTelefone != null) + { + prefixo = clienteTelefone.get_Prefixo(); + } + else + { + prefixo = null; + } + } + else + { + prefixo = null; + } + if (prefixo == null) + { + prefixo = ""; + } + prospeccao.set_Prefixo1((string)prefixo); + ObservableCollection telefones1 = cliente.get_Telefones(); + if (telefones1 != null) + { + ClienteTelefone clienteTelefone1 = telefones1.FirstOrDefault(); + if (clienteTelefone1 != null) + { + numero = clienteTelefone1.get_Numero(); + } + else + { + numero = null; + } + } + else + { + numero = null; + } + if (numero == null) + { + numero = ""; + } + prospeccao.set_Telefone1((string)numero); + str = (cliente.get_Telefones() == null || cliente.get_Telefones().Count <= 1 ? "" : cliente.get_Telefones()[1].get_Prefixo()); + prospeccao.set_Prefixo2(str); + if (cliente.get_Telefones() != null) + { + ObservableCollection telefones2 = cliente.get_Telefones(); + if (telefones2 != null) + { + count = telefones2.Count > 1; + } + else + { + count = false; + } + if (!count) + { + goto Label1; + } + numero1 = cliente.get_Telefones()[1].get_Numero(); + goto Label0; + } + Label1: + numero1 = ""; + Label0: + prospeccao.set_Telefone2(numero1); + ObservableCollection emails = cliente.get_Emails(); + if (emails != null) + { + ClienteEmail clienteEmail = emails.FirstOrDefault(); + if (clienteEmail != null) + { + email = clienteEmail.get_Email(); + } + else + { + email = null; + } + } + else + { + email = null; + } + if (email == null) + { + email = ""; + } + prospeccao.set_Email((string)email); + DateTime? vigencia2 = this.ViewModel.SelectedControle.get_Vigencia2(); + dateTime = (vigencia2.HasValue ? vigencia2.GetValueOrDefault() : Funcoes.GetNetworkTime().Date); + prospeccao.set_VigenciaFinal(new DateTime?(dateTime.AddYears(1))); + prospeccao.set_Vendedor(this.ViewModel.SelectedControle.get_VendedorPrincipal()); + Item item = this.ViewModel.Itens.FirstOrDefault(); + if (item != null) + { + descricao = item.get_Descricao(); + } + else + { + descricao = null; + } + prospeccao.set_Item(descricao); + prospeccao.set_Tipo("SEGURO PERDIDO"); + prospeccao.set_Observacao(string.Concat("SEGURO PERDIDO: PROPOSTA: ", this.ViewModel.SelectedControle.get_Proposta(), ", APÓLICE: ", this.ViewModel.SelectedControle.get_Apolice())); + prospeccao.set_Status(new StatusProspeccao?(1)); + prospeccao.set_Renovacao(true); + await this.AbrirProspeccao(prospeccao); + this.ViewModel.CarregaDocumentos(0); + await this.ViewModel.SelecionaCliente(this.ViewModel.SelectedCliente, true); + this.ApoliceItensRadioButton.IsChecked = new bool?(true); + if (this.ApoliceGrid != null && this.ApoliceGrid.Items.Count > 0 && this.ApoliceGrid.SelectedItem == null) + { + this.ApoliceGrid.SelectedItem = this.ApoliceGrid.Items[0]; + ConsultaViewModel viewModel = this.ViewModel; + DataGrid apoliceGrid = this.ApoliceGrid; + if (apoliceGrid != null) + { + selectedItem = apoliceGrid.SelectedItem; + } + else + { + selectedItem = null; + } + await viewModel.SelecionaDocumento(0, (Documento)selectedItem); + } + this.ViewModel.Loading(false); + } + else + { + this.ViewModel.Loading(false); + } + } + cliente = null; + } + + public async void Pesquisar(PesquisaAvancada pesquisa) + { + await this.ViewModel.Pesquisar(pesquisa); + if (this.ViewModel.SelectedControle != null) + { + this.ScrollToIndex(this.ApoliceGrid, this.ApoliceGrid.SelectedIndex); + } + if (this.ViewModel.SelectedEndosso != null) + { + this.ScrollToIndex(this.EndossoGrid, this.EndossoGrid.SelectedIndex); + } + if (this.ViewModel.SelectedItem != null) + { + this.ScrollToIndex(this.ItemGrid, this.ItemGrid.SelectedIndex); + } + if (this.ViewModel.SelectedParcela != null) + { + this.ScrollToIndex(this.ParcelaGrid, this.ParcelaGrid.SelectedIndex); + } + } + + private void PopupBox_OnClosed(object sender, RoutedEventArgs e) + { + this._documentoAssistencia = null; + this.ViewModel.Anotacoes = ""; + this._linkAssistencia = ""; + } + + private async void PopupBox_OnOpened(object sender, RoutedEventArgs e) + { + this._documentoAssistencia = (Documento)((PopupBox)sender).DataContext; + this._linkAssistencia = await this.ViewModel.CreateLink(this._documentoAssistencia); + if (!string.IsNullOrEmpty(this._linkAssistencia)) + { + string[] strArrays = new string[] { "Prezado(a) ", ValidationHelper.Captalize(this.ViewModel.SelectedCliente.get_Nome()), ", segue o link do seu Cartão Assistência 24 horas.", Environment.NewLine, Environment.NewLine, "LINK CARTÃO ASSISTÊNCIA 24 HORAS", Environment.NewLine, this._linkAssistencia }; + string str = string.Concat(strArrays); + this.ViewModel.Anotacoes = str; + } + } + + private async void Recusar_OnClick(object sender, RoutedEventArgs e) + { + if (!this.ViewModel.Restricao(18)) + { + await this.ViewModel.RecusarDocumento(); + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA RECUSAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + } + + private async void RelacaoItens_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.GerarExcel(this.ViewModel.FilterItens); + } + + private async void Renovar_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.Restricao(17)) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA RENOVAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + else if (!this.ViewModel.EnableRenovar) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL RENOVAR UM DOCUMENTO SEM EMISSÃO OU SEM FINAL DE VIGÊNCIA.", "OK", "", false); + } + else if (ConsultaViewModel.DocumentoSelecionado.get_Situacao() != 7) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela != null) + { + acessaTela(2, "Renovar"); + } + else + { + } + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL RENOVAR UM DOCUMENTO RECUSADO.", "OK", "", false); + } + } + + private async void ReordenarItem_Click(object sender, RoutedEventArgs e) + { + ObservableCollection itens = this.ViewModel.Itens; + List list = ( + from x in itens + select x.get_Id()).ToList(); + ConsultaViewModel viewModel = this.ViewModel; + viewModel.SalvarOrdem(await this.ViewModel.ShowReordenarItensDialog(list)); + viewModel = null; + } + + private void ScrollDocumento() + { + if (this.ViewModel.UpdatingScroll && this.ApoliceGrid.SelectedItem != null) + { + this.ApoliceGrid.ScrollIntoView(this.ApoliceGrid.SelectedItem); + } + this.ViewModel.UpdatingScroll = false; + } + + public void ScrollToIndex(DataGrid grid, int index) + { + ScrollViewer descendantByType = this.GetDescendantByType(grid, typeof(ScrollViewer)) as ScrollViewer; + int num = (index - 5 > 0 ? index - 5 : 0); + if (descendantByType == null) + { + return; + } + descendantByType.ScrollToVerticalOffset((double)num); + } + + private void ScrollToItem() + { + if (this.ItemGrid.SelectedItem == null) + { + return; + } + this.ScrollToIndex(this.ItemGrid, this.ItemGrid.SelectedIndex); + } + + private void SelecionarRadios(int filter) + { + this._carregarDocumetos = false; + this.ApoliceRadioButton.IsChecked = new bool?(filter == 0); + this.EndossoRadioButton.IsChecked = new bool?(filter == 1); + this._carregarDocumetos = true; + } + + private void Sinistros_OnClick(object sender, RoutedEventArgs e) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(7, ""); + } + + [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.ApoliceRadioButton = (RadioButton)target; + return; + } + case 2: + { + this.EndossoRadioButton = (RadioButton)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ClienteView_Click); + return; + } + case 4: + { + this.AcessarDocumentoMenuItem = (MenuItem)target; + this.AcessarDocumentoMenuItem.Click += new RoutedEventHandler(this.ApoliceView_Click); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Renovar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Perdido_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Endossar_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Recusar_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Extratos_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.TrocarCliente_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.EditarParcelas_OnClick); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExpedicaoInfo_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ValoresInfo_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ManutecaoItens_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.RelacaoItens_OnClick); + return; + } + case 17: + { + this.ApoliceGrid = (DataGrid)target; + return; + } + case 18: + case 22: + case 23: + case 24: + case 25: + case 26: + case 29: + case 30: + case 40: + case 41: + case 42: + { + this._contentLoaded = true; + return; + } + case 19: + { + this.NomeField = (DataGridTextColumn)target; + return; + } + case 20: + { + this.ApelidoField = (DataGridTextColumn)target; + return; + } + case 21: + { + this.ApolicesComissaoColumn = (DataGridTextColumn)target; + return; + } + case 27: + { + this.EndossoGrid = (DataGrid)target; + return; + } + case 28: + { + this.EndossosComissaoColumn = (DataGridTextColumn)target; + return; + } + case 31: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Parcela_Click); + return; + } + case 32: + { + this.Comissao = (WrapPanel)target; + return; + } + case 33: + { + this.ParcelaGrid = (DataGrid)target; + return; + } + case 34: + { + this.ParcelasTotalColumn = (DataGridTextColumn)target; + return; + } + case 35: + { + this.ParcelasRealizadoColumn = (DataGridTextColumn)target; + return; + } + case 36: + { + this.ParcelasComissaoColumn = (DataGridTextColumn)target; + return; + } + case 37: + { + this.ParcelasReciboColumn = (DataGridTextColumn)target; + return; + } + case 38: + { + this.ParcelasValorComissaoDescColumn = (DataGridTextColumn)target; + return; + } + case 39: + { + this.MaisInformacoesColumn = (DataGridTemplateColumn)target; + return; + } + case 43: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Item_Click); + return; + } + case 44: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Sinistros_OnClick); + return; + } + case 45: + { + this.AtivosRadioButton = (RadioButton)target; + return; + } + case 46: + { + this.ApoliceItensRadioButton = (RadioButton)target; + return; + } + case 47: + { + this.EndossoItensRadioButton = (RadioButton)target; + return; + } + case 48: + { + this.InativosRadioButton = (RadioButton)target; + return; + } + case 49: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MostrarItens_Click); + return; + } + case 50: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ReordenarItem_Click); + return; + } + case 51: + { + this.ItemGrid = (DataGrid)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) + { + switch (connectionId) + { + case 18: + { + EventSetter eventSetter = new EventSetter() + { + Event = Control.MouseDoubleClickEvent, + Handler = new MouseButtonEventHandler(this.ApoliceGrid_OnMouseDoubleClick) + }; + ((System.Windows.Style)target).Setters.Add(eventSetter); + return; + } + case 19: + case 20: + case 21: + case 27: + case 28: + { + return; + } + case 22: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 23: + { + ((Button)target).Click += new RoutedEventHandler(this.Observacoes_OnClick); + return; + } + case 24: + { + ((PopupBox)target).add_Opened(new RoutedEventHandler(this.PopupBox_OnOpened)); + ((PopupBox)target).add_Closed(new RoutedEventHandler(this.PopupBox_OnClosed)); + return; + } + case 25: + { + ((Button)target).Click += new RoutedEventHandler(this.EnviarPorWhatsApp_OnClick); + return; + } + case 26: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.EnviarPorEmail_OnClick); + return; + } + case 29: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 30: + { + ((Button)target).Click += new RoutedEventHandler(this.Observacoes_OnClick); + return; + } + default: + { + switch (connectionId) + { + case 40: + { + ((Button)target).Click += new RoutedEventHandler(this.ValoresParcelaInfo_OnClick); + return; + } + case 41: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 42: + { + ((Button)target).Click += new RoutedEventHandler(this.Observacoes_OnClick); + return; + } + default: + { + if (connectionId != 52) + { + return; + } + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + } + break; + } + } + } + + private async void TrocarCliente_OnClick(object sender, RoutedEventArgs e) + { + (new HosterWindow(new TrocarClienteView(this.ViewModel.SelectedControle), "TROCAR CLIENTE", new double?((double)500), new double?((double)200), false)).ShowDialog(); + await this.ViewModel.SelecionaCliente(MainViewModel.ClienteSelecionado, true); + Action recarregarDocumentos = Gestor.Application.Actions.Actions.RecarregarDocumentos; + if (recarregarDocumentos != null) + { + recarregarDocumentos(null); + } + else + { + } + } + + private async void ValoresInfo_OnClick(object sender, RoutedEventArgs e) + { + bool flag = this.ViewModel.Restricao(97); + if (!flag) + { + Documento documento = await this.ViewModel.AbrirDetalhes(); + this.ViewModel.ShowDrawer(new ValoresApoliceDrawer(documento), 0, true); + } + if (flag) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR MAIS INFORMAÇÕES.", "OK", "", false); + } + } + + private async void ValoresParcelaInfo_OnClick(object sender, RoutedEventArgs e) + { + Parcela parcela = await this.ViewModel.AbrirDetalhesParcela(); + this.ViewModel.ShowDrawer(new ValoresParcelaDrawer(parcela, this.ViewModel.SelectedControle), 0, true); + } + + private void VisibilityValorPago() + { + bool flag; + DataGridTextColumn parcelasTotalColumn = this.ParcelasTotalColumn; + ObservableCollection parcelas = this.ViewModel.Parcelas; + if (parcelas != null) + { + flag = parcelas.Sum((Parcela p) => p.get_ValorPago()) > new decimal(); + } + else + { + flag = false; + } + parcelasTotalColumn.Visibility = (flag ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/CriticaApoliceView.cs b/Codemerx/Gestor.Application/Views/Seguros/CriticaApoliceView.cs new file mode 100644 index 0000000..9c8b3ec --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/CriticaApoliceView.cs @@ -0,0 +1,2010 @@ +using CsQuery.ExtensionMethods; +using CurrencyTextBoxControl; +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros.Itens; +using Gestor.Common.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +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.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; +using Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.Seguros +{ + public class CriticaApoliceView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal ComboBox UsuarioBox; + + internal ComboBox SeguradoraBox; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal ToggleButton CriticadoBox; + + internal DataGrid CriticaGrid; + + internal MenuItem ConcluirCriticaButton; + + internal MenuItem CancelarDocumento; + + internal ComboBox ProdutoBox; + + internal ComboBox NegocioCorretoraBox; + + internal ComboBox SituacaoBox; + + internal DatePicker TransmissaoBox; + + internal TextBox ApoliceBox; + + internal TextBox EndossoBox; + + internal DatePicker EmissaoBox; + + internal DatePicker Vigencia1Box; + + internal DatePicker Vigencia2Box; + + internal ToggleButton AdicionalBox; + + internal CustomIsReadOnlyControl Comissao; + + internal CurrencyTextBox ComissaoBox; + + internal CurrencyTextBox PremioLiquidoBox; + + internal CurrencyTextBox PremioAdicionalBox; + + internal CurrencyTextBox IofBox; + + internal CurrencyTextBox DiferencaBox; + + internal CurrencyTextBox PremioTotalBox; + + internal CurrencyTextBox ParcelasBox; + + internal ToggleButton SeguroCombinadoBox; + + internal MenuItem EditarVendedorButton; + + internal MenuItem SalvarVendedorButton; + + internal MenuItem CancelarVendedorButton; + + internal WrapPanel VendedorFields; + + internal ToggleButton CoCorretagemToogle; + + internal ComboBox TipoVendedorBox; + + internal ComboBox VendedorBox; + + internal CustomItemValidation ComissaoNovoBox; + + internal ComboBox ComissaoNovoComboBox; + + internal CustomItemValidation ComissaoRenovacaoBox; + + internal ComboBox ComissaoRenovacaoComboBox; + + internal CurrencyTextBox ValorRepasseBox; + + internal TextBox FormaRecebidaBox; + + internal DataGrid VendedorGrid; + + internal DataGridTextColumn RepasseVendedor; + + internal TextBox NomeBox; + + internal ComboBox TipoDocumentoPrincipalBox; + + internal TextBox DocumentoPrincipalBox; + + internal DatePicker NascimentoBox; + + internal TextBox IdentidadeBox; + + internal TextBox EmissorBox; + + internal TextBox EstadoEmissorBox; + + internal ListBox TelefoneListBox; + + internal ListBox EmailListBox; + + internal DataGrid ItemGrid; + + private bool _contentLoaded; + + private bool AdicionandoVendedor + { + get; + set; + } + + private int Ordem { get; set; } = 1; + + public CriticaApoliceViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public CriticaApoliceView() + { + base.Tag = "CRÍTICA DE IMPORTAÇÃO"; + this.ViewModel = new CriticaApoliceViewModel(); + 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 async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedCritica.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(2); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedCritica.get_Documento()); + 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 ", EnumHelper.GetDescription(2), "."), "OK", "", false); + } + } + + private void AdicionalBox_OnChecked(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + this.AlteracaoDePremio_LostFocus(this.PremioAdicionalBox, new RoutedEventArgs()); + } + + private void AdicionarCoCorretagem_OnClick(object sender, RoutedEventArgs e) + { + bool valueOrDefault; + bool selectedItem; + bool flag; + ToggleButton toggleButton = (ToggleButton)sender; + if (toggleButton != null) + { + valueOrDefault = toggleButton.IsChecked.GetValueOrDefault(); + } + else + { + valueOrDefault = false; + } + bool flag1 = valueOrDefault; + ComboBox comissaoNovoComboBox = this.ComissaoNovoComboBox; + if (comissaoNovoComboBox != null) + { + selectedItem = comissaoNovoComboBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (selectedItem) + { + this.ComissaoNovoComboBox.SelectedItem = null; + } + if (flag1) + { + this.TipoVendedorBox.SelectedIndex = 0; + } + else if (this.TipoVendedorBox.SelectedItem != null) + { + this.TipoVendedorBox.SelectedItem = null; + } + ComboBox vendedorBox = this.VendedorBox; + if (vendedorBox != null) + { + flag = vendedorBox.SelectedItem; + } + else + { + flag = false; + } + if (flag) + { + this.VendedorBox.SelectedItem = null; + } + if (ValidationHelper.IsNotNullOrEmpty(this.ValorRepasseBox.Text)) + { + this.ValorRepasseBox.Text = ""; + } + this.ViewModel.VendedorCoCorretagem(flag1); + } + + private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdcionarFiltro(); + } + + private void AlteracaoDePremio_LostFocus(object sender, RoutedEventArgs e) + { + decimal iof; + if (!this.ViewModel.AllowEditApolice) + { + return; + } + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + CurrencyTextBox currencyTextBox = (CurrencyTextBox)sender; + if (currencyTextBox == null) + { + return; + } + string name = currencyTextBox.Name; + if ((name == "PremioLiquidoBox" || name == "PremioAdicionalBox") && this.IofBox.get_Number() == decimal.Zero) + { + decimal number = this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number(); + Ramo ramo = this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(); + if (ramo != null) + { + iof = ramo.get_Iof(); + } + else + { + iof = decimal.Zero; + } + decimal num = number * iof; + this.IofBox.set_Number(num); + CurrencyTextBox premioTotalBox = this.PremioTotalBox; + premioTotalBox.set_Number(premioTotalBox.get_Number() + num); + } + this.PremioTotalBox.set_Number(((this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number()) + this.IofBox.get_Number()) + this.DiferencaBox.get_Number()); + name = currencyTextBox.Name; + if ((name == "PremioLiquidoBox" || name == "PremioAdicionalBox" || name == "ComissaoBox") && this.ViewModel.HabilitarVendedor(0).Count == 0) + { + this.ViewModel.RecalculaRepasses(); + } + this.ValidarDocumento(); + } + + private async void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + this.ViewModel.EnableGrid = false; + List configuracoes = Recursos.Configuracoes; + if (configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 3)) + { + this.SituacaoBox.SelectedIndex = -1; + } + await this.ViewModel.SelecionaCritica(this.ViewModel.SelectedCritica); + this.ValidarDocumento(); + } + + private async void Apolice_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento != null) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ApoliceView(this.ViewModel.SelectedDocumento, true, false, 0, (long)0, true), string.Concat("CADASTRO DE APÓLICES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome(), " - ", this.ViewModel.SelectedDocumento.get_Apolice()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaDocumento(this.ViewModel.SelectedDocumento); + } + } + + private async void Atualizar_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.CarregaCritica(this.ViewModel.SelectedUsuario.get_Id(), this.ViewModel.SelectedSeguradora.get_Id(), this.ViewModel.Criticado); + } + + private async void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + List repasses = this.ViewModel.Repasses; + if (!( + from repasse in repasses + where !repasse.get_Vendedor().get_Corretora() + select repasse).Any()) + { + if (!this.ViewModel.HasChange && (this.ViewModel.SelectedDocumento == null || !this.ViewModel.SelectedDocumento.HasChange()) && (this.ViewModel.SelectedCliente == null || !this.ViewModel.SelectedCliente.HasChange())) + { + if (this.ViewModel.Telefones != null) + { + ObservableCollection telefones = this.ViewModel.Telefones; + if (!telefones.Any((ClienteTelefone x) => x.HasChange())) + { + goto Label0; + } + } + else + { + goto Label0; + } + } + if (!await this.ViewModel.ShowMessage(string.Concat("HÁ ALTERAÇÕES PENDENTES AINDA NÃO SALVAS, DESEJA CONTINUAR? ", Environment.NewLine, "O PROCEDIMENTO IRÁ CANCELAR AS ALTERAÇÕES REALIZADAS."), "SIM", "NÃO", false)) + { + return; + } + Label0: + await this.ViewModel.SelecionaCritica(this.ViewModel.SelectedCritica); + this.ViewModel.Alterar(false); + this.ViewModel.EnableGrid = true; + } + else + { + await this.ViewModel.ShowMessage("PARA CANCELAR AS ALTERAÇÕES É NECESSÁRIO REMOVER OS VENDEDORES COM REPASSE CONFIGURADO.", "OK", "", false); + } + } + + private void CancelarVendedor_Click(object sender, RoutedEventArgs e) + { + this.EditarVendedor(false); + this.ViewModel.SelectedPagamento = null; + this.ViewModel.SelecionarVendedor(); + } + + private async void Cliente_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ClienteView(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente(), true, null), string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + CriticaApoliceViewModel viewModel = this.ViewModel; + Cliente cliente = await this.ViewModel.CarregaCliente(this.ViewModel.SelectedCliente.get_Id()); + viewModel.SelectedCliente = cliente; + viewModel = null; + await this.ViewModel.SelecionaCliente(this.ViewModel.SelectedCliente); + } + + private void ComissaoVendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + decimal? valorRepasse; + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + Repasse selectedItem = (Repasse)comboBox.SelectedItem; + if (selectedItem != null && selectedItem.get_Tipo().GetValueOrDefault() == 3) + { + decimal comissao = (this.ViewModel.SelectedDocumento.get_Comissao() * selectedItem.get_ValorNovo() * new decimal(1, 0, 0, false, 2)) * new decimal(1, 0, 0, false, 2); + this.ViewModel.SelectedPagamento.set_ValorRepasse(new decimal?(this.ViewModel.SelectedDocumento.get_PremioTotal() * comissao)); + CurrencyTextBox valorRepasseBox = this.ValorRepasseBox; + valorRepasse = this.ViewModel.SelectedPagamento.get_ValorRepasse(); + valorRepasseBox.set_Number(valorRepasse.Value); + return; + } + this.ViewModel.SelectedPagamento.set_Repasse(selectedItem); + this.ViewModel.SelectedPagamento.set_PorcentagemRepasse(new decimal?((this.ViewModel.SelectedDocumento.get_Situacao() != 2 || this.ViewModel.SelectedDocumento.get_Negocio().GetValueOrDefault() != 1 ? selectedItem.get_ValorNovo() : selectedItem.get_ValorRenovacao()))); + if (this.ViewModel.SelectedParcela == null) + { + CriticaApoliceViewModel viewModel = this.ViewModel; + Parcela parcela = new Parcela(); + parcela.set_SubTipo(1); + viewModel.SelectedParcela = parcela; + } + this.ViewModel.SelectedParcela.set_Documento(this.ViewModel.SelectedDocumento); + this.ViewModel.SelectedPagamento.set_ValorRepasse(new decimal?(Funcoes.CalculaRepasse(selectedItem, this.ViewModel.SelectedParcela, (this.ViewModel.SelectedParcela == null ? true : this.ViewModel.SelectedParcela.get_SubTipo() == 1)))); + this.ViewModel.SelectedPagamento.set_ValorTotal(this.ViewModel.SelectedPagamento.get_ValorRepasse()); + CurrencyTextBox currencyTextBox = this.ValorRepasseBox; + valorRepasse = this.ViewModel.SelectedPagamento.get_ValorRepasse(); + currencyTextBox.set_Number(valorRepasse.Value); + this.FormaRecebidaBox.Text = EnumHelper.GetDescription(selectedItem.get_Forma()); + } + + private async void ConcluirCritica_OnClick(object sender, RoutedEventArgs e) + { + this.ConcluirCriticaButton.Click -= new RoutedEventHandler(this.ConcluirCritica_OnClick); + this.ViewModel.EnableGrid = false; + this.ExecutarValidacaoData(); + this.NomeBox.Focus(); + if (this.ViewModel.CompararValores()) + { + this.PremioTotalBox.set_Number(((this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number()) + this.IofBox.get_Number()) + this.DiferencaBox.get_Number()); + } + await this.SalvarDocumento(); + this.ConcluirCriticaButton.Click += new RoutedEventHandler(this.ConcluirCritica_OnClick); + } + + private async void ContentLoad() + { + System.Windows.Visibility visibility; + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_OnLostFocus); + CriticaApoliceView criticaApoliceView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView.SomenteNumeros); + this.CriticadoBox.Checked += new RoutedEventHandler(this.Criticado_OnChecked); + this.CriticadoBox.Unchecked += new RoutedEventHandler(this.Criticado_OnChecked); + this.UsuarioBox.SelectionChanged += new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.SelectedDateChanged += new EventHandler(this.FiltroDataBox_OnSelectedDateChanged); + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.FimBox.SelectedDateChanged += new EventHandler(this.FiltroDataBox_OnSelectedDateChanged); + this.TransmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.TransmissaoBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.EmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.EmissaoBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.Vigencia1Box.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.Vigencia1Box.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.Vigencia2Box.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.Vigencia2Box.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.NegocioCorretoraBox.SelectionChanged += new SelectionChangedEventHandler(this.NegocioCorretoraBox_OnSelectionChanged); + this.PremioLiquidoBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.PremioAdicionalBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.IofBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.DiferencaBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.AdicionalBox.Unchecked += new RoutedEventHandler(this.AdicionalBox_OnChecked); + this.AdicionalBox.Checked += new RoutedEventHandler(this.AdicionalBox_OnChecked); + this.VendedorBox.SelectionChanged += new SelectionChangedEventHandler(this.VendedorBox_OnSelectionChanged); + this.TipoVendedorBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoVendedorBox_OnSelectionChanged); + this.TipoDocumentoPrincipalBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoDocumentoPrincipalBox_OnSelectionChanged); + this.CriticaGrid.SelectionChanged += new SelectionChangedEventHandler(this.Grid_OnSelectionChanged); + DataGridTextColumn repasseVendedor = this.RepasseVendedor; + visibility = (this.ViewModel.Restricao(95) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + repasseVendedor.Visibility = visibility; + await this.ViewModel.InitialLoad(); + } + + private async void Criticado_OnChecked(object sender, RoutedEventArgs e) + { + bool flag; + bool selectedItem; + ToggleButton toggleButton = (ToggleButton)sender; + flag = (toggleButton != null ? !toggleButton.IsChecked.HasValue : true); + if (!flag) + { + ComboBox usuarioBox = this.UsuarioBox; + if (usuarioBox != null) + { + selectedItem = usuarioBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (selectedItem) + { + if (!this.ViewModel.IsLoading) + { + bool value = toggleButton.IsChecked.Value; + this.SeguradoraBox.SelectionChanged -= new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged -= new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked -= new RoutedEventHandler(this.Criticado_OnChecked); + await this.ViewModel.CarregarUsuarios(((Usuario)this.UsuarioBox.SelectedItem).get_Id(), value); + await this.ViewModel.CarregaCritica(this.ViewModel.SelectedUsuario.get_Id(), this.ViewModel.SelectedSeguradora.get_Id(), value); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged += new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked += new RoutedEventHandler(this.Criticado_OnChecked); + } + } + } + } + + private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e) + { + if (((TextBox)sender).IsReadOnly) + { + return; + } + string str = ValidationHelper.Clear(this.DocumentoPrincipalBox.Text); + if (string.IsNullOrEmpty(str)) + { + return; + } + this.DocumentoPrincipalBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14))); + this.ViewModel.JuridicaouFisica(this.DocumentoPrincipalBox.Text); + } + + private void DocumentoPrincipalBox_OnLostFocus(object sender, RoutedEventArgs e) + { + if (this.TipoDocumentoPrincipalBox.SelectedItem == null) + { + this.TipoDocumentoPrincipalBox.SelectedItem = (TipoDocumento)0; + } + if ((TipoDocumento)this.TipoDocumentoPrincipalBox.SelectedItem == null) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + } + } + + private void EditarVendedor(bool editar) + { + bool count; + ObservableCollection pagamentos; + bool flag; + ObservableCollection observableCollection; + this.AdicionandoVendedor = editar; + this.SalvarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.CancelarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.EditarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.VendedorFields.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VendedorGrid.IsEnabled = !editar; + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + if (editar) + { + if (Recursos.Configuracoes.Any((ConfiguracaoSistema config) => config.get_Configuracao() == 56)) + { + ObservableCollection pagamentos1 = this.ViewModel.Pagamentos; + if (pagamentos1 != null) + { + count = pagamentos1.Count == 1; + } + else + { + count = false; + } + if (count) + { + if (!this.ViewModel.Pagamentos.Any((VendedorParcela vendedor) => vendedor.get_Repasse() == null)) + { + pagamentos = this.ViewModel.Pagamentos; + if (pagamentos != null) + { + flag = pagamentos.Count == 0; + } + else + { + observableCollection = pagamentos; + flag = false; + } + this.CoCorretagemToogle.IsEnabled = flag; + this.ComissaoNovoBox.Visibility = System.Windows.Visibility.Visible; + this.ComissaoRenovacaoBox.Visibility = System.Windows.Visibility.Collapsed; + this.CoCorretagemToogle.IsChecked = new bool?(false); + return; + } + flag = true; + this.CoCorretagemToogle.IsEnabled = flag; + this.ComissaoNovoBox.Visibility = System.Windows.Visibility.Visible; + this.ComissaoRenovacaoBox.Visibility = System.Windows.Visibility.Collapsed; + this.CoCorretagemToogle.IsChecked = new bool?(false); + return; + } + pagamentos = this.ViewModel.Pagamentos; + if (pagamentos != null) + { + flag = pagamentos.Count == 0; + } + else + { + observableCollection = pagamentos; + flag = false; + } + this.CoCorretagemToogle.IsEnabled = flag; + this.ComissaoNovoBox.Visibility = System.Windows.Visibility.Visible; + this.ComissaoRenovacaoBox.Visibility = System.Windows.Visibility.Collapsed; + this.CoCorretagemToogle.IsChecked = new bool?(false); + return; + } + } + NegocioCorretora? negocioCorretora = this.ViewModel.SelectedDocumento.get_NegocioCorretora(); + bool valueOrDefault = negocioCorretora.GetValueOrDefault() == 1; + this.ComissaoNovoBox.Visibility = (!editar || valueOrDefault ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ComissaoRenovacaoBox.Visibility = (editar & valueOrDefault ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private async void EditarVendedorButton_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + bool hasValue; + List> keyValuePairs = this.ViewModel.SelectedDocumento.Validate(); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + bool flag1 = flag; + if (flag1) + { + Parcela selectedParcela = this.ViewModel.SelectedParcela; + if (selectedParcela != null) + { + hasValue = selectedParcela.get_DataRecebimento().HasValue; + } + else + { + hasValue = false; + } + if (hasValue) + { + await this.ViewModel.ShowMessage("DOCUMENTO COM PARCELA(S) JÁ BAIXADA(S), NÃO É POSSÍVEL ALTERAR VENDEDORES!", "OK", "", false); + return; + } + } + if (flag1) + { + this.ViewModel.IncluirVendedor(); + this.EditarVendedor(true); + this.ViewModel.VendedorCoCorretagem(false); + } + else + { + this.ValidateFields(keyValuePairs, true); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + private void ExcluirEmail_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + ClienteEmail dataContext = (ClienteEmail)button.DataContext; + this.ViewModel.ExcluirEmail(dataContext); + } + + 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.PesquisaCritica.Remove(item); + this.ViewModel.Pesquisar(); + } + + private void ExcluirTelefone_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + ClienteTelefone dataContext = (ClienteTelefone)button.DataContext; + this.ViewModel.ExcluirTelefone(dataContext); + } + + private async void ExcluirVendedor_OnClick(object sender, RoutedEventArgs e) + { + TipoRepasse? nullable; + bool selectedIndex; + object item; + TipoRepasse? tipo; + bool valueOrDefault; + object obj; + System.Windows.Visibility visibility; + DataGrid vendedorGrid = this.VendedorGrid; + if (vendedorGrid != null) + { + selectedIndex = vendedorGrid.SelectedIndex < 0; + } + else + { + selectedIndex = false; + } + if (!selectedIndex) + { + DataGrid dataGrid = this.VendedorGrid; + if (dataGrid != null) + { + item = dataGrid.Items[this.VendedorGrid.SelectedIndex]; + } + else + { + item = null; + } + VendedorParcela vendedorParcela = (VendedorParcela)item; + if (vendedorParcela != null) + { + Repasse repasse = vendedorParcela.get_Repasse(); + if (repasse != null) + { + tipo = repasse.get_Tipo(); + } + else + { + nullable = null; + tipo = nullable; + } + nullable = tipo; + valueOrDefault = nullable.GetValueOrDefault() == 3; + } + else + { + valueOrDefault = false; + } + bool flag = valueOrDefault; + CriticaApoliceViewModel viewModel = this.ViewModel; + DataGrid vendedorGrid1 = this.VendedorGrid; + if (vendedorGrid1 != null) + { + obj = vendedorGrid1.Items[this.VendedorGrid.SelectedIndex]; + } + else + { + obj = null; + } + await viewModel.ExcluirVendedor((VendedorParcela)obj, true); + await this.ViewModel.SelecionaParcela(this.ViewModel.Parcelas.FirstOrDefault()); + this.ComissaoBox.IsReadOnly = this.ViewModel.VerificaCoCorretagem(); + CriticaApoliceViewModel criticaApoliceViewModel = this.ViewModel; + visibility = (this.ComissaoBox.IsReadOnly ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + criticaApoliceViewModel.ComissOriginalVisibility = visibility; + if (flag) + { + await this.ViewModel.AjusteComissãoCoCorretagem(true); + } + } + } + + private void ExecutarValidacaoData() + { + DateTime dateTime; + DateTime? nullable; + DateTime? nullable1; + DateTime? nullable2; + DateTime? nullable3; + DateTime? nullable4; + Cliente selectedCliente = this.ViewModel.SelectedCliente; + if (this.NascimentoBox.Text == null || !DateTime.TryParse(ValidationHelper.FormatDate(this.NascimentoBox.Text), out dateTime)) + { + nullable = null; + nullable1 = nullable; + } + else + { + nullable1 = new DateTime?(dateTime); + } + selectedCliente.set_Nascimento(nullable1); + Documento selectedDocumento = this.ViewModel.SelectedDocumento; + if (this.TransmissaoBox.Text == null || !DateTime.TryParse(ValidationHelper.FormatDate(this.TransmissaoBox.Text), out dateTime)) + { + nullable = null; + nullable2 = nullable; + } + else + { + nullable2 = new DateTime?(dateTime); + } + selectedDocumento.set_Remessa(nullable2); + Documento documento = this.ViewModel.SelectedDocumento; + if (this.EmissaoBox.Text == null || !DateTime.TryParse(ValidationHelper.FormatDate(this.EmissaoBox.Text), out dateTime)) + { + nullable = null; + nullable3 = nullable; + } + else + { + nullable3 = new DateTime?(dateTime); + } + documento.set_Emissao(nullable3); + this.ViewModel.SelectedDocumento.set_Vigencia1((this.Vigencia1Box.Text == null || !DateTime.TryParse(ValidationHelper.FormatDate(this.Vigencia1Box.Text), out dateTime) ? Funcoes.GetNetworkTime().Date : dateTime)); + Documento selectedDocumento1 = this.ViewModel.SelectedDocumento; + if (this.Vigencia2Box.Text == null || !DateTime.TryParse(ValidationHelper.FormatDate(this.Vigencia2Box.Text), out dateTime)) + { + nullable = null; + nullable4 = nullable; + } + else + { + nullable4 = new DateTime?(dateTime); + } + selectedDocumento1.set_Vigencia2(nullable4); + } + + private async void FiltroDataBox_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + bool hasValue; + bool selectedItem; + DatePicker datePicker = (DatePicker)sender; + if (datePicker != null) + { + hasValue = !datePicker.SelectedDate.HasValue; + } + else + { + hasValue = true; + } + if (!hasValue) + { + ComboBox usuarioBox = this.UsuarioBox; + if (usuarioBox != null) + { + selectedItem = usuarioBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (selectedItem) + { + this.SeguradoraBox.SelectionChanged -= new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged -= new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked -= new RoutedEventHandler(this.Criticado_OnChecked); + await this.ViewModel.CarregarUsuarios(((Usuario)this.UsuarioBox.SelectedItem).get_Id(), this.ViewModel.Criticado); + await this.ViewModel.CarregaCritica(this.ViewModel.SelectedUsuario.get_Id(), this.ViewModel.SelectedSeguradora.get_Id(), this.ViewModel.Criticado); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged += new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked += new RoutedEventHandler(this.Criticado_OnChecked); + } + } + } + + private async void Grid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (this.ViewModel.EnableGrid) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null) + { + if (dataGrid.SelectedIndex >= 0) + { + this.ViewModel.EnableGrid = false; + this.ViewModel.Index = dataGrid.SelectedIndex; + await this.ViewModel.SelecionaCritica((CriticaApolice)dataGrid.Items[dataGrid.SelectedIndex]); + this.ViewModel.EnableGrid = true; + } + } + } + } + + private void Initial_DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + base.DatePicker_OnLostKeyboardFocus(sender, e); + if (string.IsNullOrEmpty(this.Vigencia1Box.Text)) + { + this.Vigencia1Box.SelectedDate = new DateTime?(DateTime.MinValue); + this.ViewModel.SelectedDocumento.set_Vigencia1(DateTime.MinValue); + } + if (string.IsNullOrWhiteSpace(this.Vigencia2Box.Text)) + { + DatePicker vigencia2Box = this.Vigencia2Box; + DateTime dateTime = ValidationHelper.ToDateTime(this.Vigencia1Box.Text); + vigencia2Box.DisplayDate = dateTime.AddYears(1); + DatePicker shortDateString = this.Vigencia2Box; + dateTime = this.Vigencia2Box.DisplayDate; + shortDateString.Text = dateTime.ToShortDateString(); + } + } + + [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/seguros/criticaapoliceview.xaml", UriKind.Relative)); + } + + private async void Item_Click(object sender, RoutedEventArgs e) + { + Item dataContext; + UserControl patrimonialView; + double? nullable; + double? nullable1; + bool? nullable2; + Button button = (Button)sender; + if (button.DataContext != null) + { + dataContext = (Item)button.DataContext; + dataContext.set_Documento(this.ViewModel.SelectedDocumento); + long id = this.ViewModel.SelectedDocumento.get_Controle().get_Ramo().get_Id(); + long num = id - (long)1; + if (num <= (long)19) + { + switch ((uint)num) + { + case 0: + case 1: + case 2: + case 14: + case 17: + { + patrimonialView = new PatrimonialView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 3: + case 7: + case 10: + case 11: + case 13: + case 15: + case 16: + case 18: + { + patrimonialView = new RiscosDiversosView(null, false, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 4: + { + patrimonialView = new AutoView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 5: + case 6: + case 8: + case 9: + { + patrimonialView = new VidaView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 12: + { + patrimonialView = new AeronauticoView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 19: + { + patrimonialView = new GranizoView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + } + } + else + { + } + long num1 = id - (long)36; + if (num1 <= (long)2) + { + switch ((uint)num1) + { + case 0: + { + patrimonialView = new ConsorcioView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 1: + { + patrimonialView = new AutoView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 2: + { + patrimonialView = new PatrimonialView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + } + } + else + { + } + if (id != (long)53) + { + patrimonialView = new RiscosDiversosView(null, false, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + patrimonialView = new VidaView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + return; + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + patrimonialView = new PatrimonialView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + patrimonialView = new RiscosDiversosView(null, false, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + patrimonialView = new AutoView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + patrimonialView = new RiscosDiversosView(null, false, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + } + + private void NegocioCorretoraBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool selectedItem; + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null) + { + selectedItem = comboBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (!selectedItem) + { + return; + } + this.AlteracaoDePremio_LostFocus(this.PremioLiquidoBox, new RoutedEventArgs()); + if (this.SalvarVendedorButton.Visibility != System.Windows.Visibility.Visible) + { + return; + } + this.EditarVendedor(true); + this.ComissaoVendedorBox_OnSelectionChanged((this.ComissaoNovoBox.Visibility == System.Windows.Visibility.Visible ? this.ComissaoNovoComboBox : this.ComissaoRenovacaoComboBox), e); + } + + private void OrdemBox_OnLostFocus(object sender, RoutedEventArgs e) + { + int num; + int num1; + TextBox textBox = sender as TextBox; + if (textBox == null) + { + return; + } + if (textBox.IsReadOnly) + { + return; + } + if (!int.TryParse(textBox.Text, out num)) + { + return; + } + WrapPanel wrapPanel = Extentions.FindVisualAncestor(Extentions.FindVisualAncestor(textBox)); + ListBox listBox = Extentions.FindVisualAncestor(wrapPanel); + if (listBox != null) + { + for (int i = 0; i < listBox.Items.Count; i++) + { + if (i != listBox.Items.IndexOf(wrapPanel.DataContext)) + { + ContentPresenter contentPresenter = FindVisualChild.Find((ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(i)); + TextBox str = (TextBox)contentPresenter.ContentTemplate.FindName("OrdemBox", contentPresenter); + if (int.TryParse(str.Text, out num1) && num1 == num) + { + str.Text = this.Ordem.ToString(); + } + } + } + } + } + + private void OrdemBox_OnPreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + int num; + TextBox textBox = sender as TextBox; + if (textBox == null) + { + return; + } + if (!int.TryParse(textBox.Text, out num)) + { + return; + } + this.Ordem = num; + } + + private async void Perfil_OnClick(object sender, RoutedEventArgs e) + { + PerfilView perfilView = new PerfilView(this.ViewModel.SelectedDocumento.get_Controle()); + if (await this.ViewModel.VerificarPermissao(32, false)) + { + (new HosterWindow(perfilView, "PERFIL", new double?((double)800), new double?((double)370), false)).ShowDialog(); + } + perfilView = null; + } + + private void Pesquisa_OnPreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key != Key.Return) + { + return; + } + this.ViewModel.AdcionarFiltro(); + } + + private async Task SalvarDocumento() + { + bool flag; + bool flag1; + bool flag2; + bool flag3; + this.ViewModel.Loading(true); + List> keyValuePairs = null; + if (this.AdicionandoVendedor) + { + keyValuePairs = await this.ViewModel.AdicionarVendedor(); + } + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag) + { + keyValuePairs = await this.ViewModel.SalvarCliente(); + flag1 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag1) + { + if (!this.ViewModel.StatusDocumento.HasValue) + { + keyValuePairs = new List>() + { + new KeyValuePair("STATUS DO SEGURO", "OBRIGATÓRIO") + }; + } + flag2 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag2) + { + if (!this.ViewModel.StatusDocumento.HasValue) + { + this.ViewModel.SelectedDocumento.set_Situacao(1); + } + keyValuePairs = await this.ViewModel.Salvar(true); + flag3 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag3) + { + await this.ViewModel.ConcluirCritica(); + this.EditarVendedor(false); + this.ViewModel.EnableGrid = true; + this.SeguroCombinadoBox.IsChecked = new bool?(false); + } + else + { + List> keyValuePairs1 = keyValuePairs; + if (!keyValuePairs1.Any>((KeyValuePair x) => x.Value == "VIGENCIANAOACEITA")) + { + this.ViewModel.Loading(false); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.ViewModel.Loading(false); + } + } + } + else + { + this.ViewModel.Loading(false); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + else + { + this.ViewModel.Loading(false); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + else + { + this.ViewModel.Loading(false); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + private async void SalvarVendedor_Click(object sender, RoutedEventArgs e) + { + TipoRepasse? nullable; + List> keyValuePairs; + bool valueOrDefault; + TipoRepasse? tipo; + bool flag; + decimal num; + bool flag1; + ((MenuItem)sender).Click -= new RoutedEventHandler(this.SalvarVendedor_Click); + bool coCorretagem = this.ViewModel.CoCorretagem; + if (coCorretagem) + { + coCorretagem = !await this.ViewModel.ShowMessage("AO ADICIONAR CO-CORRETAGEM COMO VENDEDOR, O DOCUMENTO ACIMA SERÁ SALVO.\nDESEJÁ CONTINUAR?", "SIM", "NÃO", false); + } + if (!coCorretagem) + { + if (this.ViewModel.SelectedParcela == null) + { + valueOrDefault = true; + } + else if (this.ViewModel.SelectedParcela.get_SubTipo() != 1) + { + valueOrDefault = false; + } + else + { + TipoRecebimento? tipoRecebimento = this.ViewModel.SelectedDocumento.get_TipoRecebimento(); + valueOrDefault = tipoRecebimento.GetValueOrDefault() == 1; + } + bool flag2 = valueOrDefault; + NegocioCorretora? negocioCorretora = this.ViewModel.SelectedDocumento.get_NegocioCorretora(); + bool valueOrDefault1 = negocioCorretora.GetValueOrDefault() == 1; + if (this.ComissaoRenovacaoComboBox.SelectedItem != null || this.ComissaoNovoComboBox.SelectedItem != null) + { + VendedorParcela selectedPagamento = this.ViewModel.SelectedPagamento; + if (selectedPagamento != null) + { + Repasse repasse = selectedPagamento.get_Repasse(); + if (repasse != null) + { + tipo = repasse.get_Tipo(); + } + else + { + nullable = null; + tipo = nullable; + } + nullable = tipo; + flag = nullable.GetValueOrDefault() == 3; + } + else + { + flag = false; + } + if (flag) + { + valueOrDefault1 = false; + } + object selectedItem = this.ComissaoRenovacaoComboBox.SelectedItem; + if (selectedItem == null) + { + selectedItem = this.ComissaoNovoComboBox.SelectedItem; + } + object obj = selectedItem; + VendedorParcela vendedorParcela = this.ViewModel.SelectedPagamento; + num = (valueOrDefault1 ? ((Repasse)obj).get_ValorRenovacao() : ((Repasse)obj).get_ValorNovo()); + vendedorParcela.set_PorcentagemRepasse(new decimal?(num)); + keyValuePairs = (!flag2 ? await this.ViewModel.AdicionarVendedorParcelaEspecial() : await this.ViewModel.AdicionarVendedor()); + List> keyValuePairs1 = keyValuePairs; + flag1 = (keyValuePairs1 == null ? true : keyValuePairs1.Count == 0); + if (!flag1) + { + await this.ViewModel.ShowMessage(keyValuePairs1, this.ViewModel.ErroCamposInvalidos, "OK", ""); + ((MenuItem)sender).Click += new RoutedEventHandler(this.SalvarVendedor_Click); + } + else + { + this.EditarVendedor(false); + if (this.ViewModel.VerificaCoCorretagem()) + { + this.ComissaoBox.IsReadOnly = true; + this.ViewModel.ComissOriginalVisibility = System.Windows.Visibility.Visible; + } + ((MenuItem)sender).Click += new RoutedEventHandler(this.SalvarVendedor_Click); + } + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIOS ESCOLHER O VALOR DE REPASSE ANTES DE ADICIONAR O VENDEDOR", "OK", "", false); + ((MenuItem)sender).Click += new RoutedEventHandler(this.SalvarVendedor_Click); + } + } + else + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.SalvarVendedor_Click); + } + } + + private async void Seguradora_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool hasValue; + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null && comboBox.SelectedItem != null) + { + ToggleButton criticadoBox = this.CriticadoBox; + if (criticadoBox != null) + { + hasValue = !criticadoBox.IsChecked.HasValue; + } + else + { + hasValue = true; + } + if (!hasValue) + { + this.SeguradoraBox.SelectionChanged -= new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged -= new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked -= new RoutedEventHandler(this.Criticado_OnChecked); + this.ViewModel.SelectedSeguradora = (Seguradora)comboBox.SelectedItem; + await this.ViewModel.CarregaCritica(this.ViewModel.SelectedUsuario.get_Id(), ((Seguradora)comboBox.SelectedItem).get_Id(), this.ViewModel.Criticado); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged += new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked += new RoutedEventHandler(this.Criticado_OnChecked); + } + } + } + + private void SituacaoBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (this.ViewModel.EnableFields) + { + this.ViewModel.StatusDocumento = (TipoSeguro?)comboBox.SelectedItem; + } + } + + [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.SeguradoraBox = (ComboBox)target; + 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); + 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); + return; + } + case 5: + { + this.CriticadoBox = (ToggleButton)target; + return; + } + case 6: + { + ((Button)target).Click += new RoutedEventHandler(this.Atualizar_OnClick); + return; + } + case 7: + { + ((TextBox)target).PreviewKeyDown += new KeyEventHandler(this.Pesquisa_OnPreviewKeyDown); + return; + } + case 8: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltro_OnClick); + return; + } + case 9: + case 53: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 70: + { + this._contentLoaded = true; + return; + } + case 10: + { + this.CriticaGrid = (DataGrid)target; + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 12: + { + this.ConcluirCriticaButton = (MenuItem)target; + this.ConcluirCriticaButton.Click += new RoutedEventHandler(this.ConcluirCritica_OnClick); + return; + } + case 13: + { + this.CancelarDocumento = (MenuItem)target; + this.CancelarDocumento.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cliente_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Apolice_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Tarefa_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Perfil_OnClick); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 19: + { + this.ProdutoBox = (ComboBox)target; + return; + } + case 20: + { + this.NegocioCorretoraBox = (ComboBox)target; + return; + } + case 21: + { + this.SituacaoBox = (ComboBox)target; + this.SituacaoBox.SelectionChanged += new SelectionChangedEventHandler(this.SituacaoBox_SelectionChanged); + return; + } + case 22: + { + this.TransmissaoBox = (DatePicker)target; + this.TransmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.TransmissaoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 23: + { + this.ApoliceBox = (TextBox)target; + return; + } + case 24: + { + this.EndossoBox = (TextBox)target; + return; + } + case 25: + { + this.EmissaoBox = (DatePicker)target; + this.EmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.EmissaoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 26: + { + this.Vigencia1Box = (DatePicker)target; + this.Vigencia1Box.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Initial_DatePicker_OnLostKeyboardFocus); + this.Vigencia1Box.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 27: + { + this.Vigencia2Box = (DatePicker)target; + this.Vigencia2Box.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.Vigencia2Box.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 28: + { + this.AdicionalBox = (ToggleButton)target; + return; + } + case 29: + { + this.Comissao = (CustomIsReadOnlyControl)target; + return; + } + case 30: + { + this.ComissaoBox = (CurrencyTextBox)target; + return; + } + case 31: + { + this.PremioLiquidoBox = (CurrencyTextBox)target; + return; + } + case 32: + { + this.PremioAdicionalBox = (CurrencyTextBox)target; + return; + } + case 33: + { + this.IofBox = (CurrencyTextBox)target; + return; + } + case 34: + { + this.DiferencaBox = (CurrencyTextBox)target; + return; + } + case 35: + { + this.PremioTotalBox = (CurrencyTextBox)target; + return; + } + case 36: + { + this.ParcelasBox = (CurrencyTextBox)target; + return; + } + case 37: + { + this.SeguroCombinadoBox = (ToggleButton)target; + return; + } + case 38: + { + this.EditarVendedorButton = (MenuItem)target; + this.EditarVendedorButton.Click += new RoutedEventHandler(this.EditarVendedorButton_OnClick); + return; + } + case 39: + { + this.SalvarVendedorButton = (MenuItem)target; + this.SalvarVendedorButton.Click += new RoutedEventHandler(this.SalvarVendedor_Click); + return; + } + case 40: + { + this.CancelarVendedorButton = (MenuItem)target; + this.CancelarVendedorButton.Click += new RoutedEventHandler(this.CancelarVendedor_Click); + return; + } + case 41: + { + this.VendedorFields = (WrapPanel)target; + return; + } + case 42: + { + this.CoCorretagemToogle = (ToggleButton)target; + this.CoCorretagemToogle.Click += new RoutedEventHandler(this.AdicionarCoCorretagem_OnClick); + return; + } + case 43: + { + this.TipoVendedorBox = (ComboBox)target; + return; + } + case 44: + { + this.VendedorBox = (ComboBox)target; + return; + } + case 45: + { + this.ComissaoNovoBox = (CustomItemValidation)target; + return; + } + case 46: + { + this.ComissaoNovoComboBox = (ComboBox)target; + this.ComissaoNovoComboBox.SelectionChanged += new SelectionChangedEventHandler(this.ComissaoVendedorBox_OnSelectionChanged); + return; + } + case 47: + { + this.ComissaoRenovacaoBox = (CustomItemValidation)target; + return; + } + case 48: + { + this.ComissaoRenovacaoComboBox = (ComboBox)target; + this.ComissaoRenovacaoComboBox.SelectionChanged += new SelectionChangedEventHandler(this.ComissaoVendedorBox_OnSelectionChanged); + return; + } + case 49: + { + this.ValorRepasseBox = (CurrencyTextBox)target; + return; + } + case 50: + { + this.FormaRecebidaBox = (TextBox)target; + return; + } + case 51: + { + this.VendedorGrid = (DataGrid)target; + return; + } + case 52: + { + this.RepasseVendedor = (DataGridTextColumn)target; + return; + } + case 54: + { + this.NomeBox = (TextBox)target; + return; + } + case 55: + { + this.TipoDocumentoPrincipalBox = (ComboBox)target; + return; + } + case 56: + { + this.DocumentoPrincipalBox = (TextBox)target; + CriticaApoliceView criticaApoliceView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView.SomenteNumeros); + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + return; + } + case 57: + { + this.NascimentoBox = (DatePicker)target; + this.NascimentoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.NascimentoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 58: + { + this.IdentidadeBox = (TextBox)target; + return; + } + case 59: + { + this.EmissorBox = (TextBox)target; + return; + } + case 60: + { + this.EstadoEmissorBox = (TextBox)target; + return; + } + case 61: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewTextInput += new TextCompositionEventHandler(this.SomenteData); + return; + } + case 62: + { + this.TelefoneListBox = (ListBox)target; + return; + } + case 68: + { + this.EmailListBox = (ListBox)target; + return; + } + case 71: + { + this.ItemGrid = (DataGrid)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 == 9) + { + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_OnClick)); + return; + } + if (connectionId == 53) + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirVendedor_OnClick); + return; + } + switch (connectionId) + { + case 63: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBox_OnSelectionChanged); + return; + } + case 64: + { + CriticaApoliceView criticaApoliceView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView.SomenteNumeros); + return; + } + case 65: + { + CriticaApoliceView criticaApoliceView1 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(criticaApoliceView1.FormatarTelefone); + CriticaApoliceView criticaApoliceView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView2.SomenteNumeros); + return; + } + case 66: + { + ((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus); + CriticaApoliceView criticaApoliceView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView3.SomenteNumeros); + return; + } + case 67: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirTelefone_OnClick); + return; + } + case 68: + case 71: + { + return; + } + case 69: + { + ((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus); + CriticaApoliceView criticaApoliceView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView4.SomenteNumeros); + return; + } + case 70: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirEmail_OnClick); + return; + } + case 72: + { + ((Button)target).Click += new RoutedEventHandler(this.Item_Click); + return; + } + default: + { + return; + } + } + } + + private void Tarefa_OnClick(object sender, RoutedEventArgs e) + { + Tarefa tarefa = new Tarefa(); + tarefa.set_IdCliente(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Id()); + tarefa.set_Cliente(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()); + tarefa.set_Entidade(0); + tarefa.set_IdEntidade(this.ViewModel.SelectedDocumento.get_Id()); + tarefa.set_Titulo(string.Concat(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome(), " APÓLICE ", this.ViewModel.SelectedDocumento.get_Apolice())); + Tarefa tarefa1 = tarefa; + this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa1, true), 0, false); + } + + private void TipoComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + int num; + ComboBox comboBox = (ComboBox)sender; + CustomIsReadOnlyControl customIsReadOnlyControl = Extentions.FindVisualAncestor(comboBox); + if (customIsReadOnlyControl == null) + { + return; + } + WrapPanel wrapPanel = Extentions.FindVisualAncestor(customIsReadOnlyControl); + ListBox listBox = Extentions.FindVisualAncestor(wrapPanel); + ContentPresenter contentPresenter = FindVisualChild.Find((ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(listBox.Items.IndexOf(wrapPanel.DataContext))); + DataTemplate contentTemplate = contentPresenter.ContentTemplate; + CustomItemValidation customItemValidation = (CustomItemValidation)contentTemplate.FindName("Prefixo", contentPresenter); + CustomItemValidation customItemValidation1 = (CustomItemValidation)contentTemplate.FindName("Telefone", contentPresenter); + TextBox textBox = ViewHelper.FindChildren(customItemValidation).FirstOrDefault(); + TextBox textBox1 = ViewHelper.FindChildren(customItemValidation1).FirstOrDefault(); + if (textBox == null || textBox1 == null) + { + return; + } + if ((TipoTelefone)comboBox.SelectedValue == 8) + { + customItemValidation.Visibility = System.Windows.Visibility.Collapsed; + textBox1.MaxLength = 20; + return; + } + customItemValidation.Visibility = System.Windows.Visibility.Visible; + textBox1.MaxLength = 10; + num = (textBox1.Text.Length >= 10 ? 10 : textBox1.Text.Length); + textBox1.Text = textBox1.Text.Substring(0, num); + } + + private void TipoDocumentoPrincipalBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + this.ViewModel.AlteraDocumentoPrincipal(); + } + + private void TipoVendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + if (this.ViewModel.SelectedPagamento == null) + { + this.ViewModel.SelectedPagamento = new VendedorParcela(); + } + this.ViewModel.SelectedPagamento.set_TipoVendedor((TipoVendedor)comboBox.SelectedItem); + } + + private async void Usuario_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool hasValue; + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null && comboBox.SelectedItem != null) + { + ToggleButton criticadoBox = this.CriticadoBox; + if (criticadoBox != null) + { + hasValue = !criticadoBox.IsChecked.HasValue; + } + else + { + hasValue = true; + } + if (!hasValue) + { + if (this.ViewModel.SelectedSeguradora != null) + { + this.SeguradoraBox.SelectionChanged -= new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged -= new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked -= new RoutedEventHandler(this.Criticado_OnChecked); + this.ViewModel.SelectedUsuario = (Usuario)comboBox.SelectedItem; + await this.ViewModel.CarregaCritica(((Usuario)comboBox.SelectedItem).get_Id(), this.ViewModel.SelectedSeguradora.get_Id(), this.ViewModel.Criticado); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged += new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked += new RoutedEventHandler(this.Criticado_OnChecked); + } + } + } + } + + private void ValidarDocumento() + { + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + List> keyValuePairs1 = this.ViewModel.SelectedDocumento.Validate(); + if (this.ViewModel.Telefones != null) + { + ExtensionMethods.ForEach(this.ViewModel.Telefones, (ClienteTelefone x) => { + List> keyValuePairs = x.Validate(); + keyValuePairs1.AddRange(keyValuePairs); + }); + } + this.ValidateFields(keyValuePairs1, false); + ExtensionMethods.ForEach(Extentions.FindVisualChildren(this.TelefoneListBox), (DependencyObject child) => child.ValidateFields(keyValuePairs1, false)); + } + + private void VendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + this.ViewModel.FiltrarRepasse((Vendedor)comboBox.SelectedItem); + NegocioCorretora? negocioCorretora = this.ViewModel.SelectedDocumento.get_NegocioCorretora(); + bool valueOrDefault = negocioCorretora.GetValueOrDefault() == 1; + if (valueOrDefault && this.ViewModel.CoCorretagem) + { + this.ComissaoNovoBox.Visibility = System.Windows.Visibility.Visible; + this.ComissaoRenovacaoBox.Visibility = System.Windows.Visibility.Collapsed; + return; + } + this.ComissaoNovoBox.Visibility = (!valueOrDefault ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ComissaoRenovacaoBox.Visibility = (valueOrDefault ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/AeronauticoView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/AeronauticoView.cs new file mode 100644 index 0000000..d0bef66 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/AeronauticoView.cs @@ -0,0 +1,373 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +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.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; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class AeronauticoView : BaseUserControl, IComponentConnector + { + public AeronauticoViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + private string _lastCategory = ""; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal CustomItemValidation MaisInformacoes; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public AeronauticoView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new AeronauticoViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + if (!lockInsert) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name == "MaisInformacoesRadioButton") + { + this.MaisInformacoes.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Excluir(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + [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/seguros/itens/aeronauticoview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 11: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Tipo_OnSelectionChanged); + return; + } + case 12: + { + AeronauticoView aeronauticoView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(aeronauticoView.SomenteNumeros); + return; + } + case 13: + { + AeronauticoView aeronauticoView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(aeronauticoView1.SomenteNumeros); + return; + } + case 14: + { + AeronauticoView aeronauticoView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(aeronauticoView2.SomenteNumeros); + return; + } + case 15: + { + AeronauticoView aeronauticoView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(aeronauticoView3.SomenteNumeros); + return; + } + case 16: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 17: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 18: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 19: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 20: + { + this.MaisInformacoes = (CustomItemValidation)target; + return; + } + } + this._contentLoaded = true; + } + + private void Tipo_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (((ComboBox)sender).SelectedItem == null) + { + return; + } + if (ValidationHelper.GetCategory((TipoAeronautico)((ComboBox)sender).SelectedItem) == this._lastCategory) + { + return; + } + this.ViewModel.SelectedItem.get_Aeronautico().set_Tipo((TipoAeronautico)((ComboBox)sender).SelectedItem); + this.ViewModel.UpdateAero(); + this.ValidateFields(this.ViewModel.SelectedItem.Validate(), true); + this._lastCategory = ValidationHelper.GetCategory(this.ViewModel.SelectedItem.get_Aeronautico().get_Tipo()); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/AutoView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/AutoView.cs new file mode 100644 index 0000000..4a9c3be --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/AutoView.cs @@ -0,0 +1,718 @@ +using Gestor.Application.Actions; +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.Helper; +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.Text.RegularExpressions; +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.Seguros.Itens +{ + public class AutoView : BaseUserControl, IComponentConnector + { + public AutoViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal WrapPanel PainelDadosAuto; + + internal TextBox FipeBox; + + internal AutoCompleteBox AutoCompleteFabricacao; + + internal TextBox ModeloBox; + + internal TextBox AnoModeloBox; + + internal TextBox CepCirculacaoBox; + + internal TextBox CepPernoiteBox; + + internal ComboBox ComboBoxTipoCorrecao; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal CustomItemValidation MaisInformacoes; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public AutoView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new AutoViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + if (!lockInsert) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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 ", Gestor.Common.Validation.ValidationHelper.GetDescription((TipoArquivoDigital)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void AutoCompleteFabricanteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscaFabricante(Gestor.Common.Validation.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 void BaixarXls_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.BaixarXls(); + } + + private async void BuscarModelo_OnClick(object sender, RoutedEventArgs e) + { + Fipe fipe = await this.ViewModel.ShowBuscaModeloDialog(this.ModeloBox.Text, this.AnoModeloBox.Text); + Fipe fipe1 = fipe; + if (fipe1 != null) + { + this.FipeBox.Text = fipe1.get_Codigo(); + this.ModeloBox.Text = fipe1.get_Modelo(); + this.AutoCompleteFabricacao.set_Text(fipe1.get_Marca()); + this.ViewModel.SelectedItem.get_Auto().set_Fabricante(this.ViewModel.Fabricantes.FirstOrDefault((Fabricante x) => x.get_Descricao() == fipe1.get_Marca())); + } + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void Cep_OnLostFocus(object sender, RoutedEventArgs e) + { + bool auto; + TextBox textBox = (TextBox)sender; + Item selectedItem = this.ViewModel.SelectedItem; + if (selectedItem != null) + { + auto = selectedItem.get_Auto(); + } + else + { + auto = false; + } + if (!auto) + { + return; + } + if (string.IsNullOrWhiteSpace(textBox.Text)) + { + return; + } + if ((textBox.Name == "CepCirculacaoBox" || textBox.Name == "CepPernoiteBox") && Gestor.Common.Validation.ValidationHelper.ValidaCep(textBox.Text)) + { + return; + } + if (!Gestor.Model.Helper.ValidationHelper.ValidacaoCep(Gestor.Common.Validation.ValidationHelper.FormatPostCode(textBox.Text))) + { + return; + } + textBox.Text = Gestor.Common.Validation.ValidationHelper.FormatPostCode(textBox.Text); + } + + private void Ci_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = Gestor.Common.Validation.ValidationHelper.FormatCi(textBox.Text); + } + + private void ComboBoxTipoCorrecao_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (this.ComboBoxTipoCorrecao.SelectedItem == null) + { + return; + } + this.ViewModel.Atualiza(this.ComboBoxTipoCorrecao.SelectedItem.ToString().ToUpper()); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name == "MaisInformacoesRadioButton") + { + this.MaisInformacoes.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.Excluir()) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + } + + private async void Fipe_LostFocus(object sender, RoutedEventArgs e) + { + int num; + bool auto; + object obj; + TextBox textBox = (TextBox)sender; + Item selectedItem = this.ViewModel.SelectedItem; + if (selectedItem != null) + { + auto = selectedItem.get_Auto(); + } + else + { + auto = false; + } + if (auto) + { + if (!string.IsNullOrWhiteSpace(textBox.Text)) + { + string str = Gestor.Model.Helper.ValidationHelper.FormataFipe(textBox.Text.Replace("-", "")); + if (Gestor.Model.Helper.ValidationHelper.ValidaFipe(str)) + { + textBox.Text = str; + if (!int.TryParse(Gestor.Model.Helper.ValidationHelper.OnlyNumber(str), out num) || num != 0) + { + Fipe fipe = await this.ViewModel.BuscaModelo(textBox.Text); + if (fipe != null) + { + this.ModeloBox.Text = fipe.get_Modelo(); + AutoCompleteBox autoCompleteFabricacao = this.AutoCompleteFabricacao; + List fabricantes = this.ViewModel.Fabricantes; + if (fabricantes != null) + { + obj = fabricantes.FirstOrDefault((Fabricante x) => x.get_Descricao() == fipe.get_Marca()); + } + else + { + obj = null; + } + autoCompleteFabricacao.set_SelectedItem(obj); + } + else + { + this.ViewModel.ToggleSnackBar(string.Concat("MODELO NÃO ENCONTRADO PARA O CÓDIGO FIPE ", textBox.Text), true); + } + } + } + } + } + textBox = null; + } + + private async void ImportarXls_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + Action enablePesquisarClientes = Gestor.Application.Actions.Actions.EnablePesquisarClientes; + if (enablePesquisarClientes != null) + { + enablePesquisarClientes(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + List> keyValuePairs = await this.ViewModel.ImportarXls(); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + Action action = Gestor.Application.Actions.Actions.EnablePesquisarClientes; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + Action enableMainMenu1 = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu1 != null) + { + enableMainMenu1(true); + } + else + { + } + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + Item selectedItem = this.ViewModel.SelectedItem; + List configuracoes = Recursos.Configuracoes; + bool flag = configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 18); + List configuracaoSistemas = Recursos.Configuracoes; + List> keyValuePairs = selectedItem.Validate(flag, configuracaoSistemas.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 27)); + this.ValidateFields(keyValuePairs, true); + } + + [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/seguros/itens/autoview.xaml", UriKind.Relative)); + } + + private void KeyUpBase_OnKeyUp(object sender, KeyEventArgs e) + { + TextBox textBox = (TextBox)sender; + if (!Regex.IsMatch(textBox.Text.Replace(".", ""), "^[0-9.]{11}$")) + { + textBox.Text = Regex.Replace(textBox.Text, "[^\\d]*", ""); + } + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + private void Placa(object sender, KeyEventArgs e) + { + Gestor.Model.Helper.ValidationHelper.FormataPlaca(((TextBox)sender).Text); + } + + private void Renavam_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = Gestor.Common.Validation.ValidationHelper.FormatRenavam(textBox.Text); + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.FipeBox.Focus(); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + private void SelecionaUsoVeiculo(object sender, SelectionChangedEventArgs e) + { + if (this.ViewModel.UsoVeiculo.GetValueOrDefault() == 2 || this.ViewModel.UsoVeiculo.GetValueOrDefault() == 3) + { + this.ViewModel.SelectedItem.get_Auto().set_Categoria(new Categoria?(3)); + } + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ImportarXls_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.BaixarXls_OnClick); + return; + } + case 13: + { + this.PainelDadosAuto = (WrapPanel)target; + return; + } + case 14: + { + this.FipeBox = (TextBox)target; + AutoView autoView = this; + this.FipeBox.PreviewTextInput += new TextCompositionEventHandler(autoView.SomenteNumeros); + this.FipeBox.LostFocus += new RoutedEventHandler(this.Fipe_LostFocus); + return; + } + case 15: + { + AutoView autoView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView1.Placa); + ((TextBox)target).PreviewKeyDown += new KeyEventHandler(this.Placa); + return; + } + case 16: + { + this.AutoCompleteFabricacao = (AutoCompleteBox)target; + this.AutoCompleteFabricacao.add_Populating(new PopulatingEventHandler(this, AutoView.AutoCompleteFabricanteBox_Populating)); + return; + } + case 17: + { + this.ModeloBox = (TextBox)target; + return; + } + case 18: + { + ((Button)target).Click += new RoutedEventHandler(this.BuscarModelo_OnClick); + return; + } + case 19: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.SelecionaUsoVeiculo); + return; + } + case 20: + { + AutoView autoView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView2.SomenteNumeros); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.Renavam_OnLostFocus); + ((TextBox)target).PreviewKeyUp += new KeyEventHandler(this.KeyUpBase_OnKeyUp); + return; + } + case 21: + { + ((ToggleButton)target).Checked += new RoutedEventHandler(this.ZeroKmToggleButton_Changed); + ((ToggleButton)target).Unchecked += new RoutedEventHandler(this.ZeroKmToggleButton_Changed); + return; + } + case 22: + { + AutoView autoView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView3.SomenteNumeros); + return; + } + case 23: + { + this.AnoModeloBox = (TextBox)target; + AutoView autoView4 = this; + this.AnoModeloBox.PreviewTextInput += new TextCompositionEventHandler(autoView4.SomenteNumeros); + return; + } + case 24: + { + AutoView autoView5 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView5.SomenteNumeros); + return; + } + case 25: + { + AutoView autoView6 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView6.SomenteNumeros); + return; + } + case 26: + { + this.CepCirculacaoBox = (TextBox)target; + this.CepCirculacaoBox.LostFocus += new RoutedEventHandler(this.Cep_OnLostFocus); + AutoView autoView7 = this; + this.CepCirculacaoBox.PreviewTextInput += new TextCompositionEventHandler(autoView7.SomenteNumeros); + return; + } + case 27: + { + this.CepPernoiteBox = (TextBox)target; + this.CepPernoiteBox.LostFocus += new RoutedEventHandler(this.Cep_OnLostFocus); + AutoView autoView8 = this; + this.CepPernoiteBox.PreviewTextInput += new TextCompositionEventHandler(autoView8.SomenteNumeros); + return; + } + case 28: + { + this.ComboBoxTipoCorrecao = (ComboBox)target; + this.ComboBoxTipoCorrecao.SelectionChanged += new SelectionChangedEventHandler(this.ComboBoxTipoCorrecao_SelectionChanged); + return; + } + case 29: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.Ci_OnLostFocus); + AutoView autoView9 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView9.SomenteNumeros); + return; + } + case 30: + { + AutoView autoView10 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView10.SomenteNumeros); + return; + } + case 31: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 32: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 33: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 34: + { + this.MaisInformacoes = (CustomItemValidation)target; + return; + } + } + this._contentLoaded = true; + } + + private void ZeroKmToggleButton_Changed(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedItem == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/BuscarModeloView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/BuscarModeloView.cs new file mode 100644 index 0000000..1f89612 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/BuscarModeloView.cs @@ -0,0 +1,85 @@ +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Markup; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class BuscarModeloView : BaseUserControl, IComponentConnector + { + internal DataGrid BuscaModeloGrid; + + private bool _contentLoaded; + + public BuscarModeloViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public BuscarModeloView(BuscarModeloViewModel viewModel) + { + this.ViewModel = viewModel; + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + [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/seguros/itens/buscarmodeloview.xaml", UriKind.Relative)); + } + + private void Pesquisar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Pesquisar(); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + BuscarModeloView buscarModeloView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(buscarModeloView.SomenteNumeros); + return; + } + case 2: + { + ((Button)target).Click += new RoutedEventHandler(this.Pesquisar_OnClick); + return; + } + case 3: + { + this.BuscaModeloGrid = (DataGrid)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/ConsorcioView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/ConsorcioView.cs new file mode 100644 index 0000000..3b14a0c --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/ConsorcioView.cs @@ -0,0 +1,320 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +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.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; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class ConsorcioView : BaseUserControl, IComponentConnector + { + public ConsorcioViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + private bool _salvando; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal CustomItemValidation MaisInformacoes; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ConsorcioView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new ConsorcioViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + if (!lockInsert) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name == "MaisInformacoesRadioButton") + { + this.MaisInformacoes.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Excluir(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + [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/seguros/itens/consorcioview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 11: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 12: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 13: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 14: + { + this.MaisInformacoes = (CustomItemValidation)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/GranizoView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/GranizoView.cs new file mode 100644 index 0000000..9382fe6 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/GranizoView.cs @@ -0,0 +1,383 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +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.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; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class GranizoView : BaseUserControl, IComponentConnector + { + public GranizoViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal TextBox CepBox; + + internal TextBox EnderecoBox; + + internal TextBox BairroBox; + + internal TextBox CidadeBox; + + internal TextBox EstadoBox; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal CustomItemValidation MaisInformacoes; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public GranizoView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new GranizoViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + if (!lockInsert) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name == "MaisInformacoesRadioButton") + { + this.MaisInformacoes.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.Excluir()) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.IncluirItem(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + [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/seguros/itens/granizoview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + if (!string.IsNullOrWhiteSpace(textBox.Text)) + { + string str = ValidationHelper.FormatPostCode(textBox.Text); + this.CepBox.Text = str; + if (ValidationHelper.ValidatePostCode(str)) + { + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + this.EnderecoBox.Text = enderecoBase.get_Endereco(); + this.CidadeBox.Text = enderecoBase.get_Cidade(); + this.EstadoBox.Text = enderecoBase.get_Estado(); + this.BairroBox.Text = enderecoBase.get_Bairro(); + } + } + } + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 11: + { + this.CepBox = (TextBox)target; + this.CepBox.LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + return; + } + case 12: + { + this.EnderecoBox = (TextBox)target; + return; + } + case 13: + { + GranizoView granizoView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(granizoView.SomenteNumeros); + return; + } + case 14: + { + this.BairroBox = (TextBox)target; + return; + } + case 15: + { + this.CidadeBox = (TextBox)target; + return; + } + case 16: + { + this.EstadoBox = (TextBox)target; + return; + } + case 17: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 18: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 19: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 20: + { + this.MaisInformacoes = (CustomItemValidation)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/PatrimonialView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/PatrimonialView.cs new file mode 100644 index 0000000..42e03ce --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/PatrimonialView.cs @@ -0,0 +1,466 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +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.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; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class PatrimonialView : BaseUserControl, IComponentConnector + { + public PatrimonialViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal TextBox CepBox; + + internal TextBox EnderecoBox; + + internal TextBox BairroBox; + + internal TextBox CidadeBox; + + internal TextBox EstadoBox; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal CustomItemValidation MaisInformacoes; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public PatrimonialView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new PatrimonialViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + if (!lockInsert) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void CpfBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name == "MaisInformacoesRadioButton") + { + this.MaisInformacoes.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.Excluir()) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + [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/seguros/itens/patrimonialview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + if (!string.IsNullOrWhiteSpace(textBox.Text)) + { + string str = ValidationHelper.FormatPostCode(textBox.Text); + if (ValidationHelper.ValidatePostCode(str)) + { + this.CepBox.Text = str; + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + this.EnderecoBox.Text = enderecoBase.get_Endereco(); + this.CidadeBox.Text = enderecoBase.get_Cidade(); + this.EstadoBox.Text = enderecoBase.get_Estado(); + this.BairroBox.Text = enderecoBase.get_Bairro(); + } + } + } + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 11: + { + this.CepBox = (TextBox)target; + this.CepBox.LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + return; + } + case 12: + { + this.EnderecoBox = (TextBox)target; + return; + } + case 13: + { + PatrimonialView patrimonialView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView.SomenteNumeros); + return; + } + case 14: + { + this.BairroBox = (TextBox)target; + return; + } + case 15: + { + this.CidadeBox = (TextBox)target; + return; + } + case 16: + { + this.EstadoBox = (TextBox)target; + return; + } + case 17: + { + PatrimonialView patrimonialView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView1.SomenteNumeros); + return; + } + case 18: + { + PatrimonialView patrimonialView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView2.SomenteNumeros); + PatrimonialView patrimonialView3 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(patrimonialView3.FormatarTelefone); + return; + } + case 19: + { + PatrimonialView patrimonialView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView4.SomenteNumeros); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.CpfBox_OnLostFocus); + return; + } + case 20: + { + PatrimonialView patrimonialView5 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView5.SomenteNumeros); + return; + } + case 21: + { + PatrimonialView patrimonialView6 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(patrimonialView6.FormatarTelefone); + PatrimonialView patrimonialView7 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView7.SomenteNumeros); + return; + } + case 22: + { + PatrimonialView patrimonialView8 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView8.SomenteNumeros); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.CpfBox_OnLostFocus); + return; + } + case 23: + { + PatrimonialView patrimonialView9 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView9.SomenteNumeros); + return; + } + case 24: + { + PatrimonialView patrimonialView10 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(patrimonialView10.FormatarTelefone); + PatrimonialView patrimonialView11 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView11.SomenteNumeros); + return; + } + case 25: + { + PatrimonialView patrimonialView12 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView12.SomenteNumeros); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.CpfBox_OnLostFocus); + return; + } + case 26: + { + PatrimonialView patrimonialView13 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView13.SomenteNumeros); + return; + } + case 27: + { + PatrimonialView patrimonialView14 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(patrimonialView14.FormatarTelefone); + PatrimonialView patrimonialView15 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView15.SomenteNumeros); + return; + } + case 28: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 29: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 30: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 31: + { + this.MaisInformacoes = (CustomItemValidation)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/RiscosDiversosView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/RiscosDiversosView.cs new file mode 100644 index 0000000..70a30b9 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/RiscosDiversosView.cs @@ -0,0 +1,683 @@ +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +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.Data; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class RiscosDiversosView : BaseUserControl, IComponentConnector, IStyleConnector + { + public RiscosDiversosViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + private bool _salvando; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal Menu BotoesTitulares; + + internal Separator SeparadorMaisInformacoes; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal DataGrid DataGridTitulares; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public RiscosDiversosView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new RiscosDiversosViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + if (!lockInsert) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void AlterarTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AlterarTitular(); + } + + private void AplicarTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AplicarTitular(); + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Trim().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarTitulares(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 void BotoesTitulares_OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) + { + bool flag; + if (!((Menu)sender).IsEnabled) + { + this.ViewModel.AlteracaoTitularesVisibility = System.Windows.Visibility.Collapsed; + } + DataGrid dataGridTitulares = this.DataGridTitulares; + if (dataGridTitulares != null) + { + flag = dataGridTitulares.Columns.First(); + } + else + { + flag = false; + } + if (!flag) + { + return; + } + this.DataGridTitulares.Columns.First().Visibility = (((Menu)sender).IsEnabled ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void DataGridTitulares_OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e) + { + string text; + string str; + string text1; + if (!(e.EditingElement is TextBox)) + { + return; + } + TextBox editingElement = e.EditingElement as TextBox; + string stringFormat = e.Column.ClipboardContentBinding.StringFormat; + if (stringFormat == "d") + { + if (editingElement != null) + { + text = editingElement.Text; + } + else + { + text = null; + } + if (!string.IsNullOrEmpty(text)) + { + editingElement.Text = ValidationHelper.FormatDate(editingElement.Text); + return; + } + if (editingElement != null) + { + editingElement.Text = null; + return; + } + } + else if (stringFormat == "c") + { + if (editingElement != null) + { + str = editingElement.Text; + } + else + { + str = null; + } + if (!string.IsNullOrEmpty(str)) + { + editingElement.Text = ValidationHelper.FormatCurrency(editingElement.Text); + return; + } + if (editingElement != null) + { + editingElement.Text = null; + } + } + else + { + if (editingElement != null) + { + text1 = editingElement.Text; + } + else + { + text1 = null; + } + if (!string.IsNullOrEmpty(text1)) + { + if (e.Column.SortMemberPath == "Cpf") + { + editingElement.Text = ValidationHelper.FormatDocument(editingElement.Text); + return; + } + } + else if (editingElement != null) + { + editingElement.Text = null; + return; + } + } + } + + private void Dependente_CellLoaded(object sender, RoutedEventArgs e) + { + bool valueOrDefault; + if (sender == null) + { + return; + } + DataGridCell dataGridCell = (DataGridCell)sender; + TitularesVida dataContext = (TitularesVida)((DataGridCell)sender).DataContext; + if (dataContext != null) + { + valueOrDefault = dataContext.get_Tipo().GetValueOrDefault() == 2; + } + else + { + valueOrDefault = false; + } + dataGridCell.Visibility = (valueOrDefault ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.DataGridTitulares.Visibility = System.Windows.Visibility.Collapsed; + this.SeparadorMaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.BotoesTitulares.Visibility = System.Windows.Visibility.Collapsed; + this.DataGridTitulares.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name != "MaisInformacoesRadioButton") + { + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + return; + } + this.SeparadorMaisInformacoes.Visibility = System.Windows.Visibility.Visible; + this.DataGridTitulares.Visibility = System.Windows.Visibility.Visible; + this.BotoesTitulares.Visibility = System.Windows.Visibility.Visible; + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.Excluir()) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + } + + private void ExcluirTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ExcluirTitular(); + } + + private async void ImportarTitulares_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.ImportarTitulares(); + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + private void IncluirTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirTitular(); + this.UpdateAutocompleteDependente(this.DataGridTitulares.Items.Cast().First()); + } + + [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/seguros/itens/riscosdiversosview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this._salvando = true; + this.ViewModel.Loading(true); + this.DataGridTitulares.Focus(); + List> keyValuePairs = await this.ViewModel.Salvar(this.DataGridTitulares.Items.Cast().ToList()); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + this._salvando = false; + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 11: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 12: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 13: + { + this.BotoesTitulares = (Menu)target; + this.BotoesTitulares.IsEnabledChanged += new DependencyPropertyChangedEventHandler(this.BotoesTitulares_OnIsEnabledChanged); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTitular_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AlterarTitular_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirTitular_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ImportarTitulares_OnClick); + return; + } + case 18: + { + this.SeparadorMaisInformacoes = (Separator)target; + return; + } + case 19: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 20: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 21: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 22: + { + RiscosDiversosView riscosDiversosView = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(riscosDiversosView.FormatarDocumento); + RiscosDiversosView riscosDiversosView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(riscosDiversosView1.SomenteNumeros); + return; + } + case 23: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AplicarTitular_OnClick); + return; + } + case 24: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 25: + { + this.DataGridTitulares = (DataGrid)target; + this.DataGridTitulares.CellEditEnding += new EventHandler(this.DataGridTitulares_OnCellEditEnding); + 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 26: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 27: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 28: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 29: + { + RiscosDiversosView riscosDiversosView = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(riscosDiversosView.FormatarDocumento); + RiscosDiversosView riscosDiversosView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(riscosDiversosView1.SomenteNumeros); + return; + } + case 30: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBoxSelectionChanged); + return; + } + case 31: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, RiscosDiversosView.AutoCompleteBox_Populating)); + return; + } + case 32: + { + EventSetter eventSetter = new EventSetter() + { + Event = FrameworkElement.LoadedEvent, + Handler = new RoutedEventHandler(this.Dependente_CellLoaded) + }; + ((System.Windows.Style)target).Setters.Add(eventSetter); + return; + } + default: + { + return; + } + } + } + + private async void TipoComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool dataContext; + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null) + { + dataContext = comboBox.DataContext; + } + else + { + dataContext = false; + } + if (dataContext) + { + TipoTitular? nullable = ((TitularesVida)((ComboBox)sender).DataContext).get_Tipo(); + if (nullable.GetValueOrDefault() == 2 && !this._salvando) + { + ObservableCollection titulares = this.ViewModel.Titulares; + if (!titulares.Any((TitularesVida x) => { + TipoTitular? tipo = x.get_Tipo(); + if (tipo.GetValueOrDefault() == 1) + { + return true; + } + tipo = x.get_Tipo(); + return tipo.GetValueOrDefault() == 0 & tipo.HasValue; + })) + { + ((ComboBox)sender).SelectedIndex = -1; + nullable = null; + ((TitularesVida)((ComboBox)sender).DataContext).set_Tipo(nullable); + await this.ViewModel.ShowMessage("É NECESSÁRIO ADICIONAR PELO MENOS UM TITULAR DO TIPO SÓCIO OU FUNCIONÁRIO\nANTES DE ADICIONAR UM DEPENDENTE.", "OK", "", false); + return; + } + } + this.UpdateAutocompleteDependente((TitularesVida)((ComboBox)sender).DataContext); + } + } + + private void UpdateAutocompleteDependente(TitularesVida item) + { + this.DataGridTitulares.ScrollIntoView(item, this.DataGridTitulares.Columns.First((DataGridColumn x) => (string)x.Header == "TITULAR DEPENDENTE")); + this.DataGridTitulares.UpdateLayout(); + DataGridRow dataGridRow = (DataGridRow)this.DataGridTitulares.ItemContainerGenerator.ContainerFromItem(item); + if (dataGridRow == null) + { + return; + } + ((DataGridCell)DataGridExtensions.GetVisualChild(dataGridRow).ItemContainerGenerator.ContainerFromIndex(12)).Visibility = (item.get_Tipo().GetValueOrDefault() == 2 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.DataGridTitulares.ScrollIntoView(item, this.DataGridTitulares.Columns.First()); + this.DataGridTitulares.UpdateLayout(); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/VidaView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/VidaView.cs new file mode 100644 index 0000000..afb86b5 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/VidaView.cs @@ -0,0 +1,705 @@ +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +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.Data; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class VidaView : BaseUserControl, IComponentConnector, IStyleConnector + { + public VidaViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + private bool _salvando; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal TextBox PlanoBox; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal Menu BotoesTitulares; + + internal Separator SeparadorMaisInformacoes; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal DataGrid DataGridTitulares; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public VidaView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new VidaViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + if (!lockInsert) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void AlterarTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AlterarTitular(); + } + + private void AplicarTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AplicarTitular(); + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Trim().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarTitulares(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 void BotoesTitulares_OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) + { + bool flag; + if (!((Menu)sender).IsEnabled) + { + this.ViewModel.AlteracaoTitularesVisibility = System.Windows.Visibility.Collapsed; + } + DataGrid dataGridTitulares = this.DataGridTitulares; + if (dataGridTitulares != null) + { + flag = dataGridTitulares.Columns.First(); + } + else + { + flag = false; + } + if (!flag) + { + return; + } + this.DataGridTitulares.Columns.First().Visibility = (((Menu)sender).IsEnabled ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void DataGridTitulares_OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e) + { + string text; + string str; + string text1; + if (!(e.EditingElement is TextBox)) + { + return; + } + TextBox editingElement = e.EditingElement as TextBox; + string stringFormat = e.Column.ClipboardContentBinding.StringFormat; + if (stringFormat == "d") + { + if (editingElement != null) + { + text = editingElement.Text; + } + else + { + text = null; + } + if (!string.IsNullOrEmpty(text)) + { + editingElement.Text = ValidationHelper.FormatDate(editingElement.Text); + return; + } + if (editingElement != null) + { + editingElement.Text = null; + return; + } + } + else if (stringFormat == "c") + { + if (editingElement != null) + { + str = editingElement.Text; + } + else + { + str = null; + } + if (!string.IsNullOrEmpty(str)) + { + editingElement.Text = ValidationHelper.FormatCurrency(editingElement.Text); + return; + } + if (editingElement != null) + { + editingElement.Text = null; + } + } + else + { + if (editingElement != null) + { + text1 = editingElement.Text; + } + else + { + text1 = null; + } + if (!string.IsNullOrEmpty(text1)) + { + if (e.Column.SortMemberPath == "Cpf") + { + editingElement.Text = ValidationHelper.FormatDocument(editingElement.Text); + return; + } + } + else if (editingElement != null) + { + editingElement.Text = null; + return; + } + } + } + + private void Dependente_CellLoaded(object sender, RoutedEventArgs e) + { + bool valueOrDefault; + if (sender == null) + { + return; + } + DataGridCell dataGridCell = (DataGridCell)sender; + TitularesVida dataContext = (TitularesVida)((DataGridCell)sender).DataContext; + if (dataContext != null) + { + valueOrDefault = dataContext.get_Tipo().GetValueOrDefault() == 2; + } + else + { + valueOrDefault = false; + } + dataGridCell.Visibility = (valueOrDefault ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.DataGridTitulares.Visibility = System.Windows.Visibility.Collapsed; + this.SeparadorMaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.BotoesTitulares.Visibility = System.Windows.Visibility.Collapsed; + this.DataGridTitulares.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name != "MaisInformacoesRadioButton") + { + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + return; + } + this.SeparadorMaisInformacoes.Visibility = System.Windows.Visibility.Visible; + this.DataGridTitulares.Visibility = System.Windows.Visibility.Visible; + this.BotoesTitulares.Visibility = System.Windows.Visibility.Visible; + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.Excluir()) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + } + + private void ExcluirTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ExcluirTitular(); + } + + private async void ImportarTitulares_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.ImportarTitulares(); + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + private async void IncluirTitular_OnClick(object sender, RoutedEventArgs e) + { + TitularesVida titularesVida = this.DataGridTitulares.Items.Cast().FirstOrDefault(); + if (titularesVida == null || titularesVida.get_Inicio().HasValue || titularesVida.get_Fim().HasValue || titularesVida.get_Nome() != null || titularesVida.get_Fatura() != null || titularesVida.get_Cpf() != null || titularesVida.get_Tipo().HasValue || titularesVida.get_Observacao() != null) + { + this.ViewModel.IncluirTitular(); + this.UpdateAutocompleteDependente(this.DataGridTitulares.Items.Cast().First(), false); + } + else + { + await this.ViewModel.ShowMessage("JÁ EXISTE UM CAMPO DE CADASTRO DE TITULAR CRIADO", "OK", "", false); + } + } + + [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/seguros/itens/vidaview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this._salvando = true; + this.ViewModel.Loading(true); + this.ViewModel.SelectedItem.get_Vida().set_Plano(this.PlanoBox.Text); + this.DataGridTitulares.Focus(); + List> keyValuePairs = await this.ViewModel.Salvar(this.DataGridTitulares.Items.Cast().ToList()); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + this._salvando = false; + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 11: + { + this.PlanoBox = (TextBox)target; + return; + } + case 12: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 13: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 14: + { + this.BotoesTitulares = (Menu)target; + this.BotoesTitulares.IsEnabledChanged += new DependencyPropertyChangedEventHandler(this.BotoesTitulares_OnIsEnabledChanged); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTitular_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AlterarTitular_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirTitular_OnClick); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ImportarTitulares_OnClick); + return; + } + case 19: + { + this.SeparadorMaisInformacoes = (Separator)target; + return; + } + case 20: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 21: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 22: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 23: + { + VidaView vidaView = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(vidaView.FormatarDocumento); + VidaView vidaView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(vidaView1.SomenteNumeros); + return; + } + case 24: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AplicarTitular_OnClick); + return; + } + case 25: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 26: + { + this.DataGridTitulares = (DataGrid)target; + this.DataGridTitulares.CellEditEnding += new EventHandler(this.DataGridTitulares_OnCellEditEnding); + 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 27: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 28: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 29: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 30: + { + VidaView vidaView = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(vidaView.FormatarDocumento); + VidaView vidaView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(vidaView1.SomenteNumeros); + return; + } + case 31: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBoxSelectionChanged); + return; + } + case 32: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, VidaView.AutoCompleteBox_Populating)); + return; + } + case 33: + { + EventSetter eventSetter = new EventSetter() + { + Event = FrameworkElement.LoadedEvent, + Handler = new RoutedEventHandler(this.Dependente_CellLoaded) + }; + ((System.Windows.Style)target).Setters.Add(eventSetter); + return; + } + default: + { + return; + } + } + } + + private async void TipoComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool dataContext; + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null) + { + dataContext = comboBox.DataContext; + } + else + { + dataContext = false; + } + if (dataContext) + { + TipoTitular? nullable = ((TitularesVida)((ComboBox)sender).DataContext).get_Tipo(); + if (nullable.GetValueOrDefault() == 2 && !this._salvando && this.ViewModel.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Id() != (long)6) + { + ObservableCollection titulares = this.ViewModel.Titulares; + if (!titulares.Any((TitularesVida x) => { + TipoTitular? tipo = x.get_Tipo(); + if (tipo.GetValueOrDefault() == 1) + { + return true; + } + tipo = x.get_Tipo(); + return tipo.GetValueOrDefault() == 0 & tipo.HasValue; + })) + { + ((ComboBox)sender).SelectedIndex = -1; + nullable = null; + ((TitularesVida)((ComboBox)sender).DataContext).set_Tipo(nullable); + await this.ViewModel.ShowMessage("É NECESSÁRIO ADICIONAR PELO MENOS UM TITULAR DO TIPO SÓCIO OU FUNCIONÁRIO\nANTES DE ADICIONAR UM DEPENDENTE.", "OK", "", false); + return; + } + } + this.UpdateAutocompleteDependente((TitularesVida)((ComboBox)sender).DataContext, false); + } + } + + private void UpdateAutocompleteDependente(TitularesVida item, bool scroll = true) + { + if (scroll) + { + this.DataGridTitulares.ScrollIntoView(item, this.DataGridTitulares.Columns.First((DataGridColumn x) => (string)x.Header == "TITULAR DEPENDENTE")); + } + this.DataGridTitulares.UpdateLayout(); + DataGridRow dataGridRow = (DataGridRow)this.DataGridTitulares.ItemContainerGenerator.ContainerFromItem(item); + if (dataGridRow == null) + { + return; + } + ((DataGridCell)DataGridExtensions.GetVisualChild(dataGridRow).ItemContainerGenerator.ContainerFromIndex(12)).Visibility = (item.get_Tipo().GetValueOrDefault() == 2 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + if (scroll) + { + this.DataGridTitulares.ScrollIntoView(item, this.DataGridTitulares.Columns.First()); + } + this.DataGridTitulares.UpdateLayout(); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/PerfilEmpresaView.cs b/Codemerx/Gestor.Application/Views/Seguros/PerfilEmpresaView.cs new file mode 100644 index 0000000..3d80f8c --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/PerfilEmpresaView.cs @@ -0,0 +1,267 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Generic; +using Gestor.Common.Helpers; +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.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 Xceed.Wpf.Toolkit; + +namespace Gestor.Application.Views.Seguros +{ + public class PerfilEmpresaView : BaseUserControl, IComponentConnector + { + public PerfilEmpresaViewModel ViewModel; + + private Controle _controle; + + internal MenuItem CancelarApoliceButton; + + internal TextBox TextAtividade; + + internal CustomIsReadOnlyControl ComboSegurancaControl; + + internal CheckComboBox ComboSeguranca; + + internal CustomIsReadOnlyControl ComboIncendioControl; + + internal CheckComboBox ComboIncendio; + + internal CheckBox ExclusivoDeposito; + + internal CheckBox DivisaTerrenoBaldio; + + internal CheckBox PatrimonioHistorio; + + internal CheckBox PossuiTelhado; + + internal CheckBox CaixasEletronicos; + + internal CheckBox Isopainel; + + internal CheckBox ConstrucaoReforma; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public PerfilEmpresaView(Controle controle) + { + this._controle = controle; + base.Tag = "CADASTRO DE PERFIL"; + this.ViewModel = new PerfilEmpresaViewModel(controle); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + this.LoadData(); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + bool id; + this.ViewModel.CancelarAlteracao(); + PerfilEmpresa selectedPerfilEmpresa = this.ViewModel.SelectedPerfilEmpresa; + if (selectedPerfilEmpresa != null) + { + id = selectedPerfilEmpresa.get_Id() == (long)0; + } + else + { + id = false; + } + if (id || this.ViewModel.SelectedPerfilEmpresa == null) + { + this.ViewModel.EnableIncluirPerfil = true; + } + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EnableIncluirPerfil = false; + this.ViewModel.Incluir(); + } + + [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/seguros/perfilempresaview.xaml", UriKind.Relative)); + } + + private void LoadData() + { + this.ComboSeguranca.BindData(false, true, "", false); + this.ComboIncendio.BindData(false, true, "", false); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ViewModel.Loading(false); + if (keyValuePairs != null) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + this.CancelarApoliceButton = (MenuItem)target; + this.CancelarApoliceButton.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + PerfilEmpresaView perfilEmpresaView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilEmpresaView.SomenteNumeros); + return; + } + case 7: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.VerificaOnSelected); + return; + } + case 8: + { + this.TextAtividade = (TextBox)target; + return; + } + case 9: + { + this.ComboSegurancaControl = (CustomIsReadOnlyControl)target; + return; + } + case 10: + { + this.ComboSeguranca = (CheckComboBox)target; + return; + } + case 11: + { + this.ComboIncendioControl = (CustomIsReadOnlyControl)target; + return; + } + case 12: + { + this.ComboIncendio = (CheckComboBox)target; + return; + } + case 13: + { + this.ExclusivoDeposito = (CheckBox)target; + return; + } + case 14: + { + this.DivisaTerrenoBaldio = (CheckBox)target; + return; + } + case 15: + { + this.PatrimonioHistorio = (CheckBox)target; + return; + } + case 16: + { + this.PossuiTelhado = (CheckBox)target; + return; + } + case 17: + { + this.CaixasEletronicos = (CheckBox)target; + return; + } + case 18: + { + this.Isopainel = (CheckBox)target; + return; + } + case 19: + { + this.ConstrucaoReforma = (CheckBox)target; + return; + } + } + this._contentLoaded = true; + } + + private void VerificaOnSelected(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + if (EnumHelper.GetDescription(comboBox.SelectedItem) == EnumHelper.GetDescription(0)) + { + this.ViewModel.AtivaCampos = System.Windows.Visibility.Visible; + return; + } + if (this.ViewModel.AtivaCampos == System.Windows.Visibility.Visible) + { + this.TextAtividade.Text = ""; + this.ViewModel.AtivaCampos = System.Windows.Visibility.Collapsed; + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/PerfilView.cs b/Codemerx/Gestor.Application/Views/Seguros/PerfilView.cs new file mode 100644 index 0000000..2a23628 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/PerfilView.cs @@ -0,0 +1,320 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +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.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; +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.Seguros +{ + public class PerfilView : BaseUserControl, IComponentConnector + { + public PerfilViewModel ViewModel; + + private Controle _controle; + + internal MenuItem CancelarApoliceButton; + + internal DatePicker NascimentoBox; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public PerfilView(Controle controle) + { + this._controle = controle; + base.Tag = "CADASTRO DE PERFIL"; + this.ViewModel = new PerfilViewModel(controle); + 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 Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + this.ValidarTela(); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.NascimentoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(Funcoes.DatePicker_OnLostKeyboardFocus); + this.NascimentoBox.PreviewKeyDown += new KeyEventHandler(Funcoes.DatePicker_PreviewKeyDown); + } + + private void CpfBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/seguros/perfilview.xaml", UriKind.Relative)); + } + + private void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + if (string.IsNullOrWhiteSpace(textBox.Text)) + { + return; + } + string str = ValidationHelper.FormatPostCode(textBox.Text); + if (!ValidationHelper.ValidatePostCode(str)) + { + return; + } + textBox.Text = str; + } + + private void RelacaoComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + string documento; + TimeSpan? nullable; + if (((ComboBox)sender).SelectedIndex == 0) + { + Cliente cliente = this._controle.get_Cliente(); + if (cliente != null) + { + documento = cliente.get_Documento(); + } + else + { + documento = null; + } + string str = ValidationHelper.FormatDocument(ValidationHelper.Clear(documento)); + bool flag = Regex.IsMatch(str, "\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}"); + Perfil perfil = (Perfil)this.ViewModel.SelectedPerfil.Clone(); + perfil.set_Cpf((flag ? str : "")); + perfil.set_Nome(this._controle.get_Cliente().get_Nome()); + perfil.set_Nascimento(this._controle.get_Cliente().get_Nascimento()); + perfil.set_Sexo(this._controle.get_Cliente().get_Sexo()); + perfil.set_EstadoCivil(this._controle.get_Cliente().get_EstadoCivil()); + perfil.set_Habilitacao(this._controle.get_Cliente().get_Habilitacao()); + DateTime? primeiraHabilitacao = this._controle.get_Cliente().get_PrimeiraHabilitacao(); + if (primeiraHabilitacao.HasValue) + { + DateTime networkTime = Funcoes.GetNetworkTime(); + primeiraHabilitacao = this._controle.get_Cliente().get_PrimeiraHabilitacao(); + if (primeiraHabilitacao.HasValue) + { + nullable = new TimeSpan?(networkTime - primeiraHabilitacao.GetValueOrDefault()); + } + else + { + nullable = null; + } + TimeSpan? nullable1 = nullable; + if (nullable1.Value.Days > 3650) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(10)); + } + else if (nullable1.Value.Days > 3285) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(9)); + } + else if (nullable1.Value.Days > 2920) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(8)); + } + else if (nullable1.Value.Days > 2555) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(7)); + } + else if (nullable1.Value.Days > 2190) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(6)); + } + else if (nullable1.Value.Days > 1825) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(5)); + } + else if (nullable1.Value.Days > 1460) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(4)); + } + else if (nullable1.Value.Days > 1095) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(3)); + } + else if (nullable1.Value.Days > 730) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(2)); + } + else if (nullable1.Value.Days <= 365) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(0)); + } + else + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(1)); + } + } + this.ViewModel.SelectedPerfil = perfil; + } + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + this.CancelarApoliceButton = (MenuItem)target; + this.CancelarApoliceButton.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.RelacaoComboBox_OnSelectionChanged); + return; + } + case 7: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.CpfBox_OnLostFocus); + PerfilView perfilView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView.SomenteNumeros); + return; + } + case 8: + { + this.NascimentoBox = (DatePicker)target; + this.NascimentoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.NascimentoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 9: + { + PerfilView perfilView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView1.SomenteNumeros); + return; + } + case 10: + { + PerfilView perfilView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView2.SomenteNumeros); + return; + } + case 11: + { + PerfilView perfilView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView3.SomenteNumeros); + return; + } + case 12: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + PerfilView perfilView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView4.SomenteNumeros); + return; + } + case 13: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + PerfilView perfilView5 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView5.SomenteNumeros); + return; + } + } + this._contentLoaded = true; + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedPerfil == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedPerfil.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/SinistroView.cs b/Codemerx/Gestor.Application/Views/Seguros/SinistroView.cs new file mode 100644 index 0000000..6bd6e00 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/SinistroView.cs @@ -0,0 +1,1003 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +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.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.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.Seguros +{ + public class SinistroView : BaseUserControl, IComponentConnector + { + public SinistroViewModel ViewModel; + + internal DataGrid ControleGrid; + + internal MenuItem SalvarSinistroButton; + + internal MenuItem CancelarApoliceButton; + + internal CustomIsReadOnlyControl TipoSinistroBox; + + internal ComboBox ParceiroMecanica; + + internal ComboBox ParceiroFunilaria; + + internal RadioButton AnotacoesButton; + + internal RadioButton AnotacoesInternasButton; + + internal CustomItemControl AnotacoesHoster; + + internal WebEditor Anotacoes; + + internal CustomItemControl ObservacoesHoster; + + internal WebEditor Observacoes; + + internal CustomItemControl AnotacoesInternasHoster; + + internal WebEditor AnotacoesInternas; + + internal CustomItemControl ObservacoesInternasHoster; + + internal WebEditor ObservacoesInternas; + + internal MaterialDesignThemes.Wpf.Snackbar Snackbar; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public SinistroView(Item item = null, bool attached = true) + { + item = item ?? ConsultaViewModel.ItemSelecionado; + base.Tag = "CADASTRO DE SINISTRO"; + this.ViewModel = new SinistroViewModel(item, attached); + 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 AbrirInfo_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirInfo(); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedSinistro == null) + { + return; + } + this.ViewModel.AbrirLogEmail(7, this.ViewModel.SelectedSinistro.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + bool? nullable; + bool valueOrDefault; + bool flag; + if (this.ViewModel.SelectedSinistro == null) + { + return; + } + this.ViewModel.Alterar(true); + CustomIsReadOnlyControl tipoSinistroBox = this.TipoSinistroBox; + ControleSinistro selectedControle = this.ViewModel.SelectedControle; + if (selectedControle != null) + { + List sinistros = selectedControle.get_Sinistros(); + if (sinistros != null) + { + nullable = new bool?(sinistros.Any((Sinistro x) => { + TipoSinistro? tipoSinistro = x.get_TipoSinistro(); + return tipoSinistro.GetValueOrDefault() == 0 & tipoSinistro.HasValue; + })); + } + else + { + nullable = null; + } + bool? nullable1 = nullable; + bool flag1 = false; + valueOrDefault = nullable1.GetValueOrDefault() == flag1 & nullable1.HasValue; + } + else + { + valueOrDefault = false; + } + if (valueOrDefault) + { + flag = true; + } + else + { + Sinistro selectedSinistro = this.ViewModel.SelectedSinistro; + if (selectedSinistro != null) + { + TipoSinistro? nullable2 = selectedSinistro.get_TipoSinistro(); + TipoSinistro tipoSinistro1 = 0; + flag = nullable2.GetValueOrDefault() == tipoSinistro1 & nullable2.HasValue; + } + else + { + flag = false; + } + } + tipoSinistroBox.IsEnabled = flag; + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, false); + Sinistro sinistro = this.ViewModel.SelectedSinistro; + if (sinistro == null) + { + return; + } + sinistro.Initialize(); + } + + private void Anotacoes_OnChecked(object sender, RoutedEventArgs e) + { + this.ToggleAnotacoes(true, false); + } + + private void AnotacoesInternas_OnChecked(object sender, RoutedEventArgs e) + { + this.ToggleAnotacoes(false, false); + } + + private async void ArquivoDigital_OnClick(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 5).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedSinistro.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(5); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedSinistro); + 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)5), "."), "OK", "", false); + } + } + + private void AutoCompleteBoxItem_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarItem(""); + } + + private void AutoCompleteBoxItem_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.ItemFiltrar(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 void AutoCompleteBoxSinistro_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarSinistro(""); + } + + private void AutoCompleteBoxSinistro_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.SinistroFiltrar(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 void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + this.Anotacoes.Initialize(null); + this.AnotacoesInternas.Initialize(null); + this.ViewModel.EnableFields = false; + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, false); + } + + private void ContentLoad() + { + this.ControleGrid.SelectionChanged += new SelectionChangedEventHandler(this.SinistroGrid_OnSelectionChanged); + this.AnotacoesButton.IsChecked = new bool?(this.ViewModel.IsAnotacoes); + this.AnotacoesInternasButton.IsChecked = new bool?(!this.ViewModel.IsAnotacoes); + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, false); + this.AnotacoesButton.Checked += new RoutedEventHandler(this.Anotacoes_OnChecked); + this.AnotacoesInternasButton.Checked += new RoutedEventHandler(this.AnotacoesInternas_OnChecked); + } + + private void EnviarHistorico_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EnviarLogEmail(); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void FunilariaButton_OnClick(object sender, RoutedEventArgs e) + { + Parceiro parceiroFunilaria; + long num; + object obj; + object obj1; + if (this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Id() == 0) + { + parceiroFunilaria = null; + } + else + { + parceiroFunilaria = this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroFunilaria(); + } + CadastroParceiroView cadastroParceiroView = new CadastroParceiroView(parceiroFunilaria); + (new HosterWindow(cadastroParceiroView, "CADASTRO DE PARCEIROS", new double?((double)1000), new double?((double)600), false)).ShowDialog(); + Parceiro selectedItem = (Parceiro)this.ParceiroMecanica.SelectedItem; + if (selectedItem != null) + { + num = selectedItem.get_Id(); + } + else + { + num = (long)0; + } + long num1 = num; + this.ViewModel.CarregarParceiros(); + ComboBox parceiroMecanica = this.ParceiroMecanica; + if (num1 > (long)0) + { + ObservableCollection parceiros = this.ViewModel.Parceiros; + if (parceiros != null) + { + obj = parceiros.FirstOrDefault((Parceiro x) => x.get_Id() == num1); + } + else + { + obj = null; + } + } + else + { + obj = null; + } + parceiroMecanica.SelectedItem = obj; + ComboBox comboBox = this.ParceiroFunilaria; + ObservableCollection observableCollection = this.ViewModel.Parceiros; + if (observableCollection != null) + { + obj1 = observableCollection.FirstOrDefault((Parceiro x) => { + long? nullable; + long id = x.get_Id(); + Parceiro selectedParceiro = cadastroParceiroView.ViewModel.SelectedParceiro; + if (selectedParceiro != null) + { + nullable = new long?(selectedParceiro.get_Id()); + } + else + { + nullable = null; + } + long? nullable1 = nullable; + return id == nullable1.GetValueOrDefault() & nullable1.HasValue; + }); + } + else + { + obj1 = null; + } + comboBox.SelectedItem = obj1; + } + + private void ImprimirHistorico_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedSinistro.get_Id() == 0) + { + return; + } + this.ViewModel.ImprimirHistorico(); + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedItem != null) + { + await this.ViewModel.IncluirSinistro(); + List> keyValuePairs = this.ViewModel.SelectedSinistro.Validate(); + this.ValidateFields(keyValuePairs, true); + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, false); + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIO INCLUIR O ITEM ANTES DE INCLUIR UM SINISTRO.", "OK", "", false); + } + } + + private void IncluirEnvolvido_OnClick(object sender, RoutedEventArgs e) + { + bool? nullable; + bool valueOrDefault; + bool flag; + List> keyValuePairs; + this.ViewModel.IncluirEnvolvido(); + CustomIsReadOnlyControl tipoSinistroBox = this.TipoSinistroBox; + ControleSinistro selectedControle = this.ViewModel.SelectedControle; + if (selectedControle != null) + { + List sinistros = selectedControle.get_Sinistros(); + if (sinistros != null) + { + nullable = new bool?(sinistros.Any((Sinistro x) => { + TipoSinistro? tipoSinistro = x.get_TipoSinistro(); + return tipoSinistro.GetValueOrDefault() == 0 & tipoSinistro.HasValue; + })); + } + else + { + nullable = null; + } + bool? nullable1 = nullable; + bool flag1 = false; + valueOrDefault = nullable1.GetValueOrDefault() == flag1 & nullable1.HasValue; + } + else + { + valueOrDefault = false; + } + if (valueOrDefault) + { + flag = true; + } + else + { + Sinistro selectedSinistro = this.ViewModel.SelectedSinistro; + if (selectedSinistro != null) + { + TipoSinistro? nullable2 = selectedSinistro.get_TipoSinistro(); + TipoSinistro tipoSinistro1 = 0; + flag = nullable2.GetValueOrDefault() == tipoSinistro1 & nullable2.HasValue; + } + else + { + flag = false; + } + } + tipoSinistroBox.IsEnabled = flag; + Sinistro sinistro = this.ViewModel.SelectedSinistro; + if (sinistro != null) + { + keyValuePairs = sinistro.Validate(); + } + else + { + keyValuePairs = null; + } + this.ValidateFields(keyValuePairs, true); + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, true); + } + + [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/seguros/sinistroview.xaml", UriKind.Relative)); + } + + private void ItemGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaItem((Item)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private void Log_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(7, this.ViewModel.SelectedSinistro.get_Id()); + } + + private void MecanicaButton_OnClick(object sender, RoutedEventArgs e) + { + Parceiro parceiroMecanica; + long num; + object obj; + object obj1; + if (this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroMecanica() == null || this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroMecanica().get_Id() == 0) + { + parceiroMecanica = null; + } + else + { + parceiroMecanica = this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroMecanica(); + } + CadastroParceiroView cadastroParceiroView = new CadastroParceiroView(parceiroMecanica); + (new HosterWindow(cadastroParceiroView, "CADASTRO DE PARCEIROS", new double?((double)1000), new double?((double)600), false)).ShowDialog(); + Parceiro selectedItem = (Parceiro)this.ParceiroFunilaria.SelectedItem; + if (selectedItem != null) + { + num = selectedItem.get_Id(); + } + else + { + num = (long)0; + } + long num1 = num; + this.ViewModel.CarregarParceiros(); + ComboBox parceiroFunilaria = this.ParceiroFunilaria; + if (num1 > (long)0) + { + ObservableCollection parceiros = this.ViewModel.Parceiros; + if (parceiros != null) + { + obj = parceiros.FirstOrDefault((Parceiro x) => x.get_Id() == num1); + } + else + { + obj = null; + } + } + else + { + obj = null; + } + parceiroFunilaria.SelectedItem = obj; + ComboBox comboBox = this.ParceiroMecanica; + ObservableCollection observableCollection = this.ViewModel.Parceiros; + if (observableCollection != null) + { + obj1 = observableCollection.FirstOrDefault((Parceiro x) => { + long? nullable; + long id = x.get_Id(); + Parceiro selectedParceiro = cadastroParceiroView.ViewModel.SelectedParceiro; + if (selectedParceiro != null) + { + nullable = new long?(selectedParceiro.get_Id()); + } + else + { + nullable = null; + } + long? nullable1 = nullable; + return id == nullable1.GetValueOrDefault() & nullable1.HasValue; + }); + } + else + { + obj1 = null; + } + comboBox.SelectedItem = obj1; + } + + private void ParceiroBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + SinistroViewModel viewModel; + ComboBox comboBox = (ComboBox)sender; + if (comboBox == null || comboBox.SelectedItem == null) + { + return; + } + Parceiro selectedItem = (Parceiro)comboBox.SelectedItem; + if (comboBox.Name != "ParceiroMecanica") + { + if (this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroFunilaria() == null) + { + this.ViewModel.SelectedSinistro.get_SinistroAuto().set_ParceiroFunilaria(selectedItem); + } + this.ParceiroFunilaria.Text = selectedItem.get_Nome(); + this.ViewModel.TelefonesFunileiro = ""; + bool flag = true; + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd1()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone1())) + { + flag = false; + viewModel = this.ViewModel; + viewModel.TelefonesFunileiro = string.Concat(new string[] { viewModel.TelefonesFunileiro, "TELEFONE 1: (", selectedItem.get_Ddd1(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone1()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd2()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone2())) + { + flag = false; + viewModel = this.ViewModel; + viewModel.TelefonesFunileiro = string.Concat(new string[] { viewModel.TelefonesFunileiro, "\nTELEFONE 2: (", selectedItem.get_Ddd2(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone2()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd3()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone3())) + { + flag = false; + viewModel = this.ViewModel; + viewModel.TelefonesFunileiro = string.Concat(new string[] { viewModel.TelefonesFunileiro, "\nTELEFONE 3: (", selectedItem.get_Ddd3(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone3()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Endereco()) || !string.IsNullOrWhiteSpace(selectedItem.get_Cidade()) || !string.IsNullOrWhiteSpace(selectedItem.get_Uf()) || !string.IsNullOrWhiteSpace(selectedItem.get_Bairro()) || !string.IsNullOrWhiteSpace(selectedItem.get_Cep()) || !string.IsNullOrWhiteSpace(selectedItem.get_Numero()) || !string.IsNullOrWhiteSpace(selectedItem.get_Complemento())) + { + flag = false; + viewModel = this.ViewModel; + SinistroViewModel sinistroViewModel = viewModel; + string[] telefonesFunileiro = new string[] { viewModel.TelefonesFunileiro, "\nENDEREÇO: ", selectedItem.get_Endereco(), ", ", selectedItem.get_Numero(), ", ", null, null, null, null, null, null, null, null, null }; + telefonesFunileiro[6] = (string.IsNullOrWhiteSpace(selectedItem.get_Complemento()) ? "-" : selectedItem.get_Complemento() ?? ""); + telefonesFunileiro[7] = ", "; + telefonesFunileiro[8] = selectedItem.get_Bairro(); + telefonesFunileiro[9] = ", "; + telefonesFunileiro[10] = selectedItem.get_Cidade(); + telefonesFunileiro[11] = "/"; + telefonesFunileiro[12] = selectedItem.get_Uf(); + telefonesFunileiro[13] = " - "; + telefonesFunileiro[14] = selectedItem.get_Cep(); + sinistroViewModel.TelefonesFunileiro = string.Concat(telefonesFunileiro); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Email())) + { + flag = false; + SinistroViewModel viewModel1 = this.ViewModel; + viewModel1.TelefonesFunileiro = string.Concat(viewModel1.TelefonesFunileiro, "\nEMAIL: ", selectedItem.get_Email()); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Cgccpf())) + { + flag = false; + SinistroViewModel sinistroViewModel1 = this.ViewModel; + sinistroViewModel1.TelefonesFunileiro = string.Concat(sinistroViewModel1.TelefonesFunileiro, "\nDOCUMENTO: ", selectedItem.get_Cgccpf()); + } + if (flag) + { + this.ViewModel.TelefonesFunileiro = "PARCEIRO SEM MAIS INFORMAÇÕES"; + } + } + else + { + if (this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroMecanica() == null) + { + this.ViewModel.SelectedSinistro.get_SinistroAuto().set_ParceiroMecanica(selectedItem); + } + this.ParceiroMecanica.Text = selectedItem.get_Nome(); + this.ViewModel.TelefonesMecanica = ""; + bool flag1 = true; + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd1()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone1())) + { + flag1 = false; + viewModel = this.ViewModel; + viewModel.TelefonesMecanica = string.Concat(new string[] { viewModel.TelefonesMecanica, "TELEFONE 1: (", selectedItem.get_Ddd1(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone1()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd2()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone2())) + { + flag1 = false; + viewModel = this.ViewModel; + viewModel.TelefonesMecanica = string.Concat(new string[] { viewModel.TelefonesMecanica, "\nTELEFONE 2: (", selectedItem.get_Ddd2(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone2()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd3()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone3())) + { + flag1 = false; + viewModel = this.ViewModel; + viewModel.TelefonesMecanica = string.Concat(new string[] { viewModel.TelefonesMecanica, "\nTELEFONE 3: (", selectedItem.get_Ddd3(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone3()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Endereco()) || !string.IsNullOrWhiteSpace(selectedItem.get_Cidade()) || !string.IsNullOrWhiteSpace(selectedItem.get_Uf()) || !string.IsNullOrWhiteSpace(selectedItem.get_Bairro()) || !string.IsNullOrWhiteSpace(selectedItem.get_Cep()) || !string.IsNullOrWhiteSpace(selectedItem.get_Numero()) || !string.IsNullOrWhiteSpace(selectedItem.get_Complemento())) + { + flag1 = false; + viewModel = this.ViewModel; + SinistroViewModel sinistroViewModel2 = viewModel; + string[] telefonesMecanica = new string[] { viewModel.TelefonesMecanica, "\nENDEREÇO: ", selectedItem.get_Endereco(), ", ", selectedItem.get_Numero(), ", ", null, null, null, null, null, null, null, null, null }; + telefonesMecanica[6] = (string.IsNullOrWhiteSpace(selectedItem.get_Complemento()) ? "-" : selectedItem.get_Complemento() ?? ""); + telefonesMecanica[7] = ", "; + telefonesMecanica[8] = selectedItem.get_Bairro(); + telefonesMecanica[9] = ", "; + telefonesMecanica[10] = selectedItem.get_Cidade(); + telefonesMecanica[11] = "/"; + telefonesMecanica[12] = selectedItem.get_Uf(); + telefonesMecanica[13] = " - "; + telefonesMecanica[14] = selectedItem.get_Cep(); + sinistroViewModel2.TelefonesMecanica = string.Concat(telefonesMecanica); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Email())) + { + flag1 = false; + SinistroViewModel viewModel2 = this.ViewModel; + viewModel2.TelefonesMecanica = string.Concat(viewModel2.TelefonesMecanica, "\nEMAIL: ", selectedItem.get_Email()); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Cgccpf())) + { + flag1 = false; + SinistroViewModel viewModel3 = this.ViewModel; + viewModel3.TelefonesMecanica = string.Concat(viewModel3.TelefonesMecanica, "\nDOCUMENTO: ", selectedItem.get_Cgccpf()); + } + if (flag1) + { + this.ViewModel.TelefonesMecanica = "PARCEIRO SEM MAIS INFORMAÇÕES"; + return; + } + } + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.ViewModel.Anotacoes = this.Anotacoes.GetHtml(); + this.ViewModel.AnotacoesInternas = this.AnotacoesInternas.GetHtml(); + if (this.ViewModel.EditarObservacao) + { + this.ViewModel.SelectedSinistro.set_ObservacaoInterna(this.ObservacoesInternas.GetHtml()); + this.ViewModel.SelectedSinistro.set_Observacao(this.Observacoes.GetHtml()); + } + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.Anotacoes.Initialize(null); + this.AnotacoesInternas.Initialize(null); + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, false); + } + } + + private void SinistroGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaControle((ControleSinistro)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private void SituacaoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox == null || comboBox.SelectedItem == null) + { + return; + } + if ((StatusSinistro)comboBox.SelectedItem == 1) + { + this.ViewModel.SelectedSinistro.set_DataLiquidacao(null); + this.ViewModel.LiquidacaoVisibility = System.Windows.Visibility.Collapsed; + } + else + { + this.ViewModel.LiquidacaoVisibility = System.Windows.Visibility.Visible; + } + this.Validar(); + } + + private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e) + { + this.Snackbar.set_IsActive(false); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, SinistroView.AutoCompleteBoxSinistro_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBoxSinistro_OnTextChanged)); + return; + } + case 2: + { + this.ControleGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirEnvolvido_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 7: + { + this.SalvarSinistroButton = (MenuItem)target; + this.SalvarSinistroButton.Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 8: + { + this.CancelarApoliceButton = (MenuItem)target; + this.CancelarApoliceButton.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Tarefas_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ArquivoDigital_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ImprimirHistorico_OnClick); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.EnviarHistorico_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Log_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirInfo_OnClick); + return; + } + case 17: + { + this.TipoSinistroBox = (CustomIsReadOnlyControl)target; + return; + } + case 18: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 19: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 20: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 21: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.SituacaoBox_OnSelectionChanged); + return; + } + case 22: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 23: + { + SinistroView sinistroView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(sinistroView.SomenteNumeros); + return; + } + case 24: + { + SinistroView sinistroView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(sinistroView1.SomenteNumeros); + SinistroView sinistroView2 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(sinistroView2.FormatarTelefone); + return; + } + case 25: + { + this.ParceiroMecanica = (ComboBox)target; + this.ParceiroMecanica.SelectionChanged += new SelectionChangedEventHandler(this.ParceiroBox_OnSelectionChanged); + return; + } + case 26: + { + ((Button)target).Click += new RoutedEventHandler(this.MecanicaButton_OnClick); + return; + } + case 27: + { + this.ParceiroFunilaria = (ComboBox)target; + this.ParceiroFunilaria.SelectionChanged += new SelectionChangedEventHandler(this.ParceiroBox_OnSelectionChanged); + return; + } + case 28: + { + ((Button)target).Click += new RoutedEventHandler(this.FunilariaButton_OnClick); + return; + } + case 29: + { + this.AnotacoesButton = (RadioButton)target; + return; + } + case 30: + { + this.AnotacoesInternasButton = (RadioButton)target; + return; + } + case 31: + { + this.AnotacoesHoster = (CustomItemControl)target; + return; + } + case 32: + { + this.Anotacoes = (WebEditor)target; + return; + } + case 33: + { + this.ObservacoesHoster = (CustomItemControl)target; + return; + } + case 34: + { + this.Observacoes = (WebEditor)target; + return; + } + case 35: + { + this.AnotacoesInternasHoster = (CustomItemControl)target; + return; + } + case 36: + { + this.AnotacoesInternas = (WebEditor)target; + return; + } + case 37: + { + this.ObservacoesInternasHoster = (CustomItemControl)target; + return; + } + case 38: + { + this.ObservacoesInternas = (WebEditor)target; + return; + } + case 39: + { + this.Snackbar = (MaterialDesignThemes.Wpf.Snackbar)target; + return; + } + case 40: + { + ((SnackbarMessage)target).add_ActionClick(new RoutedEventHandler(this.SnackbarMessage_ActionClick)); + return; + } + } + this._contentLoaded = true; + } + + private async void Tarefas_OnClick(object sender, RoutedEventArgs e) + { + Cliente cliente = await this.ViewModel.BuscarClienteSinistro(); + Tarefa tarefa = new Tarefa(); + tarefa.set_IdCliente(this.ViewModel.SelectedSinistro.get_Id()); + tarefa.set_Cliente(cliente.get_Nome()); + tarefa.set_Entidade(4); + tarefa.set_IdEntidade(this.ViewModel.SelectedSinistro.get_Id()); + tarefa.set_Titulo(string.Concat("SINISTRO ", this.ViewModel.SelectedSinistro.get_Numero(), " ITEM ", this.ViewModel.SelectedSinistro.get_ItemSinistrado())); + this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa, true), 0, false); + } + + private void ToggleAnotacoes(bool anotacoes, bool inclusao = false) + { + if (anotacoes) + { + this.ViewModel.IsAnotacoes = true; + if (this.ViewModel.EnableFields | inclusao) + { + this.AnotacoesHoster.Visibility = System.Windows.Visibility.Visible; + this.AnotacoesInternasHoster.Visibility = System.Windows.Visibility.Collapsed; + return; + } + this.AnotacoesHoster.Visibility = System.Windows.Visibility.Collapsed; + this.AnotacoesInternasHoster.Visibility = System.Windows.Visibility.Collapsed; + return; + } + this.ViewModel.IsAnotacoes = false; + if (this.ViewModel.EnableFields | inclusao) + { + this.AnotacoesHoster.Visibility = System.Windows.Visibility.Collapsed; + this.AnotacoesInternasHoster.Visibility = System.Windows.Visibility.Visible; + return; + } + this.AnotacoesHoster.Visibility = System.Windows.Visibility.Collapsed; + this.AnotacoesInternasHoster.Visibility = System.Windows.Visibility.Collapsed; + } + + private void Validar() + { + if (this.ViewModel.SelectedSinistro == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedSinistro.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs b/Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs new file mode 100644 index 0000000..61be59b --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs @@ -0,0 +1,154 @@ +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Seguros; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros +{ + public class TrocarClienteView : BaseUserControl, IComponentConnector + { + public TrocarClienteViewModel ViewModel; + + internal System.Windows.Controls.ProgressBar ProgressBar; + + internal MaterialDesignThemes.Wpf.Snackbar Snackbar; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public TrocarClienteView(Documento documento) + { + this.ViewModel = new TrocarClienteViewModel() + { + SelectedDocumento = documento + }; + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarCliente(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim()), null, 2).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void CloseSlackBar() + { + Thread.Sleep(5000); + System.Windows.Threading.Dispatcher dispatcher = this.ProgressBar.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => this.ToggleSnackBar("", false))); + } + + [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/seguros/trocarclienteview.xaml", UriKind.Relative)); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + if (!await this.ViewModel.Salvar()) + { + this.ToggleSnackBar("ERRO AO TROCAR CLIENTE.", true); + } + else + { + this.ToggleSnackBar("CLIENTE TROCADO COM SUCESSO.", true); + } + } + + private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e) + { + this.Snackbar.set_IsActive(false); + } + + [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.ProgressBar = (System.Windows.Controls.ProgressBar)target; + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 3: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, TrocarClienteView.AutoCompleteBox_Populating)); + return; + } + case 4: + { + this.Snackbar = (MaterialDesignThemes.Wpf.Snackbar)target; + return; + } + case 5: + { + ((SnackbarMessage)target).add_ActionClick(new RoutedEventHandler(this.SnackbarMessage_ActionClick)); + return; + } + } + this._contentLoaded = true; + } + + public void ToggleSnackBar(string message, bool active = true) + { + this.Snackbar.get_Message().Content = message; + this.Snackbar.set_IsActive(active); + if (!active) + { + return; + } + Task.Factory.StartNew(new Action(this.CloseSlackBar)); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/TutorialView.cs b/Codemerx/Gestor.Application/Views/TutorialView.cs new file mode 100644 index 0000000..10e45ae --- /dev/null +++ b/Codemerx/Gestor.Application/Views/TutorialView.cs @@ -0,0 +1,369 @@ +using Gestor.Application; +using Gestor.Application.Componentes; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Reflection; +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.Media; +using System.Windows.Shapes; +using System.Windows.Shell; +using System.Windows.Threading; + +namespace Gestor.Application.Views +{ + public class TutorialView : Window, IComponentConnector + { + public TutorialViewModel ViewModel; + + private bool _buttonClickable; + + internal System.Windows.Shell.WindowChrome WindowChrome; + + internal Grid CloseButton; + + internal Grid ProgressRing; + + internal Image ProgressBar; + + internal TextBox NomeBox; + + internal TextBox UserBox; + + internal CustomSenhaLoginBox PasswordBox; + + internal CustomSenhaLoginBox ConfirmacaoBox; + + private bool _contentLoaded; + + private Tuple PrimeiroAcesso + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public TutorialView(Tuple primeiroacesso) + { + this.PrimeiroAcesso = primeiroacesso; + this.ViewModel = new TutorialViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + this.CloseButton.MouseEnter += new MouseEventHandler(TutorialView.TopControls_OnMouseEnter); + this.CloseButton.MouseLeave += new MouseEventHandler(this.TopControls_OnMouseLeave); + } + + public void CloseButton_Click() + { + base.Close(); + } + + private async void Concluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EnableFields = false; + this.Loading(true); + bool flag = await this.ViewModel.Concluir(); + this.Loading(false); + this.ViewModel.EnableFields = true; + if (!flag) + { + base.Close(); + } + else if (await this.ViewModel.VerificaAcesso()) + { + (new MainWindow()).Show(); + base.Close(); + } + else + { + base.Close(); + } + } + + private void ConfirmacaoBox_LostFocus(object sender, RoutedEventArgs e) + { + this.ViewModel.ConfirmacaoSenha = this.ConfirmacaoBox.Text; + } + + private async void ContentLoad() + { + string str = null; + this.Loading(true); + if (this.PrimeiroAcesso.Item1) + { + await this.ViewModel.VerificarUsuario(); + } + else + { + str = await this.ViewModel.CriarBanco(); + } + this.Loading(false); + if (str == null) + { + str = await this.ViewModel.VerificaEmpresa(); + if (str == null) + { + this.ViewModel.Fase1 = true; + await this.ViewModel.IniciarConfiguracoes(); + } + else + { + await this.ViewModel.ShowMessage(str, "OK", "", false); + } + } + else + { + await this.ViewModel.ShowMessage(str, "OK", "", false); + } + str = null; + } + + private void DestativarTodasAsSeguradoras_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.DesativarSeguradoras(); + } + + private void DestativarTodosOsRamos_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.DesativarRamos(); + } + + [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/tutorialview.xaml", UriKind.Relative)); + } + + private void Loading(bool loading) + { + if (loading) + { + TutorialViewModel viewModel = this.ViewModel; + TutorialViewModel tutorialViewModel = this.ViewModel; + int num = 0; + bool flag = (bool)num; + this.ViewModel.Fase3 = (bool)num; + bool flag1 = flag; + bool flag2 = flag1; + tutorialViewModel.Fase2 = flag1; + viewModel.Fase1 = flag2; + } + this.ViewModel.LoadingVisibility = loading; + } + + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + Size newSize; + base.OnRenderSizeChanged(sizeInfo); + if (sizeInfo.HeightChanged) + { + double top = base.Top; + double height = sizeInfo.PreviousSize.Height; + newSize = sizeInfo.NewSize; + base.Top = top + (height - newSize.Height) / 2; + } + if (sizeInfo.WidthChanged) + { + double left = base.Left; + double width = sizeInfo.PreviousSize.Width; + newSize = sizeInfo.NewSize; + base.Left = left + (width - newSize.Width) / 2; + } + } + + private void PasswordBox_LostFocus(object sender, RoutedEventArgs e) + { + this.ViewModel.Senha = this.PasswordBox.Text; + } + + private async void ProsseguirFase1_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EnableFields = false; + this.Loading(true); + if (!await this.ViewModel.ValidarLogin()) + { + base.Close(); + } + this.Loading(false); + this.ViewModel.EnableFields = true; + } + + private async void ProsseguirFase2_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EnableFields = false; + this.Loading(true); + await this.ViewModel.ValidarSeguradoras(); + this.Loading(false); + this.ViewModel.EnableFields = true; + } + + [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.WindowChrome = (System.Windows.Shell.WindowChrome)target; + return; + } + case 2: + { + this.CloseButton = (Grid)target; + this.CloseButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); + this.CloseButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); + return; + } + case 3: + { + this.ProgressRing = (Grid)target; + return; + } + case 4: + { + this.ProgressBar = (Image)target; + return; + } + case 5: + { + this.NomeBox = (TextBox)target; + return; + } + case 6: + { + this.UserBox = (TextBox)target; + return; + } + case 7: + { + this.PasswordBox = (CustomSenhaLoginBox)target; + return; + } + case 8: + { + this.ConfirmacaoBox = (CustomSenhaLoginBox)target; + return; + } + case 9: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.ProsseguirFase1_OnClick); + return; + } + case 10: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.DestativarTodasAsSeguradoras_OnClick); + return; + } + case 11: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.VoltarFase2_OnClick); + return; + } + case 12: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.ProsseguirFase2_OnClick); + return; + } + case 13: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.DestativarTodosOsRamos_OnClick); + return; + } + case 14: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.VoltarFase3_OnClick); + return; + } + case 15: + { + ((RepeatButton)target).Click += new RoutedEventHandler(this.Concluir_OnClick); + return; + } + } + this._contentLoaded = true; + } + + private static void TopControls_OnMouseEnter(object sender, MouseEventArgs e) + { + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray)); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeave(object sender, MouseEventArgs e) + { + this._buttonClickable = false; + ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent); + Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; + if (child != null) + { + child.Stroke = new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + this._buttonClickable = true; + ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.DimGray)); + } + + private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + if (this._buttonClickable) + { + MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click")); + if (method == null) + { + return; + } + method.Invoke(this, null); + } + } + + private void VoltarFase2_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Fase1 = true; + this.ViewModel.Fase2 = false; + } + + private void VoltarFase3_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Fase2 = true; + this.ViewModel.Fase3 = false; + } + } +} \ No newline at end of file -- cgit v1.2.3