package 固定资产管理系统;
import java.awt.*;
import java.util.Calendar;
import javax.swing.*;
import java.sql.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Dialogreturn extends JDialog {
ConnectDataBase cdb=new ConnectDataBase();
Calendar cal=Calendar.getInstance();
JPanel panel1 = new JPanel();
JLabel lblastid = new JLabel();
JLabel lblastname = new JLabel();
JTextField txtastname = new JTextField();
JLabel lblcatename = new JLabel();
JTextField txtcatename = new JTextField();
JLabel lblsubcatename = new JLabel();
JTextField txtsubcatename = new JTextField();
JLabel lblemp = new JLabel();
JLabel lblreturndate = new JLabel();
JLabel lblreturnoperator = new JLabel();
JTextField txtreturndate = new JTextField();
JComboBox cmbreturnoperator = new JComboBox();
JButton btnreturn = new JButton();
JComboBox cmbastid = new JComboBox();
JButton btnup = new JButton();
JButton btndown = new JButton();
JLabel lbllenddate = new JLabel();
JTextField txtlenddate = new JTextField();
JTextField txtemp = new JTextField();
public Dialogreturn(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public Dialogreturn() {
this(new Frame(), "Dialoglend", false);
}
private void jbInit() throws Exception {
panel1.setLayout(null);
lblastid.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
lblastid.setText("资产编号 :");
lblastid.setBounds(new Rectangle(25, 25, 70, 20));
lblastname.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
lblastname.setText("资产名称:");
lblastname.setBounds(new Rectangle(210, 25, 70, 20));
cmbastid.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
cmbastid.setBounds(new Rectangle(90, 25, 110, 20));
cmbastid.addItemListener(new Dialogreturn_cmbastid_itemAdapter(this));
cmbastid.addItem("请选择资产编号");
for (int i = 0; i < cdb.getAstreturnid().size(); i++) {
cmbastid.addItem(cdb.getAstreturnid().get(i));
}
txtastname.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
txtastname.setEditable(false);
txtastname.setText("");
txtastname.setBounds(new Rectangle(270, 25, 110, 20));
lblcatename.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
lblcatename.setText("大类名称 :");
lblcatename.setBounds(new Rectangle(25, 75, 70, 20));
txtcatename.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
txtcatename.setEditable(false);
txtcatename.setText("");
txtcatename.setBounds(new Rectangle(90, 75, 110, 20));
lblsubcatename.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
lblsubcatename.setText("小类名称:");
lblsubcatename.setBounds(new Rectangle(210, 75, 70, 20));
txtsubcatename.setText("");
txtsubcatename.setBounds(new Rectangle(270, 75, 110, 20));
txtsubcatename.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
txtsubcatename.setEditable(false);
lblemp.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
lblemp.setText(" 领用人 :");
lblemp.setBounds(new Rectangle(25, 125, 70, 20));
lblreturndate.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
lblreturndate.setText("归还日期 :");
lblreturndate.setBounds(new Rectangle(25, 175, 80, 20));
lblreturnoperator.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
lblreturnoperator.setText("归还操作员:");
lblreturnoperator.setBounds(new Rectangle(200, 175, 80, 20));
java.sql.Date dd=new Date(cal.getTimeInMillis());
txtreturndate.setText(String.valueOf(dd));
txtreturndate.setBounds(new Rectangle(90, 175, 110, 20));
txtreturndate.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
txtreturndate.setEditable(false);
cmbreturnoperator.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
cmbreturnoperator.setBounds(new Rectangle(270, 175, 110, 20));
for(int i=0;i cmbreturnoperator.addItem(cdb.getAstlendoperator().get(i));
}
this.setTitle("归还信息");
btnreturn.setBounds(new Rectangle(290, 235, 80, 25));
btnreturn.setFont(new java.awt.Font("宋体", Font.BOLD, 13));
btnreturn.setText("归还");
btnreturn.addActionListener(new Dialogreturn_btnreturn_actionAdapter(this));
btnup.setBounds(new Rectangle(120, 235, 80, 25));
btnup.setFont(new java.awt.Font("宋体", Font.BOLD, 13));
btnup.setText("上一条");
btnup.addActionListener(new Dialogreturn_btnup_actionAdapter(this));
btndown.setBounds(new Rectangle(205, 235, 80, 25));
btndown.setFont(new java.awt.Font("宋体", Font.BOLD, 13));
btndown.setText("下一条");
btndown.addActionListener(new Dialogreturn_btndown_actionAdapter(this));
lbllenddate.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
lbllenddate.setText("领用日期:");
lbllenddate.setBounds(new Rectangle(210, 125, 80, 20));
txtlenddate.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
txtlenddate.setEditable(false);
txtlenddate.setText("");
txtlenddate.setBounds(new Rectangle(270, 125, 110, 20));
txtemp.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
txtemp.setEditable(false);
txtemp.setText("");
txtemp.setBounds(new Rectangle(90, 125, 110, 20));
getContentPane().add(panel1);
panel1.add(lblastid);
panel1.add(lblastname);
panel1.add(txtastname);
panel1.add(lblcatename);
panel1.add(txtcatename);
panel1.add(lblsubcatename);
panel1.add(txtsubcatename);
panel1.add(lblemp);
panel1.add(btnreturn);
panel1.add(cmbastid);
panel1.add(btnup);
panel1.add(btndown);
panel1.add(cmbreturnoperator);
panel1.add(lblreturnoperator);
panel1.add(lblreturndate);
panel1.add(txtreturndate);
panel1.add(lbllenddate);
panel1.add(txtlenddate);
panel1.add(txtemp);
}
public void cmbastid_itemStateChanged(ItemEvent e) {
if(cmbastid.getSelectedItem().equals("请选择资产编号")){
txtastname.setText("");
txtcatename.setText("");
txtsubcatename.setText("");
txtemp.setText("");
txtlenddate.setText("");
}
else{
txtastname.setText(cdb.getAstlendinfo(String.valueOf(cmbastid.
getSelectedItem())).get(0).toString());
txtcatename.setText(cdb.getAstlendinfo(String.valueOf(cmbastid.
getSelectedItem())).get(1).toString());
txtsubcatename.setText(cdb.getAstlendinfo(String.valueOf(cmbastid.
getSelectedItem())).get(2).toString());
txtemp.setText(cdb.getreturninfo(String.valueOf(cmbastid.
getSelectedItem())).get(1).toString());
txtlenddate.setText(cdb.getreturninfo(String.valueOf(cmbastid.
getSelectedItem())).get(2).toString());
}
}
public void btnup_actionPerformed(ActionEvent e) {
if(cmbastid.getSelectedIndex()!=0){
cmbastid.setSelectedIndex(cmbastid.getSelectedIndex()-1);
}
}
public void btndown_actionPerformed(ActionEvent e) {
if(cmbastid.getSelectedIndex() cmbastid.setSelectedIndex(cmbastid.getSelectedIndex() + 1);
}
}
public void btnreturn_actionPerformed(ActionEvent e) {
if(txtastname.getText().equals("")){
JOptionPane.showMessageDialog(this,"请选择资产编号","错误",
JOptionPane.ERROR_MESSAGE);
}
else if(JOptionPane.showConfirmDialog(this,"确定要归还资产吗?","归还信息",0)==0){
cdb.updatereturn(String.valueOf(cmbastid.getSelectedItem()),
txtreturndate.getText(),
String.valueOf(cmbreturnoperator.getSelectedItem()));
JOptionPane.showMessageDialog(this,"归还资产已经完成!","成功归还",
JOptionPane.INFORMATION_MESSAGE);
cmbastid.removeItem(cmbastid.getSelectedItem());
}
}
}
class Dialogreturn_btnreturn_actionAdapter implements ActionListener {
private Dialogreturn adaptee;
Dialogreturn_btnreturn_actionAdapter(Dialogreturn adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnreturn_actionPerformed(e);
}
}
class Dialogreturn_btndown_actionAdapter implements ActionListener {
private Dialogreturn adaptee;
Dialogreturn_btndown_actionAdapter(Dialogreturn adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btndown_actionPerformed(e);
}
}
class Dialogreturn_btnup_actionAdapter implements ActionListener {
private Dialogreturn adaptee;
Dialogreturn_btnup_actionAdapter(Dialogreturn adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnup_actionPerformed(e);
}
}
class Dialogreturn_cmbastid_itemAdapter implements ItemListener {
private Dialogreturn adaptee;
Dialogreturn_cmbastid_itemAdapter(Dialogreturn adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.cmbastid_itemStateChanged(e);
}
}