📄 classstore.java
字号:
package file2;
import java.sql.*;
import javax.swing.*;
import java.awt.*;
public class ClassStore extends JPanel{
private DBConnection con=null;
private JLabel tip=new JLabel("该类商品目前的库存情况");
private JPanel tipPane=new JPanel();
private JTable table=null;
private JScrollPane tablePane=null;
private String[][] dataForTable=null;
private String[] titleForTable={"商品名称","现有库存量","最低允许库存量"};
public ClassStore(int tip1,String classToQuery){
//查的是大类的库存情况
if(tip1==1){
tipPane.add(tip);
con=new DBConnection();
String query="select Third_name,store_in,limit from Third_Catalog"+
",Second_Catalog,First_Catalog where To_Second_ID=Second_ID"+
" and To_First_ID=First_ID and First_name='"+classToQuery+"'";
ResultSet set=con.executeSelect1(query);
int count=0;
try{
while(set.next()){
count++;
}
dataForTable=new String[count][3];
set.beforeFirst();
count=0;
while(set.next()){
dataForTable[count][0]=set.getString(1);
dataForTable[count][1]=(new Integer(set.getInt(2))).toString();
dataForTable[count][2]=(new Integer(set.getInt(3))).toString();
count++;
}
}catch(Exception e){
e.printStackTrace();
}
}
//查的是明细类的库存情况
if(tip1==2){
tipPane.add(tip);
con=new DBConnection();
String query="select Third_name,store_in,limit from Third_Catalog"+
",Second_Catalog where To_Second_ID=Second_ID"+
" and Second_name='"+classToQuery+"'";
ResultSet set=con.executeSelect1(query);
int count=0;
try{
while(set.next()){
count++;
}
dataForTable=new String[count][3];
set.beforeFirst();
count=0;
while(set.next()){
dataForTable[count][0]=set.getString(1);
dataForTable[count][1]=(new Integer(set.getInt(2))).toString();
dataForTable[count][2]=(new Integer(set.getInt(3))).toString();
count++;
}
}catch(Exception e){
e.printStackTrace();
}
}
//查的是具体商品的库存情况
if(tip1==3){
tipPane.add(tip);
con=new DBConnection();
String query="select Third_name,store_in,limit from Third_Catalog"+
" where Third_name='"+classToQuery+"'";
ResultSet set=con.executeSelect1(query);
int count=0;
try{
while(set.next()){
count++;
}
dataForTable=new String[count][3];
set.beforeFirst();
count=0;
while(set.next()){
dataForTable[count][0]=set.getString(1);
dataForTable[count][1]=(new Integer(set.getInt(2))).toString();
dataForTable[count][2]=(new Integer(set.getInt(3))).toString();
count++;
}
}catch(Exception e){
e.printStackTrace();
}
}
table=new JTable(dataForTable,titleForTable);
tablePane=new JScrollPane(table);
this.setLayout(new GridLayout(2,1));
this.add(tipPane);
this.add(tablePane);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -