客户关系管理系统
管理信息系统的开发方法有原型法和面向对象的开发方法等:
原型法的开发思路是首先根据用户的要求,由用户和开发者共同确定系统的基本要求和主要功能,利用系统快速生成工具,建立一个系统模型,再在此基础上与用户交流,将模型不断补充、修改、完善,如此反复,最终直至用户和开发者都比较满意为止,从而形成一个相对稳定、较为理想的管理信息系统。
面向对象的开发方法于20世纪80年代开始兴起的,是一种基于问题对象的自底向上的一种系统开发方法,这种方法的特点是以对象为基础,对象是分析问题和解决问题的核心。



(一)、用户登陆模块
当用户名或者密码任何一个出错系统将会给出信息提示,系统将给出错误信息提示并自动退出系统登陆。
基本代码:
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
HttpSession session = request.getSession();;
String type = request.getParameter("type");
UserDao userDao = new UserDao();
User user = new User();
String message="";
if(type.equals("login")){
String uname = request.getParameter("uname");
String upass = request.getParameter("upass");
user = userDao.getUser(uname);
if(user!=null&&user.getUpass().trim().equals(upass)){
session.setAttribute("user", user);
RequestDispatcher rd=request.getRequestDispatcher("index.jsp");
rd.forward(request,response);
}else{
message="用户名或密码不正确!";
request.setAttribute("message", message);
RequestDispatcher rd=request.getRequestDispatcher("login.jsp");
rd.forward(request,response);
} }
if(type.equals("tzupdatePwd")){
request.setAttribute("mainPage",getInitParameter("tzupdatePwd"));
String forward=this.getServletContext().getInitParameter("indexTemp");
RequestDispatcher rd=request.getRequestDispatcher(forward);
rd.forward(request, response);
}
(二)、查找客户模块
用户可以按照客户姓名、性别或是客户级别可以对其进行客户信息的搜索查看。
基本编码:
if(type.equals("selectPerson")){
String pid =request.getParameter("pid");
if(pid==null || pid.trim()==""){
List<Person> listAll = personDao.getPerson();
request.setAttribute("listPerson", listAll);
request.setAttribute("mainPage",getInitParameter("selectPerson"));
String forward=this.getServletContext().getInitParameter("indexTemp");
RequestDispatcher rd=request.getRequestDispatcher(forward);
rd.forward(request, response);
}else{
person = personDao.getPersonById(Integer.parseInt(pid));
if(person==null){
message="该客户ID不存在!";
request.setAttribute("message", message);
request.setAttribute("mainPage",getInitParameter("select"));
String forward=this.getServletContext().getInitParameter("indexTemp");
RequestDispatcher rd=request.getRequestDispatcher(forward);
rd.forward(request, response);
}else{
List<Person> listP = new ArrayList<Person>();
listP.add(person);
request.setAttribute("listPerson", listP);
request.setAttribute("mainPage",getInitParameter("selectPerson"));
String forward=this.getServletContext().getInitParameter("indexTemp");
RequestDispatcher rd=request.getRequestDispatcher(forward);
rd.forward(request, response);
}
}
(三)、修改密码模块
该模块对系统合法用户的密码进行修改。在这里需要输入原始密码、新密码和确认密码。
基本编码:
if(type.equals("updatePwd")){
User user1 = new User();
String upass = request.getParameter("newpwd1");
int uid = Integer.parseInt(request.getParameter("uid"));
user1 = userDao.getUserById(uid);
user1.setUpass(upass);
int result = userDao.updatePwd(user1);
if(result>0){
session.setAttribute("user", user1);
message="密码修改成功!";
request.setAttribute("message", message);
request.setAttribute("mainPage",getInitParameter("updatePwd"));
String forward=this.getServletContext().getInitParameter("indexTemp");
RequestDispatcher rd=request.getRequestDispatcher(forward);
rd.forward(request, response);
}
}
(四)、添加客户信息管理模块
用户输入客户的姓名、性别、年龄、电话、单位进行客户信息的添加。
基本编码:
if(type.equals("addPerson")){
String pname = request.getParameter("pname");
String psex = request.getParameter("psex");
int page = Integer.parseInt(request.getParameter("page"));
String pphone = request.getParameter("pphone");
String paddress = request.getParameter("paddress");
person.setPname(pname);
person.setPage(page);
person.setPsex(psex);
person.setPphone(pphone);
person.setPaddress(paddress);
int result = personDao.addPerson(person);
if(result>0){
message="添加成功!";
request.setAttribute("message", message);
request.setAttribute("mainPage",getInitParameter("add"));
String forward=this.getServletContext().getInitParameter("indexTemp");
RequestDispatcher rd=request.getRequestDispatcher(forward);
rd.forward(request, response);
}
}
(五)、修改客户信息管理模块
用户输入相关客户信息后查找到客户信息,可以对其修改。
代码如下:
if(type.equals("updatePerson")){
int pid = Integer.parseInt(request.getParameter("pid"));
person = personDao.getPersonById(pid);
if(person==null){
message="该客户ID不存在!";
request.setAttribute("message", message);
request.setAttribute("mainPage",getInitParameter("update"));
String forward=this.getServletContext().getInitParameter("indexTemp");
RequestDispatcher rd=request.getRequestDispatcher(forward);
rd.forward(request, response);
}else{
request.setAttribute("person", person);
request.setAttribute("mainPage",getInitParameter("updatePerson"));
String forward=this.getServletContext().getInitParameter("indexTemp");
RequestDispatcher rd=request.getRequestDispatcher(forward);
rd.forward(request, response);
}
}
(六)、查看客户列表模块
在此用户可以查看到所有客户的信息。
代码如下:
if(type.equals("select")){
request.setAttribute("mainPage",getInitParameter("select"));
String forward=this.getServletContext().getInitParameter("indexTemp");
RequestDispatcher rd=request.getRequestDispatcher(forward);
rd.forward(request, response);
}//
(七)、添加用户模块
在线添加新的用户账号和密码。
代码如下:
1.public String addKeHu(){System.out.println("name"+kname);
if(kname.equals("")||kage.equals("")||kphone.equals("")||kjob.equals("")||kzhiwei.equals("")){
String message ="请填写完整在提交!";
Map request=(Map)ActionContext.getContext().get("request");
request.put("message",message);
return "addno";
}else{
Ke ke = new Ke();
ke.setKname(kname);
ke.setKsex(ksex);
ke.setKage(Integer.parseInt(kage));
ke.setKjibie(kjibie);
ke.setKjob(kjob);
ke.setKphone(kphone);
ke.setKzhiwei(kzhiwei);
int count = keService.addKe(ke);
if(count>0){
String message ="添加成功!";
Map request=(Map)ActionContext.getContext().get("request");
request.put("message",message);
return "addok";
}else{
String message ="添加失败!";
Map request=(Map)ActionContext.getContext().get("request");
request.put("message",message);
return "addok";
}
}
}
JSP:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>添加客户 信息</title><sx:head />
</head>
<body>
<div>
<TABLE width="796" height="20" bgcolor="#ECF1FF">
<TR>
<TD>当前位置:添加客户信息</TD>
<TD width="20"></TD>
</TR>
</TABLE>
<br>
<br>
<form id="form1" action="ke!addKeHu.action" method="post" >
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="D0E7FF" width="796"
height="2">
<tr>
<td colspan="2" align="center"><font size="6" face="黑体" >添加客户信息</font></td>
</tr>
<tr>
<td colspan="2" align="center" height="40"><label id="ts1" style="color:red">
<sx:div id="divShow2" delay="0" updateFreq="0" >
</sx:div>
</label></td>
</tr>
<tr>
<td align="right" height="40">姓 名:</td>
<td align="left"><input type="text" id="kname" name="kname" size="16" maxLength="20"></td>
</tr>
<tr>
<td align="right" height="40">性 别:</td>
<td align="left">
<select id="ksex" name="ksex">
<option value="男" selected>男</option>
<option value="女">女</option>
</select>
</td>
</tr>
<tr>
<td align="right" height="40">年 龄:</td>
<td align="left"><input type="text" id="kage" name="kage" size="16" maxLength="16"></td>
</tr>
<tr>
<td align="right" height="40">电 话:</td>
<td align="left"><input type="text" id="kphone" name="kphone" size="16" maxLength="11"></td>
</tr>
<tr>
<td align="right" height="40">单 位:</td>
<td align="left"><input type="text" id="kjob" name="kjob" size="26" maxLength="20"></td>
</tr>
<tr>
<td align="right" height="40">职 位:</td>
<td align="left"><input type="text" name="kzhiwei" id="kzhiwei" size="26" maxLength="20"></td>
</tr>
<tr>
<td align="right" height="40">级 别:</td>
<td align="left">
<select name="kjibie" id="kjibie">
<option value="大客户">大客户</option>
<option value="小客户">小客户</option>
</select>
</td>
</tr>
<tr>
<td align="right">
</td>
<td align="left" height="40">
<sx:submit name="btnselect" id="btnselect" value=" 添加 " targets="divShow2"/>
<input type="reset" name="reset" value="清空">
</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
</table>
</form>
</div>
</body>
</html>
2.<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<sx:head />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户关系管理系统</title>
</head>
<style type="text/css">
a{ text-decoration:none; color:#000000;}
a:hover{ text-decoration:none; color:#FF6600;}
.ulnotab {
margin-top:0px;
margin-bottom:0px;
margin-left: 5px;
}
.ulnotab1 {
margin-top:5px;
margin-bottom:5px;
}
</style>
<body>
<%if(session.getAttribute("user")==null){response.sendRedirect("login.jsp");}%>
<center>
<table width="1024" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td height="136" colspan="2"><img src="images/top.jpg" width="1024" height="130" /></td>
</tr>
<tr valign="top">
<td width="238" height="452">
<table width="228" border="0" cellpadding="0" cellspacing="0" bgcolor="#EEEEEE" height="500">
<tr><td></td></tr>
<tr valign="top" align="center">
<td>
<table width="208" border="0" cellpadding="0" cellspacing="0" bgcolor="#D3DFE6">
<tr>
<td width="180" height="45" align="left"> 当前登录:<strong>${user.uname}</strong></td>
</tr>
<tr>
<td height="35"> </td>
</tr>
<tr>
<td align="left">
<ul class="ulnotab">
<li><sx:a href="shouye.jsp" targets="divShow1">公司简介</sx:a></li>
</ul>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="left">
<ul class="ulnotab">
<li>客户信息管理</li>
</ul>
<ul class="ulnotab1">
<li><sx:a href="selectKe.jsp" targets="divShow1">查询客户</sx:a></li>
<li><sx:a href="addKe.jsp" targets="divShow1">添加客户</sx:a></li>
</ul>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="left">
<ul class="ulnotab">
<li>用户管理</li>
</ul>
<ul class="ulnotab1">
<li><sx:a href="zhuceUser.jsp" targets="divShow1">用户添加</sx:a></li>
<li><sx:a href="updatePass.jsp" targets="divShow1">修改密码</sx:a></li>
</ul>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="left">
<ul class="ulnotab">
<li><a href="user!tuichu.action">退出</a></li>
</ul>
</td>
</tr>
<tr><td> </td></tr>
</table>
</td>
</tr>
</table></td>
<td width="786" align="left">
<sx:div id="divShow1" delay="0" updateFreq="0" >
</sx:div>
</td>
</tr>
<tr>
<td height="16" colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="2" align="center"><font size="2px"><strong>Copyright @2013 客户关系管理系统</strong></font></td>
</tr>
</table>
</center>
</body>
</html>
3.<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理员登录窗口</title>
</head>
<script type="text/javascript">
function check(){
var uname=document.getElementById("uname").value;
var upass=document.getElementById("upass").value;
if(uname==""||upass=="")
{
document.getElementById("ts1").innerHTML="请填写完整,再登录!";
return false;
}else{
document.getElementById("form1").submit();
return true;
}
}
</script>
<body bgcolor="#184caa">
<center>
<form id="form1" name="form1" method="post" action="user!getLogin.action">
<br/><br/><br/><br/><br/>
<table width="200" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3"><img src="images/topdl.jpg" width="572" height="60" /></td>
</tr>
<tr>
<td width="201"><img src="images/leftdl.jpg" width="200" height="200" /></td>
<td width="367" align="center"><table width="372" height="200" border="0" background="images/tt.jpg">
<tr>
<td colspan="2" height="35"><label id="ts1" style="color:red">${message }</label></td>
</tr>
<tr>
<td width="96" align="center"> 用户名:</td>
<td width="266" align="left"><input type="text" name="uname" id="uname" />
</td>
</tr>
<tr>
<td align="center"> 密 码:</td>
<td align="left"><input type="password" name="upass" id="upass" />
</td>
</tr>
<tr>
<td colspan="2"><input type="button" name="button" id="button" onclick="check()" value="登录系统" />
<input type="reset" name="button2" id="button2" value="清空" />
</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="3"><img src="images/enddl.jpg" width="572" height="39" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>
4.<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'message.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
${message }
</body>
</html>
5.<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<sx:head />
</head>
<body>
<TABLE width="796" height="20" bgcolor="#ECF1FF">
<TR>
<TD>当前位置:查询客户信息</TD>
<TD width="20"></TD>
</TR>
</TABLE>
<br>
<form id="form1" name="form1" method="post" action="ke!getKeHu.action">
<center>
<table width="750" border="0" bgcolor="#ECF1FF">
<tr>
<td width="201"> 姓名:
<input name="kname" type="text" id="kname" size="15" /></td>
<td width="164">性别:
<select name="ksex" id="ksex">
<option value="请选择">请选择</option>
<option value="男">男</option>
<option value="女">女</option>
</select></td>
<td width="192">客户级别:
<select name="kjibie" id="kjibie">
<option value="请选择">请选择</option>
<option value="大客户">大客户</option>
<option value="小客户">小客户</option>
</select></td>
<td width="125"><sx:submit name="btnselect" id="btnselect" value=" 查询 " targets="listDiv"/> </td>
</tr>
</table>
</center>
</form>
<sx:div id="listDiv" delay="0" updateFreq="0" >
</sx:div>
</body>
</html>
6.<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title> 修改管理员密码</title><sx:head />
</head>
<body>
<div>
<TABLE width="796" height="20" bgcolor="#ECF1FF">
<TR>
<TD>当前位置:修改管理员密码</TD>
<TD width="20"></TD>
</TR>
</TABLE>
<br>
<br>
<form id="form1" action="user!xiugai.action" method="post" >
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="D0E7FF" width="796"
height="2">
<tr>
<td colspan="2" align="center"><font size="6" face="黑体" >修改管理员密码</font></td>
</tr>
<tr>
<td colspan="2" align="center" height="40"><label id="ts1" style="color:red">
<sx:div id="divShow5" delay="0" updateFreq="0" >
</sx:div>
</label></td>
</tr>
<tr>
<td align="right" height="40">原密码:</td>
<td align="left"><input type="password" id="upass" name="upass" size="16" maxLength="20" ></td>
</tr>
<tr>
<td align="right" height="40">新密码:</td>
<td align="left"><input type="password" id="upass1" name="upass1" size="16" maxLength="16" ></td>
</tr>
<tr>
<td align="right">
</td>
<td align="left" height="40">
<sx:submit name="btnselect" id="btnselect" value=" 修改 " targets="divShow5"/>
<input type="reset" name="reset" value="清空">
</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
</table>
</form>
</div>
</body>
</html>
7.<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title> 用户信息添加</title><sx:head />
</head>
<body>
<div>
<TABLE width="796" height="20" bgcolor="#ECF1FF">
<TR>
<TD>当前位置:用户信息添加</TD>
<TD width="20"></TD>
</TR>
</TABLE>
<br>
<br>
<form id="form1" action="user!zhuce.action" method="post" >
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="D0E7FF" width="796"
height="2">
<tr>
<td colspan="2" align="center"><font size="6" face="黑体" >用户信息添加</font></td>
</tr>
<tr>
<td colspan="2" align="center" height="40"><label id="ts1" style="color:red">
<sx:div id="divShow4" delay="0" updateFreq="0" >
</sx:div>
</label></td>
</tr>
<tr>
<td align="right" height="40">用户名:</td>
<td align="left"><input type="text" id="uname" name="uname" size="16" maxLength="20" ></td>
</tr>
<tr>
<td align="right" height="40">密 码:</td>
<td align="left"><input type="password" id="upass" name="upass" size="16" maxLength="16" ></td>
</tr>
<tr>
<td align="right">
</td>
<td align="left" height="40">
<sx:submit name="btnselect" id="btnselect" value=" 注册 " targets="divShow4"/>
<input type="reset" name="reset" value="清空">
</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
</table>
</form>
</div>
</body>
</html>
浙公网安备 33010602011771号