📄 frminfo.java~23~
字号:
package bookmanager;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.util.Calendar;
import javax.swing.*;
import java.awt.Image;
public class frminfo extends JFrame {
Calendar cd;
Image i;
public frminfo() {
try {
jbInit();
i=getToolkit().getImage("D:\\曾新焱\\ceEXnBojeWcRg[1].jpg");
this.setIconImage(i);
cd=Calendar.getInstance();
Date dd=new Date(cd.getTimeInMillis());
txtindate.setText(dd.toString());
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
this.setTitle("图书入库");
this.setBackground(Color.blue);
lblmoon.setText("图书编号:");
lblmoon.setBounds(new Rectangle(0, 0, 55, 25));
txtnohk.setBorder(BorderFactory.createEtchedBorder());
txtnohk.setText("");
txtnohk.setBounds(new Rectangle(68, 4, 96, 28));
lblwer.setText("图书名称:");
lblwer.setBounds(new Rectangle(194, 1, 63, 25));
txtgoogl.setBorder(BorderFactory.createEtchedBorder());
txtgoogl.setText("");
txtgoogl.setBounds(new Rectangle(266, 4, 121, 26));
lblauo.setText("作者:");
lblauo.setBounds(new Rectangle(2, 50, 40, 22));
txtauo.setBorder(BorderFactory.createEtchedBorder());
txtauo.setText("");
txtauo.setBounds(new Rectangle(69, 45, 96, 30));
lblprice.setText("价格:");
lblprice.setBounds(new Rectangle(195, 46, 61, 21));
txtprice.setBorder(BorderFactory.createEtchedBorder());
txtprice.setText("");
txtprice.setBounds(new Rectangle(266, 44, 120, 24));
lblchub.setText("出版社:");
lblchub.setBounds(new Rectangle(1, 95, 47, 21));
txtchubj.setBorder(BorderFactory.createEtchedBorder());
txtchubj.setText("");
txtchubj.setBounds(new Rectangle(69, 91, 96, 29));
lblchdate.setText("出版时间:");
lblchdate.setBounds(new Rectangle(195, 94, 60, 26));
txtchdate.setBorder(BorderFactory.createEtchedBorder());
txtchdate.setText("");
txtchdate.setBounds(new Rectangle(266, 94, 120, 25));
lblindate.setText("入库日期:");
lblindate.setBounds(new Rectangle(1, 144, 62, 28));
txtindate.setBorder(BorderFactory.createEtchedBorder());
txtindate.setText("");
txtindate.setBounds(new Rectangle(68, 142, 101, 32));
lblnotesd.setText("页数:");
lblnotesd.setBounds(new Rectangle(197, 147, 54, 24));
txtnotesd.setBorder(BorderFactory.createEtchedBorder());
txtnotesd.setText("");
txtnotesd.setBounds(new Rectangle(265, 145, 121, 27));
btninput.setBounds(new Rectangle(4, 227, 83, 45));
btninput.setBorder(BorderFactory.createEtchedBorder());
btninput.setText("入库");
btninput.addActionListener(new frminfo_btninput_actionAdapter(this));
btnoutp.setBounds(new Rectangle(301, 227, 92, 45));
btnoutp.setBorder(BorderFactory.createEtchedBorder());
btnoutp.setText("取消");
btnoutp.addActionListener(new frminfo_btnoutp_actionAdapter(this));
btnwriteon.setBounds(new Rectangle(144, 227, 96, 45));
btnwriteon.setBorder(BorderFactory.createEtchedBorder());
btnwriteon.setText("重置");
btnwriteon.addActionListener(new frminfo_btnwriteon_actionAdapter(this));
lblifno.setText("是否在库:");
lblifno.setBounds(new Rectangle(1, 186, 59, 25));
cmbifno.setBorder(BorderFactory.createEtchedBorder());
cmbifno.setBounds(new Rectangle(67, 185, 101, 26));
cmbifno.addItem("是");
cmbifno.addItem("否");
cmbifno.setSelectedIndex(0);
this.getContentPane().add(lblmoon);
this.getContentPane().add(txtauo);
this.getContentPane().add(txtchubj);
this.getContentPane().add(txtindate);
this.getContentPane().add(lblindate);
this.getContentPane().add(lblchub);
this.getContentPane().add(lblauo);
this.getContentPane().add(lblwer);
this.getContentPane().add(lblprice);
this.getContentPane().add(lblchdate);
this.getContentPane().add(lblnotesd);
this.getContentPane().add(txtnohk);
this.getContentPane().add(txtgoogl);
this.getContentPane().add(txtprice);
this.getContentPane().add(txtchdate);
this.getContentPane().add(txtnotesd);
this.getContentPane().add(btninput);
this.getContentPane().add(btnwriteon);
this.getContentPane().add(btnoutp);
this.getContentPane().add(lblifno);
this.getContentPane().add(cmbifno);
}
JLabel lblmoon = new JLabel();
JTextField txtnohk = new JTextField();
JLabel lblwer = new JLabel();
JTextField txtgoogl = new JTextField();
JLabel lblauo = new JLabel();
JTextField txtauo = new JTextField();
JLabel lblprice = new JLabel();
JTextField txtprice = new JTextField();
JLabel lblchub = new JLabel();
JTextField txtchubj = new JTextField();
JLabel lblchdate = new JLabel();
JTextField txtchdate = new JTextField();
JLabel lblindate = new JLabel();
JTextField txtindate = new JTextField();
JLabel lblnotesd = new JLabel();
JTextField txtnotesd = new JTextField();
JButton btninput = new JButton();
JButton btnoutp = new JButton();
JButton btnwriteon = new JButton();
JLabel lblifno = new JLabel();
JComboBox cmbifno = new JComboBox();
public void btnoutp_actionPerformed(ActionEvent e) {
this.dispose();
}
public void btnwriteon_actionPerformed(ActionEvent e) {
txtnohk.setText("");
txtchdate.setText("");
txtgoogl.setText("");
txtauo.setText("");
txtnotesd.setText("");
txtprice.setText("");
txtchubj.setText("");
}
public void btninput_actionPerformed(ActionEvent e) {
int j=0;
bookinfo b=new bookinfo();
if(txtnohk.getText().equals(""))
{
JOptionPane.showMessageDialog(this,"图书编号不能为空!","错误",
JOptionPane.ERROR_MESSAGE);
}
else
{
b.setbookid(txtnohk.getText());
if(txtgoogl.getText().equals(""))
{
JOptionPane.showMessageDialog(this,"图书名称不能为空!","错误",
JOptionPane.ERROR_MESSAGE);
}
else
{
b.setbookname(txtgoogl.getText());
b.setbookautor(txtauo.getText());
if(txtprice.getText().equals(""))
{
JOptionPane.showMessageDialog(this,"图书价格不能为空!","请重输",JOptionPane.ERROR_MESSAGE);
}
else
{
b.setbookbalance(Float.parseFloat(txtprice.getText()));
b.setbookwhere(txtchubj.getText());
String s1=txtchdate.getText();
if(s1.equals(""))
{
JOptionPane.showMessageDialog(this,"日期不能为空!","请重输",JOptionPane.ERROR_MESSAGE);
}
else
{
if ((s1.substring(4, 5).equals("-") &&
s1.substring(7, 8).equals("-")) == false) {
JOptionPane.showMessageDialog(this, "请输入正确的日期格式!",
"请重输", JOptionPane.ERROR_MESSAGE);
} else {
b.setbooktime(txtchdate.getText());
b.setouttime(txtindate.getText());
if(txtnotesd.getText().equals(""))
{
JOptionPane.showMessageDialog(this,"图书页数不能为空!","请重输",JOptionPane.ERROR_MESSAGE);
}
else
{
b.setbooknotes(Integer.parseInt(txtnotesd.getText()));
}
}
}
}
if(cmbifno.getSelectedItem().toString().equals("否"))
{
JOptionPane.showMessageDialog(this,"入库不能选择否!","错误",
JOptionPane.ERROR_MESSAGE);
}
else
{
b.setonoutctrl(cmbifno.getSelectedItem().toString());
}
}
}
dialogkit gk=new dialogkit();
j=gk.ifreadture(b);
if(j==1)
{
JOptionPane.showMessageDialog(this,"成功入库","请继续",JOptionPane.OK_OPTION);
}
}
}
class frminfo_btninput_actionAdapter implements ActionListener {
private frminfo adaptee;
frminfo_btninput_actionAdapter(frminfo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btninput_actionPerformed(e);
}
}
class frminfo_btnwriteon_actionAdapter implements ActionListener {
private frminfo adaptee;
frminfo_btnwriteon_actionAdapter(frminfo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnwriteon_actionPerformed(e);
}
}
class frminfo_btnoutp_actionAdapter implements ActionListener {
private frminfo adaptee;
frminfo_btnoutp_actionAdapter(frminfo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnoutp_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -