?? customlable_bean.java
字號:
package com.v246;
public class CustomLable_bean
{
protected StringBuffer update=new StringBuffer(100);
protected String sql;//根據用戶所輸入的信息完成最基本的SQL語句
protected String withClass;//所屬欄目
protected StringBuffer insert=new StringBuffer(50);//用于執行執行的SQL語句
protected Connections connTmp=new Connections();
protected CustomLable_form custom;
protected java.sql.Connection conn=null;
protected java.sql.Statement stm=null;
protected java.sql.ResultSet rs=null;
protected String modify;//看看是修改標簽還是增加標簽
protected String id;//要修改標簽的id
protected String re="custom";//無用
protected String lableName;//標簽名稱
protected String remark;//標簽描述
protected String hot;//是否熱門
protected String news;//是否最新
protected String barNumber;//顯示多少行
protected String letterNumber;//每行顯示多少字
protected String isUpdate;//是否顯示時間
protected String isClick;//是否顯示點擊數
protected String staticed;//靜態顯示
protected String dynamic;//動態顯示
protected void initValue()
{
modify=custom.getModify();
id=custom.getId();
withClass=custom.getWithClass();
lableName=Aqu.getGB(custom.getLableName());
remark=custom.getRemark();
hot=Aqu.getRadioState(custom.getHotOrNews(),"hot");//判斷選中的按鈕,如果被選中,則返回1否則返回0
news=Aqu.getRadioState(custom.getHotOrNews(),"news");
barNumber=custom.getBarNumber();
letterNumber=custom.getLetterNumber();
isUpdate=Aqu.getCheckState(custom.getIsUpdate());
isClick=Aqu.getCheckState(custom.getIsClick());
staticed=Aqu.getRadioState(custom.getStaticOrDynamic(),"staticed");
dynamic=Aqu.getRadioState(custom.getStaticOrDynamic(),"dynamic");
if(hot.equals("1"))//如果顯示的是熱門文章
{
if(withClass.equals("0"))//如果不限定欄目
{
sql="select * from article order by Hits desc";//初始化SQL語句
}
else//否則如果不是所有欄目(顯示指定欄目)
{
sql="select * from article where classID="+withClass+" order by Hits desc";
}
}
else
{
if(withClass.equals("0"))
{
sql="select * from article order by UpdateTime desc";
}
else
{
sql="select * from article where classID="+withClass+" order by UpdateTime desc";
}
}
}
public String addCustomLable(CustomLable_form custom) throws Exception
{
this.custom=custom;//由Action處得到的數據對像存儲著用戶輸入的信息
initValue();//初始化信息
insert.append("insert into customLable(Sql,withClass,lableName,IsHot,IsNew,barNumber,letterNumber,isUpdateTime,IsClickNumber,staticed,dynamic,remark) values("+Aqu.addIC(sql)+","+withClass+","+"'{$"+lableName+"$}'"+","+hot+","+news+","+barNumber+","+letterNumber+","+isUpdate+","+isClick+","+staticed+","+dynamic+","+Aqu.addIC(remark)+")");
update.append("update customLable set Sql="+Aqu.addIC(sql)+",withClass="+withClass+",LableName='{$"+lableName+"$}',IsHot="+hot+",IsNew="+news+",BarNumber="+barNumber+",LetterNumber="+letterNumber+",isUpdateTime="+isUpdate+",IsClickNumber="+isClick+",staticed="+staticed+",dynamic="+dynamic+",remark="+Aqu.addIC(remark)+" where id="+id);
try
{
conn=connTmp.getConnection();
stm=conn.createStatement();
}
catch(Exception e)
{
throw new Exception("Error in CustomLable_bean "+e.getMessage());
}
try
{
if(modify!=null&&modify.equals("modify"))
{
stm.executeUpdate(update.toString());
re="ok";
}
else
{
rs=stm.executeQuery("select * from customlable where LableName='{$"+lableName+"$}'");
if(rs.next())
{
re="error";//如果數據庫中以經存在該標簽則返回錯誤
}
else//否則返回ok
{
stm.executeUpdate(insert.toString());
re="ok";
}
}
}
catch(java.sql.SQLException e)
{
throw new java.sql.SQLException("Errore in CustomLable_bean NO.8"+e.getMessage());
}
finally
{
if(rs!=null)rs.close();
if(stm!=null)stm.close();
if(conn!=null)conn.close();
}
return re;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -