Пример #1
0
        private void btGravar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtMatricula.Text))
            {
                if (!string.IsNullOrEmpty(txtAluno.Text))
                {
                    string aluno = txtAluno.Text.Replace("'", "''");

                    dto.Nome        = aluno;
                    dto.Responsavel = txtResponsavel.Text;
                    dto.Cod_Sala    = Convert.ToInt16(cbbSala.SelectedIndex + 1);
                    dto.Cod_Serie   = Convert.ToInt16(cbbSerie.SelectedIndex + 1);
                    dto.Cod_Turma   = Convert.ToInt16(cbbTurma.SelectedIndex + 1);

                    bll.Inserir(dto);
                    MessageBox.Show("Cadastro efetuado com sucesso!", "Sucesso");
                }
                MessageBox.Show("Por favor, informe o nome do(a) aluno(a).", "Aviso");
                return;
            }
            else
            {
                string aluno = txtAluno.Text.Replace("'", "''");

                dto.Id          = Convert.ToInt16(txtMatricula.Text);
                dto.Nome        = aluno;
                dto.Responsavel = txtResponsavel.Text;
                dto.Cod_Sala    = Convert.ToInt16(cbbSala.SelectedIndex + 1);
                dto.Cod_Serie   = Convert.ToInt16(cbbSerie.SelectedIndex + 1);
                dto.Cod_Turma   = Convert.ToInt16(cbbTurma.SelectedIndex + 1);

                bll.Atualizar(dto);
                MessageBox.Show("Cadastro atualizado com sucesso!", "Sucesso");
            }
            LimpaTudo();
            AlteraBotoes(0);
        }