topicbean.java
来自「这是一个内容管理系统(CMS)以MVC方式写出,没有使用框架」· Java 代码 · 共 73 行
JAVA
73 行
package Bean;
import java.util.Hashtable;
public class TopicBean {
private int id;
private String topicname="";//专题名称
private String introduce="";//专题简介
//DBControl DC=new DBControl();
private Hashtable<String, String> errors=new Hashtable<String, String>();
public String getIntroduce() {
return introduce;
}
public void setIntroduce(String introduce) {
this.introduce = introduce;
}
public String getTopicname() {
return topicname;
}
public void setTopicname(String topicname) {
this.topicname = topicname;
}
public boolean validata(String action,int Id){//判断数据的正确性
boolean allok=true;
if(topicname.trim().equals("")){
errors.put("topicname","专题名不能为空!");
allok=false;
}
db.DB dt= new db.DB();
try {
if(action.trim().equals("edit")){
if(dt.IsSameRecordButitSelf("topic", "TopicName", topicname.trim(),Id)){
errors.put("topicname","专题名称相同!");
allok=false;
}
}else{
if(dt.IsSameRecord("topic", "TopicName", topicname.trim())){
errors.put("topicname","专题名称相同!");
allok=false;
}
}
}catch(Exception ex){
System.out.print(ex);
}finally{
dt.close();//关闭连接
}
return allok;
}
public void setErrorMsg(String err,String errMsg){
if((err!=null)&& (errMsg!=null)){
errors.put(err, errMsg);
}
}
public String getErrorMsg(String err){
String err_msg=(String)errors.get(err);
return (err_msg==null)?"":err_msg;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
//ResultSet rs=null;
db.DB dt=new db.DB();
this.topicname=dt.returnString("select Id,TopicName from topic where Id="+id);
dt.close();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?