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

📄 merchantbusinessrecorddao.java

📁 基于struts的网上商店源码
💻 JAVA
字号:
package com.mole.struts.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Iterator;

import com.mole.struts.bean.MerchantBusinessRecordBean;
import com.mole.struts.bean.merchantBusinessRecordDetailBean;

/**
 * 
 * @author ruzhenchao Creation date: 12-05-2007
 * 
 */
public class MerchantBusinessRecordDAO extends AbstractDAO {

	// 商业记录查询
	public MerchantBusinessRecordBean[] BusinessReocrdQuery(String where,
			int pageSize, int currentPage) {
		String sql = "SELECT TOP "
				+ pageSize
				+ " [id],[CustomerId],[CustomerName],[dealtime],[totalprice],[NominalPrice] "
				+ " from v_MerchantBizRecord " + where + " AND [ID] NOT IN ("
				+ "SELECT TOP " + (currentPage - 1) * pageSize
				+ " [ID] FROM v_MerchantBizRecord  " + where
				+ " order by dealtime desc) order by dealtime desc";

		ArrayList<Object[]> arrayList = this.executeQuery(sql);
		if (arrayList == null)
			return null;

		MerchantBusinessRecordBean[] records = new MerchantBusinessRecordBean[arrayList
				.size()];
		Iterator<Object[]> it = arrayList.iterator();
		int i = 0;
		while (it.hasNext()) {
			Object[] obj = it.next();
			MerchantBusinessRecordBean record = new MerchantBusinessRecordBean();
			record.setId(String.valueOf(obj[0].toString()));
			record.setCustomerId(String.valueOf(obj[1].toString()));
			record.setCustomerName(String.valueOf(obj[2].toString()));
			record.setDealDate(String.valueOf(obj[3].toString()).substring(0,
					10));
			record.setTotalPrice(String.valueOf(obj[4].toString()));
			record.setUnitPrice(String.valueOf(obj[5].toString()));
			records[i++] = record;
		}
		return records;
	}

	// 获取页面信息
	public int getPageInfo(String where) {
		Connection conn = getConn();
		int count = 0;
		if (conn == null)
			conn = getConn();
		String sql = "select count(*) from v_MerchantBizRecord " + where;
		try {
			PreparedStatement ps = conn.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();
			if (rs.next())
				count = rs.getInt(1);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return count;
	}

	// 获取商业记录详细信息
	public merchantBusinessRecordDetailBean[] getRecordDetail(String swiftid)
			throws Exception {
		String sql = "select [swiftid],[goodsname],[goodsid],[amount],convert(int ,[factprice])factprice,convert(int ,[nominalprice])nominalprice,convert(decimal(10,2),[discount]) discount,goodsNumber from v_BusinessRecordDetail where [swiftid]="
				+ swiftid;

		ArrayList<Object[]> arrayList = this.executeQuery(sql);
		if (arrayList == null)
			return null;

		merchantBusinessRecordDetailBean[] records = new merchantBusinessRecordDetailBean[arrayList
				.size()];
		Iterator<Object[]> it = arrayList.iterator();
		int i = 0;
		while (it.hasNext()) {
			Object[] obj = it.next();
			merchantBusinessRecordDetailBean record = new merchantBusinessRecordDetailBean();
			record.setSwiftId(obj[0].toString());
			record.setGoodsName(obj[1].toString());
			record.setGoodsId(obj[2].toString());
			record.setAmount(obj[3].toString());
			record.setFactPrice(obj[4].toString());
			record.setNominalPrice(obj[5].toString());
			record.setDiscount(obj[6].toString());
			record.setGoodsNumber(obj[7].toString());
			records[i++] = record;
		}
		return records;
	}
}

⌨️ 快捷键说明

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