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

📄 oporders.java

📁 很好的东东 本人随便做的 仅供学习之用
💻 JAVA
字号:
package chuyun.operatedata;

import java.sql.*;
import java.util.ArrayList;
import chuyun.javabeans.*;
import chuyun.form.warehouse;

public class OpOrders {
	 private warehouse  wh=null;
	 private Ordersentiy orde=null;
	private ResultSet result = null;
	
	private ResultSet rcount = null;
	
	
    private ResultSet result2 = null;
	
	private ResultSet rcount2 = null;
	
	
	 private ResultSet result3 = null;
		
		private ResultSet result4  = null;

	ArrayList list = null;

	private int begin = 0;//first

	private   int end = 0; //last

	private int pagelast = 0;

	private  int pagecounts = 0;
	public  static  int max = 0;

	public static int pagenum = 1;
    public 	OperateDataBase opdb = new OperateDataBase();


	private  ArrayList<Ordersentiy> temp = new ArrayList<Ordersentiy>();
	private  ArrayList<Ordersentiy> temp1 = new ArrayList<Ordersentiy>();
	private  ArrayList<Ordersentiy> temp2 = new ArrayList<Ordersentiy>();
	private  ArrayList<warehouse> temp3 = new ArrayList<warehouse>();

	public OpOrders() {

	}

	public ArrayList<Ordersentiy> selectordersBean( int page,int count) {

		try {

			
			rcount = opdb.getMyResultSet("SELECT count(id) as ids from [order] where status='通过'");
			if (rcount.next())
				pagecounts = rcount.getInt("ids");
			   max=pagecounts;

			if (pagecounts % count == 0) {
				pagenum = pagecounts / count;
			} else {
				pagenum = pagecounts / count + 1;
				pagelast = pagecounts / count;
			}
			//int begin = page * count - count;
			//int end = page * count;
			if (page == pagenum) {
				end = pagecounts;
			}

			result = opdb.getMyResultSet("SELECT * from [order] where status='通过' ");
			try {				  
				result.absolute((page -1)* count );
				for (int i = 1; i <= count; i++) {
					if (result.next()) {
						Ordersentiy orde = new Ordersentiy();
						orde.setID(result.getInt(1));
						orde.setCustomerID(result.getInt(2));
						orde.setCustomername(result.getString(3));
						orde.setSellID(result.getInt(4));
						orde.setSell(result.getString(5));
						orde.setOrdertime(result.getDate(6));
						orde.setPrincipalID(result.getInt(7));
						orde.setPrincipal(result.getString(8));
						orde.setStatus(result.getString(9));
						orde.setType(result.getString(10));
						orde.setVerifytime(result.getDate(11));
						temp.add(orde);
						
					}//for10

				}//if

			}//try

			catch (SQLException ex) {
				ex.printStackTrace();
			}
			opdb.Dispose();
			

		} catch (Exception ex) {
			temp = null;
			ex.printStackTrace();
		}
		return temp;
	}

	
	public ArrayList<Ordersentiy> selectordersBYname(String values ,int page,int count) {

		try {

			
			rcount2 = opdb.getMyResultSet("SELECT count(*) as ids from [order] where status='通过' and customername like '%"+values+"%'");
			if (rcount2.next())
				pagecounts = rcount2.getInt("ids");

			if (pagecounts % count == 0) {
				pagenum = pagecounts / count;
			} else {
				pagenum = pagecounts / count + 1;
				pagelast = pagecounts / count;
			}
			int begin = page * count - count;
			int end = page * count;
			if (page == pagenum) {
				end = pagecounts;
			}
             String sqls="SELECT  * from [order] where status='通过' and customername like '%"+values+"%'";
			System.out.println(sqls);
             result2 = opdb.getMyResultSet(sqls);
			try {

				//for (int i = 0; i <= (page - 1) * count; i++)
					//result2.next();
				result2.absolute((page -1)* count );
				for (int i = 1; i <= count; i++) {
				
					if(result2.next()) {
						Ordersentiy orde = new Ordersentiy();
						orde.setID(result2.getInt(1));
						orde.setCustomerID(result2.getInt(2));
						orde.setCustomername(result2.getString(3));
						orde.setSellID(result2.getInt(4));
						orde.setSell(result2.getString(5));
						orde.setOrdertime(result2.getDate(6));
						orde.setPrincipalID(result2.getInt(7));
						orde.setPrincipal(result2.getString(8));
						orde.setStatus(result2.getString(9));
						orde.setType(result2.getString(10));
						orde.setVerifytime(result2.getDate(11));

						temp1.add(orde);
					}//if

				}//for10
			}//try

			catch (SQLException ex) {
				ex.printStackTrace();
			}
		//	opdb.Dispose();
			

		} catch (Exception ex) {
			temp1 = null;
			ex.printStackTrace();
		}
		return temp1;
	}
	
	public Ordersentiy selectordersBYID(int values) {

		try {


			result3 = opdb.getMyResultSet("SELECT * from [order] where id="+values);
			

				
			
				
				
					if(result3.next()) {
						 orde = new Ordersentiy();
						orde.setID(result3.getInt(1));
						orde.setCustomerID(result3.getInt(2));
						orde.setCustomername(result3.getString(3));
						orde.setSellID(result3.getInt(4));
						orde.setSell(result3.getString(5));
						orde.setOrdertime(result3.getDate(6));
						orde.setPrincipalID(result3.getInt(7));
						orde.setPrincipal(result3.getString(8));
						orde.setStatus(result3.getString(9));
						orde.setType(result3.getString(10));
						orde.setVerifytime(result3.getDate(11));

						//temp2.add(orde);
					}//if
				}//try

			catch (SQLException ex) {
				ex.printStackTrace();
			}
						
		 catch (Exception ex) {
			//temp2 = null;
			ex.printStackTrace();
		}
		return  orde;
	}
	public warehouse  selectwarehouseBYID(int values) {

		try {


			result4 = opdb.getMyResultSet("SELECT * from warehouse where id="+values);
			

				
			
				
				
					if(result4.next()) {
					 wh=new warehouse();
						wh.setWarehouse(result4.getString("warehouse"));
						
						///temp3.add(wh);
					}//if
				}//try

			catch (SQLException ex) {
				ex.printStackTrace();
			}
						
		 catch (Exception ex) {
			//temp3 = null;
			ex.printStackTrace();
		}
		return wh;
	}
	 

}

⌨️ 快捷键说明

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