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); } } }
public JsonResult Alterar_Bairro(string uf, string cidade, string bairro, string novo_nome) { short _cidade = Convert.ToInt16(cidade); short _bairro = Convert.ToInt16(bairro); novo_nome = novo_nome.ToUpper(); Endereco_bll enderecoRepository = new Endereco_bll(_connection); Bairro reg = new Bairro() { Siglauf = uf, Codcidade = _cidade, Codbairro = _bairro, Descbairro = novo_nome }; Exception ex = enderecoRepository.Alterar_Bairro(reg); var result2 = new { Success = "True" }; return(new JsonResult { Data = result2, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }