private void listar(CheckBox chkAtivos)
        {
            int estadoAVer = (chkAtivos.IsChecked == true) ? 1 : 0;
            Funcionario_Helper_CRUD fhc = new Funcionario_Helper_CRUD(App.ligacaoBD);

            _contentor = new ObservableCollection <Funcionario>(fhc.list(estadoAVer));
            listaFuncionarios.ItemsSource = _contentor;
            btnApagar.IsEnabled           = false;
            btnEditar.IsEnabled           = false;
        }
 private void BtnApagar_Click(object sender, RoutedEventArgs e)
 {
     if (_editFuncionario != null)
     {
         Funcionario_Helper_CRUD fhc = new Funcionario_Helper_CRUD(App.ligacaoBD);
         string status = fhc.apagar(_editFuncionario);
         MessageBox.Show("Funcionário apagado com sucesso!");
     }
     listar(chk);
 }
예제 #3
0
 private void BtnAddFun_Click(object sender, RoutedEventArgs e)
 {
     if (txtNome.Text != "" && txtEnd.Text != "" && txtTel.Text != "" && txtCargo.Text != "")
     {
         Funcionario_Helper_CRUD fhc = new Funcionario_Helper_CRUD(App.ligacaoBD);
         Funcionario             f;
         if (_funcionarioEdicao == null)
         {
             f = new Funcionario();
         }
         else
         {
             f = _funcionarioEdicao;
         }
         f.Nome     = txtNome.Text;
         f.Endereco = txtEnd.Text;
         f.Telefone = txtTel.Text;
         f.Cargo    = txtCargo.Text;
         if (chkEstado.IsChecked == true)
         {
             f.Estado = 1.ToString();
         }
         else
         {
             f.Estado = 0.ToString();
         }
         string status = fhc.atualizar(f);
         if (status != "")
         {
             MessageBox.Show("Erro: " + status);
         }
         else
         {
             limpaFrom();
         }
     }
 }
예제 #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;
        }