/*
* @(#)TableExample.java 1.15 01/12/03
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/**
* A a UI around the JDBCAdaptor, allowing database data to be interactively
* fetched, sorted and displayed using Swing.
*
* NOTE: This example uses a modal dialog via the static convenience methods in
* the JOptionPane. Use of modal dialogs requires JDK 1.1.4 or greater.
*
* @version 1.15 12/03/01
* @author Philip Milne
*/
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.io.*;
public class TableExample implements LayoutManager {
static String[] ConnectOptionNames = { "Connect" };
static String ConnectTitle = "Connection Information";
Dimension origin = new Dimension(0, 0);
JButton fetchButton;
JButton showConnectionInfoButton;
JPanel connectionPanel;
JFrame frame; // The query/results window.
JLabel userNameLabel;
JTextField userNameField;
JLabel passwordLabel;
JTextField passwordField;
// JLabel queryLabel;
JTextArea queryTextArea;
JComponent queryAggregate;
JLabel serverLabel;
JTextField serverField;
JLabel driverLabel;
JTextField driverField;
JLabel FileNameLabel;
JTextField FileNameField;
JPanel mainPanel;
TableSorter sorter;
JDBCAdapter dataBase;
JScrollPane tableAggregate;
String FileName;
PrintWriter log;
/**
* Brigs up a JDialog using JOptionPane containing the connectionPanel.
* If the user clicks on the 'Connect' button the connection is reset.
*/
void activateConnectionDialog() {
if(JOptionPane.showOptionDialog(tableAggregate, connectionPanel, ConnectTitle,
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, ConnectOptionNames, ConnectOptionNames[0]) == 0) {
connect();
frame.setVisible(true);
}
else if(!frame.isVisible())
System.exit(0);
}
/**
* Creates the connectionPanel, which will contain all the fields for
* the connection information.
*/
public void createConnectionDialog() {
// Create the labels and text fields.
userNameLabel = new JLabel("User name: ", JLabel.RIGHT);
userNameField = new JTextField("sa");
passwordLabel = new JLabel("Password: ", JLabel.RIGHT);
passwordField = new JTextField("sa");
serverLabel = new JLabel("Database URL: ", JLabel.RIGHT);
serverField = new JTextField("jdbc:odbc:JXC");
driverLabel = new JLabel("Driver: ", JLabel.RIGHT);
driverField = new JTextField("sun.jdbc.odbc.JdbcOdbcDriver");
FileNameLabel= new JLabel("文件名: ", JLabel.RIGHT);
FileNameField= new JTextField("XX");
connectionPanel = new JPanel(false);
connectionPanel.setLayout(new BoxLayout(connectionPanel,
BoxLayout.X_AXIS));
JPanel namePanel = new JPanel(false);
namePanel.setLayout(new GridLayout(0, 1));
namePanel.add(userNameLabel);
namePanel.add(passwordLabel);
namePanel.add(serverLabel);
namePanel.add(driverLabel);
namePanel.add(FileNameLabel);
JPanel fieldPanel = new JPanel(false);
fieldPanel.setLayout(new GridLayout(0, 1));
fieldPanel.add(userNameField);
fieldPanel.add(passwordField);
fieldPanel.add(serverField);
fieldPanel.add(driverField);
fieldPanel.add(FileNameField);
connectionPanel.add(namePanel);
connectionPanel.add(fieldPanel);
}
public TableExample() {
mainPanel = new JPanel();
// Create the panel for the connection information
createConnectionDialog();
// Create the buttons.
showConnectionInfoButton = new JButton("Configuration");
showConnectionInfoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
activateConnectionDialog();
}
}
);
fetchButton = new JButton("Fetch");
fetchButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fetch();
}
}
);
// Create the query text area and label.
queryTextArea = new JTextArea("SELECT * FROM uses", 25, 25);
queryAggregate = new JScrollPane(queryTextArea);
queryAggregate.setBorder(new BevelBorder(BevelBorder.LOWERED));
// Create the table.
tableAggregate = createTable();
tableAggregate.setBorder(new BevelBorder(BevelBorder.LOWERED));
// Add all the components to the main panel.
mainPanel.add(fetchButton);
mainPanel.add(showConnectionInfoButton);
mainPanel.add(queryAggregate);
mainPanel.add(tableAggregate);
mainPanel.setLayout(this);
// Create a Frame and put the main panel in it.
frame = new JFrame("TableExample");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}});
frame.setBackground(Color.lightGray);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setVisible(false);
frame.setBounds(200, 200, 640, 480);
activateConnectionDialog();
}
public void connect() {
dataBase = new JDBCAdapter(
serverField.getText(),
driverField.getText(),
userNameField.getText(),
passwordField.getText());
FileName=FileNameField.getText();
sorter.setModel(dataBase);
}
public void fetch() {
dataBase.executeQuery(queryTextArea.getText());
try {
log = new PrintWriter(new FileWriter(FileName+".java", true), true);
}
catch (IOException e) {
System.err.println("无法创建日志文件: " + e);
}
BornTop();
BornALL();
Bornexcute();
BornEdit();
BornAdd();
BornDel();
}
public void BornDel() {
log.println(" public void Del() throws Exception {");
log.println(" String Str=\"Delete From "+FileName+" where Id=\"+"+dataBase.getColumnName(0)+";");
log.println(" DBConnect dbc = new DBConnect();");
log.println(" dbc.executeUpdate(Str);");
log.println(" dbc.close();");
log.println(" }");
log.println("");
log.println(" }");
}
public void BornTop() {
log.println("package JXC.web;");
log.println("import JXC.Com.DBConnect;");
log.println("import java.lang.String;");
log.println("import JXC.util.StrFun;");
log.println("import java.sql.*;");
log.println("import javax.servlet.*;");
log.println("import javax.servlet.http.*;");
log.println("/**");
log.println(" * Title: 明细单信息");
log.println(" * Description:");
log.println(" * Copyright: Copyright (c) 2003");
log.println(" * Company: torch");
log.println(" * @author: wind");
log.println(" * @version 1.0");
log.println(" */");
}
public void BornALL() {
log.println("public class "+FileName +"{");
for (int i=0;i<dataBase.getColumnCount();i++)
log.println(" private "+dataBase.getColumnClassStr(i)+" "+dataBase.getColumnName(i)+";");
log.println(" public void "+FileName +"(){}");
for (int i=0;i<dataBase.getColumnCount();i++) {
String Fieldtype=dataBase.getColumnClassStr(i);
String Fieldname=dataBase.getColumnName(i);
log.println(" public "+Fieldtype+" get"+LowerOne(Fieldname)+"() {");
log.println(" return "+Fieldname+";");
log.println(" }");
log.println(" public void set"+LowerOne(Fieldname)+"("+Fieldtype+" anew) {");
log.println(" this."+Fieldname+"=anew;");
log.println(" }");
if (i==0) {
log.println(" public void set"+LowerOne(Fieldname)+"(String anew) {");
log.println(" if (anew!=null)");
log.println(" this."+Fieldname+"=Integer.parseInt(anew);");
log.println(" }");
}
}
}
public void Bornexcute(){
log.println(" public boolean ex
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
项目名称:商品进销存系统 项目描述:本系统集进、销、存,决策于一体,同时还集成了报表打印、查询统计等多种实用的功能。 运用技术:Jsp +JavaBean + Servlet +Ajax +Hibernate 开发工具:Eclipse +Tomcat+Sqlserver2000 本资源包括源代码以及数据库文件,直接导入Eclipse就可以运行
资源推荐
资源详情
资源评论
收起资源包目录
通用进销存源代码—J2EE (751个子文件)
run.bat 71B
jar.bat 49B
find.bmp 822B
find.bmp 822B
add.bmp 654B
add.bmp 654B
TableExample.class 11KB
SellItemId.class 7KB
StockItemId.class 7KB
JDBCAdapter.class 6KB
GetOrderById.class 5KB
TableSorter.class 5KB
GetSellById.class 5KB
GetStockById.class 5KB
GetStockOrderById.class 5KB
SellAndsendId.class 5KB
SendItemId.class 4KB
GetSellOrSendByclientId.class 4KB
GetSellAndSendByclientId.class 4KB
GetSendApplyByClientID.class 4KB
SellPaymentItemId.class 4KB
GetStockOrderByPurveyId.class 4KB
GetSendApplyAll.class 4KB
GetOrderByClientId.class 4KB
GetSendApplyById1.class 4KB
GetSellItemByBetweenTime.class 4KB
GetStockOrderAll.class 4KB
GetSellItemByGoodsId.class 4KB
GetSendApplyById.class 4KB
GetOrderAll.class 4KB
GetSellItemByTime.class 4KB
GetStockAll.class 3KB
GetSellAll.class 3KB
GetSellItemByClientId.class 3KB
GetStockItemByPurveyId.class 3KB
SpcgAdd.class 3KB
GetOrderByOrderId.class 3KB
GetStockItemBypurId.class 3KB
StockOrderDao.class 3KB
SendApplyDao.class 3KB
SendPaymentItemId.class 3KB
StorageItemsId.class 3KB
Order1Dao.class 3KB
GetGoodsInfoById2.class 3KB
GetGoodsInfoById1.class 3KB
GetGoodsInfoById.class 3KB
Stock.class 3KB
Sell.class 3KB
SellItemDao.class 3KB
SendPyamentDao.class 3KB
StockBackDao.class 3KB
ClientDao.class 3KB
SellbackDao.class 3KB
StockDao.class 3KB
UsersDao.class 3KB
StorageDao.class 3KB
SellDao.class 3KB
SendApply.class 3KB
GoodsCategoryDao.class 2KB
CjkAdd.class 2KB
Test.class 2KB
SpxsAdd.class 2KB
InvoiceDao.class 2KB
GoodsInfoDao.class 2KB
PskpAdd.class 2KB
PurveyDao.class 2KB
Right1Dao.class 2KB
RoleDao.class 2KB
PssqAdd.class 2KB
StockOrder.class 2KB
GetOrderId.class 2KB
KhdhAdd.class 2KB
UpdateUsers.class 2KB
CgddAdd.class 2KB
UsersAdd.class 2KB
Users.class 2KB
Purvey.class 2KB
Chklogin.class 2KB
StockBackAdd.class 2KB
SellBackAdd.class 2KB
UpdateRoleAndRight.class 2KB
PsjkAdd.class 2KB
Stockback.class 2KB
UpdatePurvey.class 2KB
Order1.class 2KB
Sellback.class 2KB
PurveyJKAdd.class 2KB
GoodsInfo.class 2KB
StoragesItemsDao.class 2KB
QyzyAdd.class 2KB
UpdateGoodsInfo.class 2KB
SendItemDao.class 2KB
SpxxAdd.class 2KB
FilterAdmin.class 2KB
FilterStock.class 2KB
FilterSell.class 2KB
FilterCW.class 2KB
FilterPS.class 2KB
FilterBB.class 2KB
UpdateClient.class 2KB
共 751 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
小浣熊6616
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页