using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Markup; using System.Windows.Threading; using CurrencyTextBoxControl; using Gestor.Application.Drawers; using Gestor.Application.Helpers; using Gestor.Application.Servicos; using Gestor.Application.ViewModels.Ferramentas; 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; 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; public NotaFiscalView() { ((FrameworkElement)this).Tag = "CADASTRO DE NOTA FISCAL"; ViewModel = new NotaFiscalViewModel(); ((FrameworkElement)this).DataContext = ViewModel; InitializeComponent(); Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher; if (dispatcher != null) { dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad)); } } private void ContentLoad() { ((DataGridColumn)NomeField).Visibility = (Visibility)(ViewModel.Apelido ? 2 : 0); ((DataGridColumn)ApelidoField).Visibility = (Visibility)((!ViewModel.Apelido) ? 2 : 0); } private void AutoCompleteBoxNotaFiscal_Populating(object sender, PopulatingEventArgs e) { e.Cancel = true; ViewModel.Filtrar(ValidationHelper.RemoveDiacritics(e.Parameter.Trim())).ContinueWith(delegate(Task> searchResult) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (searchResult.Result != null) { AutoCompleteBox val = (AutoCompleteBox)sender; val.ItemsSource = searchResult.Result; val.PopulateComplete(); } }, TaskScheduler.FromCurrentSynchronizationContext()); } private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).Text)) { ViewModel.FiltrarNotaFiscal(""); } } private void Incluir_OnClick(object sender, RoutedEventArgs e) { ViewModel.Incluir(); } private void Alterar_OnClick(object sender, RoutedEventArgs e) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown ViewModel.CancelNotaFiscal = (NotaFiscal)((DomainBase)ViewModel.SelectedNotaFiscal).Clone(); ViewModel.Alterar(alterar: true); ((DomainBase)ViewModel.SelectedNotaFiscal).Initialize(); } private async void Salvar_OnClick(object sender, RoutedEventArgs e) { ViewModel.Loading(isLoading: true); DataPicker.SelectedDate = Convert.ToDateTime(DataPicker.Text); List> list = await ViewModel.Salvar(); ((DependencyObject)(object)this).ValidateFields(list); bool num = list == null || list.Count == 0; ViewModel.Loading(isLoading: false); if (!num) { await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK"); } } private void Cancelar_OnClick(object sender, RoutedEventArgs e) { ViewModel.CancelarAlteracao(); } private void Excluir_OnClick(object sender, RoutedEventArgs e) { ViewModel.Excluir(); } private void AbrirLog_OnClick(object sender, RoutedEventArgs e) { ViewModel.AbrirLog((TipoTela)55, ((DomainBase)ViewModel.SelectedNotaFiscal).Id); } private async void UIElement_OnLostFocus(object sender, RoutedEventArgs e) { if (ViewModel.SelectedNotaFiscal != null && ViewModel.EnableFields) { bool flag = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 5); if (((FrameworkElement)(CurrencyTextBox)sender).Name == "ValorBrutoBox" && flag && ValorIssBox.Number == 0m) { decimal num = await ViewModel.BuscarImposto(); ValorIssBox.Number = ValorBrutoBox.Number * num; } ValorLiquidoBox.Number = ValorBrutoBox.Number - ValorIssBox.Number - ValorIrBox.Number; } } private async void Importar_Click(object sender, RoutedEventArgs e) { ViewModel.IsEnabled = false; ViewModel.EnableMenu = false; ViewModel.EnableMainMenu = false; List list = await ViewModel.ShowExtratoComissaoDialog(ViewModel.Seguradoras); if (list != null) { await ViewModel.SalvarLote(list); } ViewModel.EnableMainMenu = true; ViewModel.EnableMenu = true; ViewModel.IsEnabled = true; } private async void ArquivoDigital_OnClick(object sender, RoutedEventArgs e) { if (!new PermissaoArquivoDigitalServico().BuscarPermissao(Recursos.Usuario, (TipoArquivoDigital)16).Consultar) { await ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE " + ValidationHelper.GetDescription((Enum)(object)(TipoArquivoDigital)16) + "."); return; } FiltroArquivoDigital filtro = new FiltroArquivoDigital { Id = ((DomainBase)ViewModel.SelectedNotaFiscal).Id, Tipo = (TipoArquivoDigital)16, Parente = ViewModel.SelectedNotaFiscal }; ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtro), 0, close: false); } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] public void InitializeComponent() { if (!_contentLoaded) { _contentLoaded = true; Uri uri = new Uri("/Gestor.Application;component/views/ferramentas/notafiscalview.xaml", UriKind.Relative); Application.LoadComponent((object)this, uri); } } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] internal Delegate _CreateDelegate(Type delegateType, string handler) { return Delegate.CreateDelegate(delegateType, this, handler); } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] [EditorBrowsable(EditorBrowsableState.Never)] void IComponentConnector.Connect(int connectionId, object target) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Expected O, but got Unknown //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Expected O, but got Unknown switch (connectionId) { case 1: ((AutoCompleteBox)target).Populating += new PopulatingEventHandler(AutoCompleteBoxNotaFiscal_Populating); ((AutoCompleteBox)target).TextChanged += new RoutedEventHandler(AutoCompleteBox_OnTextChanged); break; case 2: NotaFiscalGrid = (DataGrid)target; break; case 3: NomeField = (DataGridTextColumn)target; break; case 4: ApelidoField = (DataGridTextColumn)target; break; case 5: ((MenuItem)target).Click += new RoutedEventHandler(Incluir_OnClick); break; case 6: ((MenuItem)target).Click += new RoutedEventHandler(Importar_Click); break; case 7: ((MenuItem)target).Click += new RoutedEventHandler(Alterar_OnClick); break; case 8: ((MenuItem)target).Click += new RoutedEventHandler(Salvar_OnClick); break; case 9: ((MenuItem)target).Click += new RoutedEventHandler(Cancelar_OnClick); break; case 10: ((MenuItem)target).Click += new RoutedEventHandler(Excluir_OnClick); break; case 11: MaisOpcoesButton = (MenuItem)target; break; case 12: ((MenuItem)target).Click += new RoutedEventHandler(AbrirLog_OnClick); break; case 13: ((MenuItem)target).Click += new RoutedEventHandler(ArquivoDigital_OnClick); break; case 14: DataPicker = (DatePicker)target; ((UIElement)DataPicker).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); ((Control)DataPicker).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick); ((UIElement)DataPicker).PreviewKeyDown += new KeyEventHandler(base.DatePicker_PreviewKeyDown); break; case 15: ValorBrutoBox = (CurrencyTextBox)target; ((UIElement)ValorBrutoBox).LostFocus += new RoutedEventHandler(UIElement_OnLostFocus); break; case 16: ValorIssBox = (CurrencyTextBox)target; ((UIElement)ValorIssBox).LostFocus += new RoutedEventHandler(UIElement_OnLostFocus); break; case 17: ValorIrBox = (CurrencyTextBox)target; ((UIElement)ValorIrBox).LostFocus += new RoutedEventHandler(UIElement_OnLostFocus); break; case 18: ValorLiquidoBox = (CurrencyTextBox)target; ((UIElement)ValorLiquidoBox).LostFocus += new RoutedEventHandler(UIElement_OnLostFocus); break; case 19: ExtratoBox = (TextBox)target; break; case 20: EstipulanteBox = (ComboBox)target; break; default: _contentLoaded = true; break; } } }