private void Btnmodifica_Click(object sender, EventArgs e) { OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + @"\Locadora.mdb"); try { conn.Open(); String SQL; SQL = "update clientes set nome='" + TxtNome.Text + "',"; SQL += "CPF='" + TxtCpf.Text + "',"; SQL += "Rg='" + TxtRG.Text + "',"; SQL += "DataNasc='" + TxtNasc.Text + "',"; SQL += "Telefone='" + TxtTel.Text + "',"; SQL += "Celular='" + TxtCel.Text + "',"; SQL += "Email='" + TxtEmail.Text + "',"; SQL += "Endereco='" + TxtEndereco.Text + "',"; SQL += "Bairro='" + TxtBairro.Text + "',"; SQL += "Complemento='" + TxtComplem.Text + "' "; SQL += "where Codigo=" + Codigo; OleDbCommand cmd = new OleDbCommand(SQL, conn); MetroMessageBox.Show(this, "Dados alterados com sucesso", "Dados cadastrados", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); cmd.ExecuteNonQuery(); conn.Close(); TxtNome.Clear(); TxtCpf.Clear(); TxtRG.Clear(); TxtNasc.Clear(); TxtTel.Clear(); TxtCel.Clear(); TxtEmail.Clear(); TxtEndereco.Clear(); TxtBairro.Clear(); TxtComplem.Clear(); TxtCnh.Clear(); } catch (Exception erro) { MessageBox.Show(erro.Message); } }
private void button1_Click(object sender, EventArgs e) { OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + @"\Locadora.mdb"); try { conn.Open(); String SQL; SQL = "insert into Funcionarios(Nome,CPF,Rg,DataNasc,Telefone,Celular,Email,Endereco,Bairro,Complemento,DataContrato,SalarioHora) Values('" + TxtNome.Text + "','" + TxtCpf.Text + "','" + TxtRG.Text + "','" + TxtNasc.Text + "','" + TxtTel.Text + "','" + TxtCel.Text + "','" + TxtEmail.Text + "','" + TxtEndereco.Text + "','" + TxtBairro.Text + "','" + TxtComplem.Text + "',+'" + TxtContrato2.Text + "','" + TxtSala + "')"; OleDbCommand cmd = new OleDbCommand(SQL, conn); MetroMessageBox.Show(this, "Cadastro realizado com sucesso", "Dados cadastrados", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); cmd.ExecuteNonQuery(); conn.Close(); TxtNome.Clear(); TxtCpf.Clear(); TxtRG.Clear(); TxtNasc.Clear(); TxtTel.Clear(); TxtCel.Clear(); TxtEmail.Clear(); TxtEndereco.Clear(); TxtBairro.Clear(); TxtComplem.Clear(); TxtSala.Clear(); } catch (Exception erro) { MessageBox.Show(erro.Message); } }