home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.Label;
- import java.awt.Panel;
- import java.awt.TextField;
- import java.util.StringTokenizer;
- import java.util.Vector;
-
- public class AuthorInquiry extends JDPClassLayout {
- JDPUser user;
- JDPJagg jaggSQL;
- JDPPopupMessage popuppanel;
- JDPMaskEdit JDPMaskEditMain;
- String moduleParameter;
- Panel Main;
- JDPChiselFramePanel ChiselPanel1;
- Panel Form1;
- Panel Panel1;
- Panel Panel2;
- JDPTabSelectPanel TabPanel1;
- JDPScrollPanel ScrollPanel1;
- Label au_idLabel1;
- TextField au_id1;
- Label au_lnameLabel1;
- TextField au_lname1;
- Label au_fnameLabel1;
- TextField au_fname1;
- Label addressLabel1;
- TextField address1;
- Label cityLabel1;
- Panel cityLine1;
- TextField city1;
- TextField state1;
- TextField zip1;
- Label phoneLabel1;
- TextField phone1;
- JDPScrollPanel ScrollPanel2;
- Label contractLabel1;
- TextField contract1;
- JDPButtons JDPButtons1;
- Panel Panel3;
- JDPWhereClause Form1SP1;
- JDPSearchResults Form1RL1;
-
- public void InitClass(JDPUser var1, Panel var2, String var3) {
- this.user = var1;
- this.moduleParameter = var3;
- this.jaggSQL = new JDPJagg(var1.jaggPath);
- ((Container)this).setLayout(new BorderLayout());
- this.popuppanel = new JDPPopupMessage(var1, this);
- ((Container)this).add(this.popuppanel);
- this.JDPMaskEditMain = new JDPMaskEdit();
- this.Main = new Panel();
- this.ChiselPanel1 = new JDPChiselFramePanel(var1, "Author Inquiry");
- this.Form1 = new Panel();
- this.Panel1 = new Panel();
- this.Panel2 = new Panel();
- String[] var4 = new String[2];
- Panel[] var5 = new Panel[]{new Panel(), null};
- var5[0].setLayout(new BorderLayout());
- var4[0] = "Name";
- var5[1] = new Panel();
- var5[1].setLayout(new BorderLayout());
- var4[1] = "Contract";
- this.TabPanel1 = new JDPTabSelectPanel(var1, var4, var5, "North");
- this.ScrollPanel1 = new JDPScrollPanel();
- this.au_idLabel1 = new Label("Id:", 0);
- this.au_id1 = new TextField("au_id", 11);
- this.au_lnameLabel1 = new Label("Last name:", 0);
- this.au_lname1 = new TextField("au_lname", 40);
- this.au_fnameLabel1 = new Label("First name:", 0);
- this.au_fname1 = new TextField("au_fname", 20);
- this.addressLabel1 = new Label("Address:", 0);
- this.address1 = new TextField("address", 40);
- this.cityLabel1 = new Label("", 0);
- this.cityLine1 = new Panel();
- this.city1 = new TextField("city", 20);
- this.state1 = new TextField("state", 2);
- this.zip1 = new TextField("zip", 5);
- this.phoneLabel1 = new Label("Phone:", 0);
- this.phone1 = new TextField("phone", 12);
- this.ScrollPanel2 = new JDPScrollPanel();
- this.contractLabel1 = new Label("Contract:", 0);
- this.contract1 = new TextField("contract", 1);
- String[] var6 = new String[]{"Apply", "Add", "Remove"};
- int[] var7 = new int[]{JDPButton.getIconValue("Save"), JDPButton.getIconValue("New"), JDPButton.getIconValue("Delete")};
- this.JDPButtons1 = new JDPButtons(var1, var6, var7, JDPButtons.getAlignmentValue("Horizontal"));
- this.Panel3 = new Panel();
- this.Main.setLayout(new BorderLayout());
- ((Container)this).add("Center", this.Main);
- this.Main.add("Center", this.ChiselPanel1);
- this.ChiselPanel1.add("Center", this.Form1);
- this.Form1.setLayout(new BorderLayout());
- this.Form1Main();
- this.Form1.add("Center", this.Panel1);
- this.Panel1.setLayout(new BorderLayout());
- this.Panel1.add("Center", this.Panel2);
- this.Panel2.setLayout(new BorderLayout());
- this.Panel2.add("Center", this.TabPanel1);
- var5[0].add("Center", this.ScrollPanel1);
- this.ScrollPanel1.add("Left", this.au_idLabel1);
- this.ScrollPanel1.add("Right", this.au_id1);
- this.ScrollPanel1.add("Left", this.au_lnameLabel1);
- this.ScrollPanel1.add("Right", this.au_lname1);
- this.ScrollPanel1.add("Left", this.au_fnameLabel1);
- this.ScrollPanel1.add("Right", this.au_fname1);
- this.ScrollPanel1.add("Left", this.addressLabel1);
- this.ScrollPanel1.add("Right", this.address1);
- this.ScrollPanel1.add("Left", this.cityLabel1);
- this.ScrollPanel1.add("Right", this.cityLine1);
- this.cityLine1.setLayout(new JDPLineLayout());
- this.cityLine1.add("Left", this.city1);
- this.cityLine1.add("Left", this.state1);
- this.cityLine1.add("Left", this.zip1);
- this.ScrollPanel1.add("Left", this.phoneLabel1);
- this.ScrollPanel1.add("Right", this.phone1);
- var5[1].add("Center", this.ScrollPanel2);
- this.ScrollPanel2.add("Left", this.contractLabel1);
- this.ScrollPanel2.add("Right", this.contract1);
- this.Panel1.add("South", this.JDPButtons1);
- this.Form1.add("West", this.Panel3);
- this.Panel3.setLayout(new BorderLayout());
- this.Panel3.add("North", this.Form1SP1);
- this.Panel3.add("Center", this.Form1RL1);
- this.TabPanel1.setTabcolor(0, var1.u._cvtcolor("Black"), var1.u._cvtcolor("LightGray"));
- this.TabPanel1.setTabcolor(1, var1.u._cvtcolor("Black"), var1.u._cvtcolor("LightGray"));
- this.ScrollPanel1.setFont(new Font("Helvetica", 0, 11));
- this.ScrollPanel1.setForeground(var1.u._cvtcolor("Black"));
- this.ScrollPanel1.setBackground(var1.u._cvtcolor("LightGray"));
- this.au_idLabel1.setFont(new Font("Helvetica", 1, 11));
- this.popuppanel.addComponent(this.au_id1, "Au Id", "");
- this.au_lnameLabel1.setFont(new Font("Helvetica", 1, 11));
- this.popuppanel.addComponent(this.au_lname1, "Au L name", "");
- this.au_fnameLabel1.setFont(new Font("Helvetica", 1, 11));
- this.popuppanel.addComponent(this.au_fname1, "Au F name", "");
- this.addressLabel1.setFont(new Font("Helvetica", 1, 11));
- this.popuppanel.addComponent(this.address1, "Address", "");
- this.cityLabel1.setFont(new Font("Helvetica", 1, 11));
- this.popuppanel.addComponent(this.city1, "City", "");
- this.popuppanel.addComponent(this.state1, "State", "");
- this.popuppanel.addComponent(this.zip1, "Zip", "");
- this.phoneLabel1.setFont(new Font("Helvetica", 1, 11));
- this.popuppanel.addComponent(this.phone1, "Phone", "");
- this.ScrollPanel2.setFont(new Font("Helvetica", 0, 11));
- this.ScrollPanel2.setForeground(var1.u._cvtcolor("Black"));
- this.ScrollPanel2.setBackground(var1.u._cvtcolor("LightGray"));
- this.contractLabel1.setFont(new Font("Helvetica", 1, 11));
- this.popuppanel.addComponent(this.contract1, "Contract", "");
- this.InitComponents();
- var1.gParm.addElement(this);
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 401:
- if (var1.key == 9 && var1.modifiers != 1) {
- if (var1.target.equals(this.au_id1)) {
- this.user.u.cursor(this.au_lname1);
- return true;
- }
-
- if (var1.target.equals(this.au_lname1)) {
- this.user.u.cursor(this.au_fname1);
- return true;
- }
-
- if (var1.target.equals(this.au_fname1)) {
- this.user.u.cursor(this.address1);
- return true;
- }
-
- if (var1.target.equals(this.address1)) {
- this.user.u.cursor(this.city1);
- return true;
- }
-
- if (var1.target.equals(this.city1)) {
- this.user.u.cursor(this.state1);
- return true;
- }
-
- if (var1.target.equals(this.state1)) {
- this.user.u.cursor(this.zip1);
- return true;
- }
-
- if (var1.target.equals(this.zip1)) {
- this.user.u.cursor(this.phone1);
- return true;
- }
-
- if (var1.target.equals(this.phone1)) {
- this.user.u.cursor(this.contract1);
- return true;
- }
-
- if (var1.target.equals(this.contract1)) {
- this.user.u.cursor(this.au_id1);
- return true;
- }
- }
-
- if (var1.key == 9 && var1.modifiers == 1) {
- if (var1.target.equals(this.au_id1)) {
- this.user.u.cursor(this.contract1);
- return true;
- }
-
- if (var1.target.equals(this.au_lname1)) {
- this.user.u.cursor(this.au_id1);
- return true;
- }
-
- if (var1.target.equals(this.au_fname1)) {
- this.user.u.cursor(this.au_lname1);
- return true;
- }
-
- if (var1.target.equals(this.address1)) {
- this.user.u.cursor(this.au_fname1);
- return true;
- }
-
- if (var1.target.equals(this.city1)) {
- this.user.u.cursor(this.address1);
- return true;
- }
-
- if (var1.target.equals(this.state1)) {
- this.user.u.cursor(this.city1);
- return true;
- }
-
- if (var1.target.equals(this.zip1)) {
- this.user.u.cursor(this.state1);
- return true;
- }
-
- if (var1.target.equals(this.phone1)) {
- this.user.u.cursor(this.zip1);
- return true;
- }
-
- if (var1.target.equals(this.contract1)) {
- this.user.u.cursor(this.phone1);
- return true;
- }
- }
-
- return false;
- case 503:
- case 504:
- case 505:
- this.popuppanel.postEvent(var1);
- return false;
- case 1001:
- if (var1.target.equals(this.JDPButtons1.button[0])) {
- this.Form1updateRow(this.Form1RL1.getSelectedKey());
- return true;
- } else if (var1.target.equals(this.JDPButtons1.button[1])) {
- this.Form1insertRow(this.Form1RL1.getSelectedKey());
- return true;
- } else if (var1.target.equals(this.JDPButtons1.button[2])) {
- this.Form1removeRow(this.Form1RL1.getSelectedKey());
- return true;
- } else if (var1.target.equals(this.Form1SP1)) {
- this.Form1RL1.clearList();
- this.Form1RL1.setFromWhereClause(this.Form1SP1.getFromWhereClause());
- this.Form1RL1.loadList();
- return true;
- } else {
- if (var1.target.equals(this.Form1RL1)) {
- this.Form1Load(this.Form1RL1.getSelectedKey());
- return true;
- }
-
- return false;
- }
- default:
- return false;
- }
- }
-
- public void InitComponents() {
- this.jaggSQL.setKeepConnectionOpen(false);
- }
-
- public void Form1Main() {
- this.Form1LoadChoices();
- this.Form1ClearFields();
- this.Form1WhereClauseMain();
- this.Form1SearchResultsMain();
- }
-
- public void Form1Load(String[] var1) {
- int var3 = 0;
- Vector var4 = new Vector();
- String var5 = this.jaggSQL.getSEP();
- if (var1 != null && var1.length >= 0) {
- String var7 = "SELECT au_id,au_lname,au_fname,phone,address,city,state,zip,contract FROM dbo_authors WHERE (1=1)";
- if (var1.length > 0 && var1[0] != null) {
- var7 = var7 + " AND au_id='" + var1[0] + "'";
- }
-
- this.jaggSQL.setDSN("JDP Tutorial");
- this.jaggSQL.setUID("");
- this.jaggSQL.setPWD("");
- this.jaggSQL.setMRW("1000");
- this.jaggSQL.setTOUT("60");
- this.user.mainmsg.setStatusMsg(JDPLang.get("Message0"), 0);
- var3 = this.jaggSQL.execSQL(var7, var4);
- if (var3 == -1) {
- this.user.u.setSqlMessage(this.jaggSQL, var7);
- } else if (var3 >= 1) {
- String var6 = (String)var4.elementAt(0);
- if (var6 != null && var6.trim().compareTo("") != 0) {
- StringTokenizer var2 = new StringTokenizer(var6, var5);
- this.au_id1.setText(var2.nextToken().trim());
- this.au_lname1.setText(var2.nextToken().trim());
- this.au_fname1.setText(var2.nextToken().trim());
- this.phone1.setText(var2.nextToken().trim());
- this.address1.setText(var2.nextToken().trim());
- this.city1.setText(var2.nextToken().trim());
- this.state1.setText(var2.nextToken().trim());
- this.zip1.setText(var2.nextToken().trim());
- this.contract1.setText(var2.nextToken().trim());
- }
-
- if (var3 > 1) {
- this.user.mainmsg.setStatusMsg(JDPLang.get("Message1"), 10);
- } else {
- this.user.mainmsg.clearStatusMsg();
- }
- } else {
- this.user.mainmsg.setStatusMsg(JDPLang.get("Message2"), 10);
- this.Form1ClearFields();
- }
- } else {
- this.Form1ClearFields();
- }
- }
-
- public boolean Form1updateRow(String[] var1) {
- return this.Form1CheckFields() ? this.Form1Save(var1, "U") : false;
- }
-
- public boolean Form1insertRow(String[] var1) {
- return this.Form1CheckFields() ? this.Form1Save(var1, "I") : false;
- }
-
- public boolean Form1removeRow(String[] var1) {
- return this.Form1Save(var1, "D");
- }
-
- boolean Form1Save(String[] var1, String var2) {
- int var3 = 0;
- Vector var4 = new Vector();
- this.jaggSQL.getSEP();
- String var5 = "";
- Object var6 = null;
- if (var2.equals("I")) {
- var5 = "INSERT INTO dbo_authors (au_id, au_lname, au_fname, phone, address, city, state, zip, contract) VALUES('" + this.user.u.replace(this.au_id1.getText(), "'", "''") + "', " + "'" + this.user.u.replace(this.au_lname1.getText(), "'", "''") + "', " + "'" + this.user.u.replace(this.au_fname1.getText(), "'", "''") + "', " + "'" + this.user.u.replace(this.phone1.getText(), "'", "''") + "', " + "'" + this.user.u.replace(this.address1.getText(), "'", "''") + "', " + "'" + this.user.u.replace(this.city1.getText(), "'", "''") + "', " + "'" + this.user.u.replace(this.state1.getText(), "'", "''") + "', " + "'" + this.user.u.replace(this.zip1.getText(), "'", "''") + "', " + "'" + this.user.u.replace(this.contract1.getText(), "'", "''") + "')";
- } else {
- if (var1 == null || var1.length == 0) {
- this.user.mainmsg.setStatusMsg(JDPLang.get("Message3"), 5);
- return false;
- }
-
- if (var2.equals("D")) {
- var5 = "DELETE FROM dbo_authors WHERE au_id='" + var1[0] + "'";
- } else {
- var5 = "UPDATE dbo_authors SET au_lname = '" + this.user.u.replace(this.au_lname1.getText(), "'", "''") + "', " + "au_fname = '" + this.user.u.replace(this.au_fname1.getText(), "'", "''") + "', " + "phone = '" + this.user.u.replace(this.phone1.getText(), "'", "''") + "', " + "address = '" + this.user.u.replace(this.address1.getText(), "'", "''") + "', " + "city = '" + this.user.u.replace(this.city1.getText(), "'", "''") + "', " + "state = '" + this.user.u.replace(this.state1.getText(), "'", "''") + "', " + "zip = '" + this.user.u.replace(this.zip1.getText(), "'", "''") + "', " + "contract = '" + this.user.u.replace(this.contract1.getText(), "'", "''") + "'" + " WHERE au_id='" + var1[0] + "'";
- }
- }
-
- this.jaggSQL.setDSN("JDP Tutorial");
- this.jaggSQL.setUID("");
- this.jaggSQL.setPWD("");
- this.jaggSQL.setMRW("1000");
- this.jaggSQL.setTOUT("60");
- this.user.mainmsg.setStatusMsg(JDPLang.get("Message0"), 0);
- var3 = this.jaggSQL.execSQL(var5, var4);
- if (var3 == 0 && var6 != null) {
- String[] var7 = new String[]{JDPLang.get("Reload"), JDPLang.get("Update")};
- int[] var8 = new int[]{6, 0};
- JDPMessageDialog var9 = new JDPMessageDialog(this.user, this.user.jdpMainWindow, JDPLang.get("Dialog0"), JDPLang.get("Dialog1"), var7, var8);
- ((JDPDialog)var9).display();
- if (var9.getPressedButton() != 1) {
- this.Form1Load(var1);
- return true;
- }
-
- var4 = new Vector();
- var3 = this.jaggSQL.execSQL((String)var6, var4);
- }
-
- if (var3 == -1) {
- this.user.u.setSqlMessage(this.jaggSQL, var5);
- return false;
- } else {
- if (var3 == 1) {
- if (var2.equals("I")) {
- this.user.mainmsg.setStatusMsg(JDPLang.get("Message4"), 3);
- } else if (var2.equals("D")) {
- this.user.mainmsg.setStatusMsg(JDPLang.get("Message5"), 3);
- } else {
- this.user.mainmsg.setStatusMsg(JDPLang.get("Message6"), 3);
- }
- } else {
- this.user.u.setSqlMessage(this.jaggSQL, var5);
- }
-
- if (var6 != null) {
- this.Form1Load(var1);
- }
-
- return true;
- }
- }
-
- public void Form1ClearFields() {
- this.au_id1.setText("");
- this.au_lname1.setText("");
- this.au_fname1.setText("");
- this.phone1.setText("");
- this.address1.setText("");
- this.city1.setText("");
- this.state1.setText("");
- this.zip1.setText("");
- this.contract1.setText("");
- }
-
- void Form1LoadChoices() {
- this.jaggSQL.setDSN("JDP Tutorial");
- this.jaggSQL.setUID("");
- this.jaggSQL.setPWD("");
- this.jaggSQL.setMRW("1000");
- this.jaggSQL.setTOUT("60");
- }
-
- public boolean Form1CheckFields() {
- return true;
- }
-
- public void Form1WhereClauseMain() {
- String[] var1 = new String[4];
- String[] var2 = new String[4];
- Vector var3 = new Vector();
- Vector var4 = new Vector();
- var1[0] = "Last name";
- var2[0] = "au_lname";
- var1[1] = "First name";
- var2[1] = "au_fname";
- var1[2] = "Address";
- var2[2] = "address";
- var1[3] = "City";
- var2[3] = "city";
- var3.addElement(new Vector());
- var4.addElement(new Vector());
- var3.addElement(new Vector());
- var4.addElement(new Vector());
- var3.addElement(new Vector());
- var4.addElement(new Vector());
- var3.addElement(new Vector());
- var4.addElement(new Vector());
- ((Vector)var3.elementAt(0)).addElement("Begins with");
- ((Vector)var4.elementAt(0)).addElement("like");
- ((Vector)var3.elementAt(0)).addElement("Contains");
- ((Vector)var4.elementAt(0)).addElement("like");
- ((Vector)var3.elementAt(1)).addElement("Begins with");
- ((Vector)var4.elementAt(1)).addElement("like");
- ((Vector)var3.elementAt(1)).addElement("Contains");
- ((Vector)var4.elementAt(1)).addElement("like");
- ((Vector)var3.elementAt(2)).addElement("Begins with");
- ((Vector)var4.elementAt(2)).addElement("like");
- ((Vector)var3.elementAt(2)).addElement("Contains");
- ((Vector)var4.elementAt(2)).addElement("like");
- ((Vector)var3.elementAt(3)).addElement("Begins with");
- ((Vector)var4.elementAt(3)).addElement("like");
- ((Vector)var3.elementAt(3)).addElement("Contains");
- ((Vector)var4.elementAt(3)).addElement("like");
- int[] var5 = new int[4];
- boolean[] var6 = new boolean[4];
- var5[0] = 42;
- var6[0] = true;
- var5[1] = 22;
- var6[1] = true;
- var5[2] = 42;
- var6[2] = true;
- var5[3] = 22;
- var6[3] = true;
- this.Form1SP1 = new JDPWhereClause(this.user, super.targetPanel, "", true, "", var1, var2, var3, var4, (String[][])null, (String[][])null, var5, var6, "FROM dbo_authors WHERE (1=1)");
- this.Form1SP1.setDSNType("ACCESS");
- this.Form1SP1.setDataType(0, 12);
- this.Form1SP1.setDataType(1, 12);
- this.Form1SP1.setDataType(2, 12);
- this.Form1SP1.setDataType(3, 12);
- }
-
- public void Form1SearchResultsMain() {
- String var1 = "au_id";
- String[] var2 = new String[0];
- String var3 = "(1=1)";
- String[] var4 = new String[]{"Last name", "First name"};
- String[] var5 = new String[]{"au_lname", "au_fname"};
- JDPJagg var6 = new JDPJagg(this.user.jaggPath);
- var6.setDSN("JDP Tutorial");
- var6.setUID("");
- var6.setPWD("");
- var6.setMRW("1000");
- var6.setTOUT("60");
- this.Form1RL1 = new JDPSearchResults(this.user, super.targetPanel, true, var6, false, var1, var2, var3, var4, var5, var5, "", true, "Total Entries:");
- int[] var7 = new int[11];
- var7[0] = 3;
- var7[1] = 5;
- this.Form1RL1.setMinWidth(160);
- this.Form1RL1.setIcons(var7);
- this.Form1RL1.setFromWhereClause(" FROM dbo_authors WHERE (1=1)");
- this.Form1RL1.clearList("Authors");
- this.Form1RL1.loadList();
- }
- }
-