Beispiel #1
0
        //Pesquisar por nome de cliente
        private void btnPesquisar_Click(object sender, EventArgs e)
        {
            if (textBoxClientes.Text.Length > 0)
            {
                ModelStand.Dispose();
                ModelStand = new ModelOficinaContainer();

                (from cliente in ModelStand.Cliente
                 where cliente.Nome.ToUpper().Contains(textBoxClientes.Text.ToUpper())
                 orderby cliente.Nome
                 select cliente).ToList();

                listBoxClientes.DataSource = ModelStand.Cliente.Local.ToBindingList();
            }
            else
            {
                ModelStand.Dispose();
                ModelStand = new ModelOficinaContainer();

                (from cliente in ModelStand.Cliente
                 orderby cliente.Nome
                 select cliente).Load();

                listBoxClientes.DataSource = ModelStand.Cliente.Local.ToBindingList();
            }
            textBoxClientes.Text = String.Empty;
        }
        //Filtrar por nº de  chassi
        private void btnFiltrar_Click(object sender, EventArgs e)
        {
            if (textBoxFiltrar.Text.Length > 0)
            {
                ModelStand.Dispose();
                ModelStand = new ModelOficinaContainer();

                (from carro in ModelStand.Carro
                 where carro.NumeroChassis.ToUpper().Contains(textBoxFiltrar.Text.ToUpper())
                 orderby carro.NumeroChassis
                 select carro).ToList();
                carroBindingSource.DataSource = ModelStand.Carro.Local.ToBindingList();
            }
            else
            {
                ModelStand.Dispose();
                ModelStand = new ModelOficinaContainer();

                (
                    from carro in ModelStand.Carro
                    orderby carro.NumeroChassis
                    select carro
                ).Load();

                carroBindingSource.DataSource = ModelStand.Cliente.Local.ToBindingList();
            }
        }
        //Pesquisa por nome
        private void btnFiltrar_Click_1(object sender, EventArgs e)
        {
            if (textBoxFiltrar.Text.Length > 0)
            {
                bindingNavigatorAddNewItem.Enabled = false;

                ModelStand.Dispose();
                ModelStand = new ModelOficinaContainer();

                (from cliente in ModelStand.Cliente
                 where cliente.Nome.ToUpper().Contains(textBoxFiltrar.Text.ToUpper())
                 orderby cliente.Nome
                 select cliente).ToList();

                clienteBindingSource.DataSource = ModelStand.Cliente.Local.ToBindingList();
            }
            else
            {
                bindingNavigatorAddNewItem.Enabled = true;

                ModelStand.Dispose();
                ModelStand = new ModelOficinaContainer();

                (from cliente in ModelStand.Cliente
                 orderby cliente.Nome
                 select cliente).Load();

                clienteBindingSource.DataSource = ModelStand.Cliente.Local.ToBindingList();
            }
            textBoxFiltrar.Text = String.Empty;
        }