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

📄 smsmanager.java

📁 jsp网站开发四“酷”全书原码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            DBConnect dbc = new DBConnect();
            sql = "update bbs.message set delR=1 where incept=? and id =" + ID;
            dbc.prepareStatement(sql);
            dbc.setBytes(1, (new String(userName.getBytes("ISO-8859-1"), "GBK")).getBytes());
            dbc.executeUpdate();
            dbc.close();
        }
	}

	public void  allDelInBox() throws Exception{
		sql="update bbs.message set delR=1 where incept=? and delR=0";
		DBConnect dbc=new DBConnect();
		dbc.prepareStatement(sql);
		dbc.setBytes(1,(new String(userName.getBytes("ISO-8859-1"),"GBK")).getBytes());
		dbc.executeUpdate();
		dbc.close();
	}
	public void  delOutBox(HttpServletRequest request) throws Exception{
		int ID=0;
        String[] ids = request.getParameterValues("id");
        if(ids.length==0)
            throw new Exception("请指定相关参数。");
        for(int i=0;i<ids.length;i++)
        {
            ID = Integer.parseInt(ids[i]);

            DBConnect dbc = new DBConnect();
            sql = "update bbs.message set delS=1 where sender=? and issend=0 and id =" + ID;
            dbc.prepareStatement(sql);
            dbc.setBytes(1, (new String(userName.getBytes("ISO-8859-1"), "GBK")).getBytes());
            dbc.executeUpdate();
            dbc.close();
        }
	}

	public void  allDelOutBox() throws Exception{
		sql="update bbs.message set delS=1 where sender=? and delS=0 and issend=0";
		DBConnect dbc=new DBConnect();
		dbc.prepareStatement(sql);
		dbc.setBytes(1,(new String(userName.getBytes("ISO-8859-1"),"GBK")).getBytes());
		dbc.executeUpdate();
		dbc.close();
	}
	public void  delIsSend(HttpServletRequest request) throws Exception{
		int ID=0;
        String[] ids = request.getParameterValues("id");
        if(ids.length==0)
            throw new Exception("请指定相关参数。");
        for(int i=0;i<ids.length;i++)
        {
            ID = Integer.parseInt(ids[i]);

            DBConnect dbc = new DBConnect();
            sql = "update bbs.message set delS=1 where sender=? and issend=1 and id =" + ID;
            dbc.prepareStatement(sql);
            dbc.setBytes(1, (new String(userName.getBytes("ISO-8859-1"), "GBK")).getBytes());
            dbc.executeUpdate();
            dbc.close();
        }
	}
	public void  allDelIsSend() throws Exception{
		sql="update bbs.message set delS=1 where sender=? and delS=0 and issend=1";
		DBConnect dbc=new DBConnect();
		dbc.prepareStatement(sql);
		dbc.setBytes(1,(new String(userName.getBytes("ISO-8859-1"),"GBK")).getBytes());
		dbc.executeUpdate();
		dbc.close();
	}
	public void  delRecycle(HttpServletRequest request) throws Exception{
		int ID=0;
        String[] ids = request.getParameterValues("id");
        if(ids.length==0)
            throw new Exception("请指定相关参数。");
        for(int i=0;i<ids.length;i++)
        {
            ID = Integer.parseInt(ids[i]);

            DBConnect dbc = new DBConnect();
            sql = "delete from bbs.message where incept=? and delR=1 and id=" + ID;
            dbc.prepareStatement(sql);
            dbc.setBytes(1, (new String(userName.getBytes("ISO-8859-1"), "GBK")).getBytes());
            dbc.executeUpdate();
            sql = "update bbs.message set delS=2 where sender=? and delS=1 and id =" + ID;
            dbc.prepareStatement(sql);
            dbc.setBytes(1, (new String(userName.getBytes("ISO-8859-1"), "GBK")).getBytes());
            dbc.executeUpdate();
            dbc.close();
        }
	}
	public void  allDelRecycle() throws Exception{
		DBConnect dbc=new DBConnect();
		sql="delete from bbs.message where incept=? and delR=1";
		dbc.prepareStatement(sql);
		dbc.setBytes(1,(new String(userName.getBytes("ISO-8859-1"),"GBK")).getBytes());
		dbc.executeUpdate();
		sql="update bbs.message set delS=2 where sender=? and delS=1";
		dbc.prepareStatement(sql);
		dbc.setBytes(1,(new String(userName.getBytes("ISO-8859-1"),"GBK")).getBytes());
		dbc.executeUpdate();
		dbc.close();
	}
	public void  delete(HttpServletRequest request) throws Exception{
		int ID=0;
        String[] ids = request.getParameterValues("id");
        if(ids.length==0)
            throw new Exception("请指定相关参数。");
        for(int i=0;i<ids.length;i++)
        {
            ID = Integer.parseInt(ids[i]);

            DBConnect dbc = new DBConnect();

            sql = "update bbs.message set delR=1 where incept=? and id=" + ID;
            dbc.prepareStatement(sql);
            dbc.setBytes(1, (new String(userName.getBytes("ISO-8859-1"), "GBK")).getBytes());
            dbc.executeUpdate();
            sql = "update bbs.message set delS=1 where sender=? and id=" + ID;
            dbc.prepareStatement(sql);
            dbc.setBytes(1, (new String(userName.getBytes("ISO-8859-1"), "GBK")).getBytes());
            dbc.executeUpdate();
            dbc.close();
        }
	}





	///////////////////////////////////////////////////////////
	public void  saveSMS(HttpServletRequest request) throws Exception{

		String touser=ParamUtil.getString(request,"touser");
		if(touser==null||touser.trim().equals(""))
			throw new Exception("您忘记填写发送对象了吧。");

		String title=ParamUtil.getString(request,"title");
		if(title==null||title.trim().equals(""))
			throw new Exception("您还没有填写标题呀。");
		String message=ParamUtil.getString(request,"message");
		if(message==null||message.trim().equals(""))
			throw new Exception("内容是必须要填写的噢。");

		String [] users=touser.split(",");
		DBConnect dbc=new DBConnect();
		ResultSet rs;
		for(int i=0;i<users.length;i++){
			if (i>4){
				dbc.close();
				throw new Exception("最多只能发送给5个用户,您的名单5位以后的请重新发送");
			}

			sql="select username from bbs.myuser where username=?";
			dbc.prepareStatement(sql);
			dbc.setBytes(1,(new String(users[i].getBytes("ISO-8859-1"),"GBK")).getBytes());
			rs=dbc.executeQuery();
			if(!rs.next()){
				dbc.close();
				throw new Exception("论坛没有这个用户,看看你的发送对象写对了嘛?");
			}

			String submit=new String(ParamUtil.getString(request,"Submit","").getBytes("ISO-8859-1"),"GBK");;

			if(submit.equals("发送")){
				sql="insert into bbs.message (incept,sender,title,content,sendtime,flag,issend) values (?,?,?,?,getdate(),0,1)";
			}
			else{
				sql="insert into bbs.message (incept,sender,title,content,sendtime,flag,issend) values (?,?,?,?,getdate(),0,0)";
			}
			dbc.prepareStatement(sql);
			dbc.setBytes(1,(new String(users[i].getBytes("ISO-8859-1"),"GBK")).getBytes());
			dbc.setBytes(2,(new String(userName.getBytes("ISO-8859-1"),"GBK")).getBytes());
			dbc.setBytes(3,(new String(title.getBytes("ISO-8859-1"),"GBK")).getBytes());
			dbc.setBytes(4,(new String(message.getBytes("ISO-8859-1"),"GBK")).getBytes());
			dbc.executeUpdate();

		}
		dbc.close();

	}


	public void saveEdit(HttpServletRequest request) throws Exception{
		int ID=0;
		try{
			ID=ParamUtil.getInt(request,"id");
		}
		catch(Exception e){
			throw new Exception("请指定相关参数。");
		}
		String touser=ParamUtil.getString(request,"touser");
		if(touser==null||touser.trim().equals(""))
			throw new Exception("您忘记填写发送对象了吧。");

		String title=ParamUtil.getString(request,"title");
		if(title==null||title.trim().equals(""))
			throw new Exception("您还没有填写标题呀。");
		String message=ParamUtil.getString(request,"message");
		if(message==null||message.trim().equals(""))
			throw new Exception("内容是必须要填写的噢。");

		String incept=touser;

		DBConnect dbc=new DBConnect();
		sql="select username from bbs.myuser where username=?";
		dbc.prepareStatement(sql);
		dbc.setBytes(1,(new String(incept.getBytes("ISO-8859-1"),"GBK")).getBytes());

		ResultSet rs=dbc.executeQuery();
		if(!rs.next()){
				dbc.close();
				throw new Exception("论坛没有这个用户,看看你的发送对象写对了嘛?");
		}
		rs.close();
		String submit=new String(ParamUtil.getString(request,"Submit","").getBytes("ISO-8859-1"),"GBK");

		if(submit.equals("发送")){
			sql="update bbs.message set incept=?,sender=?,title=?,content=?,sendtime=getdate(),flag=0,issend=1 where id="+ID;
		}
		else{
			sql="update bbs.message set incept=?,sender=?,title=?,content=?,sendtime=getdate(),flag=0,issend=0 where id="+ID;
		}
		dbc.prepareStatement(sql);
		dbc.setBytes(1,(new String(incept.getBytes("ISO-8859-1"),"GBK")).getBytes());
		dbc.setBytes(2,(new String(userName.getBytes("ISO-8859-1"),"GBK")).getBytes());
		dbc.setBytes(3,(new String(title.getBytes("ISO-8859-1"),"GBK")).getBytes());
		dbc.setBytes(4,(new String(message.getBytes("ISO-8859-1"),"GBK")).getBytes());
		dbc.executeUpdate();
		dbc.close();
	}
}

⌨️ 快捷键说明

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