private void btn_insert_Click(object sender, EventArgs e) { // dados fk_intBairro = int.Parse(txt_bairro.Text); strNOME = txt_nome.Text; intIdade = int.Parse(txt_idade.Text); strSexo = txt_sexo.Text; BDEstudoConnection context = new BDEstudoConnection(); Cliente newCliente = new Cliente() { fk_intBairro = this.fk_intBairro, strNOME = this.strNOME, intIdade = this.intIdade, strSexo = this.strSexo }; context.Cliente.Add(newCliente); context.SaveChanges(); lerdados(); MessageBox.Show("Dados inseridos com sucesso"); }
private void btn_delete_Click(object sender, EventArgs e) { pk_intCod = int.Parse(txt_Cod.Text); BDEstudoConnection context = new BDEstudoConnection(); Cliente deleteCliente = context.Cliente.First(i => i.pk_intCod == this.pk_intCod); context.Cliente.Remove(deleteCliente); context.SaveChanges(); lerdados(); MessageBox.Show("Dados removido com sucesso"); }
private void btn_update_Click(object sender, EventArgs e) { pk_intCod = int.Parse(txt_Cod.Text); fk_intBairro = int.Parse(txt_bairro.Text); strNOME = txt_nome.Text; intIdade = int.Parse(txt_idade.Text); strSexo = txt_sexo.Text; BDEstudoConnection context = new BDEstudoConnection(); Cliente readCliente = context.Cliente.First(i => i.pk_intCod == this.pk_intCod); readCliente.strNOME = this.strNOME; readCliente.fk_intBairro = this.fk_intBairro; readCliente.intIdade = this.intIdade; readCliente.strSexo = this.strSexo; context.SaveChanges(); lerdados(); MessageBox.Show("Dados atualizado com sucesso"); }