home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-05-08 | 12.6 KB | 307 lines |
- /*
- * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
- *
- * This SOURCE CODE FILE, which has been provided by Borland as part
- * of a Borland product for use ONLY by licensed users of the product,
- * includes CONFIDENTIAL and PROPRIETARY information of Borland.
- *
- * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
- * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
- * THE PRODUCT.
- *
- * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
- * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
- * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
- * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
- * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
- * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
- * CODE FILE.
- */
-
- //Title: Cliffhanger Adventure Gear
- //Version:
- //Copyright: Copyright (c) 1997 Borland International, Inc.
- //Author: Application Methods, Inc..
- //Description: Cliffhanger Adventure Gear order entry system
-
- package borland.reference.cliffhanger;
-
- import java.awt.*;
- import java.awt.event.*;
- import borland.jbcl.layout.*;
- import borland.jbcl.control.*;
- import borland.sql.dataset.*;
- import borland.jbcl.dataset.*;
- import java.util.*;
-
- /**
- * AddCustomerDlg implements the dialog for adding a new customer from the
- * OrderEntryFrame. The CustomerFrame could not be used because a modal dialog
- * is needed to get the new customer ID for the Order record.
- */
- public class AddCustomerDlg extends Dialog {
- private static DataModule1 dm = DataModule1.getDataModule();
- private QueryDataSet qdsCustomer;
- private int result;
- private int customerID;
- Panel pnlMain = new Panel();
- BevelPanel pnlCustomerInfo = new BevelPanel();
- GridBagLayout gridBagLayout1 = new GridBagLayout();
- FieldControl txtFirstName = new FieldControl();
- FieldControl txtMI = new FieldControl();
- FieldControl txtLastName = new FieldControl();
- FieldControl txtAddr1 = new FieldControl();
- FieldControl txtAddr2 = new FieldControl();
- FieldControl txtCity = new FieldControl();
- FieldControl txtState = new FieldControl();
- FieldControl txtPostalCode = new FieldControl();
- FieldControl txtCountry = new FieldControl();
- FieldControl txtPhone = new FieldControl();
- FieldControl txtEmail = new FieldControl();
- LabelControl labelControl1 = new LabelControl();
- LabelControl labelControl2 = new LabelControl();
- LabelControl labelControl3 = new LabelControl();
- LabelControl labelControl4 = new LabelControl();
- LabelControl labelControl5 = new LabelControl();
- LabelControl labelControl6 = new LabelControl();
- LabelControl labelControl7 = new LabelControl();
- LabelControl labelControl8 = new LabelControl();
- LabelControl labelControl9 = new LabelControl();
- LabelControl labelControl10 = new LabelControl();
- LabelControl labelControl11 = new LabelControl();
- BorderLayout borderLayout1 = new BorderLayout();
- BevelPanel bevelPanel1 = new BevelPanel();
- ButtonControl btnOK = new ButtonControl();
- ButtonControl btnCancel = new ButtonControl();
- FlowLayout flowLayout1 = new FlowLayout();
-
- // constants
- static final int CANCEL = 0;
- static final int OK = 1;
- ResourceBundle res = Res.getBundle("borland.reference.cliffhanger.Res");
-
- public AddCustomerDlg(Frame frame, String title, boolean modal) {
- super(frame, title, modal);
- try {
- jbInit();
- initData();
- add(pnlMain);
- pack();
- // Insert a new customer record
- newCustomer();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public AddCustomerDlg(Frame frame) {
- this(frame, "", false);
- }
-
- public AddCustomerDlg(Frame frame, boolean modal) {
- this(frame, "", modal);
- }
-
- public AddCustomerDlg(Frame frame, String title) {
- this(frame, title, false);
- }
-
- private void jbInit() throws Exception{
- pnlMain.setLayout(borderLayout1);
- pnlMain.setSize(new Dimension(400, 284));
- pnlCustomerInfo.setBevelInner(BevelPanel.FLAT);
- pnlCustomerInfo.setBevelOuter(borland.jbcl.control.BevelPanel.FLAT);
- pnlCustomerInfo.setMargins(new Insets(4, 4, 4, 4));
- txtFirstName.setColumnName("FIRSTNAME");
- txtFirstName.setDataSet(dm.getCustomerDataSet());
- txtMI.setColumnName("MI");
- txtMI.setDataSet(dm.getCustomerDataSet());
- txtLastName.setDataSet(dm.getCustomerDataSet());
- txtAddr1.setColumnName("ADDR1");
- txtAddr1.setDataSet(dm.getCustomerDataSet());
- txtAddr2.setColumnName("ADDR2");
- txtAddr2.setDataSet(dm.getCustomerDataSet());
- txtCity.setDataSet(dm.getCustomerDataSet());
- txtState.setColumnName("STATE");
- txtState.setDataSet(dm.getCustomerDataSet());
- txtPostalCode.setColumnName("POSTALCODE");
- txtPostalCode.setDataSet(dm.getCustomerDataSet());
- txtCountry.setColumnName("COUNTRY");
- txtCountry.setDataSet(dm.getCustomerDataSet());
- txtPhone.setColumnName("PHONE");
- txtPhone.setDataSet(dm.getCustomerDataSet());
- txtEmail.setColumnName("EMAIL");
- txtEmail.setDataSet(dm.getCustomerDataSet());
- txtCity.setColumnName("CITY");
- txtLastName.setColumnName("LASTNAME");
- pnlCustomerInfo.setLayout(gridBagLayout1);
- labelControl1.setText(res.getString("ACD_Name"));
- labelControl2.setText(res.getString("ACD_Address_1"));
- labelControl3.setText(res.getString("ACD_CityStateProv"));
- labelControl4.setText(res.getString("ACD_Phone"));
- labelControl5.setText(res.getString("ACD_EMail"));
- labelControl6.setText(res.getString("ACD_PostalCode"));
- labelControl7.setText(res.getString("ACD_Address_2"));
- labelControl8.setText(res.getString("ACD_Country"));
- labelControl9.setText(res.getString("ACD_First"));
- labelControl10.setText(res.getString("ACD_MI"));
- labelControl11.setText(res.getString("ACD_Last"));
- bevelPanel1.setBevelInner(BevelPanel.FLAT);
- bevelPanel1.setLayout(flowLayout1);
- btnOK.setLabel(res.getString("ACD_OK"));
- btnOK.addActionListener(new AddCustomerDlg_btnOK_actionAdapter(this));
- btnCancel.setLabel(res.getString("ACD_Cancel"));
- btnCancel.addActionListener(new AddCustomerDlg_btnCancel_actionAdapter(this));
- pnlMain.add(pnlCustomerInfo, BorderLayout.CENTER);
- pnlCustomerInfo.add(txtFirstName, new GridBagConstraints2(6, 1, 2, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 6, 0, 0), 112, 0));
- pnlCustomerInfo.add(txtMI, new GridBagConstraints2(8, 1, 2, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- pnlCustomerInfo.add(txtLastName, new GridBagConstraints2(10, 1, 3, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 4), 107, 0));
- pnlCustomerInfo.add(txtAddr1, new GridBagConstraints2(6, 2, 6, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 6, 0, 4), 224, 0));
- pnlCustomerInfo.add(txtAddr2, new GridBagConstraints2(6, 3, 6, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 6, 0, 4), 224, 0));
- pnlCustomerInfo.add(txtCity, new GridBagConstraints2(6, 4, 2, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 6, 0, 0), 108, 0));
- pnlCustomerInfo.add(txtState, new GridBagConstraints2(8, 4, 5, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 46), 17, 0));
- pnlCustomerInfo.add(txtPostalCode, new GridBagConstraints2(6, 5, 2, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 6, 0, 0), 108, 0));
- pnlCustomerInfo.add(txtCountry, new GridBagConstraints2(6, 6, 2, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 6, 0, 0), 107, 0));
- pnlCustomerInfo.add(txtPhone, new GridBagConstraints2(6, 7, 2, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 6, 0, 0), 106, 0));
- pnlCustomerInfo.add(txtEmail, new GridBagConstraints2(6, 9, 6, 1, 1.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 6, 10, 4), 223, 0));
- pnlCustomerInfo.add(labelControl1, new GridBagConstraints2(0, 1, 6, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 27, 0));
- pnlCustomerInfo.add(labelControl2, new GridBagConstraints2(0, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 6, 0, 0), 0, 0));
- pnlCustomerInfo.add(labelControl3, new GridBagConstraints2(0, 4, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
- pnlCustomerInfo.add(labelControl4, new GridBagConstraints2(0, 7, 3, 2, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 6, 0, 0), 0, 0));
- pnlCustomerInfo.add(labelControl5, new GridBagConstraints2(0, 9, 2, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 6, 10, 0), 0, 0));
- pnlCustomerInfo.add(labelControl7, new GridBagConstraints2(0, 3, 5, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
- pnlCustomerInfo.add(labelControl8, new GridBagConstraints2(0, 6, 4, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
- pnlCustomerInfo.add(labelControl9, new GridBagConstraints2(6, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 12, 0, 0), 9, 0));
- pnlCustomerInfo.add(labelControl10, new GridBagConstraints2(8, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 8, 0, 0), 0, 0));
- pnlCustomerInfo.add(labelControl11, new GridBagConstraints2(10, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 9, 0, 0), 0, 0));
- pnlCustomerInfo.add(labelControl6, new GridBagConstraints2(0, 5, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
- pnlMain.add(bevelPanel1, BorderLayout.SOUTH);
- bevelPanel1.add(btnOK, null);
- bevelPanel1.add(btnCancel, null);
- }
-
- private void initData() {
- qdsCustomer = dm.getCustomerDataSet();
- }
-
- /**
- * Method to insert a new customer record
- */
- public void newCustomer() {
- try {
- // Open the dataset if not already opened.
- qdsCustomer.open();
- // Insert a new Customer record at the end of the
- // dataset
- qdsCustomer.insertRow(false);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * When the OK button is clicked, save the new customer record, and
- * set the result property of the dialog to OK.
- */
- void btnOK_actionPerformed(ActionEvent e) {
- try {
- // Post, saveChanges (resolve), refresh the dataset and navigate to
- // the last record to get the added CustomerID.
- qdsCustomer.post();
- qdsCustomer.saveChanges(qdsCustomer);
- qdsCustomer.refresh();
- qdsCustomer.last();
- customerID = qdsCustomer.getInt("ID");
- result = OK;
- setVisible(false);
- dispose();
- }
- catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- /**
- * When the Cancel button is clicked, cancel any unposted inserts or edits.
- * Set the result property to CANCEL.
- */
- void btnCancel_actionPerformed(ActionEvent e) {
- try {
- qdsCustomer.cancel();
- }
- catch (Exception ex) {
- ex.printStackTrace();
- }
- result = CANCEL;
- setVisible(false);
- dispose();
- }
-
- /**
- * Getter method for the result property
- */
- public int getResult() {
- return this.result;
- }
-
- /**
- * getter method for the customerID property
- */
- public int getCustomerID() {
- return this.customerID;
- }
-
- }
-
- class AddCustomerDlg_btnOK_actionAdapter implements java.awt.event.ActionListener {
- AddCustomerDlg adaptee;
-
- AddCustomerDlg_btnOK_actionAdapter(AddCustomerDlg adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(ActionEvent e) {
- adaptee.btnOK_actionPerformed(e);
- }
- }
-
- class AddCustomerDlg_btnCancel_actionAdapter implements java.awt.event.ActionListener {
- AddCustomerDlg adaptee;
-
- AddCustomerDlg_btnCancel_actionAdapter(AddCustomerDlg adaptee) {
- this.adaptee = adaptee;
- }
-
- public void actionPerformed(ActionEvent e) {
- adaptee.btnCancel_actionPerformed(e);
- }
- }
-
-
-
-
-