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/Financeiro/BancosContasView.cs | 371 +++++++++++++++++++++ 1 file changed, 371 insertions(+) create mode 100644 Codemerx/Gestor.Application/Views/Financeiro/BancosContasView.cs (limited to 'Codemerx/Gestor.Application/Views/Financeiro/BancosContasView.cs') 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 -- cgit v1.2.3