java+mysql crm客户关系管理系统的设计与实现
在众多网站开发技术中,JSP支持现在绝大多数操作平台,它在代码执行效率、代码可移植性及组建的应用上均优越于其他动态网页技术。因此,本文研究了基于JSP技术的系统动态网站。根据JSP的原理按照网站时机原则以及步骤,对动态网站的定义了目标、分析了网站功能需求,进行了结构设计和艺术性设计;尤其是重点介绍了开发环境的建立、数据库的设计与实现以及系统详细设计;最后对系统进行了编码与测试。通过发布,系统能够正常运行。最后得出了动态网站的解决方案。
该产品是一款针对大中型企业对某些固定的客户进行集中管理所开发的软件,功能在于更好的使企业领导了解与各个客户之间的关系,亦使业务员更好的更快捷更方便的与客户沟通有利于为企业发掘潜在的商业利益,使企业的效益提高。
-
- 系统模块简介
- 前台显示系统
- 系统模块简介
前台显示系统包括客户信息,销售信息,产品信息。
(1)客户信息:根据客户的类型显示客户的信息。
(2)销售信息:显示销售的情况以及动态。包括商业活动中产生的一些机会。
(3)产品信息:显示各类产品以及相关信息。
(4)词典信息:显示此系统中用到的所有词典,通过权限认证的用户可以添加词典。
-
-
- 后台管理系统
-
后台管理系统是系统管理员对整个系统进行维护的平台。首先登录的同时,系统会根据权限管理来判断登陆者是否有权限对系统进行操作,根据帐号的不同级别来给帐号开放某些功能,登陆者只能对系统给定的开放的功能进行操作,否则没有权限,管理员登录后可以对客户信息,销售信息,产品信息,词典信息等模块进行增删改查看,另外还有一个角色信息,最高管理员可以设定角色并且可以给新设定的角色设定权限,界面如图所示:
2.数据库分析
2.1数据库分析
本系统采用Mysql数据库,Mysql是一种关系型数据库,在它上面可以执行几乎全部的关系型数据库标准语言SQL语言。Mysql具有良好的界面,用户可以通过菜单和对话框操作,不用编写任何命令便能有效地实现各种功能的操作,完成数据管理任务。用户可以非常方便的创建非常实用的数据库应用系统。
Mysql可以接受多种格式的数据,从而方便了用户在不同系统之间进行数据转换。
启动Mysql新建一数据库,数据库名称是:crm.sql,打开数据库包括以下表:
2.2主页面的建立
2.2.1前台页面
整个前台页面的风格就是这样,上方是导航条方便我们选择不同的板块浏览,左上角是个logo,右上角是我们的模糊搜索模块,右边是各个模块的管理链接,方便用户应用此系统。
(1) 主页代码如下:
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head><title>c r m客户关系管理</title><meta http-equiv="Content-Type" content="text/html; charset=gbk" /><link rel="stylesheet" href="images/style/style.css" type="text/css"media="screen" /><style type="text/css" media="screen">
A.applink:hover {border: 2px dotted #DCE6F4;padding: 2px;background-color: #ffff00;color: #FFFFFF;text-decoration: underline
}A.applink {border: 2px dotted #DCE6F4;padding: 2px;color: #2F5BFF;background: transparent;text-decoration: underline
}A.info {color: #2F5BFF;background: transparent;text-decoration: underline
}A.info:hover {color: green;background: transparent;text-decoration: underline
}#page {background:url("http://www.couchart.com/wp-content/themes/default/images/kubrickbg-ltr.jpg")repeat-y top;border: none;
}
</style><link rel="stylesheet" href="images/style/lightbox.css"type="text/css" media="screen" /><!-- end lightbox scripts --><script type="text/JavaScript"></script></head><body><div id="toprightnav"></div><div id="header"><div id="logoff"><table width="110" height="50"><tr><script language="JavaScript"> today=new Date(); function initArray(){ this.length=initArray.arguments.length for(var i=0;i<this.length;i++) this[i+1]=initArray.arguments[i] } var d=new initArray( "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); document.write( "<font color=#7b9baa style='font-size:13px;font-family:Verdana, Arial, Helvetica, sans-serif;'> ", today.getYear(),"年", today.getMonth()+1,"月", today.getDate(),"日 ", "</font>" ); </script><script> time_rota() </script></tr><tr><b><a href="/crm/logoff.do?method=logoff">退出系统</a> </b></tr></table></div></div><!-- /Header --><div id="navigation"><ul id="nav"><li><a href="#" title="添加客户"onclick="MM_openBrWindow('/crm/customer.do?method=add&id=text','添加客户信息','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=680,left=300,top=120')">添加客户</a></li><li class="page_item"><a href="#" title="添加联系人"onclick="MM_openBrWindow('/crm/contact.do?method=add&id=text','添加联系人信息','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=630,left=300,top=160')">添加联系人</a></li><li class="page_item"><a href="#" title="添加机会"onclick="MM_openBrWindow('/crm/chance.do?method=look&control=add','','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=260,height=450,left=300,top=160')">添加机会</a></li><li><a href="#" title="添加活动"onclick="MM_openBrWindow('/crm/action.do?method=look&control=add','添加活动信息','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=550,height=500,left=300,top=160')">添加活动</a></li><li><a href="#" title="添加销售"onclick="MM_openBrWindow('/crm/sell.do?method=look&control=add','添加销售','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=480,height=460,left=300,top=160')">添加销售</a></li><li><a href="#" title="添加产品"onclick="MM_openBrWindow('/crm/product.do?method=add&add=addProduct','添加产品','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=280,height=450,left=300,top=160')">添加产品</a></li><li><a href="#" title="添加词典"onclick="MM_openBrWindow('/crm/addDictionary.jsp','添加词典','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=255,height=230,left=300,top=160')">添加词典</a></li><li><a href="#" title="添加员工"onclick="MM_openBrWindow('/crm/employee.do?method=look&control=add','添加员工','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=370,left=300,top=160')">添加员工</a></li></ul></div><div id="loop"><div id="colcontainer"><div id="contentcol"><div id="content" class="narrowcolumn"><h1>客户管理>>客户信息</h1><div class="search" id="search"><form method="get" id="searchform" action="/crm/customer.do"><input type="hidden" name="method" value="look" /><input type="hidden" name="index" value="look" /> <select name="select" style="width: 100px"><option value="customer_name">按客户姓名</option><option value="customer_country">按客户所在国家</option><option value="customer_province">按客户所在省份</option><option value="customer_address">按客户详细地址</option><option value="customer_telephone">按客户电话</option><option value="customer_fax">按客户传真</option><option value="customer_email">按客户邮箱</option><option value="customer_website">按客户个人主页</option><option value="customer_trade">按客户行业</option><option value="customer_type">按客户类型</option><option value="customer_status">按客户状态</option><option value="customer_source">按客户来源</option></select><input type="text" name="condition" id="s"value="Enter Keyword(s)"onblur="if(this.value=='') this.value='Enter Keyword(s)';"onfocus="if(this.value=='Enter Keyword(s)') this.value='';" /><input name="Submit" type="submit" value="提 交" /></form></div><div class="post"><div class="article"><table width="750" border="0" cellpadding="0" cellspacing="0"align="center"><tr><td width="90" height="24" class="table_header">客户名称</td><td width="100" height="24" class="table_header">国家</td><td width="100" height="24" class="table_header">省、市</td><td width="80" height="24" class="table_header">区号/邮编</td><td width="150" height="24" class="table_header">地址</td><td width="80" height="24" class="table_header">电话</td><td width="150" height="24" class="table_header">电子邮箱</td></tr><c:forEach items="${customers}" var="customer"><tr><tdonclick="MM_openBrWindow('/crm/customer.do?method=editor&id=${customer.customerId }','添加客户信息','width=500,height=720,left=300,top=100')"style="cursor: hand">${customer.customerName}</td><td>${customer.customerCountry}</td><td>${customer.province}--${customer.city}</td><td>${customer.cityCode}<font color="#299943">-</font>${customer.postCode}</td><td>${customer.address}</td><td>${customer.telephone}</td><td> ${customer.email}</td></tr></c:forEach><tr><td colspan="7"><bean:write name="foot" filter="false" /></td></tr></table></div></div></div></div><div id="sidebar"><ul><li id="categories" class="widget widget_categories"><h2 class="widgettitle">客户管理</h2><ul><li><a href="/crm/customer.do?method=look" title="客户信息">客户信息</a></li><li><a href="/crm/contact.do?method=look" title="联系人信息">联系人信息</a></li><li><a href="/crm/customerlevel.do?method=look&level=1"title="客户等级">客户等级</a></li></ul></li><li id="archives" class="widget widget_archives"><h2 class="widgettitle">销售管理</h2><ul><li><a href="/crm/chance.do?method=look&control=all" title="机会">机会</a></li><li><a href="/crm/action.do?method=look&control=all" title="活动">活动</a></li><li><a href="/crm/sell.do?method=look&control=all" title="销售">销售</a></li><li><a href="/crm/detail.do?method=look" title="订单">订单</a></li></ul></li><li id="links" class="widget widget_links"><h2 class="widgettitle">产品管理</h2><ul><li><a href="/crm/product.do?method=look" title="产品管理">产品</a></li></ul></li><li id="links" class="widget widget_links"><h2 class="widgettitle">费用管理</h2><ul><li><a href="cost.do?method=look" title="费用管理">费用</a></li></ul></li><li id="archives" class="widget widget_archives"><h2 class="widgettitle">用户自定义词典</h2><ul><li><a href="/crm/dictionary.do?method=look">自定义词典</a></li><li><a href="/crm/country.do?method=look">自定义国家</a></li><li><a href="/crm/area.do?method=look">自定义地区</a></li></ul></li><li id="categories" class="widget widget_links"><h2 class="widgettitle">人事管理</h2><ul><li><a href="/crm/employee.do?method=look&control=all" title="员工管理">员工管理</a></li><li><a href="/crm/department.do?method=look&control=all" title="部门管理">部门管理</a></li><li><a href="/crm/usermanage.do?method=look" title="角色管理">角色管理</a></li><li><a href="/crm/userrole.do?method=look" title="用户权限管理">用户权限管理</a></li></ul></li></ul></div></div></div><!-- Footer --><div id="footer"></div><div id="footerinfo">© Couchart 2007 . All rights reserved. team3(赵爽、XXX、陶明飞、吴松、赵悦含、张琦、刘巧翠)</div><!-- /Footer --></body>
</html>
(2) 版权声明
本部分只是利用fireworks制作的一图片,为了进行一下版权的声明,包括了一些设为首页,联系站长,加入收藏,版权申请等一些信息。此图片的处理,借助了fireworks的各种功能,达到了很好的效果。2.3其它页面显示以及代码
我们所有的页面都用的主页面的样式,显示效果如主页面一样,下面我们提供部分代码,在此段代码中有技术含量较高的表单验证代码:
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>添加客户信息</title><script type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0window.open(theURL,winName,features);
}
//-->
</script><link href="images/style/addinf.css" rel="stylesheet" type="text/css"></head><body id="body"><center><p><b><font size="4">添 加 客 户 信 息</font> </b><br>(加*的为必须填写的内容)</p></center><form name="theForm" id="demo" action="/crm/customer.do?method=add"method="post"onSubmit="return Validator.Validate(document.getElementById('demo'))"onReset="return Validator.Validate(this,2)"><table align="center"><tr><td width="90" height="65" id="td"> * 客户姓名:</td><td width="140"><input type="text" name="customerName" id="name" size="20"maxlength="30" datatype="Cus_name" msg="提示:不能为空且只能由汉字英文或数字组成" /></td><td width="85"> * 国 家: </td><td width="147"><select name="customerCountry" style="width: 117px"><c:forEach items="${countries }" var="country"><option> ${country. countryName} </option></c:forEach></select><input name="addCountry" type="button" id="addProvince"style="width: 25px"onClick="MM_openBrWindow('/crm/addCountry.jsp','添加国家','width=250,height=230,left=400,top=300')"value="..." /></td></tr><tr><td height="65"> * 邮 编: </td><td width="140"> <input type="text" name="customerPostCode" size="20"maxlength="6" datatype="Cus_PostCode" msg="提示:不能为空且只能有6位数字" /></td><td> * 省 份:</td><td width="147"><select name="customerProvince" id="city" style="width: 117px"><c:forEach items="${provences}" var="provence"><option> ${provence.areaName} </option></c:forEach></select><input name="addCountry" type="button" id="addProvince"style="width: 25px"onClick="MM_openBrWindow('/crm/area.do?method=add&t=ready&add=addProvince','添加省份','width=220,height=230,left=400,top=300')"value="..." /></td></tr><tr><td height="65"> * 区 号: </td><td width="140"><input type="text" name="customerCityCode" size="20" maxlength="4"dataType="Cus_CityCode" msg="提示:不能为空且只能有3或4位数字" /></td><td> * 城 市: </td><td><select name="customerCity" id="city" style="width: 117px"><c:forEach items="${cities}" var="city"><option> ${city.areaName} </option></c:forEach></select><input name="addCity" type="button" id="addCity"style="width: 25px"onClick="MM_openBrWindow('/crm/area.do?method=add&t=ready','添加城市','width=250,height=500,left=300,top=160')"value="..." /></td></tr><tr><td height="65"> * 详细地址:</td><td width="140"><input name="customerAddress" type="text" size="20" maxlength="50"datatype="Cus_address" msg="提示:不能为空且只能由汉字英文或数字组成" /></td></tr><tr><td height="65"> * 客户电话:</td><td width="140"><input name="customerTelephone" type="text" size="20"maxlength="13" datatype="Cus_phone" msg="提示:不能为空且只能由数字或'-'组成" /></td><td> * 客户类型: </td><td><select name="customerType" style="width: 145px"><c:forEach items="${customerType}" var="customertype"><option value="${customertype.content}">${customertype.content}</option></c:forEach></select></td></tr><tr><td height="50"> 客户传真:</td><td width="140"><input name="customerFax" type="text" size="20" maxlength="13" require="false"datatype="Cus_fax" msg="只能由数字或'-'组成" /></td><td> * 客户来源: </td><td><select name="customerSource" style="width: 145px"><c:forEach items="${customerSource}" var="customersource"><option> ${customersource.content}</option></c:forEach></select></td></tr><tr><td height="65"> E - mail: </td><td width="140"><input name="customerEmail" type="text" size="20" maxlength="20" require="false"datatype="Cus_email" msg="电子邮箱地址格式不正确" /></td><td> * 行 业: </td><td><select name="customerTrade" style="width: 145px"><c:forEach items="${customerTrade}" var="customertrade"><option> ${customertrade.content} </option></c:forEach></select></td></tr><tr><td height="50"> 客户网站:</td><td width="140"><input name="customerWebsite" type="text" size="20" maxlength="20" require="false"datatype="Cus_web" msg="网址必须包含'http://'" /></td><td> 员 工 数: </td><td width="147"><input name="customerEmployee" type="text" size="19" require="false"datatype="Cus_emp"msg="员工数填写格式错误" maxlength="10" /></td></tr><tr><td height="50"> 收 入: </td><td width="140"><input name="customerIncome" type="text" size="20" maxlength="13" require="false"datatype="Cus_income" msg="收入填写格式错误" /></td><td> * 客户状态: </td><td><select name="customerStatus" style="width: 145px"><c:forEach items="${customerStatus}" var="customerstatus"><option> ${customerstatus.content} </option></c:forEach></select></td></tr><tr><td height="30"><html:errors /></td><td align="center"><div align="right"><input type="submit" name="Submit2" value="添加"onClick="Validator.Validate(document.getElementById('demo'))" /><input type="hidden" name="customerId" /> </div></td><td><div align="right"><input type="reset" name="reset" value="重置" /></div></td></tr></table><script>
Validator = {
Cus_email : /^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/, <!--email正则表达式-->
Cus_web : /^http:\\/\\/[A-Za-z0-9]+\\.[A-Za-z0-9]+[\\/=\\?%\\-&_~`@[\\]\\':+!]*([^<>\\"\\"])*$/, <!--客户网站正则表达式-->
Cus_name :/^[a-zA-Z0-9\\u0391-\\uFFE5]+$/, <!--客户名称只能由汉字英文或者数字组成-->
Cus_CityCode:/^[0-9]{3,4}$/,
Cus_PostCode:/^[0-9]{6,7}$/,
Cus_address:/^[a-zA-Z0-9\\u0391-\\uFFE5]+$/, <!--地址只能由汉字英文或者数字组成-->
Cus_phone : /^[+]{0,1}(\\d){1,3}[ ]?([-]?(\\d){1,12})+$/, <!--电话号码格式-->
Cus_fax :/^[+]{0,1}(\\d){1,3}[ ]?([-]?(\\d){1,12})+$/, <!--传真号码格式正则表达式-->
Cus_emp : /^\\d+$/, <!--雇用员工数只能为正整数-->
Cus_income :/^\\d+(\\.\\d+)?([E]\\d{1})?$/, <!--收入只能为正数-->
ErrorItem : [document.forms[0]],
ErrorMessage : ["以下原因导致提交失败:\\t\\t\\t\\t"],
Validate : function(theForm, mode){var obj = theForm || event.srcElement;var count = obj.elements.length;this.ErrorMessage.length = 1;this.ErrorItem.length = 1;this.ErrorItem[0] = obj;for(var i=0;i<count;i++){with(obj.elements[i]){var _dataType = getAttribute("dataType");if(typeof(_dataType) == "object" || typeof(this[_dataType]) == "undefined") continue;this.ClearState(obj.elements[i]);if(getAttribute("require") == "false" && value == "") continue;switch(_dataType){default :if(!this[_dataType].test(value)){this.AddError(i, getAttribute("msg"));}break;}}}if(this.ErrorMessage.length > 1){mode = mode || 1;var errCount = this.ErrorItem.length;switch(mode){case 1 :for(var i=1;i<errCount;i++){try{var span = document.createElement("SPAN");span.id = "__ErrorMessagePanel";span.style.color = "red";this.ErrorItem[i].parentNode.appendChild(span);span.innerHTML = this.ErrorMessage[i].replace(/\\d+:/,"");}catch(e){alert(e.description);}}this.ErrorItem[1].focus();break;case 2 :doReset();break;}return false;}return true;
},
ClearState : function(elem){with(elem){if(style.color == "red")style.color = "";var lastNode = parentNode.childNodes[parentNode.childNodes.length-1];if(lastNode.id == "__ErrorMessagePanel")parentNode.removeChild(lastNode);}
},
AddError : function(index, str){this.ErrorItem[this.ErrorItem.length] = this.ErrorItem[0].elements[index];this.ErrorMessage[this.ErrorMessage.length] = this.ErrorMessage.length + ":" + str;
}
}
function doReset(){document.theForm.customerName.value="";document.theForm.customerCityCode.value="";document.theForm.customerPostCode.value="";document.theForm.customerAddress.value="";document.theForm.customerTelephone.value="";document.theForm.customerFax.value="";document.theForm.customerEmail.value="";document.theForm.customerWebsite.value="";document.theForm.customerEmployee.value="";document.theForm.customerIncome.value="";
}
</script></form></body>
</html>
3.1 设计目标
本CRM客户关系管理系统是根据学校实际要求进行开发设计的,主要实现如下目标:
q 网页风格符合学校的特点,界面美观大方。
q 充分为用户着想,提供细致周到的技术支持。
q 提供为用户快速管理客户关系的功能,操作建议明了。
q 为网站管理员提供方便、快捷的网站维护平台。
q 提供用户精确查找功能。
q 网站运行安全稳定。
3.3 数据库设计
本系统数据库采用Mysql数据库,系统数据库名称crm。数据库crm中包含11张表。关于数据库中的主要数据表请参见附录B。
4 辅助JavaBean的编写
根据系统的需求编写需要的JavaBean。下面将给出企业门户网站中所需要的部分辅助JavaBean的编写过程。
4.1 基本数据库操作的JavaBean的编写
基本数据库操作的JavaBean是一个公共类,通常包括连接数据库的方法getConnection、获取结果集总记录数的方法ResultSet、删除数据的方法Delete等。下面将给出编写JAVA精品课程网站中的基本数据库操作的JavaBean“Database”的实现过程。