⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wtsellokaction.java

📁 structejbmysql开发工程源码
💻 JAVA
字号:
package stock.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import course.data.buy.Buy;
import course.data.buy.UserInf;

import stock.ErrMsg.ErrMsg;
import stock.data.dto.inDto.WtBuyOkInDto;
import stock.data.dto.inDto.WtSellOkInDto;

import stock.data.dto.outDto.WtBuyOkOutDto;
import stock.data.dto.outDto.WtSellOkOutDto;
import stock.form.BuyForm;
import stock.form.SellForm;

/*
 * Created on 2006-12-29
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author hyron yuhui
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class WtSellOkAction extends Action {

    String ToGB2312(String s) {
        try {
            return new String(s.getBytes("ISO-8859-1"), "GB2312");
        } catch (Exception e) {
            return null;
        }
    }

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        SellForm sell = (SellForm) form;
        try {
            ErrMsg.ErrMsgOfSellBack = "";
            if (sell.getMmlb().equals("S")) {
                return mapping.findForward("backSell");
            } else {

                WtSellOkOutDto outDto = new WtSellOkOutDto();
                WtSellOkInDto inDto = new WtSellOkInDto();
                Buy buyData = new Buy();
                UserInf userInf = new UserInf();
                setBuyDataAndUserInf(sell, buyData, userInf);
                setInDto(outDto, sell, inDto, buyData, userInf);
                String checkStr = sell.getNumOfSel();
                boolean allValid = true;
                String checkOK = "1234567890";
                int j, i;
                char ch;
                for (i = 0; i < checkStr.length(); i++) {
                    ch = checkStr.charAt(i);
                    for (j = 0; j < checkOK.length(); j++)
                        if (ch == checkOK.charAt(j)) {                           
                            break;
                        }
                    if(j==(checkOK.length())){
                        allValid=false;
                        break;
                        }
          
                }

                if (sell.getNumOfSel().equals("")||sell.getNumOfSel().length()==1) {
                    ErrMsg.ErrMsgOfSellBack = "输入购买股票数目!";
                    return mapping.findForward("inputfailure");
                } else if (!allValid) {
                    ErrMsg.ErrMsgOfSellBack = "卖出股票数目只能为整数!";
                    return mapping.findForward("inputfailure");
                } else {
                    ErrMsg.ErrMsgOfSellBack = "";
                return mapping.findForward("success");
                }
            }
        } catch (Exception e) {
            ErrMsg.ErrMsgOfSellBack = "股票代码不存在!";
            return mapping.findForward("failure");
        }

    }

    public void setInDto(WtSellOkOutDto outDto, ActionForm form,
            WtSellOkInDto inDto, Buy buyData, UserInf userInf) {

        SellForm sell = (SellForm) form;
        outDto.upDateDB(buyData, userInf);

    }

    public void setBuyDataAndUserInf(ActionForm form, Buy buyData,
            UserInf userInf) {
        //buyData
        SellForm sell = (SellForm) form;
        buyData.setUserName(sell.getUserName());
        buyData.setStkID(sell.getStkID());
        buyData.setStkSumNum(sell.getNumOfSel());
        buyData.setStkCanUsed(sell.getNumOfSel());
        buyData.setPriSelNow(sell.getPriOfSel());
        //String numGetLos;
        //String priStpLos;
        // String stkState;

        buyData.setReason(sell.getReason());
        //userInfo
        userInf.setUserName(sell.getUserName());
        int numOfSel = 0;
        int priOfSel = 0;
        int cashCanUsed = 0;
        if (sell.getNumOfSel().equals("")
                || sell.getNumOfSel().toString() == null) {
            sell.setNumOfSel("0");
        }
        if (sell.getPriOfSel().equals("")
                || sell.getPriOfSel().toString() == null) {
            sell.setPriOfSel("0");
        }

        try {
            numOfSel = Integer.parseInt(sell.getNumOfSel());
            priOfSel = Integer.parseInt(sell.getPriOfSel());
            cashCanUsed = numOfSel * priOfSel;
        } catch (Exception e) {
            numOfSel = 0;
            priOfSel = 0;
            cashCanUsed = 0;
        }
        userInf.setCashCanUsed(Integer.toString(cashCanUsed));

        //String sumOfWth;
        userInf.setNumOfDone(Integer.toString(cashCanUsed));

        //String incOfDay;
        //String incOfWeek;
        //String inc;

    }
}

⌨️ 快捷键说明

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