private void BtAdd_Click(object sender, EventArgs e) { inputBox iBox = new inputBox(); bool bAllow = gtiCore.GetBinaryAccess((int)TAcesso.CadastroPais_Alterar); if (!bAllow) { MessageBox.Show("Acesso não permitido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } String sCod = iBox.Show("", "Informação", "Digite o nome do país.", 40); if (!string.IsNullOrEmpty(sCod)) { Endereco_bll endereco_class = new Endereco_bll(_connection); GTI_Models.Models.Pais reg = new GTI_Models.Models.Pais { Nome_pais = sCod.ToUpper() }; Exception ex = endereco_class.Incluir_Pais(reg); if (ex != null) { ErrorBox eBox = new ErrorBox("Atenção", "País já cadastrado.", ex); eBox.ShowDialog(); } else { Carrega_Lista(); } } }
private void LstLogr_KeyDown(object sender, KeyEventArgs e) { if (LogradouroList.SelectedValue == null) { return; } Endereco_bll enderecoRepository = new Endereco_bll(_connection); if (e.KeyCode == Keys.Escape) { LogradouroList.Visible = false; LogradouroText.Focus(); return; } if (e.KeyCode == Keys.Enter) { LogradouroText.Text = LogradouroList.Text; LogradouroText.Tag = LogradouroList.SelectedValue.ToString(); LogradouroList.Visible = false; CarregaCep(); NumeroList.Focus(); } }
public JsonResult Incluir_Cidade(string uf, string cidade) { cidade = cidade.ToUpper(); Endereco_bll enderecoRepository = new Endereco_bll(_connection); bool existeCidade = enderecoRepository.Existe_Cidade(uf, cidade); if (existeCidade) { var result = new { Cidade_Codigo = 0, Success = "False", Msg = "Cidade já cadastrada!" }; return(new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } Cidade reg = new Cidade() { Siglauf = uf, Desccidade = cidade }; int _codigo = enderecoRepository.Incluir_cidade(reg); var result2 = new { Cidade_Codigo = (short)_codigo, Success = "True" }; return(new JsonResult { Data = result2, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public static Cep Busca_CepDB(int Cep) { var cepObj = new Cep(); Endereco_bll enderecoRepository = new Endereco_bll("GTiconnection"); Cepdb _cep = enderecoRepository.Retorna_CepDB(Cep); if (_cep == null) { cepObj.Endereco = ""; cepObj.Bairro = ""; cepObj.CEP = ""; cepObj.Cidade = ""; cepObj.Estado = ""; } else { cepObj.Endereco = _cep.Logradouro; cepObj.Bairro = enderecoRepository.Retorna_Bairro(_cep.Uf, _cep.Cidadecodigo, _cep.Bairrocodigo); cepObj.CEP = _cep.Cep; cepObj.Cidade = enderecoRepository.Retorna_Cidade(_cep.Uf, _cep.Cidadecodigo); cepObj.Estado = _cep.Uf; } return(cepObj); }
private void TxtLogradouro_KeyDown(object sender, KeyEventArgs e) { if (Convert.ToInt32(CidadeList.SelectedValue) != 413) { CepMask.Text = ""; return; } if (!string.IsNullOrEmpty(LogradouroText.Text) && e.KeyCode == Keys.Enter) { Endereco_bll clsImovel = new Endereco_bll(_connection); List <Logradouro> Listalogradouro = clsImovel.Lista_Logradouro(LogradouroText.Text); LogradouroList.DataSource = Listalogradouro; LogradouroList.DisplayMember = "endereco"; LogradouroList.ValueMember = "codlogradouro"; if (LogradouroList.Items.Count > 0) { LogradouroList.Visible = true; LogradouroList.BringToFront(); LogradouroList.DroppedDown = true; LogradouroList.Focus(); } else { MessageBox.Show("Logradouro não localizado.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); LogradouroText.Focus(); } } else { LogradouroText.Tag = ""; } }
public JsonResult Incluir_Bairro(string uf, string cidade, string bairro) { short _cidade = Convert.ToInt16(cidade); bairro = bairro.ToUpper(); Endereco_bll enderecoRepository = new Endereco_bll(_connection); bool existeBairro = enderecoRepository.Existe_Bairro(uf, _cidade, bairro); if (existeBairro) { var result = new { Bairro_Codigo = 0, Success = "False", Msg = "Bairro já cadastrado!" }; return(new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } Bairro reg = new Bairro() { Siglauf = uf, Codcidade = _cidade, Descbairro = bairro }; int _codigo = enderecoRepository.Incluir_bairro(reg); var result2 = new { Bairro_Codigo = (short)_codigo, Success = "True" }; return(new JsonResult { Data = result2, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
private void CmbUF_SelectedIndexChanged(object sender, EventArgs e) { BairroListBox.DataSource = null; if (UFCombo.SelectedIndex == -1) { return; } gtiCore.Ocupado(this); Uf Estado = (Uf)UFCombo.SelectedItem; String sUF = Estado.Siglauf; Endereco_bll cidade_class = new Endereco_bll(_connection); List <Cidade> lista = cidade_class.Lista_Cidade(sUF); List <CustomListBoxItem> myItems = new List <CustomListBoxItem>(); foreach (Cidade item in lista) { myItems.Add(new CustomListBoxItem(item.Desccidade, item.Codcidade)); } CidadeCombo.DisplayMember = "_name"; CidadeCombo.ValueMember = "_value"; CidadeCombo.DataSource = myItems; if (UFCombo.SelectedIndex > 0 && UFCombo.SelectedValue.ToString() == "SP") { CidadeCombo.SelectedValue = 413; } gtiCore.Liberado(this); }
private void BtDel_Click(object sender, EventArgs e) { if (lstMain.SelectedItem == null) { return; } bool bAllow = gtiCore.GetBinaryAccess((int)TAcesso.CadastroPais_Alterar); if (!bAllow) { MessageBox.Show("Acesso não permitido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MessageBox.Show("Excluir este país?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Endereco_bll endereco_class = new Endereco_bll(_connection); GTI_Models.Models.Pais reg = new GTI_Models.Models.Pais { Id_pais = Convert.ToInt16(lstMain.SelectedValue.ToString()) }; Exception ex = endereco_class.Excluir_Pais(reg); if (ex != null) { ErrorBox eBox = new ErrorBox("Atenção", ex.Message, ex); eBox.ShowDialog(); } else { Carrega_Lista(); } } }
public ActionResult Cidade_Edit() { Endereco_bll enderecoRepository = new Endereco_bll(_connection); List <Uf> listaUf = enderecoRepository.Lista_UF(); ViewBag.ListaUF = new SelectList(listaUf, "siglauf", "descuf"); return(View()); }
private void Carrega_Pais() { Endereco_bll clsCidade = new Endereco_bll(_connection); PaisList.DataSource = clsCidade.Lista_Pais(); PaisList.DisplayMember = "nome_pais"; PaisList.ValueMember = "id_pais"; }
private void Carrega_UF() { Endereco_bll clsCidade = new Endereco_bll(_connection); UFList.DataSource = clsCidade.Lista_UF(); UFList.DisplayMember = "descuf"; UFList.ValueMember = "siglauf"; }
public JsonResult Lista_Cidade(string uf) { Endereco_bll enderecoRepository = new Endereco_bll(_connection); List <Cidade> Lista = enderecoRepository.Lista_Cidade(uf); return(new JsonResult { Data = Lista, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
private void Bairro_Load(object sender, EventArgs e) { Endereco_bll cidade_class = new Endereco_bll(_connection); UFCombo.DataSource = cidade_class.Lista_UF(); UFCombo.DisplayMember = "siglauf"; UFCombo.ValueMember = "siglauf"; UFCombo.SelectedValue = "SP"; }
public JsonResult Lista_Endereco(string search) { Endereco_bll enderecoRepository = new Endereco_bll(_connection); List <Logradouro> Lista_Search = enderecoRepository.Lista_Logradouro(search); return(new JsonResult { Data = Lista_Search, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
private void Carrega_Lista() { gtiCore.Ocupado(this); Endereco_bll endereco_class = new Endereco_bll(_connection); List <GTI_Models.Models.Pais> lista = endereco_class.Lista_Pais(); lstMain.DataSource = lista; lstMain.DisplayMember = "Nome_pais"; lstMain.ValueMember = "Id_pais"; gtiCore.Liberado(this); }
private void CarregaCep() { if (Convert.ToInt32(LogradouroText.Tag.ToString()) == 0) { LogradouroText.Tag = "0"; } if (UFList.SelectedValue.ToString() == "SP" && Convert.ToInt32(CidadeList.SelectedValue) == 413) { Endereco_bll clsEndereco = new Endereco_bll(_connection); int nCep = clsEndereco.RetornaCep(Convert.ToInt32(LogradouroText.Tag.ToString()), NumeroList.Text == ""?(short)0: Convert.ToInt16(NumeroList.Text)); CepMask.Text = nCep.ToString("00000-000"); } }
public JsonResult Lista_Bairro(string uf, string cidade) { if (cidade == "") { return(null); } int _cidade = Convert.ToInt32(cidade); Endereco_bll enderecoRepository = new Endereco_bll(_connection); List <Bairro> Lista = enderecoRepository.Lista_Bairro(uf, _cidade); return(new JsonResult { Data = Lista, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
private void Carrega_UF() { Endereco_bll EnderecoRepository = new Endereco_bll(_connection); List <GTI_Models.Models.Uf> lista = EnderecoRepository.Lista_UF(); List <CustomListBoxItem6> myItems = new List <CustomListBoxItem6>(); myItems.Add(new CustomListBoxItem6(" ", "EX")); foreach (GTI_Models.Models.Uf item in lista) { myItems.Add(new CustomListBoxItem6(item.Descuf, item.Siglauf)); } UFList.DisplayMember = "_name"; UFList.ValueMember = "_value"; UFList.DataSource = myItems; }
private void Carrega_Bairro() { if (CidadeList.SelectedIndex > -1) { Endereco_bll EnderecoRepository = new Endereco_bll(_connection); List <GTI_Models.Models.Bairro> lista = EnderecoRepository.Lista_Bairro(UFList.SelectedValue.ToString(), Convert.ToInt32(CidadeList.SelectedValue)); List <CustomListBoxItem> myItems = new List <CustomListBoxItem>(); foreach (GTI_Models.Models.Bairro item in lista) { myItems.Add(new CustomListBoxItem(item.Descbairro, item.Codbairro)); } BairroList.DisplayMember = "_name"; BairroList.ValueMember = "_value"; BairroList.DataSource = myItems; } }
private void BtEdit_Click(object sender, EventArgs e) { if (BairroListBox.SelectedItem == null) { return; } bool bAllowLocal = gtiCore.GetBinaryAccess((int)TAcesso.CadastroBairro_Alterar_Local); bool bAllowFora = gtiCore.GetBinaryAccess((int)TAcesso.CadastroBairro_Alterar_Fora); if (!bAllowLocal && !bAllowFora) { MessageBox.Show("Acesso não permitido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (UFCombo.SelectedValue.ToString() == "SP" && Convert.ToInt32(CidadeCombo.SelectedValue) == 413 && !bAllowLocal) { MessageBox.Show("Acesso não permitido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } inputBox iBox = new inputBox(); String sCod = iBox.Show(BairroListBox.Text, "Informação", "Digite o nome do bairro.", 40); if (!string.IsNullOrEmpty(sCod)) { Endereco_bll bairro_class = new Endereco_bll(_connection); GTI_Models.Models.Bairro reg = new GTI_Models.Models.Bairro { Siglauf = UFCombo.SelectedValue.ToString(), Codcidade = Convert.ToInt16(CidadeCombo.SelectedValue.ToString()), Codbairro = Convert.ToInt16(BairroListBox.SelectedValue.ToString()), Descbairro = sCod.ToUpper() }; Exception ex = bairro_class.Alterar_Bairro(reg); if (ex != null) { ErrorBox eBox = new ErrorBox("Atenção", "Bairro já cadastrado.", ex); eBox.ShowDialog(); } else { CmbCidade_SelectedIndexChanged(sender, e); } } }
private void BtAdd_Click(object sender, EventArgs e) { inputBox iBox = new inputBox(); bool bAllowLocal = gtiCore.GetBinaryAccess((int)TAcesso.CadastroBairro_Alterar_Local); bool bAllowFora = gtiCore.GetBinaryAccess((int)TAcesso.CadastroBairro_Alterar_Fora); if (!bAllowLocal && !bAllowFora) { MessageBox.Show("Acesso não permitido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (UFCombo.SelectedValue.ToString() == "SP" && Convert.ToInt32(CidadeCombo.SelectedValue) == 413 && !bAllowLocal) { MessageBox.Show("Acesso não permitido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string _nomeBairro = iBox.Show("", "Informação", "Digite o nome do bairro.", 40); if (!string.IsNullOrEmpty(_nomeBairro)) { _nomeBairro = _nomeBairro.ToUpper(); string _uf = UFCombo.SelectedValue.ToString(); short _cidade = Convert.ToInt16(CidadeCombo.SelectedValue.ToString()); Endereco_bll enderecoRepository = new Endereco_bll(_connection); bool _existe = enderecoRepository.Existe_Bairro(_uf, _cidade, _nomeBairro); if (_existe) { MessageBox.Show("Bairro já cadastrado.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { GTI_Models.Models.Bairro reg = new GTI_Models.Models.Bairro { Siglauf = _uf, Codcidade = _cidade, Descbairro = _nomeBairro.ToUpper() }; int _cod = enderecoRepository.Incluir_bairro(reg); CmbCidade_SelectedIndexChanged(sender, e); } } }
private void BtDel_Click(object sender, EventArgs e) { if (BairroListBox.SelectedItem == null) { return; } bool bAllowLocal = gtiCore.GetBinaryAccess((int)TAcesso.CadastroBairro_Alterar_Local); bool bAllowFora = gtiCore.GetBinaryAccess((int)TAcesso.CadastroBairro_Alterar_Fora); if (!bAllowLocal && !bAllowFora) { MessageBox.Show("Acesso não permitido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (UFCombo.SelectedValue.ToString() == "SP" && Convert.ToInt32(CidadeCombo.SelectedValue) == 413 && !bAllowLocal) { MessageBox.Show("Acesso não permitido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MessageBox.Show("Excluir este bairro?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Endereco_bll bairro_class = new Endereco_bll(_connection); GTI_Models.Models.Bairro reg = new GTI_Models.Models.Bairro { Siglauf = UFCombo.SelectedValue.ToString(), Codcidade = Convert.ToInt16(CidadeCombo.SelectedValue.ToString()), Codbairro = Convert.ToInt16(BairroListBox.SelectedValue.ToString()) }; Exception ex = bairro_class.Excluir_Bairro(reg); if (ex != null) { ErrorBox eBox = new ErrorBox("Atenção", ex.Message, ex); eBox.ShowDialog(); } else { CmbCidade_SelectedIndexChanged(sender, e); } } }
private void CmbUF_SelectedIndexChanged(object sender, EventArgs e) { if (UFList.SelectedIndex > -1) { Endereco_bll clsCidade = new Endereco_bll(_connection); List <Cidade> lista = clsCidade.Lista_Cidade(UFList.SelectedValue.ToString()); List <CustomListBoxItem> myItems = new List <CustomListBoxItem>(); foreach (Cidade item in lista) { myItems.Add(new CustomListBoxItem(item.Desccidade, item.Codcidade)); } CidadeList.DisplayMember = "_name"; CidadeList.ValueMember = "_value"; CidadeList.DataSource = myItems; if (UFList.SelectedIndex > 0 && UFList.SelectedValue.ToString() == "SP") { CidadeList.SelectedValue = 413; } } }
private void CmbCidade_SelectedIndexChanged(object sender, EventArgs e) { BairroListBox.DataSource = null; if (CidadeCombo.SelectedIndex == -1) { return; } gtiCore.Ocupado(this); String sUF = UFCombo.SelectedValue.ToString(); CustomListBoxItem city = (CustomListBoxItem)CidadeCombo.SelectedItem; Int32 nCodCidade = city._value; Endereco_bll bairro_class = new Endereco_bll(_connection); List <GTI_Models.Models.Bairro> lista = bairro_class.Lista_Bairro(sUF, nCodCidade); BairroListBox.DataSource = lista; BairroListBox.DisplayMember = "descbairro"; BairroListBox.ValueMember = "codbairro"; gtiCore.Liberado(this); }
public JsonResult Alterar_Cidade(string uf, string cidade, string novo_nome) { short _cidade = Convert.ToInt16(cidade); novo_nome = novo_nome.ToUpper(); Endereco_bll enderecoRepository = new Endereco_bll(_connection); Cidade reg = new Cidade() { Siglauf = uf, Codcidade = _cidade, Desccidade = novo_nome }; Exception ex = enderecoRepository.Alterar_Cidade(reg); var result2 = new { Success = "True" }; return(new JsonResult { Data = result2, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
private void CarregaCep() { if (Convert.ToInt32(LogradouroText.Tag.ToString()) == 0) { LogradouroText.Tag = "0"; } if (UFList.SelectedValue.ToString() == "SP" && Convert.ToInt32(CidadeList.SelectedValue) == 413) { Endereco_bll enderecoRepository = new Endereco_bll(_connection); int nCep = enderecoRepository.RetornaCep(Convert.ToInt32(LogradouroText.Tag.ToString()), NumeroList.Text == ""?(short)0: Convert.ToInt16(NumeroList.Text)); CepMask.Text = nCep.ToString("00000-000"); short _num = 0; if (gtiCore.IsNumeric(NumeroList.Text)) { _num = Convert.ToInt16(NumeroList.Text); } GTI_Models.Models.Bairro _bairro = enderecoRepository.RetornaLogradouroBairro(Convert.ToInt32(LogradouroText.Tag.ToString()), _num); BairroText.Text = _bairro.Descbairro; BairroText.Tag = _bairro.Codbairro.ToString(); } }
private void BtEdit_Click(object sender, EventArgs e) { if (lstMain.SelectedItem == null) { return; } bool bAllow = gtiCore.GetBinaryAccess((int)TAcesso.CadastroPais_Alterar); if (!bAllow) { MessageBox.Show("Acesso não permitido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } inputBox iBox = new inputBox(); String sCod = iBox.Show(lstMain.Text, "Informação", "Digite o nome do país.", 50); if (!string.IsNullOrEmpty(sCod)) { Endereco_bll endereco_class = new Endereco_bll(_connection); GTI_Models.Models.Pais reg = new GTI_Models.Models.Pais { Id_pais = Convert.ToInt16(lstMain.SelectedValue.ToString()), Nome_pais = sCod.ToUpper() }; Exception ex = endereco_class.Alterar_Pais(reg); if (ex != null) { ErrorBox eBox = new ErrorBox("Atenção", "País já cadastrado.", ex); eBox.ShowDialog(); } else { Carrega_Lista(); } } }
private List <Redesim_licenciamentoStruct> Insert_Licenciamento(List <Redesim_licenciamentoStruct> _listaLicenciamento, string _guid) { Redesim_bll redesimRepository = new Redesim_bll(_connection); Endereco_bll enderecoRepository = new Endereco_bll(_connection); Empresa_bll empresaRepository = new Empresa_bll(_connection); Imovel_bll imovelRepository = new Imovel_bll(_connection); int _pos = 0; foreach (Redesim_licenciamentoStruct item in _listaLicenciamento) { bool _existe = redesimRepository.Existe_Licenciamento(item.Protocolo, Convert.ToDateTime(item.DataSolicitacao)); if (!_existe) { string _cnae_principal = ""; int _size = item.Cnae.Length; if (_size > 0) { string[] _listaCnae = new string[_size]; int _indexCnae = 0; foreach (string ev in item.Cnae) { if (_indexCnae == 0) { _cnae_principal = ev; } else { if (ev.Length == 7) { _listaCnae[_indexCnae] = ev; } } _indexCnae++; } redesimRepository.Incluir_Cnae(item.Protocolo, _listaCnae); } Redesim_licenciamento reg = new Redesim_licenciamento() { Arquivo = _guid, Protocolo = item.Protocolo, Data_Solicitacao = Convert.ToDateTime(item.DataSolicitacao), Situacao_Solicitacao = Convert.ToInt32(item.SituacaoSolicitacao), Data_Validade = Functions.IsDate(item.DataValidade) ? Convert.ToDateTime(item.DataValidade) : DateTime.MinValue, Mei = item.PorteEmpresaMei == "Não" ? false : true, Cnpj = item.Cnpj.Contains("E") ? "" : item.Cnpj, Razao_Social = item.RazaoSocial.ToUpper(), Cep = item.Cep == ""?0 : Convert.ToInt32(item.Cep), Complemento = Functions.TrimEx(item.Complemento), Cnae_Principal = _cnae_principal }; Exception ex = redesimRepository.Incluir_Licenciamento(reg); } _listaLicenciamento[_pos].Duplicado = _existe; _listaLicenciamento[_pos].Arquivo = _guid; //Master _existe = redesimRepository.Existe_Master(item.Protocolo); if (!_existe) { Redesim_master _master = new Redesim_master() { Protocolo = item.Protocolo, Data_licenca = Convert.ToDateTime(item.DataSolicitacao), Cnpj = item.Cnpj.Contains("E")?"":item.Cnpj, Razao_Social = item.RazaoSocial.ToUpper(), Cep = item.Cep, Complemento = Functions.TrimEx(item.Complemento), Cnae_Principal = item.Cnae[0], Data_Validade = Functions.IsDate(item.DataValidade) ? Convert.ToDateTime(item.DataValidade) : DateTime.MinValue, }; string _num = Functions.RetornaNumero(item.Numero); if (_num == "") { _master.Numero = 0; } else { _master.Numero = Convert.ToInt32(_num); } item.Cep = item.Cep == "" ? "0" : item.Cep; LogradouroStruct _log = enderecoRepository.Retorna_Logradouro_Cep(Convert.ToInt32(item.Cep)); int _logradouro = 0; if (_log != null && _log.CodLogradouro != null) { _logradouro = (int)_log.CodLogradouro; } _master.Logradouro = _logradouro; if (_master.Cnpj != "") { int _inscricao = empresaRepository.ExisteEmpresaCnpj(_master.Cnpj); if (_inscricao > 0) { _master.Inscricao = _inscricao; _master.Situacao = "Cadastrada"; } } _master.Numero_Imovel = imovelRepository.Retorna_Codigo_Endereco(_master.Logradouro, _master.Numero); Exception ex = redesimRepository.Incluir_Master(_master); } _existe = redesimRepository.Existe_Registro(item.Protocolo); if (_existe) { Redesim_Registro _registro = redesimRepository.Retorna_Registro(item.Protocolo); Exception ex = redesimRepository.Atualizar_Master_Registro(_registro); } _existe = redesimRepository.Existe_Viabilidade(item.Protocolo); if (_existe) { Redesim_Viabilidade _via = redesimRepository.Retorna_Viabilidade(item.Protocolo); Exception ex = redesimRepository.Atualizar_Master_Viabilidade(_via); } _pos++; } return(_listaLicenciamento); }
private void Carrega_Endereco(GTI_Models.Models.Endereco reg) { Carrega_Pais(); Carrega_UF(); if (reg.Id_pais > 0) { PaisList.SelectedValue = reg.Id_pais; } if (!string.IsNullOrWhiteSpace(reg.Sigla_uf)) { UFList.SelectedValue = reg.Sigla_uf; CmbUF_SelectedIndexChanged(null, null); } if (reg.Id_cidade > 0) { CidadeList.SelectedValue = Convert.ToInt32(reg.Id_cidade); CmbCidade_SelectedIndexChanged(null, null); } Endereco_bll enderecoRepository = new Endereco_bll(_connection); if (reg.Id_logradouro > 0) { LogradouroText.Text = enderecoRepository.Retorna_Logradouro(reg.Id_logradouro); } else { LogradouroText.Text = reg.Nome_logradouro; } LogradouroText.Tag = reg.Id_logradouro; ComplementoText.Text = reg.Complemento; EmailText.Text = reg.Email; NumeroList.Text = reg.Numero_imovel > 0 ? reg.Numero_imovel.ToString() : ""; if (reg.Id_bairro > 0) { if (reg.Sigla_uf == "SP" && reg.Id_cidade == 413) { //GTI_Models.Models.Bairro _bairro = enderecoRepository.RetornaLogradouroBairro(reg.Id_logradouro, (short)reg.Numero_imovel); //BairroText.Text = _bairro.Descbairro; //BairroText.Tag = _bairro.Codbairro.ToString(); } else { BairroText.Text = enderecoRepository.Retorna_Bairro(reg.Sigla_uf, reg.Id_cidade, reg.Id_bairro); BairroText.Tag = reg.Id_bairro.ToString(); } BairroList.SelectedValue = reg.Id_bairro; } if (reg.Cep > 0) { CepMask.Text = reg.Cep.ToString(); } else { CarregaCep(); } TelefoneText.Text = reg.Telefone ?? ""; if (reg.TemFone == null) { TemFoneCheck.CheckState = CheckState.Unchecked; } else { if (reg.TemFone == true) { TemFoneCheck.CheckState = CheckState.Checked; } } if (reg.WhatsApp == null) { WhatsAppCheck.CheckState = CheckState.Unchecked; } else { if (reg.WhatsApp == true) { WhatsAppCheck.CheckState = CheckState.Checked; } } BairroList.Focus(); }
public ActionResult Cidadao_vw() { if (Session["hashid"] == null) { return(RedirectToAction("Login", "Home")); } Cidadao_bll cidadaoRepository = new Cidadao_bll(_connection); Endereco_bll enderecoRepository = new Endereco_bll(_connection); List <Profissao> Lista = cidadaoRepository.Lista_Profissao(); ViewBag.Lista_Profissao = new SelectList(Lista, "Codigo", "Nome"); var _cod = TempData["cod"]; int _codigo = 0; if (_cod == null) { return(RedirectToAction("Cidadao_chkedt")); } else { _codigo = Convert.ToInt32(_cod); } if (_codigo == 0) { return(RedirectToAction("Cidadao_chkedt")); } CidadaoStruct _cid = cidadaoRepository.Dados_Cidadao(_codigo); CidadaoViewModel model = new CidadaoViewModel() { Codigo = _codigo, CpfCnpj = string.IsNullOrEmpty(_cid.Cnpj) ? Functions.FormatarCpfCnpj(_cid.Cpf) : Functions.FormatarCpfCnpj(_cid.Cnpj), Nome = _cid.Nome, Data_Nascto = _cid.DataNascto == null ? "" : Convert.ToDateTime(_cid.DataNascto).ToString("dd/MM/yyyy"), Rg_Numero = _cid.Rg ?? "", Rg_Orgao = _cid.Orgao ?? "", Cnh_Numero = _cid.Cnh ?? "", Cnh_Orgao = _cid.Orgaocnh ?? "", Profissao_Codigo = _cid.CodigoProfissao == null ? 0 : (int)_cid.CodigoProfissao, EnderecoR = new EnderecoStruct() { Cep = _cid.CepR == null ? "" : _cid.CepR.ToString(), Numero = _cid.NumeroR, Complemento = _cid.ComplementoR ?? "", NomeBairro = _cid.NomeBairroR ?? "", NomeCidade = _cid.NomeCidadeR ?? "", UF = _cid.UfR, Telefone = _cid.TelefoneR ?? "", Email = _cid.EmailR ?? "" }, EnderecoC = new EnderecoStruct() { Cep = _cid.CepC == null ? "" : _cid.CepC.ToString(), Numero = _cid.NumeroC, Complemento = _cid.ComplementoC ?? "", NomeBairro = _cid.NomeBairroC ?? "", NomeCidade = _cid.NomeCidadeC ?? "", UF = _cid.UfC, Telefone = _cid.TelefoneC ?? "", Email = _cid.EmailC ?? "" }, }; if (model.Profissao_Codigo > 0) { model.Profissao_Nome = cidadaoRepository.Retorna_Profissao_Nome(model.Profissao_Codigo); } List <Logradouro> Lista_LogradouroR = new List <Logradouro>(); List <Logradouro> Lista_LogradouroC = new List <Logradouro>(); ViewBag.LogradouroR = new SelectList(Lista_LogradouroR, "Codlogradouro", "Endereco"); ViewBag.LogradouroC = new SelectList(Lista_LogradouroC, "Codlogradouro", "Endereco"); int _cepR = string.IsNullOrEmpty(model.EnderecoR.Cep) ? 0 : Convert.ToInt32(model.EnderecoR.Cep); int _cepC = string.IsNullOrEmpty(model.EnderecoC.Cep) ? 0 : Convert.ToInt32(model.EnderecoC.Cep); if (_cepR > 0) { List <string> Lista_Tmp = enderecoRepository.Retorna_CepDB_Logradouro(_cepR); int s = 1; foreach (string item in Lista_Tmp) { Lista_LogradouroR.Add(new Logradouro() { Codlogradouro = s, Endereco = item.ToUpper() }); s++; } List <Cepdb> cepdbR = enderecoRepository.Retorna_CepDB_Logradouro_Codigo(_cepR, _cid.CodigoBairroR == null ? 0 : (int)_cid.CodigoBairroR); if (cepdbR.Count > 0) { model.EnderecoR.Endereco = cepdbR[0].Logradouro.ToUpper(); } } if (_cepC > 0) { List <string> Lista_Tmp = enderecoRepository.Retorna_CepDB_Logradouro(_cepC); int s = 1; foreach (string item in Lista_Tmp) { Lista_LogradouroC.Add(new Logradouro() { Codlogradouro = s, Endereco = item.ToUpper() }); s++; } List <Cepdb> cepdbC = enderecoRepository.Retorna_CepDB_Logradouro_Codigo(_cepC, _cid.CodigoBairroC == null ? 0 : (int)_cid.CodigoBairroC); if (cepdbC.Count > 0) { model.EnderecoC.Endereco = cepdbC[0].Logradouro.ToUpper(); } } return(View(model)); }