Exemple #1
0
        public User GetUser(string name)
        {
            User       item = null;
            SqlCommand cmd  = new SqlCommand("dbo.uspGetUserByName", DbsConnections.SqlBCApp);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(DbsSqlParams.Direct("@Name", SqlDbType.VarChar, name));

            if (cmd.Connection.State != ConnectionState.Open)
            {
                cmd.Connection.Open();
            }
            SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            if (reader.Read())
            {
                item = new User()
                {
                    IdUsuario = reader.GetInt32(reader.GetOrdinal("IdUsuario")),
                    Nombre    = reader.GetString(reader.GetOrdinal("Nombre")),
                    Apellido  = reader.GetString(reader.GetOrdinal("Apellido")),
                    Password  = reader.GetString(reader.GetOrdinal("Password"))
                };
            }
            reader.Close();
            return(item);
        }
Exemple #2
0
        public static bool GetAuth(string Name, string NameP)
        {
            var command = new SqlCommand("uspAuth", DbsConnections.SqlBCApp)
            {
                CommandType = CommandType.StoredProcedure
            };

            command.Parameters.Add(DbsSqlParams.Direct("@Name", SqlDbType.VarChar, Name));
            command.Parameters.Add(DbsSqlParams.Direct("@NameP", SqlDbType.VarChar, NameP));

            return(DbsSqlOperations.GetInt(command) == 1);
        }