📄 orgstorageman_frm.java
字号:
package KcglSys;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.sql.*;
import javax.swing.tree.DefaultMutableTreeNode;
import com.borland.dbswing.*;
import com.borland.dx.sql.dataset.*;
import com.borland.dx.dataset.*;
import javax.swing.tree.TreePath;
/**
* <p>Title: 库存管理信息系统</p>
* <p>Description: 库存管理信息系统,企业好帮手</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: ios</p>
* @author dragon
* @version 1.0
*/
public class OrgStorageMan_Frm
extends JFrame {
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JScrollPane jScrollPane1 = new JScrollPane();
JTree jTree1 = new JTree();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
TableScrollPane tableScrollPane1 = new TableScrollPane();
JdbTable jdbTable1 = new JdbTable();
Database database1 = new Database();
QueryDataSet queryDataSet1 = new QueryDataSet();
Column column1 = new Column();
JButton jButton1 = new JButton();
JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();
Column column2 = new Column();
Column column3 = new Column();
Column column4 = new Column();
JButton jButton2 = new JButton();
//Construct the frame
public OrgStorageMan_Frm() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel)this.getContentPane();
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(608, 421));
this.setTitle("期初库存设置");
jLabel1.setText("以下是库房/货位列表:");
//建立库房、库位列表树
DefaultMutableTreeNode top = new DefaultMutableTreeNode("仓库");
jTree1 = new JTree(top);
//实例化buildTree
buildWarehouseTree whtree = new buildWarehouseTree();
//初始化whtree
whtree.get_Tree(jTree1, top);
//扩展第一结点
jTree1.expandRow(0);
MouseListener ml = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
int selRow = jTree1.getRowForLocation(e.getX(), e.getY());
TreePath selPath = jTree1.getPathForLocation(e.getX(), e.getY());
if (selRow == 0) {
queryDataSet1.close();
queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(
database1,
"SELECT os.GoodsId as \"货物代码\",g.GName as \"名称\" ,g.GStyle as \"型号\",g.GUnit " +
"as \"计量单位\",g.InPrice as \"进货价格\",g.OutPrice as \"销售价格\",os.OrgPrice as " +
"\"期初金额\",os.OrgAmount as \"期初数量\",os.WhId as \"库房\",os.WsId as \"货位\" FROM " +
"OriginalStorage os,GoodsInfo g where g.goodsid=os.goodsid ", null, true,
Load.ALL));
queryDataSet1.refresh();
}
else if (selRow > 0) {
String nodeStr = selPath.getPathComponent(1).toString();
int whidEnd = nodeStr.indexOf("]");
String whid = nodeStr.substring(1, whidEnd);
queryDataSet1.close();
String sql = null;
if (selPath.getPathCount() == 2) {
sql =
"SELECT os.GoodsId as \"货物代码\",g.GName as \"名称\" ,g.GStyle as \"型号\",g.GUnit " +
"as \"计量单位\",g.InPrice as \"进货价格\",g.OutPrice as \"销售价格\",os.OrgPrice as " +
"\"期初金额\",os.OrgAmount as \"期初数量\",os.WhId as \"库房\",os.WsId as \"货位\" FROM " +
"OriginalStorage os,GoodsInfo g where g.goodsid=os.goodsid and os.whid='" +
whid + "'";
}
else if (selPath.getPathCount() == 3) {
String node2Str = selPath.getPathComponent(2).toString();
int wsidEnd = nodeStr.indexOf("]");
String wsid = node2Str.substring(1, wsidEnd);
sql =
"SELECT os.GoodsId as \"货物代码\",g.GName as \"名称\" ,g.GStyle as \"型号\",g.GUnit " +
"as \"计量单位\",g.InPrice as \"进货价格\",g.OutPrice as \"销售价格\",os.OrgPrice as " +
"\"期初金额\",os.OrgAmount as \"期初数量\",os.WhId as \"库房\",os.WsId as \"货位\" FROM " +
"OriginalStorage os,GoodsInfo g where g.goodsid=os.goodsid and os.whid='" +
whid + "' and os.wsid='" + wsid + "'";
}
queryDataSet1.setQuery(new com.borland.dx.sql.dataset.
QueryDescriptor(database1, sql, null, true,
Load.ALL));
queryDataSet1.refresh();
}
}
};
jTree1.addMouseListener(ml);
jLabel2.setText("以下是对应货位的期初库存列表:");
tableScrollPane1.setBorder(BorderFactory.createLineBorder(Color.black));
database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor(
"jdbc:odbc:KcglSys", "sa", "sa", false, "sun.jdbc.odbc.JdbcOdbcDriver"));
column1.setColumnName("whid");
column1.setDataType(com.borland.dx.dataset.Variant.STRING);
column1.setPreferredOrdinal(0);
column1.setServerColumnName("NewColumn1");
column1.setSqlType(0);
queryDataSet1.setMetaDataUpdate(MetaDataUpdate.TABLENAME +
MetaDataUpdate.PRECISION +
MetaDataUpdate.SCALE +
MetaDataUpdate.SEARCHABLE);
queryDataSet1.setEnableInsert(false);
queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(
database1,
"SELECT os.GoodsId as \"货物代码\",g.GName as \"名称\" ,g.GStyle as \"型号\",g.GUnit " +
"as \"计量单位\",g.InPrice as \"进货价格\",g.OutPrice as \"销售价格\",os.OrgPrice as " +
"\"期初金额\",os.OrgAmount as \"期初数量\",os.WhId as \"库房\",os.WsId as \"货位\" FROM " +
"OriginalStorage os,GoodsInfo g where g.goodsid=os.goodsid ", null, true,
Load.ALL));
jdbTable1.setDataSet(queryDataSet1);
jButton1.setText("添加");
jButton1.addActionListener(new OrgStorageMan_Frm_jButton1_actionAdapter(this));
jdbNavToolBar1.setBorder(BorderFactory.createLineBorder(Color.black));
jdbNavToolBar1.setButtonStatePrior(JdbNavToolBar.AUTO_ENABLED);
jdbNavToolBar1.setButtonStateLast(JdbNavToolBar.AUTO_ENABLED);
jdbNavToolBar1.setButtonStateInsert(JdbNavToolBar.HIDDEN);
jdbNavToolBar1.setButtonStatePost(JdbNavToolBar.HIDDEN);
jdbNavToolBar1.setButtonStateCancel(JdbNavToolBar.HIDDEN);
jdbNavToolBar1.setButtonStateDitto(JdbNavToolBar.HIDDEN);
jdbNavToolBar1.setDataSet(queryDataSet1);
column2.setColumnName("货物代码");
column2.setDataType(com.borland.dx.dataset.Variant.INT);
column2.setRowId(true);
column2.setTableName("OriginalStorage");
column2.setServerColumnName("GoodsId");
column2.setSqlType(4);
column3.setColumnName("库房");
column3.setDataType(com.borland.dx.dataset.Variant.STRING);
column3.setPrecision(10);
column3.setRowId(true);
column3.setTableName("OriginalStorage");
column3.setServerColumnName("WhId");
column3.setSqlType(1);
column4.setColumnName("货位");
column4.setDataType(com.borland.dx.dataset.Variant.STRING);
column4.setPrecision(10);
column4.setRowId(true);
column4.setTableName("OriginalStorage");
column4.setServerColumnName("WsId");
column4.setSqlType(1);
queryDataSet1.setColumns(new Column[] {column2, column3, column4});
jButton2.setText("关闭");
jButton2.addActionListener(new OrgStorageMan_Frm_jButton2_actionAdapter(this)); jTree1.setBorder(null); jScrollPane1.setBorder(BorderFactory.createLoweredBevelBorder()); contentPane.add(jScrollPane1, new XYConstraints(19, 37, 179, 330));
contentPane.add(jLabel1, new XYConstraints(20, 13, 137, -1));
contentPane.add(jLabel2, new XYConstraints(222, 16, 208, -1));
contentPane.add(tableScrollPane1, new XYConstraints(215, 36, 378, 287));
contentPane.add(jdbNavToolBar1, new XYConstraints(280, 322, -1, -1));
contentPane.add(jButton1, new XYConstraints(218, 329, -1, 22));
contentPane.add(jButton2, new XYConstraints(520, 330, -1, -1));
tableScrollPane1.getViewport().add(jdbTable1, null);
jScrollPane1.getViewport().add(jTree1, null);
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
this.dispose();
}
}
void jButton2_actionPerformed(ActionEvent e) {
this.dispose();
}
void jButton1_actionPerformed(ActionEvent e) {
//实例化GetFrmCentershow,该类是由我们创建的用于实现窗口中心显示
GetFrmCenterShow gfc = new GetFrmCenterShow();
//实例化Main_frame
AddOrgGoods_Frm frame = new AddOrgGoods_Frm();
//让frame显示在屏幕中心
gfc.get_center(frame);
//frame的显示
frame.show();
//本窗体的退出
this.dispose();
}
}
class OrgStorageMan_Frm_jButton1_actionAdapter
implements java.awt.event.ActionListener {
OrgStorageMan_Frm adaptee;
OrgStorageMan_Frm_jButton1_actionAdapter(OrgStorageMan_Frm adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class OrgStorageMan_Frm_jButton2_actionAdapter
implements java.awt.event.ActionListener {
OrgStorageMan_Frm adaptee;
OrgStorageMan_Frm_jButton2_actionAdapter(OrgStorageMan_Frm adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -