private void btnExcluir_ButtonClick(object sender, EventArgs e) { if (TxtCodigo1.Text != "") { DialogResult result; string msg = "Deseja remover o Codigo: " + TxtCodigo1.Text.ToString() + " ?"; result = MessageBox.Show(msg, "Remover", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { clsDados.Model.Professor oProf = new clsDados.Model.Professor(); clsDados.DAL.Professor dalProf = new clsDados.DAL.Professor(); clsDados.BLL.Professor bllProf = new clsDados.BLL.Professor(); oProf.Codigo = int.Parse(TxtCodigo1.Text); bllProf.Delete(oProf); MessageBox.Show(" Foi excluido com sucesso!!"); DtgvProfessor1.DataSource = dalProf.Select(); DtgvProfessor1.Refresh(); } if (result == DialogResult.No) { MessageBox.Show("Operação cancelada!!"); DtgvProfessor1.DataSource = dalProf.Select(); DtgvProfessor1.Refresh(); } } else { MessageBox.Show("Codigo Invalido", "Remover", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnCadastrar_ButtonClick(object sender, EventArgs e) { clsDados.Model.Professor oProf = new clsDados.Model.Professor(); clsDados.DAL.Professor dalProf = new clsDados.DAL.Professor(); clsDados.BLL.Professor bllProf = new clsDados.BLL.Professor(); string n = txtNome1.Text; n = n.ToUpper(); txtNome1.Text = n; if (TxtCodigo1.Text != "" && txtNome1.Text != "" && MtxtCpf1.Text != "" && MtxtTelefone.Text != "") { DialogResult result; string msg = "Deseja salvar o Aluno: " + txtNome1.Text.ToString() + " ?"; result = MessageBox.Show(msg, "Salvar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { // oAluno.Codigo = int.Parse(TxtCodigo1.Text); oProf.Nome = txtNome1.Text; oProf.Cpf = MtxtCpf1.Text; oProf.Telefone = MtxtTelefone.Text; oProf.DataCadastro = dTCadastro2.Value; bllProf.Insert(oProf); MessageBox.Show(" Foi cadastrado com sucesso!!"); DtgvProfessor1.DataSource = dalProf.Select(); DtgvProfessor1.Refresh(); } if (result == DialogResult.No) { MessageBox.Show("Operação cancelada!"); DtgvProfessor1.DataSource = dalProf.Select(); DtgvProfessor1.Refresh(); } } else { MessageBox.Show("Codigo inválido -\n Atribua valores aos campos!! ", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }