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

📄 clubmessage.java

📁 GamVan Club v1.1 源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * ClubMessage.java
 * Made In GamVan
 * Created on 2005年3月28日, 下午9:04
 */
package com.gamvan.club.message;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import com.gamvan.club.ClubUsers;
import com.gamvan.conn.ConnClub;
import com.gamvan.tools.EncodeString;
import com.gamvan.tools.Gb;
public class ClubMessage {
    private String cmTakeUser = "";
    private String cmSendUser = "";
    private int cmID = 0;
    private String cmTopic = "";
    private String cmContent = "";
    private String cmUserIp = "";
    private String cmAddTime = "";
    private int cmIsTake = 0; //已经接收,尚未接收。
    private int cmIsSend = 0;
    private int cmOrder = 0;
    private int cmReID = 0;
    private int isPost = 0;
    private int cmSendID = 0;
    private int cmTakeID = 0;
    private String message="";
    //格式化当前时间
    java.text.SimpleDateFormat isNow = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private String now = isNow.format(new java.util.Date());
    ConnClub bridge = new ConnClub();
    EncodeString es = new EncodeString();
    Gb clubgb = new Gb();
    public boolean takeDel(String cmids[]) throws Exception{
        boolean bea = false;
        if(cmids==null){
            message = "请选定你要删除的短消息。";
            return bea;
        }
        String cmid = "0";
        StringBuffer sqlCommand = new StringBuffer("");
        Connection con = bridge.getConnection();
        for(int i=0; i<cmids.length; i++){
            cmid += "," + cmids[i];
        }
        try{
            sqlCommand.append("Delete From GVclubMessageTake where cmID in ("+ cmid +")");
            PreparedStatement pps = con.prepareStatement(sqlCommand.toString());
            pps.executeUpdate();
            pps.close();
            bea = true;
            message = "操作成功,所选短信已被删除。";
        }catch(Exception e){
            message = e.toString();
            con.close();
        }finally{
            con.close();
        }
        //message = sqlCommand.toString();
        return bea;
    }
    public boolean sendDel(String cmids[]) throws Exception{
        boolean bea = false;
        if(cmids==null){
            message = "请选定你要删除的短消息。";
            return bea;
        }
        String cmid = "0";
        StringBuffer sqlCommand = new StringBuffer("");
        Connection con = bridge.getConnection();
        for(int i=0; i<cmids.length; i++){
            cmid += "," + cmids[i];
        }
        try{
            sqlCommand.append("Delete From GVclubMessageSend where cmID in ("+ cmid +")");
            PreparedStatement pps = con.prepareStatement(sqlCommand.toString());
            pps.executeUpdate();
            pps.close();
            bea = true;
            message = "操作成功,所选短信已被删除。";
        }catch(Exception e){
            //message = e.toString();
            con.close();
        }finally{
            con.close();
        }
        return bea;
    }
    public boolean takeUpdate(int cmID) throws Exception{
        boolean bea = false;
        Connection con = bridge.getConnection();
        StringBuffer sqlCommand = new StringBuffer("");
        try{
            sqlCommand.append("update GVclubMessageTake set cmIsTake=1 where cmID=?");
            PreparedStatement pps = con.prepareStatement(sqlCommand.toString());
            pps.setInt(1,cmID);
            pps.executeUpdate();
            pps.close();
        }catch(Exception e){
            con.close();
        }finally{
            con.close();
        }
        return bea;
    }
    public boolean sendUpdate(int cmID) throws Exception{
        boolean bea = false;
        Connection con = bridge.getConnection();
        StringBuffer sqlCommand = new StringBuffer("");
        try{
            sqlCommand.append("update GVclubMessageSend set cmIsSend=1 where cmID=?");
            PreparedStatement pps = con.prepareStatement(sqlCommand.toString());
            pps.setInt(1,cmID);
            pps.executeUpdate();
            pps.close();
        }catch(Exception e){
            con.close();
        }finally{
            con.close();
        }
        return bea;
    } 
    
    // 查询用户是否有新短消息。
    public boolean newMessage(String uName) throws Exception{
        boolean bea = false;
        Connection con = bridge.getConnection();
        StringBuffer sqlCommand = new StringBuffer("");
        try{
            sqlCommand.append("Select * From GVclubMessageTake where cmIsTake=0 ");
            sqlCommand.append(" and cmTakeUser=? order by cmOrder desc, cmID desc");
            PreparedStatement pps = con.prepareStatement(sqlCommand.toString());
            pps.setString(1,uName);
            ResultSet rs;
            rs = pps.executeQuery();
            if(rs.next()){
                cmID = rs.getInt(1);
                cmTakeUser = rs.getString(2);
                cmSendUser = rs.getString(3);
                cmTopic = rs.getString(4);
                cmContent = rs.getString(5);
                cmAddTime = rs.getString(7);
                cmAddTime = cmAddTime.replace(".0","");
                cmIsTake = rs.getInt(8);
                cmOrder = rs.getInt(9);
                cmReID = rs.getInt(10);
                cmSendID = rs.getInt(11);
                cmTakeID = rs.getInt(12);
                bea = true;
            }
            rs.close();
            pps.close();
        }catch(Exception e){
            message = e.toString();
            bea = false;
            con.close();
        }finally{
            con.close();
        }
        return bea;
    }
    //
    public boolean sendToTake(int cmID) throws Exception{
        boolean bea = false;
        sendMessageInfo(cmID);
        sendUpdate(cmID);
        this.cmIsTake = 0;
        cmAddTake(cmTakeUser);
        message = "短信发送成功!";
        return bea;
    }
    //
     public boolean takeMessageInfo(int cmID) throws Exception{
        boolean bea = false;
        Connection con = bridge.getConnection();
        StringBuffer sqlCommand = new StringBuffer("");
        try{
            sqlCommand.append("select * From GVclubMessageTake where cmID=?");
            PreparedStatement pps = con.prepareStatement(sqlCommand.toString());
            pps.setInt(1,cmID);
            ResultSet rs;
            rs = pps.executeQuery();
            if(rs.next()){
                cmID = rs.getInt(1);
                cmTakeUser = rs.getString(2);
                cmSendUser = rs.getString(3);
                cmTopic = rs.getString(4);
                cmContent = rs.getString(5);
                cmAddTime = rs.getString(7);
                cmAddTime = cmAddTime.replace(".0","");
                cmIsTake = rs.getInt(8);
                cmOrder = rs.getInt(9);
                cmReID = rs.getInt(10);
                cmSendID = rs.getInt(11);
                cmTakeID = rs.getInt(12);
                bea = true;
            }
            rs.close();
            pps.close();
        }catch(Exception e){
            con.close();
            message = e.toString();
        }finally{
            con.close();
        }
        return bea;
    }
    public boolean sendMessageInfo(int cmID) throws Exception{
        boolean bea = false;
        Connection con = bridge.getConnection();
        StringBuffer sqlCommand = new StringBuffer("");
        try{
            sqlCommand.append("select * From GVclubMessageSend where cmID=?");
            PreparedStatement pps = con.prepareStatement(sqlCommand.toString());
            pps.setInt(1,cmID);
            ResultSet rs;
            rs = pps.executeQuery();
            if(rs.next()){
                cmID = rs.getInt(1);

⌨️ 快捷键说明

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