import diamondedge.util.*;
import diamondedge.ado.*;
import diamondedge.vb.*;
import java.awt.*;
import java.awt.event.*;

public class CreditInfo extends AwtForm
             implements ActionListener
{
  public AwtLabel Label2 = new AwtLabel();
  public TextField txtStatus = new TextField();
  public AwtLabel Label3 = new AwtLabel();
  public AwtLine Line7 = new AwtLine();
  public TextField txtCCNumber = new TextField();
  public Choice cmbBank = new Choice();
  public AwtLabel Label4 = new AwtLabel();
  public AwtLabel Label5 = new AwtLabel();
  public Button cmdCancel = new Button();
  public AwtLine Line1 = new AwtLine();
  public AwtLine Line2 = new AwtLine();
  public AwtLine Line4 = new AwtLine();
  public AwtLabel Label1 = new AwtLabel();
  public AwtLine Line5 = new AwtLine();
  public Button cmdValidate = new Button();
  public Checkbox optCCard[] = new Checkbox[3];

  public CreditInfo()
  {
  }

  public void initialize()
  {
    if( initialized )
      return;
    try
    {
      setLayout( null );
      setName( "CreditInfo" );
      setTitle( "CreditInfo" );
      //unsup LinkTopic = "Form1";
      //unsup PaletteMode = 1;
      setScaleHeight( 6795 );
      setScaleWidth( 3630 );
      setFormLocation( 189, 106 );
      setSize( 242, 453 );
      setFormSize( 242, 453 );

      txtStatus.setName( "txtStatus" );
      add( txtStatus );
      //unsup txtStatus.FontUnderline = false;
      //unsup txtStatus.FontStrikethrough = false;
      //unsup txtStatus.TabIndex = 11;
      txtStatus.setText( "Pending" );
      txtStatus.setVisible( true );
      txtStatus.setLocation( 40, 368 );
      txtStatus.setSize( 161, 25 );
      txtStatus.setFont( new Font("SansSerif", Font.PLAIN, 12) );

      cmbBank.setName( "cmbBank" );
      add( cmbBank );
      //unsup cmbBank.TabIndex = 9;
      cmbBank.setVisible( true );
      initializeList( cmbBank, new String[] { "Advanta", "Capitol One", "Citibank", "Chase Manhattan", "CoreStates", "NatWest", "Other" } );
      cmbBank.setLocation( 40, 296 );
      cmbBank.setSize( 161, 21 );

      cmdCancel.setName( "cmdCancel" );
      add( cmdCancel );
      cmdCancel.setLabel( "Cancel" );
      //unsup cmdCancel.FontUnderline = false;
      //unsup cmdCancel.FontStrikethrough = false;
      //unsup cmdCancel.TabIndex = 8;
      cmdCancel.setVisible( true );
      cmdCancel.setLocation( 144, 416 );
      cmdCancel.setSize( 81, 33 );
      cmdCancel.setFont( new Font("SansSerif", Font.BOLD, 12) );

      cmdValidate.setName( "cmdValidate" );
      add( cmdValidate );
      cmdValidate.setLabel( "Validate" );
      //unsup cmdValidate.FontUnderline = false;
      //unsup cmdValidate.FontStrikethrough = false;
      //unsup cmdValidate.TabIndex = 7;
      cmdValidate.setVisible( true );
      cmdValidate.setLocation( 16, 416 );
      cmdValidate.setSize( 81, 33 );
      cmdValidate.setFont( new Font("SansSerif", Font.BOLD, 12) );

      txtCCNumber.setName( "txtCCNumber" );
      add( txtCCNumber );
      //unsup txtCCNumber.FontUnderline = false;
      //unsup txtCCNumber.FontStrikethrough = false;
      //unsup txtCCNumber.TabIndex = 3;
      txtCCNumber.setVisible( true );
      txtCCNumber.setText( "" );
      txtCCNumber.setLocation( 40, 96 );
      txtCCNumber.setSize( 161, 25 );
      txtCCNumber.setFont( new Font("SansSerif", Font.PLAIN, 12) );

      if( optCCard[2] == null )
        optCCard[2] = new Checkbox();
      optCCard[2].setName( "optCCard[2]" );
      addExclusiveButton( optCCard[2] );
      optCCard[2].setLabel( "American Express" );
      //unsup optCCard[2].FontUnderline = false;
      //unsup optCCard[2].FontStrikethrough = false;
      //unsup optCCard[2].TabIndex = 2;
      optCCard[2].setVisible( true );
      optCCard[2].setLocation( 40, 224 );
      optCCard[2].setSize( 161, 17 );
      optCCard[2].setFont( new Font("SansSerif", Font.PLAIN, 12) );

      if( optCCard[1] == null )
        optCCard[1] = new Checkbox();
      optCCard[1].setName( "optCCard[1]" );
      addExclusiveButton( optCCard[1] );
      optCCard[1].setLabel( "Mastercard" );
      //unsup optCCard[1].FontUnderline = false;
      //unsup optCCard[1].FontStrikethrough = false;
      //unsup optCCard[1].TabIndex = 1;
      optCCard[1].setVisible( true );
      optCCard[1].setLocation( 40, 200 );
      optCCard[1].setSize( 153, 19 );
      optCCard[1].setFont( new Font("SansSerif", Font.PLAIN, 12) );

      if( optCCard[0] == null )
        optCCard[0] = new Checkbox();
      optCCard[0].setName( "optCCard[0]" );
      addExclusiveButton( optCCard[0] );
      optCCard[0].setLabel( "Visa" );
      //unsup optCCard[0].FontUnderline = false;
      //unsup optCCard[0].FontStrikethrough = false;
      //unsup optCCard[0].TabIndex = 0;
      optCCard[0].setVisible( true );
      optCCard[0].setLocation( 40, 176 );
      optCCard[0].setSize( 97, 17 );
      optCCard[0].setFont( new Font("SansSerif", Font.PLAIN, 12) );

      Line1.setName( "Line1" );
      add( Line1 );
      Line1.setLineColor( Color.blue );
      Line1.setX1( 240 );
      Line1.setX2( 3360 );
      Line1.setY1( 600 );
      Line1.setY2( 600 );
      Line1.setVisible( true );

      Line7.setName( "Line7" );
      add( Line7 );
      Line7.setLineColor( Color.red );
      Line7.setX1( 600 );
      Line7.setX2( 3000 );
      Line7.setY1( 5400 );
      Line7.setY2( 5400 );
      Line7.setVisible( true );

      Line5.setName( "Line5" );
      add( Line5 );
      Line5.setLineColor( Color.red );
      Line5.setX1( 600 );
      Line5.setX2( 3000 );
      Line5.setY1( 4300 );
      Line5.setY2( 4300 );
      Line5.setVisible( true );

      Line4.setName( "Line4" );
      add( Line4 );
      Line4.setLineColor( Color.red );
      Line4.setX1( 600 );
      Line4.setX2( 3000 );
      Line4.setY1( 2520 );
      Line4.setY2( 2520 );
      Line4.setVisible( true );

      Line2.setName( "Line2" );
      add( Line2 );
      Line2.setLineColor( Color.red );
      Line2.setX1( 600 );
      Line2.setX2( 3000 );
      Line2.setY1( 1320 );
      Line2.setY2( 1320 );
      Line2.setVisible( true );

      Label5.setName( "Label5" );
      add( Label5 );
      Label5.setAlignment( AwtLabel.CENTER );
      Label5.setText( "Status:" );
      //unsup Label5.FontUnderline = false;
      //unsup Label5.FontStrikethrough = false;
      //unsup Label5.TabIndex = 12;
      Label5.setVisible( true );
      Label5.setLocation( 40, 336 );
      Label5.setSize( 161, 17 );
      Label5.setFont( new Font("SansSerif", Font.BOLD|Font.ITALIC, 14) );

      Label4.setName( "Label4" );
      add( Label4 );
      Label4.setAlignment( AwtLabel.CENTER );
      Label4.setText( "Issuing Bank:" );
      //unsup Label4.FontUnderline = false;
      //unsup Label4.FontStrikethrough = false;
      //unsup Label4.TabIndex = 10;
      Label4.setVisible( true );
      Label4.setLocation( 40, 264 );
      Label4.setSize( 161, 20 );
      Label4.setFont( new Font("SansSerif", Font.BOLD|Font.ITALIC, 14) );

      Label3.setName( "Label3" );
      add( Label3 );
      Label3.setAlignment( AwtLabel.CENTER );
      Label3.setText( "Credit Card Type:" );
      //unsup Label3.FontUnderline = false;
      //unsup Label3.FontStrikethrough = false;
      //unsup Label3.TabIndex = 6;
      Label3.setVisible( true );
      Label3.setLocation( 40, 144 );
      Label3.setSize( 161, 17 );
      Label3.setFont( new Font("SansSerif", Font.BOLD|Font.ITALIC, 14) );

      Label2.setName( "Label2" );
      add( Label2 );
      Label2.setAlignment( AwtLabel.CENTER );
      Label2.setText( "Credit Card Validation" );
      //unsup Label2.FontUnderline = false;
      //unsup Label2.FontStrikethrough = false;
      //unsup Label2.TabIndex = 5;
      Label2.setVisible( true );
      Label2.setLocation( 8, 8 );
      Label2.setSize( 225, 25 );
      Label2.setFont( new Font("SansSerif", Font.BOLD, 16) );

      Label1.setName( "Label1" );
      add( Label1 );
      Label1.setAlignment( AwtLabel.CENTER );
      Label1.setText( "Credit Card Numer:" );
      //unsup Label1.FontUnderline = false;
      //unsup Label1.FontStrikethrough = false;
      //unsup Label1.TabIndex = 4;
      Label1.setVisible( true );
      Label1.setLocation( 24, 64 );
      Label1.setSize( 193, 17 );
      Label1.setFont( new Font("SansSerif", Font.BOLD|Font.ITALIC, 14) );
    }
    catch(Exception _e_) { Err.set(_e_,"CreditInfo"); }

    if( !unloaded )
      enableEvents();
    super.initialize();
    initialized = true;
  }

  // methods

  public void Form_Load()
  {
    try
    {

      txtStatus.setEditable( !true );
      optCCard[0].setState( true );
      cmbBank.select( "Advanta" );

    }
    catch(Exception _e_) { Err.set(_e_,"Form_Load"); }
  }

  // events

  private void cmdCancel_Click()
  {
    try
    {

      optCCard[0].setState( true );
      cmbBank.select( "Advanta" );
      txtCCNumber.setText( "" );
      txtStatus.setText( "Pending" );

    }
    catch(Exception _e_) { Err.set(_e_,"cmdCancel_Click"); }
  }

  private void cmdValidate_Click()
  {
    try
    {

      if( optCCard[0].getState() == true )
      {
        txtStatus.setText( "Approved" );
      }
      else
      {
        txtStatus.setText( "Declined" );
      }

    }
    catch(Exception _e_) { Err.set(_e_,"cmdValidate_Click"); }
  }

  // implementation of Listener interfaces

  public void actionPerformed( ActionEvent e )
  {
    if( e.getSource() == cmdCancel )
    {
      cmdCancel_Click();
    }
    else if( e.getSource() == cmdValidate )
    {
      cmdValidate_Click();
    }
  }

  public void enableEvents()
  {
    cmdCancel.addActionListener( this );
    cmdValidate.addActionListener( this );
  }
}