home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / JDPUserSystemMaint.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-09  |  9.4 KB  |  406 lines

  1. import java.awt.BorderLayout;
  2. import java.awt.Button;
  3. import java.awt.Choice;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Event;
  7. import java.awt.Panel;
  8. import java.awt.TextField;
  9. import java.util.StringTokenizer;
  10. import java.util.Vector;
  11.  
  12. public class JDPUserSystemMaint extends JDPClassLayout {
  13.    JDPWhereClause jdpWhereClause;
  14.    JDPSearchResults searchResults;
  15.    String[] psortChoice;
  16.    String[] pdisplayChoice;
  17.    int itemIndex;
  18.    boolean insertRequested;
  19.    boolean deleteRequested;
  20.    JDPPopupMessage popuppanel;
  21.    JDPJagg jaggSQL;
  22.    TextField userid;
  23.    TextField username;
  24.    TextField firstname;
  25.    TextField lastname;
  26.    TextField status;
  27.    TextField jdpsystem0;
  28.    TextField jdpsystem1;
  29.    TextField jdpsystem2;
  30.    TextField jdpsystem3;
  31.    TextField jdpsystem4;
  32.    TextField jdpsystem5;
  33.    TextField jdpsystem6;
  34.    TextField jdpsystem7;
  35.    TextField jdpsystem8;
  36.    TextField jdpsystem9;
  37.    String pfromWhereClause;
  38.  
  39.    void newSearch() {
  40.       String var1 = this.pfromWhereClause + " AND " + this.jdpWhereClause.whereClause;
  41.       this.searchResults.setFromWhereClause(var1);
  42.       this.searchResults.clearList();
  43.       this.searchResults.loadList();
  44.    }
  45.  
  46.    void clearFields() {
  47.       this.userid.setText("");
  48.       this.username.setText("");
  49.       this.firstname.setText("");
  50.       this.lastname.setText("");
  51.       this.status.setText("");
  52.       this.jdpsystem0.setText("");
  53.       this.jdpsystem1.setText("");
  54.       this.jdpsystem2.setText("");
  55.       this.jdpsystem3.setText("");
  56.       this.jdpsystem4.setText("");
  57.       this.jdpsystem5.setText("");
  58.       this.jdpsystem6.setText("");
  59.       this.jdpsystem7.setText("");
  60.       this.jdpsystem8.setText("");
  61.       this.jdpsystem9.setText("");
  62.    }
  63.  
  64.    void loadData() {
  65.       int var2 = 0;
  66.       Vector var3 = new Vector();
  67.       String var4 = this.jaggSQL.getSEP();
  68.       this.itemIndex = this.searchResults.resultList.getSelectedIndex();
  69.       String var6 = "SELECT userid," + "username," + "firstname," + "lastname," + "status," + "jdpsystem0," + "jdpsystem1," + "jdpsystem2," + "jdpsystem3," + "jdpsystem4," + "jdpsystem5," + "jdpsystem6," + "jdpsystem7," + "jdpsystem8," + "jdpsystem9 FROM JDPUser WHERE userid=" + this.searchResults.recordKey0[this.itemIndex];
  70.       if (super.user.DEBUG) {
  71.          System.out.println("loadData SQL: " + var6);
  72.       }
  73.  
  74.       super.user.mainmsg.setStatusMsg("Accessing database...", 0);
  75.       var2 = this.jaggSQL.execSQL(var6, var3);
  76.       if (super.user.DEBUG) {
  77.          System.out.println("loadData CNT: " + Integer.toString(var2));
  78.       }
  79.  
  80.       if (var2 == -1) {
  81.          super.user.u.setSqlMessage(this.jaggSQL, var6);
  82.       } else {
  83.          if (var2 == 1) {
  84.             String var5 = (String)var3.elementAt(0);
  85.             if (var5 != null && var5.trim().compareTo("") != 0) {
  86.                StringTokenizer var1 = new StringTokenizer(var5);
  87.                this.userid.setText(var1.nextToken(var4).trim());
  88.                this.username.setText(var1.nextToken(var4).trim());
  89.                this.firstname.setText(var1.nextToken(var4).trim());
  90.                this.lastname.setText(var1.nextToken(var4).trim());
  91.                this.status.setText(var1.nextToken(var4).trim());
  92.                this.jdpsystem0.setText(var1.nextToken(var4).trim());
  93.                this.jdpsystem1.setText(var1.nextToken(var4).trim());
  94.                this.jdpsystem2.setText(var1.nextToken(var4).trim());
  95.                this.jdpsystem3.setText(var1.nextToken(var4).trim());
  96.                this.jdpsystem4.setText(var1.nextToken(var4).trim());
  97.                this.jdpsystem5.setText(var1.nextToken(var4).trim());
  98.                this.jdpsystem6.setText(var1.nextToken(var4).trim());
  99.                this.jdpsystem7.setText(var1.nextToken(var4).trim());
  100.                this.jdpsystem8.setText(var1.nextToken(var4).trim());
  101.                this.jdpsystem9.setText(var1.nextToken(var4).trim());
  102.             }
  103.  
  104.             super.user.mainmsg.clearStatusMsg();
  105.          } else {
  106.             super.user.mainmsg.setStatusMsg("Requested entry does not exist.", 10);
  107.             this.clearFields();
  108.          }
  109.  
  110.          String var7 = this.status.getText();
  111.          if (var7.compareTo("A") == 0) {
  112.             this.status.setText("Active");
  113.          }
  114.  
  115.          if (var7.compareTo("P") == 0) {
  116.             this.status.setText("Pending");
  117.          }
  118.  
  119.          if (var7.compareTo("S") == 0) {
  120.             this.status.setText("Suspended");
  121.          }
  122.  
  123.          if (var7.compareTo("C") == 0) {
  124.             this.status.setText("Cancelled");
  125.          }
  126.  
  127.          if (var7.compareTo("X") == 0) {
  128.             this.status.setText("Deleted");
  129.          }
  130.  
  131.          if (var7.compareTo("F") == 0) {
  132.             this.status.setText("Free");
  133.          }
  134.  
  135.          if (var7.compareTo("G") == 0) {
  136.             this.status.setText("Guest");
  137.          }
  138.  
  139.       }
  140.    }
  141.  
  142.    boolean saveData() {
  143.       int var1 = 0;
  144.       Vector var2 = new Vector();
  145.       this.jaggSQL.getSEP();
  146.       String var3 = "";
  147.       this.itemIndex = this.searchResults.resultList.getSelectedIndex();
  148.       if (this.itemIndex < 0) {
  149.          super.user.mainmsg.setStatusMsg("You must first make a selection", 5);
  150.          return false;
  151.       } else {
  152.          var3 = "UPDATE JDPUser SET " + "jdpsystem0 = '" + this.jdpsystem0.getText() + "', " + "jdpsystem1 = '" + this.jdpsystem1.getText() + "', " + "jdpsystem2 = '" + this.jdpsystem2.getText() + "', " + "jdpsystem3 = '" + this.jdpsystem3.getText() + "', " + "jdpsystem4 = '" + this.jdpsystem4.getText() + "', " + "jdpsystem5 = '" + this.jdpsystem5.getText() + "', " + "jdpsystem6 = '" + this.jdpsystem6.getText() + "', " + "jdpsystem7 = '" + this.jdpsystem7.getText() + "', " + "jdpsystem8 = '" + this.jdpsystem8.getText() + "', " + "jdpsystem9 = '" + this.jdpsystem9.getText() + "'" + " WHERE userid=" + this.searchResults.recordKey0[this.itemIndex];
  153.          if (super.user.DEBUG) {
  154.             System.out.println("saveData SQL: " + var3);
  155.          }
  156.  
  157.          super.user.mainmsg.setStatusMsg("Accessing database...", 0);
  158.          var1 = this.jaggSQL.execSQL(var3, var2);
  159.          if (super.user.DEBUG) {
  160.             System.out.println("saveData CNT: " + Integer.toString(var1));
  161.          }
  162.  
  163.          if (var1 == -1) {
  164.             super.user.u.setSqlMessage(this.jaggSQL, var3);
  165.             return false;
  166.          } else {
  167.             if (var1 == 1) {
  168.                super.user.mainmsg.setStatusMsg("Record successfully updated.", 3);
  169.                this.insertRequested = false;
  170.                this.deleteRequested = false;
  171.             } else {
  172.                super.user.u.setSqlMessage(this.jaggSQL, var3);
  173.             }
  174.  
  175.             return true;
  176.          }
  177.       }
  178.    }
  179.  
  180.    boolean checkFields() {
  181.       return true;
  182.    }
  183.  
  184.    public boolean handleEvent(Event var1) {
  185.       switch (var1.id) {
  186.          case 401:
  187.             if (var1.key == 9) {
  188.                if (var1.target.equals(this.jdpsystem0)) {
  189.                   super.user.u.cursor(this.jdpsystem1);
  190.                   return true;
  191.                }
  192.  
  193.                if (var1.target.equals(this.jdpsystem1)) {
  194.                   super.user.u.cursor(this.jdpsystem2);
  195.                   return true;
  196.                }
  197.  
  198.                if (var1.target.equals(this.jdpsystem2)) {
  199.                   super.user.u.cursor(this.jdpsystem3);
  200.                   return true;
  201.                }
  202.  
  203.                if (var1.target.equals(this.jdpsystem3)) {
  204.                   super.user.u.cursor(this.jdpsystem4);
  205.                   return true;
  206.                }
  207.  
  208.                if (var1.target.equals(this.jdpsystem4)) {
  209.                   super.user.u.cursor(this.jdpsystem5);
  210.                   return true;
  211.                }
  212.  
  213.                if (var1.target.equals(this.jdpsystem5)) {
  214.                   super.user.u.cursor(this.jdpsystem6);
  215.                   return true;
  216.                }
  217.  
  218.                if (var1.target.equals(this.jdpsystem6)) {
  219.                   super.user.u.cursor(this.jdpsystem7);
  220.                   return true;
  221.                }
  222.  
  223.                if (var1.target.equals(this.jdpsystem7)) {
  224.                   super.user.u.cursor(this.jdpsystem8);
  225.                   return true;
  226.                }
  227.  
  228.                if (var1.target.equals(this.jdpsystem8)) {
  229.                   super.user.u.cursor(this.jdpsystem9);
  230.                   return true;
  231.                }
  232.  
  233.                if (var1.target.equals(this.jdpsystem9)) {
  234.                   super.user.u.cursor(this.jdpsystem0);
  235.                   return true;
  236.                }
  237.  
  238.                super.user.u.cursor(this.jdpsystem0);
  239.                return true;
  240.             }
  241.  
  242.             return false;
  243.          case 503:
  244.          case 504:
  245.          case 505:
  246.             this.popuppanel.postEvent(var1);
  247.             return false;
  248.          case 1001:
  249.             if (var1.target.equals(this.searchResults.resultList)) {
  250.                this.loadData();
  251.                return true;
  252.             } else if (var1.target instanceof Button) {
  253.                String var2 = (String)var1.arg;
  254.                if (var2.trim().compareTo("Apply") == 0) {
  255.                   if (this.checkFields()) {
  256.                      this.saveData();
  257.                   }
  258.  
  259.                   return true;
  260.                } else if (var2.trim().compareTo("Reset") == 0) {
  261.                   this.loadData();
  262.                   return true;
  263.                } else {
  264.                   if (var2.trim().compareTo("Search") == 0) {
  265.                      this.newSearch();
  266.                      return true;
  267.                   }
  268.  
  269.                   return true;
  270.                }
  271.             } else {
  272.                if (var1.target instanceof Choice) {
  273.                   return true;
  274.                }
  275.  
  276.                if (var1.target instanceof TextField) {
  277.                   this.checkFields();
  278.                }
  279.  
  280.                return false;
  281.             }
  282.          default:
  283.             return false;
  284.       }
  285.    }
  286.  
  287.    public void InitClass(JDPUser var1, Panel var2, String var3) {
  288.       super.user = var1;
  289.       this.jaggSQL = new JDPJagg(var1.jaggPath);
  290.       this.jaggSQL.loadSettings(var1);
  291.       ((Container)this).setLayout(new BorderLayout());
  292.       ((Component)this).setFont(var1.plainFont);
  293.       this.popuppanel = new JDPPopupMessage(var1, var2);
  294.       ((Container)var2).add(this.popuppanel);
  295.       Panel var4 = new Panel();
  296.       ((Container)var4).setLayout(new BorderLayout());
  297.       Panel var5 = new Panel();
  298.       ((Container)var5).setLayout(new BorderLayout());
  299.       Panel var6 = new Panel();
  300.       ((Container)var6).setLayout(new BorderLayout());
  301.       JDPScrollPanel var7 = new JDPScrollPanel();
  302.       String var8 = "userid";
  303.       this.pfromWhereClause = "FROM JDPUser WHERE (1=1)";
  304.       this.psortChoice = new String[4];
  305.       this.psortChoice[0] = "userid";
  306.       this.psortChoice[1] = "username";
  307.       this.psortChoice[2] = "firstname";
  308.       this.psortChoice[3] = "lastname";
  309.       String[] var9 = new String[]{"User ID", "Username", "First Name", "Last Name"};
  310.       this.pdisplayChoice = this.psortChoice;
  311.       String var10 = var9[1];
  312.       boolean var11 = true;
  313.       String var12 = "Total Users:";
  314.       this.userid = new TextField("", 4);
  315.       this.username = new TextField("", 20);
  316.       this.firstname = new TextField("", 15);
  317.       this.lastname = new TextField("", 20);
  318.       this.status = new TextField("", 10);
  319.       this.jdpsystem0 = new TextField("", 5);
  320.       this.jdpsystem1 = new TextField("", 5);
  321.       this.jdpsystem2 = new TextField("", 5);
  322.       this.jdpsystem3 = new TextField("", 5);
  323.       this.jdpsystem4 = new TextField("", 5);
  324.       this.jdpsystem5 = new TextField("", 5);
  325.       this.jdpsystem6 = new TextField("", 5);
  326.       this.jdpsystem7 = new TextField("", 5);
  327.       this.jdpsystem8 = new TextField("", 5);
  328.       this.jdpsystem9 = new TextField("", 5);
  329.       this.userid.setEditable(false);
  330.       this.username.setEditable(false);
  331.       this.firstname.setEditable(false);
  332.       this.lastname.setEditable(false);
  333.       this.status.setEditable(false);
  334.       ((Container)var7).add("Left", new JDPWrapLabel(var1, "User ID:"));
  335.       ((Container)var7).add("Left", new JDPWrapLabel(var1, "Username:"));
  336.       ((Container)var7).add("Left", new JDPWrapLabel(var1, "First Name:"));
  337.       ((Container)var7).add("Left", new JDPWrapLabel(var1, "Last Name:"));
  338.       ((Container)var7).add("Left", new JDPWrapLabel(var1, "Status:"));
  339.       ((Container)var7).add("Left", new JDPWrapLabel(var1, "Systems:"));
  340.       ((Container)var7).add("Right", this.userid);
  341.       ((Container)var7).add("Right", this.username);
  342.       ((Container)var7).add("Right", this.firstname);
  343.       ((Container)var7).add("Right", this.lastname);
  344.       ((Container)var7).add("Right", this.status);
  345.       Panel var13 = new Panel();
  346.       ((Container)var13).setLayout(new JDPLineLayout(1));
  347.       Panel var14 = new Panel();
  348.       ((Container)var14).setLayout(new JDPLineLayout(1));
  349.       ((Container)var13).add("Left", this.jdpsystem0);
  350.       ((Container)var13).add("Left", this.jdpsystem1);
  351.       ((Container)var13).add("Left", this.jdpsystem2);
  352.       ((Container)var13).add("Left", this.jdpsystem3);
  353.       ((Container)var13).add("Left", this.jdpsystem4);
  354.       ((Container)var14).add("Left", this.jdpsystem5);
  355.       ((Container)var14).add("Left", this.jdpsystem6);
  356.       ((Container)var14).add("Left", this.jdpsystem7);
  357.       ((Container)var14).add("Left", this.jdpsystem8);
  358.       ((Container)var14).add("Left", this.jdpsystem9);
  359.       ((Container)var7).add("Right", var13);
  360.       ((Container)var7).add("Right", var14);
  361.       ((Container)var6).add("Center", var7);
  362.       String[] var15 = new String[]{"Apply", "Reset"};
  363.       int[] var16 = new int[]{0, 6, 8, 9, 10};
  364.       JDPButtons var17 = new JDPButtons(var1, var15, var16, JDPButtons.HORIZONTAL);
  365.       ((Container)var6).add("South", var17);
  366.       this.popuppanel.addComponent(var17.button[0], "Apply Changes", "Save changes to the database");
  367.       this.popuppanel.addComponent(var17.button[1], "Undo Changes", "Undo changes by reloading the record");
  368.       ((Container)var4).add("Center", var6);
  369.       String[] var18 = new String[]{"Userid", "Username", "Firstname", "Lastname"};
  370.       String[] var19 = new String[]{"userid", "username", "firstname", "lastname"};
  371.       String[][] var20 = new String[4][8];
  372.       var20[0][0] = "Greater than";
  373.       var20[0][1] = "Less than";
  374.       var20[0][2] = "Equal to";
  375.       var20[1][0] = "Begins with";
  376.       var20[1][1] = "Contains";
  377.       var20[2][0] = "Begins with";
  378.       var20[2][1] = "Contains";
  379.       var20[3][0] = "Begins with";
  380.       var20[3][1] = "Contains";
  381.       String[][] var21 = new String[4][8];
  382.       var21[0][0] = ">";
  383.       var21[0][1] = "<";
  384.       var21[0][2] = "=";
  385.       var21[1][0] = " like ";
  386.       var21[1][1] = " like ";
  387.       var21[2][0] = " like ";
  388.       var21[2][1] = " like ";
  389.       var21[3][0] = " like ";
  390.       var21[3][1] = " like ";
  391.       boolean[] var22 = new boolean[]{false, true, true, true};
  392.       int[] var23 = new int[]{6, 22, 17, 22};
  393.       this.jdpWhereClause = new JDPWhereClause(var1, var2, "JDPUserSystemMaint", true, var18[1], var18, var19, var20, var21, (String[][])null, (String[][])null, var23, var22);
  394.       this.searchResults = new JDPSearchResults(var1, (Container)var2, false, this.jaggSQL, false, var8, (String[])null, this.pfromWhereClause, var9, this.psortChoice, this.pdisplayChoice, var10, var11, var12);
  395.       this.searchResults.setIcon(5);
  396.       Panel var24 = new Panel();
  397.       ((Container)var24).setLayout(new BorderLayout());
  398.       ((Container)var24).add("North", this.jdpWhereClause);
  399.       ((Container)var24).add("Center", this.searchResults);
  400.       ((Container)var4).add("West", var24);
  401.       ((Container)this).add("Center", new JDPChiselFramePanel(var1, "Maintain User Access to Systems", var4, "North"));
  402.       this.searchResults.loadList();
  403.       ((Component)var2).paintAll(((Component)var2).getGraphics());
  404.    }
  405. }
  406.