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

📄 frmbrcxdb.java

📁 很全面的包括了住院管理的各项功能。如:管理员登录
💻 JAVA
字号:
package myprojects.FrmBRCXDb;

import java.sql.*;

public class FrmBRCXDb {	
	
	public ResultSet rs = null;
	public ResultSet rsFY = null;
	public ResultSet rsJF = null;
	public int count = 0;
	//public boolean flg = false;
	String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
	String dbConn = "jdbc:odbc:DbServer";    
	Connection con;	
	Statement stmt;
	
	
	public boolean getConnection(){
		
		 try {
		 
			 //加载驱动程序
		 	Class.forName(dbDriver);
		 
		 	//建立连接
		 	con = DriverManager.getConnection(dbConn);
		 
		 	//关闭自动提交
		 	con.setAutoCommit(false);
		 
		 	//设定事务级别
		 	con.setTransactionIsolation(con.TRANSACTION_SERIALIZABLE);
			 
			//创建一个JDBC声明
			stmt = con.createStatement(
										ResultSet.TYPE_SCROLL_INSENSITIVE,
                                        ResultSet.CONCUR_UPDATABLE);		 
			return true;		 		 		 
		 }
		 
		 catch (Exception e) {
		 	System.out.println(e.getMessage());
        	e.printStackTrace();	 		 	
		 	return false;	
		 }
	}
	
	public String getDate()
    {
    	String Date = null;
        try 
        {
            //sql字符串
            String strSQL = "";
            strSQL = "select substring(convert(varchar(16),getdate(),120),1,16) as sysdate";
            //执行sql结果保存在动态集里
            ResultSet rsDate = stmt.executeQuery(strSQL);
            while(rsDate.next())
            {
                Date = rsDate.getString("sysdate");
            }
        } 
        catch (Exception e) 
        {
          System.out.println(e.getMessage());
          e.printStackTrace();
        }
        return Date;
     }
	  
	
	//执行查询	
	public int getDataMD(String[] str) {    
    	
    	try {  
    		  		
    		//sql字符串
            String strSQL = "";            
            strSQL = "select ZYH,BLH,BRXM,BRXB,CSNY,SFZH,ZYKS,BCH,BRDH,BRDZ,LXRXM,LXRDH,LXRDZ,RYRQ,CYRQ from View_ZYBR";            
            strSQL = strSQL + " where ZYH like '%" + str[0] + "%'";
            strSQL = strSQL + " and BLH like '%" + str[1] + "%'";
            strSQL = strSQL + " and BRXM like '%" + str[2] + "%'";
            strSQL = strSQL + " and isnull(BRXB,'') like '%" + str[3] + "%'";
            strSQL = strSQL + " and isnull(CSNY,'') like '%" + str[4] + "%'";
            strSQL = strSQL + " and isnull(SFZH,'') like '%" + str[5] + "%'";
            strSQL = strSQL + " and ZYKS like '%" + str[6] + "%'";
            strSQL = strSQL + " and isnull(BCH,'') like '%" + str[7] + "%'";
            strSQL = strSQL + " and isnull(BRDH,'') like '%" + str[8] + "%'";
            strSQL = strSQL + " and isnull(BRDZ,'') like '%" + str[9] + "%'";
            strSQL = strSQL + " and isnull(LXRXM,'') like '%" + str[10] + "%'";
            strSQL = strSQL + " and isnull(LXRDH,'') like '%" + str[11] + "%'";
            strSQL = strSQL + " and isnull(LXRDZ,'') like '%" + str[12] + "%'";
            strSQL = strSQL + " and RYRQ like '%" + str[13] + "%'";
            strSQL = strSQL + " and isnull(CYRQ,'') like '%" + str[14] + "%'"; 	   	    		 		
    		System.out.println(strSQL);    		 	   	
    		rs = stmt.executeQuery(strSQL);
    		count = 0;
    		while(rs.next()){
            	count++;           	           	            	         	
        	}        	
        	rs.beforeFirst();   
	        if (count > 0) {
	        	//查询成功
	        	System.out.print("查询病人数:");
	        	System.out.println(count); 
            	return count;
        	} else {        		
            	//查询失败
            	return -1;
        	}
        	 
    	}
    	catch (SQLException e)     	
    	{
        	System.out.println(e.getMessage());
        	e.printStackTrace();
        	return 0;         	
    	}    	  	 	
   }
	
	public int getDataFY(String str) {
		
		try {
			
			String strSQL = "select CFRQ,KM,DJ*SL AS SUM,DJ,SL,ZYKS,JJDW,GG,KMLB,XMFL,ZFBL,ZYH,CD,CJ from View_WJZFY ";
			strSQL = strSQL + " where ZYH = '"+ str +"'";
			System.out.println(strSQL);    		 	   	
    		rsFY = stmt.executeQuery(strSQL);
    		count = 0;
           	while(rsFY.next()){           		
            	count++;        	            	            	         	
        	}        	
        	rsFY.beforeFirst();   
	        if (count > 0) {
	        	//查询成功
	        	System.out.print("查询病人费用项数:");
	        	System.out.println(count);
            	return count;
        	} else {        		
            	//查询失败
            	return -1;
        	}
    	}
    	catch (SQLException e)    	
    	{
        	System.out.println(e.getMessage());
        	e.printStackTrace();
        	return 0;         	
    	}
	
	}
	
	public int getDataJF(String str) {		
		
		try {			
			String strSQL = "select JFRQ,SFY,JE,ZYH,JFXS from JFJL ";
			strSQL = strSQL + " where ZYH = '"+ str +"'";
			System.out.println(strSQL);    		 	   	
    		rsJF = stmt.executeQuery(strSQL);
    		count = 0;    		
           	while(rsJF.next()){
            	count++;           	           	            	         	
        	}        	
        	rsJF.beforeFirst();   
	        if (count > 0) {
	        	//查询成功
	        	System.out.print("查询病人交费次数:");
	        	System.out.println(count); 
            	return count;
        	} else {        		
            	//查询失败
            	return -1;
        	}
    	}
    	catch (SQLException e)     	
    	{
        	System.out.println(e.getMessage());
        	e.printStackTrace();
        	return 0;         	
    	}
		
	}	

	/*
	*关闭数据库连接
	*/  
	public void closeDB(){
    	try	{
        	//在系统连接关闭之前,将所有未能及时提交的事务释放
        	con.commit();
        	//关闭连接
        	if (!con.isClosed())
    		con.close();
    	}
    	catch(SQLException se)
    	{
        	System.out.print(se.getMessage());
        	se.printStackTrace();
    	}
	}	 


}

⌨️ 快捷键说明

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