<file_sep>package ui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import _jz.is_digit;
import _jz.jz_util;
import model.category;
import model.m_budget;
import model.brand;
import model.m_info;
import model.m_to_s;
import model.s_info;
import util.BaseException;

public class FrmModify_m extends JDialog implements ActionListener{
//	public m_info m2;
	private m_info m = new m_info();
	private brand brd = new brand();
	private category cate = new category();
	private s_info s_inf = new s_info();
	private int s_id=0;
	
	private JPanel toolBar = new JPanel();
	private JPanel jp = new JPanel();
	private JPanel jp1 = new JPanel();private JPanel jp2 = new JPanel();
	private JPanel jp3 = new JPanel();private JPanel jp4 = new JPanel();
	private JPanel jp5 = new JPanel();private JPanel jp6 = new JPanel();
	private JPanel jp7 = new JPanel();private JPanel jp8 = new JPanel();
	private JPanel jp9 = new JPanel();

	private JButton btnOk = new JButton("确定");
	private JButton btnCancel = new JButton("取消");
	private JLabel labelName = new JLabel("材料名：");
	private JLabel label_brand = new JLabel("品牌号：");
	private JLabel label_category = new JLabel("类别号：");
	private JLabel label_standard = new JLabel("规格    ：");
	private JLabel label_model_number = new JLabel("型号    ：");
	private JLabel label_flower_color = new JLabel("花色    ：");
	private JLabel label_unit_price = new JLabel("单价    ：");
	private JLabel label_unit_of_valuation = new JLabel("计价单位：");
	private JLabel label_s_inf = new JLabel("服务    ：");
	
	private JTextField edtName = new JTextField(25);
	private JTextField edt_brand = new JTextField(25);
	private JTextField edt_category = new JTextField(25);
	private JTextField edt_standard = new JTextField(25);
	private JTextField edt_model_number = new JTextField(25);
	private JTextField edt_flower_color = new JTextField(25);
	private JTextField edt_unit_price = new JTextField(25);
	private JTextField edt_unit_of_valuation = new JTextField(24);
	private JTextField edt_s_inf = new JTextField(25);
	
	private JButton btn_brand= new JButton("查看现有品牌");
	private JButton btn_category= new JButton("查看现有类别");
	private JButton btn_s_inf= new JButton("查看现有服务");
	
	public FrmModify_m(Frame f, String s, boolean b) {
		super(f, s, b);
	}
	public FrmModify_m(MouseAdapter mouseAdapter, String s, boolean b) {
		// TODO Auto-generated constructor stub
		super();
	}
	//=================================================================================
	private int flg=0;//用于判断选项,add_s=1,modify_s=2
	protected void add_m() {								//添加材料
		flg=1;
		fuyong();
	}
	protected void modify_m(m_info super_m) {			//修改材料
		flg=2;
		this.m = super_m;
		fuyong();
		
		edtName.setText(m.getM_name());//赋值当前材料名
		edt_brand.setText(String.valueOf(m.getBrand().getBrand_id()));//赋值当前品牌号
		edt_category.setText(String.valueOf(m.getCategory().getCategory_id()));//赋值当前类别号
		edt_standard.setText(m.getStandard());
		edt_model_number.setText(m.getModel_number());
		edt_flower_color.setText(m.getFlower_color());
		edt_unit_price.setText(String.valueOf(m.getUnit_price()));
		edt_unit_of_valuation.setText(m.getUnit_of_valuation());
		
		try {
			s_id = jz_util.m_to_s_manager.m_get_s(m.getM_id());
		} catch (BaseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(s_id!=0)
			edt_s_inf.setText(String.valueOf(s_id));
	}
	protected void del_m(m_info super_m) {				//删除材料
		try {
			m_to_s mts = new m_to_s();
			mts.setM_id(super_m.getM_id());
			jz_util.m_to_s_manager.del_m_to_s(mts);
			jz_util.m_info_manager.del_m(super_m);
		} catch (BaseException e) {
			// TODO Auto-generated catch block
			JOptionPane.showMessageDialog(null, e.getMessage(), "错误",JOptionPane.ERROR_MESSAGE);
			return;
		}
	}
//公用部分=========================================================================
	private void fuyong() {

		toolBar.setLayout(new FlowLayout(FlowLayout.RIGHT));
		toolBar.add(this.btnOk);
		toolBar.add(btnCancel);
		this.getContentPane().add(toolBar, BorderLayout.SOUTH);
		
		jp.setLayout(new FlowLayout(FlowLayout.LEFT));
		jp1.setLayout(new FlowLayout(FlowLayout.LEFT));jp2.setLayout(new FlowLayout(FlowLayout.LEFT));
		jp3.setLayout(new FlowLayout(FlowLayout.LEFT));jp4.setLayout(new FlowLayout(FlowLayout.LEFT));
		jp5.setLayout(new FlowLayout(FlowLayout.LEFT));jp6.setLayout(new FlowLayout(FlowLayout.LEFT));
		jp7.setLayout(new FlowLayout(FlowLayout.LEFT));jp8.setLayout(new FlowLayout(FlowLayout.LEFT));
		jp9.setLayout(new FlowLayout(FlowLayout.LEFT));
		
		jp1.add(labelName);
		jp1.add(edtName);
		jp2.add(label_brand);
		jp2.add(edt_brand);
		jp2.add(btn_brand);
		jp3.add(label_category);
		jp3.add(edt_category);
		jp3.add(btn_category);
		jp4.add(label_standard);
		jp4.add(edt_standard);
		jp5.add(label_model_number);
		jp5.add(edt_model_number);
		jp6.add(label_flower_color);
		jp6.add(edt_flower_color);
		jp7.add(label_unit_price);
		jp7.add(edt_unit_price);
		jp8.add(label_unit_of_valuation);
		jp8.add(edt_unit_of_valuation);
		jp9.add(label_s_inf);
		jp9.add(edt_s_inf);
		jp9.add(btn_s_inf);
		
		jp.add(jp1);jp.add(jp2);
		jp.add(jp3);jp.add(jp4);
		jp.add(jp5);jp.add(jp6);
		jp.add(jp7);jp.add(jp8);
		if(flg==2)
			jp.add(jp9);
		
		this.getContentPane().add(jp);
		
		this.setSize(500, 430);
		// 屏幕居中显示
		double width = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
		double height = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
		this.setLocation((int) (width - this.getWidth()) / 2,
				(int) (height - this.getHeight()) / 2);

		this.validate();
		this.btnOk.addActionListener(this);
		this.btnCancel.addActionListener(this);
		
		this.btn_brand.addActionListener(this);
		this.btn_category.addActionListener(this);
		this.btn_s_inf.addActionListener(this);
	}
//响应设置==========================================================================
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource()==this.btn_s_inf)
		{
			Frmload_s fs = new Frmload_s(this,"现有服务信息", true); 
			fs.setVisible(true);
			if(fs.s_inf.getS_id()!=0)
			{
				edt_s_inf.setText(String.valueOf(fs.s_inf.getS_id()));
				this.s_inf = fs.s_inf;
			}
		}
		else if(e.getSource()==this.btn_brand)
		{
			Frmload_brand fb = new Frmload_brand(this,"现有品牌信息", true); 
			if(fb.brand.getBrand_id()!=0) 
			{
				edt_brand.setText(String.valueOf(fb.brand.getBrand_id()));
				this.brd = fb.brand;
			}
		}
		else if(e.getSource()==this.btn_category)
		{
			Frmload_category fc = new Frmload_category(this,"现有类别信息", true);
			if(fc.category.getCategory_id()!=0) 
			{
				edt_category.setText(String.valueOf(fc.category.getCategory_id()));
				this.cate = fc.category;
			}	
		}
		else if(e.getSource()==this.btnCancel)
			this.setVisible(false);
		else if(e.getSource()==this.btnOk){
			try {
				double unit_price;
				
				if("".equals(this.edt_brand.getText()))
					throw new BaseException("品牌号不能为空");
				else if(!is_digit.isInteger(this.edt_brand.getText()))
					throw new BaseException("品牌号 请输入纯数字");
				if("".equals(this.edt_category.getText()))
					throw new BaseException("类别号不能为空");
				else if(!is_digit.isInteger(this.edt_category.getText()))
					throw new BaseException("类别号 请输入纯数字");
				if("".equals(this.edt_s_inf.getText()))
					this.s_id=0;
				else if(!is_digit.isInteger(this.edt_s_inf.getText()))
					throw new BaseException("服务号 请输入纯数字");
				else 
					{this.s_id=(Integer.parseInt(this.edt_s_inf.getText()));}
				
				if("".equals(this.edt_unit_price.getText()))
					{unit_price = 0.0;}
				else if(!is_digit.isDouble(this.edt_unit_price.getText()))
					throw new BaseException("单价 请输入纯数字");
				else if(Double.parseDouble(this.edt_unit_price.getText())<0)
					throw new BaseException("单价 不能小于0");
				else
					{unit_price = Double.parseDouble(this.edt_unit_price.getText());}	
				
				m.setM_name(edtName.getText());
				m.setBrand(jz_util.brand_manager.load_brand(Integer.parseInt(this.edt_brand.getText())));
				m.setCategory(jz_util.category_manager.load_category(Integer.parseInt(this.edt_category.getText())));
				m.setStandard(this.edt_standard.getText());
				m.setModel_number(this.edt_model_number.getText());
				m.setFlower_color(this.edt_flower_color.getText());
				m.setUnit_price(unit_price);
				m.setUnit_of_valuation(this.edt_unit_of_valuation.getText());
				m.setS_id(s_id);
				m_to_s mts = new m_to_s(m.getM_id(),s_id,1);
				if(flg==1)
				{
					jz_util.m_info_manager.add_m(m);
				}
				else if(flg==2)
				{
					jz_util.m_info_manager.change_m(m);
					jz_util.m_to_s_manager.change_m_to_s(mts);
				}
					
				else throw new BaseException("材料信息操作错误，flg="+flg);
				this.setVisible(false);
			} catch (BaseException e1) {
				JOptionPane.showMessageDialog(null, e1.getMessage(), "错误",JOptionPane.ERROR_MESSAGE);
				return;
			}
		}
	}

}
<file_sep>package model;

public class user {
	public static user currentLoginUser=null;
	
	public static final String[] tableTitles={"序号","用户名","用户密码","等级"};
	/**
	 * 请自行根据javabean的设计修改本函数代码，col表示界面表格中的列序号，0开始
	 */
	
	
	public String getCell(int col){
		if(col==0) return String.valueOf(user_id);
		else if(col==1) return user_name;
		else if(col==2) return psd;
		else if(col==3) return String.valueOf(level);
		else return "";
	}
	
	private int user_id;
	private String user_name;
	private int level;
	private String psd;
	
	public user() {
		super();
	}

	public user(String user_name, int level, String psd) {
		super();
		this.user_name = user_name;
		this.level = level;
		this.psd = psd;
	}
	
	public static user getCurrentLoginUser() {
		return currentLoginUser;
	}

	public static void setCurrentLoginUser(user currentLoginUser) {
		user.currentLoginUser = currentLoginUser;
	}
	
	public int getUser_id() {
		return user_id;
	}
	
	public void setUser_id(int user_id) {
		this.user_id = user_id;
	}

	public String getUser_name() {
		return user_name;
	}
	public void setUser_name(String user_name) {
		this.user_name = user_name;
	}
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}
	public String getPsd() {
		return psd;
	}
	public void setPsd(String psd) {
		this.psd = psd;
	}
	
}
<file_sep>package _jz;

import itf.*;

import java.util.regex.Pattern;

import function.*;

public class jz_util {
	public static user_itf user_manager= new user_manager();
	public static brand_itf brand_manager = new brand_manager();
	public static category_itf category_manager = new category_manager();
	public static m_budget_itf m_budget_manager = new m_budget_manager();
	public static m_info_itf m_info_manager = new m_info_manager();
	public static m_to_s_itf m_to_s_manager = new m_to_s_manager();
	public static s_budget_itf s_budget_manager = new s_budget_manager();
	public static s_info_itf s_info_manager = new s_info_manager();
	
}
<file_sep>package model;

public class s_budget {
	public static final String[] tableTitles={"序号","服务内容","数量","单价","服务时间","用户名"};
	/**
	 * 请自行根据javabean的设计修改本函数代码，col表示界面表格中的列序号，0开始
	 */
	
	
	public String getCell(int col){
		if(col==0) return String.valueOf(s_budget_id);
		else if(col==1) return s.getService_content();
		else if(col==2) return String.valueOf(quantity);
		else if(col==3) return String.valueOf(s.getUnit_price());
		else if(col==4) return String.valueOf(s.getService_time());
		else if(col==5) return user.getUser_name();
		else return "";
	}
	
	private int s_budget_id;
    private int quantity;
    private int required_time;
    private String remark;
    
    private s_info s;
    private user user;
    
	public s_budget() {
		super();
	}
	public s_budget(s_info s, int quantity, int required_time, String remark, user user) {
		super();
		//this.s_budget_id = s_budget_id;
		this.s = s;
		this.quantity = quantity;
		this.required_time = required_time;
		this.remark = remark;
		this.user = user;
	}
	
	
	public s_info getS() {
		return s;
	}
	public void setS(s_info s) {
		this.s = s;
	}
	public user getUser() {
		return user;
	}
	public void setUser(user user) {
		this.user = user;
	}
	public int getS_budget_id() {
		return s_budget_id;
	}
	public void setS_budget_id(int s_budget_id) {
		this.s_budget_id = s_budget_id;
	}
	public int getQuantity() {
		return quantity;
	}
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	public int getRequired_time() {
		return required_time;
	}
	public void setRequired_time(int required_time) {
		this.required_time = required_time;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
    
}
<file_sep>package function;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.query.Query;

import itf.brand_itf;
import model.brand;
import util.BaseException;
import util.BusinessException;
import util.HBUtil;

public class brand_manager implements brand_itf{

	@Override//1.添加品牌
	public brand add_brand(brand brd) throws BaseException {
		// TODO Auto-generated method stub
		Session s = HBUtil.getSession();
		Transaction tx = s.beginTransaction();
		
		if(brd.getBrand_name()==null || "".equals(brd.getBrand_name()) || brd.getBrand_name().length()>20) 
			{throw new BusinessException("品牌名必须是1-20个字母");}
				
		String hql = "from brand where brand_name = '"+brd.getBrand_name()+"'";
		Query query = s.createQuery(hql);
		if(query.list().size()==0) //品牌名不存在
			{s.save(brd);tx.commit();System.out.println("输出在这12");}
		else
			{throw new BusinessException("品牌名已存在1");}
		
		s.close();
		return brd;
	}

	@Override//2.删除品牌，有材料存在时，不能删除
	public void del_brand(brand brand) throws BaseException {
		// TODO Auto-generated method stub
		Session s = HBUtil.getSession();
		Transaction tx = s.beginTransaction();
		
		String hql = "from brand where brand_name = '"+brand.getBrand_name()+"'";
		Query query = s.createQuery(hql);
		if(query.list().size()==0) //品牌名不存在
			{throw new BusinessException("此品牌不存在");}
		else
		{
			String hql2 = "from m_info where brand_id = "+brand.getBrand_id();
			Query query2 = s.createQuery(hql2);
			if(query2.list().size()!=0)
				{throw new BusinessException("此品牌下存在商品,不能删除");}
		}
		hql = "delete from brand where brand_name = '"+brand.getBrand_name()+"'";
		s.createQuery(hql).executeUpdate();
		tx.commit();
		s.close();
	}

	@Override//3.修改品牌名,不能与已有名重复
	public brand change_brand(brand brd) throws BaseException {
		// TODO Auto-generated method stub
		Session s = HBUtil.getSession();
		Transaction tx = s.beginTransaction();
		
		if(brd.getBrand_name()==null || "".equals(brd.getBrand_name()) || brd.getBrand_name().length()>20) 
			{throw new BusinessException("品牌名必须是1-20个字母");}

		String hql2 = "from m_info where brand_id = "+brd.getBrand_id();
		Query query2 = s.createQuery(hql2);
		if(query2.list().size()!=0)
			{throw new BusinessException("此品牌下存在商品,不能修改");}
		
		String hql = "from brand where brand_name = '"+brd.getBrand_name()+"'";
		Query query = s.createQuery(hql);
		if(query.list().size()==0) //品牌名不存在
			{s.update(brd);}
		else
			{throw new BusinessException("此品牌名已存在");}
	
		tx.commit();
		s.close();
		return brd;
	}

	@Override//4.提取当前所有品牌
	public List<brand> load_all() throws BaseException {
		// TODO Auto-generated method stub
		Session s = HBUtil.getSession();
		
		List<brand> all_brand = new ArrayList<brand>();
		
		String hql = "from brand";
		all_brand = s.createQuery(hql).list();
		
		s.close();
		return all_brand;
	}
	
			//5.提取指定品牌
	public brand load_brand(int brand_id)throws BaseException{
		Session s = HBUtil.getSession();
		brand brand = new brand();
		String hql;
		
		if(brand_id==0)
			{throw new BusinessException("请指定品牌号");}
		else if(brand_id!=0)
		{
			hql = "from brand where brand_id = "+brand_id;
			Query query = s.createQuery(hql);
			if(query.list().size()==0)
				{throw new BusinessException("该品牌不存在");}
			brand = (model.brand) query.list().get(0);
		}
		s.close();
		return brand;
		
	}
	public List<brand> load_brand_byname(String name)throws BaseException{
		Session s = HBUtil.getSession();
		List<brand> all_brand = new ArrayList<brand>();
		String hql;
		
		if("".equals(name))
		{
			hql = "from brand";
		}
		else
		{
			hql = "from brand where brand_name like '%"+name+"%'";
		}
		all_brand = s.createQuery(hql).list();
		
		s.close();
		return all_brand;
	}
}
<file_sep>package function;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.query.Query;

import itf.category_itf;
import model.brand;
import model.category;
import util.BaseException;
import util.BusinessException;
import util.HBUtil;

public class category_manager implements category_itf{

	@Override//1.添加类别
	public category add_category(category cate) throws BaseException {
		// TODO Auto-generated method stub
		Session s = HBUtil.getSession();
		Transaction tx = s.beginTransaction();
		
		if(cate.getCategory_name()==null || "".equals(cate.getCategory_name()) || cate.getCategory_name().length()>20) 
		{throw new BusinessException("类别名必须是1-20个字母");}
		
		String hql = "from category where category_name = '"+cate.getCategory_name()+"'";
		Query query = s.createQuery(hql);
		if(query.list().size()==0) //类别名不存在
			{s.save(cate);}
		else
			{throw new BusinessException("类别名已存在");}
		
		tx.commit();
		s.close();
		return cate;
	}

	@Override//2.删除类别，有材料存在时，不能删除
	public void del_category(category category) throws BaseException {
		// TODO Auto-generated method stub
		Session s = HBUtil.getSession();
		Transaction tx = s.beginTransaction();
		
		String hql = "from category where category_name = '"+category.getCategory_name()+"'";
		Query query = s.createQuery(hql);
		if(query.list().size()==0) //类别名不存在
			{throw new BusinessException("此类别不存在");}
		else
		{
			String hql2 = "from m_info where category_id = "+category.getCategory_id();
			Query query2 = s.createQuery(hql2);
			if(query2.list().size()!=0)
				{throw new BusinessException("此类别下存在商品,不能删除");}
		}
		
		hql = "delete from category where category_name = '"+category.getCategory_name()+"'";
		s.createQuery(hql).executeUpdate();
		tx.commit();
		s.close();
		
	}

	@Override//3.修改类别名,不能与已有名重复
	public category change_category(category cate) throws BaseException {
		// TODO Auto-generated method stub
		Session s = HBUtil.getSession();
		Transaction tx = s.beginTransaction();
		
		if(cate.getCategory_name()==null || "".equals(cate.getCategory_name()) || cate.getCategory_name().length()>20) 
		{throw new BusinessException("类别名必须是1-20个字母");}
		else 
		{
			String hql2 = "from m_info where category_id = "+cate.getCategory_id();
			Query query2 = s.createQuery(hql2);
			if(query2.list().size()!=0)
				{throw new BusinessException("此类别下存在商品,不能修改");}
			
			String hql = "from category where category_name = '"+cate.getCategory_name()+"'";
			Query query = s.createQuery(hql);
			if(query.list().size()==0) //品牌名不存在
				{s.update(cate);}
			else
				{throw new BusinessException("此类别名已存在");}
		}
		tx.commit();
		s.close();
		return cate;
	}

	@Override//4.提取当前所有类别
	public List<category> load_all() throws BaseException {
		// TODO Auto-generated method stub
		Session s = HBUtil.getSession();
		
		List<category> all_category = new ArrayList<category>();
		
		String hql = "from category";
		all_category = s.createQuery(hql).list();
		s.close();
		return all_category;
	}
			//5.提取指定品牌
	public category load_category(int category_id)throws BaseException{
		Session s = HBUtil.getSession();
		category category = new category();
		String hql;
		
		if(category_id==0)
			{throw new BusinessException("请指定类别号");}
		else if(category_id!=0)
		{
			hql = "from category where category_id = "+category_id;
			Query query = s.createQuery(hql);
			if(query.list().size()==0)
				{throw new BusinessException("该类别不存在");}
			category = (model.category) query.list().get(0);
		}
		s.close();
		return category;
	}
	public List<category> load_category_byname(String name) throws BaseException {
		// TODO Auto-generated method stub
		Session s = HBUtil.getSession();
		String hql;
		List<category> all_category = new ArrayList<category>();
		if("".equals(name))
			hql = "from category";
		else
			hql = "from category where category_name like '%"+name+"%'";
		all_category = s.createQuery(hql).list();
		
		s.close();
		return all_category;
	}
}
<file_sep>package ui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;

import _jz.jz_util;
import model.m_budget;
import model.s_budget;
import model.user;
import util.BaseException;

public class Frmload_bgt extends JDialog implements ActionListener{
	private List<m_budget> all_m_budget = null;
	private List<s_budget> all_s_budget = null;
	private user usr = new user();
	
	private Object tbl_m_budget_title[] = m_budget.tableTitles;
	private Object tbl_m_budget_data[][];
	private DefaultTableModel tab_m_budget_model = new DefaultTableModel();
	private JTable data_table_m_budget = new JTable(tab_m_budget_model);
	private TableRowSorter<DefaultTableModel> sort_m_budget = new TableRowSorter<DefaultTableModel>(tab_m_budget_model);
	//服务预算
	private Object tbl_s_budget_title[] = s_budget.tableTitles;
	private Object tbl_s_budget_data[][];
	private DefaultTableModel tab_s_budget_model = new DefaultTableModel();
	private JTable data_table_s_budget = new JTable(tab_s_budget_model);
	private TableRowSorter<DefaultTableModel> sort_s_budget = new TableRowSorter<DefaultTableModel>(tab_s_budget_model);
	
	private JPanel jp = new JPanel(new BorderLayout());
	private JPanel jp_left = new JPanel(new BorderLayout());
	private JPanel jp_right = new JPanel(new BorderLayout());
	private JScrollPane jp1 = new JScrollPane();private JScrollPane jp2 = new JScrollPane();
	private JLabel label_m_bgt = new JLabel("材料预算表");
	private JLabel label_s_bgt = new JLabel("服务预算表");
	private JPanel jp_left_n = new JPanel(new FlowLayout(FlowLayout.CENTER));
	private JPanel jp_right_n = new JPanel(new FlowLayout(FlowLayout.CENTER));
	private JPanel jp_s_c = new JPanel(new FlowLayout(FlowLayout.CENTER));
	private JButton btn_total = new JButton("合计");
	
	public Frmload_bgt(Frmload_user f, String s, boolean b, user super_usr) {
		// TODO Auto-generated constructor stub
		super(f,s,b);
		this.usr = super_usr;
		fuyong();
	}
//=============================================================================================
	private void fuyong() {
		jp1 = new JScrollPane(this.data_table_m_budget);
		jp2 = new JScrollPane(this.data_table_s_budget);
		jp_left_n.add(label_m_bgt);jp_right_n.add(label_s_bgt);
		jp_left.add(jp_left_n, BorderLayout.NORTH); jp_left.add(jp1,BorderLayout.CENTER);
		jp_right.add(jp_right_n, BorderLayout.NORTH); jp_right.add(jp2, BorderLayout.CENTER);
		jp.add(jp_left, BorderLayout.WEST);
		jp.add(jp_right, BorderLayout.CENTER);
		jp.add(btn_total, BorderLayout.SOUTH);
		this.getContentPane().add(jp);
		this.reload_m_budget_table();
		this.reload_s_budget_table();
		
		 this.setSize(1000, 600);
		double width = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
		double height = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
		this.setLocation((int) (width - this.getWidth()) / 2,
				(int) (height - this.getHeight()) / 2);

		this.validate();
		this.btn_total.addActionListener(this);
	}
//=============================================================================================
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource()==this.btn_total)
		{
			Frmtotal dlg = new Frmtotal(this,"合计", true, usr);
			dlg.setVisible(true);
		}
	}
//=============================================================================================
	private void reload_m_budget_table() {//当前用户材料预算
		try {
			all_m_budget = jz_util.m_budget_manager.load_m_budget(usr);
			
		}catch (BaseException e) {
			JOptionPane.showMessageDialog(null, e.getMessage(), "错误",JOptionPane.ERROR_MESSAGE);
			return;
		}
		tbl_m_budget_data = new Object[all_m_budget.size()][m_budget.tableTitles.length];
		for(int i=0; i<all_m_budget.size(); i++)
		for(int j=0; j<m_budget.tableTitles.length; j++)
		{
			if(j==0) 
				{tbl_m_budget_data[i][j]=i+1;continue;}//序号
			tbl_m_budget_data[i][j] = all_m_budget.get(i).getCell(j);
		}
		
		tab_m_budget_model.setDataVector(tbl_m_budget_data, tbl_m_budget_title);
		this.data_table_m_budget.validate();
		this.data_table_m_budget.repaint();
	}
	protected void reload_s_budget_table() {//当前用户服务预算
		try {
			all_s_budget = jz_util.s_budget_manager.load_s_budget(usr);
			
		}catch (BaseException e) {
			JOptionPane.showMessageDialog(null, e.getMessage(), "错误",JOptionPane.ERROR_MESSAGE);
			return;
		}
		
		tbl_s_budget_data = new Object[all_s_budget.size()][s_budget.tableTitles.length];
		for(int i=0; i<all_s_budget.size(); i++)
		for(int j=0; j<s_budget.tableTitles.length; j++)
		{
			if(j==0) 
				{tbl_s_budget_data[i][j]=i+1;continue;}//序号
			tbl_s_budget_data[i][j] = all_s_budget.get(i).getCell(j);
		}
		
		tab_s_budget_model.setDataVector(tbl_s_budget_data, tbl_s_budget_title);
		this.data_table_s_budget.validate();
		this.data_table_s_budget.repaint();
	}
	
}
<file_sep>package model;

public class brand {
	public static final String[] tableTitles={"序号","品牌名","描述"};
	/**
	 * 请自行根据javabean的设计修改本函数代码，col表示界面表格中的列序号，0开始
	 */
	
	
	public String getCell(int col){
		if(col==0) return String.valueOf(brand_id);
		else if(col==1) return brand_name;
		else if(col==2) return brand_describe;
		else return "";
	}
	
	private int brand_id;
	private String brand_name;
	private String brand_describe;
	
	public brand() {
		super();
	}
	public brand(String brand_name, String brand_describe) {
		super();
		//this.brand_id = brand_id;
		this.brand_name = brand_name;
		this.brand_describe = brand_describe;
	}
	
	public int getBrand_id() {
		return brand_id;
	}
	public void setBrand_id(int brand_id) {
		this.brand_id = brand_id;
	}
	public String getBrand_name() {
		return brand_name;
	}
	public void setBrand_name(String brand_name) {
		this.brand_name = brand_name;
	}
	public String getBrand_describe() {
		return brand_describe;
	}
	public void setBrand_describe(String brand_describe) {
		this.brand_describe = brand_describe;
	}
	
}
<file_sep>package model;

public class s_info {
	public static final String[] tableTitles={"序号","服务内容","服务等级","单价","计价单位","服务时间"};
	/**
	 * 请自行根据javabean的设计修改本函数代码，col表示界面表格中的列序号，0开始
	 */
	public static final String[] tableTitles2={"序号","服务内容","服务等级","单价","计价单位","服务时间","数量"};
	
	public String getCell(int col){
		if(col==0) return String.valueOf(s_id);
		else if(col==1) return service_content;
		else if(col==2) return String.valueOf(service_level);
		else if(col==3) return String.valueOf(unit_price);
		else if(col==4) return unit_of_valuation;
		else if(col==5) return String.valueOf(service_time);
		else return "";
	}
	
	private int s_id;
	private String service_content;	//服务内容
	private int service_level;		//服务等级
	private double unit_price;		//单价
	private String unit_of_valuation;//计价单位
	private int service_time;		//服务时间
	
	public s_info() {
		super();
	}
	public s_info(String service_content, int service_level, double unit_price, String unit_of_valuation,
			int service_time) {
		super();
		this.service_content = service_content;
		this.service_level = service_level;
		this.unit_price = unit_price;
		this.unit_of_valuation = unit_of_valuation;
		this.service_time = service_time;
	}
	
	public int getS_id() {
		return s_id;
	}
	public void setS_id(int s_id) {
		this.s_id = s_id;
	}
	public String getService_content() {
		return service_content;
	}
	public void setService_content(String service_content) {
		this.service_content = service_content;
	}
	public int getService_level() {
		return service_level;
	}
	public void setService_level(int service_level) {
		this.service_level = service_level;
	}
	public double getUnit_price() {
		return unit_price;
	}
	public void setUnit_price(double unit_price) {
		this.unit_price = unit_price;
	}
	public String getUnit_of_valuation() {
		return unit_of_valuation;
	}
	public void setUnit_of_valuation(String unit_of_valuation) {
		this.unit_of_valuation = unit_of_valuation;
	}
	public int getService_time() {
		return service_time;
	}
	public void setService_time(int service_time) {
		this.service_time = service_time;
	}
	
}
<file_sep>package ui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import _jz.jz_util;
import model.m_budget;
import model.s_budget;
import model.user;
import util.BaseException;

public class Frmtotal extends JDialog implements ActionListener{
	private double cnt_m = 0;
	private double cnt_s = 0;
	private double total = 0;
	private user usr = new user();
	private List<m_budget> list_m = new ArrayList<m_budget>();
	private List<s_budget> list_s = new ArrayList<s_budget>();
	
	private JPanel jp = new JPanel();
	private JPanel jp1 = new JPanel();private JPanel jp2 = new JPanel();
	private JPanel jp3 = new JPanel();private JPanel jp4 = new JPanel();
	
	private JButton btnOk = new JButton("确定");
	private JLabel label_cnt_m = new JLabel("材料合计：");
	private JLabel label_cnt_s = new JLabel("服务合计：");
	private JLabel label_total = new JLabel("合计：");
	
	public Frmtotal(FrmMain f, String s, boolean b) {
		// TODO Auto-generated constructor stub
		super(f,s,b);
		try {
			list_m = jz_util.m_budget_manager.load_m_budget(user.currentLoginUser);
			list_s = jz_util.s_budget_manager.load_s_budget(user.currentLoginUser);
		} catch (BaseException e) {
			// TODO Auto-generated catch block
			JOptionPane.showMessageDialog(null, e.getMessage(), "错误",JOptionPane.ERROR_MESSAGE);
			return;
		}
		fuyong();
	}
	public Frmtotal(Frmload_bgt f, String s, boolean b, user super_usr) {
		// TODO Auto-generated constructor stub
		super(f,s,b);
		this.usr = super_usr;
		try {
			list_m = jz_util.m_budget_manager.load_m_budget(this.usr);
			list_s = jz_util.s_budget_manager.load_s_budget(this.usr);
		} catch (BaseException e) {
			// TODO Auto-generated catch block
			JOptionPane.showMessageDialog(null, e.getMessage(), "错误",JOptionPane.ERROR_MESSAGE);
			return;
		}
		fuyong();
	}
	private void fuyong() {
		
		for(int i=0; i<list_m.size(); i++)
		{
			cnt_m+=list_m.get(i).getUnit_price()*list_m.get(i).getQuantity();
		}
		for(int i=0; i<list_s.size(); i++)
		{
			double unit_price = list_s.get(i).getS().getUnit_price();
			cnt_s+=list_s.get(i).getQuantity()*unit_price;
		}
		total = cnt_m+cnt_s;
		
		label_cnt_m.setText("材料合计："+cnt_m);
		label_cnt_s.setText("服务合计："+cnt_s);
		label_total.setText("合计         ："+total);
		
		
		jp.setLayout(new FlowLayout(FlowLayout.LEFT));
		jp1.setLayout(new FlowLayout(FlowLayout.LEFT));jp2.setLayout(new FlowLayout(FlowLayout.LEFT));
		jp3.setLayout(new FlowLayout(FlowLayout.LEFT));jp4.setLayout(new FlowLayout(FlowLayout.RIGHT));
		
		jp4.add(this.btnOk);
		this.getContentPane().add(jp4, BorderLayout.SOUTH);
		jp1.setPreferredSize(new Dimension(350, 30));jp2.setPreferredSize(new Dimension(350, 30));
		jp3.setPreferredSize(new Dimension(350, 30));
		
		jp1.add(label_cnt_m);
		jp2.add(label_cnt_s);
		jp3.add(label_total);

		jp.add(jp1);jp.add(jp2);
		jp.add(jp3);
		this.getContentPane().add(jp);
		
		this.setSize(300, 200);
		// 屏幕居中显示
		double width = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
		double height = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
		this.setLocation((int) (width - this.getWidth()) / 2,
				(int) (height - this.getHeight()) / 2);

		this.validate();
		this.btnOk.addActionListener(this);
		
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource()==this.btnOk)
			this.setVisible(false);
	}

}
