📄 4.借书界面.txt
字号:
{
String str4_3_3;
str4_3_3=jTextField4.getText();
Statement stmt4_3_2 = conn.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_3_2 = "select * from book where 编号 = '"+str4_3_3+"'";
ResultSet rs4_3_2 = stmt4_3_2.executeQuery(sq4_3_2);
if(!rs4_3_2.next())
{
JOptionPane.showMessageDialog(this,"书籍编号错误","错误",JOptionPane.ERROR_MESSAGE);
}
else{
Statement stmt4_3_3 = conn.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_3_3 ="select 借阅情况 from book where 编号 = '"+str4_3_3+"'";
ResultSet rs4_3_3 = stmt4_3_3.executeQuery(sq4_3_3);
String a = new String("未借");
if ((rs4_3_3.next()) &&!rs4_3_3.getString("借阅情况").equals(a))
{
JOptionPane.showMessageDialog(this, "此书已借被借阅","错误", JOptionPane.ERROR_MESSAGE);
}
else
{
Statement stmt4_3_4 = conn.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_3_4 ="select 已借书籍3 from reader where ID = '"+str4_3_1+"'";
ResultSet rs4_3_4 = stmt4_3_4.executeQuery(sq4_3_4);
String b = new String("未借");
if(rs4_3_4.next()&&!rs4_3_4.getString("已借书籍3").equals(b))
{
JOptionPane.showMessageDialog(this, "此借书位已经不能借书,请尝试其他借书位","错误", JOptionPane.ERROR_MESSAGE);
}
else{
Statement stmt4_1_23 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_1_23 = "select * from book where 编号 = '"+str4_3_3+"'";
ResultSet rs4_1_23 = stmt4_1_23.executeQuery(sq4_1_23);
if(rs4_1_23.next())
{ String rs1item1 = rs4_1_23.getString("编号");
String rs1item2 = rs4_1_23.getString("书名");
String rs1item3 = rs4_1_23.getString( "作者");
String rs1item4 = rs4_1_23.getString("出版社");
jTextArea1.setText("编号: " +
rs1item1 +
'\n' +
"书名: " + rs1item2 + '\n' +
"作者: " + rs1item3 + '\n' +
"出版社: " + rs1item4 +
'\n');}
JOptionPane.showMessageDialog(this,"请核对所借的书籍信息", "成功借书",JOptionPane.OK_CANCEL_OPTION);
try
{
Statement stmt4_3_5_1 = conn.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sq4_3_5_1="select * from book where 编号='"+str4_3_3+"'";
ResultSet rs4_3_5_1 = stmt4_3_5_1.executeQuery(sq4_3_5_1);
if(rs4_3_5_1.next())
{
String bookName3 = rs4_3_5_1.getString("书名");
Statement stmt4_3_5 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sq4_3_5 ="update reader set 已借书籍3 ='"+bookName3+"' where ID ='" +str4_3_1 + "'";
stmt4_3_5.executeUpdate(sq4_3_5);
Statement stmt4_3_6 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sq4_3_6 =
"update book set 借阅情况 = '送书' where 编号 ='" +
str4_3_3 + "'";
stmt4_3_6.executeUpdate(sq4_3_6);
}
Statement stmt4_3_7 = conn.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_3_7 ="update book set 借书ID = '" +str4_3_1 + "' where 编号 ='" + str4_3_3 + "'";
stmt4_3_7.executeUpdate(sq4_3_7);
}
catch (Exception e)
{
System.err.println(e);
}
}
}
}
}
catch(Exception e)
{
System.err.println(e);
}
}
} catch(Exception e)
{
System.err.println(e);
}
}//F4_3()
public void jButton4_actionPerformed(ActionEvent e) {
F4_4();
}
void F4_4(){
try
{
String str4_4_1,str4_4_2;
str4_4_1=jTextField1.getText();
str4_4_2=new String(jPasswordField1.getPassword());
Statement stmt4_4_1 = conn.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_4_l= "select * from reader where ID='"+str4_4_1+"' AND 密码 = '"+str4_4_2+"' ";
ResultSet rs4_4_1 = stmt4_4_1.executeQuery(sq4_4_l);
if(!rs4_4_1.next())
{
JOptionPane.showMessageDialog(this,"帐号或者密码错误","错误",JOptionPane.ERROR_MESSAGE);
}
else
{
try
{
String str4_4_3;
str4_4_3=jTextField5.getText();
Statement stmt4_4_2 = conn.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_4_2 = "select * from book where 编号 = '"+str4_4_3+"'";
ResultSet rs4_4_2 = stmt4_4_2.executeQuery(sq4_4_2);
if(!rs4_4_2.next())
{
JOptionPane.showMessageDialog(this,"书籍编号错误","错误",JOptionPane.ERROR_MESSAGE);
}
else{
Statement stmt4_4_3 = conn.createStatement(
ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_4_3 ="select 借阅情况 from book where 编号 = '"+str4_4_3+"'";
ResultSet rs4_4_3 = stmt4_4_3.executeQuery(sq4_4_3);
String a = new String("未借");
if ((rs4_4_3.next()) &&!rs4_4_3.getString("借阅情况").equals(a))
{
JOptionPane.showMessageDialog(this, "此书已借被借阅","错误", JOptionPane.ERROR_MESSAGE);
}
else
{
Statement stmt4_4_4 = conn.createStatement(
ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_4_4 ="select 已借书籍4 from reader where ID = '"+str4_4_1+"'";
ResultSet rs4_4_4 = stmt4_4_4.executeQuery(sq4_4_4);
String b = new String("未借");
if(rs4_4_4.next()&&!rs4_4_4.getString("已借书籍4").equals(b))
{
JOptionPane.showMessageDialog(this, "此借书位已经不能借书,请尝试其他借书位","错误", JOptionPane.ERROR_MESSAGE);
}
else{
Statement stmt4_1_24 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_1_24 = "select * from book where 编号 = '"+str4_4_3+"'";
ResultSet rs4_1_24 = stmt4_1_24.executeQuery(sq4_1_24);
if(rs4_1_24.next())
{ String rs1item1 = rs4_1_24.getString("编号");
String rs1item2 = rs4_1_24.getString("书名");
String rs1item3 = rs4_1_24.getString( "作者");
String rs1item4 = rs4_1_24.getString("出版社");
jTextArea1.setText("编号: " +
rs1item1 +
'\n' +
"书名: " + rs1item2 + '\n' +
"作者: " + rs1item3 + '\n' +
"出版社: " + rs1item4 +
'\n');}
JOptionPane.showMessageDialog(this,"请核对所借的书籍信息", "成功借书",JOptionPane.OK_CANCEL_OPTION);
try
{
Statement stmt4_4_5_1 = conn.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sq4_4_5_1="select * from book where 编号='"+str4_4_3+"'";
ResultSet rs4_4_5_1 = stmt4_4_5_1.executeQuery(sq4_4_5_1);
if(rs4_4_5_1.next())
{
String bookName4 = rs4_4_5_1.getString("书名");
Statement stmt4_4_5 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sq4_4_5 ="update reader set 已借书籍4 ='"+bookName4+"' where ID ='" +str4_4_1 + "'";
stmt4_4_5.executeUpdate(sq4_4_5);
Statement stmt4_4_6 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sq4_4_6 =
"update book set 借阅情况 = '送书' where 编号 ='" +
str4_4_3 + "'";
stmt4_4_6.executeUpdate(sq4_4_6);
}
Statement stmt4_4_7 = conn.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sq4_4_7 ="update book set 借书ID = '" +str4_4_1 + "' where 编号 ='" + str4_4_3 + "'";
stmt4_4_7.executeUpdate(sq4_4_7);
}
catch (Exception e)
{
System.err.println(e);
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -