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

📄 staticsrenderbymonth.java

📁 JAVA实现的酒店管理系统
💻 JAVA
字号:
package file1;
/*
 * 功能描述:酒店的出租收入按月份统计查询入口
 * Author:黄顺武
 * Time:---
 * Last Modified:2007-12-15
 * Modify Reason:数据库连接类DBConnection 的内部结构设计得到优化
 */
import javax.swing.*;
import sun.jdbc.rowset.*;
import java.sql.*;

public class StaticsRenderByMonth extends JPanel {

	private String tip = "请输入要查询的年月:";
	private DateMonthYear dateMonthYear = null;
	private String valueGet = null;
	private float result = 0;
	private CheckYearMonth checkYM = null;
	private String[][] numAndPrice = null;
	private IdentityDate identityDate=new IdentityDate();//实例化对两个日期进行相关性判断的类对象

	public StaticsRenderByMonth() {
		dateMonthYear = new DateMonthYear();
		valueGet = dateMonthYear.getValueGet(tip);
		if (valueGet == null) {
			return;
		}
		checkYM = new CheckYearMonth();
		String monthStr = checkYM.check(valueGet);
		if (monthStr == null) {
			return;
		}
		try {
			DBConnection con = new DBConnection();
			String query = "select bookNum,dateOut,Sprice from HUseBook,HGrade where hGrade=grade";
			CachedRowSet crs = con.getResultSet(query);
			int count = 0;
			while (crs.next()) {
				String dateOut = crs.getString(2);
				crs.getFloat(3);
				identityDate.setFirstDate(dateOut.trim());
				identityDate.setSecondDate(monthStr);
				if (identityDate.isInTheSameMonth()==0) {//两个日期在同一年份
					count++;
				}
			}
			numAndPrice = new String[count][2];
			crs.beforeFirst();
			count = 0;
			while (crs.next()) {
				int numTemp = crs.getInt(1);
				String dateOut = crs.getString(2);
				float price = crs.getFloat(3);
				identityDate.setFirstDate(dateOut.trim());
				identityDate.setSecondDate(monthStr);
				if (identityDate.isInTheSameMonth()==0) {//两个日期在同一年份
					numAndPrice[count][0] = String.valueOf(numTemp);
					numAndPrice[count][1] = String.valueOf(price);
					count++;
				}
			}
			int temp = count;
			count = 0;
			for (; count < temp; count++) {
				int bNum = Integer.valueOf(numAndPrice[count][0]);
				float price = Float.valueOf(numAndPrice[count][1]);
				result += (bNum * price);
			}
			JOptionPane.showMessageDialog(null, "该月客房出租收入为 " + result + " 元!",
					"", JOptionPane.INFORMATION_MESSAGE);
		} catch (ClassNotFoundException cnfe) {
			cnfe.printStackTrace();
			return;
		} catch (SQLException sqle) {
			sqle.printStackTrace();
			return;
		} catch (NumberFormatException nfe) {
			nfe.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

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