private void tsexcluir_Click(object sender, EventArgs e) { BLL.CidadesBLL cidadesBLL = new BLL.CidadesBLL(); Model.CidadeModel cidadesModel = new Model.CidadeModel(); if (txtcodigocidade.Text == String.Empty) { MessageBox.Show("Selecione a cidade que deseja excluir", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { cidadesModel.Codigo = Convert.ToInt32(txtcodigocidade.Text); if (MessageBox.Show("Tem certeza que deseja excluir a cidade codigo " + txtcodigocidade.Text + "?", "AVISO", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { cidadesBLL.ExcluirCidades(cidadesModel); MessageBox.Show("Cidade excluída com Sucesso", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); RecebeUltimaCidade(0); } else { tsCancelar.Enabled = false; } } }
private void txtcidadeconsulta_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Enter: BLL.CidadesBLL cidadesBLL = new BLL.CidadesBLL(); if (rbcodconsulta.Checked == true) { if (rbconsultanao.Checked == true) { dtgconsultacidades.DataSource = cidadesBLL.getCidadesDT("codigo", "N", txtcidadeconsulta.Text); } else { dtgconsultacidades.DataSource = cidadesBLL.getCidadesDT("codigo", "S", txtcidadeconsulta.Text); } if (rbconsultatodos.Checked == true) { dtgconsultacidades.DataSource = cidadesBLL.getCidadesDT("codigo", "T", txtcidadeconsulta.Text); } } if (rbnomeconsulta.Checked == true) { if (rbconsultatodos.Checked == true) { dtgconsultacidades.DataSource = cidadesBLL.getCidadesDT("cidade", "T", txtcidadeconsulta.Text); } if (rbconsultanao.Checked == true) { dtgconsultacidades.DataSource = cidadesBLL.getCidadesDT("cidade", "N", txtcidadeconsulta.Text); } if (rbconsultasim.Checked == true) { dtgconsultacidades.DataSource = cidadesBLL.getCidadesDT("cidade", "S", txtcidadeconsulta.Text); } } break; } }
private void salvarCidades() { BLL.CidadesBLL cidadesBLL = new BLL.CidadesBLL(); Model.CidadeModel cidadesModel = new Model.CidadeModel(); cidadesModel.Cidade = txtcidade.Text; if ((rbnao.Checked == false) && (rbsim.Checked == true)) { cidadesModel.Bloqueado = "S"; } if ((rbnao.Checked == true) && (rbsim.Checked == false)) { cidadesModel.Bloqueado = "N"; } cidadesModel.UF = mskuf.Text; if (Modificar == false) { cidadesBLL.IncluirCidades(cidadesModel); } else { cidadesModel.Codigo = Convert.ToInt32(txtcodigocidade.Text); cidadesBLL.AlterarCidades(cidadesModel); } MessageBox.Show("Dados Gravados com Sucesso", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); }