コード例 #1
0
 private void ValidaDados()
 {
     if (TxtNomeInstrutor.Text.Trim() == String.Empty)
     {
         throw new Exception("O campo nome não pode ser nulo.");
     }
     if (CmbCidade.SelectedItem == null)
     {
         throw new Exception("O campo cidade não pode ser nulo.");
     }
     this._Instrutor.Nome = TxtNomeInstrutor.Text;
     this._Instrutor.TelefoneResidencial = TxtTelefoneResidencial.Text;
     this._Instrutor.TelefoneCelular     = TxtTelefoneCelular.Text;
     this._Instrutor.RG  = TxtRG.Text;
     this._Instrutor.CPF = TxtCPF.Text;
     Dominio.Endereco end = new Dominio.Endereco();
     end.Rua                    = TxtRua.Text;
     end.Numero                 = int.Parse(TxtNumero.Text);
     end.Complemento            = TxtComplemento.Text;
     end.Bairro                 = TxtBairro.Text;
     end.CEP                    = TxtCEP.Text;
     end.Cidade                 = (Dominio.Cidade)CmbCidade.SelectedItem;
     end.Cidade.Estado          = (Dominio.Estado)CmbEstado.SelectedItem;
     this._Instrutor.Endereco   = end;
     this._Instrutor.Observacao = TxtObservacaoInstrutor.Text;
     if (this._Instrutor.PathFoto == null)
     {
         this._Instrutor.PathFoto = "";
     }
 }
コード例 #2
0
            public static Dominio.Endereco ConsultaCEP(string CEP)
            {
                Dominio.Endereco Endereco;

                var res = Framework.WebServices.WebserviceCorreios.ConsultaCEP(CEP);

                if (res != null)
                {
                    Endereco = new Dominio.Endereco()
                    {
                        bairro       = res.bairro,
                        cep          = res.cep,
                        cidade       = res.cidade,
                        complemento  = res.complemento,
                        complemento2 = res.complemento2,
                        end          = res.end,
                        Id           = res.Id,
                        uf           = res.uf
                    };
                }
                else
                {
                    return(new Dominio.Endereco());
                }


                return(Endereco);
            }
コード例 #3
0
        public List <GerenciadorFinanceiro.Dominio.Aluno> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Aluno where Ativo = 1 order by Nome";
            List <Dominio.Aluno> listAlunos = new List <GerenciadorFinanceiro.Dominio.Aluno>();

            try
            {
                Conection.AbrirConexao();
                var              reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.Aluno    aluno;
                Dominio.Endereco endereco;
                while (reader.Read())
                {
                    aluno                     = new Dominio.Aluno();
                    aluno.IdAluno             = (int)reader["IdAluno"];;
                    aluno.NomeAluno           = (string)reader["Nome"];
                    aluno.CPF_CNPJ            = (string)reader["CPF_CNPJ"];
                    aluno.RG_InscEstadual     = (string)reader["RG_InscricaoEstadual"];
                    aluno.TelefoneResidencial = (string)reader["TelefoneResidencial"];
                    aluno.TelefoneComercial   = (string)reader["TelefoneComercial"];
                    aluno.TelefoneCelular     = (string)reader["TelefoneCelular"];
                    aluno.DataNascimento      = (DateTime)reader["DataNascimento"];
                    endereco                  = new Dominio.Endereco();
                    endereco.Rua              = (string)reader["Rua"];
                    endereco.Numero           = (int)reader["Numero"];
                    endereco.Complemento      = (string)reader["Complemento"];
                    endereco.Bairro           = (string)reader["Bairro"];
                    endereco.CEP              = (string)reader["CEP"];
                    endereco.Cidade           = new RepositorioCidade().BuscarObjetoPorId((int)reader["IdCidade"]);
                    aluno.Endereco            = endereco;
                    endereco                  = null;
                    aluno.SSP                 = (string)reader["SSP"];
                    aluno.NomePai             = (string)reader["NomePai"];
                    aluno.NomeMae             = (string)reader["NomeMae"];
                    aluno.Referencia          = (string)reader["Referencia"];
                    aluno.Observacao          = (string)reader["Observacao"];
                    aluno.Email               = (string)reader["Email"];
                    listAlunos.Add(aluno);
                    aluno = null;
                }
                return(listAlunos);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar todos os Alunos.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
コード例 #4
0
        public Dominio.Aluno BuscarObjetoPorId(int id)
        {
            string sSqlSelect = "select * from TB_Aluno where IdAluno = @IdAluno";

            try
            {
                Conection.AbrirConexao();
                var              reader   = Conection.ExecuteReader(sSqlSelect, id);
                Dominio.Aluno    aluno    = new Dominio.Aluno();
                Dominio.Endereco endereco = new Dominio.Endereco();
                while (reader.Read())
                {
                    aluno.IdAluno             = id;
                    aluno.NomeAluno           = (string)reader["Nome"];
                    aluno.CPF_CNPJ            = (string)reader["CPF_CNPJ"];
                    aluno.RG_InscEstadual     = (string)reader["RG_InscEstadual"];
                    aluno.TelefoneResidencial = (string)reader["TelefoneResidencial"];
                    aluno.TelefoneComercial   = (string)reader["TelefoneComercial"];
                    aluno.TelefoneCelular     = (string)reader["TelefoneCelular"];
                    aluno.DataNascimento      = (DateTime)reader["DataNascimento"];
                    endereco.Rua         = (string)reader["Rua"];
                    endereco.Numero      = (int)reader["Numero"];
                    endereco.Complemento = (string)reader["Complemento"];
                    endereco.Bairro      = (string)reader["Bairro"];
                    endereco.CEP         = (string)reader["CEP"];
                    endereco.Cidade      = new RepositorioCidade().BuscarObjetoPorId((int)reader["IdCidade"]);
                    aluno.Endereco       = endereco;
                    aluno.SSP            = (string)reader["SSP"];
                    aluno.NomePai        = (string)reader["NomePai"];
                    aluno.NomeMae        = (string)reader["NomeMae"];
                    aluno.Referencia     = (string)reader["Referencia"];
                    aluno.Observacao     = (string)reader["Observacao"];
                    aluno.Email          = (string)reader["Email"];
                }
                return(aluno);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível Buscar o Aluno.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
コード例 #5
0
        public List <GerenciadorFinanceiro.Dominio.Instrutor> BuscarTodos()
        {
            string sSqlSelect = "select * from TB_Instrutor where Ativo = 1 order by Nome";
            List <Dominio.Instrutor> listaInstrutor = new List <GerenciadorFinanceiro.Dominio.Instrutor>();

            try
            {
                Conection.AbrirConexao();
                var reader = Conection.ExecuteReader(sSqlSelect);
                Dominio.Instrutor instrutor;
                while (reader.Read())
                {
                    instrutor                     = new Dominio.Instrutor();
                    instrutor.IdInstrutor         = (int)reader["IdInstrutor"];
                    instrutor.Nome                = (string)reader["Nome"];
                    instrutor.TelefoneResidencial = (string)reader["TelefoneResidencial"];
                    instrutor.TelefoneCelular     = (string)reader["TelefoneCelular"];
                    instrutor.RG                  = (string)reader["RG"];
                    instrutor.CPF                 = (string)reader["CPF"];
                    Dominio.Endereco endereco = new Dominio.Endereco();
                    endereco.Rua         = (string)reader["Rua"];
                    endereco.Numero      = (int)reader["Numero"];
                    endereco.Complemento = (string)reader["Complemento"];
                    endereco.Bairro      = (string)reader["Bairro"];
                    endereco.CEP         = (string)reader["CEP"];
                    endereco.Cidade      = new Repositorio.RepositorioCidade().BuscarObjetoPorId((int)reader["IdCidade"]);
                    instrutor.Endereco   = endereco;
                    instrutor.PathFoto   = (string)reader["PathFoto"];
                    instrutor.Observacao = (string)reader["Observacao"];
                    endereco             = null;
                    listaInstrutor.Add(instrutor);
                    instrutor = null;
                }
                return(listaInstrutor);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível buscar os instrutores.", ex);
            }
            finally
            {
                Conection.FecharConexao();
            }
        }
コード例 #6
0
 private void DGInstrutores_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (this.DGInstrutores.Columns[e.ColumnIndex].Name == "Rua")
     {
         if (e != null)
         {
             if (e.Value != null)
             {
                 Dominio.Endereco endereco = (Dominio.Endereco)e.Value;//DGInstrutores.Rows[e.RowIndex].Cells["Rua"]
                 e.Value = endereco.Rua;
                 DGInstrutores.Rows[e.RowIndex].Cells["Numero"].Value      = endereco.Numero;
                 DGInstrutores.Rows[e.RowIndex].Cells["Complemento"].Value = endereco.Complemento;
                 DGInstrutores.Rows[e.RowIndex].Cells["Bairro"].Value      = endereco.Bairro;
                 DGInstrutores.Rows[e.RowIndex].Cells["CEP"].Value         = endereco.CEP;
                 DGInstrutores.Rows[e.RowIndex].Cells["Cidade"].Value      = endereco.Cidade.NomeCidade;
             }
         }
     }
 }
コード例 #7
0
        protected override void Seed(Infraestrutura.EFContext context)
        {
            List <Dominio.Fornecedor> lforn1 = new List <Dominio.Fornecedor>();
            List <Dominio.Fornecedor> lforn2 = new List <Dominio.Fornecedor>();


            Dominio.Fornecedor umbro = new Dominio.Fornecedor {
                Nome = "Umbro", Email = "*****@*****.**"
            };
            Dominio.Fornecedor nike = new Dominio.Fornecedor {
                Nome = "Nike", Email = "*****@*****.**"
            };
            Dominio.Fornecedor apple = new Dominio.Fornecedor {
                Nome = "Apple", Email = "*****@*****.**"
            };
            Dominio.Fornecedor samsung = new Dominio.Fornecedor {
                Nome = "Samsung", Email = "*****@*****.**"
            };

            List <Dominio.Fornecedor> lforn3 = new List <Dominio.Fornecedor>()
            {
                apple
            };

            lforn1.Add(umbro);
            lforn1.Add(nike);
            lforn1.Add(new Dominio.Fornecedor {
                Nome = "Odebrecht", Email = "*****@*****.**"
            });
            context.Fornecedor.AddOrUpdate(lforn1[0]);
            context.Fornecedor.AddOrUpdate(lforn1[1]);

            lforn2.Add(new Dominio.Fornecedor {
                Nome = "ANDRADE GUTIERREZ", Email = "*****@*****.**"
            });
            lforn2.Add(new Dominio.Fornecedor {
                Nome = "UTC", Email = "*****@*****.**"
            });
            context.Fornecedor.AddOrUpdate(lforn2[0]);
            context.Fornecedor.AddOrUpdate(lforn2[1]);

            var prod = new Dominio.Produto
            {
                Nome = "Camiseta",
                QuantidadeEmEstoque = 2,
                Preco     = 199.0f,
                UrlImagem = "~/Images/Produtos/camiseta tabajara.jpg",
                QuantidadeEstoqueMinimo = 1,
                Referencia   = "CI001",
                Peso         = 1.0f,
                Fornecedores = lforn1
            };
            var prodChape = new Dominio.Produto
            {
                Nome = "Camiseta Chape",
                QuantidadeEmEstoque = 2,
                Preco     = 199.0f,
                UrlImagem = "~/Images/Produtos/chapecoense.jpg",
                QuantidadeEstoqueMinimo = 1,
                Referencia   = "CI002",
                Peso         = 1.0f,
                Fornecedores = new List <Dominio.Fornecedor>()
                {
                    umbro
                }
            };

            context.Produto.AddOrUpdate(
                new Dominio.Produto {
                Nome = "Jaqueta", QuantidadeEmEstoque = 2, Preco = 329.99f, UrlImagem = "~/Images/Produtos/Jaqueta.png", QuantidadeEstoqueMinimo = 5, Referencia = "CI005", Peso = 100.0f, Fornecedores = lforn1
            },
                new Dominio.Produto {
                Nome = "Iphone 5s", QuantidadeEmEstoque = 5, Preco = 2000.0f, UrlImagem = "~/Images/Produtos/iphone.png", QuantidadeEstoqueMinimo = 10, Referencia = "CI003", Peso = 1500.0f, Fornecedores = lforn3
            },
                new Dominio.Produto {
                Nome = "Mega Drive III", QuantidadeEmEstoque = 10, Preco = 459.0f, UrlImagem = "~/Images/Produtos/mega-drive.jpg", QuantidadeEstoqueMinimo = 20, Referencia = "CI004", Peso = 1000.0f, Fornecedores = lforn2
            },
                new Dominio.Produto {
                Nome = "Camiseta Grêmio", QuantidadeEmEstoque = 10, Preco = 219.0f, UrlImagem = "~/Images/Produtos/gremio.jpg", QuantidadeEstoqueMinimo = 20, Referencia = "CI006", Peso = 1000.0f, Fornecedores = new List <Dominio.Fornecedor>()
                {
                    umbro
                }
            },
                new Dominio.Produto {
                Nome = "Camiseta Internacional", QuantidadeEmEstoque = 10, Preco = 159.0f, UrlImagem = "~/Images/Produtos/internacional.jpg", QuantidadeEstoqueMinimo = 20, Referencia = "CI007", Peso = 1000.0f, Fornecedores = new List <Dominio.Fornecedor>()
                {
                    nike
                }
            },
                new Dominio.Produto {
                Nome = "Samsung Galaxy j5 duos", QuantidadeEmEstoque = 10, Preco = 1459.0f, UrlImagem = "~/Images/Produtos/samsung.jpg", QuantidadeEstoqueMinimo = 20, Referencia = "CI008", Peso = 1000.0f, Fornecedores = new List <Dominio.Fornecedor>()
                {
                    samsung
                }
            },
                prod,
                prodChape
                );

            List <Dominio.PedidoItemFornecedor> pi = new List <Dominio.PedidoItemFornecedor>();

            pi.Add(new Dominio.PedidoItemFornecedor {
                Fornecedor = lforn1[0], Produto = prod, Quantidade = 100, DataPrevista = DateTime.Now.Date
            });

            context.Compra.AddOrUpdate(new Dominio.Compra
            {
                Data     = DateTime.Now.Date,
                NumeroNF = 952287,
                Pedidos  = pi,
                Status   = Dominio.Enums.StatusCompra.AguardandoRecebimento
            });

            /* Cliente */


            Dominio.Cliente cli2 = new Dominio.Cliente
            {
                Id    = 12,
                Cpf   = 8381543336,
                Email = "*****@*****.**",
                Login = "******",
                Nome  = "Leonardo dos Santos",
                Rg    = 014442,
                Senha = "123l"
            };
            context.Cliente.AddOrUpdate(cli2);

            Dominio.Cidade ci = context.Cidade.Find(1);

            /* Endereço */
            Dominio.Endereco end = new Dominio.Endereco
            {
                CEP         = 93115270,
                Bairro      = "Santos Dumont",
                Cidade      = ci,
                Complemento = "B18 A31",
                Numero      = 36,
                Rua         = "Tomé de Souza"
            };
            context.Endereco.AddOrUpdate(end);

            var lprod = new List <Dominio.PedidoClienteProduto>();

            var produtoPedido = context.Produto.FirstOrDefault();

            if (produtoPedido != null)
            {
                lprod.Add(new Dominio.PedidoClienteProduto()
                {
                    IdProduto  = produtoPedido.IdProduto,
                    Produto    = produtoPedido,
                    Quantidade = 1
                });
            }

            var camisetaProd = context.Produto.FirstOrDefault(p => p.Nome == "Camiseta");

            if (camisetaProd != null)
            {
                lprod.Add(new Dominio.PedidoClienteProduto()
                {
                    IdProduto  = camisetaProd.IdProduto,
                    Produto    = camisetaProd,
                    Quantidade = 1
                });
            }

            /* PedidoCliente */
            Dominio.PedidoCliente pc = new Dominio.PedidoCliente
            {
                Cliente         = cli2,
                CodigoRastreio  = "AA123456789BR",
                Data            = DateTime.Now,
                EnderecoEntrega = end,
                NumDocPag       = 1,
                Numero          = 234,
                Status          = Dominio.Enums.StatusPedido.AguardandoConfirmacaoPagamento,
                Produtos        = lprod
            };
            context.PedidoCliente.AddOrUpdate(pc);



            try
            {
                context.SaveChanges();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException e)
            {
                string mensagem = string.Empty;
                foreach (var validationErrors in e.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        mensagem += String.Format("Property: {0} Error: {1}",
                                                  validationError.PropertyName,
                                                  validationError.ErrorMessage);
                    }
                }
                throw new Exception(mensagem);
            }
        }