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

📄 bsotherinfo.java

📁 一个网上购书系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	}
	
	/**
	 * 添加新闻
	 * @param paymentName
	 * @param sort
	 * @throws SQLException
	 * @throws IOException
	 */
	public void addNews(String title,
						String type,
						String content) throws SQLException,IOException
	{
		String sql = "";
		sql = "insert into news(title,type,content,issueDate) " +
			"VALUES('"+title+"','"+type+"','"+content+"','"+StringUtil.genDateTimeString()+"')";
		dbconn.execute(sql);
	}
	
	/**
	 * 列出所有新闻
	 * @return Vector
	 * @throws SQLException
	 * @throws IOException
	 */
	public Vector getAllNews()throws SQLException,IOException
	{
		Vector v = null;
		String sql = "";	
		sql = "select * from news order by issueDate desc ";
		v = dbconn.ListOfMapData(sql);
		return v;
	}
	
	/**
	 * 删除新闻
	 * @param id
	 * @throws SQLException
	 * @throws IOException
	 */
	public void delNews(String id)throws SQLException,IOException
	{
		String sql = "";	
		sql = "delete from news where id = '"+id+"' ";		
		dbconn.execute(sql);
	}
	
	/**
	 * 根据ID找到相应的新闻记录
	 * @param id
	 * @return Vector
	 * @throws SQLException
	 * @throws IOException
	 */
	public Map getAllNews(String id)throws SQLException,IOException
	{
		Vector v = null;
		Map map = null;
		String sql = "";	
		sql = "select * from news where id='"+id+"' ";
		v = dbconn.ListOfMapData(sql);
		if(v!=null)
			map = (Map)v.get(0);
		return map;
	}
	
	/**
	 * 修改新闻
	 * @param id
	 * @param title
	 * @param type
	 * @param content
	 * @throws SQLException
	 * @throws IOException
	 */
	public void modifyNews(String id,
							String title,
							String type,
							String content)throws SQLException,IOException
	{
		String sql = "";
		sql = "update news set title = '"+title+"',type='"+type+"'," +
			"content='"+content+"',issueDate='"+StringUtil.genDateTimeString()+"' where id='"+id+"' ";	
			
		dbconn.execute(sql);
	}
	
	/**
	 * 列出所有的市
	 * @param provinceId
	 * @return Vector
	 * @throws SQLException
	 * @throws IOException
	 */
	public Vector getAllCity(String provinceId)throws SQLException,IOException
	{
		Vector v = null;
		String sql = "";	
		sql = "select * from city ";
		if(!provinceId.equals("all"))
			sql = sql + " where provinceId='"+provinceId+"' ";
		sql = sql + "order by sort ";
		v = dbconn.ListOfMapData(sql);
		return v;
	}
	
	/**
	 * 取出市的最大序号
	 * @return String
	 * @throws SQLException
	 * @throws IOException
	 */
	public String getMaxSortCity() throws SQLException,IOException
	{
		Vector v = null;
		String sort = "";
		String sql = "";	
		sql = "select max(sort) as sort from city ";
		v = dbconn.ListOfMapData(sql);
		Map map = (Map)v.get(0);
		sort = (String)map.get("sort");
		if(sort == null)sort="0";
		return sort;
	}
	
	/**
	 * 添加市信息
	 * @param provinceId
	 * @param cityName
	 * @param cityNumber
	 * @param sort
	 * @throws SQLException
	 * @throws IOException
	 */
	public void addCity(String provinceId,
						String cityName,
						String cityNumber,
						String sort) throws SQLException,IOException
	{
		String sql = "";
		sql = "insert into city(provinceId,cityName,cityNumber,sort,createDate) " +
			"VALUES('"+provinceId+"','"+cityName+"','"+cityNumber+"','"+sort+"'," +
					"'"+StringUtil.genDateTimeString()+"')";
		dbconn.execute(sql);
	}
	
	/**
	 * 修改市信息
	 * @param id
	 * @param provinceId
	 * @param cityName
	 * @param cityNumber
	 * @param sort
	 * @throws SQLException
	 * @throws IOException
	 */
	public void modifyCity(String id,
							String provinceId,
							String cityName,
							String cityNumber,
							String sort)throws SQLException,IOException
	{
		String sql = "";
		sql = "update city set provinceId = '"+provinceId+"',cityName='"+cityName+"'," +
			"cityNumber='"+cityNumber+"',sort='"+sort+"'," +
					"createDate='"+StringUtil.genDateTimeString()+"' where id='"+id+"' ";	
		dbconn.execute(sql);
	}
	
	/**
	 * 删除市信息
	 * @param id
	 * @throws SQLException
	 * @throws IOException
	 */
	public void delCity(String id)throws SQLException,IOException
	{
		String sql = "";	
		sql = "delete from city where id = '"+id+"' ";		
		dbconn.execute(sql);
	}
	
	/**
	 * 根据类型列出相应的其它信息
	 * @param type
	 * @return Vector
	 * @throws SQLException
	 * @throws IOException
	 */
	public Vector getAllOtherInfo(String type)throws SQLException,IOException
	{
		Vector v = null;
		String sql = "";	
		sql = "select * from other_info where type='"+type+"' ";
		v = dbconn.ListOfMapData(sql);
		return v;
	}
	
	/**
	 * 修改其他信息
	 * @param type
	 * @param content
	 * @throws SQLException
	 * @throws IOException
	 */
	public void modifyOtherInfo(String type,String content)throws SQLException,IOException
	{
		String sql = "";
		sql = "update other_info set content = '"+content+"' where type='"+type+"' ";	
		dbconn.execute(sql);
	}
	
	/**
	 * 增加区
	 * @param cityId
	 * @param name
	 * @param districtNumber
	 * @param sort
	 * @throws SQLException
	 */
	public void addDistrict(String cityId,String name,String districtNumber,String sort) throws SQLException
	{
		String sql = "insert into district (cityId,districtName,districtNumber,sort,createDate) " +
				"values('"+cityId+"','"+name+"','"+districtNumber+"','"+sort+"','"+StringUtil.genDateTimeString()+"')";
		dbconn.execute(sql);
	}
	
	public Vector getAllDistrict() throws SQLException
	{
		Vector v = null;
		String sql = "";	
		sql = "select * from district ";
		sql = sql + "order by sort ";
		v = dbconn.ListOfMapData(sql);
		return v;
	}
	
	public void delDistrict(String id)throws SQLException,IOException
	{
		String sql = "";	
		sql = "delete from district where id = '"+id+"' ";		
		dbconn.execute(sql);
	}
	
	public Vector getDistrictById(String id) throws SQLException
	{
		Vector v = null;
		String sql = "";	
		sql = "select * from district where id="+id;
		sql = sql + " order by sort ";
		System.out.println(sql);
		v = dbconn.ListOfMapData(sql);
		return v;
	}
	
	public Vector getDistrictByCityId(String cityId) throws SQLException
	{
		Vector v = null;
		String sql = "";	
		sql = "select * from district where cityId="+cityId;
		sql = sql + " order by sort ";
		System.out.println(sql);
		v = dbconn.ListOfMapData(sql);
		return v;
	}
	
	public Vector getCityByProvinceId(String id) throws SQLException
	{
		Vector v = null;
		String sql = "";	
		sql = "select * from city where provinceId="+id;
		sql = sql + " order by sort ";
		System.out.println(sql);
		v = dbconn.ListOfMapData(sql);
		return v;
	}
	
	public void modifyDistrict(String id,
			String cityId,
			String districtName,
			String districtNumber,
			String sort)throws SQLException,IOException
	{
		String sql = "";
		sql = "update district set cityId = '"+cityId+"',districtName='"+districtName+"'," +
		"districtNumber='"+districtNumber+"',sort='"+sort+"'," +
			"createDate='"+StringUtil.genDateTimeString()+"' where id='"+id+"' ";	
		dbconn.execute(sql);
	}
	
	/**
	 * 生成定单
	 */
	public int deal(String userId,String receiveMan,String linkMan,
			String address,String phone,String province,String city,String district,
			String zip,String mobilePhone,String paymentType,
			String carrierType,double sumPrice) throws SQLException
	{
		String sql = "insert into order_manager(userId,paymentType,carrierType," +
				"orderDate,province,city,district,address,zip,phone,receiveMan,linkMan," +
				"mobilePhone,sumPrice) values" +
				"('"+userId+"','"+paymentType+"','"+carrierType+"'," +
				"'"+StringUtil.genDateTimeString()+"','"+province+"','"+city+"','"+
				district+"','"+address+"','"+zip+"','"+phone+"','"+receiveMan+"','"+
				linkMan+"','"+mobilePhone+"','"+sumPrice+"')";
		System.out.println(sql);
		Statement stat = dbconn.getStatement();
		stat.execute(sql);
		ResultSet result = stat.getGeneratedKeys();
		if(result.next())
		{
			System.out.println(result.getInt(1));
			return result.getInt(1);
			
		}
		return 0;
	}
	
	public Vector getAllOrder(String userId) throws SQLException
	{
		Vector v = null;
		String sql = "";	
		sql = "select * from order_manager where userId='"+userId+"' order by orderDate ";
		v = dbconn.ListOfMapData(sql);
		return v;
	}
	
	public Map getOrderById(String orderId) throws SQLException
	{
		Vector v = null;
		String sql = "";	
		sql = "select * from order_manager where orderId='"+orderId+"' order by orderDate ";
		v = dbconn.ListOfMapData(sql);
		if(v!=null&&v.size()>0)
			return (Map)v.get(0);
		return null;
	}
	
	public void dealDetail(String name,String isbn,
		String price,String sumPrice,String number,String orderId,String productType) throws SQLException
	{
		String sql = "insert into order_detail(commodityName,isbn,price,sumPrice,number,orderId,productType)"+
					" values ('"+name+"','"+isbn+"','"+price+"','"+sumPrice+"','"+number+"','"
					+orderId+"','"+productType+"')";
		dbconn.execute(sql);
	}
	
	public Vector getOrderDetailByOrderId(String orderId) throws SQLException
	{
		String sql = "select * from order_detail where orderId ='" + orderId + "' ";
		Vector v = dbconn.ListOfMapData(sql);
		return v;
	}
}

⌨️ 快捷键说明

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