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

📄 updateproduct.jsp

📁 某电子商品销售公司为了提升企业形象和商品销售量
💻 JSP
字号:
<%@ page language="java" import="s2jsp.bysj.dao.*,s2jsp.bysj.entity.*" pageEncoding="gbk"%>
<%@ include file="checkSession.jsp" %>
<html>

	<head>
		<meta http-equiv="Content-Language" content="zh-cn">
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
		<title>管理员-添加</title>
		<link rel="stylesheet" type="text/css" href="../css/style_admin.css">
		<%
			request.setCharacterEncoding("gbk");
			response.setContentType("text/html;charset=gb2312");			
			String action = request.getParameter("action");
			String productID = request.getParameter("productID");
			
			ProductDao productDao = new ProductDao();
			Product product = new Product();
			
			if (action != null && "update".equals(action)) {
				String serialNumber = request.getParameter("serialNumber");
				String name = request.getParameter("name");
				String brand = request.getParameter("brand");
				String model = request.getParameter("model");
				String price = request.getParameter("price");
				String picture = request.getParameter("picture");
				String description = request.getParameter("description");
				
				
				product.setProductID(Integer.parseInt(productID));
				product.setSerialNumber(serialNumber);
				product.setName(name);
				product.setBrand(brand);
				product.setModel(model);
				product.setPrice(Double.parseDouble(price));
				product.setPicture(picture);
				product.setDescription(description);
				
				
				
				int count = productDao.updateProduct(product);
				if (count > 0)
					out
						.print("<script type='text/javascript'>alert('成功修改一条商品信息。');location.replace('addProduct.jsp');</script>");
				else
					out
						.print("<script type='text/javascript'>alert('修改失败。');history.go(-1);</script>");
				}
			else{
				
				product = productDao.findProductByID(productID);
				
			}

			
		%>
		<script type="text/javascript">
		function fun_check_form(){
			if(document.form1.name.value==""){
				alert("请输入新闻标题信息。");
				return false;
			}else if(document.form1.serialNumber.value==""){
				alert("请输入新闻内容。");
				return false;
			}else{
				return true;
			}
		}
		
		</script>
	</head>

	<body>
		<form name="form1" action="updateProduct.jsp" method="post" onSubmit="return fun_check_form()">
			<table cellspacing="1" cellpadding="4" width="100%"  align="left"
				class="tableborder" id="table3">

				<input type="hidden" name="action" value="update" />
				<input type="hidden" name="productID" value="<%=productID %>" />
				<tr>
					<td colspan="12" class="header">
						添加商品信息
					</td>
				</tr>
				<tr>
					<td class="altbg1">
						商品编号:
					</td>
					<td class="altbg2">
						<input type="text" name="serialNumber" size="34" value="<%=product.getSerialNumber() %>" />
					</td>
				</tr>
				<tr>
					<td class="altbg1">
						商品名称:
					</td>
					<td class="altbg2">
						<input type="text" name="name" size="34" value="<%=product.getName() %>" />
					</td>
				</tr>
				<tr>
					<td class="altbg1">
						商品商标:
					</td>
					<td class="altbg2">
						<input type="text" name="brand" size="34" value="<%=product.getBrand() %>" />
					</td>
				</tr>	
				<tr>
					<td class="altbg1">
						商品型号:
					</td>
					<td class="altbg2">
						<input type="text" name="model" size="34" value="<%=product.getModel() %>" />
					</td>
				</tr>
				<tr>
					<td class="altbg1">
						商品价格:
					</td>
					<td class="altbg2">
						<input type="text" name="price" size="34" value="<%=product.getPrice() %>" />
					</td>
				</tr>
				<tr>
					<td class="altbg1">
						商品图片:
					</td>
					<td class="altbg2">
						<input type="text" name="picture" size="34" value="<%=product.getPicture() %>" />
					</td>
				</tr>
				<tr>
					<td class="altbg1">
						商品介绍:
					</td>
					<td class="altbg2">
						<textarea rows="5" cols="60" name="description" ><%=product.getDescription().trim() %></textarea>
					</td>
				</tr>
				

				<tr>
					<td class="altbg1">
					</td>
					<td class="altbg2">
						<input type="submit" value="提交" name="B1" />
						&nbsp;
						<input type="reset" value="重置" name="B2" />
					</td>
				</tr>

			</table>
		</form>
	</body>

</html>

⌨️ 快捷键说明

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