//============================================== private void frmCompleto_Load(object sender, EventArgs e) { //txtCod.Text = "1"; PreencherUF(); txtNome.Focus(); if (txtCod.Text != "") { clnAgenda ObjClnAgenda = new clnAgenda(); ObjClnAgenda.Cod = Convert.ToInt16(txtCod.Text); OracleDataReader ObjDrDados; ObjDrDados = ObjClnAgenda.ListarUsuario(); if (ObjDrDados.Read()) { txtNome.Text = ObjDrDados["nome"].ToString(); txtMaskTel.Text = ObjDrDados["tel"].ToString(); txtMaskCep.Text = ObjDrDados["cep"].ToString(); txtEnd.Text = ObjDrDados["endereco"].ToString(); cboUF.Text = ObjDrDados["UF"].ToString(); txtNr.Text = ObjDrDados["nr"].ToString(); txtBairro.Text = ObjDrDados["bairro"].ToString(); txtCidade.Text = ObjDrDados["cidade"].ToString(); } } txtNome.Focus(); }
public void CarregaDataGrid() { clnAgenda ObjAgenda = new clnAgenda(); dgv.DataSource = ObjAgenda.Listar(txtDescricao.Text).Tables[0]; dgv.Columns[0].HeaderText = ("Código"); dgv.Columns[1].HeaderText = ("Cliente"); dgv.Columns[2].HeaderText = ("Contatos"); dgv.AutoResizeColumns(); if (dgv.RowCount == 0) { btnRelatorio.Enabled = false; btnConsultar.Enabled = false; btnalterar.Enabled = false; btnexcluir.Enabled = false; MessageBox.Show("NÃO FORAM ENCONTRADOS DADOS COM A INFORMAÇÃO: " + txtDescricao.Text, "Verificar", MessageBoxButtons.OK, MessageBoxIcon.Information); dgv.DataSource = null; txtDescricao.Text = ""; txtDescricao.Focus(); } else { btnRelatorio.Enabled = true; } btnConsultar.Enabled = true; btnalterar.Enabled = true; btnexcluir.Enabled = true; }
//============================================================ public void PreencherUF() { clnAgenda objAgenda = new clnAgenda(); cboUF.DataSource = objAgenda.PreencherUF().Tables[0]; cboUF.ValueMember = "UF"; cboUF.DisplayMember = "UF"; cboUF.SelectedIndex = -1; }
private void btnexcluir_Click(object sender, EventArgs e) { DialogResult resultado = MessageBox.Show("Deseja excluir o registro? " + Convert.ToString(dgv.CurrentRow.Cells[0].Value), "E X C L U S Ã O", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (DialogResult.Yes == resultado) { clnAgenda ObjAgenda = new clnAgenda(); ObjAgenda.Cod = Convert.ToInt32(dgv.CurrentRow.Cells[0].Value); ObjAgenda.ExcluirLogicamente(); MessageBox.Show("Registro excluído com sucesso.", "E X C L U S Ã O", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("OPERAÇÃO CANCELADA", " CANCELAMENTO DE E X C L U S Ã O", MessageBoxButtons.OK, MessageBoxIcon.Information); } CarregaDataGrid(); }
//============================================ private void btnGravar_Click(object sender, EventArgs e) { if ((txtNome.Text == "") || (txtMaskTel.Text == "") || (txtNr.Text == "") || (txtMaskCep.Text == "") || (txtEnd.Text == "") || (cboUF.Text == "") || (txtBairro.Text == "") || (txtCidade.Text == "")) { MessageBox.Show("Os Campos com * são Obrigatórios", "Item Novo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtNome.Focus(); } else { clnAgenda Agenda = new clnAgenda(); Agenda.Nome = txtNome.Text; Agenda.Tel = txtMaskTel.Text; Agenda.Nr = txtNr.Text; Agenda.Cep = txtMaskCep.Text; Agenda.Endereco = txtEnd.Text; Agenda.UF = cboUF.Text; Agenda.Bairro = txtBairro.Text; Agenda.Cidade = txtCidade.Text; if (txtCod.Text == "") { Agenda.Gravar(); MessageBox.Show("Registro Gravado com Sucesso", "Item Novo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtCod.Text != "") { Agenda.Cod = Convert.ToInt32(txtCod.Text); Agenda.Alterar(); MessageBox.Show("Registro de número " + txtCod.Text + " alterado com sucesso!", "Alteração", MessageBoxButtons.OK, MessageBoxIcon.Information); } Close(); } }