📄 xujie.java~44~
字号:
package infomanagement;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2003</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import com.borland.dbswing.*;
import com.borland.dx.sql.dataset.*;
import com.borland.dx.dataset.*;
import java.awt.event.*;
import java.awt.Font;
import java.awt.BorderLayout;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class xujie extends JDialog {
private JPanel jPanel1 = new JPanel();
private XYLayout xYLayout1 = new XYLayout();
private JLabel jLabel1 = new JLabel();
private JLabel jLabel4 = new JLabel();
private QueryDataSet queryDataSet1 = new QueryDataSet();
private Database database1 = new Database();
private QueryDataSet queryDataSet2 = new QueryDataSet();
private Column column1 = new Column();
JLabel jLabel2 = new JLabel();
JLabel jLabel5 = new JLabel();
JTextField jTextField2 = new JTextField();
JButton jButton1 = new JButton();
JLabel jLabel6 = new JLabel();
JTextField jTextField3 = new JTextField();
public xujie(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public xujie() {
this(null, "", false);
}
private void jbInit() throws Exception {
jPanel1.setLayout(xYLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 23));
jLabel1.setForeground(Color.magenta);
jLabel1.setBorder(BorderFactory.createEtchedBorder());
jLabel1.setText(" 续借图书");
jLabel4.setBorder(BorderFactory.createEtchedBorder());
database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor
("jdbc:odbc:local", "sa", "", false,
"sun.jdbc.odbc.JdbcOdbcDriver"));
column1.setColumnName("NewColumn1");
column1.setDataType(com.borland.dx.dataset.Variant.STRING);
column1.setPreferredOrdinal(0);
column1.setServerColumnName("NewColumn1");
column1.setSqlType(0);
jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
jLabel2.setForeground(Color.red);
jLabel2.setText(" 请输入学号和书号");
jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
jLabel5.setForeground(Color.magenta);
jLabel5.setText("学号");
jButton1.setText("续借");
jButton1.addMouseListener(new java.awt.event.MouseAdapter()
{
//判断输入是否正确,是就进入,否就弹出一个对话框提示错误
public void mouseClicked(MouseEvent e){
abClicked(e);
}
}
);
jLabel6.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
jLabel6.setForeground(Color.magenta);
jLabel6.setText("书号");
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jLabel1, new XYConstraints(0, 1, 399, 53));
jPanel1.add(jLabel2, new XYConstraints(35, 72, -1, -1));
jPanel1.add(jLabel6, new XYConstraints(130, 184, -1, -1));
jPanel1.add(jTextField3, new XYConstraints(174, 185, 80, -1));
jPanel1.add(jLabel5, new XYConstraints(133, 136, -1, -1));
jPanel1.add(jTextField2, new XYConstraints(174, 142, 78, -1));
jPanel1.add(jLabel4, new XYConstraints(5, 101, 397, 202));
jPanel1.add(jButton1, new XYConstraints(170, 246, -1, -1));
}
void abClicked(MouseEvent e)
{
String b=jTextField2.getText();
String c=jTextField3.getText();
Calendar currentCalendars= Calendar.getInstance();
int years= currentCalendars.get(Calendar.YEAR);//年
int months= currentCalendars.get(Calendar.MONTH)+1;//月
int days= currentCalendars.get(Calendar.DAY_OF_MONTH);//日
String dd=years+"-"+months+"-"+days;
try
{
dabaco bb = new dabaco();
boolean mk=false;
boolean ttt=false;
String jj3="select 借书日期,续借日期 from bookjc where 学号="+"'"+b+"'";
//String jj4="select 借书日期 from bookjc where 学号="+"'"+a+"'";
ResultSet gj3=bb.stmt.executeQuery(jj3);
//String heu=jj31.getString(2);
//System.out.println(heu);
while (gj3.next())
{
String gjj3=gj3.getString(1);
String hjj3=gj3.getString(2);
//System.out.println(gjj3);
if(hjj3==null||hjj3.length()==0)
{
if(gjj3!=null&&gjj3.length()!=0)
{
int oop=gjj3.indexOf("-");
int oop1=gjj3.indexOf("-",oop+1);
String days1=gjj3.substring(oop1+1);
String months1=gjj3.substring(oop+1,oop1);
String years1=gjj3.substring(0,oop);
int days2=Integer.parseInt(days1);
int months2=Integer.parseInt(months1);
int years2=Integer.parseInt(years1);
int cha=((years-years2)*12+months-months2)*30+days-days2;
if(cha>=30)
{
ttt=true;
}
}
else
{
}
}
else
{
int oop=hjj3.indexOf("-");
int oop1=hjj3.indexOf("-",oop+1);
String days1=hjj3.substring(oop1+1);
String months1=hjj3.substring(oop+1,oop1);
String years1=hjj3.substring(0,oop);
int days2=Integer.parseInt(days1);
int months2=Integer.parseInt(months1);
int years2=Integer.parseInt(years1);
int cha=((years-years2)*12+months-months2)*30+days-days2;
if(cha>=30)
{
ttt=true;
}
}
}
if(ttt==false)
{
String jj1="update bookjc set 续借日期="+"'"+dd+"'"+"where 学号="+"'"+b+"'"
+"and 书号="+"'"+c+"'";
String jj2="update historya set 续借日期="+"'"+dd+"'"+"where 学号="+"'"+b+"'"
+"and 书号="+"'"+c+"'";
//String jj3="select 续借日期 from bookjc where 学号="+"'"+b+"'"+"and 书号="+"'"+c+"'";
String jj4="select 借书日期 from bookjc where 学号="+"'"+b+"'"+"and 书号="+"'"+c+"'";
ResultSet rt=bb.stmt.executeQuery(jj3);
String rt1="";
while(rt.next())
{
rt1=rt.getString(1);
}
if(rt1==null||rt1.length()==0)
{
ResultSet rtt=bb.stmt.executeQuery(jj4);
String rtt1="";
while(rtt.next())
{
rtt1 = rtt.getString(1);
}
//System.out.println("ddddddddddd");
int oop=rtt1.indexOf("-");
int oop1=rtt1.indexOf("-",oop+1);
String days1=rtt1.substring(oop1+1);
String months1=rtt1.substring(oop+1,oop1);
String years1=rtt1.substring(0,oop);
int days2=Integer.parseInt(days1);
int months2=Integer.parseInt(months1);
int years2=Integer.parseInt(years1);
int cha=((years-years2)*12+months-months2)*30+days-days2;
if(cha<=30)
{
ResultSet ffg = bb.stmt.executeQuery(jj1 + jj2);
}
else
{
String fhg="已经过期,不能续借";
cheng dlg=new cheng(fhg);
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 +
loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.setModal(true);
dlg.pack();
dlg.setVisible(true);
}
}
else
{
String dtt="已经续借过,不能再续借";
cheng dlg=new cheng(dtt);
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 +
loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.setModal(true);
dlg.pack();
dlg.setVisible(true);
}
}
}
catch(Exception ex)
{
}
}
void cancel()
{
dispose() ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -