From d20eaef005395bbc1de9eede6995a3269ee13965 Mon Sep 17 00:00:00 2001 From: uboger <928044283@qq.com> Date: Sun, 17 Jan 2021 03:11:30 +0800 Subject: [PATCH] Update Back.java --- Back.java | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Back.java b/Back.java index ceee3d9..e1d8d23 100644 --- a/Back.java +++ b/Back.java @@ -12,19 +12,19 @@ public class Back extends Frame { * */ private static final long serialVersionUID = 7670129939284773294L; - Label bookidlb = new Label("ͼ"), readeridlb = new Label("߱"); + Label bookidlb = new Label("图书编号"), readeridlb = new Label("读者编号"); TextField bookidtxt = new TextField(), readeridtxt = new TextField(); - Button querybtn = new Button("ѯ"), borrowbtn = new Button(""), - closebtn = new Button(""); + Button querybtn = new Button("查询"), borrowbtn = new Button("还书"), + closebtn = new Button("清除"); String SepLine = "--------------------------------------------------"; - String[] sep = { "ͼϢ", "Ϣ", "Ϣ" }; + String[] sep = { "图书信息", "读者信息", "借阅信息" }; Label[] seplabel = new Label[3]; - String[] optionname = { "", "ߣ", "磺", "ʱ䣺", "ۣ", "", "","ͣ", "ɽ", "ɽ", "ڣ","Ķ","" }; + String[] optionname = { "书名:", "作者:", "出版社:", "出版时间:", "定价:", "存量:", "姓名:","类型:", "可借数:", "可借天数:", "借阅日期:","阅读天数:","还书日期" }; Label[] alloption = new Label[13]; Label[] showoption = new Label[13]; public Back() { - setTitle("ͼ黹"); + setTitle("图书归还"); setLayout(null); setSize(500, 470); setResizable(false); @@ -46,7 +46,7 @@ public Back() { ly = ly + 30; } if (ly == 90 || ly == 210 || ly == 300) { - System.out.println(i);// /̫ + System.out.println(i);// /太奇怪了 seplabel[i] = new Label(SepLine + sep[i] + SepLine); seplabel[i].setBounds(20, ly, 440, 20); add(seplabel[i]); @@ -107,18 +107,18 @@ public void borrowActionPerformed(ActionEvent e) { if (!bookid.equals("") && !readerid.equals("")) { Date currentdate = new Date(); String borrowbackdate = showoption[12].getText(); - String sql = "update borrow set back_date='"+borrowbackdate+"',if_back=''"; - sql=sql+"where book_id='"+bookid+"'and reader_id='"+readerid+"'and if_back=''"; + String sql = "update borrow set back_date='"+borrowbackdate+"',if_back='是'"; + sql=sql+"where book_id='"+bookid+"'and reader_id='"+readerid+"'and if_back='否'"; String sql1 = "update book set stock='" + (Integer.parseInt(showoption[5].getText()) + 1) + "'" + "where id='" + bookid + "'"; int success = DbOp.executeUpdate(sql); if (success == 1) { DbOp.executeUpdate(sql1); - JOptionPane.showMessageDialog(null, "ɹ"); + JOptionPane.showMessageDialog(null, "还书成功"); } else { - JOptionPane.showMessageDialog(null, "ݵǼʧܣ"); + JOptionPane.showMessageDialog(null, "还书数据登记失败!"); } setInitialize(); } @@ -128,14 +128,14 @@ public void queryActionPerformed(ActionEvent e) { String bookid = bookidtxt.getText(), readerid = readeridtxt.getText(); if (!bookid.equals("") && !readerid.equals("")) { } else { - JOptionPane.showMessageDialog(null, "ͼźͶ߱ŶΪ"); + JOptionPane.showMessageDialog(null, "图书编号和读者编号都不可以为空"); setInitialize(); return; } Book book = BookSelect.SelectBookByID(bookid); Reader reader = ReaderSelect.SelectReaderByID(readerid); if (!IfBorrowBack.findBook(bookid, readerid)) { - JOptionPane.showMessageDialog(null,"ѯö߽Ȿ"); + JOptionPane.showMessageDialog(null,"查询不到该读者借阅这本书"); setInitialize(); return; @@ -154,7 +154,7 @@ public void queryActionPerformed(ActionEvent e) { showoption[8].setText(String.valueOf(reader.getMax_num())); showoption[9].setText(String.valueOf(reader.getDays_num())); } else { - JOptionPane.showMessageDialog(null, "ڸͼö"); + JOptionPane.showMessageDialog(null, "不存在该图书或该读者"); setInitialize(); return; @@ -170,14 +170,14 @@ public void queryActionPerformed(ActionEvent e) { bookidtxt.setEditable(false); readeridtxt.setEditable(false); } - public boolean IfLeapYear(int year) {// Ƿ꣬ڼʱ + public boolean IfLeapYear(int year) {// 是否闰年,用于计算时间差 if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) { return true; } return false; } - public String getReaderBorrowDays(Date date1, Date date2) {// ʱ + public String getReaderBorrowDays(Date date1, Date date2) {// 计算时间差 String sum = ""; int year1 = 0, month1 = 0, day1 = 0; int year2 = 0, month2 = 0, day2 = 0; @@ -222,11 +222,11 @@ public void queryActionPerformed(ActionEvent e) { sum = String.valueOf(count); return sum; } - public Date getBorrowDate(String bookid, String readerid) {// ȡ߽ + public Date getBorrowDate(String bookid, String readerid) {// 获取读者借书日期 String sql, mydate = ""; Date readerdate = new Date(); sql = "select * from borrow where book_id='" + bookid - + "' and reader_id='" + readerid + "' and if_back=''"; + + "' and reader_id='" + readerid + "' and if_back='否'"; ResultSet rs = DbOp.executeQuery(sql); try { if (rs.next()) { @@ -236,9 +236,9 @@ public void queryActionPerformed(ActionEvent e) { readerdate = sdf.parse(mydate); DbOp.close(); } catch (SQLException e) { - JOptionPane.showMessageDialog(null, "ڲѯʧ"); + JOptionPane.showMessageDialog(null, "借书日期查询失败"); } catch (ParseException e2) { - JOptionPane.showMessageDialog(null, "쳣"); + JOptionPane.showMessageDialog(null, "借书日期异常"); } return readerdate; } @@ -255,7 +255,7 @@ public void setInitialize() { borrowbtn.setEnabled(false); } - public static void main(String[] args){ + public static void main(String[] args){ new Back(); } -} \ No newline at end of file +}