栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

利用Javabean+JSP去实现商品进销存中任何一个场景,实现对商品数量的绑定。

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

利用Javabean+JSP去实现商品进销存中任何一个场景,实现对商品数量的绑定。

利用Javabean+JSP去实现商品进销存中任何一个场景,实现对商品数量的绑定。

先引入几个需要的jar包

add.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="mybean.Goods"  %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>








	
	    
	
	
添加商品数量



    
	
    

商品一览表

商品类型 单价 添加入库/数量
衣服 ¥200
裤子 ¥168
鞋子 ¥99
帽子 ¥69

pay.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="mybean.Goods"  %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


  
    
    提交结算
	
	
	    
	
		
  
  
    
	
	<%
		String Count;
		Count=request.getParameter("Clothes");
		int C = Integer.parseInt(Count); 
		buy.setClothes(C);
		//衣服数量
		Count=request.getParameter("Trouers");
		int T = Integer.parseInt(Count); 
		buy.setTrouers(T);
		//裤子数量
		Count=request.getParameter("Shoes");
		int S = Integer.parseInt(Count); 
		buy.setShoes(S);
		//鞋子数量
		Count=request.getParameter("Cap");
		int Cap = Integer.parseInt(Count); 
		buy.setCap(Cap);
		//鞋子数量
	%> 
	

商品统计表

商品类型 单价/元 商品数量统计/件
衣服 ¥200 <%=buy.Clothes()%>
裤子 ¥168 <%=buy.Trouers()%>
鞋子 ¥99 <%=buy.Shoes()%>
帽子 ¥69 <%=buy.Cap()%>
金额总计/元 <%=buy.Sum() %>/元

javaBean(Goods.java)

package mybean;
public class Goods{
	//衣服、鞋子、裤子、和帽子商品
    private int Clothes=0;
    private int Shoes=0;
    private int Trouers=0;
    private int Cap=0;
    private String Notice;
    private int sum;
    public int getClothes() {
		return Clothes;
	}
	public void setClothes(int Clothes) {
		this.Clothes = Clothes;
	}
	//衣服
	public int getShoes() {
		return Shoes;
	}
	public void setShoes(int Shoes) {
		this.Shoes= Shoes;
	}
	
	//鞋子
	public int getTrouers() {
		return Trouers;
	}
	public void setTrouers(int Trouers) {
		this.Trouers = Trouers;
	}
	//帽子
	public int getCap() {
		return Cap;
	}
	public void setCap(int Cap) {
		this.Cap = Cap;
	}

	public String Clothes(){
		 Notice="";
		Notice+=getClothes();
		return Notice;
	}
	public String Trouers(){
		 Notice="";
		Notice+=getTrouers();
		return Notice;
	}
	public String Shoes(){
		 Notice="";
		Notice+=getShoes();
		return Notice;
	}
	public String Cap(){
		 Notice="";
		Notice+=getCap();
		return Notice;
	}
	public int Sum(){
		sum=0;
		sum+=getClothes()*200;
		sum+=getTrouers()*168;
		sum+=getShoes()*99;
		sum+=getCap()*69;
		return sum;
	}
}

效果图:


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/572228.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号