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

📄 clubaffiche.java

📁 GamVan Club v1.1 源代码
💻 JAVA
字号:
package com.gamvan.club.manage;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.gamvan.conn.ConnClub;
import com.gamvan.tools.Gb;
public class ClubAffiche{
    private String caTopic = new String("");
    private String caContent = new String("");
    private String caAddTime = new String("");
    private String caByUser = new String("");
    private String caByip = new String("");
    private String message = new String("");
    private int caID = 0;
    private int ccID = 0;
    private int caDays = 0;
    Gb clubgb = new Gb(); //中文编码
    //格式化当前时间
    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();
    public boolean clubAffiche(String act) throws SQLException{
        boolean bea = false;
        if(act.equals("add")){
            bea = afficheAdd();
        }else if(act.equals("edit")){
            bea = afficheEdit();
        }else{
             message= "您的操作触发一个美丽的意外,指令将不被执行,请重新尝试!";
        }
        return bea;
    }
    public boolean afficheAdd() throws SQLException{
        boolean bea = false;
        String sqlCommand = new String();
        Connection con = bridge.getConnection();
         try{
             sqlCommand = "Insert Into GVclubAffiche(ccID, caTopic, caContent, caAddTime, caDays";
             sqlCommand += ", caByUser, caByip) Values(?,?,?,?,?,?,?)";
             PreparedStatement pps = con.prepareStatement(sqlCommand);
             pps.setInt(1, ccID);
             pps.setString(2, caTopic);
             pps.setString(3, caContent);
             pps.setString(4, now);
             pps.setInt(5, caDays);
             pps.setString(6, caByUser);
             pps.setString(7, caByip);
             pps.executeUpdate();
             pps.close();
             bea = true;
             message= "公告添加成功!";
             //message = String.valueOf(caDays) + caByUser + caByip;
         }catch(Exception e){
             bea = false;
             //message=now;
             message= e+"系统发生意外错误,指令将不被执行,请重新尝试!";
         }finally{
         	con.close();
         }
        return bea;
    }
    public boolean afficheEdit() throws SQLException{
        boolean bea = false;
        String sqlCommand = new String();
        Connection con = bridge.getConnection();
         try{
             sqlCommand = "Update GVclubAffiche set caTopic=?, caContent=?, caAddTime=?";
             sqlCommand +=", caDays=?, caByUser=?, caByip=?, ccID=? where caID=?";
             PreparedStatement pps = con.prepareStatement(sqlCommand);
             pps.setString(1, caTopic);
             pps.setString(2, caContent);
             pps.setString(3, now);
             pps.setInt(4, caDays);
             pps.setString(5, caByUser);
             pps.setString(6, caByip);
             pps.setInt(7,ccID);
             pps.setInt(8,caID);
             pps.executeUpdate();
             pps.close();
             bea = true;
             message= "公告编辑成功!";
         }catch(Exception e){
             bea = false;
             message= "系统发生意外错误,指令将不被执行,请重新尝试!";
         }finally{
         	con.close();
         }
        
        return bea;
    }
    public boolean afficheInfo(int caid) throws SQLException{
        boolean bea = false;
        String sqlCommand = new String();
        ResultSet rs;
        Connection con = bridge.getConnection();
         try{
             sqlCommand = "Select * From GVclubAffiche where caID=?";
             PreparedStatement pps = con.prepareStatement(sqlCommand);
             pps.setInt(1, caid);
             rs = pps.executeQuery();
             if(rs.next()){
                 caTopic = rs.getString(3).trim();
                 caContent = rs.getString(4).trim();
                 caAddTime = rs.getString(5);
                 caDays = rs.getInt(6);
                 caByUser = rs.getString(7);
                 caByip = rs.getString(8);
             }
             pps.close();
             bea = true;
         }catch(Exception e){
             bea = false;
             message= "系统发生意外错误,指令将不被执行,请重新尝试!";
         }finally{
         	con.close();
         }
        return bea;
    }
    public boolean afficheDel(String[] caIDs) throws SQLException{
        boolean bea = false;
        String sqlCommand = new String();
        String caids = new String();
        Connection con = bridge.getConnection();
         try{
             caids = "0";
             int i = 0;   
             for (i = 0; i < caIDs.length; i++) {
                caids += "," + caIDs[i];
             } 
             sqlCommand = "DELETE FROM GVclubAffiche where caID  in ("+ caids + ")";
             
             PreparedStatement pps = con.prepareStatement(sqlCommand);
             pps.executeUpdate();
             pps.close();
             bea = true;
             message= "所选公告已被删除!";
         }catch(Exception e){
             bea = false;
             message= "系统发生意外错误,指令将不被执行,请重新尝试!";
         }finally{
         	con.close();
         }
        //message= sqlCommand;
        return bea;
    }
    public String getMessage(){
        return this.message;
    }
    public void setCAID(int caID){
       this.caID=caID;
    }
    public void setCCID(int ccID){
       this.ccID=ccID;
    }
    public void setDays(String caDays){
        if(caDays!=null){
            this.caDays = Integer.parseInt(caDays);
        }
    }
    public int getDays(){
        return this.caDays;
    }
    public String getByUser(){
        return this.caByUser;
    }
    public void setByUser(String caByUser){
        //caByUser = clubgb.gb(caByUser);
        this.caByUser=caByUser.trim();
    }
    public String getByip(){
        return this.caByip;
    }
    public void setByip(String caByip){
        this.caByip=caByip.trim();
    }
    public String getTopic(){
        return this.caTopic;
    }
    public void setTopic(String caTopic){
        caTopic = clubgb.gb(caTopic);
        this.caTopic=caTopic.trim();
    } 
    public String getContent(){
        return this.caContent;
    }
    public void setContent(String caContent){
        caContent = clubgb.gb(caContent);
        this.caContent=caContent.trim();
    }
}

⌨️ 快捷键说明

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