summaryrefslogtreecommitdiff
path: root/Gestor.Application/Views/Ferramentas/ManutencaoPagamentosView.cs
blob: f57ac7c46a67dde71fb134a9d07575264f97af49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
using Gestor.Application.Servicos.Seguros;
using Gestor.Application.ViewModels.Ferramentas;
using Gestor.Application.ViewModels.Generic;
using Gestor.Application.Views.Generic;
using Gestor.Application.Views.Seguros;
using Gestor.Model.Domain.Ferramentas;
using Gestor.Model.Domain.Relatorios;
using Gestor.Model.Domain.Seguros;
using MaterialDesignThemes.Wpf;
using System;
using System.CodeDom.Compiler;
using System.Collections.ObjectModel;
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 Xceed.Wpf.AvalonDock.Controls;

namespace Gestor.Application.Views.Ferramentas
{
	public class ManutencaoPagamentosView : BaseUserControl, IComponentConnector, IStyleConnector
	{
		private bool _contentLoaded;

		public ManutencaoPagamentosViewModel ViewModel
		{
			get;
			set;
		}

		[DebuggerNonUserCode]
		[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
		internal Delegate _CreateDelegate(Type delegateType, string handler)
		{
			return Delegate.CreateDelegate(delegateType, this, handler);
		}

		public ManutencaoPagamentosView()
		{
			base.Tag = "MANUTENÇÃO DE PAGAMENTOS";
			this.ViewModel = new ManutencaoPagamentosViewModel();
			base.DataContext = this.ViewModel;
			this.InitializeComponent();
		}

		private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.AdcionarFiltroPersonalizado();
		}

		private async void Apolice_OnClick(object sender, RoutedEventArgs e)
		{
			ManutencaoPagamentos dataContext = (ManutencaoPagamentos)((Button)sender).DataContext;
			if (dataContext != null)
			{
				this.ViewModel.Loading(true);
				long idDocumento = dataContext.get_IdDocumento();
				Documento documento = await (new ApoliceServico()).BuscarApoliceAsync(idDocumento, false, false);
				if (documento != null)
				{
					double? nullable = null;
					double? nullable1 = nullable;
					nullable = null;
					(new HosterWindow(new ApoliceView(documento, true, false, 1, dataContext.get_IdParcela(), false), string.Concat("CADASTRO DE APÓLICES - ", documento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).Show();
					this.ViewModel.Loading(false);
				}
				else
				{
					this.ViewModel.Loading(false);
				}
			}
			dataContext = null;
		}

		private async void Buscar_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.Loading(true);
			await this.ViewModel.Buscar();
			this.ViewModel.Loading(false);
		}

		private void CheckBox_Checked(object sender, RoutedEventArgs e)
		{
			this.ViewModel.Selecionar(true);
		}

		private async void Excluir_OnClick(object sender, RoutedEventArgs e)
		{
			if (this.ViewModel.Pagamentos != null)
			{
				ObservableCollection<ManutencaoPagamentos> pagamentos = this.ViewModel.Pagamentos;
				if (!pagamentos.All<ManutencaoPagamentos>((ManutencaoPagamentos x) => !x.get_Selecionado()))
				{
					bool? nullable = await this.ViewModel.ShowSenha("DESEJA REALMENTE EXCLUIR OS PAGAMENTOS SELECIONADOS?\nESSE PROCEDIMENTO É IRREVERSÍVEL.");
					if (!nullable.HasValue)
					{
						return;
					}
					else if (!nullable.GetValueOrDefault())
					{
						await this.ViewModel.ShowMessage("SENHA INVÁLIDA", "OK", "", false);
						return;
					}
					else
					{
						this.ViewModel.Loading(true);
						await this.ViewModel.Excluir();
						this.ViewModel.Loading(false);
						return;
					}
				}
			}
			await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR OS PAGAMENTOS QUE DESEJA EXCLUIR ANTES DE PROSSEGUIR", "OK", "", false);
		}

		private void ExcluirFiltro_OnClick(object sender, RoutedEventArgs e)
		{
			Chip chip = sender as Chip;
			if (chip == null)
			{
				return;
			}
			ListBox listBox = Extentions.FindVisualAncestor<ListBox>(chip);
			FiltroPersonalizado item = (FiltroPersonalizado)listBox.Items[listBox.Items.IndexOf(chip.DataContext)];
			if (item == null)
			{
				return;
			}
			this.ViewModel.FiltroPersonalizadoSelecionado.Remove(item);
			this.ViewModel.PesquisaPersonalizada();
		}

		private void FecharFiltro_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.VisibilityFiltroPersonalizado = (this.ViewModel.VisibilityFiltroPersonalizado == System.Windows.Visibility.Collapsed ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed);
		}

		[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/manutencaopagamentosview.xaml", UriKind.Relative));
		}

		[DebuggerNonUserCode]
		[EditorBrowsable(EditorBrowsableState.Never)]
		[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
		void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
		{
			switch (connectionId)
			{
				case 1:
				{
					((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
					((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					return;
				}
				case 2:
				{
					((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
					((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					return;
				}
				case 3:
				{
					((Button)target).Click += new RoutedEventHandler(this.Buscar_OnClick);
					return;
				}
				case 4:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick);
					return;
				}
				case 5:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.FecharFiltro_OnClick);
					return;
				}
				case 6:
				{
					((Button)target).Click += new RoutedEventHandler(this.FecharFiltro_OnClick);
					return;
				}
				case 7:
				{
					((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					return;
				}
				case 8:
				{
					((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					return;
				}
				case 9:
				{
					((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltro_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)
		{
			switch (connectionId)
			{
				case 10:
				{
					((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_OnClick));
					return;
				}
				case 11:
				{
					((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBox_Checked);
					((CheckBox)target).Unchecked += new RoutedEventHandler(this.UnCheckBox_Checked);
					return;
				}
				case 12:
				{
					((Button)target).Click += new RoutedEventHandler(this.Apolice_OnClick);
					return;
				}
				default:
				{
					return;
				}
			}
		}

		private void UnCheckBox_Checked(object sender, RoutedEventArgs e)
		{
			this.ViewModel.Selecionar(false);
		}
	}
}