?? templatemanage.java
字號:
package com.v246;
public class TemplateManage
{
/*
*本類是自定義EL,用于templateManage.jsp
**/
public static String getManage(String id)throws Exception
{
String withTypeName=null;
String url=null;
StringBuffer re=new StringBuffer(3000);
java.sql.Connection conn=null;
java.sql.Statement stm=null;
java.sql.ResultSet rs=null;
Connections connTmp=new Connections();
try
{
conn=connTmp.getConnection();
stm=conn.createStatement();
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
url=Aqu.getUrl(connTmp.getConnection(),"config","url");
if(id.equals("0"))//如果id等于0那么就代表要輸出所有欄目
{
rs=stm.executeQuery("select * from template");
while(rs.next())
{
if(rs.getBoolean("IsDefault"))
{
re.append("<TR class=tdbg onmouseover=\"this.style.backgroundColor='#BFDFFF'\"onmouseout="this.style.backgroundColor=''\"> <TD align=middle width=30>"+rs.getInt("TemplateId")+"</TD><TD align=middle width=150>"+getWithTypeName(rs.getInt("WithType"))+"</TD><TD align=middle><A href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=modify&pid=0'>"+rs.getString("TemplateName")+"</A></TD><TD align=middle width=100><B>√</B></TD><TD align=middle width=200><FONT color=#39867b>設為默認 </FONT><A href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=modify&pid=0'>修改模板</A> <FONT color=#39867b>刪除模板</FONT> </TD></TR>");
}
else
{
re.append("<TR class=tdbg onmouseover=\"this.style.backgroundColor='#BFDFFF'\" onmouseout="this.style.backgroundColor=''\"> <TD align=middle width=30>"+rs.getInt("TemplateId")+"</TD> <TD align=middle width=150>"+getWithTypeName(rs.getInt("WithType"))+"</TD> <TD align=middle><A href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=modify&pid=0'>"+rs.getString("TemplateName")+"</A></TD> <TD align=middle width=100><B>×</B></TD><TD align=middle width=200><A href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=set&pid=0'>設為默認</A> <A href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=modify&pid=0'>修改模板</A> <A onclick=\"return confirm('確定要刪除此版面設計模板嗎?刪除此版面設計模板后原使用此版面設計模板的文章將改為使用系統默認版面設計模板。');\" href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=del&pid=0'>刪除模板</A> </TD> </TR>");
}
}
}
else
{
rs=stm.executeQuery("select * from template where WithType="+id);
while(rs.next())
{
if(rs.getBoolean("IsDefault"))
{
re.append("<TR class=tdbg onmouseover=\"this.style.backgroundColor='#BFDFFF'\"onmouseout="this.style.backgroundColor=''\"> <TD align=middle width=30>"+rs.getInt("TemplateId")+"</TD><TD align=middle width=150>"+getWithTypeName(rs.getInt("WithType"))+"</TD><TD align=middle><A href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=modify'>"+rs.getString("TemplateName")+"</A></TD><TD align=middle width=100><B>√</B></TD><TD align=middle width=200><FONT color=#39867b>設為默認 </FONT><A href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=modify&pid="+rs.getInt("WithType")+"'>修改模板</A> <FONT color=#39867b>刪除模板</FONT> </TD></TR>");
}
else
{
re.append("<TR class=tdbg onmouseover=\"this.style.backgroundColor='#BFDFFF'\" onmouseout="this.style.backgroundColor=''\"> <TD align=middle width=30>"+rs.getInt("TemplateId")+"</TD> <TD align=middle width=150>"+getWithTypeName(rs.getInt("WithType"))+"</TD> <TD align=middle><A href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=modify&pid="+rs.getInt("WithType")+"'>"+rs.getString("TemplateName")+"</A></TD> <TD align=middle width=100><B>×</B></TD><TD align=middle width=200><A href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=set&pid="+rs.getInt("WithType")+"'>設為默認</A> <A href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=modify&pid="+rs.getInt("WithType")+"'>修改模板</A> <A onclick=\"return confirm('確定要刪除此版面設計模板嗎?刪除此版面設計模板后原使用此版面設計模板的文章將改為使用系統默認版面設計模板。');\" href='"+url+"/admin/MMDTemplate.jsp?id="+rs.getInt("TemplateId")+"&action=del&pid="+rs.getInt("WithType")+"'>刪除模板</A> </TD> </TR>");
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(rs!=null) rs.close();
if(stm!=null) stm.close();
if(conn!=null) conn.close();
}
return re.toString();
}
private static String getWithTypeName(int id)throws Exception
{
String re=null;
java.sql.Connection conn=null;
java.sql.Statement stm=null;
java.sql.ResultSet rs=null;
Connections connTmp=new Connections();
try
{
conn=connTmp.getConnection();
stm=conn.createStatement();
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
rs=stm.executeQuery("select * from templateType where id="+id);
if(rs.next())
{
re=rs.getString("Type");
}
else
{
re="數據錯誤";
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(rs!=null)rs.close();
if(stm!=null)stm.close();
if(conn!=null)conn.close();
}
return re;
}
public static String getAllTemplateType() throws Exception
{
String url=null;
StringBuffer re=new StringBuffer(500);
java.sql.Connection conn=null;
java.sql.Statement stm=null;
java.sql.ResultSet rs=null;
Connections connTmp=new Connections();
try
{
conn=connTmp.getConnection();
stm=conn.createStatement();
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
url=Aqu.getUrl(connTmp.getConnection(),"config","url");
rs=stm.executeQuery("select * from templatetype");
re.append(" | ");
while(rs.next())
{
re.append("<a href='"+url+"/admin/templateManage.jsp?id="+rs.getInt("Id")+"'>"+rs.getString("Type")+"</A> | ");
}
re.append("<a href='"+url+"/admin/templateManage.jsp?id=0'>所有模板</A> | ");
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(rs!=null) rs.close();
if(stm!=null) stm.close();
if(conn!=null) conn.close();
}
return re.toString();
}
public static void main(String[] args)
{
try
{
System.out.println(getManage("0"));
}
catch(Exception e)
{
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -