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 --- .../Views/Ferramentas/NotaFiscalView.cs | 327 +++++++++++++++++++++ 1 file changed, 327 insertions(+) create mode 100644 Gestor.Application/Views/Ferramentas/NotaFiscalView.cs (limited to 'Gestor.Application/Views/Ferramentas/NotaFiscalView.cs') diff --git a/Gestor.Application/Views/Ferramentas/NotaFiscalView.cs b/Gestor.Application/Views/Ferramentas/NotaFiscalView.cs new file mode 100644 index 0000000..a4928ce --- /dev/null +++ b/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 -- cgit v1.2.3