managermember.java
来自「对学习 VC有所帮助的几个例子」· Java 代码 · 共 590 行 · 第 1/2 页
JAVA
590 行
dbconn.ExeUpdate(s2);
dbconn.CloseConn();
httpsession.putValue("LoginUser", s4);
return "注册成功!";
}
}
public boolean adminLogin(HttpServletRequest httpservletrequest, String s)
throws Exception
{
boolean flag = false;
HttpSession httpsession = httpservletrequest.getSession(true);
String s2 = handle.getString(httpservletrequest, "name");
String s3 = handle.getString(httpservletrequest, "pwd");
s3 = md5.getMD5ofStr(s3.trim());
try
{
String s1 = "SELECT * FROM " + s + " WHERE name='" + s2 + "' AND pwd='" + s3 + "'";
ResultSet resultset = dbconn.ExeQuery(s1);
if(resultset.next())
{
administratorBean administratorbean = new administratorBean();
administratorbean.setId(resultset.getInt("aid"));
administratorbean.setName(resultset.getString("name"));
administratorbean.setPwd(resultset.getString("pwd"));
administratorbean.setLevel(resultset.getInt("level"));
httpsession.putValue("administratorBean", administratorbean);
flag = true;
}
dbconn.CloseConn();
}
catch(SQLException sqlexception)
{
System.err.println("aq.executeQuery:" + sqlexception.getMessage());
}
return flag;
}
public void createAdmin(HttpServletRequest httpservletrequest, String s)
{
String s2 = handle.getString(httpservletrequest, "name");
String s3 = handle.getString(httpservletrequest, "pwd");
s3 = md5.getMD5ofStr(s3.trim());
int i = handle.getInt(httpservletrequest, "level");
String s1 = "INSERT INTO " + s + "(name,pwd,level) VALUES('" + s2 + "','" + s3 + "'," + i + ")";
dbconn.ExeUpdate(s1);
}
public void delAdmin(HttpServletRequest httpservletrequest, String s)
throws Exception
{
int i = handle.getInt(httpservletrequest, "aid");
String s1 = "DELETE FROM " + s + " WHERE aid=" + i;
dbconn.ExeUpdate(s1);
dbconn.CloseConn();
}
public Vector getAdministratorBeanVector(String s)
throws Exception
{
Vector vector = new Vector();
try
{
String s1 = "SELECT * FROM " + s + " ORDER BY aid DESC";
administratorBean administratorbean;
for(ResultSet resultset = dbconn.ExeQuery(s1); resultset.next(); vector.addElement(administratorbean))
{
administratorbean = new administratorBean();
administratorbean.setId(resultset.getInt("aid"));
administratorbean.setName(resultset.getString("name"));
administratorbean.setLevel(resultset.getInt("level"));
}
dbconn.CloseConn();
}
catch(SQLException sqlexception)
{
System.err.println("aq.executeQuery:" + sqlexception.getMessage());
}
return vector;
}
public Hashtable getModifyInfo(HttpServletRequest httpservletrequest, String s)
throws Exception
{
String s1 = "";
String s3 = "";
String s4 = "";
String s5 = "";
String s6 = "";
int i = 0;
int j = 0;
Hashtable hashtable = new Hashtable();
HttpSession httpsession = httpservletrequest.getSession(true);
String s7 = (String)httpsession.getValue("LoginUser");
try
{
String s2 = "SELECT * FROM " + s + " WHERE account='" + s7 + "'";
ResultSet resultset = dbconn.ExeQuery(s2);
if(resultset.next())
{
s3 = resultset.getString("name");
s4 = resultset.getString("tel");
s5 = resultset.getString("address");
s6 = resultset.getString("email");
i = resultset.getInt("sex");
j = resultset.getInt("age");
}
dbconn.CloseConn();
}
catch(SQLException sqlexception)
{
System.err.println("aq.executeQuery:" + sqlexception.getMessage());
}
hashtable.put("name", s3);
hashtable.put("tel", s4);
hashtable.put("address", s5);
hashtable.put("email", s6);
hashtable.put("sex", new Integer(i));
hashtable.put("age", new Integer(j));
return hashtable;
}
public void gotoLogin(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws Exception
{
HttpSession httpsession = httpservletrequest.getSession(true);
administratorBean administratorbean = (administratorBean)httpsession.getValue("administratorBean");
if(httpsession.getValue("administratorBean") == null)
httpservletresponse.sendRedirect("member_sys/adminlogin.jsp");
else
if(administratorbean.getLevel() == 0)
httpservletresponse.sendRedirect("purchase_sys/onlyorder.jsp");
}
public void gotoLogin2(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws Exception
{
HttpSession httpsession = httpservletrequest.getSession(true);
if(httpsession.getValue("administratorBean") == null)
httpservletresponse.sendRedirect("../index.jsp");
}
public void loginOut(HttpServletRequest httpservletrequest)
{
HttpSession httpsession = httpservletrequest.getSession(true);
httpsession.removeValue("administratorBean");
}
public void modifyAdmin(HttpServletRequest httpservletrequest, String s)
throws Exception
{
int i = handle.getInt(httpservletrequest, "aid");
int j = handle.getInt(httpservletrequest, "level");
String s1 = handle.getString(httpservletrequest, "name");
String s2 = handle.getString(httpservletrequest, "pwd");
s2 = md5.getMD5ofStr(s2.trim());
String s4 = "";
if(!s1.equals(""))
s4 = s4 + "name='" + s1 + "',";
if(!s2.equals(""))
s4 = s4 + "pwd='" + s2 + "',";
s4 = s4 + "level=" + j;
String s3 = "UPDATE " + s + " SET " + s4 + " WHERE aid=" + i;
dbconn.ExeUpdate(s3);
dbconn.CloseConn();
}
public void modifyInfo(HttpServletRequest httpservletrequest, String s)
throws Exception
{
String s1 = "";
HttpSession httpsession = httpservletrequest.getSession(true);
String s2 = (String)httpsession.getValue("LoginUser");
String s3 = handle.getString(httpservletrequest, "pwd");
String s4 = handle.getString(httpservletrequest, "name");
s4 = handle.GBK2ISO(s4);
String s5 = handle.getString(httpservletrequest, "tel");
String s6 = handle.getString(httpservletrequest, "address");
s6 = handle.GBK2ISO(s6);
String s7 = handle.getString(httpservletrequest, "email");
int i = handle.getInt(httpservletrequest, "sex");
int j = handle.getInt(httpservletrequest, "age");
if(s3.equals(""))
s1 = "UPDATE " + s + " SET name='" + s4 + "',tel='" + s5 + "',address='" + s6 + "',email='" + s7 + "',sex=" + i + ",age=" + j + " WHERE account='" + s2 + "'";
else
s1 = "UPDATE " + s + " SET name='" + s4 + "',tel='" + s5 + "',address='" + s6 + "',email='" + s7 + "',sex=" + i + ",age=" + j + ",pwd='" + md5.getMD5ofStr(s3) + "' WHERE account='" + s2 + "'";
dbconn.ExeUpdate(s1);
dbconn.CloseConn();
}
public String search_turn(Hashtable hashtable, String s, String s1, String s2)
throws Exception
{
String s3 = "";
int k = Integer.parseInt(String.valueOf(hashtable.get("nextpage")));
int l = Integer.parseInt(String.valueOf(hashtable.get("prevpage")));
int i1 = Integer.parseInt(String.valueOf(hashtable.get("pagesize")));
int j1 = Integer.parseInt(String.valueOf(hashtable.get("pagecount")));
int k1 = Integer.parseInt(String.valueOf(hashtable.get("pagecount2")));
int l1 = Integer.parseInt(String.valueOf(hashtable.get("page1")));
int i2 = Integer.parseInt(String.valueOf(hashtable.get("page2")));
s1 = handle.ISO2GBK(s1);
s3 = s3 + "<form name=form1 method=post action=" + s + ">";
s3 = s3 + "<table width=100% border=0 cellspacing=0 cellpadding=0 align=center>";
s3 = s3 + " <tr> ";
s3 = s3 + " <td bgcolor=999999> ";
s3 = s3 + " <table width=100% border=0 cellspacing=1 cellpadding=3>";
s3 = s3 + " <tr bgcolor=f1f1f1>";
s3 = s3 + "\t <td align=center valign=middle width=50%>关键词: ";
s3 = s3 + " <input type=text name=keywords value=" + s1 + ">";
s3 = s3 + " ";
s3 = s3 + "<select name=type>";
s3 = s3 + " <option selected>选择类别</option>";
s3 = s3 + " <option value=name>帐 号</option>";
s3 = s3 + " <option value=address>地 址</option>";
s3 = s3 + "</select>";
s3 = s3 + " <input type=submit name=Submit value=搜索>";
s3 = s3 + " </td>";
s3 = s3 + "\t <td align=center valign=middle width=50%>";
s3 = s3 + " <table><tr><td align=center valign=middle width=30%>";
s3 = s3 + " <SELECT onchange=\"var jmpURL1=this.options[this.selectedIndex].value; if(jmpURL1!='') {self.location=jmpURL1;} else {this.selectedIndex=0;}\" size=1 name=select>";
s3 = s3 + " <option value=''>选择翻页</option>";
for(int i = 0; i < j1; i++)
{
int j = i + 1;
s3 = s3 + " <option value=" + s + "?CurrentPage=" + i + "&keywords=" + s1 + "&type=" + s2 + ">第 " + j + " 页</option>";
}
s3 = s3 + " </select>";
s3 = s3 + " </td>";
s3 = s3 + " <td align=center valign=middle width=20%>";
s3 = s3 + " 当前页:" + i2 + "/" + j1;
s3 = s3 + " </td>";
s3 = s3 + " <td align=center valign=middle width=40% style='font-family:Webdings'>";
if(j1 != 0)
s3 = s3 + "<a href=" + s + "?CurrentPage=0&keywords=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">7</a> ";
else
s3 = s3 + "7 ";
if(l1 != 0)
s3 = s3 + "<a href=" + s + "?CurrentPage=" + l + "&keywords=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">3</a>";
else
s3 = s3 + "3";
if(l1 != k1 && j1 != 0)
s3 = s3 + " <a href=" + s + "?CurrentPage=" + k + "&keywords=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">4</a> ";
else
s3 = s3 + " 4 ";
int j2 = j1 - 1;
if(j1 != 0)
s3 = s3 + "<a href=" + s + "?CurrentPage=" + j2 + "&keywords=" + s1 + "&type=" + s2 + " onMouseOver=\"this.style.color='red'\" onMouseOut=\"this.style.color='black'\">8</a>";
else
s3 = s3 + "8";
s3 = s3 + "</td></tr></table>";
s3 = s3 + "\t </td>";
s3 = s3 + " </tr>";
s3 = s3 + " </table>";
s3 = s3 + " </td>";
s3 = s3 + " </tr>";
s3 = s3 + "</table>";
return s3;
}
public Hashtable turn_page(String s, int i, int j)
{
int i1 = 0;
Hashtable hashtable = new Hashtable();
if(!s.equals(""))
i1 = Integer.parseInt(s);
int k = j / i;
if(i * k < j)
k++;
if(Integer.parseInt(s) > k)
i1 = k - 1;
else
if(Integer.parseInt(s) < 0)
i1 = 0;
int l = k - 1;
int j1 = i1 + 1;
int k1 = i1 * i;
int l1 = k1 + i;
int i2 = i1 + 1;
int j2 = i1 - 1;
hashtable.put("pt_st", new Integer(k1));
hashtable.put("pt_en", new Integer(l1));
hashtable.put("nextpage", new Integer(i2));
hashtable.put("prevpage", new Integer(j2));
hashtable.put("pagesize", new Integer(i));
hashtable.put("pagecount", new Integer(k));
hashtable.put("pagecount2", new Integer(l));
hashtable.put("page1", new Integer(i1));
hashtable.put("page2", new Integer(j1));
return hashtable;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?