📄 managerview.java
字号:
borrow=LM.bookBorrow(num,r_name);
if (borrow==true)
JOptionPane.showMessageDialog(null,"恭喜~~借书成功!");
else
JOptionPane.showMessageDialog(null,"对不起,您不能借阅该书!");
}
if (source==jbt1[1]){
String jtf1=jtf_num[1].getText();
int num=Integer.parseInt(jtf1);
Return=LM.bookReturn(num,r_name);
if (Return==true)
JOptionPane.showMessageDialog(null,"恭喜~~还书成功!");
else
JOptionPane.showMessageDialog(null,"对不起,您不能归还该书!");
}
if (source==jbt1[2]){
String jtf1=jtf_num[2].getText();
int num=Integer.parseInt(jtf1);
renew=LM.renew(num,r_name);
if (renew==true)
JOptionPane.showMessageDialog(null,"恭喜~~续借成功!");
else
JOptionPane.showMessageDialog(null,"对不起,您不能续借该书!");
}
}
}
class bt_find implements ActionListener{
public void actionPerformed(ActionEvent evt) {
findlist= (String)findList.getSelectedItem();
String find=tf_find.getText();
if (findlist.equals("编号")){
bk=LM.searchByNO(Integer.parseInt(find));
if (bk==null)
JOptionPane.showMessageDialog(null,"本图书馆没有此书!");
else{
text1.setText(bk.getNO()+" "+bk.getName()+
" "+bk.getSort()+" "+bk.getAuthor()+
" "+bk.getPublisher()+" "+bk.getPrice()+
" "+bk.getPublicTime());
}
}
if (findlist.equals("书名")){
bk=LM.searchByName(find);
if (bk==null)
JOptionPane.showMessageDialog(null,"本图书馆没有此书!");
else{
text1.setText(bk.getNO()+" "+bk.getName()+
" "+bk.getSort()+" "+bk.getAuthor()+
" "+bk.getPublisher()+" "+bk.getPrice()+
" "+bk.getPublicTime());
}
}
if (findlist.equals("类别")){
for (int i=0;i<10;i++){
sort_book[i]=(LM.searchBySort(find))[i];
if (sort_book[i]==null)
JOptionPane.showMessageDialog(null,"本图书馆没有此书!");
else{
text1.insert(sort_book[i].getNO()+" "+sort_book[i].getName()+
" "+sort_book[i].getSort()+" "+sort_book[i].getAuthor()+
" "+sort_book[i].getPublisher()+" "+sort_book[i].getPrice()+
" "+sort_book[i].getPublicTime()+"\n",0);
}
}
}
}
}
class Add implements ActionListener{
public void actionPerformed(ActionEvent evt) {
for (int i=0;i<7;i++)
info[i]=tf_bkinfo[i].getText();
add=LM.bookAdd(info[0], info[1], info[2], info[3], info[4], Double.parseDouble(info[5]), info[6]);
if (add==true)
JOptionPane.showMessageDialog(null,"恭喜~~添加成功!");
else
JOptionPane.showMessageDialog(null,"对不起,不能添加!");
}
}
class Delet implements ActionListener{
public void actionPerformed(ActionEvent evt) {
int num=Integer.parseInt(tf_remove.getText());
delet=LM.bookDel(num);
if (delet==true)
JOptionPane.showMessageDialog(null,"恭喜~~删除成功!");
else
JOptionPane.showMessageDialog(null,"对不起,您不能删除该书!");
}
}
class Look implements ActionListener{
public void actionPerformed(ActionEvent evt) {
for (int i=0;i<100;i++)
library_store[i]=new Book();
String r,temp1,temp2,temp3,temp4,temp5,temp6,temp7,temp8,temp9,temp0;
int count=0;
try{
FileReader fileReader = new FileReader("library.txt");
BufferedReader bufferReader = new BufferedReader(fileReader);
while ((r = bufferReader.readLine()) != null) {
StringTokenizer toKen_Student = new StringTokenizer(r);
temp0=toKen_Student.nextToken();
temp1=toKen_Student.nextToken();
temp2=toKen_Student.nextToken();
temp3=toKen_Student.nextToken();
temp4=toKen_Student.nextToken();
temp5=toKen_Student.nextToken();
temp6=toKen_Student.nextToken();
temp7=toKen_Student.nextToken();
temp8=toKen_Student.nextToken();
temp9=toKen_Student.nextToken();
library_store[count].setNO(Integer.parseInt(temp0));
library_store[count].setName(temp1);
library_store[count].setSort(temp2);
library_store[count].setHolder(temp3);
library_store[count].setDeadline(temp4);
library_store[count].setISBN(temp5);
library_store[count].setAuthor(temp6);
library_store[count].setPublisher(temp7);
library_store[count].setPrice(Double.parseDouble(temp8));
library_store[count].setPublicTime(temp9);
count++;
}
}catch(IOException ie){
System.err.println("error:" + ie.getMessage());
}
for (int i=0;i<count;i++)
text1.insert(library_store[i].getNO()+" "+library_store[i].getName()+
" "+library_store[i].getSort()+" "+library_store[i].getAuthor()+
" "+library_store[i].getPublisher()+" "+library_store[i].getPrice()+
" "+library_store[i].getPublicTime()+"\n",0);
}
}
class Reserve implements ActionListener{
public void actionPerformed(ActionEvent evt) {
for (int i=0;i<100;i++)
library_store[i]=new Book();
String r,temp1,temp2,temp3,temp4,temp5,temp6,temp7,temp8,temp9,temp0;
int count=0;
try{
FileReader fileReader = new FileReader("reserve.txt");
BufferedReader bufferReader = new BufferedReader(fileReader);
while ((r = bufferReader.readLine()) != null) {
StringTokenizer toKen_Student = new StringTokenizer(r);
temp0=toKen_Student.nextToken();
temp1=toKen_Student.nextToken();
temp2=toKen_Student.nextToken();
temp3=toKen_Student.nextToken();
temp4=toKen_Student.nextToken();
temp5=toKen_Student.nextToken();
temp6=toKen_Student.nextToken();
temp7=toKen_Student.nextToken();
temp8=toKen_Student.nextToken();
temp9=toKen_Student.nextToken();
library_store[count].setNO(Integer.parseInt(temp0));
library_store[count].setName(temp1);
library_store[count].setSort(temp2);
library_store[count].setHolder(temp3);
library_store[count].setDeadline(temp4);
library_store[count].setISBN(temp5);
library_store[count].setAuthor(temp6);
library_store[count].setPublisher(temp7);
library_store[count].setPrice(Double.parseDouble(temp8));
library_store[count].setPublicTime(temp9);
count++;
}
}catch(IOException ie){
System.err.println("error:" + ie.getMessage());
}
for (int i=0;i<count;i++)
text1.insert(library_store[i].getNO()+" "+library_store[i].getName()+
" "+library_store[i].getSort()+" "+library_store[i].getAuthor()+
" "+library_store[i].getPublisher()+" "+library_store[i].getPrice()+
" "+library_store[i].getPublicTime()+"\n",0);
}
}
class clear implements ActionListener{
public void actionPerformed(ActionEvent evt) {
Object source = evt.getSource();
for (int i=0;i<7;i++){
tf_bkinfo[i].setText(" ");
}
}
}
class cancel implements ActionListener{
public void actionPerformed(ActionEvent evt) {
for (int i=0;i<3;i++){
jtf_name[i].setText(" ");
}
}
}
class cancel2 implements ActionListener{
public void actionPerformed(ActionEvent evt) {
for (int i=0;i<7;i++){
jtf_num[i].setText(" ");
}
}
}
CardLayout lf_card;
private JPanel wp=new JPanel();
private JPanel np=new JPanel();
private JPanel ep=new JPanel();
private JPanel []lf_pn=new JPanel[8];
private JLabel label1,label2;
private JLabel []jlabel_name=new JLabel[3];
private JLabel []jlabel_num=new JLabel[3];
private JTextField []jtf_name=new JTextField[3];
private JTextField []jtf_num=new JTextField[3];
private JTextArea text1;
private Box b1,b3,b2;
private Box[]jb_find=new Box[3];
private Box[]jb_fc=new Box[3];
private Box[]jb_name=new Box[3];
private Box[]jb_num=new Box[3];
private JButton[] jbt_fname=new JButton[3];
private JButton[] jbt_fcancel=new JButton[3];
private Box[] jb_bt=new Box[3];
private JScrollPane scroll;
private JButton [] bt=new JButton[8];
private JButton [] jbt1=new JButton[3];
private JButton [] jbt2=new JButton[3];
private JTextField tf_find;
private JButton bt_find;
private Box b_hfind;
private JButton bt_look;
private JLabel lb_look;
private String[]bk_info={"书名称:","类别: ","ISBN: ","作者: ","出版社:","价钱: ","出版日期:"};
private JLabel [] lb_bkinfo=new JLabel[7];
private JTextField []tf_bkinfo=new JTextField[7];
private Box[] b_bkinfo=new Box[7];
private JButton btadd_ok,bt_clear;
private Box b_hbt;
private JButton bt_remove,bt_reserve;
private JLabel lb_remove;
private JTextField tf_remove;
private Box bre_name;
private Box[]b_vadd=new Box[8];
private String r_name,findlist;
private JComboBox findList;
private String[] findName={"编号","书名","类别"};
private boolean borrow=false;
private boolean Return=false;
private boolean renew=false;
private boolean add=false;
private boolean delet=false;
private String[] info={"","","","","","",""};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -