Esempio n. 1
0
        private void listar(CheckBox chkDisponivel)
        {
            int estadoAVer        = (chkDisponivel.IsChecked == true) ? 1 : 0;
            Livro_Helper_CRUD lhc = new Livro_Helper_CRUD(App.ligacaoBD);

            _contentor = new ObservableCollection <Livro>(lhc.list(estadoAVer));
            listaLivros.ItemsSource = _contentor;
            btnApagar.IsEnabled     = false;
            btnEditar.IsEnabled     = false;
        }
Esempio n. 2
0
 private void BtnApagar_Click(object sender, RoutedEventArgs e)
 {
     if (_editLivro != null)
     {
         Livro_Helper_CRUD lhc    = new Livro_Helper_CRUD(App.ligacaoBD);
         string            status = lhc.apagar(_editLivro);
         MessageBox.Show("Livro apagado com sucesso!");
     }
     listar(chk);
 }
 private void BtnAddLivro_Click(object sender, RoutedEventArgs e)
 {
     if (txtNome.Text != "" &&
         txtAutor.Text != "" &&
         txtAno.Text != "" &&
         txtEditora.Text != "" &&
         txtGen.Text != "")
     {
         Livro_Helper_CRUD lhc = new Livro_Helper_CRUD(App.ligacaoBD);
         Livro             l;
         if (_livroEdicao == null)
         {
             l = new Livro();
         }
         else
         {
             l = _livroEdicao;
         }
         l.Nome    = txtNome.Text;
         l.Autor   = txtAutor.Text;
         l.Editora = txtEditora.Text;
         l.Genero  = txtGen.Text;
         try
         {
             l.Ano = Convert.ToInt32(txtAno.Text);
         }
         catch
         {
             l.Ano = 1500;
         }
         string status = lhc.atualizar(l);
         if (status != "")
         {
             MessageBox.Show("Erro: " + status);
         }
         else
         {
             limpaFrom();
         }
     }
 }
Esempio n. 4
0
        private void preencherComboLst()
        {
            //Combobox Livros
            Livro_Helper_CRUD lhc = new Livro_Helper_CRUD(App.ligacaoBD);
            List <Livro>      lstL;

            if (cmbLivroLst.ItemsSource != null)
            {
                cmbLivroLst.ItemsSource = null;
            }
            if (cmbLivroLst.Items.Count > 0)
            {
                cmbLivroLst.Items.Clear();
            }
            lstL = lhc.list(0);

            if (lstL.Count > 0)
            {
                cmbLivroLst.ItemsSource = lstL;
            }
            else
            {
                Livro L = new Livro();
                L.Nome = "Sem Livros Emprestados";
                cmbLivroLst.Items.Add(L);
            }
            cmbLivroLst.SelectedIndex = 0;

            //Combobox Clientes
            Cliente_Helper_CRUD chc = new Cliente_Helper_CRUD(App.ligacaoBD);

            if (cmbClienteLst.ItemsSource != null)
            {
                cmbClienteLst.ItemsSource = null;
            }
            if (cmbClienteLst.Items.Count > 0)
            {
                cmbClienteLst.Items.Clear();
            }
            List <Cliente> lstC = chc.list(1);

            if (lstC.Count > 0)
            {
                cmbClienteLst.ItemsSource = lstC;
            }
            else
            {
                Cliente C = new Cliente();
                C.Nome = "Sem Clientes";
                cmbClienteLst.Items.Add(C);
            }
            cmbClienteLst.SelectedIndex = 0;

            //Combobox Funcionarios
            Funcionario_Helper_CRUD fhc = new Funcionario_Helper_CRUD(App.ligacaoBD);

            if (cmbFuncionarioLst.ItemsSource != null)
            {
                cmbFuncionarioLst.ItemsSource = null;
            }
            if (cmbFuncionarioLst.Items.Count > 0)
            {
                cmbFuncionarioLst.Items.Clear();
            }
            List <Funcionario> lstF = fhc.list(1);

            if (lstF.Count > 0)
            {
                cmbFuncionarioLst.ItemsSource = lstF;
            }
            else
            {
                Funcionario F = new Funcionario();
                F.Nome = "Sem Funcionários";
                cmbFuncionarioLst.Items.Add(F);
            }
            cmbFuncionarioLst.SelectedIndex = 0;
        }