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

📄 goods.java

📁 实现图书管理
💻 JAVA
字号:
package mypkg;

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

public class goods extends Execute_DB
{
	//定义类成员变量
	private long GoodsID;    
	private int BuyNumber;
	private long UserID;   
	private long BookID;
	private String CreateTime;
	private String strSql;

	private int Pay;
	private int Send;
	//private String FormDate;
    
    //初始化类成员变量
	public goods()
	{
		this.GoodsID=0;        
		this.UserID=0;	
		this.BuyNumber=0;
		this.BookID=0;
		this.Pay=0;
		this.Send=0;
		java.util.Date NowTime = new java.util.Date();
		this.CreateTime = NowTime.toLocaleString();
		this.strSql=""; 
	}
   
	//向goods数据表中添加一条新记录
	public boolean add_goods()
	{
        
		this.strSql="insert into goods ";
		this.strSql=this.strSql + "(";   
		this.strSql=this.strSql + "BuyNumber,";
		this.strSql=this.strSql + "UserID,"; 
		this.strSql=this.strSql + "BookID,";
		this.strSql=this.strSql + "Pay,";
		this.strSql=this.strSql + "Send,";
		this.strSql=this.strSql + "CreateTime";               
		this.strSql=this.strSql + ") ";        
		this.strSql=this.strSql + "values(";
		this.strSql=this.strSql + "'" + this.BuyNumber + "',";
		this.strSql=this.strSql + "'" + this.UserID + "',";	
		this.strSql=this.strSql + "'" + this.BookID + "',";	
		this.strSql=this.strSql + "'" + this.Pay + "',";	
		this.strSql=this.strSql + "'" + this.Send + "',";	
		this.strSql=this.strSql + "'" + this.CreateTime + "'";
		this.strSql=this.strSql + ")";
		
		boolean isAdd = super.exeSql(this.strSql);		
		return isAdd;
	}  
	////付款确认
	public boolean updatepay()
	{     
		this.strSql="update goods set "; 
		this.strSql=this.strSql + " Pay= 1 ";
		this.strSql=this.strSql + " where UserID='" + this.UserID + "'";
		System.out.println(this.strSql);
		boolean isAdd = super.exeSql(this.strSql);		
		return isAdd;
	}
	////发货
	public boolean updatesend()
	{     
		this.strSql="update goods set "; 
		this.strSql=this.strSql + " Send= 1 ";
		this.strSql=this.strSql + " where UserID='" + this.UserID + "'";
		this.strSql=this.strSql + " and BookID='" + this.BookID + "'";
		System.out.println(this.strSql);
		boolean isAdd = super.exeSql(this.strSql);		
		return isAdd;
	}
	/////取消发货
	public boolean updatesendno()
	{     
		this.strSql="update goods set "; 
		this.strSql=this.strSql + " Send= 0 ";
		this.strSql=this.strSql + " where UserID='" + this.UserID + "'";
		this.strSql=this.strSql + " and BookID='" + this.BookID + "'";
		System.out.println(this.strSql);
		boolean isAdd = super.exeSql(this.strSql);		
		return isAdd;
	}
   
	//删除成员变量GoodsID中对应的图书信息
	public boolean delete_goods()
	{
		this.strSql="delete from goods where GoodsID =";
		this.strSql=this.strSql + this.GoodsID;
		
		boolean isDelete = super.exeSql(this.strSql);		
		return isDelete;
	}	
	
	
 	//删除类DeleteGoodsID中对应的图书信息
	public boolean delete_goods(String DeleteGoodsID)
	{
		this.strSql="delete from goods where GoodsID in (";
		this.strSql=this.strSql + DeleteGoodsID + ")";
		
		boolean isDelete = super.exeSql(this.strSql);		
		return isDelete;
	}
	
	///
	//购物历史
	public ResultSet showsall()
	{	
		this.strSql="select * from goods where Pay=1 and Send=1";	
		ResultSet rs = null;              
		try
		{
			rs = super.exeSqlQuery(this.strSql); 
		}
		catch(Exception ex)
		{
			System.out.println(ex.toString());            
		}
		return rs;        
	} 
	public ResultSet showsend()
	{	
		this.strSql="select * from goods where Pay=1 and Send=0";
		ResultSet rs = null;              
		try
		{
			rs = super.exeSqlQuery(this.strSql); 
		}
		catch(Exception ex)
		{
			System.out.println(ex.toString());            
		}
		return rs;        
	} 
	//获取所有购物信息,返回一个ResultSet类型对象 对用户进行的操作
	public ResultSet show_goods()
	{	
		this.strSql="select * from goods where Pay=0 and UserID = ";
		this.strSql=this.strSql + this.UserID;
		ResultSet rs = null;              
		try
		{
			rs = super.exeSqlQuery(this.strSql); 
		}
		catch(Exception ex)
		{
			System.out.println(ex.toString());            
		}
		return rs;        
	} 
	public ResultSet show_goodhis()
	{	
		this.strSql="select * from goods where Pay=1 and Send=1 and UserID = ";
		this.strSql=this.strSql + this.UserID;
		ResultSet rs = null;              
		try
		{
			rs = super.exeSqlQuery(this.strSql); 
		}
		catch(Exception ex)
		{
			System.out.println(ex.toString());            
		}
		return rs;        
	} 
	
	public ResultSet show_good()
	{	
		this.strSql="select * from goods where Pay=0 ";
		ResultSet rs = null;              
		try
		{
			rs = super.exeSqlQuery(this.strSql); 
		}
		catch(Exception ex)
		{
			System.out.println(ex.toString());            
		}
		return rs;        
	}
   ///
	///

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

	//获取类成员变量GoodsID的值  
	public long getGoodsID()
	{
		return this.GoodsID;	
	} 
	
	 //设置类成员变量Send的值 
 	public void setSend(int Send)
	{
		this.Send = Send;	
	}   

	//获取类成员变量Send的值  
	public int getSend()
	{
		return this.Send;	
	} 
	//设置类成员变量Pay的值 
	public void setPay(int Pay)
	{
		this.Pay = Pay;	
	}   

	//获取类成员变量Pay的值  
	public int getPay()
	{
		return this.Pay;	
	} 
	//设置类成员变量ShouHuo的值 
	
	
	 //设置类成员变量UserID的值 
 	public void setUserID(long UserID)
	{
		this.UserID = UserID;	
	}   

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

	//获取类成员变量BookID的值  
	public long getBookID()
	{
		return this.BookID;	
	} 	
	
	 //设置类成员变量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 + -