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

            _contentor = new ObservableCollection <Cliente>(chc.list(estadoAVer));
            listaClientes.ItemsSource = _contentor;
            btnApagar.IsEnabled       = false;
            btnEditar.IsEnabled       = false;
        }
 private void BtnApagar_Click(object sender, RoutedEventArgs e)
 {
     if (_editCliente != null)
     {
         Cliente_Helper_CRUD chc = new Cliente_Helper_CRUD(App.ligacaoBD);
         string status           = chc.apagar(_editCliente);
         MessageBox.Show("Cliente apagado com sucesso!");
     }
     listar(chk);
 }
示例#3
0
 private void BtnAddCliente_Click(object sender, RoutedEventArgs e)
 {
     if (txtNome.Text != "" && txtEnd.Text != "" && txtTel.Text != "")
     {
         Cliente_Helper_CRUD chc = new Cliente_Helper_CRUD(App.ligacaoBD);
         Cliente             c;
         if (_clienteEdicao == null)
         {
             c = new Cliente();
         }
         else
         {
             c = _clienteEdicao;
         }
         c.Nome     = txtNome.Text;
         c.Endereco = txtEnd.Text;
         c.Telefone = txtTel.Text;
         if (chkEstado.IsChecked == true)
         {
             c.Estado = 1.ToString();
         }
         else
         {
             c.Estado = 0.ToString();
         }
         string status = chc.atualizar(c);
         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;
        }