版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
Web應(yīng)用開發(fā)工程師案例手冊(cè)----財(cái)務(wù)報(bào)銷管理系統(tǒng)一、項(xiàng)目需求分析1、項(xiàng)目背景描述某學(xué)院的財(cái)務(wù)部門,現(xiàn)在感覺到本院的財(cái)務(wù)支出管理有點(diǎn)混亂,對(duì)于個(gè)別業(yè)務(wù)部門存在任意開支的現(xiàn)象,所以希望通過網(wǎng)上統(tǒng)一登記報(bào)銷細(xì)目的形式,財(cái)務(wù)主管和院領(lǐng)導(dǎo)可以隨時(shí)掌握學(xué)院的經(jīng)費(fèi)支出情況。學(xué)院的財(cái)務(wù)形式描述如下:每年學(xué)院的國家撥款及各類收入都按照各個(gè)業(yè)務(wù)部門的預(yù)算,劃成分類的賬號(hào),所有的支出都按照其所發(fā)生的業(yè)務(wù)性質(zhì)所屬賬號(hào)進(jìn)行報(bào)銷。各個(gè)賬號(hào)有相應(yīng)的負(fù)責(zé)人和出納,有的負(fù)責(zé)人會(huì)有多個(gè)賬號(hào)的支配權(quán)限,有的出納可以操作多個(gè)賬號(hào),只要業(yè)務(wù)相關(guān)即可,這些都是由財(cái)務(wù)主管來分配。用戶已經(jīng)提供原始表格,一期任務(wù)把該表格實(shí)現(xiàn)網(wǎng)上填報(bào)即可。財(cái)務(wù)主管可以看到全院所有的報(bào)銷信息,財(cái)務(wù)助理只能看到自己錄入的信息。所有的記錄應(yīng)可以導(dǎo)出Excel表格。2、需求概要分析(1)、用戶和角色權(quán)限部分:財(cái)務(wù)主管維護(hù)系統(tǒng)用戶,并為用戶指定角色,用戶的初始化密碼和證件號(hào)相同,各用戶自己登陸后可修改密碼。角色分為三類:、出納:可以對(duì)自己被授權(quán)的賬號(hào)進(jìn)行報(bào)銷記錄的維護(hù);、賬號(hào)負(fù)責(zé)人:可以對(duì)自己被授權(quán)的賬號(hào)進(jìn)行查詢,不能做新增、修改、刪除等操作;、財(cái)務(wù)主管:可以查詢、維護(hù)全院所有賬號(hào)的報(bào)銷記錄;(2)、報(bào)銷記錄維護(hù):填寫報(bào)銷記錄時(shí),需要記錄摘要、費(fèi)用類型、經(jīng)辦人、所屬賬號(hào)、記錄人、記錄時(shí)間、處理方式等信息。參考用戶提供的原始表格。為規(guī)范填寫,費(fèi)用記錄、處理方式都做標(biāo)準(zhǔn)化處理,財(cái)務(wù)主管維護(hù)代碼表后,出納錄入時(shí)選擇錄入。為避免賬號(hào)填寫錯(cuò)誤,出納錄入時(shí),賬號(hào)信息也是選擇方式錄入,每個(gè)出納只能列出自己被授權(quán)的賬號(hào)。(3)、報(bào)銷記錄查詢根據(jù)賬號(hào)、費(fèi)用類型、金額范圍等字段進(jìn)行查詢。出納和賬號(hào)負(fù)責(zé)人只能查詢到自己被授權(quán)的賬號(hào)的報(bào)銷記錄。財(cái)務(wù)主管可以看到所有賬號(hào)的報(bào)銷記錄。查詢結(jié)果最下方,需要對(duì)金額字段做匯總。查詢結(jié)果應(yīng)該能導(dǎo)出Excel3、開發(fā)技術(shù)參數(shù)數(shù)據(jù)庫采用Oracle;系統(tǒng)架構(gòu)采用Struts+Spring+Hibernate;涉及開發(fā)環(huán)境和工具:JDK1.5、Eclipse(MyEclipse)、Resin3.0.19(Tomcat5.5以上亦可)、Dreamweaver、Oracle數(shù)據(jù)庫及客戶端;二、系統(tǒng)功能設(shè)計(jì)1、用戶維護(hù)只有財(cái)務(wù)主管才有用戶維護(hù)的功能。新加用戶按鈕修改用戶刪除用戶選擇序號(hào)用戶名角色C新加用戶按鈕修改用戶刪除用戶選擇序號(hào)用戶名角色Checkbox12001230001出納Checkbox22001580610賬號(hào)負(fù)責(zé)人Checkbox3…………說明:1、選中某條記錄,可以進(jìn)行修改,每次只能修改一條記錄;2、刪除可以批量進(jìn)行,可以選中多條記錄進(jìn)行刪除;3、點(diǎn)新加用戶按鈕后,跳轉(zhuǎn)到下頁的新加用戶界面;報(bào)銷維護(hù)賬號(hào)授權(quán)賬號(hào)維護(hù)處理方式維護(hù)費(fèi)用類型維護(hù)用戶維護(hù)退出Banner(財(cái)務(wù)主管)---用戶維護(hù)新加用戶頁面新加用戶頁面用戶登陸名:__________用戶姓名:____________角色:__________(select)保存按鈕說明:1、角色的下拉選項(xiàng)有出納、賬號(hào)負(fù)責(zé)人兩類;2、保存用戶時(shí),應(yīng)檢測(cè)該用戶名是否已經(jīng)存在,如果存在,則返回本頁面并給出相應(yīng)提示;3、用戶名應(yīng)當(dāng)是用戶證件號(hào);2、賬號(hào)維護(hù)新加賬號(hào)頁面新加賬號(hào)頁面賬號(hào):_____________賬號(hào)名稱:__________賬號(hào)負(fù)責(zé)人:_______賬號(hào)狀態(tài):__________(select)備注:_______________________________________________保存按鈕說明:賬號(hào)狀態(tài)是指:正常、關(guān)閉兩種狀態(tài)Banner(財(cái)務(wù)主管)---賬號(hào)維護(hù)Banner(財(cái)務(wù)主管)---賬號(hào)維護(hù)報(bào)銷維護(hù)賬號(hào)授權(quán)賬號(hào)維護(hù)處理方式維護(hù)費(fèi)用類型維護(hù)用戶維護(hù)退出新加賬號(hào)按鈕修改賬號(hào)刪除賬號(hào)選擇序號(hào)賬號(hào)賬號(hào)名稱賬號(hào)負(fù)責(zé)人賬號(hào)狀態(tài)備注Checkbox11000010001日常辦公賬號(hào)張華正常Checkbox23000020005學(xué)生活動(dòng)經(jīng)費(fèi)李軍正常Checkbox3…………說明:1、選中某條記錄,可以進(jìn)行修改,每次只能修改一條記錄;2、刪除可以批量進(jìn)行,可以選中多條記錄進(jìn)行刪除;3、點(diǎn)新加用戶按鈕后,跳轉(zhuǎn)到上頁的新加賬號(hào)界面;3、報(bào)銷處理方式維護(hù)Banner(財(cái)務(wù)主管)---Banner(財(cái)務(wù)主管)---報(bào)銷處理方式維護(hù)報(bào)銷維護(hù)賬號(hào)授權(quán)賬號(hào)維護(hù)處理方式維護(hù)費(fèi)用類型維護(hù)用戶維護(hù)退出新加處理方式按鈕修改刪除選擇序號(hào)處理方式Checkbox1已領(lǐng)現(xiàn)金Checkbox2已領(lǐng)支票Checkbox3……說明:1、選中某條記錄,可以進(jìn)行修改,每次只能修改一條記錄;2、刪除可以批量進(jìn)行,可以選中多條記錄進(jìn)行刪除;3、點(diǎn)新加處理方式按鈕后,跳轉(zhuǎn)到下頁的新加處理方式界面;新加處理方式新加處理方式頁面處理方式:__________保存按鈕說明:保存的時(shí)候,要檢測(cè)該處理方式是否已經(jīng)存在,如果已經(jīng)存在,需要返回本頁并給出提示;4、費(fèi)用類型維護(hù)Banner(財(cái)務(wù)主管)---費(fèi)用類型維護(hù)Banner(財(cái)務(wù)主管)---費(fèi)用類型維護(hù)報(bào)銷維護(hù)賬號(hào)授權(quán)賬號(hào)維護(hù)處理方式維護(hù)費(fèi)用類型維護(hù)用戶維護(hù)退出新加費(fèi)用類型按鈕修改刪除選擇序號(hào)費(fèi)用代碼費(fèi)用類型費(fèi)用說明Checkbox101辦公費(fèi)……Checkbox202郵電費(fèi)……Checkbox3……說明:1、選中某條記錄,可以進(jìn)行修改,每次只能修改一條記錄;2、刪除可以批量進(jìn)行,可以選中多條記錄進(jìn)行刪除;3、點(diǎn)新加處理方式按鈕后,跳轉(zhuǎn)到下頁的新加處理方式界面;新加費(fèi)用類型新加費(fèi)用類型費(fèi)用代碼:______費(fèi)用類型:_____________費(fèi)用說明:____________________________________(textarea)保存按鈕說明:1、保存的時(shí)候,要檢測(cè)該費(fèi)用類型是否已經(jīng)存在,如果已經(jīng)存在,需要返回本頁并給出提示;2、費(fèi)用代碼、費(fèi)用類型、費(fèi)用說明均為必填項(xiàng);5、賬號(hào)授權(quán)報(bào)銷維護(hù)賬號(hào)授權(quán)報(bào)銷維護(hù)賬號(hào)授權(quán)賬號(hào)維護(hù)處理方式維護(hù)費(fèi)用類型維護(hù)用戶維護(hù)退出Banner(財(cái)務(wù)主管)---賬號(hào)授權(quán)新加賬號(hào)授權(quán)新加賬號(hào)授權(quán)按鈕修改刪除賬號(hào)_______授權(quán)人______查詢按鈕選擇序號(hào)賬號(hào)授權(quán)人Checkbox11000010001張華Checkbox21000010002李磊說明:1、選中某條記錄,可以進(jìn)行修改,每次只能修改一條記錄;2、刪除可以批量進(jìn)行,可以選中多條記錄進(jìn)行刪除;3、點(diǎn)新加按鈕后,跳轉(zhuǎn)到下頁的新賬號(hào)授權(quán)界面;4、點(diǎn)下查詢按鈕后,本頁顯示查詢結(jié)果;新建賬號(hào)授權(quán)頁新建賬號(hào)授權(quán)頁賬號(hào):________(select)授權(quán)人:_________(select)保存說明:1、賬號(hào)的下拉框是從賬號(hào)表中讀出;2、授權(quán)人的下拉框是從用戶表中讀出,顯示用戶的真實(shí)姓名,存盤時(shí)存用戶的zjh;Banner—Banner—報(bào)銷維護(hù)首頁報(bào)銷維護(hù)報(bào)銷維護(hù)賬號(hào)授權(quán)賬號(hào)維護(hù)處理方式維護(hù)費(fèi)用類型維護(hù)用戶維護(hù)退出新加修改刪除新加修改刪除賬號(hào):_____(select)金額范圍____至____報(bào)銷時(shí)間_____至_____費(fèi)用類型:______(select)處理方式:_______(select)查詢按鈕選擇序號(hào)摘要費(fèi)用類型處理方式金額經(jīng)辦人記錄人報(bào)銷時(shí)間備注合計(jì):***----------------------------------------------------------------------------說明:1、賬號(hào)是當(dāng)前用戶被授權(quán)的所有賬號(hào)下拉選擇;2、費(fèi)用類型、處理方式都是下拉列表;3、頁面底部是當(dāng)頁的金額合計(jì)新加報(bào)銷記錄頁新加報(bào)銷記錄頁賬號(hào):________(select)金額:____________摘要:________費(fèi)用類型:______(select)處理方式:________(select)報(bào)銷時(shí)間:____________經(jīng)辦人:_____________保存按鈕說明:1、存盤的時(shí)候,自動(dòng)保存當(dāng)前用戶為錄入人;2、金額框,只能輸入數(shù)值型;三、數(shù)據(jù)庫設(shè)計(jì)1、報(bào)銷明細(xì)表2、用戶表3、費(fèi)用類型4、賬號(hào)5、賬號(hào)授權(quán)四、運(yùn)行結(jié)果實(shí)例用戶登錄報(bào)銷記錄列表賬號(hào)授權(quán)結(jié)果導(dǎo)出Excel刪除之前必須進(jìn)行詢問與確認(rèn)賬號(hào)維護(hù)用戶管理報(bào)銷處理方式的維護(hù)費(fèi)用類型維護(hù)五、重點(diǎn)代碼剖析Struts-config.xml<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEstruts-configPUBLIC"-//ApacheSoftwareFoundation//DTDStrutsConfiguration1.2//EN""/dtds/struts-config_1_2.dtd"><struts-config><data-sources/><form-beans><form-beanname="loginForm"type=".thcic.demo.form.LoginForm"/><form-beanname="zhForm"type=".thcic.demo.form.ZhForm"/><form-beanname="bxListForm"type=".thcic.demo.form.BxListForm"/><form-beanname="fylxForm"type=".thcic.demo.form.FylxForm"/><form-beanname="clfsForm"type=".thcic.demo.form.ClfsForm"/><form-beanname="zhsqForm"type=".thcic.demo.form.ZhsqForm"/><form-beanname="bxmxForm"type=".thcic.demo.form.BxmxForm"/><form-beanname="cwUserForm"type=".thcic.demo.form.CwUserForm"/><form-beanname="testForm"type=".thcic.demo.form.TestForm"/></form-beans><global-exceptions/><global-forwards/><action-mappings><actionattribute="loginForm"input="/login.jsp"name="loginForm"path="/login"scope="request"type=".thcic.demo.action.LoginAction"><forwardname="loginSuccess"path="/bxmx.do?method=list"/><forwardname="loginError"path="/error.jsp"/></action><actionattribute="bxmxForm"input="/bxmxList.jsp"parameter="method"name="bxmxForm"path="/bxmx"scope="request"type=".thcic.demo.action.BxmxAction"><forwardname="success"path="/bxmxList.jsp"/></action><actionattribute="zhForm"name="zhForm"parameter="method"path="/zh"scope="request"type=".thcic.demo.action.ZhAction"><forwardname="success"path="/zh.jsp"/></action><actionattribute="fylxForm"input="/fylxAdd.jsp"name="fylxForm"parameter="method"path="/fylx"scope="request"type=".thcic.demo.action.FylxAction"><forwardname="success"path="/fylx.jsp"/></action><actionattribute="clfsForm"input="/clfsadd.jsp"name="clfsForm"parameter="method"path="/clfs"scope="request"type=".thcic.demo.action.ClfsAction"><forwardname="success"path="/clfs.jsp"/></action><actionattribute="zhsqForm"input="/zhsq.jsp"parameter="method"name="zhsqForm"path="/zhsq"scope="request"type=".thcic.demo.action.ZhsqAction"><forwardname="success"path="/zhsq.jsp"/></action><actionattribute="cwUserForm"input="/cwUserAdd.jsp"name="cwUserForm"parameter="method"path="/cwUser"scope="request"type=".thcic.demo.action.CwUserAction"><forwardname="success"path="/user.jsp"/></action></action-mappings><message-resourcesparameter=".thcic.demo.ApplicationResources"/></struts-config>Web.xml<?xmlversion="1.0"encoding="UTF-8"?><web-app> <!--設(shè)置請(qǐng)求編碼過濾器--> <filter> <filter-name>EncodeFilter</filter-name> <filter-class>.thcic.demo.util.ReqEncodeFilter</filter-class> <init-param> <!--設(shè)置請(qǐng)求編碼類型--> <param-name>RequestEncode</param-name> <param-value>GBK</param-value> </init-param> </filter> <!--請(qǐng)求編碼過濾器與網(wǎng)址映射--> <filter-mapping> <filter-name>EncodeFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping><servlet><servlet-name>action</servlet-name><servlet-class>org.apache.struts.action.ActionServlet</servlet-class><init-param><param-name>config</param-name><param-value>/WEB-INF/struts-config.xml</param-value></init-param><init-param><param-name>debug</param-name><param-value>3</param-value></init-param><init-param><param-name>detail</param-name><param-value>3</param-value></init-param><load-on-startup>0</load-on-startup></servlet><servlet-mapping><servlet-name>action</servlet-name><url-pattern>*.do</url-pattern></servlet-mapping><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>//報(bào)銷明細(xì)的Actionpackage.thcic.demo.action;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.apache.struts.action.ActionForm;importorg.apache.struts.action.ActionForward;importorg.apache.struts.action.ActionMapping;importorg.apache.struts.actions.DispatchAction;import.thcic.demo.bo.BxmxService;import.thcic.demo.bo.ClfsService;import.thcic.demo.bo.FylxService;import.thcic.demo.bo.ZhsqService;import.thcic.demo.form.BxmxForm;import.thcic.demo.vo.Bxmx;import.thcic.demo.vo.CwUser;publicclassBxmxActionextendsDispatchAction{ //報(bào)銷明細(xì)的列表 publicActionForwardlist(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ getListData(request); returnmapping.findForward("success"); }//獲得列表需要顯示的數(shù)據(jù) privatevoidgetListData(HttpServletRequestrequest){ BxmxServicebxmxService=newBxmxService(); ZhsqServicezhsqService=newZhsqService(); FylxServicefylxService=newFylxService(); ClfsServiceclfsService=newClfsService(); CwUseruser=(CwUser)request.getSession().getAttribute("user"); //找到當(dāng)前用戶有權(quán)限看到的所有報(bào)銷記錄 request.setAttribute("bxmxList",bxmxService.getUserBxmx(user)); //找到當(dāng)前用戶被授權(quán)的全部賬號(hào) request.setAttribute("zhList",zhsqService.getUserZhList(user)); //費(fèi)用類型列表 request.setAttribute("fylxList",fylxService.getAllFylxList()); //處理方式列表 request.setAttribute("clfsList",clfsService.getAllClfsList()); } //新加報(bào)銷明細(xì) publicActionForwardsaveOrUpdate(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ BxmxFormbxmxForm=(BxmxForm)form; //把form里的屬性賦值給mx實(shí)體 Bxmxmx=newBxmx(); if(bxmxForm.getId()!=null&&bxmxForm.getId().trim()!=""&&bxmxForm.getId().length()>0){ mx.setId(Long.parseLong(bxmxForm.getId())); } mx.setFylx(bxmxForm.getFylx()); mx.setJe(Double.parseDouble(bxmxForm.getJe())); mx.setBxsj(bxmxForm.getBxsj()); mx.setClfs(bxmxForm.getClfs()); mx.setBz(bxmxForm.getBz()); mx.setJbr(bxmxForm.getJbr()); mx.setJlr(((CwUser)request.getSession().getAttribute("user")).getUsername()); mx.setZh(bxmxForm.getZh()); mx.setZy(bxmxForm.getZy()); newBxmxService().saveOrUpdateClfs(mx); //做好返回?cái)?shù)據(jù)準(zhǔn)備 this.getListData(request); bxmxForm.reset(mapping,request); returnmapping.findForward("success"); } //刪除報(bào)銷明細(xì) publicActionForwarddelete(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ BxmxServicebxmxService=newBxmxService(); Stringid=request.getParameter("id"); Bxmxmx=bxmxService.getBxmxById(id); bxmxService.delBxmx(mx); this.getListData(request); returnmapping.findForward("success"); } /** *編輯某條記錄 **/ publicActionForwardtoEdit(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ BxmxFormbxmxForm=(BxmxForm)form; BxmxServicebxmxService=newBxmxService(); Stringid=request.getParameter("id"); Bxmxmx=bxmxService.getBxmxById(id); bxmxForm.setBxsj(mx.getBxsj()); bxmxForm.setBz(mx.getBz()); bxmxForm.setClfs(mx.getClfs()); bxmxForm.setFylx(mx.getFylx()); bxmxForm.setId(String.valueOf(mx.getId())); bxmxForm.setJbr(mx.getJbr()); bxmxForm.setJe(String.valueOf(mx.getJe())); bxmxForm.setJlr(mx.getJlr()); bxmxForm.setZy(mx.getZy()); bxmxForm.setZh(mx.getZh()); this.getListData(request); returnmapping.findForward("success"); } }package.thcic.demo.action;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.apache.struts.action.ActionForm;importorg.apache.struts.action.ActionForward;importorg.apache.struts.action.ActionMapping;importorg.apache.struts.actions.DispatchAction;import.thcic.demo.bo.ClfsService;import.thcic.demo.form.ClfsForm;import.thcic.demo.vo.Clfs;publicclassClfsActionextendsDispatchAction{ publicActionForwardlist(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ClfsFormclfsForm=(ClfsForm)form; ClfsServiceclfsService=newClfsService(); request.setAttribute("clfsList",clfsService.getAllClfsList()); returnmapping.findForward("success"); } publicActionForwardsaveOrUpdate(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ClfsFormclfsForm=(ClfsForm)form; ClfsServiceclfsService=newClfsService(); Clfsclfs=newClfs(); clfs.setClfs(clfsForm.getClfs()); if(clfsForm.getId()!=null&&clfsForm.getId().trim()!=""&&clfsForm.getId().length()>0){ clfs.setId(Long.parseLong(clfsForm.getId())); } clfsService.saveOrUpdateClfs(clfs); request.setAttribute("clfsList",clfsService.getAllClfsList()); clfsForm.reset(mapping,request); returnmapping.findForward("success"); } /** *編輯某條記錄 **/ publicActionForwardtoEdit(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ClfsFormclfsForm=(ClfsForm)form; ClfsServiceclfsService=newClfsService(); Stringid=request.getParameter("id"); Clfsclfs=clfsService.getClfsByID(id); clfsForm.setClfs(clfs.getClfs()); clfsForm.setId(String.valueOf(clfs.getId())); request.setAttribute("clfsList",clfsService.getAllClfsList()); returnmapping.findForward("success"); } publicActionForwarddelete(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ClfsFormclfsForm=(ClfsForm)form; ClfsServiceclfsService=newClfsService(); Stringid=request.getParameter("id"); Clfsclfs=clfsService.getClfsByID(id); clfsService.delClfs(clfs); request.setAttribute("clfsList",clfsService.getAllClfsList()); clfsForm.reset(mapping,request); returnmapping.findForward("success"); }}package.thcic.demo.action;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.apache.struts.action.ActionForm;importorg.apache.struts.action.ActionForward;importorg.apache.struts.action.ActionMapping;importorg.apache.struts.actions.DispatchAction;import.thcic.demo.bo.UserService;import.thcic.demo.form.CwUserForm;import.thcic.demo.vo.CwUser;publicclassCwUserActionextendsDispatchAction{ //用戶列表 publicActionForwardlist(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ CwUserFormcwUserForm=(CwUserForm)form; UserServiceuserService=newUserService(); request.setAttribute("userList",userService.getUserList()); returnmapping.findForward("success"); } //新加用戶 publicActionForwardsaveOrUpdate(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ CwUserFormcwUserForm=(CwUserForm)form; UserServiceuserService=newUserService(); CwUseruser=newCwUser(); if(cwUserForm.getId()!=null&&cwUserForm.getId().trim()!=""&&cwUserForm.getId().length()>0){ user.setId(Long.parseLong(cwUserForm.getId())); } user.setUsername(cwUserForm.getUsername()); user.setRealname(cwUserForm.getRealname()); user.setRole(cwUserForm.getRole()); userService.saveOrUpdate(user); request.setAttribute("userList",userService.getUserList()); cwUserForm.reset(mapping,request); returnmapping.findForward("success"); } /** *編輯某條記錄 **/ publicActionForwardtoEdit(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ CwUserFormcwUserForm=(CwUserForm)form; UserServiceuserService=newUserService(); Stringid=request.getParameter("id"); CwUseruser=userService.getUserById(id); cwUserForm.setUsername(user.getUsername()); cwUserForm.setRealname(user.getRealname()); cwUserForm.setRole(user.getRole()); request.setAttribute("userList",userService.getUserList()); returnmapping.findForward("success"); } //刪除用戶 publicActionForwarddelete(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ CwUserFormcwUserForm=(CwUserForm)form; UserServiceuserService=newUserService(); Stringid=request.getParameter("id"); CwUseruser=userService.getUserById(id); userService.delUser(user); request.setAttribute("userList",userService.getUserList()); cwUserForm.reset(mapping,request); returnmapping.findForward("success"); }}package.thcic.demo.action;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.apache.struts.action.ActionForm;importorg.apache.struts.action.ActionForward;importorg.apache.struts.action.ActionMapping;importorg.apache.struts.actions.DispatchAction;import.thcic.demo.bo.FylxService;import.thcic.demo.form.FylxForm;import.thcic.demo.vo.Fylx;publicclassFylxActionextendsDispatchAction{ publicActionForwardlist(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ FylxFormfylxForm=(FylxForm)form; getFylxList(request); returnmapping.findForward("success"); } privatevoidgetFylxList(HttpServletRequestrequest){ //獲得所有費(fèi)用類型的列表 FylxServicefylxService=newFylxService(); request.setAttribute("fylxList",fylxService.getAllFylxList()); } publicActionForwardsaveOrUpdate(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ FylxFormfylxForm=(FylxForm)form; Fylxfylx=newFylx(); if(fylxForm.getId()!=null&&fylxForm.getId().trim()!=""&&fylxForm.getId().length()>0){ fylx.setId(Long.parseLong(fylxForm.getId())); } fylx.setFylx(fylxForm.getFylx()); fylx.setFylxsm(fylxForm.getFylxsm()); FylxServicefylxService=newFylxService(); fylxService.saveOrUpdate(fylx); getFylxList(request); returnmapping.findForward("success"); } publicActionForwarddelete(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ FylxFormfylxForm=(FylxForm)form; FylxServicefylxService=newFylxService(); Stringid=request.getParameter("id");Fylxfylx=fylxService.getFylxById(id) ; fylxService.delFylx(fylx); getFylxList(request); returnmapping.findForward("success"); } /** *編輯某條記錄 **/ publicActionForwardtoEdit(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ FylxFormfylxForm=(FylxForm)form; FylxServicefylxService=newFylxService(); Stringid=request.getParameter("id");Fylxfylx=fylxService.getFylxById(id) ;fylxForm.setFylx(fylx.getFylx());fylxForm.setFylxsm(fylx.getFylxsm());fylxForm.setId(String.valueOf(fylx.getId())); getFylxList(request); returnmapping.findForward("success"); }}package.thcic.demo.action;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.apache.struts.action.Action;importorg.apache.struts.action.ActionForm;importorg.apache.struts.action.ActionForward;importorg.apache.struts.action.ActionMapping;import.thcic.demo.bo.UserService;import.thcic.demo.form.LoginForm;import.thcic.demo.vo.CwUser;publicclassLoginActionextendsAction{ publicActionForwardexecute(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ LoginFormloginForm=(LoginForm)form; UserServiceuserService=newUserService(); //構(gòu)造VO實(shí)體 CwUseruser=newCwUser(); user.setUsername(loginForm.getUsername()); user.setPassword(loginForm.getPassword()); if(userService.isCwUser(user)){ //如果是財(cái)務(wù)報(bào)銷系統(tǒng)的用戶,得到完整的用戶對(duì)象,裝入session request.getSession().setAttribute("user",userService.getCwUser(user)); returnmapping.findForward("loginSuccess"); }else{ request.getSession().setAttribute("errorMessage","登陸用戶名或密碼錯(cuò)誤!"); returnmapping.findForward("loginError"); } }}package.thcic.demo.action;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.apache.struts.action.ActionForm;importorg.apache.struts.action.ActionForward;importorg.apache.struts.action.ActionMapping;importorg.apache.struts.actions.DispatchAction;import.thcic.demo.bo.ZhService;import.thcic.demo.form.ZhForm;import.thcic.demo.vo.Zh;publicclassZhActionextendsDispatchAction{ publicActionForwardlist(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ZhFormzhForm=(ZhForm)form; ZhServicezhService=newZhService(); request.setAttribute("zhList",zhService.getAllZhList()); returnmapping.findForward("success"); } /** *賬號(hào)新加 **/ publicActionForwardsaveOrUpdate(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ZhFormzhForm=(ZhForm)form; ZhServicezhService=newZhService(); Zhzh=newZh(); zh.setBz(zhForm.getBz()); zh.setZh(zhForm.getZh()); zh.setZhfzr(zhForm.getZhfzr()); zh.setZhmc(zhForm.getZhmc()); zh.setZhzt(zhForm.getZhzt()); if(zhForm.getId()!=null&&zhForm.getId().trim()!=""&&zhForm.getId().length()>0){ zh.setId(Long.parseLong(zhForm.getId())); } zhService.saveOrUpdate(zh); request.setAttribute("zhList",zhService.getAllZhList()); zhForm.reset(mapping,request); returnmapping.findForward("success"); } /** *編輯某條記錄 **/ publicActionForwardtoEdit(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ZhFormzhForm=(ZhForm)form; ZhServicezhService=newZhService(); Stringid=request.getParameter("id"); Zhzh=zhService.getZhById(id); zhForm.setZh(zh.getZh()); zhForm.setId(String.valueOf(zh.getId())); zhForm.setZhfzr(zh.getZhfzr()); zhForm.setZhmc(zh.getZhmc()); zhForm.setZhzt(zh.getZhzt()); request.setAttribute("zhList",zhService.getAllZhList()); returnmapping.findForward("success"); } /** *賬號(hào)刪除 **/ publicActionForwarddelete(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ZhFormzhForm=(ZhForm)form; ZhServicezhService=newZhService(); Stringid=request.getParameter("id"); Zhzh=zhService.getZhById(id); zhService.delZh(zh); request.setAttribute("zhList",zhService.getAllZhList()); returnmapping.findForward("success"); } }package.thcic.demo.action;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.apache.struts.action.ActionForm;importorg.apache.struts.action.ActionForward;importorg.apache.struts.action.ActionMapping;importorg.apache.struts.actions.DispatchAction;import.thcic.demo.bo.ZhService;import.thcic.demo.bo.ZhsqService;import.thcic.demo.form.ZhsqForm;import.thcic.demo.vo.Zhsq;publicclassZhsqActionextendsDispatchAction{ publicActionForwardlist(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ZhsqFormzhsqForm=(ZhsqForm)form; ZhsqServicezhsqService=newZhsqService(); ZhServicezhService=newZhService(); request.setAttribute("zhsqList",zhsqService.getZhsqList()); request.setAttribute("zhList",zhService.getAllZhList()); returnmapping.findForward("success"); } publicActionForwardsaveOrUpdate(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ZhsqFormzhsqForm=(ZhsqForm)form; ZhsqServicezhsqService=newZhsqService(); Zhsqzhsq=newZhsq(); if(zhsqForm.getId()!=null&&zhsqForm.getId().trim()!=""&&zhsqForm.getId().length()>0){ zhsq.setId(Long.parseLong(zhsqForm.getId())); } zhsq.setUsername(zhsqForm.getUsername()); zhsq.setZh(zhsqForm.getZh()); zhsqService.saveOrUpdate(zhsq); request.setAttribute("zhsqList",zhsqService.getZhsqList()); zhsqForm.reset(mapping,request); returnmapping.findForward("success"); } /** *編輯某條記錄 **/ publicActionForwardtoEdit(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ZhsqFormzhsqForm=(ZhsqForm)form; ZhsqServicezhsqService=newZhsqService(); Stringid=request.getParameter("id"); Zhsqzhsq=zhsqService.getZhsqByID(id); zhsqForm.setZh(zhsq.getZh()); zhsqForm.setId(String.valueOf(zhsq.getId())); zhsqForm.setUsername(zhsq.getUsername()); request.setAttribute("zhsqList",zhsqService.getZhsqList()); returnmapping.findForward("success"); } publicActionForwarddelete(ActionMappingmapping,ActionFormform, HttpServletRequestrequest,HttpServletResponseresponse){ ZhsqFormzhsqForm=(ZhsqForm)form; ZhsqServicezhsqService=newZhsqService(); Stringid=request.getParameter("id"); Zhsqzhsq=zhsqService.getZhsqByID(id); zhsqService.delZhsq(zhsq); request.setAttribute("zhsqList",zhsqService.getZhsqList()); returnmapping.findForward("success"); }}package.thcic.demo.bo;importjava.util.ArrayList;importjava.util.List;importorg.hibernate.Transaction;import.thcic.demo.dao.BxmxDAO;import.thcic.demo.vo.Bxmx;import.thcic.demo.vo.CwUser;import.thcic.demo.vo.Zhsq;publicclassBxmxService{ //返回某用戶所有可以看到的報(bào)銷明細(xì)記錄 publicList<Bxmx>getUserBxmx(CwUseruser){ List<Bxmx>bxmxList=newArrayList<Bxmx>(); BxmxDAObxmxDao=newBxmxDAO(); if(user.getRole().equals("財(cái)務(wù)主管")){ bxmxList=bxmxDao.findAll(); }else{ //先獲得該用戶所有被授權(quán)的賬號(hào)列表 ZhsqServicezhsqService=newZhsqService(); List<Zhsq>zhsqList=zhsqService.getUserZh(user.getUsername()); for(Zhsqsq:zhsqList){ Bxmxmx=newBxmx(); mx.setZh(sq.getZh()); //找到每個(gè)賬號(hào)的報(bào)銷明細(xì),添加到返回列表中 List<Bxmx>mxList=bxmxDao.findByExample(mx); for(Bxmxbxmx:mxList){ bxmxList.add(bxmx); } } } returnbxmxList; } // //新增一個(gè)報(bào)銷明細(xì)記錄// publicvoidaddBxmx(Bxmxmx){// BxmxDAOmxDao=newBxmxDAO();// Transactiontran=null;// try{// tran=mxDao.getSession().beginTransaction();// mxDao.save(mx);// mxDao.getSession().flush();// mit();// }catch(Exceptione){// e.printStackTrace();// }// } //刪除一個(gè)報(bào)銷明細(xì)記錄 publicvoiddelBxmx(Bxmxmx){ BxmxDAOmxDao=newBxmxDAO(); Transactiontran=null; try{ tran=mxDao.getSession().beginTransaction(); mxDao.delete(mx); mxDao.getSession().flush(); mit(); }catch(Exceptione){ e.printStackTrace(); } } //添加或者修改一條記錄 publicvoidsaveOrUpdateClfs(Bxmxbxmx){ BxmxDAOmxDao=newBxmxDAO(); Transactiontran=null; try{ tran=mxDao.getSession().beginTransaction(); if(bxmx.getId()==null||bxmx.getId()==0){ mxDao.save(bxmx); }else{ mxDao.getSession().clear(); mxDao.update(bxmx); } mxDao.getSession().flush(); mit(); }catch(Exceptione){ e.printStackTrace(); } } /** *根據(jù)ID獲得一個(gè)報(bào)銷記錄
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024版石灰石供應(yīng)合同模板
- 二零二五年度應(yīng)急管理及救援裝備租賃合同3篇
- 2025年度人工智能專利池共享與許可合同3篇
- 2025年度城市公共交通設(shè)施建設(shè)合同規(guī)范3篇
- 二零二四年商業(yè)地產(chǎn)項(xiàng)目新型業(yè)態(tài)招商代理服務(wù)合同樣本3篇
- 年度芳香除臭化學(xué)品:空氣清新劑產(chǎn)業(yè)分析報(bào)告
- 2025年新型材料現(xiàn)貨購銷合同標(biāo)準(zhǔn)范本3篇
- 2024-2025學(xué)年高中歷史第二單元古希臘和古羅馬的政治制度單元總結(jié)學(xué)案含解析岳麓版必修1
- 2025年度校園配送服務(wù)食品安全快速檢測(cè)質(zhì)量管理體系建設(shè)合同3篇
- 2025年度人工智能算法工程師保密協(xié)議及知識(shí)產(chǎn)權(quán)保護(hù)合同3篇
- 寺廟祈?;顒?dòng)方案(共6篇)
- 2025年病案編碼員資格證試題庫(含答案)
- 企業(yè)財(cái)務(wù)三年戰(zhàn)略規(guī)劃
- 提高膿毒性休克患者1h集束化措施落實(shí)率
- 山東省濟(jì)南市天橋區(qū)2024-2025學(xué)年八年級(jí)數(shù)學(xué)上學(xué)期期中考試試題
- 主播mcn合同模板
- 新疆2024年中考數(shù)學(xué)試卷(含答案)
- 2024測(cè)繪個(gè)人年終工作總結(jié)
- DB11 637-2015 房屋結(jié)構(gòu)綜合安全性鑒定標(biāo)準(zhǔn)
- 制造業(yè)生產(chǎn)流程作業(yè)指導(dǎo)書
- DB34∕T 4444-2023 企業(yè)信息化系統(tǒng)上云評(píng)估服務(wù)規(guī)范
評(píng)論
0/150
提交評(píng)論