summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/Views/BI/NotasView.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
commit1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch)
treee1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/Views/BI/NotasView.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/Views/BI/NotasView.cs')
-rw-r--r--Codemerx/Gestor.Application/Views/BI/NotasView.cs298
1 files changed, 298 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/Views/BI/NotasView.cs b/Codemerx/Gestor.Application/Views/BI/NotasView.cs
new file mode 100644
index 0000000..1386592
--- /dev/null
+++ b/Codemerx/Gestor.Application/Views/BI/NotasView.cs
@@ -0,0 +1,298 @@
+using Gestor.Application.Helpers;
+using Gestor.Application.ViewModels.BI;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.Views.Generic;
+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.Media;
+
+namespace Gestor.Application.Views.BI
+{
+ public class NotasView : BaseUserControl, IComponentConnector, IStyleConnector
+ {
+ internal ProgressBar ProgressRing;
+
+ private bool _contentLoaded;
+
+ public NotasViewModel ViewModel
+ {
+ get;
+ set;
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ internal Delegate _CreateDelegate(Type delegateType, string handler)
+ {
+ return Delegate.CreateDelegate(delegateType, this, handler);
+ }
+
+ public NotasView()
+ {
+ this.ViewModel = new NotasViewModel();
+ base.DataContext = this.ViewModel;
+ this.InitializeComponent();
+ }
+
+ private async Task AbrirNota(Tarefa data, bool notaBool = false, bool agendamento = false)
+ {
+ while (true)
+ {
+ Tarefa tarefa = await this.ViewModel.ShowTarefaDialog(data, notaBool, agendamento);
+ Tarefa tarefa1 = tarefa;
+ if (tarefa1 == null)
+ {
+ return;
+ }
+ if (tarefa1.get_Usuario() == null)
+ {
+ tarefa1.set_Usuario(tarefa1.get_UsuariosVinculados().FirstOrDefault<Usuario>());
+ }
+ List<ResponsavelTarefa> list = tarefa1.get_UsuariosVinculados().Select<Usuario, ResponsavelTarefa>((Usuario x) => {
+ ResponsavelTarefa responsavelTarefa = new ResponsavelTarefa();
+ responsavelTarefa.set_IdTarefa(tarefa1.get_Id());
+ responsavelTarefa.set_Usuario(x);
+ return responsavelTarefa;
+ }).ToList<ResponsavelTarefa>();
+ tarefa1.set_Responsaveis(list);
+ this.ViewModel.Loading(true);
+ List<KeyValuePair<string, string>> keyValuePairs = await this.ViewModel.Salvar(tarefa1);
+ this.ViewModel.Loading(false);
+ if (keyValuePairs == null || keyValuePairs.Count == 0)
+ {
+ break;
+ }
+ await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", "");
+ }
+ this.ViewModel.ToggleSnackBar("NOTA SALVA COM SUCESSO.", true);
+ await this.ViewModel.CarregarNotas();
+ return;
+ }
+
+ private async void AdicionarNota_OnClick(object sender, RoutedEventArgs e)
+ {
+ await this.ViewModel.AdicionarNota();
+ }
+
+ private async void ExcluirNota_OnClick(object sender, RoutedEventArgs e)
+ {
+ Tarefa dataContext = ((Button)sender).DataContext as Tarefa;
+ if (dataContext != null)
+ {
+ await this.ViewModel.ExcluirNota(dataContext);
+ await this.ViewModel.CarregarNotas();
+ }
+ }
+
+ private static object GetDataFromListBox(ItemsControl source, Point point)
+ {
+ UIElement parent = source.InputHitTest(point) as UIElement;
+ if (parent == null)
+ {
+ return null;
+ }
+ object unsetValue = DependencyProperty.UnsetValue;
+ while (unsetValue == DependencyProperty.UnsetValue)
+ {
+ if (parent == null)
+ {
+ continue;
+ }
+ unsetValue = source.ItemContainerGenerator.ItemFromContainer(parent);
+ if (unsetValue == DependencyProperty.UnsetValue)
+ {
+ parent = VisualTreeHelper.GetParent(parent) as UIElement;
+ }
+ if (parent != source)
+ {
+ continue;
+ }
+ return null;
+ }
+ if (unsetValue == DependencyProperty.UnsetValue)
+ {
+ return null;
+ }
+ return unsetValue;
+ }
+
+ [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/bi/notasview.xaml", UriKind.Relative));
+ }
+
+ private async void ListBox_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ List<Usuario> list;
+ ListBox listBox = (ListBox)sender;
+ object dataFromListBox = NotasView.GetDataFromListBox(listBox, e.GetPosition(listBox));
+ if (dataFromListBox != null)
+ {
+ Tarefa tarefa = new Tarefa();
+ DomainBase.Copy<Tarefa, Tarefa>(tarefa, (Tarefa)dataFromListBox);
+ Tarefa tarefa1 = tarefa;
+ List<ResponsavelTarefa> responsaveis = tarefa.get_Responsaveis();
+ if (responsaveis != null)
+ {
+ list = (
+ from x in responsaveis
+ select x.get_Usuario()).ToList<Usuario>();
+ }
+ else
+ {
+ list = null;
+ }
+ tarefa1.set_UsuariosVinculados(list);
+ await this.AbrirNota(tarefa, tarefa.get_Entidade() == 1, tarefa.get_Entidade() == 1);
+ }
+ }
+
+ private async void NotaConcluida_OnClick(object sender, RoutedEventArgs e)
+ {
+ Tarefa dataContext = ((Button)sender).DataContext as Tarefa;
+ if (dataContext != null)
+ {
+ dataContext.set_Conclusao(new DateTime?(Funcoes.GetNetworkTime()));
+ dataContext.set_Status(2);
+ await this.ViewModel.SalvarNota(dataContext);
+ await this.ViewModel.CarregarNotas();
+ }
+ }
+
+ private async void SarvarNota_OnClick(object sender, RoutedEventArgs e)
+ {
+ Tarefa dataContext = ((Button)sender).DataContext as Tarefa;
+ if (dataContext != null)
+ {
+ this.ViewModel.Loading(true);
+ List<KeyValuePair<string, string>> keyValuePairs = await this.ViewModel.Salvar(dataContext);
+ this.ViewModel.Loading(false);
+ if (keyValuePairs == null || keyValuePairs.Count == 0)
+ {
+ this.ViewModel.ToggleSnackBar("NOTA SALVA COM SUCESSO.", true);
+ }
+ else
+ {
+ await this.ViewModel.CarregarNotas();
+ }
+ }
+ }
+
+ [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:
+ {
+ ((ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(this.ListBox_OnPreviewMouseDoubleClick);
+ return;
+ }
+ case 3:
+ case 4:
+ case 5:
+ {
+ this._contentLoaded = true;
+ return;
+ }
+ case 6:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.AdicionarNota_OnClick);
+ return;
+ }
+ case 7:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.ToggleNotasConcluidas_OnClick);
+ return;
+ }
+ case 8:
+ {
+ ((ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(this.ListBox_OnPreviewMouseDoubleClick);
+ return;
+ }
+ default:
+ {
+ this._contentLoaded = true;
+ return;
+ }
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target)
+ {
+ switch (connectionId)
+ {
+ case 3:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.ExcluirNota_OnClick);
+ return;
+ }
+ case 4:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.NotaConcluida_OnClick);
+ return;
+ }
+ case 5:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.SarvarNota_OnClick);
+ return;
+ }
+ case 6:
+ case 7:
+ case 8:
+ {
+ return;
+ }
+ case 9:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.ExcluirNota_OnClick);
+ return;
+ }
+ case 10:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.SarvarNota_OnClick);
+ return;
+ }
+ default:
+ {
+ return;
+ }
+ }
+ }
+
+ private void ToggleNotasConcluidas_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.ToggleNotasConcluidas();
+ }
+ }
+} \ No newline at end of file