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

📄 mailbean.java

📁 “JSP数据库项目案例导航”一书从第一章到第十一章各章实例的源程序文件以及数据库文件。 注意: 1. 本书中的案例提供的数据库环境不同
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/**********************************************************
Copyright (C),2003-10-17, Beijing  USTB.
All rights reserved.
Filename: MailBean.java
Author: cqh,baointoo
Version 1.0
Date:2003-10-17
Description:all beans about the mail model
Other:
Variable List:

Function List:
1.public MailBean()          
2.public void addFMail(Hashtable hash) throws Exception								//add record in zz_fyjb
3.public void addSMail(Hashtable hash) throws Exception   							//add record in zz_syjb
4.public void addFujian(Hashtable hash) throws Exception							//add record in zz_yjfjb
5.public void addGlc(Hashtable hash) throws Exception								 //add record in zz_glcb
6.public void addSMS(String sender,String receiver,String sjid) throws Exception    //add record in sms

7.public Vector receiveMail(String user,String table,int value) throws Exception    //get record from zz_syjb
8.public Vector sendMail(String user,String table,int value) throws Exception		//get record from zz_fyjb
9.public Vector receiveFujian(String user,String table) throws Exception			//get record from zz_yjfjb
10.public Vector receiveGlc(String zgbh) throws Exception							//get record from zz_glcb 

11.public void modifyFMail(int value,int fjid) throws Exception						//change the status of the record in zz_fyjb
12.public void modifySMail(int value,String sjid) throws Exception					//change the status of the record in zz_syjb
13.public void modifyREAD(int value,int sjid) throws Exception						//change the column "read" in zz_syjb,to check 
																					  whether the mail has been read
14.public void delFMail(String value) throws Exception								//delete record from zz_fyjb
15.public void delFJ(int value) throws Exception									//delete record from zz_yjfjb
16.public void delSMail(String value) throws Exception								//delete record from zz_syjb
17.public void delGlc(int value) throws Exception									//delete filter-word(glc) from zz_glcb
18.public String getMax(String table,String value) throws Exception					//get the max id from the table
19.public void addSJR(Hashtable hash)throws Exception								//add record in zz_sjrb
20.public void delSJR(int value)throws Exception									//delete record from zz_sjrb
21.public void delSFGX(int value) throws Exception									//delete record from zz_sjfjgxb
22.public void addSFGX(String sjid,String yjfjid) throws Exception					//add record from zz_sjfjgxb
23.public Vector getFJ(String value) throws Exception								//get record from zz_yjfjb
24.public int refuse(String jsrbh,String zgbh) throws Exception						//get record from zz_sjrb,get refuse-person
25.public String convert(int value) throws Exception								//convert the total sum from int type to the string type
26.public String toUtf8String(String src)											//convert to the utf8 code
27.public String getGL() throws Exception											//get system-filter from dic-table
28.public int CheckMount(String zgbh) throws Exception								//get the total used space of the mailbox
29.public void DeleteFujianFromReceive(String sjid) throws Exception				//delete additions with receive mail
30.public void DeleteFujianFromSend(String yjfjid) throws Exception					//delete additions with send mail
31.public void DeleteFJ(String yjfjid) throws Exception                                         //delete accesory
32.private int CheckS(String yjfjid) throws Exception                				//get the number of the sjids associated with accesory
33.private int CheckF(String yjfjid) throws Exception  								//get the number of the fjids associated with accesory
34.public void DeleteFJInS (String yjfjid) throws Exception 						//delete accesory with receive mail
35.public void DeleteFJInF (String yjfjid) throws Exception 						//delete accesory in sendmail box
36.public void DeleteFJInC (String yjfjid) throws Exception 						//delete accesory in caogao box
37.public String getmyTime()  throws Exception										//get the current time

History:
***********************************************************/
package oa.bean;

import java.text.*;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.sql.*;
import oa.main.*;
import com.jspsmart.upload.SmartUpload;
import com.jspsmart.upload.SmartUploadException;

public class MailBean extends ParentBean{

  public MailBean() throws Exception{
   }

  public String addSMail(Hashtable hash){
    String strFJID = ds.toString((String)hash.get("FJID"));
    String strSJID = ds.toString((String)hash.get("SJID"));
	String strSJRZGBH[] = ds.toString((String)hash.get("SJR")).split(",");
    String strFJRZGBH = ds.toString((String)hash.get("FJR"));
    String strZT = ds.toString((String)hash.get("ZT"));
    String strNR = ds.toString((String)hash.get("NR")).replaceAll("'","''");
    String strJLSJ = ds.toString((String)hash.get("JLSJ"));
    String strFSSJ = ds.toString((String)hash.get("FSSJ"));
    String strFJDX = ds.toString((String)hash.get("FJDX"));
    String strYJZT = ds.toString((String)hash.get("YJZT"));
    String strREAD=ds.toString((String)hash.get("READ"));
    String strSUCCESS=ds.toString((String)hash.get("SUCCESS"));

	createStatement();
	clearBatch();
	
	String strSJID1 = "";
	long intID = ds.makeID(Integer.parseInt(strFJRZGBH));
	for (int i=0;i<strSJRZGBH.length ;i++ )
	{
		//intID = ds.makeID ( Integer.parseInt(strSJRZGBH));
		if(strSJRZGBH[i].equals(""))
			continue;
		 String strSQL ="INSERT INTO zz_syjb(SJID,SJRZGBH,FJRZGBH,ZT,NR,JLSJ,FSSJ,FJDX,YJZT,READ,SUCCESS) VALUES('"
                  +intID+"','"+strSJRZGBH[i]+"','"+strFJRZGBH+"','"+strZT+"','"+strNR
                  +"','"+strJLSJ+"','"+strFSSJ+"',"+strFJDX+","+strYJZT+","+strREAD+","+strSUCCESS+")";
		 addBatch(strSQL);
		 strSJID1 += Long.toString(intID) + ",";
		 intID++;
	}
	executeBatch();
	closeStm();
	return strSJID1;
  }

     public void addFMail(Hashtable hash){
          String strFJID = ds.toString((String)hash.get("FJID"));
          String strSJRZGBH = ds.toString((String)hash.get("SJR"));
          String strFJRZGBH = ds.toString((String)hash.get("FJR"));
          String strZT = ds.toString((String)hash.get("ZT"));
          String strNR = ds.toString((String)hash.get("NR")).replaceAll("'","''");
          String strJLSJ = ds.toString((String)hash.get("JLSJ"));
          String strFSSJ = ds.toString((String)hash.get("FSSJ"));
          String strFJDX = ds.toString((String)hash.get("FJDX"));
          String strYJZT = ds.toString((String)hash.get("YJZT"));
	      String strSUCCESS=ds.toString((String)hash.get("SUCCESS"));
          String strSQL ="INSERT INTO zz_fyjb(FJID,FJRZGBH,ZT,NR,JLSJ,FSSJ,FJDX,YJZT,SUCCESS) VALUES('"
                        +strFJID+"','"+strFJRZGBH+"','"+strZT+"','"+strNR
                        +"','"+strJLSJ+"','"+strFSSJ+"',"+strFJDX+","+strYJZT+","+strSUCCESS+")";
          db.ExecuteSQL(strSQL);
        }

    public void addFujian(Hashtable hash){
         String strYJFJID = ds.toString((String)hash.get("YJFJID"));
         String strFJID = ds.toString((String)hash.get("FJID"));
         String strFJMC = ds.toString((String)hash.get("FJMC")).replaceAll("'","''");
         String strFJDX = ds.toGBK(ds.toString((String)hash.get("FJDX")));
         String strFJWZ = ds.toGBK(ds.toString((String)hash.get("FJWZ")));
         String strFJXMC = ds.toString((String)hash.get("FJXMC")).replaceAll("'","''");
		 String strFUJIANZT = ds.toString((String)hash.get("FUJIANZT"));
         String strSQL ="INSERT INTO zz_yjfjb(YJFJID,FJID,FJMC,FJDX,FJWZ,FJXMC,FUJIANZT) VALUES('"
                       +strYJFJID+"','"+strFJID+"','"+strFJMC+"','"+strFJDX
                       +"','"+strFJWZ+"','"+strFJXMC+"','"+strFUJIANZT+"')";
         db.ExecuteSQL(strSQL);
        }

     public void addGlc(Hashtable hash ){
              String strGLCID = ds.toString((String)hash.get("GLCID"));
              String strGlc = ds.toString((String)hash.get("GLC"));
              String strZGBH=ds.toString((String)hash.get("ZGBH"));
              String strSQL ="INSERT INTO zz_glcb(GLCID,GLC,ZGBH) VALUES('"+strGLCID+"','"+strGlc+"',"+strZGBH+")";
              db.ExecuteSQL(strSQL);
       }

     public void addSMS(String sender,String receiver,String sjid){
		      ResultSet rs=null,rs1=null;
              DocBean doc=null;
			  DealString ds=new DealString();
              long SMSID=ds.makeID(Integer.parseInt(sender));
			  String str1="select xm from zz_zgb where zgbh='"+sender+"'";
			  Statement stmt = null;
			try{
			  doc = new DocBean();
			  rs1 = doc.QuerySQL(str1);
			  while (rs1.next()){
				  String xm=rs1.getString("xm");	
			  	  String str="select zt from zz_syjb where sjid='"+sjid+"'";
				  rs=doc.QuerySQL(str);
				  while (rs.next()){
					  String zt=ds.toString(rs.getString("zt")).replaceAll("'","''");
					  String SENDER=ds.toString((String)sender);
					  String RECEIVER=ds.toString((String)receiver);

					  //处理接收者新消息数量
					  oa.main.Online.add1SMSCount ( RECEIVER ) ;
					  oa.main.Online.addSMSNew ( RECEIVER ) ;
					  String title = "系统消息";
					  String content=xm+"已经读了您的主题为“"+zt+"”的邮件";
					  String SENDTIME=ds.getDateTime();
					  String sms="insert into SMS(ID,SENDER,RECEIVER,TITLE,content,SENDTIME,ISREAD,ISDEL) values('"+SMSID+"','"+SENDER+"','"+RECEIVER+"','"+title+"','"+content+"','"+SENDTIME+"','0','0')";
					  doc.ExecuteSQL(sms);
				  }
			  }
			}catch(Exception e){System.out.println("运行时出错:"+e);}
			finally{
				if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
				if(rs1!=null)try{ stmt = rs1.getStatement(); rs1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
				if(doc !=null)
					doc.closeConn();
			}
        }
	 /**       对时间格式进行转换
	   *
	   *
	  **/
	 public String getDate(String fssj)
	 {
		  String s = fssj.substring(0,fssj.indexOf(" "));
		  int n = s.indexOf("-");
		  if (n == 4)
		  {
			  s = s.replaceAll("-","年");
		  }
		  else 
		  {
			  s = s.replaceAll("-","月");
		  }

		  s += "日";
		  return s;
			 
	 }

	 public void addSMS1(String sender,String receiver,String sjid,String mail_zt){
		      ResultSet rs=null,rs1=null;
              DocBean doc=null;
			  DealString ds=new DealString();
              long SMSID=ds.makeID(Integer.parseInt(sender));
			  String str1="select xm from zz_zgb where zgbh='"+sender+"'";
			  Statement stmt = null;
			try{
			  doc = new DocBean();
			  rs1 = doc.QuerySQL(str1);
			  while (rs1.next()){
				  String xm=rs1.getString("xm");	
			  	  String str="select zt,fssj from zz_syjb where sjid='"+sjid+"'";
				  rs=doc.QuerySQL(str);
				  while (rs.next()){
					  String zt=ds.toString(rs.getString("zt"));
					  String fssj = ds.toString(rs.getString("fssj"));
					  String s = ds.getDateTime();//getDate(fssj);
					  String SENDER=ds.toString((String)sender);
					  String RECEIVER=ds.toString((String)receiver);

					  //处理接收者新消息数量
					  oa.main.Online.add1SMSCount ( RECEIVER ) ;
					  oa.main.Online.addSMSNew ( RECEIVER ) ;

					  String title="邮件发送失败通知";
					  String nr = s + ","+xm+"欲给您发送一封 \""+mail_zt+"\" 邮件,由于您的邮箱已满,所以不能成功发送给您,请您尽快清理您的邮箱。";
					  String SENDTIME=ds.getDateTime();
					  String sms="insert into SMS(ID,SENDER,RECEIVER,TITLE,CONTENT,SENDTIME,ISREAD,ISDEL) values('"+SMSID+"','"+SENDER+"','"+RECEIVER+"','"+title+"','"+nr+"','"+SENDTIME+"','0','0')";
					  doc.ExecuteSQL(sms);
				  }
			  }
			}catch(Exception e){System.out.println("运行时出错:"+e);}
			finally{
				if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
				if(rs1!=null)try{ stmt = rs1.getStatement(); rs1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
				if(doc !=null)
					doc.closeConn();
			}
        }

     public Vector receiveMail(String user,String table,int value,String sort,String searchType){
           Vector vector = new Vector();
           String strSQL ="select zz_syjb.*,zz_zgb.xm,zz_zgb.zgbh from zz_syjb,zz_zgb where zz_zgb.zgbh=zz_syjb.fjrzgbh and success='0' and "+table+"='"+user +"' and yjzt='"+value+"' order by";
		   /**   sort=0:正序;sort=1:倒序;
		     *   searchType = 1:发件人;2.主题;3.发送日期;4.附件;5.附件大小;6.邮件是否已读;
			 *
			**/

		   String w = "";
		   if (searchType.equals("1"))
		   {
			   w = " xm";
		   }
		   else if (searchType.equals("2"))
		   {
			   w = " zt";
		   }
		   else if (searchType.equals("3"))
		   {
			   w = " fssj";
		   }
		   else if (searchType.equals("4") || searchType.equals("5"))
		   {
			   w = " fjdx";
		   }
		   else if (searchType.equals("6"))
		   {
			   w = " read";
		   }
		  strSQL += w;
		  if (sort.equals("1"))
		  {
			  strSQL += " desc";
		  }
		   ResultSet rs = db.QuerySQL(strSQL);
           MailElementBean meb;
		   Statement stmt = null;
		   try{
           while(rs.next()){
             meb= new MailElementBean();
				 meb.setSJID(rs.getLong("SJID"));
				 meb.setSJRZGBH(rs.getString("SJRZGBH"));
				 meb.setFJRZGBH(rs.getString("FJRZGBH"));
				 meb.setXM(rs.getString("XM"));
				 meb.setZT(rs.getString("ZT"));
				 meb.setNR(rs.getString("NR"));
				 meb.setJLSJ(rs.getString("JLSJ"));
				 meb.setFSSJ(rs.getString("FSSJ"));
				 meb.setFJDX(rs.getInt("FJDX"));
				 meb.setYJZT(rs.getInt("YJZT"));
				 meb.setREAD(rs.getString("READ"));
				 meb.setZGBH(rs.getString("ZGBH"));
				 meb.setSUCCESS(rs.getInt("SUCCESS"));
             vector.add(meb);
        }
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
           return vector;
         }

         public Vector sendMail(String user,String table,int value,String sort,String searchType){
           Vector vector = new Vector();
           String strSQL ="select zz_fyjb.*,zz_sjrb.*,zz_zgb.xm from zz_fyjb,zz_zgb,zz_sjrb where zz_fyjb.fjid=zz_sjrb.fjid and zz_sjrb.sjrzgbh=zz_zgb.zgbh and success='0' and "+table+"="+user +" and yjzt='"+value+"'";
		   String w = "";
		   if (searchType.equals("1"))
		   {
			   w = " order by xm";
		   }
		   else if (searchType.equals("2"))
		   {
			   w = " order by zt";
		   }
		   else if (searchType.equals("3"))
		   {
			   w = " order by fssj";
		   }
		   else if (searchType.equals("4") || searchType.equals("5"))
		   {
			   w = " order by fjdx";
		   }
		   else if (searchType.equals("6"))
		   {
			   w = " order by read";
		   }
		  strSQL += w;
		  if (sort.equals("1"))
		  {
			  strSQL += " desc";
		  }

           ResultSet rs = db.QuerySQL(strSQL);
		   Statement stmt = null;
		   try{
           MailElementBean meb;
           while(rs.next()){
             meb= new MailElementBean();
				 meb.setFJID(rs.getLong("FJID"));
				 meb.setFJRZGBH(rs.getString("FJRZGBH"));
				  meb.setSJRZGBH(rs.getString("SJRZGBH"));
				 meb.setXM(rs.getString("XM"));
				 meb.setZT(rs.getString("ZT"));
				 meb.setNR(rs.getString("NR"));
				 meb.setJLSJ(rs.getString("JLSJ"));
				 meb.setFSSJ(rs.getString("FSSJ"));
				 meb.setFJDX(rs.getInt("FJDX"));
				 meb.setYJZT(rs.getInt("YJZT"));
				 meb.setSUCCESS(rs.getInt("SUCCESS"));
             vector.add(meb);
           }
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
           return vector;
         }

         public Vector receiveFujian(String user,String table){
             Vector vector = new Vector();
             String strSQL ="select * from zz_yjfjb where "+table+"="+user;
             ResultSet rs = db.QuerySQL(strSQL);
			 Statement stmt = null;
			 try{
             MailElementBean meb;
             while(rs.next()){
		    meb= new MailElementBean();
                    meb.setYJFJID(rs.getLong("YJFJID"));
                    meb.setFJID(rs.getLong("FJID"));
                    meb.setFJMC(rs.getString("FJMC"));
                    meb.setFJDX(rs.getInt("FJDX"));
                    meb.setFJWZ(rs.getString("FJWZ"));
                    meb.setFJXMC(rs.getString("FJXMC"));
                    meb.setFUJIANZT(rs.getInt("FUJIANZT"));
             vector.add(meb);
       }
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
       return vector;
         }

      public Vector receiveGlc(String zgbh){
		  Vector vector = new Vector();
		  String strSQL ="select * from zz_glcb where zgbh='"+zgbh+"'";
		  ResultSet rs = db.QuerySQL(strSQL);
		  Statement stmt = null;
		  try{
			  MailElementBean meb;
			  while(rs.next()){
				 meb= new MailElementBean();
					  meb.setGLCID(rs.getInt("GLCID"));
					  meb.setGLC(rs.getString("GLC"));
					  meb.setZGBH(rs.getString("ZGBH"));
			   vector.add(meb);
                }
			}catch(Exception e){System.out.println("运行时出错:"+e);}
			finally{
				if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
			}
         return vector;
         }

    public void modifyFMail(int value,long fjid){
      String strSQL="update zz_fyjb set yjzt='"+value+"'  where fjid='"+fjid+"'";
      db.ExecuteSQL(strSQL);
    }
    public void modifySMail(int value,String sjid){
		  String strSQL="update zz_syjb set yjzt='"+value+"'  where sjid='"+sjid+"'";

⌨️ 快捷键说明

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