private void VVeiculoEditar_Load(object sender, EventArgs e)
        {
            List <MPessoa> ListaCPF = DPessoa.PesquisarComboBox(null);

            foreach (MPessoa CPF in ListaCPF)
            {
                comboBoxCpf.Items.Add(CPF.CPF);
            }

            atual = CVeiculo.Obter(atual);

            if (atual != null)
            {
                comboBoxCpf.Text          = atual.PessoaCPF;
                textBoxRENAVAM.Text       = atual.RENAVAM;
                textBoxPlaca.Text         = atual.Placa;
                textBoxModelo.Text        = atual.Modelo;
                textBoxAnoModelo.Text     = atual.AnoModelo.ToString();
                textBoxAnoFabricacao.Text = atual.AnoFabricacao.ToString();
            }
            else
            {
                Close();
            }
        }
Example #2
0
        //ATUALIZAR
        public static void Atualizar(MPessoa item)
        {
            if (item == null)
            {
                throw new Exception("Objeto PESSOA inválido");
            }

            if (item.Nome.Trim() == "" || item.Nome.Length > 200)
            {
                throw new Exception("Nome digitado inválido");
            }

            if (item.DataNascimento >= DateTime.Now)
            {
                throw new Exception("Ano de Nascimento não pode ser maior que a data atual!");
            }

            try
            {
                DPessoa.Atualizar(item);
            }
            catch
            {
                throw;
            }
        }
Example #3
0
        //PESQUISAR
        public static List <MPessoa> Pesquisar(MPessoa item)
        {
            List <MPessoa> retorno = null;

            if (item != null && item.Nome != null && item.Nome.Length <= 200)
            {
                string cpf = item.CPF.Replace(".", "");
                cpf = cpf.Replace("-", "");
                cpf = cpf.Trim();

                if (cpf == "")
                {
                    item.CPF = "";
                }

                retorno = DPessoa.Pesquisar(item);

                //RETORNO SE NÃO HOUVER NENHUM CADASTRO
                if (retorno == null)
                {
                    throw new Exception("A Pesquisa não retornou nenhum cadastro!");
                }
            }
            return(retorno);
        }
Example #4
0
        public static string Excluir(int id)
        {
            DPessoa Obj = new DPessoa();

            Obj.IdPessoa = id;

            return(Obj.ExcluirPessoa(Obj));
        }
Example #5
0
        public static string InserirPessoa(string nome, DateTime data, string numero, string endereco, string cpf, string telefone, string email, byte[] foto)
        {
            DPessoa Obj = new DPessoa();

            Obj.Nome       = nome;
            Obj.Data       = data;
            Obj.Endereco   = endereco;
            Obj.NumeroCasa = numero;
            Obj.Cpf        = cpf;
            Obj.Telefone   = telefone;
            Obj.Email      = email;
            Obj.Foto       = foto;
            return(Obj.inserirPessoa(Obj));
        }
Example #6
0
        public static string Editar(string nome, int id, string endereco, DateTime data, string numero, string cpf, string telefone, string email)
        {
            DPessoa Obj = new DPessoa();

            Obj.Nome       = nome;
            Obj.IdPessoa   = id;
            Obj.Endereco   = endereco;
            Obj.Data       = data;
            Obj.NumeroCasa = numero;
            Obj.Cpf        = cpf;
            Obj.Telefone   = telefone;
            Obj.Email      = email;

            return(Obj.Editar(Obj));
        }
        public static void Excluir(MPessoa item)
        {
            if (item.CPF.Trim() == "")
            {
                throw new Exception("CPF inválido");
            }

            try
            {
                DPessoa.Excluir(item);
            }
            catch
            {
                throw;
            }
        }
Example #8
0
        //INSERIR
        public static void Inserir(MPessoa item)
        {
            if (item == null)
            {
                throw new Exception("Objeto PESSOA inválido");
            }

            //NOME
            if (item.Nome.Trim() == "" || item.Nome.Length > 200)
            {
                throw new Exception("O Nome digitado esta inválido");
            }

            //CPF
            if (item.CPF.Trim() == "" || item.CPF.Length != 14)
            {
                throw new Exception("Objeto CPF em branco, ou com numeros incompletos");
            }

            for (int i = 0; i < 14; i++)
            {
                if (i != 3 && i != 7 && i != 11)
                {
                    if (!Char.IsDigit(item.CPF[i]))
                    {
                        throw new Exception("CPF inválido");
                    }
                }
            }

            //DATA DE NASCIMENTO
            if (item.DataNascimento > DateTime.Now)
            {
                throw new Exception("Ano de Nascimento não pode ser maior que a data atual!");
            }

            try
            {
                DPessoa.Inserir(item);
            }
            catch
            {
                throw;
            }
        }
        public static MPessoa Obter(MPessoa item)
        {
            MPessoa retorno = null;

            if (item != null)
            {
                string cpf = item.CPF.Replace(".", "");
                cpf = cpf.Replace("-", "");
                cpf = cpf.Trim();

                if (cpf == "")
                {
                    item.CPF = "";
                }

                retorno = DPessoa.Obter(item);
            }

            return(retorno);
        }
Example #10
0
        public static void Atualizar(MPessoa item)
        {
            if (item == null)
            {
                throw new Exception("Objeto PESSOA inválido");
            }

            if (item.Nome.Trim() == "" || item.Nome.Length > 200)
            {
                throw new Exception("Objeto PESSOA nome inválido");
            }

            try
            {
                DPessoa.Atualizar(item);
            }
            catch
            {
                throw;
            }
        }
Example #11
0
        public static List <MPessoa> Pesquisar(MPessoa item)
        {
            List <MPessoa> retorno = null;

            if (item != null && item.Nome != null && item.Nome.Length <= 200)
            {
                string cpf = item.CPF.Replace(".", "");
                cpf = cpf.Replace("-", "");
                cpf = cpf.Trim();

                if (cpf == "")
                {
                    item.CPF = "";
                }

                retorno = DPessoa.Pesquisar(item);
            }
            retorno = DPessoa.Pesquisar(item);

            return(retorno);
        }
Example #12
0
        public static void Inserir(MPessoa item)
        {
            if (item == null)
            {
                throw new Exception("Objeto PESSOA inválido");
            }

            if (item.Nome.Trim() == "" || item.Nome.Length > 200)
            {
                throw new Exception("Objeto PESSOA nome inválido");
            }

            //todo CPF
            //todo DataNascimento

            try
            {
                DPessoa.Inserir(item);
            }
            catch
            {
                throw;
            }
        }