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

📄 dialogkit.java~33~

📁 此程序是用Java实现的一个图书管理系统,再加以可以做毕业设计用而,而且实现的工能相对效全.
💻 JAVA~33~
字号:
package bookmanager;

import java.sql.Statement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.sql.*;
import java.util.Vector;

public class dialogkit {//控制类
    public dialogkit() {
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    public Vector dialogread(String u)
   {
       Statement s;
       ResultSet rs;
       Vector vvr=new Vector();
       dbconnection db=new dbconnection();
       try {
           s = db.getconnection().createStatement();
           rs = s.executeQuery("select * from readinfo where readid='"+u+"'");
           while (rs.next()) {
               Vector vt=new Vector();
               for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
               {
                   vt.add(rs.getString(i));
               }
               vvr.add(vt);
           }
       } catch (SQLException ex) {
       }
       return vvr;
   }

    public Vector dialogll()
    {
        Statement s;
        ResultSet rs;
        Vector vvr=new Vector();
        dbconnection db=new dbconnection();
        try {
            s = db.getconnection().createStatement();
            rs = s.executeQuery("select * from readinfo");
            while (rs.next()) {
                Vector vt=new Vector();
                for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
                {
                    vt.add(rs.getString(i));
                }
                vvr.add(vt);
            }
        } catch (SQLException ex) {
        }
        return vvr;
    }
    public ArrayList dialog()
    {
        Statement s;
        ResultSet rs;
        ArrayList list=new ArrayList();
        dbconnection db=new dbconnection();
        try {
            s = db.getconnection().createStatement();
            rs = s.executeQuery("select * from userinfo");
            while (rs.next()) {
                userinfo user=new userinfo();
                user.setusername(rs.getString(1));
                user.setpwd(rs.getString(2));
                list.add(user);
            }
        } catch (SQLException ex) {
        }
        return list;
    }
    public boolean ifusernamepwd(String user,String pwd)
    {
        Statement sf;
        ResultSet rt;
        dbconnection dt=new dbconnection();
        try {
            sf = dt.getconnection().createStatement();
            rt = sf.executeQuery("select * from userinfo where username='" +
                                 user + "' and pwd='" + pwd + "'");
            int i=0;
            while(rt.next())
            {
                i++;
            }
            if(i==0)
                return false;
        } catch (SQLException ex) {
        }
        return true;
    }
    public boolean ifusernamepwd(String pwd)
   {
       Statement sf;
       ResultSet rt;
       dbconnection dt=new dbconnection();
       try {
           sf = dt.getconnection().createStatement();
           rt = sf.executeQuery("select * from userinfo where pwd='" + pwd + "'");
           int i=0;
           while(rt.next())
           {
               i++;
           }
           if(i==0)
               return false;
       } catch (SQLException ex) {
       }
       return true;
   }
   public void update(String str1,String str3)
   {
       Statement sf;
       dbconnection dt=new dbconnection();
        try {
            sf = dt.getconnection().createStatement();
            sf.executeUpdate("update userinfo set pwd='" + str1 + "'" +
                                 " where username='" + str3 + "'");
        } catch (SQLException ex) {
        }
   }
   public Vector vectornum(String a)
   {
       Statement sy;
       ResultSet r;
       Vector vv=new Vector();
       dbconnection dtf=new dbconnection();
    try {
        sy = dtf.getconnection().createStatement();
        r = sy.executeQuery("select * from bookinfo where bookid='"+a+"'");
        while(r.next())
        {
            Vector v=new Vector();
            for(int i=1;i<=r.getMetaData().getColumnCount();i++)
            {
                v.add(r.getString(i));
            }
            vv.add(v);
        }
    } catch (SQLException ex) {
    }
    return vv;
   }
   public Vector vectornumj(String ef)
  {
      Statement sy;
      ResultSet r;
      Vector vv=new Vector();
      dbconnection dtf=new dbconnection();
   try {
       sy = dtf.getconnection().createStatement();
       r = sy.executeQuery("select * from bookinfo where bookname like '%"+ef+"%'");
       while(r.next())
       {
           Vector v=new Vector();
           for(int i=1;i<=r.getMetaData().getColumnCount();i++)
           {
               v.add(r.getString(i));
           }
           vv.add(v);
       }
   } catch (SQLException ex) {
   }
   return vv;
  }
  public Vector vectornumber(String b)
    {
        Statement sy;
        ResultSet r;
        Vector vv=new Vector();
        dbconnection dtf=new dbconnection();
     try {
         sy = dtf.getconnection().createStatement();
         r = sy.executeQuery("select * from bookinfo where bookautor like '%"+b+"%'");
         while(r.next())
         {
             Vector v=new Vector();
             for(int i=1;i<=r.getMetaData().getColumnCount();i++)
             {
                 v.add(r.getString(i));
             }
             vv.add(v);
         }
     } catch (SQLException ex) {
     }
     return vv;
   }
   public Vector vectornumb(String c)
  {
      Statement sy;
      ResultSet r;
      Vector vv=new Vector();
      dbconnection dtf=new dbconnection();
   try {
       sy = dtf.getconnection().createStatement();
       r = sy.executeQuery("select * from bookinfo where bookwhere like '%"+c+"%'");
       while(r.next())
       {
           Vector v=new Vector();
           for(int i=1;i<=r.getMetaData().getColumnCount();i++)
           {
               v.add(r.getString(i));
           }
           vv.add(v);
       }
   } catch (SQLException ex) {
   }
   return vv;
  }
  public int ifreadture(bookinfo b)
  {
      Statement s;
      int i=0;
      dbconnection a = new dbconnection();
      try {
          s = a.getconnection().createStatement();
          String tr = "insert into bookinfo(bookid,bookname,bookautor,bookbalance,bookwhere,booktime,booknotes,outtime,onoutctrl) values('"
                      + b.getbookid() + "','" + b.getbookname() + "','" + b.getbookautor() + "'," + b.getbookbalance() + ",'" +
                      b.getbookwhere() + "','" + b.getbooktime() + "'," + b.getbooknotes() + ",'" + b.getouttime() + "','" +
                      b.getonoutctrl() + "')";
          i=s.executeUpdate(tr);
      } catch (SQLException ex) {
      }
      return i;
  }
    private void jbInit() throws Exception {
    }
}

⌨️ 快捷键说明

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