⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jiechu.java

📁 这是自己做的图书馆信息管理系统
💻 JAVA
字号:
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.Statement;
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 jiechu 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 jiechu(Frame frame, String title, boolean modal) {
    super(frame, title, modal);
    try {
      jbInit();
      pack();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  public jiechu() {
    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(jButton1, new XYConstraints(164, 246, -1, -1));
    jPanel1.add(jLabel2, new XYConstraints(35, 72, -1, -1));
    jPanel1.add(jLabel5, new XYConstraints(138, 136, -1, -1));
    jPanel1.add(jTextField2, new XYConstraints(185, 140, 78, -1));
    jPanel1.add(jTextField3, new XYConstraints(186, 185, 80, -1));
    jPanel1.add(jLabel6, new XYConstraints(140, 183, -1, -1));
    jPanel1.add(jLabel4, new XYConstraints(2, 102, 397, 202));
  }

  void abClicked(MouseEvent e)
    {
      String a=jTextField2.getText();
      String b=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();
        //Statement ps = bb.conn.createStatement();
        String gg;
        String gg1;
        boolean mk = false;
        boolean nk=false;
        boolean pk=false;
        String query1 = "select 书号,学号 from bookyd";
        String query2 = "select 书号 from bookjc";
        String query3 = "select 书号 from book";
        String query4="";

        ResultSet ff = bb.stmt.executeQuery(query1);
        while (ff.next())
        {
          gg = ff.getString(1);
          gg1=ff.getString(2);
          //query4="select 学号 from bookyd where 书号="+"'"+gg+"'";

          //ResultSet vv=bb.stmt.executeQuery(query4);

          boolean xx=gg.equals(b);
          //int ef=Integer.parseInt(a.trim());
          boolean xx1=gg1.equals(a);
          if (mk == true)
          {

          }
          else if (xx1==false&&xx==true) {
            mk = true;

          }
          else {

          }

        }
        if (mk == true)
        {
          String st = new String("该书已被别人预定,不能外借");
          cheng dlg = new cheng(st);
          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
        {
          //System.out.println(query1);
          ResultSet kk = bb.stmt.executeQuery(query2);
          while (kk.next()) {
            String ll = kk.getString(1);
            if (nk == true) {

            }
            else if (ll.equals(b)) {
              nk = true;

            }
            else {

            }

            //ResultSet rs = bb.stmt.executeUpdate(query);
          }
          if (nk == true)
          {
          String st = new String("该书已被借出,不能外借");
          cheng dlg = new cheng(st);
          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
        {
          ResultSet oo = bb.stmt.executeQuery(query3);
          while (oo.next()) {
            String mm = oo.getString(1);
            if (pk == true) {

            }
            else if (mm.equals(b)) {
              pk = true;

            }
            else
            {

            }
          }
          if(pk==true)
          {
              boolean ttt=false;

               String jj3="select 借书日期,续借日期 from bookjc where 学号="+"'"+a+"'";
               //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 ann="select 书号 from bookjc where 学号="+"'"+a+"'";

               ResultSet dff=bb.stmt.executeQuery(ann);
               String ann1="";
               int ann3=0;
               while(dff.next())
               {
                 ann1=dff.getString(1);
                 ann3++;
               }
               if(ann3<=3)
               {

               String sppp=years+"-"+months+"-"+days;

               String aaa="select 学号, 书号 from bookyd ";

               ResultSet fhj=bb.stmt.executeQuery(aaa);

                String fhh="";
                String fhh1="";
               while(fhj.next())
               {
                  fhh = fhj.getString(1);
                  fhh1=fhj.getString(2);
               }
               boolean bbb=fhh.equals(a)&&fhh1.equals(b);
              // System.out.println("llllllll");

            if(bbb==true)
            {
               //update historya bookjc

               String bn="insert into bookjc values("+"'"+a+"'"+","+"'"+b+"'"+","
                   +"'"+sppp+"'"+","+"'"+null+"'"+")";
               String bnn="update historya set 借书日期="+"'"+sppp+"'"
                   +"where 学号="+"'"+a+"'"+"and 书号="+"'"+b+"'";
               String bnnn="delete from bookyd where 学号="+"'"+a+"'"+"and 书号="+"'"+b+"'";

               ResultSet fgg  = bb.stmt.executeQuery(bn+bnn+bnnn);
               //ResultSet fggg = bb.stmt.executeQuery(bnn);
               //String ii="insert into bookjc values("+"'"+a+"'"+","+"'"+b+"'"
               //+","+"'"+sppp+"'"+","+"'"+null+"'"+")";
              // ResultSet dd = bb.stmt.executeQuery(ii);


            }
            else
            {
               String bn1="insert into bookjc values('"+a+"','"+b+"','"+sppp+"',"+null+")";
               String bnn1="insert into historya values('"+a+"','"+b+"','"+sppp+"',"+null+","+null+","+null+")";
               String bnnn1="delete from bookyd where 学号="+"'"+a+"'"+"and 书号="+"'"+b+"'";
                dabaco bc = new dabaco();
               ResultSet fggg2= bc.stmt.executeQuery(bnn1+bn1+bnnn1);

            }
            /*
            String sf="     操作成功";
            cheng dlg = new cheng(sf);
            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 jo="该同学所借的书已超过4本,不能再借";
            cheng dlg = new cheng(jo);
            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
      {
            //System.out.println("ddddddddd");
            String stt="该同学所借书有超期的,不能借书";
            cheng dlg = new cheng(stt);
            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 st="              书库中没有该书";
            cheng dlg = new cheng(st);
            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(SQLException ex)
      {

      }
    }










  void cancel()
  {
    dispose() ;
  }



}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -