From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- .../Relatorios/FechamentoFinanceiroView.cs | 285 +++++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 Gestor.Application/Views/Financeiro/Relatorios/FechamentoFinanceiroView.cs (limited to 'Gestor.Application/Views/Financeiro/Relatorios/FechamentoFinanceiroView.cs') diff --git a/Gestor.Application/Views/Financeiro/Relatorios/FechamentoFinanceiroView.cs b/Gestor.Application/Views/Financeiro/Relatorios/FechamentoFinanceiroView.cs new file mode 100644 index 0000000..3c04339 --- /dev/null +++ b/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 -- cgit v1.2.3