⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datamodel.java

📁 j2ee API 开发重要工具 免费下载 欢迎使用
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 2003 Sun Microsystems, Inc.  All rights reserved.  U.S.  * Government Rights - Commercial software.  Government users are subject  * to the Sun Microsystems, Inc. standard license agreement and  * applicable provisions of the FAR and its supplements.  Use is subject  * to license terms.   *  * This distribution may include materials developed by third parties.  * Sun, Sun Microsystems, the Sun logo, Java and J2EE are trademarks  * or registered trademarks of Sun Microsystems, Inc. in the U.S. and  * other countries.   *  * Copyright (c) 2003 Sun Microsystems, Inc. Tous droits reserves. *  * Droits du gouvernement americain, utilisateurs gouvernementaux - logiciel * commercial. Les utilisateurs gouvernementaux sont soumis au contrat de  * licence standard de Sun Microsystems, Inc., ainsi qu'aux dispositions  * en vigueur de la FAR (Federal Acquisition Regulations) et des  * supplements a celles-ci.  Distribue par des licences qui en  * restreignent l'utilisation. *  * Cette distribution peut comprendre des composants developpes par des  * tierces parties. Sun, Sun Microsystems, le logo Sun, Java et J2EE  * sont des marques de fabrique ou des marques deposees de Sun  * Microsystems, Inc. aux Etats-Unis et dans d'autres pays. */package com.sun.ebank.appclient;import java.util.ResourceBundle;import java.util.Date;import java.util.ArrayList;import java.math.BigDecimal;import com.sun.ebank.util.EJBGetter;import javax.naming.InitialContext;import javax.swing.JTextField;import javax.swing.JOptionPane;import java.rmi.RemoteException;import com.sun.ebank.ejb.customer.CustomerController;import com.sun.ebank.ejb.customer.CustomerControllerHome;import com.sun.ebank.ejb.exception.CustomerNotFoundException;import com.sun.ebank.ejb.account.AccountController;import com.sun.ebank.ejb.account.AccountControllerHome;import com.sun.ebank.ejb.exception.AccountNotFoundException;import com.sun.ebank.ejb.exception.IllegalAccountTypeException;import com.sun.ebank.ejb.exception.CustomerInAccountException;import com.sun.ebank.ejb.exception.InvalidParameterException;import com.sun.ebank.util.CustomerDetails;import com.sun.ebank.util.AccountDetails;public class DataModel {//Private instance variables  private BankAdmin frame;  private ResourceBundle messages;  private int currentFunction;   private String returned;  private Date timestamp;//Private EJB variables  private static CustomerController customer;  private static AccountController account;//Protected instance variables  protected String first, last, mid, str, cty, st, zp,       tel, mail, descrip, credit, type, bal, begbal,       custID, actID;  protected BigDecimal balance, creditline, beginbalance;  protected BigDecimal bigzero = new BigDecimal("0.00");  protected boolean checkbal, checkbegbal;//Constructor   public DataModel(BankAdmin frame, ResourceBundle messages) {   this.frame = frame;   this.messages = messages;//Look up and create CustomerController bean    try {      CustomerControllerHome customerControllerHome =       EJBGetter.getCustomerControllerHome();      customer = customerControllerHome.create();    } catch (Exception NamingException) {      NamingException.printStackTrace();    }//Look up and create AccountController bean    try {      AccountControllerHome accountControllerHome =       EJBGetter.getAccountControllerHome();      account = accountControllerHome.create();    } catch (Exception NamingException) {      NamingException.printStackTrace();    }  }  private String getData(JTextField component) {    String text, trimmed;    if(component.getText().length() > 0) {      text = component.getText();      trimmed = text.trim();      return trimmed;    } else {      text = null;      return text;    }  }  protected int checkActData(String returned, int currentFunction) {    this.currentFunction = currentFunction;    this.returned = returned;    if(currentFunction == 6) { //remove account      this.actID = getData(frame.account);      this.custID = getData(frame.customer);      frame.clearMessages(1);      if((this.custID != null) && (this.actID != null)) {        int success = writeData();        return success;      } else {        frame.messlab5.setText(messages.getString("MissingRequiredException"));        return 1;      }    } else { // create account//Retrieve data from UI      this.descrip = getData(frame.descrip);      this.bal = getData(frame.bal);      this.credit = getData(frame.credit);      this.begbal = getData(frame.begbal);      this.custID = getData(frame.cust);      //Get type      if(frame.savingsact.isSelected()) {        this.type="Savings";      } else if(frame.checkingact.isSelected()) {        this.type="Checking";      } else if(frame.creditact.isSelected()) {        this.type="Credit";      } else if(frame.mnymktact.isSelected()) {        this.type="Money Market";      } else {        this.type=null;      }       frame.clearMessages(1);      if(this.begbal != null) {        checkbegbal = begbal.equals("0");      }       //See if user pressed Return after entering      //beginning balance      if(this.bal != null) {        checkbal = bal.equals("0");      }      if(checkbal == true) {        String begbalstring = frame.begbal.getText();        //Assign beginning balance to balance        this.bal = begbalstring;      }      //Convert balance, begin balance, and credit line      //String values to BigDecimal types for      //writing to the database      balance = new BigDecimal(bal);      creditline = new BigDecimal(credit);      beginbalance = new BigDecimal(begbal);      if((this.custID != null) && (this.begbal != null)        && (this.type != null) && (checkbegbal == false)) {        int success = writeData();        return success;      } else {        frame.messlab5.setText(messages.getString("MissingRequiredException"));        return 1;      }    }  }  protected int checkCustData(String returned, int currentFunction) {    this.currentFunction = currentFunction;    this.returned=returned;    int i, j, k;    this.last = getData(frame.lname);    this.first = getData(frame.fname);    this.mid = getData(frame.mi);    this.str = getData(frame.street);    this.cty = getData(frame.city);    this.st = getData(frame.state);    this.zp = getData(frame.zip);    this.tel = getData(frame.phone);    this.mail = getData(frame.e);    frame.clearMessages(1);    if((last != null) && (first != null) && (str != null)                      && (cty != null) && (st != null)) {      i = 0;    } else {      frame.messlab5.setText(messages.getString("MissingRequiredException"));      i = 1;    }    if(frame.mi.getText().length() > 1) {      frame.messlab4.setText(messages.getString("MILimitException"));      j = 1;    } else {      j = 0;    }    if(frame.state.getText().length() > 2) {      frame.messlab3.setText(messages.getString("StateLimitException"));      k = 1;    } else {      k = 0;    }    if((i == 0) && (j == 0) && (k == 0)) {      int success = writeData();      return success;     } else { 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -