home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / bit.pm < prev    next >
Encoding:
Text File  |  2001-11-05  |  1.9 KB  |  75 lines

  1. ############################################################################
  2. #
  3. # Win32::ASP::Field::bit - implements bit fields in the Win32-ASP-DB system
  4. #
  5. # Author: Toby Everett
  6. # Revision: 0.02
  7. # Last Change:
  8. ############################################################################
  9. # Copyright 1999, 2000 Toby Everett.  All rights reserved.
  10. #
  11. # This file is distributed under the Artistic License. See
  12. # http://www.ActiveState.com/corporate/artistic_license.htm or
  13. # the license that comes with your perl distribution.
  14. #
  15. # For comments, questions, bugs or general interest, feel free to
  16. # contact Toby Everett at teverett@alascom.att.com
  17. ############################################################################
  18.  
  19. use Win32::ASP::Field;
  20. use Error qw/:try/;
  21. use Win32::ASP::Error;
  22.  
  23. package Win32::ASP::Field::bit;
  24.  
  25. @ISA = ('Win32::ASP::Field');
  26.  
  27. use strict;
  28.  
  29. sub _check_value {
  30.   my $self = shift;
  31.   my($value) = @_;
  32.  
  33.   if ($value ne '0' and $value ne '1') {
  34.     throw Win32::ASP::Error::Field::bad_value (field => $self, bad_value => $value,
  35.         error => "The value is not a bit value.");
  36.   }
  37.  
  38.   $self->SUPER::_check_value($value);
  39. }
  40.  
  41. sub _as_html_view {
  42.   my $self = shift;
  43.   my($record, $data) = @_;
  44.  
  45.   my $value = $record->{$data}->{$self->name};
  46.   return $value ? 'Yes' : 'No';
  47. }
  48.  
  49. sub _as_html_edit_rw {
  50.   my $self = shift;
  51.   my($record, $data) = @_;
  52.  
  53.   my $formname = $self->formname;
  54.   my $value = $record->{$data}->{$self->name};
  55.   my $help = $self->as_html_mouseover($record, $data);
  56.  
  57.   my $yes = $value ? 'CHECKED' : '';
  58.   my $no =  $value ? '' : 'CHECKED';
  59.   chomp(my $retval = <<ENDHTML);
  60. <INPUT $yes NAME="$formname" TYPE="radio" VALUE="1" $help>Yes
  61. <INPUT $no  NAME="$formname" TYPE="radio" VALUE="0" $help>No
  62. ENDHTML
  63.   return $retval;
  64. }
  65.  
  66. sub _as_sql {
  67.   my $self = shift;
  68.   my($value) = @_;
  69.  
  70.   $self->check_value($value);
  71.   return $value;
  72. }
  73.  
  74. 1;
  75.