news_manager.java

来自「本系统实现的是一个信息发布平台」· Java 代码 · 共 93 行

JAVA
93
字号
/*
 * 创建日期 2005-8-24
 *
 * TODO 要更改此生成的文件的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
package cn.edu.bit.business;


import java.util.GregorianCalendar;

import cn.edu.bit.DBQuery.DataProcess;

/**
 * @author ligang
 *
 * TODO 要更改此生成的类型注释的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
public class News_Manager {

	public static void Add_News(String title,String content)
	{
		GregorianCalendar gc = new GregorianCalendar();
		
		
		try
		{
			title=new String(title.getBytes("ISO8859_1"));
		
			content=new String(content.getBytes("ISO8859_1"));
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
		String query = "insert into news(title,content,datetime)values('"+title+
						"','"+content+"','"+gc.getTime().toLocaleString()+"')";
		
		try
		{
			DataProcess.ExeQuery(query);
		}
		catch(Exception e){
			e.printStackTrace();
		}
		
	}
	
	public static void Edit_News(String title,String content,int id)
	{
		GregorianCalendar gc = new GregorianCalendar();
		
		
		try
		{
			title=new String(title.getBytes("ISO8859_1"));
		
			content=new String(content.getBytes("ISO8859_1"));
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
		String query = "update news set title='"+title+"',content='"+content+
						"',datetime='"+gc.getTime().toLocaleString()+"' where id="+id;
		
		
		try
		{
			DataProcess.ExeQuery(query);
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public static void Delete_News(int id)
	{
		String deleteStr = "delete from news where id="+id;
		
		try
		{
			DataProcess.ExeQuery(deleteStr);
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

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