示例#1
0
 public bool verifica_usuario_existe(cUsuario user)
 {
     try
     {
         #region QUERY
         cGlobal.query = "SELECT LOGIN FROM USUARIO_TB WHERE LOGIN = '******' ";
         using (DataTable dt = dao.retorna_datatable(cGlobal.query))
         {
             if (dt.Rows.Count == 0)
             {
                 return(false);
             }
             else
             {
                 cGlobal.userlogado = (dt.Rows[0]).ItemArray[0].ToString();
                 return(true);
             }
         }
         #endregion
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#2
0
 public void grava_acesso(cUsuario user)
 {
     try
     {
         #region QUERY
         cGlobal.query = "INSERT INTO USUARIO_TB (USUARIO," +
                         "EMAIL," +
                         "LOGIN," +
                         "PWD," +
                         "DTCAD," +
                         "RESET_PWD," +
                         "ADM," +
                         "ATIVO," +
                         "ID_SETOR)" +
                         "VALUES('" + user.usuario + "', " +
                         "'" + user.email + "', " +
                         "'" + user.login + "', " +
                         "'" + user.senha + "', " +
                         "'" + user.dtcad + "'," +
                         "0," +
                         "0," +
                         "0," +
                         "1)";
         dao.executa_query(cGlobal.query);
         #endregion
     }
     catch (OleDbException ex)
     {
         throw ex;
     }
 }
示例#3
0
 public bool valida_login(cUsuario user)
 {
     try
     {
         #region QUERY
         cGlobal.query = "SELECT TB1.LOGIN, TB2.SETOR FROM USUARIO_TB TB1, SETOR_TB TB2 " +
                         "WHERE TB2.ID_SETOR = TB1.ID_SETOR " +
                         "AND TB1.LOGIN = '******' " +
                         "AND TB1.PWD = '" + user.senha + "' ";
         using (DataTable dt = dao.retorna_datatable(cGlobal.query))
         {
             if (dt.Rows.Count == 0)
             {
                 return(false);
             }
             else
             {
                 cGlobal.userlogado = (dt.Rows[0]).ItemArray[0].ToString();
                 cGlobal.userSetor  = (dt.Rows[0]).ItemArray[1].ToString();
                 return(true);
             }
         }
         #endregion
     }
     catch (OleDbException ex)
     {
         throw ex;
     }
 }
示例#4
0
 public void exclui_usuario(cUsuario user)
 {
     try
     {
         #region QUERY
         cGlobal.query = "DELETE FROM USUARIO_TB WHERE ID_USUARIO = " + user.id_usuario + " ";
         dao.executa_query(cGlobal.query);
         #endregion
     }
     catch (OleDbException ex)
     {
         throw ex;
     }
 }
示例#5
0
 public void grava_alteracao_senha(cUsuario user)
 {
     try
     {
         #region QUERY
         cGlobal.query = "UPDATE USUARIO_TB SET PWD = '" + user.senha + "'," +
                         "RESET_PWD = 0 " +
                         "WHERE ID_USUARIO = " + user.id_usuario + " ";
         dao.executa_query(cGlobal.query);
         #endregion
     }
     catch (OleDbException ex)
     {
         throw ex;
     }
 }
示例#6
0
 public bool verifica_reset_senha(cUsuario user)
 {
     #region RETORNA LINHA AFETADA
     cGlobal.query = "SELECT * FROM USUARIO_TB WHERE LOGIN = '******' AND PWD = '" + user.senha + "' AND RESET_PWD = -1 ";
     using (DataTable dt = dao.retorna_datatable(cGlobal.query))
     {
         if (dt.Rows.Count == 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     #endregion
 }
示例#7
0
 //public List<cPermissao> retorna_permissoes(cUsuario user)
 //{
 //    List<cPermissao> per = new List<cPermissao>();
 //    per.Clear();
 //    try
 //    {
 //        cGlobal.query = "SELECT * FROM USUARIO_TB WHERE LOGIN = '******' ";
 //        using (OleDbCommand cmd = new OleDbCommand(cmdText: cGlobal.query, connection: cDAO.abre_conexao()))
 //        {
 //            cmd.CommandTimeout = 120;
 //            cmd.CommandType = CommandType.Text;
 //            using (OleDbDataReader dr = cmd.ExecuteReader())
 //            {
 //                while (dr.Read())
 //                {
 //                    per.Add(new cPermissao(Convert.ToBoolean(dr["CAD_EVENTO"].ToString()),
 //                                           Convert.ToBoolean(dr["APR_EVENTO"].ToString()),
 //                                           Convert.ToBoolean(dr["CAD_CLIENTE"].ToString()),
 //                                           Convert.ToBoolean(dr["CRONOGRAMA"].ToString()),
 //                                           Convert.ToBoolean(dr["PRODUTO"].ToString()),
 //                                           Convert.ToBoolean(dr["SUPORTE"].ToString())
 //                        ));
 //                }
 //            }
 //            cDAO.fecha_conexao();
 //        }
 //        return per.ToList();
 //    }
 //    catch (OleDbException ex)
 //    {
 //        throw ex;
 //    }
 //}
 public bool verifica_login_ativo(cUsuario user)
 {
     #region QUERY
     cGlobal.query = "SELECT * FROM USUARIO_TB WHERE LOGIN = '******' AND PWD = '" + user.senha + "' AND ATIVO = 0 ";
     using (DataTable dt = dao.retorna_datatable(cGlobal.query))
     {
         if (dt.Rows.Count == 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     #endregion
 }
示例#8
0
        public int retorna_id_usuario(cUsuario user)
        {
            try
            {
                #region RETORNO
                int id = 0;

                cGlobal.query = "SELECT ID_USUARIO FROM USUARIO_TB WHERE LOGIN = '******' AND PWD = '" + user.senha + "' ";
                using (DataTable dt = dao.retorna_datatable(cGlobal.query))
                {
                    return(id = int.Parse((dt.Rows[0]).ItemArray[0].ToString()));
                }
                #endregion
            }
            catch (OleDbException ex)
            {
                throw ex;
            }
        }
示例#9
0
 public void atualiza_cadastro_usuario(cUsuario user, bool altsenha)
 {
     try
     {
         #region QUERY
         if (!altsenha)
         {
             cGlobal.query = "UPDATE USUARIO_TB SET USUARIO = '" + user.usuario + "'," +
                             "EMAIL = '" + user.email + "'," +
                             "LOGIN = '******'," +
                             "RESET_PWD = " + user.reset_pwd + "," +
                             "ADM = " + user.adm + "," +
                             "ATIVO = " + user.ativo + "," +
                             "ID_SETOR = " + user.id_setor + "," +
                             "EXEC = " + user.exec + "," +
                             "RPT = " + user.rpt + " " +
                             "WHERE ID_USUARIO = " + user.id_usuario + " ";
         }
         else
         {
             cGlobal.query = "UPDATE USUARIO_TB SET USUARIO = '" + user.usuario + "'," +
                             "EMAIL = '" + user.email + "'," +
                             "LOGIN = '******'," +
                             "PWD = '" + user.senha + "'," +
                             "RESET_PWD = " + user.reset_pwd + "," +
                             "RPT = " + user.rpt + "," +
                             "ATIVO = " + user.ativo + "," +
                             "ID_SETOR = " + user.id_setor + "," +
                             "ADM = " + user.adm + "," +
                             "EXEC = " + user.exec + " " +
                             "WHERE ID_USUARIO = " + user.id_usuario + " ";
         }
         dao.executa_query(cGlobal.query);
         #endregion
     }
     catch (OleDbException ex)
     {
         throw ex;
     }
 }