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

📄 goods.java

📁 一个网购物系统有JAVA 写成...稍加修改就可以成为毕业设计用..希望对你们有用
💻 JAVA
字号:
package com.wssd;

import java.util.*;
import java.sql.*;
import java.text.*;

public class Goods extends ExecuteDB
{
	//定义类成员变量
	private long GoodsID;    
	private int BuyNumber;
	private long UserID;   
	private long WareID;
	private String CreateTime;
	private String strSql;
	
	//初始化类成员变量
	public Goods()
	{
		this.GoodsID=0;        
		this.UserID=0;	
		this.BuyNumber=0;
		this.WareID=0;
		java.util.Date NowTime = new java.util.Date();
		this.CreateTime = NowTime.toLocaleString();
		this.strSql=""; 
	}
   
	//向goods数据表中添加一条新记录
	public boolean add()
	{
		this.strSql="insert into goods ";
		this.strSql=this.strSql + "(BuyNumber,UserID,WareID,CreateTime) ";        
		this.strSql=this.strSql + "values('" + this.BuyNumber + "','" + this.UserID + "','" + this.WareID + "','" + this.CreateTime + "')";
		
		boolean isAdd = super.exeSql(this.strSql);		
		return isAdd;
	}  
   
	//删除成员变量GoodsID中对应的商品信息
	public boolean delete()
	{
		this.strSql="delete from goods where GoodsID =";
		this.strSql=this.strSql + this.GoodsID;
		
		boolean isDelete = super.exeSql(this.strSql);		
		return isDelete;
	}	
	
   	//删除类sGoodsID中对应的商品信息
	public boolean delete(String sGoodsID)
	{
		this.strSql="delete from goods where GoodsID in (";
		this.strSql=this.strSql + sGoodsID + ")";
		
		boolean isDelete = super.exeSql(this.strSql);		
		return isDelete;
	}
	
	//验证GoodsID和UserID是否匹配  
	public boolean valid()
	{
		this.strSql="select * from goods ";
		this.strSql=this.strSql + " where UserID="+ this.UserID;
		this.strSql=this.strSql + " and GoodsID="+ this.GoodsID;         
		System.out.println(this.strSql);
		try
		{
			ResultSet rs = super.exeQuery(this.strSql); 
			if (rs.next())
			{				
				return true;
			}
			else
			{                
				return false;
			}
		}
		catch(Exception e)
		{            
			return false;
		}       
	}

	//获取所有订单信息,返回一个ResultSet类型对象
	public ResultSet show_all_goods()
	{
		this.strSql="select * from goods";		
		ResultSet rs = null;              
		try
		{
			rs = super.exeQuery(this.strSql); 
		}
		catch(Exception e)
		{
			System.out.println(e.toString());            
		}
		return rs;        
	} 
	
	//获取成员变量UserID对应的订单信息,返回一个ResultSet类型对象
	public ResultSet show_my_goods()
	{
		this.strSql="select * from goods where UserID = "+this.UserID;		
		ResultSet rs = null;              
		try
		{
			rs = super.exeQuery(this.strSql); 
		}
		catch(Exception e)
		{
			System.out.println(e.toString());            
		}
		return rs;        
	} 
	
   
	//设置类成员变量GoodsID的值 
	public void setGoodsID(long GoodsID)
	{
		this.GoodsID = GoodsID;	
	}   

	//获取类成员变量GoodsID的值  
	public long getGoodsID()
	{
		return this.GoodsID;	
	} 

	 //设置类成员变量GoodsID的值 
 	public void setUserID(long UserID)
	{
		this.UserID = UserID;	
	}   

	//获取类成员变量UserID的值  
	public long getUserID()
	{
		return this.UserID;	
	} 
	
	//设置类成员变量WareID的值 
 	public void setWareID(long WareID)
	{
		this.WareID = WareID;	
	}   

	//获取类成员变量WareID的值  
	public long getWareID()
	{
		return this.WareID;	
	} 	
	
	 //设置类成员变量BuyNumber的值 
 	public void setBuyNumber(int BuyNumber)
	{
		this.BuyNumber = BuyNumber;	
	}   

	//获取类成员变量BuyNumber的值  
	public int getBuyNumber()
	{
		return this.BuyNumber;	
	} 	
	
	 //设置类成员变量CreateTime的值 
 	public void setCreateTime(String CreateTime)
	{
		this.CreateTime = CreateTime;	
	}   

	//获取类成员变量CreateTime的值  
	public String getCreateTime()
	{
		return this.CreateTime;	
	} 
}

⌨️ 快捷键说明

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