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

📄 utilmyphotos.java

📁 spring+struts+hibernate做的银行系统
💻 JAVA
字号:
/*
 * Created on 2006-4-14
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package cn.com.tym.util.tablebean;

import java.sql.SQLException;

import cn.com.tym.pub.DB;

import java.sql.ResultSet;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;


import cn.com.tym.pub.PageBean;

import cn.com.tym.util.text.DealText;

import cn.com.tym.vip.Filename;
import cn.com.tym.vip.MyphotoBean;
import cn.com.tym.vip.PhotoBean;
/**
 * @author jack_booth
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class UtilMyphotos {

	
	//��������ͼ

	 public static String lookVisualize(String id,DB db)throws SQLException{

	 	String img="";
	    String strSql = "select * from mdh_myphotos  where  filename_id " +
	    		"in ( select photofile_id from mdh_myphotofile  where vip_id='"+id+"')  and visualize=1";
	      try{
	      	ResultSet rs=db.OpenSql(strSql);
	        if(rs.next())
	            img=rs.getString("photopath");
	        else
	        	img="images/img_xiangce.jpg";
	      }catch(SQLException e){
	      	  db.close();
	      	  throw e;
	      }
	   	return img;
	   }
	 //��ɫ�ռ�  û�оͷ���һ��յ�ͼƬ
	 public static String lookPhotoVisualize(String id,DB db)throws SQLException{

	 	String img="";
	    String strSql = "select * from mdh_myphotos  where  filename_id " +
	    		"in ( select photofile_id from mdh_myphotofile  where vip_id='"+id+"')  and visualize=1";
	      try{
	      	ResultSet rs=db.OpenSql(strSql);
	        if(rs.next())
	            img=rs.getString("photopath");
	        else
	        	img="images/img_gg.jpg";
	      }catch(SQLException e){
	      	  db.close();
	      	  throw e;
	      }
	   	return img;
	   }	 
	 
	 
		//取得默认值
		public ArrayList  getViphoto(HttpServletRequest request,String id,DB db)throws SQLException{
			
	 
		 String strSql= "select photo_id,photoname,photopath from mdh_myphotos where  Filename_id in " +
		 		"(select photofile_id from mdh_myphotofile   where vip_id='"+id+"' and filename='默认目录') order by photo_id desc"; 
			
		 ArrayList  list=new ArrayList();
		 	ResultSet rs = null;
	PageBean pageBean=new PageBean(request);
	pageBean.setPageSize(8);
	pageBean.count();
	int currRow=pageBean.getCurrentRow();
	int lastRow=pageBean.getLastRow();

	String csql="select count(*) from mdh_myphotos where  Filename_id in (select photofile_id from mdh_myphotofile   where vip_id='"+id+"' and filename='默认目录') ";
	String urlStr="PhotoAction.do?method=myPhoto&mmId="+id+"";
	try{
	pageBean.count(db,rs,csql,urlStr);
	}
	catch(Exception e){}
	strSql=" select  top "+lastRow+" * from mdh_myphotos where  Filename_id in (select photofile_id from mdh_myphotofile   where vip_id='"+id+"' and filename='默认目录') order by photo_id desc ";
	try{
	rs=db.OpenSql(strSql);
	if(currRow>0)
		rs.absolute(currRow);
	   while(rs.next())
	    {	 
	    	MyphotoBean photoBean=new MyphotoBean();

	       	photoBean.setPhotoId(rs.getString("photo_id"));
	       	photoBean.setPhotoName(rs.getString("photoname"));
	       	photoBean.setPhotoPath(rs.getString("photopath"));
	        
	          list.add(photoBean);
	         photoBean=null;
	    }}
	     	catch(SQLException e){
	     		db.close();
	       	e.printStackTrace();
	     	}
	      finally{
	      	db.close();
	      }
			return   list;
	}
		//������ϴ�ͼƬ�õ����е�Ŀ¼�����ϲ�ͬ���ǣ���(Ĭ��Ŀ¼
		public ArrayList getFilenames(String id,DB db)throws Exception{
			
			ArrayList arraylist=new ArrayList();
			Filename bean=null;
			String strSql="select photofile_id, filename  from mdh_myphotofile where  vip_id='"+id+"' ";
			
			ResultSet rs=db.OpenSql(strSql);
			while(rs.next()){
				bean=new Filename();
				bean.setPhotofileId(rs.getString("photofile_id"));
				bean.setFilename(rs.getString("filename"));
				
				arraylist.add(bean);
			}
			
			return arraylist;
		}
		
		//选择目录
		public ArrayList  getViphoto(HttpServletRequest request,String id,String dirId,DB db)throws SQLException{
			
		 //�õ���ѡ��8Ŀ�µ�ͼƬ
		 String strSql= "select photo_id,photoname,photopath from mdh_myphotos " +
		 		"where filename_id=(select top 1 photofile_id from  mdh_myphotofile " +
		 		"where vip_id =(select register_id from mdh_register where register_id='"+id+"') and photofile_id='"+dirId+"')"; 
		 ArrayList  list=new ArrayList();
		 	ResultSet rs = null;
	PageBean pageBean=new PageBean(request);
	pageBean.setPageSize(8);
	pageBean.count();
	int currRow=pageBean.getCurrentRow();
	int lastRow=pageBean.getLastRow();

	String csql="select count(*) from mdh_myphotos where filename_id=(select top 1 photofile_id from  mdh_myphotofile " +
 		"where vip_id =(select register_id from mdh_register where register_id='"+id+"') and photofile_id='"+dirId+"')";
	
	String urlStr="PhotoAction.do?method=myPhotoList&mmId="+id+"&dirname="+dirId+"";
	try{
	pageBean.count(db,rs,csql,urlStr);
	}
	catch(Exception e){}
	strSql=" select  top "+lastRow+" * from mdh_myphotos where filename_id=(select top 1 photofile_id from  mdh_myphotofile " +
 		"where vip_id =(select register_id from mdh_register where register_id='"+id+"') and photofile_id='"+dirId+"')";
	try{
	rs=db.OpenSql(strSql);
	if(currRow>0)
		rs.absolute(currRow);
		 	PhotoBean  bean=null;
		      
		        while( rs.next()) {
		        	MyphotoBean photoBean=new MyphotoBean();
			       	photoBean.setPhotoId(rs.getString("photo_id"));
			       	photoBean.setPhotoName(rs.getString("photoname"));
			       	photoBean.setPhotoPath(rs.getString("photopath"));
						
				     list.add(photoBean);
			         photoBean=null;			
				}}
 	catch(SQLException e){
 		db.close();
   	e.printStackTrace();
 	}
  finally{
  	db.close();
  }
	return   list;
 
		}
		public ArrayList  getViphotoFileName(HttpServletRequest request,String id,String photofile_id,DB db)throws SQLException{
			
		 //�õ�Ĭ��ͼƬ
		 String strSql= "select photo_id,photoname,photopath from mdh_myphotos where  Filename_id in " +
		 		"(select photofile_id from mdh_myphotofile   where vip_id='"+id+"' and photofile_id='"+photofile_id+"') order by photo_id desc"; 
			
		 ArrayList  list=new ArrayList();
		 	ResultSet rs = null;
	PageBean pageBean=new PageBean(request);
	pageBean.setPageSize(8);
	pageBean.count();
	int currRow=pageBean.getCurrentRow();
	int lastRow=pageBean.getLastRow();

	String csql="select count(*) from mdh_myphotos where  Filename_id in (select photofile_id from mdh_myphotofile   where vip_id='"+id+"' and photofile_id='"+photofile_id+"') ";
	String urlStr="PhotoAction.do?method=myPhotoFileName";
	try{
	pageBean.count(db,rs,csql,urlStr);
	}
	catch(Exception e){}
	strSql=" select  top "+lastRow+" * from mdh_myphotos where  Filename_id in (select photofile_id from mdh_myphotofile   where vip_id='"+id+"' and photofile_id='"+photofile_id+"') order by photo_id desc ";
	try{
	rs=db.OpenSql(strSql);
	if(currRow>0)
		rs.absolute(currRow);
	   while(rs.next())
	    {	 
	    	MyphotoBean photoBean=new MyphotoBean();

	       	photoBean.setPhotoId(rs.getString("photo_id"));
	       	photoBean.setPhotoName(rs.getString("photoname"));
	       	photoBean.setPhotoPath(rs.getString("photopath"));
	        
	          list.add(photoBean);
	         photoBean=null;
	    }}
	     	catch(SQLException e){
	     		db.close();
	       	e.printStackTrace();
	     	}
	      finally{
	      	db.close();
	      }
			return   list;
	}
		//�ϴ�ͼƬ
		//���� 2 ����ͬ��ͼƬ, ���� 1 �ɹ�,����0 ���벻�ɹ�
		public int insertPhoto(String id,String filenameId,String filename,String photopath,String content,DB db)throws Exception{
			int su=2;
			 //�ж����Ŀ¼���Ƿ�����ͬ��ͼƬ
			   String  text=DealText.dealToSql(filename);
			   String  text2=DealText.dealToSql(content);

			String strSql="select * from mdh_myphotos  where filename_id='"+filenameId+"' and  photoname='"+text+"'";
				ResultSet rs=db.OpenSql(strSql);//����
			if(!rs.next()){
								//Ĭ��'0'Ϊ,����������ͼ, 1,Ϊ����,
				String strSql2="insert into mdh_myphotos values('"+filenameId+"','"+text+"','"+photopath+"','"+getNewTime()+"','"+text2+"','0','0')";
			
				su=db.ExecSql(strSql2);
				
			}
			return su;
			
		}
		
		// �ж��Ƿ�����������ͼƬ
		
		public boolean checkPhoto(String id,DB db)throws SQLException {
			boolean checked=false;
			
			String strSql="select * from mdh_myphotos where" +
					" filename_id in(  select photofile_id " +
					"from mdh_myphotofile  where vip_id='"+id+"') and visualize=1";
			
			ResultSet rs=db.OpenSql(strSql);
			if(!rs.next()){
				checked=true;
			}
			
			return checked;
			
		}
		//�Ƿ��Ѽ���
		public boolean checkLock(String photoId,DB db)throws SQLException {
			boolean checked=false;
			
			String strSql=" select * from mdh_myphotos where photo_id='"+photoId+"' and lock=0";
			
			ResultSet rs=db.OpenSql(strSql);
			if(!rs.next()){
				checked=true;
	
			}
			
			return checked;
			
		}
		
		//����
	 
		
		public boolean inserLock(String photoId,DB db)throws SQLException{
			
			boolean checked=false;
			String strSql="update  mdh_myphotos set lock=1  where photo_id='"+photoId+"'";
			
			if(db.ExecSql(strSql)!=0)
			{
				checked=true;
				
			}
				return checked;
		}
		
		//��������ͼƬ
		
		public boolean inserGoodPhoto(String photoId,DB db)throws SQLException{
			
			boolean checked=false;
			String strSql="update  mdh_myphotos set visualize=1  where photo_id='"+photoId+"'";
			
			if(db.ExecSql(strSql)!=0)
			{
				checked=true;
				
			}
				return checked;
		}
		//ɾ��ͼƬ
		public boolean deletePhotoss(String photoId,DB db)throws SQLException{
			
			boolean checked=false;
			String strSql="delete from  mdh_myphotos  where photo_id='"+photoId+"'";
			
			if(db.ExecSql(strSql)!=0)
			{
				checked=true;
				
			}
				return checked;
		}
		/**
		 * @return
		 */
		  public static String getNewTime()
		  {
			 SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			Date date=new Date();
	 			String strDate = sf.format(date);
		  	return strDate;
		  }
}

⌨️ 快捷键说明

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