Example #1
0
        public Exception Atualiza_Codigo_Remessa_Cobranca( )
        {
            Parametros p = null;

            using (GTI_Context db = new GTI_Context(_connection)) {
                var _sql   = (from c in db.Parametros where c.Nomeparam == "COBRANCA" select c.Valparam).FirstOrDefault();
                int _valor = Convert.ToInt32(_sql) + 1;

                p          = db.Parametros.First(i => i.Nomeparam == "COBRANCA");
                p.Valparam = _valor.ToString();
                try {
                    db.SaveChanges();
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #2
0
        public string Nome_por_Cnpj(string cnpj)
        {
            string _nome = "", _nome2 = "";

            using (GTI_Context db = new GTI_Context(_connection)) {
                var Sql = (from c in db.Cidadao where c.Cnpj == cnpj select c.Nomecidadao).FirstOrDefault();
                if (Sql != null)
                {
                    _nome = Sql.ToString();
                }
                var Sql2 = (from m in db.Mobiliario where m.Cnpj == cnpj select m.Razaosocial).FirstOrDefault();
                if (Sql2 != null)
                {
                    _nome2 = Sql2.ToString();
                }
            }
            return(_nome2 == null? _nome:_nome2);
        }
Example #3
0
        public Exception Insert_W_Imovel_Historico(WImovel_Historico Reg)
        {
            using (var db = new GTI_Context(_connection)) {
                db.Database.CommandTimeout = 180;
                object[] Parametros = new object[6];

                Parametros[0] = new SqlParameter {
                    ParameterName = "@guid", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Guid
                };
                Parametros[1] = new SqlParameter {
                    ParameterName = "@seq", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Seq
                };
                Parametros[2] = new SqlParameter {
                    ParameterName = "@data_alteracao", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Data_Alteracao
                };
                Parametros[3] = new SqlParameter {
                    ParameterName = "@historico", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Historico
                };
                Parametros[4] = new SqlParameter {
                    ParameterName = "@usuario_codigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Usuario_Codigo
                };
                if (Reg.Usuario_Codigo == 0)
                {
                    Parametros[5] = new SqlParameter {
                        ParameterName = "@usuario_nome", SqlValue = DBNull.Value
                    }
                }
                ;
                else
                {
                    Parametros[5] = new SqlParameter {
                        ParameterName = "@usuario_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Usuario_Nome
                    }
                };

                db.Database.ExecuteSqlCommand("INSERT INTO wimovel_historico(guid,seq,data_alteracao,historico,usuario_codigo,usuario_nome) VALUES(@guid,@seq,@data_alteracao,@historico,@usuario_codigo,@usuario_nome)", Parametros);
                try {
                    db.SaveChanges();
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #4
0
 public Exception Incluir_bairro(Bairro reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         var cntCod = (from c in db.Bairro where c.Siglauf == reg.Siglauf && c.Codcidade == reg.Codcidade select c.Codbairro).Count();
         int maxCod = 1;
         if (cntCod > 0)
         {
             maxCod = (from c in db.Bairro where c.Siglauf == reg.Siglauf && c.Codcidade == reg.Codcidade select c.Codbairro).Max() + 1;
         }
         reg.Codbairro = Convert.ToInt16(maxCod);
         db.Bairro.Add(reg);
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #5
0
 public Exception Incluir_Pais(Pais reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         int cntCod = (from c in db.Pais select c).Count();
         int maxCod = 1;
         if (cntCod > 0)
         {
             maxCod = (from c in db.Pais select c.Id_pais).Max() + 1;
         }
         reg.Id_pais = maxCod;
         db.Pais.Add(reg);
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #6
0
 public int Incluir_cidade(Cidade reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         var cntCod = (from c in db.Cidade where c.Siglauf == reg.Siglauf select c.Codcidade).Count();
         int maxCod = 1;
         if (cntCod > 0)
         {
             maxCod = (from c in db.Cidade where c.Siglauf == reg.Siglauf select c.Codcidade).Max() + 1;
         }
         reg.Codcidade = Convert.ToInt16(maxCod);
         db.Cidade.Add(reg);
         try {
             db.SaveChanges();
         } catch {
             maxCod = 0;
         }
         return(maxCod);
     }
 }
Example #7
0
 public List <Cidadao> Lista_Cidadao(string Nome, string Cpf, string CNPJ)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         var Sql = (from c in db.Cidadao select c);
         if (!String.IsNullOrEmpty(Nome))
         {
             Sql = Sql.Where(c => c.Nomecidadao.Contains(Nome));
         }
         if (!String.IsNullOrEmpty(Cpf))
         {
             Sql = Sql.Where(c => c.Cpf.Contains(Cpf));
         }
         if (!String.IsNullOrEmpty(CNPJ))
         {
             Sql = Sql.Where(c => c.Cnpj.Contains(CNPJ));
         }
         return(Sql.ToList());
     }
 }
Example #8
0
 public Mobreq_main_Struct Retorna_Requerimento(string Guid)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         var Sql = (from c in db.Mobreq_Main
                    join m in db.Mobiliario on c.Codigo equals m.Codigomob into cm from m in cm.DefaultIfEmpty()
                    join t in db.Mobreq_Evento on c.Tipo equals t.Codigo into ct from t in ct.DefaultIfEmpty()
                    join s in db.Mobreq_Situacao on c.Situacao equals s.Codigo into st from s in st.DefaultIfEmpty()
                    join u in db.Usuario on c.UserId2 equals u.Id into ut from u in ut.DefaultIfEmpty()
                    where c.Guid == Guid
                    orderby c.Data_Inclusao
                    select new Mobreq_main_Struct {
             Codigo = c.Codigo, Data_Evento = c.Data_Evento, Data_Inclusao = c.Data_Inclusao, CpfCnpj = m.Cnpj == null ? m.Cpf : m.Cnpj,
             Guid = c.Guid, Obs = c.Obs, Razao_Social = m.Razaosocial.Substring(0, 27), Tipo_Codigo = c.Tipo,
             Tipo_Nome = t.Descricao.Substring(0, 30), UserId = c.UserId, UserPrf = c.UserPrf, Situacao_Codigo = c.Situacao,
             Situacao_Nome = s.Descricao, UserId2_Codigo = c.UserId2, Data_Evento2 = c.Data_Evento2, UserId2_Nome = u.Nomecompleto, Ano = c.Ano, Numero = c.Numero
         }).FirstOrDefault();
         return(Sql);
     }
 }
Example #9
0
        public Exception Incluir_Usuario(Usuario reg)
        {
            using (GTI_Context db = new GTI_Context(_connection)) {
                try {
                    List <SqlParameter> parameters = new List <SqlParameter> {
                        new SqlParameter("@id", reg.Id),
                        new SqlParameter("@nomelogin", reg.Nomelogin),
                        new SqlParameter("@nomecompleto", reg.Nomecompleto),
                        new SqlParameter("@setor_atual", reg.Setor_atual)
                    };

                    db.Database.ExecuteSqlCommand("INSERT INTO usuario2(id,nomelogin,nomecompleto,ativo,setor_atual)" +
                                                  " VALUES(@id,@nomelogin,@nomecompleto,@ativo,@setor_atual)", parameters.ToArray());
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #10
0
        public int Incluir_Porte_Empresa(string Name)
        {
            using (GTI_Context db = new GTI_Context(_connection)) {
                int cntCod = (from c in db.Redesim_Porte_Empresa select c).Count();
                int maxCod = 1;
                if (cntCod > 0)
                {
                    maxCod = (from c in db.Redesim_Porte_Empresa select c.Codigo).Max() + 1;
                }
                try {
                    db.Database.ExecuteSqlCommand("INSERT redesim_porte_empresa(codigo,nome) values(@codigo,@nome)",
                                                  new SqlParameter("@codigo", maxCod), new SqlParameter("@nome", Name));
                } catch (Exception ex) {
                    throw ex;
                }

                return(maxCod);
            }
        }
Example #11
0
        public Bairro RetornaLogradouroBairro(Int32 CodigoLogradouro, Int16 Numero)
        {
            int    nBairro = 0;
            int    Num1, Num2;
            Bairro _bairro = new Bairro();

            using (GTI_Context db = new GTI_Context(_connection)) {
                var Sql = (from e in db.Logradouro_Bairro where e.Logradouro == CodigoLogradouro select e).ToList();
                if (Sql.Count == 0)
                {
                    nBairro = 0;
                }
                else if (Sql.Count == 1)
                {
                    nBairro = Sql[0].Bairro;
                }
                else
                {
                    foreach (var item in Sql)
                    {
                        Num1 = Convert.ToInt32(item.Inicial);
                        Num2 = Convert.ToInt32(item.Final);
                        if (Numero >= Num1 && Numero <= Num2)
                        {
                            nBairro = item.Bairro;
                            break;
                        }
                        else if (Numero >= Num1 && Num2 == 0)
                        {
                            nBairro = item.Bairro;
                            break;
                        }
                    }
                }
                if (nBairro > 0)
                {
                    _bairro = (from e in db.Bairro where e.Siglauf == "SP" && e.Codcidade == 413 && e.Codbairro == nBairro select e).FirstOrDefault();
                }
            }
            return(_bairro);
        }
Example #12
0
        public string Nome_por_Cpf(string cpf)
        {
            string _nome = "";

            using (GTI_Context db = new GTI_Context(_connection)) {
                var Sql = (from c in db.Cidadao where c.Cpf == cpf select c.Nomecidadao).FirstOrDefault();
                if (Sql != null)
                {
                    _nome = Sql.ToString();
                }
                else
                {
                    var Sql2 = (from m in db.Mobiliario where m.Cpf == cpf select m.Razaosocial).FirstOrDefault();
                    if (Sql2 != null)
                    {
                        _nome = Sql2.ToString();
                    }
                }
            }
            return(_nome);
        }
Example #13
0
        public Exception Alterar_Usuario_Local(List <Usuariocc> reg)
        {
            using (GTI_Context db = new GTI_Context(_connection)) {
                db.Database.ExecuteSqlCommand("DELETE FROM usuariocc WHERE userid=@id", new SqlParameter("@id", reg[0].Userid));

                List <SqlParameter> parameters = new List <SqlParameter>();
                foreach (Usuariocc item in reg)
                {
                    try {
                        parameters.Add(new SqlParameter("@Userid", item.Userid));
                        parameters.Add(new SqlParameter("@Codigocc", item.Codigocc));

                        db.Database.ExecuteSqlCommand("INSERT INTO usuariocc(userid,codigocc) VALUES(@Userid,@Codigocc)", parameters.ToArray());
                        parameters.Clear();
                    } catch (Exception ex) {
                        return(ex);
                    }
                }
                return(null);
            }
        }
Example #14
0
        public List <Logradouro> Lista_Logradouro(String Filter = "")
        {
            using (GTI_Context db = new GTI_Context(_connection)) {
                var reg = (from l in db.Logradouro
                           select new { l.Codlogradouro, l.Endereco });
                if (!String.IsNullOrEmpty(Filter))
                {
                    reg = reg.Where(u => u.Endereco.Contains(Filter)).OrderBy(u => u.Endereco);
                }

                List <Logradouro> Lista = new List <Logradouro>();
                foreach (var query in reg)
                {
                    Logradouro Linha = new Logradouro {
                        Codlogradouro = query.Codlogradouro,
                        Endereco      = query.Endereco
                    };
                    Lista.Add(Linha);
                }
                return(Lista);
            }
        }
Example #15
0
 public Exception Alterar_Gti000(Gti000 reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         Gti000 u = db.Gti000.First(i => i.UserId == reg.UserId);
         u.Form_Extrato_Height          = reg.Form_Extrato_Height;
         u.Form_Extrato_Width           = reg.Form_Extrato_Width;
         u.Form_Processo_Lista_Height   = reg.Form_Processo_Lista_Height;
         u.Form_Processo_Lista_Width    = reg.Form_Processo_Lista_Width;
         u.Form_Processo_Tramite_Height = reg.Form_Processo_Tramite_Height;
         u.Form_Processo_Tramite_Width  = reg.Form_Processo_Tramite_Width;
         u.Form_Report_Height           = reg.Form_Report_Height;
         u.Form_Report_Width            = reg.Form_Report_Width;
         u.Path_Anexo  = reg.Path_Anexo;
         u.Path_Report = reg.Path_Report;
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #16
0
 public usuarioStruct Retorna_Usuario(int Id)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         var reg = (from t in db.Usuario
                    join cc in db.Centrocusto on t.Setor_atual equals cc.Codigo into tcc from cc in tcc.DefaultIfEmpty()
                    where t.Id == Id
                    orderby t.Nomelogin select new usuarioStruct {
             Nome_login = t.Nomelogin, Nome_completo = t.Nomecompleto, Ativo = t.Ativo,
             Id = t.Id, Senha = t.Senha, Senha2 = t.Senha2, Setor_atual = t.Setor_atual, Nome_setor = cc.Descricao
         }).FirstOrDefault();
         usuarioStruct Sql = new usuarioStruct {
             Id            = reg.Id,
             Nome_completo = reg.Nome_completo,
             Nome_login    = reg.Nome_login,
             Senha         = reg.Senha,
             Senha2        = reg.Senha2,
             Setor_atual   = reg.Setor_atual,
             Nome_setor    = reg.Nome_setor,
             Ativo         = reg.Ativo
         };
         return(Sql);
     }
 }
Example #17
0
 public List <usuarioStruct> Lista_Usuarios()
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         var reg = (from t in db.Usuario
                    join cc in db.Centrocusto on t.Setor_atual equals cc.Codigo into tcc from cc in tcc.DefaultIfEmpty()
                    where t.Ativo == 1
                    orderby t.Nomecompleto select new { t.Nomelogin, t.Nomecompleto, t.Ativo, t.Id, t.Senha, t.Setor_atual, cc.Descricao }).ToList();
         List <usuarioStruct> Lista = new List <usuarioStruct>();
         foreach (var item in reg)
         {
             usuarioStruct Linha = new usuarioStruct {
                 Nome_login    = item.Nomelogin,
                 Nome_completo = item.Nomecompleto,
                 Ativo         = item.Ativo,
                 Id            = item.Id,
                 Senha         = item.Senha,
                 Setor_atual   = item.Setor_atual,
                 Nome_setor    = item.Descricao
             };
             Lista.Add(Linha);
         }
         return(Lista);
     }
 }
Example #18
0
 public Exception Incluir_cidadao(Cidadao reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         var cntCod = (from c in db.Cidadao select c).Count();
         int nMax;
         if (cntCod > 0)
         {
             var maxCod = (from c in db.Cidadao select c.Codcidadao).Max();
             nMax = Convert.ToInt32(maxCod + 1);
         }
         else
         {
             nMax = 1;
         }
         reg.Codcidadao = nMax;
         db.Cidadao.Add(reg);
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #19
0
        public Cepdb Retorna_CepDB(int Cep)
        {
            string _cep = Cep.ToString().PadLeft(8, '0');

            using (GTI_Context db = new GTI_Context(_connection)) {
                Cepdb _cepdb = null;
                var   sql    = (from c in db.CepDB where c.Cep == _cep select c).FirstOrDefault();

                if (sql != null)
                {
                    _cepdb = new Cepdb()
                    {
                        Cep          = sql.Cep,
                        Uf           = sql.Uf,
                        Cidadecodigo = sql.Cidadecodigo,
                        Bairrocodigo = sql.Bairrocodigo,
                        Logradouro   = sql.Logradouro
                    };
                }
                else
                {
                    _cepdb = new Cepdb()
                    {
                        Cep          = Cep.ToString(),
                        Uf           = "",
                        Cidadecodigo = 0,
                        Bairrocodigo = 0,
                        Logradouro   = ""
                    };
                }

                //     _cepdb.Cidade = Retorna_Cidade(_cepdb.Uf, _cepdb.Cidadecodigo);
                //      _cepdb.Bairro = Retorna_Bairro(_cepdb.Uf, _cepdb.Cidadecodigo,_cepdb.Bairrocodigo);
                return(_cepdb);
            }
        }
Example #20
0
        public Exception Atualizar_Master_Registro(Redesim_Registro reg)
        {
            using (GTI_Context db = new GTI_Context(_connection)) {
                Endereco_Data    enderecoRepository = new Endereco_Data("GTIconnection");
                LogradouroStruct _log = enderecoRepository.Retorna_Logradour_Cep(Convert.ToInt32(reg.Cep));
                int _logradouro       = 0;
                if (_log != null && _log.CodLogradouro != null)
                {
                    _logradouro = (int)_log.CodLogradouro;
                }
                else
                {
                    _logradouro = 0;
                }

                object[] Parametros = new object[9];
                Parametros[0] = new SqlParameter {
                    ParameterName = "@protocolo", SqlDbType = SqlDbType.VarChar, SqlValue = reg.Protocolo
                };
                Parametros[1] = new SqlParameter {
                    ParameterName = "@razao_social", SqlDbType = SqlDbType.VarChar, SqlValue = reg.Razao_Social
                };
                Parametros[2] = new SqlParameter {
                    ParameterName = "@cnpj", SqlDbType = SqlDbType.VarChar, SqlValue = reg.Cnpj
                };
                Parametros[3] = new SqlParameter {
                    ParameterName = "@logradouro", SqlDbType = SqlDbType.Int, SqlValue = _logradouro
                };
                Parametros[4] = new SqlParameter {
                    ParameterName = "@numero", SqlDbType = SqlDbType.Int, SqlValue = reg.Numero
                };
                if (string.IsNullOrEmpty(reg.Complemento))
                {
                    Parametros[5] = new SqlParameter {
                        ParameterName = "@complemento", SqlValue = DBNull.Value
                    }
                }
                ;
                else
                {
                    Parametros[5] = new SqlParameter {
                        ParameterName = "@complemento", SqlDbType = SqlDbType.VarChar, SqlValue = reg.Complemento
                    }
                };
                Parametros[6] = new SqlParameter {
                    ParameterName = "@cep", SqlDbType = SqlDbType.VarChar, SqlValue = reg.Cep
                };
                Parametros[7] = new SqlParameter {
                    ParameterName = "@cnae_principal", SqlDbType = SqlDbType.VarChar, SqlValue = reg.Cnae_Principal
                };
                Parametros[8] = new SqlParameter {
                    ParameterName = "@inscricao", SqlDbType = SqlDbType.Int, SqlValue = reg.Inscricao
                };
                try {
                    db.Database.ExecuteSqlCommand("UPDATE redesim_master SET razao_social=@razao_social,cnpj=@cnpj,logradouro=@logradouro,numero=@numero,complemento=@complemento," +
                                                  "cep=@cep,cnae_principal=@cnae_principal,inscricao=@inscricao where protocolo=@protocolo", Parametros);
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #21
0
        public List <int> Lista_Codigos_Documento(string Documento, TipoDocumento _tipo)
        {
            List <int> _lista = new List <int>();

            using (GTI_Context db = new GTI_Context(_connection)) {
                string _doc = dalCore.RetornaNumero(Documento);

                List <int> _codigos;
                //procura imóvel
                if (_tipo == TipoDocumento.Cpf)
                {
                    //_codigos = (from i in db.Cadimob join p in db.Proprietario on i.Codreduzido equals p.Codreduzido join c in db.Cidadao on p.Codcidadao equals c.Codcidadao
                    //           where p.Tipoprop == "P" && p.Principal == true && c.Cpf.Contains(_doc) select i.Codreduzido).ToList();
                    _codigos = (from i in db.Cadimob join p in db.Proprietario on i.Codreduzido equals p.Codreduzido join c in db.Cidadao on p.Codcidadao equals c.Codcidadao
                                where  c.Cpf.Contains(_doc) select i.Codreduzido).ToList();
                }
                else
                {
                    //_codigos = (from i in db.Cadimob join p in db.Proprietario on i.Codreduzido equals p.Codreduzido join c in db.Cidadao on p.Codcidadao equals c.Codcidadao
                    //           where p.Tipoprop == "P" && p.Principal == true && c.Cnpj.Contains(_doc) select i.Codreduzido).ToList();
                    _codigos = (from i in db.Cadimob join p in db.Proprietario on i.Codreduzido equals p.Codreduzido join c in db.Cidadao on p.Codcidadao equals c.Codcidadao
                                where  c.Cnpj.Contains(_doc) select i.Codreduzido).ToList();
                }
                foreach (int item in _codigos)
                {
                    _lista.Add(item);
                }

                _codigos.Clear();
                //procura empresa
                if (_tipo == TipoDocumento.Cpf)
                {
                    _codigos = (from m in db.Mobiliario where m.Cpf.Contains(_doc) select m.Codigomob).ToList();
                }
                else
                {
                    _codigos = (from m in db.Mobiliario where m.Cnpj.Contains(_doc) select m.Codigomob).ToList();
                }
                foreach (int item in _codigos)
                {
                    _lista.Add(item);
                }

                _codigos.Clear();
                //procura cidadão
                if (_tipo == TipoDocumento.Cpf)
                {
                    _codigos = (from c in db.Cidadao where  c.Codcidadao >= 500000 && c.Codcidadao < 700000 && c.Cpf.Contains(_doc) select c.Codcidadao).ToList();
                }
                else
                {
                    _codigos = (from c in db.Cidadao where c.Codcidadao >= 500000 && c.Codcidadao < 700000 && c.Cnpj.Contains(_doc) select c.Codcidadao).ToList();
                }
                foreach (int item in _codigos)
                {
                    _lista.Add(item);
                }
            }

            return(_lista);
        }
Example #22
0
        public int Incluir_Mobreq_Main(Mobreq_main Reg)
        {
            using (var db = new GTI_Context(_connection)) {
                db.Database.CommandTimeout = 180;

                int _numero = 1;
                var Sql     = (from p in db.Mobreq_Main where p.Ano == DateTime.Now.Year select p.Numero).FirstOrDefault();
                if (Sql > 0)
                {
                    _numero = (from p in db.Mobreq_Main where p.Ano == DateTime.Now.Year select p.Numero).Max() + 1;
                }


                object[] Parametros = new object[11];
                Parametros[0] = new SqlParameter {
                    ParameterName = "@guid", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Guid
                };
                Parametros[1] = new SqlParameter {
                    ParameterName = "@codigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Codigo
                };
                Parametros[2] = new SqlParameter {
                    ParameterName = "@tipo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Tipo
                };
                Parametros[3] = new SqlParameter {
                    ParameterName = "@data_evento", SqlDbType = SqlDbType.SmallDateTime, SqlValue = Reg.Data_Evento
                };
                Parametros[4] = new SqlParameter {
                    ParameterName = "@data_inclusao", SqlDbType = SqlDbType.SmallDateTime, SqlValue = Reg.Data_Inclusao
                };
                if (string.IsNullOrEmpty(Reg.Obs))
                {
                    Parametros[5] = new SqlParameter {
                        ParameterName = "@obs", SqlValue = DBNull.Value
                    }
                }
                ;
                else
                {
                    Parametros[5] = new SqlParameter {
                        ParameterName = "@obs", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Obs
                    }
                };
                Parametros[6] = new SqlParameter {
                    ParameterName = "@userid", SqlDbType = SqlDbType.Int, SqlValue = Reg.UserId
                };
                Parametros[7] = new SqlParameter {
                    ParameterName = "@userprf", SqlDbType = SqlDbType.Bit, SqlValue = Reg.UserPrf
                };
                Parametros[8] = new SqlParameter {
                    ParameterName = "@situacao", SqlDbType = SqlDbType.Int, SqlValue = Reg.Situacao
                };
                Parametros[9] = new SqlParameter {
                    ParameterName = "@numero", SqlDbType = SqlDbType.Int, SqlValue = _numero
                };
                Parametros[10] = new SqlParameter {
                    ParameterName = "@ano", SqlDbType = SqlDbType.SmallInt, SqlValue = DateTime.Now.Year
                };

                try {
                    db.Database.ExecuteSqlCommand("INSERT INTO mobreq_main(guid,Codigo,Tipo,data_evento,data_inclusao,obs,userid,userprf,situacao,numero,ano) " +
                                                  "VALUES(@guid,@Codigo,@Tipo,@data_evento,@data_inclusao,@obs,@userid,@userprf,@situacao,@numero,@ano)", Parametros);
                } catch {
                    return(0);
                }
                return(_numero);
            }
        }
Example #23
0
        public Exception Insert_W_Imovel_Area(WImovel_Area Reg)
        {
            using (var db = new GTI_Context(_connection)) {
                db.Database.CommandTimeout = 180;
                object[] Parametros = new object[13];

                Parametros[0] = new SqlParameter {
                    ParameterName = "@guid", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Guid
                };
                Parametros[1] = new SqlParameter {
                    ParameterName = "@seq", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Seq
                };
                Parametros[2] = new SqlParameter {
                    ParameterName = "@area", SqlDbType = SqlDbType.Decimal, SqlValue = Reg.Area
                };
                Parametros[3] = new SqlParameter {
                    ParameterName = "@uso_codigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Uso_codigo
                };
                Parametros[4] = new SqlParameter {
                    ParameterName = "@uso_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Uso_nome
                };
                Parametros[5] = new SqlParameter {
                    ParameterName = "@tipo_codigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Tipo_codigo
                };
                Parametros[6] = new SqlParameter {
                    ParameterName = "@tipo_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Tipo_nome
                };
                Parametros[7] = new SqlParameter {
                    ParameterName = "@categoria_codigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Categoria_codigo
                };
                Parametros[8] = new SqlParameter {
                    ParameterName = "@categoria_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Categoria_nome
                };
                if (Reg.Data_Aprovacao == null)
                {
                    Parametros[9] = new SqlParameter {
                        ParameterName = "@data_aprovacao", SqlValue = DBNull.Value
                    }
                }
                ;
                else
                {
                    Parametros[9] = new SqlParameter {
                        ParameterName = "@data_aprovacao", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Data_Aprovacao
                    }
                };
                if (Reg.Processo_Data == null)
                {
                    Parametros[10] = new SqlParameter {
                        ParameterName = "@processo_data", SqlValue = DBNull.Value
                    }
                }
                ;
                else
                {
                    Parametros[10] = new SqlParameter {
                        ParameterName = "@processo_data", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Processo_Data
                    }
                };
                if (Reg.Processo_Numero == null)
                {
                    Parametros[11] = new SqlParameter {
                        ParameterName = "@processo_numero", SqlValue = DBNull.Value
                    }
                }
                ;
                else
                {
                    Parametros[11] = new SqlParameter {
                        ParameterName = "@processo_numero", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Processo_Numero
                    }
                };
                Parametros[12] = new SqlParameter {
                    ParameterName = "@pavimentos", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Pavimentos
                };

                db.Database.ExecuteSqlCommand("INSERT INTO wimovel_area(guid,seq,area,uso_codigo,uso_nome,tipo_codigo,tipo_nome,categoria_codigo,categoria_nome,data_aprovacao,processo_data,processo_numero," +
                                              "pavimentos) VALUES(@guid,@seq,@area,@uso_codigo,@uso_nome,@tipo_codigo,@tipo_nome,@categoria_codigo,@categoria_nome,@data_aprovacao,@processo_data,@processo_numero,@pavimentos)", Parametros);
                try {
                    db.SaveChanges();
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #24
0
        public CidadaoStruct Dados_Cidadao(int _codigo)
        {
            using (GTI_Context db = new GTI_Context(_connection)) {
                var Sql = (from c in db.Cidadao
                           join l in db.Logradouro on c.Codlogradouro equals l.Codlogradouro into lc from l in lc.DefaultIfEmpty()
                           join l2 in db.Logradouro on c.Codlogradouro2 equals l2.Codlogradouro into l2c from l2 in l2c.DefaultIfEmpty()
                           join a in db.Cidade on new { p1 = c.Siglauf, p2 = (short)c.Codcidade } equals new { p1 = a.Siglauf, p2 = a.Codcidade } into ac from a in ac.DefaultIfEmpty()
                           join a2 in db.Cidade on new { p1 = c.Siglauf, p2 = (short)c.Codcidade } equals new { p1 = a2.Siglauf, p2 = a2.Codcidade } into a2c from a2 in a2c.DefaultIfEmpty()
                           join b in db.Bairro on new { p1 = c.Siglauf, p2 = (short)c.Codcidade, p3 = (short)c.Codbairro } equals new { p1 = b.Siglauf, p2 = b.Codcidade, p3 = b.Codbairro } into bc from b in bc.DefaultIfEmpty()
                           join b2 in db.Bairro on new { p1 = c.Siglauf2, p2 = (short)c.Codcidade2, p3 = (short)c.Codbairro2 } equals new { p1 = b2.Siglauf, p2 = b2.Codcidade, p3 = b2.Codbairro } into b2c from b2 in b2c.DefaultIfEmpty()
                           where c.Codcidadao == _codigo
                           select new  { c.Codcidadao, c.Nomecidadao, c.Cpf, c.Data_nascimento, c.Cnpj, c.Etiqueta, c.Etiqueta2, c.Juridica, c.Profissao, c.Rg,
                                         c.Orgao, c.Codlogradouro, c.Codlogradouro2, c.Nomelogradouro, c.Nomelogradouro2, c.Codbairro, c.Codbairro2, c.Codcidade, c.Codcidade2,
                                         c.Siglauf, c.Siglauf2, c.Cep, c.Cep2, c.Codpais, c.Codpais2, c.Telefone, c.Telefone2, c.Email, c.Email2, c.Whatsapp, c.Whatsapp2, c.Numimovel,
                                         c.Numimovel2, c.Complemento, c.Complemento2, c.Codprofissao, Endereco_NomeR = l.Endereco, Endereco_NomeC = l2.Endereco, Bairro_NomeR = b.Descbairro,
                                         Bairro_NomeC = b2.Descbairro, Nome_CidadeR = a.Desccidade, Nome_CidadeC = a2.Desccidade }).FirstOrDefault();

                CidadaoStruct reg = new CidadaoStruct()
                {
                    Codigo            = Sql.Codcidadao,
                    Nome              = Sql.Nomecidadao,
                    Cpf               = Sql.Cpf,
                    Cnpj              = Sql.Cnpj,
                    Rg                = Sql.Rg,
                    Orgao             = Sql.Orgao,
                    DataNascto        = Sql.Data_nascimento,
                    EtiquetaR         = Sql.Etiqueta,
                    EtiquetaC         = Sql.Etiqueta2,
                    Juridica          = Sql.Juridica == null?false: (bool)Sql.Juridica,
                    Profissao         = Sql.Profissao,
                    TelefoneR         = Sql.Telefone,
                    TelefoneC         = Sql.Telefone2,
                    EmailR            = Sql.Email,
                    EmailC            = Sql.Email2,
                    Whatsapp          = Sql.Whatsapp,
                    Whatsapp2         = Sql.Whatsapp2,
                    CodigoLogradouroR = Sql.Codlogradouro,
                    CodigoLogradouroC = Sql.Codlogradouro2,
                    EnderecoR         = Sql.Nomelogradouro,
                    EnderecoC         = Sql.Nomelogradouro2,
                    NumeroR           = Sql.Numimovel,
                    NumeroC           = Sql.Numimovel2,
                    ComplementoR      = Sql.Complemento,
                    ComplementoC      = Sql.Complemento2,
                    CodigoBairroR     = Sql.Codbairro,
                    CodigoBairroC     = Sql.Codbairro2,
                    CodigoPaisR       = Sql.Codpais,
                    CodigoPaisC       = Sql.Codpais2,
                    CodigoCidadeR     = Sql.Codcidade,
                    CodigoCidadeC     = Sql.Codcidade2,
                    NomeCidadeR       = Sql.Nome_CidadeR,
                    NomeCidadeC       = Sql.Nome_CidadeC,
                    UfR               = Sql.Siglauf,
                    UfC               = Sql.Siglauf2,
                    CodigoProfissao   = Sql.Codprofissao,
                    NomeBairroR       = Sql.Bairro_NomeR,
                    NomeBairroC       = Sql.Bairro_NomeC
                };
                if (Sql.Codlogradouro > 0)
                {
                    reg.EnderecoR = Sql.Endereco_NomeR;
                }
                if (Sql.Codlogradouro2 > 0)
                {
                    reg.EnderecoC = Sql.Endereco_NomeC;
                }

                if (!string.IsNullOrWhiteSpace(reg.Cnpj))
                {
                    reg.Tipodoc = 1;
                }
                else
                {
                    reg.Tipodoc = 2;
                }

                return(reg);
            }
        }
Example #25
0
        public CidadaoStruct LoadReg(Int32 nCodigo)
        {
            using (GTI_Context db = new GTI_Context(_connection)) {
                var reg = (from c in db.Cidadao
                           join l in db.Logradouro on c.Codlogradouro equals l.Codlogradouro into cl1 from l in cl1.DefaultIfEmpty()
                           join l2 in db.Logradouro on c.Codlogradouro2 equals l2.Codlogradouro into cl2 from l2 in cl2.DefaultIfEmpty()
                           join b in db.Bairro on new { p1 = c.Siglauf, p2 = c.Codcidade, p3 = c.Codbairro } equals new { p1 = b.Siglauf, p2 = (short?)b.Codcidade, p3 = (short?)b.Codbairro } into cb from b in cb.DefaultIfEmpty()
                           join b2 in db.Bairro on new { p1 = c.Siglauf2, p2 = c.Codcidade2, p3 = c.Codbairro2 } equals new { p1 = b2.Siglauf, p2 = (short?)b2.Codcidade, p3 = (short?)b2.Codbairro } into cb2 from b2 in cb2.DefaultIfEmpty()
                           join d in db.Cidade on new { p1 = c.Siglauf, p2 = c.Codcidade } equals new { p1 = d.Siglauf, p2 = (short?)d.Codcidade } into cd from d in cd.DefaultIfEmpty()
                           join d2 in db.Cidade on new { p1 = c.Siglauf2, p2 = c.Codcidade2 } equals new { p1 = d2.Siglauf, p2 = (short?)d2.Codcidade } into cd2 from d2 in cd2.DefaultIfEmpty()
                           join p in db.Pais on c.Codpais equals p.Id_pais into cp from p in cp.DefaultIfEmpty()
                           join p2 in db.Pais on c.Codpais equals p2.Id_pais into cp2 from p2 in cp2.DefaultIfEmpty()
                           where c.Codcidadao == nCodigo
                           select new {
                    c.Codcidadao, c.Nomecidadao, c.Cpf, c.Cnpj, c.Rg, c.Orgao, c.Codprofissao, c.Data_nascimento, c.Juridica,
                    c.Codlogradouro, c.Codlogradouro2, enderecoR = l.Endereco, enderecoC = l2.Endereco, c.Numimovel, c.Numimovel2, c.Complemento, c.Complemento2,
                    c.Etiqueta, c.Etiqueta2, c.Siglauf, c.Siglauf2, c.Codbairro, c.Codbairro2, c.Codcidade, c.Codcidade2, c.Cep, c.Cep2, c.Codpais, c.Codpais2, c.Telefone, c.Telefone2,
                    c.Email, c.Email2, c.Nomelogradouro, c.Nomelogradouro2, c.Profissao, nomebairroR = b.Descbairro, nomebairroC = b2.Descbairro, nomecidadeR = d.Desccidade,
                    nomecidadeC = d2.Desccidade, nomepaisR = p.Nome_pais, nomepaisC = p2.Nome_pais, c.Temfone, c.Temfone2, c.Whatsapp, c.Whatsapp2
                }).FirstOrDefault();


                CidadaoStruct Linha = new CidadaoStruct {
                    Codigo = reg.Codcidadao,
                    Nome   = reg.Nomecidadao
                };

                if (!string.IsNullOrEmpty(reg.Cpf) && reg.Cpf.ToString().Length > 10)
                {
                    Linha.Cpf     = reg.Cpf;
                    Linha.Cnpj    = "";
                    Linha.Tipodoc = 1;
                }
                else
                {
                    if (!string.IsNullOrEmpty(reg.Cnpj) && reg.Cnpj.ToString().Length > 10)
                    {
                        Linha.Cpf     = "";
                        Linha.Cnpj    = reg.Cnpj;
                        Linha.Tipodoc = 2;
                    }
                    else
                    {
                        Linha.Cpf     = "";
                        Linha.Cnpj    = "";
                        Linha.Tipodoc = 0;
                    }
                }

                Linha.Rg                = reg.Rg;
                Linha.Orgao             = reg.Orgao;
                Linha.Profissao         = reg.Profissao;
                Linha.DataNascto        = reg.Data_nascimento;
                Linha.Juridica          = Convert.ToBoolean(reg.Juridica);
                Linha.CodigoLogradouroR = reg.Codlogradouro;

                Linha.CodigoLogradouroC = reg.Codlogradouro2;
                Endereco_Data clsEnderco = new Endereco_Data(_connection);

                if (reg.Codcidade == 413)
                {
                    Linha.EnderecoR = reg.enderecoR;
                    Linha.CepR      = Convert.ToInt32(clsEnderco.RetornaCep(Convert.ToInt32(reg.Codlogradouro), Convert.ToInt16(reg.Numimovel)));
                }
                else
                {
                    Linha.EnderecoR = reg.Nomelogradouro;
                    Linha.CepR      = reg.Cep;
                }
                if (reg.Codcidade2 == 413)
                {
                    Linha.EnderecoC = reg.enderecoC;
                    Linha.CepC      = Convert.ToInt32(clsEnderco.RetornaCep(Convert.ToInt32(reg.Codlogradouro2), Convert.ToInt16(reg.Numimovel2)));
                }
                else
                {
                    Linha.EnderecoC = reg.Nomelogradouro2;
                    Linha.CepC      = reg.Cep2;
                }
                Linha.NumeroR       = reg.Numimovel;
                Linha.NumeroC       = reg.Numimovel2;
                Linha.ComplementoR  = reg.Complemento;
                Linha.ComplementoC  = reg.Complemento2;
                Linha.EtiquetaR     = reg.Etiqueta;
                Linha.EtiquetaC     = reg.Etiqueta2;
                Linha.UfR           = reg.Siglauf;
                Linha.UfC           = reg.Siglauf2;
                Linha.CodigoBairroR = reg.Codbairro;
                Linha.CodigoBairroC = reg.Codbairro2;
                Linha.NomeBairroR   = reg.nomebairroR;
                Linha.NomeBairroC   = reg.nomebairroC;
                Linha.CodigoCidadeR = reg.Codcidade;
                Linha.CodigoCidadeC = reg.Codcidade2;
                Linha.NomeCidadeR   = reg.nomecidadeR;
                Linha.NomeCidadeC   = reg.nomecidadeC;
                Linha.PaisR         = reg.nomepaisR;
                Linha.PaisC         = reg.nomepaisC;
                Linha.TelefoneR     = reg.Telefone;
                Linha.TelefoneC     = reg.Telefone2;
                Linha.EmailR        = reg.Email;
                Linha.EmailC        = reg.Email2;
                Linha.CodigoPaisR   = reg.Codpais;
                Linha.CodigoPaisC   = reg.Codpais2;
                Linha.Temfone       = reg.Temfone;
                Linha.Temfone2      = reg.Temfone2;
                Linha.Whatsapp      = reg.Whatsapp;
                Linha.Whatsapp2     = reg.Whatsapp2;
                return(Linha);
            }
        }
Example #26
0
 public List <Cepdb> Retorna_CepDB_Logradouro_Codigo(int Cep, int Bairro)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         return((from c in db.CepDB where c.Cep == Cep.ToString() && c.Bairrocodigo == Bairro orderby c.Logradouro select c).ToList());
     }
 }
Example #27
0
 public employees RetornaEmployee(int id)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         return(db.Employees.FirstOrDefault(e => e.Id == id));
     }
 }
Example #28
0
        public Exception Update_wimovel_main(WImovel_Main Reg)
        {
            using (var db = new GTI_Context(_connection)) {
                db.Database.CommandTimeout = 180;
                object[] Parametros = new object[29];
                Parametros[0] = new SqlParameter {
                    ParameterName = "@guid", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Guid
                };
                Parametros[1] = new SqlParameter {
                    ParameterName = "@codigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Codigo
                };
                Parametros[2] = new SqlParameter {
                    ParameterName = "@cip", SqlDbType = SqlDbType.Bit, SqlValue = Reg.Cip
                };
                Parametros[3] = new SqlParameter {
                    ParameterName = "@imune", SqlDbType = SqlDbType.Bit, SqlValue = Reg.Imune
                };
                Parametros[4] = new SqlParameter {
                    ParameterName = "@conjugado", SqlDbType = SqlDbType.Bit, SqlValue = Reg.Conjugado
                };
                Parametros[5] = new SqlParameter {
                    ParameterName = "@reside", SqlDbType = SqlDbType.Bit, SqlValue = Reg.Reside
                };
                Parametros[6] = new SqlParameter {
                    ParameterName = "@area_terreno", SqlDbType = SqlDbType.Decimal, SqlValue = Reg.Area_Terreno
                };
                Parametros[7] = new SqlParameter {
                    ParameterName = "@topografia", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Topografia
                };
                Parametros[8] = new SqlParameter {
                    ParameterName = "@pedologia", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Pedologia
                };
                Parametros[9] = new SqlParameter {
                    ParameterName = "@benfeitoria", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Benfeitoria
                };
                Parametros[10] = new SqlParameter {
                    ParameterName = "@categoria", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Categoria
                };
                Parametros[11] = new SqlParameter {
                    ParameterName = "@usoterreno", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Usoterreno
                };
                Parametros[12] = new SqlParameter {
                    ParameterName = "@situacao", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Situacao
                };
                Parametros[13] = new SqlParameter {
                    ParameterName = "@userid", SqlDbType = SqlDbType.Int, SqlValue = Reg.Userid
                };
                Parametros[14] = new SqlParameter {
                    ParameterName = "@inscricao", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Inscricao
                };
                Parametros[15] = new SqlParameter {
                    ParameterName = "@condominio", SqlDbType = SqlDbType.Int, SqlValue = Reg.Condominio
                };
                Parametros[16] = new SqlParameter {
                    ParameterName = "@data_alteracao", SqlDbType = SqlDbType.SmallDateTime, SqlValue = Reg.Data_Alteracao
                };
                Parametros[17] = new SqlParameter {
                    ParameterName = "@condominio_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Condominio_Nome
                };
                Parametros[18] = new SqlParameter {
                    ParameterName = "@topografia_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Topografia_Nome
                };
                Parametros[19] = new SqlParameter {
                    ParameterName = "@pedologia_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Pedologia_Nome
                };
                Parametros[20] = new SqlParameter {
                    ParameterName = "@benfeitoria_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Benfeitoria_Nome
                };
                Parametros[21] = new SqlParameter {
                    ParameterName = "@categoria_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Categoria_Nome
                };
                Parametros[22] = new SqlParameter {
                    ParameterName = "@usoterreno_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Usoterreno_Nome
                };
                Parametros[23] = new SqlParameter {
                    ParameterName = "@situacao_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Situacao_Nome
                };
                if (Reg.Lote_Original != null)
                {
                    Parametros[24] = new SqlParameter {
                        ParameterName = "@lote_original", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Lote_Original
                    }
                }
                ;
                else
                {
                    Parametros[24] = new SqlParameter {
                        ParameterName = "@lote_original", SqlValue = DBNull.Value
                    }
                };
                if (Reg.Quadra_Original != null)
                {
                    Parametros[25] = new SqlParameter {
                        ParameterName = "@quadra_original", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Quadra_Original
                    }
                }
                ;
                else
                {
                    Parametros[25] = new SqlParameter {
                        ParameterName = "@quadra_original", SqlValue = DBNull.Value
                    }
                };
                Parametros[26] = new SqlParameter {
                    ParameterName = "@tipo_matricula", SqlDbType = SqlDbType.Char, SqlValue = Reg.Tipo_Matricula
                };
                Parametros[27] = new SqlParameter {
                    ParameterName = "@numero_matricula", SqlDbType = SqlDbType.BigInt, SqlValue = Reg.Numero_Matricula
                };
                Parametros[28] = new SqlParameter {
                    ParameterName = "@tipo_endereco", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Tipo_Endereco
                };

                db.Database.ExecuteSqlCommand("update wimovel_main set cip=@cip,imune=@imune,conjugado=@conjugado,reside=@reside,area_terreno=@area_terreno,topografia=@topografia,pedologia=@pedologia," +
                                              "benfeitoria=@benfeitoria,categoria=@categoria,usoterreno=@usoterreno,situacao=@situacao,topografia_nome=@topografia_nome,pedologia_nome=@pedologia_nome,benfeitoria_nome=@benfeitoria_nome," +
                                              "categoria_nome=@categoria_nome,usoterreno_nome=@usoterreno_nome,situacao_nome=@situacao_nome,condominio_nome=@condominio_nome,inscricao=@inscricao,lote_original=@lote_original," +
                                              "quadra_original=@quadra_original,tipo_matricula=@tipo_matricula,tipo_endereco=@tipo_endereco,numero_matricula=@numero_matricula where guid=@guid ", Parametros);
                try {
                    db.SaveChanges();
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #29
0
 public IEnumerable <employees> ListaEmployee()
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         return(db.Employees.ToList());
     }
 }
Example #30
0
        public Exception Insert_wimovel_main2(WImovel_Main Reg)
        {
            using (var db = new GTI_Context(_connection)) {
                db.Database.CommandTimeout = 180;
                object[] Parametros = new object[24];
                Parametros[0] = new SqlParameter {
                    ParameterName = "@guid", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Guid
                };
                Parametros[1] = new SqlParameter {
                    ParameterName = "@codigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Codigo
                };
                Parametros[2] = new SqlParameter {
                    ParameterName = "@cip", SqlDbType = SqlDbType.Bit, SqlValue = Reg.Cip
                };
                Parametros[3] = new SqlParameter {
                    ParameterName = "@imune", SqlDbType = SqlDbType.Bit, SqlValue = Reg.Imune
                };
                Parametros[4] = new SqlParameter {
                    ParameterName = "@conjugado", SqlDbType = SqlDbType.Bit, SqlValue = Reg.Conjugado
                };
                Parametros[5] = new SqlParameter {
                    ParameterName = "@reside", SqlDbType = SqlDbType.Bit, SqlValue = Reg.Reside
                };
                Parametros[6] = new SqlParameter {
                    ParameterName = "@area_terreno", SqlDbType = SqlDbType.Decimal, SqlValue = Reg.Area_Terreno
                };
                Parametros[7] = new SqlParameter {
                    ParameterName = "@topografia", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Topografia
                };
                Parametros[8] = new SqlParameter {
                    ParameterName = "@pedologia", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Pedologia
                };
                Parametros[9] = new SqlParameter {
                    ParameterName = "@benfeitoria", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Benfeitoria
                };
                Parametros[10] = new SqlParameter {
                    ParameterName = "@categoria", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Categoria
                };
                Parametros[11] = new SqlParameter {
                    ParameterName = "@usoterreno", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Usoterreno
                };
                Parametros[12] = new SqlParameter {
                    ParameterName = "@situacao", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Situacao
                };
                Parametros[13] = new SqlParameter {
                    ParameterName = "@userid", SqlDbType = SqlDbType.Int, SqlValue = Reg.Userid
                };
                Parametros[14] = new SqlParameter {
                    ParameterName = "@inscricao", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Inscricao
                };
                Parametros[15] = new SqlParameter {
                    ParameterName = "@condominio", SqlDbType = SqlDbType.Int, SqlValue = Reg.Condominio
                };
                Parametros[16] = new SqlParameter {
                    ParameterName = "@data_alteracao", SqlDbType = SqlDbType.SmallDateTime, SqlValue = Reg.Data_Alteracao
                };
                Parametros[17] = new SqlParameter {
                    ParameterName = "@condominio_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Condominio_Nome
                };
                Parametros[18] = new SqlParameter {
                    ParameterName = "@topografia_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Topografia_Nome
                };
                Parametros[19] = new SqlParameter {
                    ParameterName = "@pedologia_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Pedologia_Nome
                };
                Parametros[20] = new SqlParameter {
                    ParameterName = "@benfeitoria_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Benfeitoria_Nome
                };
                Parametros[21] = new SqlParameter {
                    ParameterName = "@categoria_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Categoria_Nome
                };
                Parametros[22] = new SqlParameter {
                    ParameterName = "@usoterreno_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Usoterreno_Nome
                };
                Parametros[23] = new SqlParameter {
                    ParameterName = "@situacao_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Situacao_Nome
                };

                db.Database.ExecuteSqlCommand("INSERT INTO wimovel_main(guid,codigo,cip,imune,conjugado,reside,area_terreno,topografia,pedologia,benfeitoria,categoria,usoterreno,situacao,userid," +
                                              "inscricao,condominio,data_alteracao,condominio_nome,topografia_nome,pedologia_nome,benfeitoria_nome,categoria_nome,usoterreno_nome,situacao_nome) " +
                                              "VALUES(@guid,@codigo,@cip,@imune,@conjugado,@reside,@area_terreno,@topografia,@pedologia,@benfeitoria,@categoria,@usoterreno,@situacao,@userid," +
                                              "@inscricao,@condominio,@data_alteracao,@condominio_nome,@topografia_nome,@pedologia_nome,@benfeitoria_nome,@categoria_nome,@usoterreno_nome,@situacao_nome)", Parametros);
                try {
                    db.SaveChanges();
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }