软件工程短学期实践即将接近尾声,我们的软件工程项目也已趋于完成。
软件工程短学期实践项目:
这是一个简单的客户信息管理维护软件,它能把客户编号、客户姓名、客户电话和客户性别保存在数据库之中,我们可以在数据库中查询保存的客户信息,还可以随时修改以及删除客户信息。
随后,我们在老师的指导下,开始自己修改设计软件,我做的是库存管理项目,代码如下:
package com.crm.action; import java.util.Map; import com.crm.bean.Item; import com.crm.service.ItemService; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class FindItemByCdtAction extends ActionSupport { private Item item; private ItemService findCdtService; public Item getItem() { return item; } public void setItem(Item item) { this.item = item; } public ItemService getFindCdtService() { return findCdtService; } public void setFindCdtService(ItemService findCdtService) { this.findCdtService = findCdtService; } @SuppressWarnings({ "unchecked", "unchecked" }) @Override public String execute() throws Exception { // TODO Auto-generated method stub Map map=(Map)ActionContext.getContext().get("request"); map.put("list", this.findCdtService.findItemByCondition(item)); return SUCCESS; } }
package com.crm.action; import java.io.InputStream; import com.crm.service.ItemService; import com.opensymphony.xwork2.ActionSupport; public class GenerateExcelAction extends ActionSupport{ private ItemService excelService; public ItemService getExcelService(){ return excelService; } public void setExcelService(ItemService excelService){ this.excelService =excelService; } public InputStream getDownloadFile(){ return this.excelService.getInputStream(); } @Override public String execute() throws Exception{ //TODO Auto-generated method stub return SUCCESS; } }
package com.crm.action; import com.crm.bean.Item; import com.crm.service.ItemService; import com.opensymphony.xwork2.ActionSupport; public class ItemSaveAction extends ActionSupport { private ItemService service; private Item item; public Item getItem() { return item; } public void setItem(Item item) { this.item = item; } public ItemService getService() { return service; } public void setService(ItemService service) { this.service = service; } @Override public String execute() throws Exception { // TODO Auto-generated method stub this.service.saveItem(item); return SUCCESS; } }
package com.crm.action; import java.util.Map; import com.crm.bean.Item; import com.crm.service.ItemService; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class ListItemAction extends ActionSupport { private ItemService service; private Item item; public void setService(ItemService service) { this.service=service; } @Override public String execute() throws Exception { // TODO Auto-generated method stub Map map=(Map)ActionContext.getContext().get("request"); map.put("list", this.service.findAllItem()); return SUCCESS; } public Item getItem() { return item; } public void setItem(Item item) { this.item = item; } }
package com.crm.action; import com.crm.bean.Item; import com.crm.service.ItemService; import com.opensymphony.xwork2.ActionSupport; public class RemoveItemAction extends ActionSupport { private Item item; private ItemService service; public Item getItem() { return item; } public void setItem(Item item) { this.item = item; } public ItemService getService() { return service; } public void setService(ItemService service) { this.service = service; } @Override public String execute() throws Exception { // TODO Auto-generated method stub this.service.removeItem(item); return SUCCESS; } }
package com.crm.action; import java.util.ArrayList; import java.util.List; import com.crm.bean.Item; import com.crm.service.ItemService; import com.opensymphony.xwork2.ActionSupport; public class UpdateItemAction extends ActionSupport { /** * */ private static final long serialVersionUID = 1L; private ItemService updateItemService; private Item item; public ItemService getUpdateItemService() { return updateItemService; } public void setUpdateCustService(ItemService updateItemService) { this.updateItemService = updateItemService; } public Item getItem() { return item; } public void setItem(Item item) { this.item = item; } public String execute() throws Exception { // TODO Auto-generated method stu b //this.customer.setCustsex(this.strList.get(0).toString()); if(item != null){ this.updateItemService.updateItem(item); return SUCCESS; }else{ return ""; } } }
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%> <%@ taglib prefix="s" uri="/struts-tags" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="textml; charset=ISO-8859-1"> <title>库存管理</title> <style> .divcss5{width:600px;height:120px;border:1px solid #000;margin:20px;padding:10px;} body,table{ font-size:12px; } table{ table-layout:fixed; empty-cells:show; border-collapse: collapse; margin:0 auto; } td{ height:30px; } h1,h2,h3{ font-size:12px; margin:0; padding:0; } .table{ border:1px solid #000; color:#000; margin:20px; } .table th { background-repeat:repeat-x; height:30px; } .table td,.table th{ border:1px solid #000; padding:0 1em 0; } .table tr.alter{ background-color:#000; } input{ margin:8px; } </style> <script language="JavaScript" type="text/javascript"> function openwind(){ feature="dialogWidth:650px;dialogHeight:200px;status:no;help:no;scrollbars:no;dialogTop:150;"; window.showModalDialog("custSave.jsp",null,feature); }; function funDelete(){ if(confirm('确定要执行此操作吗?')){ return true; }else{ return false; } } function updatewindow(){ feature="dialogWidth:650px;dialogHeight:200px;status:no;help:no;scrollbars:no;dialogTop:150;"; window.showModalDialog("custUpdate.jsp",null,feature); function funExcel(){ location.href='generateExcel.action'; } }; </script> </head> <body> <CENTER> <center><div><font color="red" size="6">库存管理</font></div></center> <div style="width:20px"></div> <div class="divcss5" id="div1"> <s:form action="listCust" theme="simple"> <div style="width:10px"></div> 商品编号:<s:textfield name="item.itemnumber" label="itemnumber" id="txt1"></s:textfield> 商品名称:<s:textfield name="item.itemname" label="itemname" id="txt2"></s:textfield><br> 商品数量:<s:textfield name="item.itemamount" label="itemnumber" id="txt3"></s:textfield> 商品种类:<s:textfield name="item.itemvariety" label="itemvariety" id="txt4"></s:textfield><br> <div style="width:20px"></div> <input width="100" type = "button" id = "add" name = "btn" value="入库" onClick="openwind()"/> <s:submit action="findCdt" value="查询"> </s:submit> <input width="100" type = "button" id = "rtn" name = "btn" value="返回" onClick="history.go(-1)"/> <input width="100" type = "button" value="生成excel" onClick="funExcel();"/> </s:form> </div> <div style="width:20px"></div> <table border="1" width="47%" class="table"> <tr> <td>商品编号</td> <td>名称</td> <td>品种</td> <td>数量</td> <td>经办人</td> <td>进货渠道</td> <td>入库时间</td> <td width="80">操作</td> </tr> <s:iterator value="#request.list" id="item"> <tr> <td><s:property value="#item.itemnumber"/></td> <td><s:property value="#item.itemname"/></td> <td> <s:if test="#item.itemvariety == 1"> <s:property value="'日用品'"/> </s:if> <s:elseif test="#item.itemvariety == 2"> <s:property value="'数码科技'"/> </s:elseif> <s:elseif test="#item.itemvariety == 3"> <s:property value="'其他'"/> </s:elseif> </td> <td><s:property value="#item.age"/></td> <td><s:property value="#item.itemamount"/></td> <td><s:property value="#item.position"/></td> <td><s:property value="#item.importdate"/></td> <td> <s:a href="updatePreviewitem.action?item.id=%{#item.id}">出库</s:a> <s:a href="deleteitem.action?item.id=%{#item.id}" onClick="return funDelete();">下架</s:a> </td> </tr> </s:iterator> </table> </CENTER> </body> <html>