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

📄 ware.java

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

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

public class Ware extends ExecuteDB
{
	//定义类成员变量
	private long WareID;    
	private String WareName;       
	private String Company;   
	private String Addr;
	private float Price;
	private String PicUrl;
	private long SortID;   
	private String Intro;
	private String CreateTime;
	private String strSql;
	
    
    //初始化类成员变量
	public Ware()
	{
		this.WareID=0;        
		this.WareName="";		
		this.Company="";		
		this.SortID=0;	
		this.Price=0;
		this.Addr="";
		this.PicUrl = "00000000000000.gif";
		this.Intro = "";
		java.util.Date NowTime = new java.util.Date();
		this.CreateTime = NowTime.toLocaleString();
		this.strSql=""; 
	}
   
	//向wares数据表中添加一条新记录
	public boolean add()
	{
        
		this.strSql="insert into wares ";
		this.strSql=this.strSql + "(WareName,Company,Addr,Price,SortID,PicUrl,Intro,CreateTime) ";       
		this.strSql=this.strSql + "values('" + this.WareName + "','" + this.Company + "','" + this.Addr + "','" + this.Price + "','" + this.SortID + "','" + this.PicUrl + "','" + this.Intro + "','" + this.CreateTime + "')";
		
		boolean isAdd = super.exeSql(this.strSql);		
		return isAdd;
	}   
   
  	//修改类成员变量WareID对应的商品信息
	public boolean modify()
	{
		this.strSql="update wares set ";	
		this.strSql=this.strSql + "WareName=" + "'" + this.WareName + "',";
		this.strSql=this.strSql + "Company=" + "'" + this.Company + "',";		
		this.strSql=this.strSql + "Addr=" + "'" + this.Addr + "',";	
		this.strSql=this.strSql + "Price=" + "'" + this.Price + "',";	
		this.strSql=this.strSql + "SortID=" + "'" + this.SortID + "',";	
		this.strSql=this.strSql + "PicUrl=" + "'" + this.PicUrl + "',";
		this.strSql=this.strSql + "Intro=" + "'" + this.Intro + "',";
		this.strSql=this.strSql + "CreateTime=" + "'" + this.CreateTime + "'";
		this.strSql=this.strSql + " where WareID=" + this.WareID;		
		
		boolean isUpdate = super.exeSql(this.strSql);		
		return isUpdate;
	}	
   
 	//删除类sWareID中对应的商品信息
	public boolean delete(String sWareID)
	{
		this.strSql="delete from wares where WareID in (";
		this.strSql=this.strSql + sWareID + ")";
		
		boolean isDelete = super.exeSql(this.strSql);		
		return isDelete;
	}
	
   
	//获取类成员变量WareID对应的商品信息
	public boolean init()
	{
		this.strSql="select * from wares where WareID=";
		this.strSql=this.strSql + this.WareID;        

		try
		{
			ResultSet rs = super.exeQuery(this.strSql);
			if (rs.next())
			{
				this.WareID=rs.getLong("WareID");                
				this.WareName=rs.getString("WareName"); 
				this.Addr=rs.getString("Addr");
				this.Company=rs.getString("Company");
				this.PicUrl=rs.getString("PicUrl");   
				this.Price=rs.getFloat("Price");
				this.SortID=rs.getInt("SortID");   
				this.Intro=rs.getString("Intro");
				this.CreateTime=rs.getString("CreateTime");
				return true;
			}
			else
				return false;			
		}
		catch(Exception e)
		{		 
			return false;
		}
	}
	
	//获取所有普通商品信息,返回一个ResultSet类型对象
	public ResultSet show_wares()
	{
		this.strSql="select * from wares order by CreateTime desc";
		ResultSet rs = null;              
		try
		{
			rs = super.exeQuery(this.strSql); 
		}
		catch(Exception ex)
		{
			System.out.println(ex.toString());            
		}
		return rs;        
	} 
   
   	//以WareName、Company、Addr、SortID为条件搜索wares数据表,获得符合条件的记录,返回一个ResultSet类型对象
	public ResultSet search_wares()
	{
		this.strSql="select * from wares where";
		this.strSql=this.strSql + " WareName like '%" + this.WareName +"%'";    
		this.strSql=this.strSql + " and Company like '%" + this.Company +"%'"; 
		this.strSql=this.strSql + " and Addr like '%" + this.Addr +"%'";
		if(SortID != 0)
			this.strSql=this.strSql + " and SortID =" + this.SortID;		
		
		ResultSet rs = null;              
		try
		{
			rs = super.exeQuery(this.strSql); 
		}
		catch(Exception ex)
		{
			System.out.println(ex.toString());            
		}
		return rs;        
	} 
   
	//设置类成员变量WareID的值 
	public void setWareID(long WareID)
	{
		this.WareID = WareID;	
	}   

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

	//获取类成员变量WareName的值  
	public String getWareName()
	{
		return this.WareName;	
	} 
	
	 //设置类成员变量Company的值 
 	public void setCompany(String Company)
	{
		this.Company = Company;	
	}   

	//获取类成员变量Company的值  
	public String getCompany()
	{
		return this.Company;	
	} 
	
	 //设置类成员变量Addr的值 
 	public void setAddr(String Addr)
	{
		this.Addr = Addr;	
	}   

	//获取类成员变量Addr的值  
	public String getAddr()
	{
		return this.Addr;	
	} 
	
	//设置类成员变量Price的值 
 	public void setPrice(float Price)
	{
		this.Price = Price;	
	}   

	//获取类成员变量Price的值  
	public float getPrice()
	{
		return this.Price;	
	} 
	
	 //设置类成员变量SortID的值 
 	public void setSortID(long SortID)
	{
		this.SortID = SortID;	
	}   

	//获取类成员变量SortID的值  
	public long getSortID()
	{
		return this.SortID;	
	}
	 	
	//设置类成员变量PicUrl的值 
 	public void setPicUrl(String PicUrl)
	{
		this.PicUrl = PicUrl;	
	}   

	//获取类成员变量PicUrl的值  
	public String getPicUrl()
	{
		return this.PicUrl;	
	} 
	
	//设置类成员变量Intro的值 
 	public void setIntro(String Intro)
	{
		this.Intro = Intro;	
	}   

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