summaryrefslogtreecommitdiff
path: root/Gestor.Application/Views/Ferramentas/NotaFiscalView.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Application/Views/Ferramentas/NotaFiscalView.cs')
-rw-r--r--Gestor.Application/Views/Ferramentas/NotaFiscalView.cs327
1 files changed, 0 insertions, 327 deletions
diff --git a/Gestor.Application/Views/Ferramentas/NotaFiscalView.cs b/Gestor.Application/Views/Ferramentas/NotaFiscalView.cs
deleted file mode 100644
index a4928ce..0000000
--- a/Gestor.Application/Views/Ferramentas/NotaFiscalView.cs
+++ /dev/null
@@ -1,327 +0,0 @@
-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<List<NotaFiscal>> 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<NotaFiscal> 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<KeyValuePair<string, string>> 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<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- bool flag = configuracoes.Any<ConfiguracaoSistema>((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