Example #1
0
        ///BOTÃO DELETAR
        ///


        private void btnDeletar_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja deletar os dados do autor?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                int var = Convert.ToInt32(txtID.Text);

                CAutor.CAutorClient oProxy = new CAutor.CAutorClient();
                oProxy.Open();

                try
                {
                    oProxy.Deletar(var);

                    LimpaCampos();

                    HabilitaCampos();


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


                    btnAlterar.Enabled = false;

                    btnInserir.Enabled = true;

                    btnDeletar.Enabled = false;
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #2
0
        ///BOTÃO PROCURAR
        ///



        private void btnProcurar_Click(object sender, EventArgs e)
        {
            if (cmbPesquisa.SelectedIndex == 0)
            {
                int var = Convert.ToInt32(txtPesquisa.Text);
                CAutor.CAutorClient oProxy = new CAutor.CAutorClient();
                oProxy.Open();

                if (oProxy.Selecionar(var) != null)
                {
                    AUTOR oAutor = oProxy.Selecionar(var);

                    txtNome.Text      = oAutor.NOME;
                    txtSobreNome.Text = oAutor.SOBRENOME;
                    txtBiografia.Text = oAutor.BIOGRAFIA;
                    txtSite.Text      = oAutor.SITE;
                    txtID.Text        = oAutor.ID_AUTOR.ToString();

                    DesabilitaCampos();

                    btnAlterar.Enabled = true;

                    btnDeletar.Enabled = true;

                    btnInserir.Enabled = false;
                }
                else
                {
                    MessageBox.Show("Autor não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                CAutor.CAutorClient oProxy = new CAutor.CAutorClient();
                oProxy.Open();

                if (oProxy.SelecionarNome(txtPesquisa.Text) != null)
                {
                    AUTOR oAutor = oProxy.SelecionarNome(txtPesquisa.Text);

                    txtNome.Text      = oAutor.NOME;
                    txtSobreNome.Text = oAutor.SOBRENOME;
                    txtBiografia.Text = oAutor.BIOGRAFIA;
                    txtSite.Text      = oAutor.SITE;
                    txtID.Text        = oAutor.ID_AUTOR.ToString();

                    DesabilitaCampos();

                    btnAlterar.Enabled = true;

                    btnDeletar.Enabled = true;

                    btnInserir.Enabled = false;
                }
                else
                {
                    MessageBox.Show("Autor não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btnProcurar_Click(object sender, EventArgs e)
        {
            if (cmbPesquisa.SelectedIndex == 0)
            {
                CAutor.CAutorClient oProxy = new CAutor.CAutorClient();
                oProxy.Open();
                dtgAutores.DataSource = oProxy.ListaTodosAutores();
            }
            else if (cmbPesquisa.SelectedIndex == 1)
            {
                int var = Convert.ToInt32(txtPesquisa.Text);
                CAutor.CAutorClient oProxy = new CAutor.CAutorClient();
                oProxy.Open();

                if (oProxy.Selecionar(var) != null)
                {
                    List <AUTOR> oAutores = new List <AUTOR>();
                    oAutores.Add(oProxy.Selecionar(var));
                    dtgAutores.DataSource = oAutores;
                    dtgAutores.Refresh();
                }
                else
                {
                    MessageBox.Show("Autor não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (cmbPesquisa.SelectedIndex == 2)
            {
                CAutor.CAutorClient oProxy = new CAutor.CAutorClient();
                oProxy.Open();

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

                    dtgAutores.DataSource = oAutor;
                    dtgAutores.Refresh();
                }
                else
                {
                    MessageBox.Show("Autor não encontrado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #4
0
        ///LOAD


        private void frmCadastroLivro_Load(object sender, EventArgs e)
        {
            CAutor.CAutorClient oProxy = new CAutor.CAutorClient();
            oProxy.Open();

            var Lista = oProxy.ListaTodosAutores();

            foreach (var p in Lista)
            {
                cmbAutor1.Items.Add(p.NOME);
                cmbAutor2.Items.Add(p.NOME);
            }

            oProxy.Close();



            CGenero.CGeneroClient oProxy2 = new CGenero.CGeneroClient();
            oProxy2.Open();

            var Lista2 = oProxy2.ListaTodosGeneros();

            foreach (var p in Lista2)
            {
                cmbGenero1.Items.Add(p.DESCRICAO);
            }

            oProxy2.Close();



            CEditora.CEditoraClient oProxy3 = new CEditora.CEditoraClient();
            oProxy3.Open();

            var Lista3 = oProxy3.ListaTodasEditoras();

            foreach (var p in Lista3)
            {
                cmbEditora.Items.Add(p.NOME);
            }

            oProxy3.Close();
        }
Example #5
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (VerificaControles())
            {
                LIVRO oLivro = new LIVRO();

                oLivro.TITULO        = txtTitulo.Text;
                oLivro.VOLUME        = Convert.ToInt32(txtVolume.Text);
                oLivro.DATA_PUBLIC   = dtp_Publicacao.Value;
                oLivro.QTD_EXMPLARES = Convert.ToInt32(txtQuantidade.Text);
                oLivro.SUMARIO       = txtSumario.Text;
                oLivro.QTD_DISP_EMPR = Convert.ToInt32(txtQuantidade.Text);
                oLivro.ID_EDITORA    = cmbEditora.SelectedIndex;


                CAutor.CAutorClient oProxy = new CAutor.CAutorClient();
                oProxy.Open();

                AUTOR xAutor  = oProxy.SelecionarNome(cmbAutor1.Text);
                AUTOR xAutor2 = oProxy.SelecionarNome(cmbAutor2.Text);

                oLivro.AUTOR.Add(xAutor);
                oLivro.AUTOR.Add(xAutor2);

                oProxy.Close();



                CEditora.CEditoraClient oProxy2 = new CEditora.CEditoraClient();
                oProxy2.Open();

                EDITORA xEditora = oProxy2.SelecionarNome(cmbEditora.Text);
                oLivro.EDITORA = xEditora;

                oProxy2.Close();



                CGenero.CGeneroClient oProxy3 = new CGenero.CGeneroClient();
                oProxy3.Open();

                GENERO xGenero = oProxy3.SelecionarDescricao(cmbGenero1.Text);
                oLivro.GENERO.Add(xGenero);

                oProxy3.Close();



                //oLivro.QTD_DISP_EMPR = ??????????
                //oLivro.ID_EDITORA = cmbEditora.SelectedIndex;
                //oLivro.GENERO =
                //oLivro.Emprestimo = ???????????
                //oLivro.RESERVA = ???????


                CLivro.CLivroClient oProxy4 = new CLivro.CLivroClient();
                oProxy4.Open();

                if (var == 0)
                {
                    try
                    {
                        if (oProxy4.Cadastrar(oLivro))
                        {
                            MessageBox.Show("Cadastro realizado com sucesso!", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            LimpaCampos();
                        }
                        else
                        {
                            if (MessageBox.Show("Livro existente! Deseja carregar os dados do livro?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                            {
                                string var = oLivro.TITULO;

                                btnSalvar.Enabled = false;

                                btnDeletar.Enabled = true;

                                btnAlterar.Enabled = true;



                                LIVRO xLivro = oProxy4.SelecionarTitulo(var);

                                int var2 = xLivro.ID_LIVRO;

                                txtTitulo.Text = xLivro.TITULO;
                                //???????? = oLivro.QTD_DISP_EMPR;
                                txtQuantidade.Text   = xLivro.QTD_EXMPLARES.ToString();
                                txtSumario.Text      = xLivro.SUMARIO;
                                dtp_Publicacao.Value = xLivro.DATA_PUBLIC;
                                cmbEditora.Text      = xLivro.EDITORA.NOME;
                                cmbAutor1.Text       = xLivro.AUTOR.ElementAt(0).NOME;
                                cmbAutor2.Text       = xLivro.AUTOR.ElementAt(1).NOME;
                                cmbGenero1.Text      = xLivro.GENERO.ElementAt(0).DESCRICAO;
                                //???????? = .GENERO;
                                //???????? = oLivro.Emprestimo;
                                //???????? = oLivro.RESERVA;
                                txtID.Text = Convert.ToString(var2);


                                DesabilitaCampos();
                            }
                            else
                            {
                                LimpaCampos();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    try
                    {
                        if (oProxy4.Alterar(oLivro))
                        {
                            MessageBox.Show("Alteração realizada com sucesso!", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            LimpaCampos();

                            btnAlterar.Enabled = false;

                            HabilitaCampos();

                            var = 0;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("Preencha todos os campos!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #6
0
        ///BOTÃO SALVAR
        ///


        private void btnInserir_Click(object sender, EventArgs e)
        {
            if (VerificaControles())
            {
                AUTOR oAutor = new AUTOR();

                oAutor.BIOGRAFIA = txtBiografia.Text;
                oAutor.NOME      = txtNome.Text;
                oAutor.SITE      = txtSite.Text;
                oAutor.SOBRENOME = txtSobreNome.Text;


                CAutor.CAutorClient oProxy = new CAutor.CAutorClient();
                oProxy.Open();


                if (var == 0)
                {
                    try
                    {
                        if (oProxy.Cadastrar(oAutor))
                        {
                            MessageBox.Show("Cadastro realizado com sucesso!", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            LimpaCampos();
                        }
                        else
                        {
                            if (MessageBox.Show("Autor existente! Deseja carregar os dados do Autor?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                            {
                                btnInserir.Enabled = false;

                                btnDeletar.Enabled = true;

                                btnAlterar.Enabled = true;

                                AUTOR xAutor = oProxy.SelecionarNome(oAutor.NOME);


                                txtNome.Text      = xAutor.NOME;
                                txtSobreNome.Text = xAutor.SOBRENOME;
                                txtBiografia.Text = xAutor.BIOGRAFIA;
                                txtID.Text        = Convert.ToString(xAutor.ID_AUTOR);
                                txtSite.Text      = xAutor.SITE;

                                DesabilitaCampos();
                            }
                            else
                            {
                                LimpaCampos();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

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

                            btnAlterar.Enabled = false;

                            HabilitaCampos();

                            var = 0;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("Preencha todos os campos!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }