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

📄 prize.java

📁 这是一个JSP网站程序
💻 JAVA
字号:
package com.yibo.yiqu.db;

import com.yibo.yiqu.domain.UserInfo;
import java.util.ArrayList;
import java.util.Iterator;
import java.sql.*;

/**
 * @author liuzhaofeng
 *
 * To change this generated comment edit the fenger variable "typecomment":
 * Window>Preferences>Java>fenger.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
 
public class prize
{
    Connection con;
    //得到获奖名单 by 时间
   public ArrayList getName(String force,String end)
    {
        ArrayList arraylist = new ArrayList();
        try
        {
            con = DataMYSQConnection.getConnection();
        }
        catch(Exception exception)
        {
            System.out.print("运行代号:prize 001");
        }
        String s1 = "select * from user_info where jihuo_time>='"+force+"' and jihuo_time<='"+end+"'";
        try
        {
            PreparedStatement pstmt = con.prepareStatement(s1);
            UserInfo bean;
            for(ResultSet resultset = pstmt.executeQuery(); resultset.next(); arraylist.add(bean))
            {
                bean = new UserInfo();
                bean.setUserID(resultset.getInt("UserID"));
                String  nickname = new   String(resultset.getString("UserNickname").getBytes("ISO8859-1"),"gbk"); 
                bean.setUserNickname(nickname);
                bean.setJhuoTime(resultset.getString("jihuo_time"));
                bean.setMoneyCount(resultset.getInt("MoneyCount"));
            }
        }
        catch(Exception exception1)
        {
            System.out.print("查询获奖名单信息失败"+"运行代号:prize 002");
        }
        finally
        {
            if(con != null)
                try
                {
                    con.close();
                }
                catch(Exception exception3) { }
        }
        return arraylist;
    }
    //得到获奖名单 by 通行证号
   public ArrayList getName1(String username)
    {
        ArrayList arraylist = new ArrayList();
        try
        {
            con = DataMYSQConnection.getConnection();
        }
        catch(Exception exception)
        {
            System.out.print("运行代号:prize 011");
        }
        String s1 = "select * from user_info where UserNickname='"+username+"'";
        try
        {
            PreparedStatement pstmt = con.prepareStatement(s1);
            UserInfo bean;
            for(ResultSet resultset = pstmt.executeQuery(); resultset.next(); arraylist.add(bean))
            {
                bean = new UserInfo();
                bean.setUserID(resultset.getInt("UserID"));
                String  nickname = new   String(resultset.getString("UserNickname").getBytes("ISO8859-1"),"gbk"); 
                bean.setUserNickname(nickname);
                bean.setJhuoTime(resultset.getString("jihuo_time"));
                bean.setMoneyCount(resultset.getInt("MoneyCount"));
            }
        }
        catch(Exception exception1)
        {
            System.out.print("查询获奖名单信息失败"+"运行代号:prize 022");
        }
        finally
        {
            if(con != null)
                try
                {
                    con.close();
                }
                catch(Exception exception3) { }
        }
        return arraylist;
    }
	//show用户名1
  public StringBuffer showPNames(String force,String end)
  {
        StringBuffer stringbuffer = new StringBuffer();
        prize pr = new prize();
        ArrayList arraylist = pr.getName(force,end);
        int userid;//用户ID
        String name;//用户通行证号
        String jihuo;//用户激活日期
        int money;
        for(Iterator iterator = arraylist.iterator(); iterator.hasNext(); stringbuffer.append("<tr><td>"+userid+"</td>"
        +"<td>"+name+"</td><td>"+money+"</td><td>"+jihuo+"</td><td><a href='Money_add.jsp?userid="+userid+"' target=_blank>充值</a></td>"))
        {
            UserInfo bean = (UserInfo)iterator.next();
            userid = bean.getUserID();
            name = bean.getUserNickname();
            jihuo = bean.getJhuoTime().substring(1,19);
            money = bean.getMoneyCount();
        }
        return stringbuffer;
    }
	//show 用户名2
  public StringBuffer showPNames1(String username)
  {
        StringBuffer stringbuffer = new StringBuffer();
        prize pr = new prize();
        ArrayList arraylist = pr.getName1(username);
        int userid;//用户ID
        String name;//用户通行证号
        String jihuo;//用户激活日期
        int money;
        for(Iterator iterator = arraylist.iterator(); iterator.hasNext(); stringbuffer.append("<tr><td>"+userid+"</td>"
        +"<td>"+name+"</td><td>"+money+"</td><td>"+jihuo+"</td><td><a href='Money_add.jsp?userid="+userid+"' target=_blank>充值</a></td>"))
        {
            UserInfo bean = (UserInfo)iterator.next();
            userid = bean.getUserID();
            name = bean.getUserNickname();
            jihuo = bean.getJhuoTime().substring(1,19);
            money = bean.getMoneyCount();
        }
        return stringbuffer;
    } 
//update the MoneyCount of the users in the table user_info
  public boolean updateMoney(int money,int userid)
    {
        boolean flag = false;
        Connection con = null;
        try
        {
            con = DataMYSQConnection.getConnection();
        }
        catch(Exception exception)
        {
            System.out.println("运行代号: prize 00");
        }
        String s = "update user_info set MoneyCount=MoneyCount+'"+money+"' where userid="+userid+"";
        try
        {
            PreparedStatement preparedstatement = con.prepareStatement(s);
            preparedstatement.execute();
            flag = true;
        }
        catch(Exception exception1)
        {
        	System.out.println("运行代号:prize 004");
        }
        finally
        {
            if(con != null)
                try
                {
                    con.close();
                }
                catch(Exception exception3) 
                {
                	System.out.println("运行代号: prize 005");
                }
        }
        return flag;
    } 
    
    

  // 得到用户中心商都老成员信息
  public UserInfo getUserContent(int userid){
  	UserInfo nbean=new UserInfo();
  	Connection con=null;
    try{
        con=DataMYSQConnection.getConnection();
       }catch(Exception e)
       {
       		System.out.println("运行代号: prize 006");
       }
          	
  	String sql="select * from user_info where UserID='"+userid+"'";
  	 	  
    try{
  	  PreparedStatement pstm=con.prepareStatement(sql);  	   
  	    ResultSet rs=pstm.executeQuery();  	    
  	    while(rs.next())
  	    {  	     
  	        nbean.setMoneyCount(rs.getInt("MoneyCount"));
  	    }
  	  }catch(Exception e)
      {
      		System.out.println("运行代号: prize 007");
      }finally
      {
      if(con!=null){
      	try{con.close();}catch(Exception e)
      	{
      		System.out.println("运行代号: prize 008");
      	}
      }
    }	
  return nbean;
  } 
// 得到大厅总人数
  public int getCount(){
  	int count=0;
  	Connection con=null;
    try{
        con=DataMYSQConnection.getConnection();
       }catch(Exception e)
       {
       		System.out.println("运行代号: prize 009");
       }
          	
  	String sql="select count(*) as countall from user_info";
  	 	  
    try{
  	  PreparedStatement pstm=con.prepareStatement(sql);  	   
  	    ResultSet rs=pstm.executeQuery(); 
  	  if(rs.next())
  	  {
  	  	count=rs.getInt("countall");
  	  }  	    
  	  }catch(Exception e)
      {
      		System.out.println("运行代号: prize 010");
      }finally
      {
      if(con!=null){
      	try{con.close();}catch(Exception e)
      	{
      		System.out.println("运行代号: prize 100");
      	}
      }
    }	
  return count;
  } 
// 得到时间段内总人数
  public int getCount(String force,String end){
  	int count=0;
  	Connection con=null;
    try{
        con=DataMYSQConnection.getConnection();
       }catch(Exception e)
       {
       		System.out.println("运行代号: prize 009");
       }
          	
  	String sql="select count(*) as countall from user_info where jihuo_time>='"+force+"' and jihuo_time<='"+end+"'";
  	 	  
    try{
  	  PreparedStatement pstm=con.prepareStatement(sql);  	   
  	    ResultSet rs=pstm.executeQuery(); 
  	  if(rs.next())
  	  {
  	  	count=rs.getInt("countall");
  	  }  	    
  	  }catch(Exception e)
      {
      		System.out.println("运行代号: prize 010");
      }finally
      {
      if(con!=null){
      	try{con.close();}catch(Exception e)
      	{
      		System.out.println("运行代号: prize 100");
      	}
      }
    }	
  return count;
  }                         
}
                   

⌨️ 快捷键说明

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