📄 goadd.java
字号:
package com.store.action.gOm;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.bean.DAO.ProductDAO;
import com.bean.DAO.ProductoutputDAO;
import com.bean.DTO.ProductoutputDTO;
import com.bean.DTO.UserinforDTO;
import com.database.DataSourceFactory;
import com.servlet.AbstractAction;
import com.system.action.popedomCheck;
public class goAdd extends AbstractAction {
public String process(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String url = "goList.do";
UserinforDTO udt = (UserinforDTO) request.getSession().getAttribute(
"userinfor");
popedomCheck pc = new popedomCheck(udt);
if (pc.storeCheck2()) {
request.setCharacterEncoding("utf-8");
ProductoutputDTO prd = new ProductoutputDTO();
ProductoutputDAO prda = new ProductoutputDAO();
ProductDAO pd = new ProductDAO();
String name = request.getParameter("name");
System.out.println("goname: " + name);
int productID = 0;
Connection con = null;
try {
con = DataSourceFactory.getDataSource().getConnection();
if (name != null)
if (pd.existproduct(name, con)) {
productID = pd.getproductID(name, con);
System.out.println("goid: " + productID);
} else {
url = "/storeManage/gOm/addError.jsp";
}
prd.setProductID(productID);
String amount = request.getParameter("outamount");
if (amount != null)
prd.setOutamount(Integer.parseInt(amount));
String price = request.getParameter("price");
if (price != null)
prd.setTradeprice(Float.parseFloat(price));
prd.setConsumer(request.getParameter("provider"));
prd.setOuttime(request.getParameter("time"));
String cid = request.getParameter("checkerID");
if (cid != null)
prd.setCheckerID(Integer.parseInt(cid));
prda.Addproductoutput(prd, con);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
url = "User/login.jsp";
}
return url;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -