private void btnBuscaAlteracaoDelecao_Click(object sender, EventArgs e) { this.btnLimpa_Click(null, null); this._modelCliente = new mCliente(); frmBuscaCliente objCliente = new frmBuscaCliente(this._modelCliente, true); try { DialogResult resultado = objCliente.ShowDialog(); if (resultado == DialogResult.Cancel) { this._modelCliente = null; } else { this.PopulaTelaComModelAlteracao(); } } catch (Exception ex) { throw ex; } finally { objCliente = null; } }
private void btnCdCliente_Click(object sender, EventArgs e) { this._modelCliente = new mCliente(); frmBuscaCliente objFrmCliente = new frmBuscaCliente(this._modelCliente); try { DialogResult resultado = objFrmCliente.ShowDialog(); if (resultado == DialogResult.Cancel) { this._modelCliente = null; this.txtCdCliente.Text = string.Empty; } else { this.txtCdCliente.Text = this._modelCliente.NomeCliente; } } catch (Exception ex) { throw ex; } finally { objFrmCliente = null; } }
public List <mCliente> MontaRetorno(DataSet dataSet) { List <mCliente> ret; mCliente aux; try { ret = new List <mCliente>(); for (int i = 0; i < dataSet.Tables[0].Rows.Count - 1; i++) { aux = new mCliente { CodCliente = Convert.ToInt32(dataSet.Tables[0].Rows[i]["CODCLIENTE"]), RazSocial = dataSet.Tables[0].Rows[i]["RAZSOCIAL"].ToString() }; ret.Add(aux); aux = null; } return(ret); } catch (Exception ex) { throw ex; } }
private void btnLimpa_Click(object sender, EventArgs e) { base.LimpaDadosTela(this); this.rdbBrasil.Checked = true; this._modelCliente = null; base.Alteracao = false; }
public void ValidaDados(mCliente model) { if (model.CodPostal != null && model.Nom_pais == "Brasil") { UTIL.Validacoes.ValidaMasked(model.CodPostal, TCC.BUSINESS.UTIL.TipoMasked.cep); } if (model.Email != null) { string email = Convert.ToString(model.Email); UTIL.Validacoes.ValidaEmail(email); } if (model.Ddi != null) { string ddi = Convert.ToString(model.Ddi); UTIL.Validacoes.ValidaMasked(ddi, TCC.BUSINESS.UTIL.TipoMasked.ddd); } if (model.Ddd != null && model.Nom_pais == "Brasil") { string ddd = Convert.ToString(model.Ddd); UTIL.Validacoes.ValidaMasked(ddd, TCC.BUSINESS.UTIL.TipoMasked.ddd); } if (model.TelefoneCliente != null && model.Nom_pais == "Brasil") { string tel = Convert.ToString(model.TelefoneCliente); UTIL.Validacoes.ValidaMasked(tel, TCC.BUSINESS.UTIL.TipoMasked.tel); } if (model.Cpf != null) { UTIL.Validacoes.ValidaMasked(model.Cpf, TCC.BUSINESS.UTIL.TipoMasked.cpf); if (this.ExisteCpf(model.Cpf) == true) { throw new BUSINESS.Exceptions.Cliente.CPFClienteExistente(); } } if (model.Cnpj != null) { string cnpj = Convert.ToString(model.Cnpj); UTIL.Validacoes.ValidaMasked(cnpj, TCC.BUSINESS.UTIL.TipoMasked.cnpj); if (this.ExisteCnpj(cnpj) == true) { throw new BUSINESS.Exceptions.Cliente.CNPJClienteExistente(); } } if (model.IdentInter != null) { if (this.ExisteIdentInter(model.IdentInter) == true) { throw new BUSINESS.Exceptions.Cliente.IdentInterExistenteException(); } } }
public List <mCliente> Consulta(mCliente p_obj, Filtros objFiltro) { try { return(ObjDados.Consulta(p_obj, objFiltro)); } catch (Exception ex) { throw ex; } }
private void button1_Click(object sender, EventArgs e) { List <mCliente> ListaTabela; Filtros filtros; mCliente mCliente; try { filtros = new Filtros(); mCliente = new mCliente(); ListaTabela = ClienteController.Consulta(mCliente, filtros); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
public List <mCliente> Consulta(mCliente mCliente, Filtros ObjFiltros) { List <mCliente> retorno; string comando; try { comando = "SELECT TOP 10 * FROM TBCLI"; retorno = MontaRetorno(Dados.ExecutarSelect(comando)); return(retorno); } catch (Exception ex) { throw ex; } }
public frmBuscaCliente(mCliente modelCliente, bool alteracao) { InitializeComponent(); this._model = modelCliente; this._alteracao = alteracao; }
private void btnLimpa_Click(object sender, EventArgs e) { base.LimpaDadosTela(this); this._modelCliente = null; this._listaModelVendaProduto = null; }
public void Update(mCliente mCliente) { throw new System.NotImplementedException(); }
public frmBuscaCliente(mCliente modelCliente) { InitializeComponent(); this._model = modelCliente; this._alteracao = false; }
public void Insert(mCliente mCliente) { throw new System.NotImplementedException(); }
/// <summary> /// Pega os dados que estão na tela e popula o model /// </summary> /// <returns>Model populado</returns> private mCliente PegaDadosTela() { mCliente model = new mCliente(); rCliente regra = new rCliente(); try { if (base.Alteracao == true) { model.IdCliente = this._modelCliente.IdCliente; } else { model.IdCliente = regra.BuscaIdMaximo(); } model.NomeCliente = this.txtNome.Text; if (string.IsNullOrEmpty(this.txtDDI.Text) == true) { model.Ddi = null; } else { model.Ddi = this.txtDDI.Text; } if (string.IsNullOrEmpty(this.txtDDD.Text) == true) { model.Ddd = null; } else { model.Ddd = Convert.ToInt32(this.txtDDD.Text); } if (this.txtTelefone.Visible == true) { string tel = this.txtTelefone.Text.Replace("-", string.Empty); tel = tel.Replace(" ", string.Empty); if (string.IsNullOrEmpty(tel) == true) { model.TelefoneCliente = null; } else { model.TelefoneCliente = Convert.ToInt32(tel); } } else { if (string.IsNullOrEmpty(this.txtTelefoneInter.Text) == true) { model.TelefoneCliente = null; } else { model.TelefoneCliente = Convert.ToInt32(this.txtTelefoneInter.Text); } } model.NomeRua = this.txtRua.Text; if (string.IsNullOrEmpty(this.txtNumero.Text) == true) { model.NumeroEndereco = null; } else { model.NumeroEndereco = Convert.ToInt32(this.txtNumero.Text); } model.ComplementoEndereco = this.txtComplemento.Text; string cep = txtCep.Text.Replace("-", string.Empty); cep = cep.Replace(" ", string.Empty); if (this.txtCep.Visible == true) { model.CodPostal = cep; } else { model.CodPostal = this.txtCodPostal.Text; } if (string.IsNullOrEmpty(this.txtBairro.Text) == true) { model.Bairro = null; } else { model.Bairro = this.txtBairro.Text; } model.Cidade = this.txtCidade.Text; string cpf = this.txtCPF.Text.Replace("-", string.Empty); cpf = cpf.Replace(".", string.Empty); cpf = cpf.Replace(" ", string.Empty); if (string.IsNullOrEmpty(cpf) == true) { model.Cpf = null; } else { model.Cpf = cpf; } string cnpj = this.txtCnpj.Text.Replace("-", string.Empty); cnpj = cnpj.Replace(".", string.Empty); cnpj = cnpj.Replace("/", string.Empty); cnpj = cnpj.Replace(" ", string.Empty); if (string.IsNullOrEmpty(cnpj) == true) { model.Cnpj = null; } else { model.Cnpj = Convert.ToDecimal(cnpj); } model.DatAtl = DateTime.Now; model.FlgAtivo = true; if (string.IsNullOrEmpty(this.txtEmail.Text) == true) { model.Email = null; } else { model.Email = this.txtEmail.Text; } if (this.rdbBrasil.Checked == true) { model.Nom_pais = "Brasil"; model.Nom_est_inter = null; model.IdentInter = null; } else { model.Nom_pais = this.txtPais.Text; model.Nom_est_inter = this.txtEstado.Text; model.IdentInter = this.txtIdentInter.Text; } if (this.cboEstado.Enabled == true) { model.SlgEstado = this.cboEstado.GetItemText(this.cboEstado.SelectedItem); } else { model.SlgEstado = null; } return model; } catch (Exception ex) { throw ex; } finally { model = null; } }
/// <summary> /// Pega os dados que estão na tela e popula o model /// </summary> /// <returns>Model populado</returns> private mCliente PegaDadosTela() { mCliente model = new mCliente(); rCliente regra = new rCliente(); try { if (base.Alteracao == true) { model.IdCliente = this._modelCliente.IdCliente; } else { model.IdCliente = regra.BuscaIdMaximo(); } model.NomeCliente = this.txtNome.Text; if (string.IsNullOrEmpty(this.txtDDI.Text) == true) { model.Ddi = null; } else { model.Ddi = this.txtDDI.Text; } if (string.IsNullOrEmpty(this.txtDDD.Text) == true) { model.Ddd = null; } else { model.Ddd = Convert.ToInt32(this.txtDDD.Text); } if (this.txtTelefone.Visible == true) { string tel = this.txtTelefone.Text.Replace("-", string.Empty); tel = tel.Replace(" ", string.Empty); if (string.IsNullOrEmpty(tel) == true) { model.TelefoneCliente = null; } else { model.TelefoneCliente = Convert.ToInt32(tel); } } else { if (string.IsNullOrEmpty(this.txtTelefoneInter.Text) == true) { model.TelefoneCliente = null; } else { model.TelefoneCliente = Convert.ToInt32(this.txtTelefoneInter.Text); } } model.NomeRua = this.txtRua.Text; if (string.IsNullOrEmpty(this.txtNumero.Text) == true) { model.NumeroEndereco = null; } else { model.NumeroEndereco = Convert.ToInt32(this.txtNumero.Text); } model.ComplementoEndereco = this.txtComplemento.Text; string cep = txtCep.Text.Replace("-", string.Empty); cep = cep.Replace(" ", string.Empty); if (this.txtCep.Visible == true) { model.CodPostal = cep; } else { model.CodPostal = this.txtCodPostal.Text; } if (string.IsNullOrEmpty(this.txtBairro.Text) == true) { model.Bairro = null; } else { model.Bairro = this.txtBairro.Text; } model.Cidade = this.txtCidade.Text; string cpf = this.txtCPF.Text.Replace("-", string.Empty); cpf = cpf.Replace(".", string.Empty); cpf = cpf.Replace(" ", string.Empty); if (string.IsNullOrEmpty(cpf) == true) { model.Cpf = null; } else { model.Cpf = cpf; } string cnpj = this.txtCnpj.Text.Replace("-", string.Empty); cnpj = cnpj.Replace(".", string.Empty); cnpj = cnpj.Replace("/", string.Empty); cnpj = cnpj.Replace(" ", string.Empty); if (string.IsNullOrEmpty(cnpj) == true) { model.Cnpj = null; } else { model.Cnpj = Convert.ToDecimal(cnpj); } model.DatAtl = DateTime.Now; model.FlgAtivo = true; if (string.IsNullOrEmpty(this.txtEmail.Text) == true) { model.Email = null; } else { model.Email = this.txtEmail.Text; } if (this.rdbBrasil.Checked == true) { model.Nom_pais = "Brasil"; model.Nom_est_inter = null; model.IdentInter = null; } else { model.Nom_pais = this.txtPais.Text; model.Nom_est_inter = this.txtEstado.Text; model.IdentInter = this.txtIdentInter.Text; } if (this.cboEstado.Enabled == true) { model.SlgEstado = this.cboEstado.GetItemText(this.cboEstado.SelectedItem); } else { model.SlgEstado = null; } return(model); } catch (Exception ex) { throw ex; } finally { model = null; } }
private void AsyncMostrarCliente(string cpf) { if (cpf == string.Empty) { ViewGetCPF = Visibility.Visible; } Task <mPF_Ext> .Factory.StartNew(() => mdata.ExistPessoaFisica(cpf)) .ContinueWith(task => { if (task.IsCompleted) { PF = new mCliente(); PF.Inscricao = task.Result.CPF; PF.NomeRazao = task.Result.Nome; PF.Telefones = task.Result.Telefones; PF.Email = task.Result.Email; ListaPJ.Clear(); if (task.Result.ColecaoVinculos.Count < 1) { SomentePF = true; } 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 = new mCliente(); PJ.Inscricao = task_two.Result.CNPJ; PJ.NomeRazao = task_two.Result.RazaoSocial; PJ.Telefones = task_two.Result.Telefones; PJ.Email = task_two.Result.Email; } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }