Java Web开发(JSP)
课程设计报告
题 目:个人信息管理系统
设 计 者:xxxx
专业班级:xxxxxxxx
学 号:xxxxxxxx
指导教师: xxxxx
20##年 1月 5日
xxxxx大学计算机学院
个人信息管理系统报告书
一、系统需求背景
该系统实现用户的个人信息管理,根据用户的需求实现相应的信息查询以及更新为用户挺方便的使用功能。
本系统适用于所有人的个人信息管理,主要任务是对用户的的事宜、心情、工作、学习、个人帐目等等的记载,并对这些进行信息进行日常管理。社会发展越来越快,在面对多发方面压力的情况下,生活难免会陷入混乱,我们在每天的生活和学习中会接触到大量丰富的信息,对于个人信息也需要有一个系统的管理。
二、系统所涉及的一些知识
该个人信息管理系统管理系统采用JSP+JDBC+MySQL、extjs、struts、spring、ibatis来实现,视图层采用JSP来实现,并通过JDBC来连接MySQL数据库。
JSP(Java Server Pages)是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准。 JSP技术是用JAVA语言作为脚本语言的,JSP网页为整个服务器端的JAVA库单元提供了一个接口来服务于HTTP的应用程序。
JDBC是一种可用于执行SQL语句的JavaAPI(ApplicationProgrammingInterface应用程序设计接口)。它由一些Java语言编写的类和界面组成。JDBC为数据库应用开发人员、数据库前台工具开发人员提供了一种标准的应用程序设计接口,使开发人员可以用纯Java语言编写完整的数据库应用程序。
MySQL是一个真正的多用户、多线程SQL数据库服务器。SQL(结构化查询语言)是世界上最流行的和标准化的数据库语言。MySQL是以一个客户机/服务器结构的实现,它由一个服务器守护程序mysqld和很多不同的客户程序和库组成。
MySQL 主要目标是快速、健壮和易用。最初是因为我们需要这样一个SQL服务器,它能处理与任何可不昂贵硬件平台上提供数据库的厂家在一个数量级上的大型数据库,但速度更快,MySQL就开发出来。
三、 功能需求分析
对模块及其基本功能进行分析
本系统为方便用户使用起见设计了八块:主页、任务管理、笔记管理、相册管理、订阅管理、文档管理、帐目管理、系统管理。系统的基本功能是:用户登陆后,可以通过一系列的操作管理个人信息,使得日常个人信息管理得到合理的保管,及时的进行完善,使得生活更有条不紊,并且各个功能模块都可以选择性的开启或者停用。
四、 系统设计方案
整体设计方案。
根据系统功能需求分析,可将系统完善大致分为如下几步:
程序结构
主模块
五、 系统涉及的数据库表
所使用的数据库及其字段。
数据库安装的是MySQL 5.1,根据系统功能需求分析得到如下数据库表:
六、 具体功能分析
1、 登录界面
<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@page import="global.Constants"%>
<%@page import="util.ServletHelp"%>
<%@page import="global.security.SessionUtils"%><html>
<head>
<%
String baseUrl = request.getContextPath();
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
$(document).ready(function(){
// 全局参数
var baseParams = {start:0, limit:<%=Constants.PAGE_SIZE %>, delflag:"<%=Constants.DEL_FLAG_1 %>"};
// 用户数据源
var userListStore = new Ext.data.JsonStore({
url: '<%=baseUrl %>/userAction.do?method=queryForPaging',
root: 'datas',
totalProperty: 'results',
fields: ['userId', 'userName', 'role', 'sex', 'birthdayStr', 'email', 'phone', 'status'],
baseParams: baseParams,
autoLoad: true
});
// 工具栏
var userListToolbar = new Ext.Toolbar({
renderTo: 'userListToolBarDiv',
items: [
new Ext.Button({
id: 'userList-add-button',
text: '添加',
iconCls: 'user_add'
}),
'-',
new Ext.Button({
id: 'userList-start-button',
text: '启用',
iconCls: 'status_online'
}),
new Ext.Button({
id: 'userList-stop-button',
text: '停用',
iconCls: 'status_offline'
}),
new Ext.Button({
id: 'userList-delete-button',
text: '删除',
iconCls: 'status_busy'
}),
new Ext.ux.form.SearchField({
store: userListStore,
width: 320,
paramName: 'userName',
emptyText: '请输入用户名...',
style: 'margin-left: 10px;'
})
]
});
// 用户数据表格
var sm = new Ext.grid.CheckboxSelectionModel();
var userListGrid = new Ext.grid.GridPanel({
id: 'userListGrid',
renderTo: 'userListGridDiv',
border: false,
stateful: true,
autoScroll: 'auto',
store: userListStore,
loadMask: true,
cm: new Ext.grid.ColumnModel({
defaults: {
width: 100,
sortable: true
},
columns: [
sm,
new Ext.grid.RowNumberer({header:'№'}),
{id:'role',header: '角色', width: 100, sortable: true, dataIndex: 'role'},
{id:'userId',header: '账号', width: 100, sortable: true, dataIndex: 'userId'},
{id:'userName',header: '用户名', width: 100, sortable: true, dataIndex: 'userName'},
{id:'sex',header: '性别', width: 50, sortable: true, dataIndex: 'sex'},
{id:'birthdayStr',header: '生日', width: 100, sortable: true, dataIndex: 'birthdayStr'},
{id:'email',header: '邮箱', width: 180, sortable: true, dataIndex: 'email'},
{id:'phone',header: '电话', width: 100, sortable: true, dataIndex: 'phone'},
{id:'status',header: '状态', width: 50, sortable: true, dataIndex: 'status'}
]
}),
sm: sm,
columnLines: true,
bbar: new Ext.PagingToolbar({
pageSize: <%=Constants.PAGE_SIZE %>,
store: userListStore,
displayInfo: true,
displayMsg: Anynote.PAGINGTOOLBAR_DISPLAYMSG,
emptyMsg: Anynote.PAGINGTOOLBAR_EMPTYMSG,
doLoad: function(start){
baseParams.start = start;
this.store.load({params: baseParams});
}
})
});
// 设置Grid高度和宽度
Anynote.resizeGridTo("userListGrid", 0, 56);
// 添加按钮
$("#userList-add-button").click(function(){
// 角色数据源
var roleStore = new Ext.data.ArrayStore({
fields : ['role', 'roleName'],
data : <%=ServletHelp.getArrayFromMap(Constants.ROLE_MAP, null)%>,
sortInfo: {field: "role", direction: "ASC"}
});
if('<%=Constants.ROLE_CODE_1%>'=='<%=SessionUtils.getUserRole()%>'){
roleStore.removeAt(0);
}else{
roleStore.removeAt(0);
roleStore.removeAt(0);
}
// 性别数据源
var sexStore = new Ext.data.ArrayStore({
fields : ['sex', 'sexName'],
data : <%=ServletHelp.getArrayFromMap(Constants.SEX_MAP, null)%>,
sortInfo: {field: "sex", direction: "ASC"}
});
// 风格数据源
var themeStore = new Ext.data.SimpleStore({
fields : ['theme', 'themeName'],
data : Anynote.THEME_DATA
});
// 编辑用户Form
var addUserFormPanel = new Ext.FormPanel({
id: 'addUserFormPanel',
labelWidth: 60,
buttonAlign: 'center',
border: false,
bodyStyle: 'padding:10px;text-align:left;background-color:transparent;',
url: '',
items:[{// 角色
xtype:'combo',
hiddenName: 'role',
fieldLabel: '角色',
store: roleStore,
mode : 'local',
triggerAction: "all",
valueField: 'role',
displayField: 'roleName',
allowBlank:false,
editable: false,
width: 230,
anchor:'98%'
},{// 账号
xtype:'textfield',
name: 'userId',
fieldLabel: '账号',
anchor:'98%',
allowBlank:false,
maxLength: 20
},new Ext.form.TextField ({// 密码
inputType: 'password',
name:'password',
fieldLabel:'密码',
anchor:'98%',
allowBlank:false,
maxLength: 20
}),new Ext.form.TextField ({// 确认密码
inputType: 'password',
name:'repassword',
fieldLabel:'确认密码',
anchor:'98%',
allowBlank:false,
maxLength: 20
}),{// 姓名
xtype:'textfield',
id:'userName',
name:'userName',
fieldLabel:'姓名',
anchor:'98%',
allowBlank:false,
maxLength: 20
},{// 性别
xtype:'combo',
hiddenName: 'sex',
fieldLabel: '性别',
store: sexStore,
mode : 'local',
triggerAction: "all",
valueField: 'sex',
displayField: 'sexName',
allowBlank:false,
editable: false,
width: 230,
anchor:'98%'
},{// 生日
xtype:'datefield',
name: 'birthdayStr',
fieldLabel: '生日',
format: 'Y-m-d',
width: 230,
anchor:'98%'
},{// 邮箱
xtype:'textfield',
name:'email',
fieldLabel:'邮箱',
anchor:'98%',
vtype:'email',
allowBlank:false,
maxLength: 50
},{// 电话
xtype:'textfield',
name:'phone',
fieldLabel:'电话',
anchor:'98%',
maxLength: 20
},{// 风格
xtype:'combo',
hiddenName: 'theme',
fieldLabel: '风格',
store: themeStore,
mode : 'local',
triggerAction: "all",
valueField: 'theme',
displayField: 'themeName',
value: 'ext-all.css',
editable: false,
allowBlank:false,
width: 230,
anchor:'98%'
},{
xtype: 'radiogroup',
fieldLabel: '主页',
itemCls: 'x-check-group-alt',
columns: 3,
items: [
{boxLabel: '任务', name: 'homePage', inputValue: "<%=Constants.HOME_PAGE_1_URL%>", checked: true},
{boxLabel: '笔记', name: 'homePage', inputValue: "<%=Constants.HOME_PAGE_2_URL%>"},
{boxLabel: '相册', name: 'homePage', inputValue: "<%=Constants.HOME_PAGE_3_URL%>"},
{boxLabel: '账目', name: 'homePage', inputValue: "<%=Constants.HOME_PAGE_4_URL%>"},
{boxLabel: '订阅', name: 'homePage', inputValue: "<%=Constants.HOME_PAGE_5_URL%>"},
{boxLabel: '文档', name: 'homePage', inputValue: "<%=Constants.HOME_PAGE_7_URL%>"}
]
},{
xtype: 'checkboxgroup',
fieldLabel: '模块',
itemCls: 'x-check-group-alt',
columns: 3,
items: [
{boxLabel: '任务', name: 'showTodo', checked: true},
{boxLabel: '笔记', name: 'showNote', checked: true},
{boxLabel: '相册', name: 'showPicture', checked: true},
{boxLabel: '账目', name: 'showAccount', checked: true},
{boxLabel: '订阅', name: 'showFeed', checked: true},
{boxLabel: '文档', name: 'showDocument', checked: true}
]
},{// 验证码
xtype:'textfield',
id:'verifyCode',
name:'verifyCode',
fieldLabel:'验证码',
anchor:'98%',
allowBlank:false,
maxLength: 20
},{
width: 110,
border: false,
style: 'margin-left:65px;line-height:20px;',
bodyStyle: 'background-color:transparent;',
html:'<img id="VerifyCodeImg" src="" style="float:left;"/><span style="float:right;"><a href="javascript:changeVerifyCode();">换一张</a></span>'
}],
buttons: [{
text:'提交',
handler: function(){
var form = addUserFormPanel.getForm();
if(form.isValid()){
// 发送请求
Anynote.ajaxRequest({
baseUrl: '<%=baseUrl %>',
baseParams: form.getValues(),
action: '/loginAction.do?method=register',
callback: function(jsonResult){
userListGrid.getStore().reload();
addUserWindow.close();
},
showWaiting: true,
failureMsg: '保存失败.'
});
}
}
},{
text: '重置',
handler: function(){
addUserFormPanel.getForm().reset();
}
}]
});
// 用户注册窗口
var addUserWindow = new Ext.Window({
title: '添加用户',
width: 330,
height: 490,
modal: true,
maximizable: false,
resizable: false,
layout:'fit',
plain: true,
items: [addUserFormPanel]
}).show();
// 获得验证码
changeVerifyCode();
});
// 启用按钮
$("#userList-start-button").click(function(){
// 启用
submit("start");
});
// 停用按钮
$("#userList-stop-button").click(function(){
// 停用
submit("stop");
});
// 删除按钮
$("#userList-delete-button").click(function(){
// 提交
submit("delete");
});
// 提交
function submit(type){
var msg = "";
var status = "";
if(type=="delete"){
msg = "确定要删除账户及其文件吗?";
}elseif(type=="stop"){
msg = "确定要停用吗?";
status = "<%=Constants.USER_STATUS_2%>";
type = "updateStatus";
}elseif(type=="start"){
msg = "确定要启用吗?";
status = "<%=Constants.USER_STATUS_1%>";
type = "updateStatus";
}
var records = userListGrid.getSelectionModel().getSelections();
if(records.length < 1){
Ext.Msg.alert("提示", "请至少选择一条数据.");
}else{
Ext.Msg.confirm("警告", msg, function(btn){
if(btn=="yes"){
var userIds = "";
for(var i=0;i<records.length;i++){
userIds = userIds + records[i].get("userId") + ",";
}
// 发送请求
Anynote.ajaxRequest({
baseUrl: '<%=baseUrl %>',
baseParams: {userIds:userIds, status:status},
action: '/userAction.do?method='+type,
callback: function(jsonResult){
userListGrid.getStore().reload();
},
showWaiting: true,
failureMsg: '保存失败.'
});
}
});
}
}
});
// 更换验证码
function changeVerifyCode(){
$("#VerifyCodeImg").attr("src", "<%=baseUrl %>/loginAction.do?method=getVerifyCode&time="+new Date());
}
</script>
</head>
<body>
<div id="userListDiv">
<div id="userListToolBarDiv"></div>
<div id="userListGridDiv" style="width:100%;height:100%;">
</div>
帐目查询界面
<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@page import="global.Constants"%>
<%@page import="util.DateUtils"%>
<%@page import="util.ServletHelp"%>
<%@page import="util.StringUtils"%>
<html>
<head>
<%
String baseUrl = request.getContextPath();
String accountBookId = request.getParameter("accountBookId");
String accountBookName = request.getParameter("accountBookName");
if(StringUtils.isEmpty(accountBookName) || "null".equals(accountBookName)){
accountBookName = "所有账目";
}else{
accountBookName = java.net.URLDecoder.decode(accountBookName, "UTF-8");
}
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
Ext.chart.Chart.CHART_URL = '<%=baseUrl %>/websrc/js/ext-3.3.0/resources/charts.swf';
$(document).ready(function(){
// 全局参数
var baseParams = {start:0, limit:"<%=Constants.PAGE_SIZE %>", accountBookId:"<%=accountBookId %>", fromDate:"<%=DateUtils.getFirstDayOfMonthAsString(DateUtils.DATE_PATTON_1)%>", toDate:"<%=DateUtils.getLastDayOfMonthAsString(DateUtils.DATE_PATTON_1)%>"};
var accountBookName = '<%=accountBookName%>';
// 工具栏
var accountListToolbar = new Ext.Toolbar({
renderTo: 'accountListToolBarDiv',
items: [
'当前:'+accountBookName,
'-',
new Ext.Button({
id: 'accountList-search-button',
text: '查询',
iconCls: 'report_magnify'
}),
new Ext.Button({
id: 'accountList-add-button',
text: '添加',
iconCls: 'report_add'
}),
new Ext.Button({
id: 'accountList-edit-button',
text: '修改',
iconCls: 'report_edit'
}),
new Ext.Button({
id: 'accountList-delete-button',
text: '删除',
iconCls: 'report_delete'
}),
'-',
new Ext.Button({
id: 'accountList-inout-button',
text: '收支统计',
iconCls: 'chart_bar'
}),
new Ext.Button({
id: 'accountList-groupin-button',
text: '收入统计',
iconCls: 'chart_pie'
}),
new Ext.Button({
id: 'accountList-groupout-button',
text: '支出统计',
iconCls: 'chart_pie'
})
]
});
// 账目分类数据源
var accountCategoryStore = new Ext.data.JsonStore({
url: '<%=baseUrl %>/accountCategoryAction.do?method=query',
root: 'datas',
fields: ['categoryId', 'categoryName'],
autoLoad: {
params: {'status':''},
callback: function(records, success){
this.insert(0, new Ext.data.Record({
categoryId: "",
categoryName: "全部"
}));
}
}
});
// 账目类型数据源
var accountTypeStore = new Ext.data.ArrayStore({
fields : ['accountType', 'accountTypeName'],
data : <%=ServletHelp.getArrayFromMap(Constants.ACCOUNT_TYPE_MAP, "全部")%>,
sortInfo: {field: "accountType", direction: "ASC"}
});
// 检索账目Form
var searchAccountFormPanel = new Ext.FormPanel({
id: 'searchAccountFormPanel',
renderTo: 'accountListSearchDiv',
labelWidth: 60,
width:600,
border: false,
bodyStyle: 'padding:5px;',
url: '',
items: [{
layout:'column',
border: false,
items:[{
columnWidth:.5,
layout: 'form',
border: false,
items: [{
// 账目类型
xtype:'combo',
hiddenName: 'accountType',
fieldLabel: '账目类型',
store: accountTypeStore,
mode : 'local',
triggerAction: "all",
emptyText: '请选择...',
valueField: 'accountType',
displayField: 'accountTypeName',
listeners:{
change:function(){
accountCategoryStore.load({
params: {'status':this.value},
callback: function(records, success){
if(records.length==0){
accountCategoryStore.removeAll();
}else{
accountCategoryStore.insert(0, new Ext.data.Record({
categoryId: "",
categoryName: "全部"
}));
}
searchAccountFormPanel.getForm().findField("categoryId").setValue("");
}
});
}
},
editable: false,
anchor:'95%'
},{
// 开始日期
xtype:'datefield',
id: 'fromDate',
name: 'fromDate',
fieldLabel: '开始日期',
format: 'Y-m-d',
value: '<%=DateUtils.getFirstDayOfMonthAsString(DateUtils.DATE_PATTON_1)%>',
anchor:'95%'
}]
},{
columnWidth:.5,
layout: 'form',
border: false,
items: [{
// 收支项目
xtype:'combo',
hiddenName: 'categoryId',
fieldLabel: '收支项目',
store: accountCategoryStore,
mode : 'local',
triggerAction: "all",
emptyText: '请选择...',
valueField: 'categoryId',
displayField: 'categoryName',
editable: false,
anchor:'95%'
},{
// 结束日期
xtype:'datefield',
id: 'toDate',
name: 'toDate',
fieldLabel: '结束日期',
format: 'Y-m-d',
value: '<%=DateUtils.getLastDayOfMonthAsString(DateUtils.DATE_PATTON_1)%>',
anchor:'95%'
}]
},{
columnWidth:.5,
layout: 'form',
border: false,
items: [{
// 账目备注
xtype:'textfield',
id:'remark',
name:'remark',
fieldLabel:'账目备注',
anchor:'95%'
}]
}]
}]
});
// 账目合计信息
var accountListGridHeaderPanel = new Ext.Panel({
id: 'accountListGridHeaderPanel',
renderTo: 'accountListGridHeaderDiv',
contentEl: 'accountListGridHeaderInfoDiv',
bodyStyle: 'padding:5px;border-width:0px;border-top-width:1px;'
});
// 账目数据源
var accountListStore = new Ext.data.JsonStore({
url: '<%=baseUrl %>/accountAction.do?method=query',
root: 'datas',
totalProperty: 'results',
fields: ['accountId', 'accountBookId', 'accountBookName', 'accountType', 'categoryName', 'accountDateStr', 'money', 'remark', 'updateDateStr'],
baseParams: baseParams,
autoLoad: true
});
// 账目数据表格
var sm = new Ext.grid.CheckboxSelectionModel();
var accountListGrid = new Ext.grid.GridPanel({
id: 'accountListGrid',
renderTo: 'accountListGridDiv',
border: false,
columnLines: true,
stateful: true,
autoScroll: 'auto',
height: 500,
store: accountListStore,
loadMask: true,
cm: new Ext.grid.ColumnModel({
defaults: {
width: 120,
sortable: true
},
columns: [
sm,
new Ext.grid.RowNumberer({header:'№'}),
{id:'accountBookId',header: '账本ID', width: 100, sortable: true, dataIndex: 'accountBookId', hidden: true},
{id:'accountBookName',header: '账本', width: 100, sortable: true, dataIndex: 'accountBookName'},
{id:'accountId',header: '账目ID', width: 100, sortable: true, dataIndex: 'accountId', hidden: true},
{id:'accountType',header: '账目类型', width: 100, sortable: true, dataIndex: 'accountType'},
{id:'categoryName',header: '收支项目', width: 150, sortable: true, dataIndex: 'categoryName'},
{id:'money',header: '金额', width: 100, sortable: true, dataIndex: 'money', align: 'right', renderer: Ext.util.Format.numberRenderer('0,000.00')},
{id:'accountDateStr',header: '账目日期', width: 100, sortable: true, dataIndex: 'accountDateStr'},
{id:'remark',header: '备注', width: 300, sortable: true, dataIndex: 'remark'}
]
}),
sm: sm,
columnLines: true,
bbar: new Ext.PagingToolbar({
pageSize: <%=Constants.PAGE_SIZE %>,
store: accountListStore,
displayInfo: true,
displayMsg: Anynote.PAGINGTOOLBAR_DISPLAYMSG,
emptyMsg: Anynote.PAGINGTOOLBAR_EMPTYMSG,
doLoad: function(start){
var form = searchAccountFormPanel.getForm();
var param = form.getValues();
param.start = start;
param.limit = baseParams.limit;
this.store.load({params: param});
}
}),
listeners: accountListStore.on("load", function(){getSum();})
});
// 设置Grid高度和宽度
Anynote.resizeGridTo("accountListGrid", 0, 169);
// 行双击事件
accountListGrid.on("rowdblclick", function(){
$("#accountList-edit-button").click();
});
// 添加按钮
$("#accountList-add-button").click(function(){
if('<%=accountBookId %>'==0){
Ext.Msg.alert('提示', '请先创建一个账本.');
}else{
accountWindow = new Ext.Window({
title: '添加账目',
width: 400,
height: 270,
modal: true,
resizable: false,
plain: true,
layout:'fit',
autoLoad:{url:'<%=baseUrl %>/websrc/page/account/editAccount.jsp?type=CREATE&accountBookId=<%=accountBookId%>',scripts:true,nocache:true}
});
accountWindow.show();
}
});
// 修改按钮
$("#accountList-edit-button").click(function(){
var records = Ext.getCmp("accountListGrid").getSelectionModel().getSelections();
if(records.length!=1){
Ext.Msg.alert("提示", "请选择一条数据.");
}else{
var accountId = records[0].get("accountId");
accountWindow = new Ext.Window({
title: '编辑账目',
width: 400,
height: 250,
modal: true,
resizable: false,
layout:'fit',
plain: true,
autoLoad:{url:'<%=baseUrl %>/websrc/page/account/editAccount.jsp?type=UPDATE&accountId='+accountId,scripts:true,nocache:true}
});
accountWindow.show();
}
});
// 删除按钮
$("#accountList-delete-button").click(function(){
var records = Ext.getCmp("accountListGrid").getSelectionModel().getSelections();
if(records.length < 1){
Ext.Msg.alert("提示", "请至少选择一条数据.");
}else{
Ext.Msg.confirm("警告", "确定要删除吗?", function(btn){
if(btn=="yes"){
var accountIds = "";
for(var i=0;i<records.length;i++){
accountIds = accountIds + records[i].get("accountId") + ",";
}
// 发送请求
Anynote.ajaxRequest({
baseUrl: '<%=baseUrl %>',
baseParams: {accountIds:accountIds},
action: '/accountAction.do?method=delete',
callback: function(jsonResult){
Ext.getCmp("accountListGrid").getStore().reload({
callback: function(records, success){getSum();}
});
},
showWaiting: true,
failureMsg: '删除失败.'
});
}
});
}
});
// 查询按钮
$("#accountList-search-button").click(function(){
var form = searchAccountFormPanel.getForm();
var param = form.getValues();
accountListStore.load({params: param});
});
// 收支统计按钮
$("#accountList-inout-button").click(function(){
var fromDate = searchAccountFormPanel.getForm().findField('fromDate').getValue();
var toDate = searchAccountFormPanel.getForm().findField('toDate').getValue();
if(fromDate=='' || toDate==''){
Ext.Msg.alert('提示','请选择统计日期!');
}else{
// 发送请求-取合计值
Anynote.ajaxRequest({
baseUrl: '<%=baseUrl %>',
baseParams: {fromDate:fromDate,toDate:toDate,accountBookId:<%=accountBookId %>},
action: '/accountAction.do?method=getSum',
callback: function(jsonResult){
if(jsonResult.success==true){
// 收支统计数据
var accountListInOutStore = new Ext.data.ArrayStore({
fields: ['inout', 'money'],
data: [['收入',jsonResult.currentInMoney],['支出',jsonResult.currentOutMoney]]
});
// 收支统计窗口
var groupInOutWindow = new Ext.Window({
title: '收支统计',
width: 300,
height: 450,
modal: true,
maximizable: false,
resizable: false,
layout:'fit',
plain: true,
items: {
xtype: 'columnchart',
store: accountListInOutStore,
yField: 'money',
xField: 'inout',
xAxis: new Ext.chart.CategoryAxis({
title: '收支'
}),
yAxis: new Ext.chart.NumericAxis({
title: '金额'
}),
extraStyle: {
xAxis: {
labelRotation: 0
}
}
}
}).show();
}else{
Ext.Msg.alert('提示','统计错误.');
}
}
});
}
});
// 收入统计按钮
$("#accountList-groupin-button").click(function(){
var fromDate = searchAccountFormPanel.getForm().findField('fromDate').getValue();
var toDate = searchAccountFormPanel.getForm().findField('toDate').getValue();
if(fromDate=='' || toDate==''){
Ext.Msg.alert('提示','请选择统计日期.');
}else{
// 收入统计数据源
var accountListGroupInStore = new Ext.data.JsonStore({
url: '<%=baseUrl %>/accountAction.do?method=getGroupSumMoney',
root: 'datas',
totalProperty: 'results',
fields: ['categoryName', 'money'],
baseParams: {accountBookId:'<%=accountBookId%>',accountType:'1',fromDate:fromDate,toDate:toDate},
autoLoad: true
});
var groupInWindow = new Ext.Window({
title: '收入统计',
width: 600,
height: 450,
modal: true,
maximizable: false,
resizable: false,
layout:'fit',
plain: true,
items: {
store: accountListGroupInStore,
xtype: 'piechart',
dataField: 'money',
categoryField: 'categoryName',
extraStyle:{
legend:{
display: 'bottom',
padding: 5
}
}
}
}).show();
}
});
// 支出统计按钮
$("#accountList-groupout-button").click(function(){
var fromDate = searchAccountFormPanel.getForm().findField('fromDate').getValue();
var toDate = searchAccountFormPanel.getForm().findField('toDate').getValue();
if(fromDate=='' || toDate==''){
Ext.Msg.alert('提示','请选择统计日期.');
}else{
// 支出统计数据源
var accountListGroupOutStore = new Ext.data.JsonStore({
url: '<%=baseUrl %>/accountAction.do?method=getGroupSumMoney',
root: 'datas',
totalProperty: 'results',
fields: ['categoryName', 'money'],
baseParams: {accountBookId:'<%=accountBookId%>',accountType:'2',fromDate:fromDate,toDate:toDate,accountBookId:<%=accountBookId %>},
autoLoad: true
});
var groupOutWindow = new Ext.Window({
title: '支出统计',
width: 600,
height: 450,
modal: true,
maximizable: false,
resizable: false,
layout:'fit',
plain: true,
items: {
store: accountListGroupOutStore,
xtype: 'piechart',
dataField: 'money',
categoryField: 'categoryName',
extraStyle:{
legend:{
display: 'bottom',
padding: 5
}
}
}
}).show();
}
});
});
// 取合计值
function getSum(){
var form = Ext.getCmp("searchAccountFormPanel").getForm();
var param = form.getValues();
param.accountBookId = '<%=accountBookId %>';
// 发送请求-取合计值
Anynote.ajaxRequest({
baseUrl: '<%=baseUrl %>',
baseParams: param,
action: '/accountAction.do?method=getSum',
callback: function(jsonResult){
setGridHeader(jsonResult);
}
});
}
// 取合计值回调方法
function setGridHeader(jsonResult){
if(jsonResult.success==true){
$("#inMoneySpan").html(Ext.util.Format.number(jsonResult.inMoney,'0,000.00'));
$("#outMoneySpan").html(Ext.util.Format.number(jsonResult.outMoney,'0,000.00'));
$("#balanceSpan").html(Ext.util.Format.number(jsonResult.balance,'0,000.00'));
$("#currentInMoneySpan").html(Ext.util.Format.number(jsonResult.currentInMoney,'0,000.00'));
$("#currentOutMoneySpan").html(Ext.util.Format.number(jsonResult.currentOutMoney,'0,000.00'));
}
}
</script>
</head>
<body>
<div id="accountListDiv">
<div id="accountListToolBarDiv"></div>
<div id="accountListSearchDiv"></div>
<div id="accountListGridHeaderDiv">
<div id="accountListGridHeaderInfoDiv" style="font-size:12px;font-weight:bold;" class="x-hide-display">
<span style="float: left;">
<span>当前收入:</span><span id="currentInMoneySpan">--</span><span> 元</span>
<span>当前支出:</span><span id="currentOutMoneySpan">--</span><span> 元</span>
</span>
<span style="float: right;">
<span>总收入:</span><span id="inMoneySpan">--</span><span> 元</span>
<span>总支出:</span><span id="outMoneySpan">--</span><span> 元</span>
<span>总余额:</span><span id="balanceSpan">--</span><span> 元</span>
</span>
</div>
</div>
<div id="accountListGridDiv" style="width:100%;height:100%;"></div>
</div>
七、 总结:
在做系统发的过程中,学到了许多JSP知识,对JSP相关知识有了更细致的认识,以前上课时总是只听不练,虽然课上听的很明白,但由于课下缺少练习,相关的知识没有及时得到巩固,通过这次课程设计,对JSP相关知识有了更细致的认识,但同时也存在一些欠缺,部分界面没有完成,在数据库的连接过程还不够熟练,需要进一步完善学习。