コード例 #1
0
        protected override void BtExcluir()
        {
            if (SelecionarId(metroGrid1) && Id_selecionado > 0)
            {
                repositorio.ClearNotifications();
                Veiculo      item   = repositorio.GetOne(p => p.VeiculoId == Id_selecionado);
                DialogResult result = MessageBox.Show("Excluir ?\n ID: " + item.VeiculoId + " PLACA:" + item.Placa.Valor + "\nDE: " + item.Pessoa.Nome, "Deseja realmente exluir ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    repositorio.Delete(Id_selecionado);

                    if (repositorio.IsInvalid())
                    {
                        foreach (var msg in repositorio.Notifications)
                        {
                            MessageBox.Show("ERRO", msg.Message, MessageBoxButtons.OK);
                        }
                    }
                    else
                    {
                        repositorio.Save();
                        Pesquisar();
                    }
                }
            }
        }
コード例 #2
0
        public override bool update()
        {
            repositorio.ClearNotifications();
            if (entidade == null)
            {
                return(false);
            }
            if (entidade.IsInvalid())
            {
                Erros = false;
                ShowErros(entidade.Notifications);
                return(false);
            }
            bool retorno = repositorio.Update(entidade);

            if (repositorio.IsInvalid())
            {
                Erros = false;
                ShowErros(repositorio.Notifications);
                return(false);
            }
            else
            {
                Erros = true;
                return(retorno);
            }
        }
コード例 #3
0
        protected override void Pesquisar()
        {
            metroGrid1.AutoGenerateColumns = false;
            listRelacao = new List <MenuVeiculo>();
            //para apresentar objetos de valor no grid view tem que se criar outros objetos contento tipos comuns (int, string, float)
            repositorio = new RepositorioVeiculo(new UnitOfWork());
            repositorio.ClearNotifications();
            metroGrid1.DataSource = null;
            var list = repositorio.GetAll();

            if (chkIncluirInativos.Checked == false)
            {
                list = list.Where(p => p.Placa.Valor.Contains(txtBusca.Text) && p.Pessoa.Nome.Contains(txtPropNome.Text) && p.Ativo == true).ToList();
            }
            else
            {
                list = list.Where(p => p.Placa.Valor.Contains(txtBusca.Text) && p.Pessoa.Nome.Contains(txtPropNome.Text)).ToList();
            }
            foreach (var item in list)
            {
                listRelacao.Add(new MenuVeiculo {
                    id = item.VeiculoId, placa = item.Placa.Valor, descricao = item.DescricaoModelo, PropNome = item.Pessoa.Nome, CpfCnpj = item.Pessoa.CpfCnpj
                });
            }

            metroGrid1.DataSource = listRelacao;
            LblTotal.Text         = "Total: " + metroGrid1.RowCount.ToString();
            if (repositorio.IsInvalid())
            {
                foreach (var msg in repositorio.Notifications)
                {
                    MessageBox.Show("ERRO", msg.Message, MessageBoxButtons.OK);
                }
            }
        }