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

📄 money.java

📁 酒店管理系统·可用于一般旅社的营业操作。方便你的酒店管理
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.redingsoft.checkout;import com.redingsoft.locationutil.LocationUtil;import com.redingsoft.sql.SetSQL;import com.test.Counter;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Dimension;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.ResultSet;import java.sql.SQLException;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.*;import javax.swing.table.DefaultTableModel;/** * * @author Administrator */public class money extends JDialog implements ActionListener{          //声明一个面板    JPanel jp1;    //声明一个标签    JLabel jl1,jl2;   JButton bt1,bt2;   JTable tb1;   JScrollPane sp;   DefaultTableModel dftm1;   //时、声明数组出示阿华表模式   String cols[]={"结算单号","入住时间","入住天数","实际收入","结算时间"};   String rows[][]=new String [30][5];   String sql=null;   //构造方法   public money (){   //实例化       jl1=new JLabel("营业额:");       jl2=new JLabel("营业额");       bt1=new JButton("总营业额");       bt2=new JButton("更新");       bt1.setContentAreaFilled(false);       bt2.setContentAreaFilled(false);       jp1=new JPanel();       //是理化化表格       dftm1=new DefaultTableModel(){            @Override           public   boolean   isCellEditable(int   row,   int   column)   {                  return   false;              }        } ;          tb1=new JTable();       dftm1.setDataVector(rows, cols);       sql="select chk_no 结算单号,in_no 入住时间,days 入住天数,money 实际收入,chk_time 结算时间 from checkout where delmark=0";         initTabel(sql);       tb1.setModel(dftm1);       sp=new JScrollPane(tb1);       jp1.add(jl1);       jp1.add(jl2);       jp1.add(bt1);       jp1.add(bt2);       //修饰面板       jp1.setBackground(Color.CYAN);       sp.setPreferredSize(new Dimension(300,300));       //添加侦听       bt1.addActionListener(this);       bt2.addActionListener(this);       //添加到主窗口       this.add(BorderLayout.NORTH,sp);       this.add(BorderLayout.SOUTH,jp1);       this.setDefaultCloseOperation(money.DISPOSE_ON_CLOSE);       this.setTitle("查询营业额");       this.setSize(500, 380);       LocationUtil.setLocation(this);          }   /****   public static void main(String []aa){   new money();   }    * ****************************/   public void initTabel(String sql){   //设置表格的模式    //初始化表表模式     SetSQL.initDTM(dftm1,sql);     if(dftm1.getRowCount()!=0){      tb1.setModel(dftm1); //    tb=new JTable();    }else{        WarnMsg("提示","还没有营业额的信息!");        }}     /*******************************************************     * 函数名称:WarnMsgPane(String title ,String msg ,component null)     * 参数:tile 提示标题 msg 提示消息 显示他的父组件     * 功能:为错误的输入和连接错误做出提示     ************************************************************/ public static void WarnMsg(String title,String msg){  JOptionPane.showMessageDialog(null,msg,title,JOptionPane.WARNING_MESSAGE); }    public void actionPerformed(ActionEvent e) {    //    throw new UnsupportedOperationException("Not supported yet.");       Object o=e.getSource();       if(o==bt1){            try {                String sel = "select sum(money) from checkout where delmark=0";                ResultSet rs = SetSQL.executeQuery(sel);                rs.next();              String money=String.valueOf(rs.getFloat(1));              jl2.setForeground(Color.BLUE);              jl2.setText(money);             // System.out.print(money);            } catch (SQLException ex) {             //   Logger.getLogger(money.class.getName()).log(Level.SEVERE, null, ex);            }       }//end if(o==bt1)       if(o==bt2){ //更新        initTabel(sql);       }    }      }

⌨️ 快捷键说明

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