storeaddaction.java

来自「一个完整的网络订餐系统」· Java 代码 · 共 80 行

JAVA
80
字号
package com.store.web.action;


import org.apache.struts.action.ActionForward;
import com.common.struts.*;
import com.store.dao.StoreDao;
import com.store.form.Store;

public class StoreAddAction extends AbstractAction {

  public StoreAddAction() {
  }

  public ActionForward execute(ActionContext actionContext) throws java.lang.Exception {

    String storeID = actionContext.getParameter("storeID");
    String adminname = actionContext.getParameter("adminname");
    String adminpassword = actionContext.getParameter("adminpassword");

    String storeName = actionContext.getParameter("storeName");
    String province = actionContext.getParameter("province");
    String area = actionContext.getParameter("area");

    String relationer = actionContext.getParameter("relationer");
    String phone = actionContext.getParameter("phone");
    String fax = actionContext.getParameter("fax");
    String email = actionContext.getParameter("email");

    String address = actionContext.getParameter("address");
    String postcode = actionContext.getParameter("postcode");
    String netadderss = actionContext.getParameter("netadderss");
    String location = actionContext.getParameter("location");

    String memo = actionContext.getParameter("memo");

    String path = actionContext.getParameter("path");

    int pointer = 0;
    String spointer = actionContext.getParameter("pointer");
    if (! ( ("").equals(spointer) || null == spointer))
      pointer = Integer.parseInt(spointer);

    int starNum = 0;
    String sstarNum = actionContext.getParameter("starNum");
    if (! ( ("").equals(sstarNum) || null == sstarNum))
      starNum = Integer.parseInt(sstarNum);

    Store info = new Store(storeID, adminname, adminpassword, storeName,
                           province, area,
                           relationer, phone, fax, email, address, postcode,
                           netadderss, location,
                           memo, pointer, starNum, null, null);

    StoreDao dao = new StoreDao();

    int nRet = dao.insertStoreToDb(info);

    if ( ("").equals(path) || null == path || ("null").equals(path)) {
      if (nRet > 0) {
        actionContext.getSession().setAttribute("storename", storeName);
        return actionContext.getMapping().findForward("storeAddSuccess");
      }
      else
        return actionContext.getMapping().findForward("storeAddFail");
    }
    if( ("admin").equals(path) )
    {
      if (nRet > 0) {
        return actionContext.getMapping().findForward("adminstoreAddSuccess");
      }
      else
        return actionContext.getMapping().findForward("adminstoreAddFail");

    }
 return null;


  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?