/// <summary> /// Exibe MessageBox /// </summary> /// <param name="message">passa messagem por parametro</param> private void AsyncMessageBox(string message, bool retornook) { BlackBox = Visibility.Collapsed; StarProgress = false; TextMsgBox = message; ShowMsgBox = Visibility.Visible; System.Media.SystemSounds.Exclamation.Play(); Task.Factory.StartNew(() => Freezetime(10)).ContinueWith(taskmsg => { if (taskmsg.IsCompleted) { ShowMsgBox = Visibility.Collapsed; if (retornook == true) { Atendimento.Clear(); PF.Clear(); PJ.Clear(); Protocolo = NProtocolo(); Atendimento.Operador = AccountOn.Identificador; AreaTransferencia.Limpar(); ns.GoBack(); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
private void ExecuteCommandPesquisarInscricao(object obj) { try { if (Atendimento.Cliente.Inscricao == string.Empty) { return; } string identificador = new mMascaras().Remove(Atendimento.Cliente.Inscricao); PF.Clear(); PJ.Clear(); switch (identificador.Length) { case 11: ClientePF(new mData().ExistPessoaFisica(identificador)); break; case 14: ClientePJ(new mData().ExistPessoaJuridica(identificador)); break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async void MostrarCliente(string cpf) { PF.Clear(); ListaPJ.Clear(); var pf = Task.Run(() => mdata.ExistPessoaFisica(cpf)); await pf; if (pf.IsCompleted) { PF.Add(new mCliente() { Inscricao = pf.Result.CPF, NomeRazao = pf.Result.Nome, Telefones = pf.Result.Telefones, Email = pf.Result.Email }); } List <Task <mPJ_Ext> > l_pj = new List <Task <mPJ_Ext> >(); foreach (mVinculos v in pf.Result.ColecaoVinculos) { l_pj.Add(Task.Run(() => mdata.ExistPessoaJuridica(v.CNPJ))); } foreach (Task <mPJ_Ext> pj in l_pj) { await pj; //if (pj.Result.SituacaoCadastral != "BAIXADO") if (pj.IsCompleted) { if (pf.Result.ColecaoVinculos.Count > 1) { ListaPJ.Add(new mCliente() { Inscricao = pj.Result.CNPJ, NomeRazao = pj.Result.RazaoSocial, Telefones = pj.Result.Telefones, Email = pj.Result.Email }); ViewListaPJ = Visibility.Visible; } else { PJ.Add(new mCliente() { Inscricao = pj.Result.CNPJ, NomeRazao = pj.Result.RazaoSocial, Telefones = pj.Result.Telefones, Email = pj.Result.Email }); } } } }
private void AsyncMostrarCliente(string cpf) { Task <mPF_Ext> .Factory.StartNew(() => mdata.ExistPessoaFisica(cpf)) .ContinueWith(task => { if (task.IsCompleted) { PF.Clear(); PF.Add(new mCliente() { Inscricao = task.Result.CPF, NomeRazao = task.Result.Nome, Telefones = task.Result.Telefones, Email = task.Result.Email }); ListaPJ.Clear(); foreach (mVinculos v in task.Result.ColecaoVinculos) { Task <mPJ_Ext> .Factory.StartNew(() => mdata.ExistPessoaJuridica(v.CNPJ)).ContinueWith(task_two => { if (task_two.IsCompleted) { if (task.Result.ColecaoVinculos.Count > 1) { ListaPJ.Add(new mCliente() { Inscricao = task_two.Result.CNPJ, NomeRazao = task_two.Result.RazaoSocial, Telefones = task_two.Result.Telefones, Email = task_two.Result.Email }); ViewListaPJ = Visibility.Visible; } else { PJ.Add(new mCliente() { Inscricao = task_two.Result.CNPJ, NomeRazao = task_two.Result.RazaoSocial, Telefones = task_two.Result.Telefones, Email = task_two.Result.Email }); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
private void ExecuteCommandCancelCliente(object obj) { if (MessageBox.Show(string.Format("Cancelar Atendimento do Cliente {0}?", Atendimento.Cliente.NomeRazao), "Sim.Alerta!", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { Atendimento.Clear(); PJ.Clear(); PF.Clear(); Atendimento.Operador = AccountOn.Identificador; AreaTransferencia.Limpar(); Corpo = Visibility.Collapsed; Cabecalho = Visibility.Visible; } }
private void ExecuteCommandCancel(object obj) { Atendimento.Clear(); PJ.Clear(); PF.Clear(); Atendimento.Operador = AccountOn.Identificador; AreaTransferencia.Limpar(); Corpo = Visibility.Collapsed; Cabecalho = Visibility.Visible; if (ns.CanGoBack) { ns.GoBack(); } }
private void AsyncMostrarDados(string _cpf) { try { Task <mAmbulante> .Factory.StartNew(() => mdatacm.GetCAmbulante(_cpf)) .ContinueWith(task => { if (task.IsCompleted) { try { if (task.Result != null) { if (task.Result.Pessoa.Inscricao == _cpf || task.Result.Cadastro == _cpf) { Ambulante = task.Result; PF.Clear(); PJ.Clear(); PF.Add(task.Result.Pessoa); PJ.Add(task.Result.Empresa); DataLicencaView = Ambulante.TemLicenca; if (PJ[0].Inscricao == string.Empty) { SomentePF = true; TemEmpresa = Visibility.Visible; } else { SomentePF = false; TemEmpresa = Visibility.Collapsed; } if (task.Result.Empresa.Inscricao == string.Empty) { PJ.Clear(); } string[] _atv = task.Result.Atividades.Split(';'); foreach (string atv in _atv) { if (atv != string.Empty) { ListaAtividades.Add(new mCNAE() { CNAE = atv.Substring(0, 10), Ocupacao = atv.Remove(0, 13) }); } } if (task.Result.TipoInstalacoes.Contains("TENDA;")) { IsTenda = true; } if (task.Result.TipoInstalacoes.Contains("VEÍCULO;")) { IsVeiculo = true; } if (task.Result.TipoInstalacoes.Contains("CARRINHO;")) { IsCarrinho = true; } if (task.Result.TipoInstalacoes.Contains("TRAILER;")) { IsTrailer = true; } if (task.Result.TipoInstalacoes.Contains("OUTROS")) { IsOutros = true; string input = task.Result.TipoInstalacoes; string[] testing = Regex.Matches(input, @"\[(.+?)\]") .Cast <Match>() .Select(s => s.Groups[1].Value).ToArray(); GetOutros = testing[0]; } string[] _twk = task.Result.PeridoTrabalho.Split('/'); foreach (string wk in _twk) { if (wk != string.Empty) { string[] iwk = wk.Split('-'); ListarTimeWork.Add(new mPeriodos() { Dias = iwk[0].TrimEnd(), Periodos = iwk[1].TrimStart() }); } } ViewInfo = Visibility.Visible; } else { AsyncPessoa(AreaTransferencia.CPF); AsyncEmpresa(AreaTransferencia.CNPJ); } } } catch (Exception ex) { MessageBox.Show(string.Format("Erro '{0}' inesperado, informe o Suporte!", ex.Message), "Sim.Alerta!"); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } catch (Exception ex) { MessageBox.Show(ex.Message); } }