Esempio n. 1
0
 public static User Login(User objUser)
 {
     SqlDatabase db = ConfigDAO.CreateDB();
     User objReturn = null;
     using (DbConnection connection = db.CreateConnection())
     {
         connection.Open();
         try
         {
             DbCommand dbCommand = db.GetStoredProcCommand("PR_GER_UsuarioLogin_SEL");
             dbCommand.CommandTimeout = ConfigDAO.CommmandTimeout;
             db.AddInParameter(dbCommand, "@nom_Email", DbType.String, objUser.Email);
             db.AddInParameter(dbCommand, "@nom_Senha", DbType.String, objUser.Password);
             using (DataSet dsRetorno = db.ExecuteDataSet(dbCommand))
             {
                 objReturn = FromDataRow(dsRetorno.Tables[0].Rows[0]);
             }
         }
         catch
         {
             objReturn.Id = -1;
         }
         finally
         {
             connection.Close();
         }
     }
     return objReturn;
 }
Esempio n. 2
0
       public static void Insert(User objUser, Permission objPermition)
       {
           SqlDatabase db = ConfigDAO.CreateDB();


           using (DbConnection connection = db.CreateConnection())
           {
               
               try
               {
                   connection.Open();
                   DbCommand dbCommand = db.GetStoredProcCommand("PR_GER_ELOSLog_INS");

                   db.AddInParameter(dbCommand, "@cod_Usuario", SqlDbType.Int, objUser.Id);
                   db.AddInParameter(dbCommand, "@cod_Modulo", SqlDbType.Int, objPermition.Module.Id);
                   db.AddInParameter(dbCommand, "@nom_Action", SqlDbType.VarChar, objPermition.Action);
                   db.AddInParameter(dbCommand, "@nom_Controller", SqlDbType.VarChar, objPermition.Controller);
                   db.AddInParameter(dbCommand, "@nom_ParametroLog", SqlDbType.VarChar, objPermition.ParametersLog);


                   dbCommand.CommandTimeout = ConfigDAO.CommmandTimeout;

                   db.ExecuteNonQuery(dbCommand);
               }
               catch { }
               finally
               {
                   connection.Close();
               }
           }

       }
Esempio n. 3
0
       private static User FromDataRow(DataRow dr)
       {
           User objUser = new User();

           objUser.Id = Convert.ToInt32(dr["cod_Usuario"]);

           objUser.Email = dr["nom_Email"].ToString();
           objUser.Name = dr["nom_Usuario"].ToString();

           return objUser;
       }
Esempio n. 4
0
 public static Permission SelectByUser(User objUser, Permission objPermition)
 {
     SqlDatabase db = ConfigDAO.CreateDB();
     IDataReader dr = null;
     using (DbConnection connection = db.CreateConnection())
     {
        
         try
         {
             connection.Open();
             DbCommand dbCommand = db.GetStoredProcCommand("PR_GER_Permissao_SEL_ByUsuario");
             dbCommand.CommandTimeout = ConfigDAO.CommmandTimeout;
             db.AddInParameter(dbCommand, "@cod_Usuario", SqlDbType.Int, objUser.Id);
             db.AddInParameter(dbCommand, "@nom_Action", SqlDbType.VarChar, objPermition.Action);
             db.AddInParameter(dbCommand, "@nom_Controller", SqlDbType.VarChar, objPermition.Controller);
             db.AddInParameter(dbCommand, "@cod_Modulo", SqlDbType.Int, objPermition.Module.Id);
             dr = db.ExecuteReader(dbCommand);
             if (dr.Read())
             {
                 objPermition.Value = dr.GetInt32(0);
                 objPermition.Module = new Module { Id = dr.GetInt32(1) };
                 objPermition.Name = Convert.IsDBNull(dr[2]) ? string.Empty : dr.GetString(2);
                 objPermition.Description = Convert.IsDBNull(dr[3]) ? string.Empty : dr.GetString(3);
             }
         }
         catch
         {
             objPermition.Value = 0;
             objPermition.Module = new Module { Id = 0 };
         }
         finally
         {
             if (dr != null && !dr.IsClosed)
             {
                 dr.Close();
                 dr.Dispose();
             }
             connection.Close();
         }
     }
     return objPermition;
 }
Esempio n. 5
0
 public static User Login(User objUser)
 {
     return UserDAO.Login(objUser);
 }
Esempio n. 6
0
        public static void Insert(User objUser, Permission objPermition)
        {

            LogDAO.Insert(objUser, objPermition);

        }
Esempio n. 7
0
 public static Permission SelectByUser(User objUser, Permission objPermition)
 {
     return PermitionDAO.SelectByUser(objUser, objPermition);
 }