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

📄 indentlist.java

📁 J2EE网络书店系统 采用JSP , servlet ,javabean开发 初学者可以参考
💻 JAVA
字号:
/*
 * 创建日期 2005-3-8
 *
 * TODO 要更改此生成的文件的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
package store;

import javax.servlet.http.HttpServletRequest;
import java.sql.ResultSet;
import java.util.Vector;
import store.DBConnect;

/**
 * @author wwx
 *
 * TODO 要更改此生成的类型注释的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
public class IndentList {
	private long id;
	private String indentno = null;
	private String ISBN = null;
	private int amount = 0;
	
	public IndentList()
	{
	
	}
	
	public void SetId(long l)
	{
		id = l;
	}
	
	public void SetIndentNO(String s)
	{
		indentno = s;
	}
	
	public void SetBookNO(String s)
	{
		ISBN = s;
	}
	
	public void SetAmount(int i)
	{
		amount = i;
	}
	
	public long GetId()
	{
		return id;
	}
	
	public String GetIndentNO()
	{
		return indentno;
	}
	
	public String GetISBN()
	{
		return ISBN;
	}
	
	public String GetAmount()
	{
		return String.valueOf(amount);
	}
	
	public void AddIndentList() throws Exception
	{
		String s = "";
		boolean flag = false;
		if (amount==0 || ISBN==null || indentno==null)
		{
			s = s + "Please set your indentlist's values before commiting it!<br>";
			flag = true;
		}
		
		if (!flag)
		{
			DBConnect dbconnect = new DBConnect();
			dbconnect.prepareStatement("insert into My_indentlist (indentno,bookno,amount) values (?,?,?)");
			dbconnect.setString(1, indentno);
			dbconnect.setString(2, ISBN);
			dbconnect.setInt(3, amount);
			dbconnect.executeUpdate();
			dbconnect.close();
		}
		
		if (flag)
		{
			throw new Exception(s);
		}
	}
	
	public void DelIndentList(HttpServletRequest httpservletrequest) throws Exception
	{
		String s = "";
		boolean flag = false;
		String s1 = ParamUtils.getString(httpservletrequest, "field", "");
		String s2 = ParamUtils.getString(httpservletrequest, "keyword", "");
		if(s1.equals("") || s1==null)
		{
			s1 = (String)httpservletrequest.getAttribute("field");
			
		}
		if(s2.equals("") || s2==null)
		{
			s2 = (String)httpservletrequest.getAttribute("keyword");
		}
		
		if(s1.equals("") || s1==null)
		{
			s = s + "You have not input the field!<br>";
			flag = true;
		}
		if(s2.equals("") || s2==null)
		{
			s = s + "You have not input the keyword!<br>";
			flag = true;
		}
		
		if(!flag)
		{
			DBConnect dbconnect = new DBConnect();
			dbconnect.prepareStatement("delete from My_indentlist where "+ s1 +"=?");
			if (s1.equals("id"))
			{
				dbconnect.setLong(1, Long.parseLong(s2));
			}
			else
			{
				dbconnect.setString(1, s2);
			}
			dbconnect.executeUpdate();
			dbconnect.close();
		}
		
		if(flag)
		{
			throw new Exception(s);
		}
	}
	
	public Vector LoadIndentList(HttpServletRequest httpservletrequest) throws Exception
	{
		Vector vector = new Vector();
		String s = "";
		boolean flag = false;
		
		String s1 = ParamUtils.getString(httpservletrequest, "field","");
		String s2 = ParamUtils.getString(httpservletrequest, "keyword","");
		if(s1.equals("") || s1==null)
		{
			s1 = (String)httpservletrequest.getAttribute("field");
			
		}
		if(s2.equals("") || s2==null)
		{
			s2 = (String)httpservletrequest.getAttribute("keyword");
		}
		
		if(s1.equals("") || s1==null)
		{
			s = s + "You have not input the field!<br>";
			flag = true;
		}
		if(s2.equals("") || s2==null)
		{
			s = s + "You have not input the keyword!<br>";
			flag = true;
		}
		
		if(!flag)
		{
			DBConnect dbconnect = new DBConnect();
			dbconnect.prepareStatement("select * from My_indentlist where "+s1+"=?");
			if (s1.equals("id"))
			{
				dbconnect.setLong(1, Long.parseLong(s2));
			}
			else
			{
				dbconnect.setString(1, s2);
			}
			IndentList indentlist;
			for(ResultSet resultset=dbconnect.executeQuery(); resultset.next();vector.add(indentlist))
			{
				indentlist = new IndentList();
				indentlist.SetId(resultset.getLong("id"));
				indentlist.SetBookNO(resultset.getString("bookno"));
				indentlist.SetIndentNO(resultset.getString("indentno"));
				indentlist.SetAmount(resultset.getInt("amount"));
			}
			dbconnect.close();
		}
		
		if(flag)
		{
			throw new Exception(s);
		}
		else
		{
			return vector;
		}
	}

}

⌨️ 快捷键说明

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