package labor;
import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class EquScrap_Labor extends JFrame{
private JLabel equName=new JLabel("设备名:");
private JTextField nameEqu=new JTextField(10);
private JLabel equModel=new JLabel("型号:");
private JTextField modelEqu=new JTextField(10);
private JLabel equSpec=new JLabel("规格:");
private JTextField specEqu=new JTextField(10);
private JLabel equAmount=new JLabel("数量:");
private JTextField amountEqu=new JTextField(10);
private JLabel equCondition=new JLabel("运行状况:");
private JTextField conditionEqu=new JTextField(10);
private JLabel equManufacturer=new JLabel("生产厂家:");
private JTextField manufacturerEqu=new JTextField(10);
private JLabel equDate=new JLabel("报废时间(xxxx.xx.xx):");
private JTextField dateEqu=new JTextField(10);
private JLabel jidu=new JLabel("报废季度:");
private Choice jiduxuanze=new Choice();
private JButton insert=new JButton("入库");
private JButton search=new JButton("查询");
private JButton back=new JButton("返回");
private Container c=this.getContentPane();
public EquScrap_Labor() {
super("设备报废管理");
init();
}
private void init(){
JPanel jp=new JPanel();
JPanel jp1=new JPanel();
jp1.setLayout(new GridLayout(8,2));
jp1.add(equName);jp1.add(nameEqu);
jp1.add(equModel);jp1.add(modelEqu);
jp1.add(equSpec);jp1.add(specEqu);
jp1.add(equAmount);jp1.add(amountEqu);
jp1.add(equCondition);jp1.add(conditionEqu);
jp1.add(equManufacturer);jp1.add(manufacturerEqu);
jp1.add(equDate);jp1.add(dateEqu);
jiduxuanze.add("第一季度");jiduxuanze.add("第二季度");jiduxuanze.add("第三季度");jiduxuanze.add("第四季度");
jp1.add(equDate);jp1.add(dateEqu);
jp1.add(equManufacturer);jp1.add(manufacturerEqu);
jp1.add(jidu);jp1.add(jiduxuanze);
JPanel jp2=new JPanel();
jp2.add(insert);jp2.add(search);jp2.add(back);
jp.add(jp1);jp.add(jp2);
c.add(jp,BorderLayout.NORTH);
insert.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
DBConnection db=new DBConnection();
String sqlInsert="insert into equScrap(Ename,Emodel,Espec,Eamount,Econdition,Emanufacturer,Escrapdate,Escrapseason) values(?,?,?,?,?,?,?,?) ";
try {
PreparedStatement pst=db.conn.prepareStatement(sqlInsert,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
pst.setString(1, nameEqu.getText());
pst.setString(2, modelEqu.getText());
pst.setString(3, specEqu.getText());
pst.setString(4, amountEqu.getText());
pst.setString(5, conditionEqu.getText());
pst.setString(6, manufacturerEqu.getText());
pst.setString(7, dateEqu.getText());
pst.setString(8, jiduxuanze.getSelectedItem());
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "录入成功!");
} catch (SQLException e1) {
e1.printStackTrace();
}
}
});
back.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
hide_me();
Mana_Labor ul=new Mana_Labor();
}
});
search.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SearchScrap_Labor ssl=new SearchScrap_Labor();
}
});
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(500,400);
this.setVisible(true);
}
public void hide_me(){
this.setVisible(false);
}
/*public static void main(String args[]){
EquScrap_Labor sl=new EquScrap_Labor();
}*/
}
有冗余