1. 程式人生 > >軟件工程實踐記錄p2(day4-6)

軟件工程實踐記錄p2(day4-6)

年齡 new array window 界面 back gin css map

前三天只要是搭建平臺,構建鏈接,而這三天的實踐內容則主要是實現數據的新增,刪除,查詢和修改。

技術分享技術分享

com.crm.action.CustSaveAction.java新增信息代碼:

package com.crm.action;

import com.crm.bean.Cust;
import com.crm.service.CustService;
import com.opensymphony.xwork2.ActionSupport;

public class CustSaveAction  extends ActionSupport{
  

    private CustService service;
    
private Cust cust; public Cust getCust() { return cust; } public void setCust(Cust cust) { this.cust = cust; } public CustService getService() { return service; } public void setService(CustService service) { this.service = service; } @Override
public String execute() throws Exception { // TODO Auto-generated method stub this.service.saveCustomer(cust); return SUCCESS; } }

com.crm.action.FindCustByCdtAction.java查詢信息代碼:

package com.crm.action;

import java.util.Map;

import com.crm.bean.Cust;
import com.crm.service.CustService;
import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class FindCustByCdtAction extends ActionSupport{ private Cust cust; private CustService findCdtService; public Cust getCust() { return cust; } public void setCust(Cust cust) { this.cust = cust; } public CustService getFindCdtService() { return findCdtService; } public void setFindCdtService(CustService 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.findCustByCondition(cust)); return SUCCESS; } }

com.crm.action.RemoveCustAction.java刪除信息代碼:

package com.crm.action;

import com.crm.bean.Cust;
import com.crm.service.CustService;
import com.opensymphony.xwork2.ActionSupport;

public class RemoveCustAction extends ActionSupport{
    private Cust cust;
    private CustService service;
    public Cust getCust() {
        return cust;
    }
    public void setCust(Cust cust) {
        this.cust = cust;
    }
    public CustService getService() {
        return service;
    }
    public void setService(CustService service) {
        this.service = service;
    }
    @Override
    public String execute() throws Exception {
        // TODO Auto-generated method stub
        this.service.removeCustomer(cust);
        return SUCCESS;
    }
    

}

com.crm.action.UpdatePreviewCustAction.java更改信息數據代碼:

package com.crm.action;

import com.crm.bean.Cust;
import com.crm.service.CustService;
import com.opensymphony.xwork2.ActionSupport;

public class UpdatePreviewCustAction extends ActionSupport {

    private CustService updatePreviewCustService;
    private Cust customer;

    public Cust getCustomer() {
        return customer;
    }

    public void setCustomer(Cust customer) {
        this.customer = customer;
    }

    public CustService getUpdatePreviewCustService() {
        return updatePreviewCustService;
    }

    public void setUpdatePreviewCustService(CustService updatePreviewCustService) {
        this.updatePreviewCustService = updatePreviewCustService;
    }

    @Override
    public String execute() throws Exception {
        // TODO Auto-generated method stub
        customer = this.updatePreviewCustService.findCustomerById(customer
                .getId());
        return SUCCESS;
    }

}

com.crm.action.TypeAction.java下拉菜單選擇性別代碼

package com.crm.action;

import java.util.ArrayList;
import java.util.List;

import com.crm.bean.Type;
import com.opensymphony.xwork2.ActionSupport;

public class TypeAction extends ActionSupport {
    private List<Type> strList = new ArrayList<Type>();

    public List<Type> getStrList() {
        List<Type> list = new ArrayList<Type>();
        Type type1 = new Type();
        type1.setId("1");
        type1.setName("男");
        Type type2 = new Type();
        type2.setId("2");
        type2.setName("女");
        Type type3 = new Type();
        type3.setId("3");
        type3.setName("其他");
        list.add(type1);
        list.add(type2);
        list.add(type3);
        this.strList = list;
        return strList;
    }

    public void setStrList(List<Type> strList) {
        this.strList = strList;
    }

    @Override
    public String execute() throws Exception {
        // TODO Auto-generated method stub
        return SUCCESS;
    }

}

custAdd.jsp新增客戶信息界面代碼

<body>
    <CENTER>
    <div><font size="5" color="red">新增客戶信息</font></div>
    <center></center>
    <div style="width:20px"></div>
    <div class="divcss5"> 
    <s:form action="saveCust" theme="simple">
    <div style="width:10px"></div>
        客戶編號:<s:textfield name="cust.custno"    label="custno"></s:textfield>
        性別:<s:select name="strList" headerKey="0" headerValue="-----------請選擇-----------" list="#list.strList" listKey="id" listValue="name"/><br>
        客戶名稱:<s:textfield name="cust.custname"  label="custname"></s:textfield>
        年齡:<s:textfield name="cust.telephone" label="telephone"></s:textfield><br>
        <tr><td>&nbsp;</td></tr>
        <s:submit value="保存" onClick="window.close();"></s:submit>
        <input width="100" type = "button" id = "smt" name = "btn" value="關閉" onClick="window.close();"/>
    </s:form>
    </div>
    <div style="width:20px"></div>
    </CENTER>
</body>

custSave.jsp新增客戶信息界面代碼

<body>
    <CENTER>
    <div><font size="5" color="red">新增客戶信息</font></div>
    <center></center>
    <div style="width:20px"></div>
    <div class="divcss5"> 
    <s:form action="saveCust" theme="simple">
    <div style="width:10px;padding:10px"></div>
        客戶編號:<s:textfield name="cust.custnumber"    label="客戶編號"></s:textfield><br>
        客戶名稱:<s:textfield name="cust.custname"  label="客戶名稱"></s:textfield><br>
        客戶性別:<s:textfield name="cust.custsex" label="客戶性別"></s:textfield><br>
        電話號碼:<s:textfield name="cust.custphone" label="電話號碼"></s:textfield><br>
        <tr><td>&nbsp;</td></tr>
        <s:submit value="保存" style="margin:10px"></s:submit>
        <input style="margin:10px" width="100"  type = "button" id = "smt" name = "btn" value="關閉" onClick="window.close();"/>
    </s:form>
    </div>
    <div style="width:20px"></div>
    </CENTER>
</body>

custInfo.jsp客戶信息維護界面代碼

<body>
    <CENTER>
    <center><div><font color="red" size="6">客戶信息維護</font></div></center>
    <div style="width:20px"></div>
    <div class="divcss5"> 
    <s:form action="findCdtCustList" theme="simple">
    <div style="width:10px"></div>
        客戶編號:<s:textfield name="cust.custno"    label="custno"></s:textfield>
        客戶名稱:<s:textfield name="cust.custname"  label="custname"></s:textfield><br>
        出生日期:<s:textfield name="cust.address"   label="address"></s:textfield>
        電話號碼:<s:textfield name="cust.telephone" label="telephone"></s:textfield><br>
        <div style="width:20px"></div>
        <input width="100" type = "button" id = "add" name = "btn" value="新增" onClick="openwind();"/>
        <s:submit value="查詢"></s:submit>
        <input width="100" type = "button" id = "smt" name = "btn" value="返回" onClick="history.go(-1)"/>
    </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="customer">
          <tr>
           <td><s:property value="#customer.custno"/></td>
           <td><s:property value="#customer.custname"/></td>
           <td>
           <s:if test="#customer.sex == 1">
           <s:property value="‘男‘"/>
           </s:if>
           <s:elseif test="#customer.sex == 2">
           <s:property value="‘女‘"/>
           </s:elseif>
           <s:elseif test="#customer.sex == 3">
           <s:property value="‘其他‘"/>
           </s:elseif>
           </td>
           <td><s:property value="#customer.age"/></td>
           <td><s:property value="#customer.telephone"/></td>
           <td><s:property value="#customer.position"/></td>
           <td><s:property value="#customer.logindate"/></td>
           <td>
           <s:a href="updatePreviewCust.action?customer.id=%{#customer.id}">修改</s:a>
           <s:a href="delectCustomer.action?customer.id=%{#customer.id}" onClick="return funDelete();">刪除</s:a>
           </td>
          </tr>
          
        </s:iterator>
    </table>
    </CENTER>
</body>

custUpdate.jsp修改客戶信息界面代碼

<body>
    <CENTER>
    <div><font size="5" color="red">修改客戶信息</font></div>
    <center></center>
    <div style="width:20px"></div>
    <div class="divcss5"> 
    <s:form action="updateCust" theme="simple">
    <div style="width:10px"></div>
        客戶編號:<s:textfield name="customer.custno" value="%{customer.custno}"    label="custno"></s:textfield>
        性別:<s:select name="strList" headerKey="0" value="%{customer.sex}" headerValue="-----------請選擇-----------" list="#list.strList" listKey="id" listValue="name"/><br>
        客戶名稱:<s:textfield name="customer.custname" value="%{customer.custname}"  label="custname"></s:textfield>
        年齡:<s:textfield name="customer.telephone" label="%{customer.telephone}"></s:textfield><br>
        <s:hidden name="customer.id" value="%{customer.id}" ></s:hidden>
        <tr><td>&nbsp;</td></tr>
        <s:submit value="保存" onClick="window.history.back(-1);"></s:submit>
        <input width="100" type = "button" id = "smt" name = "btn" value="關閉" onClick="history.go(-1);"/>
    </s:form>
    </div>
    <div style="width:20px"></div>
    </CENTER>
</body>

待問題:個人電腦包沖突報錯,應該是操作系統和jdk的問題;更改信息的網頁還會報錯505

軟件工程實踐記錄p2(day4-6)