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

📄 medlisty.java

📁 一个很好的医院管理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		springLayout.putConstraint(SpringLayout.WEST, label_7, 370, SpringLayout.WEST, this);

		//final JButton ConnDB = new JButton();
		ConnDB.addMouseListener(new MouseAdapter() {
			public void mouseClicked(final MouseEvent e) {
				connToDatabase();
			}
		});
		ConnDB.setText("连接数据库");
		add(ConnDB);
		springLayout.putConstraint(SpringLayout.EAST, ConnDB, 300, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.WEST, ConnDB, 0, SpringLayout.WEST, 房间号jTextField);
		springLayout.putConstraint(SpringLayout.SOUTH, ConnDB, 0, SpringLayout.SOUTH, 床位号jTextField);
		springLayout.putConstraint(SpringLayout.NORTH, ConnDB, 0, SpringLayout.NORTH, 床位号jTextField);

		//final JButton privesRow = new JButton();
		privesRow.addMouseListener(new MouseAdapter() {
			public void mouseClicked(final MouseEvent e) {
				//------------------------------------
				nextRow.setEnabled(true);
				try{
					if(rs.isBeforeFirst())
					{
						System.out.println("已经是第一行了");
						privesRow.setEnabled(false);
						JOptionPane.showMessageDialog(Doctor.frame, "已经是第一条了!",
								"注意", JOptionPane.YES_OPTION);
						
					}
					if(rs.isFirst())
					{
						privesRow.setEnabled(false);
						privesRow.invalidate();
						System.out.println("此出弹了消息没有上一条了");
						JOptionPane.showMessageDialog(Doctor.frame, "没有上一条了!",
								"注意", JOptionPane.YES_OPTION);
						return;
					}
					if(rs.previous())
					{
						//String docNo=rs.getString("docNo");
				    	//String docName=rs.getString("docName");			    	
				    	//System.out.println(docNo+docName);
						String medicalNo=rs.getString("medicalNo");
						String accountNO=rs.getString("accountNO");
						String need=rs.getString("need");
						String sickName=rs.getString("sickName");
						String docName=rs.getString("docName");
						String roomNo=rs.getString("roomNo");
						String bedNo=rs.getString("bedNo");
						
						药品号jTextField.setText(medicalNo);
						帐户余客jTextField.setText(need);
						帐户jTextField.setText(accountNO);
						病人姓名jTextField.setText(sickName);
						开药医生jTextField.setText(docName);
						房间号jTextField.setText(roomNo);
						床位号jTextField.setText(bedNo);
						System.out.println(medicalNo+accountNO+need+sickName+docName+roomNo+bedNo);
					}
				}catch(SQLException PreviousEX)
				{
					System.out.println("PreviousEx ERROR!!!");
					System.out.println(PreviousEX.getMessage());
				}
				//------------------------------------
			}
		});
		privesRow.setText("前一条");
		add(privesRow);
		springLayout.putConstraint(SpringLayout.EAST, privesRow, 375, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.WEST, privesRow, 0, SpringLayout.EAST, ConnDB);
		springLayout.putConstraint(SpringLayout.SOUTH, privesRow, 0, SpringLayout.SOUTH, ConnDB);
		springLayout.putConstraint(SpringLayout.NORTH, privesRow, 0, SpringLayout.NORTH, ConnDB);

		//final JButton nextRow = new JButton();
		nextRow.setText("下一条");
		nextRow.addMouseListener(new MouseAdapter() {
			public void mouseClicked(final MouseEvent e) {
				//--------------------------------
				privesRow.setEnabled(true);
				try{
					if(rs.isAfterLast())
					{
						System.out.println("已经是最后一行了");
						JOptionPane.showMessageDialog(Doctor.frame, "已经是最后一条了!",
								"注意", JOptionPane.YES_OPTION);
						nextRow.setEnabled(false);
					}
					if(rs.next())
					{
						String medicalNo=rs.getString("medicalNo");
						//String docNo=rs.getString("docNo");
				    	//String docName=rs.getString("docName");			    	
						String accountNO=rs.getString("accountNO");
						String need=rs.getString("need");
						String sickName=rs.getString("sickName");
						String docName=rs.getString("docName");
						String roomNo=rs.getString("roomNo");
						String bedNo=rs.getString("bedNo");
						
						药品号jTextField.setText(medicalNo);
						帐户余客jTextField.setText(need);
						帐户jTextField.setText(accountNO);
						病人姓名jTextField.setText(sickName);
						开药医生jTextField.setText(docName);
						房间号jTextField.setText(roomNo);
						床位号jTextField.setText(bedNo);
						System.out.println(medicalNo+accountNO+need+sickName+docName+roomNo+bedNo);
					}
					if(rs.isLast())
					{
						nextRow.setEnabled(false);
						nextRow.invalidate();
						System.out.println("没有下一条了");
					}
				}catch(SQLException nextEX)
				{
					
					System.out.println("nextEx ERROR!!!");
					System.out.println(nextEX.getMessage());
				}
				//--------------------------------
			}
		});
		add(nextRow);
		springLayout.putConstraint(SpringLayout.EAST, nextRow, 455, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.WEST, nextRow, 0, SpringLayout.EAST, privesRow);
		springLayout.putConstraint(SpringLayout.SOUTH, nextRow, 0, SpringLayout.SOUTH, privesRow);
		springLayout.putConstraint(SpringLayout.NORTH, nextRow, 0, SpringLayout.NORTH, privesRow);

		//final JButton Exit = new JButton();
		Exit.addMouseListener(new MouseAdapter() {
			public void mouseClicked(final MouseEvent e) {
				药品号jTextField.setText("");
				帐户余客jTextField.setText("");
				帐户jTextField.setText("");
				病人姓名jTextField.setText("");
				开药医生jTextField.setText("");
				房间号jTextField.setText("");
				床位号jTextField.setText("");		
				try{
					conn.close();
					JOptionPane.showMessageDialog(Doctor.frame, " 数据库已经关闭!",
							"注意", JOptionPane.ERROR_MESSAGE);
				}catch(SQLException col)
				{
					col.printStackTrace();
					JOptionPane.showMessageDialog(Doctor.frame, "您打开数据库了吗!",
							"注意", JOptionPane.YES_OPTION);
				}
			}
		});
		Exit.setText("关闭数据库");
		add(Exit);
		springLayout.putConstraint(SpringLayout.EAST, Exit, 555, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.WEST, Exit, 0, SpringLayout.EAST, nextRow);
		springLayout.putConstraint(SpringLayout.SOUTH, Exit, 0, SpringLayout.SOUTH, nextRow);
		springLayout.putConstraint(SpringLayout.NORTH, Exit, 0, SpringLayout.NORTH, nextRow);
		//
	}
	public void connToDatabase()
	{
		try{
		    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		    }catch(Exception e){
		    System.out.println("Not Found Driver!!!");
		    }
		    try{
		    conn=DriverManager.getConnection("jdbc:odbc:Hospital","","");
		    Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
		    rs=stmt.executeQuery("select foregift.medicalNo,foregift.accountNO,foregift.need,sick.sickName,doctor.docName,sick.roomNo,sick.bedNo from foregift,sick,doctor where foregift.medicalNo=sick.medicalNo and doctor.docNo=sick.docNo");
		    JOptionPane.showMessageDialog(Doctor.frame, " 数据库连接成功!",
					"注意", JOptionPane.ERROR_MESSAGE);
		    }catch(SQLException e){
		       System.out.println("Link Error");
		    }
	}
}

⌨️ 快捷键说明

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