📄 查询面板.java
字号:
package 固定资产管理系统;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class 查询面板 extends JPanel
{
内容 nei=new 内容();
public 查询面板() {
try {
nei.txtnum.setText("fyffff");
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setLayout(null);
lbl编号.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
lbl编号.setBorder(BorderFactory.createEtchedBorder());
lbl编号.setHorizontalAlignment(SwingConstants.CENTER);
lbl编号.setText("以资产编号为条件");
lbl编号.setBounds(new Rectangle(13, 12, 119, 32));
tzt编号.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
tzt编号.setText("");
tzt编号.setBounds(new Rectangle(13, 51, 119, 32));
btn编号查询.setBounds(new Rectangle(22, 90, 99, 32));
btn编号查询.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
btn编号查询.setText("按编号查询");
btn编号查询.addActionListener(new 查询面板_btn编号查询_actionAdapter(this));
lbl名称.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
lbl名称.setBorder(BorderFactory.createEtchedBorder());
lbl名称.setHorizontalAlignment(SwingConstants.CENTER);
lbl名称.setText("以资产名称为条件");
lbl名称.setBounds(new Rectangle(13, 137, 119, 32));
txt名称.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
txt名称.setText("");
txt名称.setBounds(new Rectangle(13, 179, 119, 32));
btn名称查询.setBounds(new Rectangle(22, 221, 101, 32));
btn名称查询.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
btn名称查询.setText("按名称查询");
btn名称查询.addActionListener(new 查询面板_btn名称查询_actionAdapter(this));
this.setBorder(BorderFactory.createEtchedBorder());
btn编号查询.addActionListener(new 查询面板_btn编号查询_actionAdapter(this));
this.add(btn名称查询);
this.add(txt名称);
this.add(tzt编号);
this.add(lbl编号);
this.add(btn编号查询);
this.add(lbl名称);
this.setVisible(true);
}
JLabel lbl编号 = new JLabel();
JTextField tzt编号 = new JTextField();
JButton btn编号查询 = new JButton();
JLabel lbl名称 = new JLabel();
JTextField txt名称 = new JTextField();
JButton btn名称查询 = new JButton();
public void btn编号查询_actionPerformed(ActionEvent e) {
String num=tzt编号.getText();
连接 l=new 连接();
Connection con=l.ver();
try {
PreparedStatement pst=con.prepareStatement("select assetid from asset固定资产信息表 where assetid=?");
pst.setString(1,num);
ResultSet rs=pst.executeQuery();
if(rs.next())
{
String number=rs.getString("assetid");
//System.out.println(rs.getString("assetid").toString().trim());
nei.txtnum.setText(number.trim());
// nei.txt资产名称.setText(rs.getString("asset_name").trim());
// nei.txt大类编号.setText(rs.getString("cateid").trim());
// nei.txt子类编号.setText(rs.getString("subcateid").trim());
// nei.txt样式.setText(rs.getString("model").trim());
// nei.txt价格.setText(rs.getString("price").trim());
// //nei.txt购入日期.setText(rs.getString("purchase_date").trim().toString());
// // nei.txt状态.setText(rs.getString("status").trim());
// nei.txt购入人.setText(rs.getString("purchaser").trim());
// nei.txt备注.setText(rs.getString("remarks").trim());
// nei.txt借用人.setText(rs.getString("useby").trim());
pst.close();
}
else
{
JOptionPane.showMessageDialog(this,"没有所查的东西!");
return;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void btn名称查询_actionPerformed(ActionEvent e) {
String name = txt名称.getText();
连接 l = new 连接();
内容 nei = new 内容();
Connection con = l.ver();
try {
PreparedStatement pst=con.prepareStatement("select * from asset固定资产信息表 where asset_name=?");
pst.setString(1, name);
ResultSet rs = pst.executeQuery();
if (rs.next())
{
nei.txtnum.setText(rs.getString("assetid").trim());
// nei.txt资产名称.setText(rs.getString("asset_name").trim());
// nei.txt大类编号.setText(rs.getString("cateid").trim());
// nei.txt子类编号.setText(rs.getString("subcateid").trim());
// nei.txt样式.setText(rs.getString("model").trim());
// nei.txt价格.setText(rs.getString("price").trim());
// //nei.txt购入日期.setText(rs.getString("purchase_date").trim().toString());
// // nei.txt状态.setText(rs.getString("status").trim());
// nei.txt购入人.setText(rs.getString("purchaser").trim());
// nei.txt备注.setText(rs.getString("remarks").trim());
// nei.txt借用人.setText(rs.getString("useby").trim());
pst.close();
rs.close();
} else {
pst.close();
rs.close();
JOptionPane.showMessageDialog(this, "没有所查的东西!");
return;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
class 查询面板_btn名称查询_actionAdapter implements ActionListener {
private 查询面板 adaptee;
查询面板_btn名称查询_actionAdapter(查询面板 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btn名称查询_actionPerformed(e);
}
}
class 查询面板_btn编号查询_actionAdapter implements ActionListener {
private 查询面板 adaptee;
查询面板_btn编号查询_actionAdapter(查询面板 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btn编号查询_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -