Example #1
0
        public Exception Insert_wimovel_main(string Guid, int Codigo, int UserId)
        {
            using (var db = new GTI_Context(_connection)) {
                db.Database.CommandTimeout = 180;
                object[] Parametros = new object[4];
                Parametros[0] = new SqlParameter {
                    ParameterName = "@guid", SqlDbType = SqlDbType.VarChar, SqlValue = Guid
                };
                Parametros[1] = new SqlParameter {
                    ParameterName = "@codigo", SqlDbType = SqlDbType.Int, SqlValue = Codigo
                };
                Parametros[2] = new SqlParameter {
                    ParameterName = "@data_alteracao", SqlDbType = SqlDbType.SmallDateTime, SqlValue = DateTime.Now
                };
                Parametros[3] = new SqlParameter {
                    ParameterName = "@userid", SqlDbType = SqlDbType.Int, SqlValue = UserId
                };

                db.Database.ExecuteSqlCommand("INSERT INTO wimovel_main(guid,codigo,data_alteracao,userid) VALUES(@guid,@codigo,@data_alteracao,@userid)", Parametros);
                try {
                    db.SaveChanges();
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #2
0
 public Exception Incluir_CepDB(Cepdb Reg)
 {
     using (var db = new GTI_Context(_connection)) {
         object[] Parametros = new object[7];
         Parametros[0] = new SqlParameter {
             ParameterName = "@cep", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Cep
         };
         Parametros[1] = new SqlParameter {
             ParameterName = "@uf", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Uf
         };
         Parametros[2] = new SqlParameter {
             ParameterName = "@cidadecodigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Cidadecodigo
         };
         Parametros[3] = new SqlParameter {
             ParameterName = "@bairrocodigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Bairrocodigo
         };
         Parametros[4] = new SqlParameter {
             ParameterName = "@logradouro", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Logradouro
         };
         Parametros[5] = new SqlParameter {
             ParameterName = "@func", SqlDbType = SqlDbType.Bit, SqlValue = Reg.Func
         };
         Parametros[6] = new SqlParameter {
             ParameterName = "@userid", SqlDbType = SqlDbType.Int, SqlValue = Reg.Userid
         };
         db.Database.ExecuteSqlCommand("INSERT INTO cepdb(cep,uf,cidadecodigo,bairrocodigo,logradouro,func,userid) " +
                                       " VALUES(@cep,@uf,@cidadecodigo,@bairrocodigo,@logradouro,@func,@userid)", Parametros);
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #3
0
        public Exception Insert_W_Imovel_Testada(WImovel_Testada Reg)
        {
            using (var db = new GTI_Context(_connection)) {
                db.Database.CommandTimeout = 180;
                object[] Parametros = new object[3];

                Parametros[0] = new SqlParameter {
                    ParameterName = "@guid", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Guid
                };
                Parametros[1] = new SqlParameter {
                    ParameterName = "@face", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Face
                };
                Parametros[2] = new SqlParameter {
                    ParameterName = "@comprimento", SqlDbType = SqlDbType.Decimal, SqlValue = Reg.Comprimento
                };

                db.Database.ExecuteSqlCommand("INSERT INTO wimovel_testada(guid,face,comprimento) VALUES(@guid,@face,@comprimento)", Parametros);
                try {
                    db.SaveChanges();
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #4
0
        public Exception Insert_W_Imovel_Prop(WImovel_Prop Reg)
        {
            using (var db = new GTI_Context(_connection)) {
                db.Database.CommandTimeout = 180;
                object[] Parametros = new object[5];

                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 = "@nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Nome
                };
                Parametros[3] = new SqlParameter {
                    ParameterName = "@tipo", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Tipo
                };
                Parametros[4] = new SqlParameter {
                    ParameterName = "@principal", SqlDbType = SqlDbType.Bit, SqlValue = Reg.Principal
                };

                db.Database.ExecuteSqlCommand("INSERT INTO wimovel_prop(guid,codigo,nome,tipo,principal) VALUES(@guid,@codigo,@nome,@tipo,@principal)", Parametros);
                try {
                    db.SaveChanges();
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #5
0
        private Gti000 Create_GTI_Setting(int UserId, string Path)
        {
            string _path = System.IO.Path.Combine(Path + "\\Report");

            using (var db = new GTI_Context(_connection)) {
                object[] Parametros = new object[2];
                Parametros[0] = new SqlParameter {
                    ParameterName = "@userid", SqlDbType = SqlDbType.Int, SqlValue = UserId
                };
                Parametros[1] = new SqlParameter {
                    ParameterName = "@path_report", SqlDbType = SqlDbType.VarChar, SqlValue = _path
                };
                db.Database.ExecuteSqlCommand("INSERT INTO gti000(userid,path_report) VALUES(@userid,@path_report)", Parametros);
                try {
                    db.SaveChanges();
                } catch {
                    throw;
                }
            }

            Gti000 reg = new Gti000()
            {
                UserId      = UserId,
                Path_Report = _path
            };

            return(reg);
        }
Example #6
0
 public void DeleteEmployee(int id)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         employees b = db.Employees.First(i => i.Id == id);
         db.Employees.Remove(b);
         db.SaveChanges();
     }
 }
Example #7
0
 public Exception Excluir_W_Imovel_Codigo(int Codigo)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         try {
             db.WImovel_Main.RemoveRange(db.WImovel_Main.Where(i => i.Codigo == Codigo));
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #8
0
 public Exception Excluir_W_Imovel_Historico_Guid(string guid)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         try {
             db.WImovel_Historico.RemoveRange(db.WImovel_Historico.Where(i => i.Guid == guid));
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #9
0
 public Exception Incluir_observacao_cidadao(obscidadao reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         db.Obscidadao.Add(reg);
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #10
0
 public Exception Excluir_W_Imovel_Historico_Seq(string guid, int seq)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         try {
             WImovel_Historico b = db.WImovel_Historico.Find(db.WImovel_Historico.Where(i => i.Guid == guid && i.Seq == seq));
             db.WImovel_Historico.Remove(b);
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #11
0
 public Exception Excluir_W_Imovel_Testada_Codigo(string guid, int codigo)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         try {
             WImovel_Testada b = db.WImovel_Testada.Find(db.WImovel_Testada.Where(i => i.Guid == guid && i.Face == codigo));
             db.WImovel_Testada.Remove(b);
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #12
0
 public Exception Excluir_cidadao(int Codigo)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         try {
             Cidadao b = db.Cidadao.First(i => i.Codcidadao == Codigo);
             db.Cidadao.Remove(b);
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #13
0
 public Exception Alterar_Profissao(Profissao reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         try {
             int       _id_profissao = reg.Codigo;
             Profissao b             = db.Profissao.First(i => i.Codigo == _id_profissao);
             b.Nome = reg.Nome;
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #14
0
 public Exception Excluir_Profissao(Profissao reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         int       _id_profissao = reg.Codigo;
         Profissao b             = db.Profissao.First(i => i.Codigo == _id_profissao);
         try {
             db.Profissao.Remove(b);
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #15
0
 public Exception Excluir_Pais(Pais reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         int  nCodPais = reg.Id_pais;
         Pais b        = db.Pais.First(i => i.Id_pais == nCodPais);
         try {
             db.Pais.Remove(b);
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #16
0
 public Exception Alterar_Senha(Usuario reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         string  sLogin = reg.Nomelogin;
         Usuario b      = db.Usuario.First(i => i.Nomelogin == sLogin);
         b.Senha2 = reg.Senha2;
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #17
0
 public Exception SaveUserBinary(Usuario reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         int     nId = (int)reg.Id;
         Usuario b   = db.Usuario.First(i => i.Id == nId);
         b.Userbinary = reg.Userbinary;
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #18
0
        public Exception Insert_W_Imovel_Endereco(WImovel_Endereco Reg)
        {
            using (var db = new GTI_Context(_connection)) {
                db.Database.CommandTimeout = 180;
                object[] Parametros = new object[8];

                Parametros[0] = new SqlParameter {
                    ParameterName = "@guid", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Guid
                };
                Parametros[1] = new SqlParameter {
                    ParameterName = "@logradouro_codigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Logradouro_codigo
                };
                Parametros[2] = new SqlParameter {
                    ParameterName = "@logradouro_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Logradouro_nome
                };
                Parametros[3] = new SqlParameter {
                    ParameterName = "@numero", SqlDbType = SqlDbType.SmallInt, SqlValue = Reg.Numero
                };
                if (Reg.Complemento != null)
                {
                    Parametros[4] = new SqlParameter {
                        ParameterName = "@complemento", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Complemento
                    }
                }
                ;
                else
                {
                    Parametros[4] = new SqlParameter {
                        ParameterName = "@complemento", SqlValue = DBNull.Value
                    }
                };
                Parametros[5] = new SqlParameter {
                    ParameterName = "@bairro_codigo", SqlDbType = SqlDbType.Int, SqlValue = Reg.Bairro_codigo
                };
                Parametros[6] = new SqlParameter {
                    ParameterName = "@bairro_nome", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Bairro_nome
                };
                Parametros[7] = new SqlParameter {
                    ParameterName = "@cep", SqlDbType = SqlDbType.VarChar, SqlValue = Reg.Cep
                };

                db.Database.ExecuteSqlCommand("INSERT INTO wimovel_endereco(guid,logradouro_codigo,logradouro_nome,numero,complemento,bairro_codigo,bairro_nome,cep) VALUES(@guid,@logradouro_codigo,@logradouro_nome,@numero,@complemento,@bairro_codigo,@bairro_nome,@cep)", Parametros);
                try {
                    db.SaveChanges();
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #19
0
 public Exception Alterar_Cidade(Cidade reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         string sUF        = reg.Siglauf;
         int    nCodCidade = reg.Codcidade;
         Cidade b          = db.Cidade.First(i => i.Siglauf == sUF && i.Codcidade == nCodCidade);
         b.Desccidade = reg.Desccidade;
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #20
0
 public Exception Alterar_Situacao(string Guid, short NovaSituacao, int User)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         try {
             Mobreq_main b = db.Mobreq_Main.First(i => i.Guid == Guid);
             b.Situacao     = NovaSituacao;
             b.UserId2      = User;
             b.Data_Evento2 = DateTime.Now;
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #21
0
 public Exception Incluir_profissao(Profissao reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         var maxCod = (from p in db.Profissao select p.Codigo).Max();
         int nMax   = Convert.ToInt32(maxCod + 1);
         reg.Codigo = nMax;
         db.Profissao.Add(reg);
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #22
0
        public Exception Alterar_cidadao(Cidadao reg)
        {
            using (GTI_Context db = new GTI_Context(_connection)) {
                Cidadao b = db.Cidadao.First(i => i.Codcidadao == reg.Codcidadao);
                b.Nomecidadao     = reg.Nomecidadao;
                b.Rg              = reg.Rg;
                b.Juridica        = reg.Juridica;
                b.Cnpj            = reg.Cnpj;
                b.Cpf             = reg.Cpf;
                b.Data_nascimento = reg.Data_nascimento;
                b.Codprofissao    = reg.Codprofissao;

                b.Etiqueta      = reg.Etiqueta;
                b.Codlogradouro = reg.Codlogradouro;
                b.Numimovel     = reg.Numimovel;
                b.Complemento   = reg.Complemento;
                b.Codbairro     = reg.Codbairro;
                b.Codcidade     = reg.Codcidade;
                b.Siglauf       = reg.Siglauf;
                b.Cep           = reg.Cep;
                b.Pais          = reg.Pais;
                b.Telefone      = reg.Telefone;
                b.Email         = reg.Email;
                b.Temfone       = reg.Temfone;
                b.Whatsapp      = reg.Whatsapp;

                b.Etiqueta2      = reg.Etiqueta2;
                b.Codlogradouro2 = reg.Codlogradouro2;
                b.Numimovel2     = reg.Numimovel2;
                b.Complemento2   = reg.Complemento2;
                b.Codbairro2     = reg.Codbairro2;
                b.Codcidade2     = reg.Codcidade2;
                b.Siglauf2       = reg.Siglauf2;
                b.Cep2           = reg.Cep2;
                b.Pais2          = reg.Pais2;
                b.Telefone2      = reg.Telefone2;
                b.Email2         = reg.Email2;
                b.Temfone2       = reg.Temfone2;
                b.Whatsapp2      = reg.Whatsapp2;

                try {
                    db.SaveChanges();
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            }
        }
Example #23
0
 public Exception Alterar_Usuario(Usuario reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         Usuario b = db.Usuario.First(i => i.Id == reg.Id);
         b.Nomecompleto = reg.Nomecompleto;
         b.Nomelogin    = reg.Nomelogin;
         b.Setor_atual  = reg.Setor_atual;
         b.Ativo        = reg.Ativo;
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #24
0
 public Exception UpdateEmployee(int id, employees employee)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         employees b = db.Employees.First(i => i.Id == id);
         b.FirstName = employee.FirstName;
         b.LastName  = employee.LastName;
         b.Gender    = employee.Gender;
         b.Salary    = employee.Salary;
         try {
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #25
0
 public Exception Excluir_Bairro(Bairro reg)
 {
     using (GTI_Context db = new GTI_Context(_connection)) {
         string sUF        = reg.Siglauf;
         int    nCodCidade = reg.Codcidade;
         int    nCodBairro = reg.Codbairro;
         Bairro b          = db.Bairro.First(i => i.Siglauf == sUF && i.Codcidade == nCodCidade && i.Codbairro == nCodBairro);
         try {
             db.Bairro.Remove(b);
             db.SaveChanges();
         } catch (Exception ex) {
             return(ex);
         }
         return(null);
     }
 }
Example #26
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 #27
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 #28
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 #29
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 #30
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);
     }
 }