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

📄 staticsrenderbydate.java

📁 JAVA实现的酒店管理系统
💻 JAVA
字号:
package file1;
/*
 * 功能描述:酒店的客房出租收入按日期统计查询入口
 * @Author:黄顺武
 * Version:1.3
 */
import javax.swing.*;
import sun.jdbc.rowset.*;
import java.util.StringTokenizer;
import java.sql.*;

public class StaticsRenderByDate extends JPanel {

	private String tip = "请输入要查询的日期:";
	private DateMonthYear dateMonthYear = null;
	private String valueGet = null;
	private GetDate getD=new GetDate();
	private float result = 0;
	private String[] bookNum = null;
	private String[] hNoS = null;
	
	public StaticsRenderByDate() {
		dateMonthYear = new DateMonthYear();
		valueGet = dateMonthYear.getValueGet(tip);
		if (valueGet == null) {
			return;
		}
		String date = checkDate(valueGet);
		if (date == null) {
			return;
		}
		try {
			DBConnection con = new DBConnection();
			String query = "select bookNum,hNo from HUseBook where dateOut='"
					+ date + "'";
			CachedRowSet crs = con.getResultSet(query);
			int count = 0;
			while (crs.next()) {
				count++;
			}
			bookNum = new String[count];
			hNoS = new String[count];
			crs.beforeFirst();
			count = 0;
			while (crs.next()) {
				bookNum[count] = String.valueOf(crs.getInt(1));
				hNoS[count] = crs.getString(2);
				count++;
			}
			crs = null;
			int temp = count;
			count = 0;
			float price = 0;
			int num = 0;
			for (; count < temp; count++) {
				if (hNoS[count].indexOf(",") == -1) {
					query = "select Sprice from House,HGrade where HouseNo='"
							+ hNoS[count] + "' and hGrade=grade";
					crs = con.getResultSet(query);
					if (crs.next()) {
						price = crs.getFloat(1);
						num = Integer.valueOf(bookNum[count]);
						result += (num * price);
					}
				} else {
					StringTokenizer st = new StringTokenizer(hNoS[count], ",");
					int seed = 0;
					String sHNo = null;
					while (st.hasMoreTokens()) {
						sHNo = st.nextToken();
						if (seed == 0) {
							break;
						}
					}
					query = "select Sprice from House,HGrade where HouseNo='"
							+ sHNo + "' and hGrade=grade";
					crs = con.getResultSet(query);
					if (crs.next()) {
						price = crs.getFloat(1);
						num = Integer.valueOf(bookNum[count]);
						result += (num * 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();
		}

	}

	private String checkDate(String value) {
		String valueReturned = getD.getDate(value);
		if (valueReturned == null) {
			JOptionPane.showMessageDialog(null, "日期必须为如:2007-09-29的格式!", "",
					JOptionPane.INFORMATION_MESSAGE);
			return null;
		}
		return valueReturned;
	}
}

⌨️ 快捷键说明

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