public void carregaDataGrid() { Clncliente ObjAgenda = new Clncliente(); dgvDados.DataSource = ObjAgenda.Listar(txtdescricao.Text).Tables[0]; dgvDados.Columns[0].HeaderText = ("Cod"); dgvDados.Columns[1].HeaderText = ("Cliente"); dgvDados.Columns[2].HeaderText = ("Telefone"); dgvDados.AutoResizeColumns(); if (dgvDados.RowCount == 0) { btnconsultar.Enabled = false; btnalterar.Enabled = false; btnpesquisar.Enabled = false; btnexcluir.Enabled = false; MessageBox.Show("Não foram encontrado daos com a informação" + txtdescricao.Text, "VERIFICAR", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvDados.DataSource = null; txtdescricao.Text = ""; txtdescricao.Focus(); } else { btnconsultar.Enabled = true; btnalterar.Enabled = true; btnexcluir.Enabled = true; } }
private void Cliente_Load(object sender, EventArgs e) { txtlogradouro.Enabled = false; txtuf.Enabled = false; txtbairro.Enabled = false; txtcidade.Enabled = false; txtcod_cliente.Enabled = false; if (txtcod_cliente.Text != "") { Clncliente ObjClnAgenda = new Clncliente(); OracleDataReader ObjDrDados; ObjDrDados = ObjClnAgenda.ListarUsuario(txtcod_cliente.Text); if (ObjDrDados.Read()) { txtnome.Text = ObjDrDados["Nome"].ToString(); maskedtel.Text = ObjDrDados["Telefone"].ToString(); maskedcel.Text = ObjDrDados["Celular"].ToString(); maskedcep.Text = ObjDrDados["CEP"].ToString(); txtlogradouro.Text = ObjDrDados["Logradouro"].ToString(); txtuf.Text = ObjDrDados["UF"].ToString(); txtn.Text = ObjDrDados["Nº"].ToString(); txtbairro.Text = ObjDrDados["Bairro"].ToString(); txtcidade.Text = ObjDrDados["Cidade"].ToString(); } txtnome.Focus(); } }
private void btnexcluir_Click(object sender, EventArgs e) { int msg; msg = Convert.ToInt32(MessageBox.Show("DESEJA EXCLUIR O REGISTRO?" + Convert.ToString(dgvDados.CurrentRow.Cells[1].Value), "E X C L U S Ã O", MessageBoxButtons.YesNo, MessageBoxIcon.Information)); if (msg == 6) { Clncliente objAgenda = new Clncliente(); objAgenda.CodCliente = Convert.ToInt32(dgvDados.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 E X C L U S Ã O ", MessageBoxButtons.OK, MessageBoxIcon.Information); } carregaDataGrid(); }
private void btnsalvar_Click(object sender, EventArgs e) { maskedcpf.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; if (maskedcpf.Text == "") { MessageBox.Show("Informe um CPF!", "CPF", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (Validacoes.validarCPF(maskedcpf.Text)) { maskedcpf.TextMaskFormat = MaskFormat.IncludePromptAndLiterals; try { if ((txtnome.Text == "") || (maskedtel.Text == "") || (txtn.Text == "") || (maskedcpf.Text == "")) { MessageBox.Show("Os campos com * são de preenchimento obrigatórios"); } else { Clncliente Cliente = new Clncliente(); if (txtcod_cliente.Text != "") { Cliente.CodCliente = Convert.ToInt32(txtcod_cliente.Text); } Cliente.Nome = txtnome.Text; Cliente.DtNasc = maskeddt_nasc.Text; Cliente.Sexo = combosexo.Text; Cliente.CPF = maskedcpf.Text.Replace(".", "-"); Cliente.RG = maskedrg.Text; Cliente.Logradouro = txtlogradouro.Text; Cliente.NumResid = txtn.Text; Cliente.Complemento = txtcomplemento.Text; Cliente.CEP = maskedcep.Text.Replace("-", ""); Cliente.Bairro = txtbairro.Text; Cliente.Cidade = txtcidade.Text; Cliente.UF = txtuf.Text; Cliente.Telefone = maskedtel.Text.Replace("()", "-"); Cliente.Celular = maskedcel.Text.Replace("()", "-"); Cliente.Email = txtemail.Text; if (ObjOperacao == clnFuncoesGerais.Operacao.Inclusao) { Cliente.Gravar(); MessageBox.Show("Dados gravados com sucesso!!", "Item Novo " + txtnome.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (ObjOperacao == clnFuncoesGerais.Operacao.Alteracao) { Cliente.Alterar(); MessageBox.Show("Registro nº " + txtcod_cliente.Text + "Alterado com sucesso ", "Alteração", MessageBoxButtons.OK, MessageBoxIcon.Information); } Close(); } } catch (Exception ex) { MessageBox.Show("Erro ao inserir Cliente\n" + ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Informe um CPF válido!", "CPF", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }