Пример #1
0
        private void btnProcurar_Click(object sender, EventArgs e)
        {
            int var = Convert.ToInt32(txt_ID.Text);
            CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
            oProxy.Open();

            if (oProxy.Selecionar(var)!= null)
            {
                ALUNO oAluno = AlunoMetod.Selecionar(var);

                txtNome.Text = oAluno.NOME;
                txtSobreNome.Text = oAluno.SOBRENOME;
                dtpNasc.Value = oAluno.NASC;
                txtCPF.Text = oAluno.CPF;
                txtEnd.Text = oAluno.ENDERECO;
                txtBairro.Text = oAluno.BAIRRO;
                txtCidade.Text = oAluno.CIDADE;
                cmbUF.SelectedItem = oAluno.UF;
                cmbPais.SelectedItem = oAluno.PAIS;
                txtCEP.Text = oAluno.CEP;
                txtTelRes.Text = oAluno.TEL_RES;
                txtTelCel.Text = oAluno.TEL_CEL;
                txtEmail.Text = oAluno.EMAIL;
                txtID.Text = oAluno.ID_ALUNO.ToString();

                txtNome.Enabled = false;
                txtSobreNome.Enabled = false;
                txtCPF.Enabled = false;
                dtpNasc.Enabled = false;
            }
            else
            {
                MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        ///BOTÃO DELETAR
        /// 
        private void btnDeletar_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja deletar os dados do aluno?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                int var = Convert.ToInt32(txtID.Text);

                CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
                oProxy.Open();

                try
                {
                    oProxy.Deletar(var);

                    LimpaCampos();

                    HabilitaCampos();

                    MessageBox.Show("Aluno deletado com sucesso!", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    btnAlterar.Enabled = false;

                    btnSalvar.Enabled = true;

                    btnDeletar.Enabled = false;
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

            }
        }
Пример #3
0
        private void btnProcurar_Click(object sender, EventArgs e)
        {
            if (cmbPesquisa.SelectedIndex == 0)
            {
                int var = Convert.ToInt32(txtPesquisa.Text);
                CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
                oProxy.Open();

                if (oProxy.Selecionar(var) != null)
                {
                    ALUNO oAluno = oProxy.Selecionar(var);

                    txtNome.Text      = oAluno.NOME;
                    txtSobreNome.Text = oAluno.SOBRENOME;
                    txtID.Text        = oAluno.ID_ALUNO.ToString();
                }
                else
                {
                    MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
                oProxy.Open();

                if (oProxy.SelecionarNome(txtPesquisa.Text) != null)
                {
                    ALUNO oAluno = oProxy.SelecionarNome(txtPesquisa.Text);

                    txtNome.Text      = oAluno.NOME;
                    txtSobreNome.Text = oAluno.SOBRENOME;
                    txtID.Text        = oAluno.ID_ALUNO.ToString();
                }
                else
                {
                    MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #4
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            ALUNO oAluno = new ALUNO();

            oAluno.NOME = txtNome.Text;
            oAluno.SOBRENOME = txtSobreNome.Text;
            oAluno.NASC = dtpNasc.Value;
            oAluno.CPF = txtCPF.Text;
            oAluno.ENDERECO = txtEnd.Text;
            oAluno.BAIRRO = txtBairro.Text;
            oAluno.CIDADE = txtCidade.Text;
            oAluno.UF = cmbUF.SelectedItem.ToString();
            oAluno.PAIS = cmbPais.SelectedItem.ToString();
            oAluno.CEP = txtCEP.Text;
            oAluno.TEL_RES = txtTelRes.Text;
            oAluno.TEL_CEL = txtTelCel.Text;
            oAluno.EMAIL = txtEmail.Text;

            CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
            oProxy.Open();

            try
            {
                if (oProxy.Alterar(oAluno))
                {
                    MessageBox.Show("Alteração realizada com sucesso!", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LimpaCampos();

                    txtNome.Enabled = true;
                    txtSobreNome.Enabled = true;
                    txtCPF.Enabled = true;
                    dtpNasc.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
        private void btnProcurar_Click(object sender, EventArgs e)
        {
            if (cmbPesquisa.SelectedIndex == 0)
            {
                dtgAlunos.DataSource = AlunoMetod.SelecionarTodos();
            }
            else if (cmbPesquisa.SelectedIndex == 1)
            {
                int var = Convert.ToInt32(txtPesquisa.Text);
                CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
                oProxy.Open();

                if (oProxy.Selecionar(var) != null)
                {
                    List<ALUNO> oAlunos = new List<ALUNO>();
                    oAlunos.Add(oProxy.Selecionar(var));
                    dtgAlunos.DataSource = oAlunos;
                    dtgAlunos.Refresh();
                }
                else
                {
                    MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (cmbPesquisa.SelectedIndex == 2)
            {

                CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
                oProxy.Open();

                if (oProxy.SelecionarNome(txtPesquisa.Text) != null)
                {
                    List<ALUNO> oAlunos = new List<ALUNO>();
                    oAlunos.Add(oProxy.SelecionarNome(txtPesquisa.Text));

                    dtgAlunos.DataSource = oAlunos;
                    dtgAlunos.Refresh();
                }
                else
                {
                    MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (cmbPesquisa.SelectedIndex == 3)
            {
                CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
                oProxy.Open();

                if (oProxy.SelecionarCPF(txtPesquisa.Text) != null)
                {
                    List<ALUNO> oAlunos = new List<ALUNO>();
                    oAlunos.Add(oProxy.SelecionarCPF(txtPesquisa.Text));

                    dtgAlunos.DataSource = oAlunos;
                    dtgAlunos.Refresh();
                }
                else
                {
                    MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #6
0
        private void btnProcurar_Click(object sender, EventArgs e)
        {
            if (cmbPesquisa.SelectedIndex == 0)
            {
                int var = Convert.ToInt32(txtPesquisa.Text);
                CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
                oProxy.Open();

                if (oProxy.Selecionar(var) != null)
                {
                    ALUNO oAluno = oProxy.Selecionar(var);

                    txtNome.Text = oAluno.NOME;
                    txtSobreNome.Text = oAluno.SOBRENOME;
                    txtID.Text = oAluno.ID_ALUNO.ToString();

                }
                else
                {
                    MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {

                CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
                oProxy.Open();

                if (oProxy.SelecionarNome(txtPesquisa.Text) != null)
                {
                    ALUNO oAluno = oProxy.SelecionarNome(txtPesquisa.Text);

                    txtNome.Text = oAluno.NOME;
                    txtSobreNome.Text = oAluno.SOBRENOME;
                    txtID.Text = oAluno.ID_ALUNO.ToString();

                }
                else
                {
                    MessageBox.Show("Aluno não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #7
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            ALUNO oAluno = new ALUNO();

            oAluno.NOME = txtNome.Text;
            oAluno.SOBRENOME = txtSobreNome.Text;
            oAluno.NASC = dtpNasc.Value;
            oAluno.CPF = txtCPF.Text;
            oAluno.ENDERECO = txtEnd.Text;
            oAluno.BAIRRO = txtBairro.Text;
            oAluno.CIDADE = txtCidade.Text;
            oAluno.UF = cmbUF.SelectedItem.ToString();
            oAluno.PAIS = cmbPais.SelectedItem.ToString();
            oAluno.CEP = txtCEP.Text;
            oAluno.TEL_RES = txtTelRes.Text;
            oAluno.TEL_CEL = txtTelCel.Text;
            oAluno.EMAIL = txtEmail.Text;

            CAluno.CAlunoClient oProxy = new CAluno.CAlunoClient();
            oProxy.Open();

            try
            {
                if (oProxy.Cadastrar(oAluno))
                {
                    MessageBox.Show("Cadastro realizado com sucesso!", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LimpaCampos();
                }
                else
                {
                    if (MessageBox.Show("Aluno existente! Deseja carregar os dados do aluno?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        string var = oAluno.CPF;

                        ALUNO xAluno = oProxy.SelecionarCPF(var);

                        txtNome.Text = xAluno.NOME;
                        txtSobreNome.Text = xAluno.SOBRENOME;
                        dtpNasc.Value = xAluno.NASC;
                        txtCPF.Text = xAluno.CPF;
                        txtEnd.Text = xAluno.ENDERECO;
                        txtBairro.Text = xAluno.BAIRRO;
                        txtCidade.Text = xAluno.CIDADE;
                        cmbUF.SelectedItem = xAluno.UF;
                        cmbPais.SelectedItem = xAluno.PAIS;
                        txtCEP.Text = xAluno.CEP;
                        txtTelRes.Text = xAluno.TEL_RES;
                        txtTelCel.Text = xAluno.TEL_CEL;
                        txtEmail.Text = xAluno.EMAIL;
                        txtID.Text = xAluno.ID_ALUNO.ToString();

                        txtNome.Enabled = false;
                        txtSobreNome.Enabled = false;
                        txtCPF.Enabled = false;
                        txtID.Enabled = false;
                        dtpNasc.Enabled = false;
                    }
                    else
                    {
                        LimpaCampos();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }