评论

收藏

[Java] Java swing实现酒店管理系统

编程语言 编程语言 发布于:2021-09-18 17:02 | 阅读数:489 | 评论:0

这篇文章主要为大家详细介绍了Java swing实现酒店管理系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
今天给大家提供一个由今天给大家提供一个由java swing实现的酒店管理系统,数据库采用sqlserver,我会贴上部分代码,完整的代码请看文章最下方下载,下面看代码:
1.主框架代码:
package 主框架窗口;
 
import java.awt.borderlayout;
import java.awt.color;
import java.awt.dimension;
import java.awt.flowlayout;
import java.awt.event.actionevent;
import java.awt.event.actionlistener;
import java.awt.event.mouseevent;
import java.awt.event.mouselistener;
import java.awt.event.windowadapter;
import java.awt.event.windowevent;
import java.sql.connection;
import java.sql.drivermanager;
import java.sql.resultset;
import java.sql.statement;
 
import javax.swing.jbutton;
import javax.swing.jframe;
import javax.swing.jlabel;
import javax.swing.jmenu;
import javax.swing.jmenubar;
import javax.swing.jmenuitem;
import javax.swing.joptionpane;
import javax.swing.jpanel;
import javax.swing.jsplitpane;
import javax.swing.jtoolbar;
import javax.swing.border.lineborder;
import javax.swing.table.defaulttablemodel;
 
import com.sunshine.sunsdk.system.suntools;
 
import sunsdk.sql.journal;
import sunsdk.sql.sunsql;
import sunsdk.swing.tjbutton;
import 关于我们.about;
import 团体开单.team;
import 客户管理.customer;
import 客房预定.engage;
import 宾客结账.checkout;
import 散客开单.individual;
import 系统设置.setup;
import 网络设置.netsetup;
import 菜单事件窗口.apartbill;
import 菜单事件窗口.change;
import 菜单事件窗口.goon;
import 菜单事件窗口.record;
import 菜单事件窗口.unitebill;
import 营业查询.query;
//加入公共类库
//加入模块类库
//散客开单
//团体开单
//宾客结帐
//预订房间
//营业查询
//客户管理
//网络设置
//系统设置
//关于我们
//下拉菜单中的功能库
 
 
 
public class hotelframe 
extends jframe 
implements actionlistener, mouselistener, runnable {
 
 //用户名,权限
 public static string userid, puil;
 public static jlabel lba, lbb;
 public static string clue = " 提 示 : ";
 public static string face = " 当前操作界面 : ";
 
 //声名与菜单相关的类
 private jmenubar mb;
 private jmenu m1, m2, m3, m4;
 private jmenuitem mi11, mi12, mi13, mi14, mi15, mi16, mi17, mi18, mi19,
  mi21, mi22, mi23, mi24, mi25,
   mi31, mi32, mi33, mi34, mi35, mi36;
 //工具栏
 private jtoolbar tb;
 private jbutton bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9, bta;
 //分割面板
 private jsplitpane spanemain, spaneleft, spaneright;
 //模块接口
 private jpanel panelmain, bott, jp2, jp3, jp4;
 private lefttoppanel jp1;  //主窗口左边面板
 //功能提示
 private string tooltip[] = {
 "零散宾客入住登记 ",
 "团体入住登记 ",
 "关于本软件的支持信息 ",
 "宾客退房结算 ",
 "为宾客预订房间 ",
 "查询营业情况 ",
 "为酒店固定客户设置参数 ",
 "设置系统的网络连接方式 ",
 "设置系统参数 ",
 "返回windows "
 };
 
 //功能模块
 /*#######################################################################*/
 individual idv = new individual(this); //散客开单
 team tm = new team(this); //团体开单
 checkout co = new checkout(this); //宾客结帐
 engage eg = new engage(this); //客房预定
 query qr = new query(this); //营业查询
 customer ct = new customer(this); //客户管理
 netsetup ns = new netsetup(this); //网络设置
 setup st = new setup(this); //系统设置
 about ab = new about(this); //关于我们 
 goon go = new goon(this); //宾客续住
 change cg = new change(this); //更换房间
 // remind rm = new remind(this); //电子提醒
 unitebill ub = new unitebill(this); //合并帐单
 apartbill ap = new apartbill(this); //拆分帐单
 record rc = new record(this); //系统日志
 /*#######################################################################*/
 
 
 
 //构造函数
 public hotelframe (string us, string pu) {
 super ("阳光酒店管理系统 - ★★版");
 
 userid = us; //获得操作员名称
 puil = pu; //获得操作员权限
 
 panelmain = new jpanel (new borderlayout()); //主面板
 
 //制作菜单
 buildmenubar ();
 //制作工具栏
 buildtoolbar ();
 //制作分割面板
 buildspanemain ();
 //制作窗口底端信息框
 buildbott ();
 
 //加入组件到主面板
 panelmain.add ("north", tb); //加入工具栏
 panelmain.add ("south", bott); //加入窗口底端信息框
 panelmain.add ("center", spanemain); //加入分割面板
 
 //加入菜单栏
 this.setjmenubar (mb);
 
 //加事件监听
 addlistener ();
 
 this.addwindowlistener (new windowadapter () {
 public void windowclosing (windowevent we) {
 quit ();
 }//end windowclosing
 });
 
 this.setcontentpane (panelmain);
 this.setbounds (2, 2, 1020, 740);
 this.setdefaultcloseoperation (jframe.do_nothing_on_close);
 this.setminimumsize (new dimension (1020, 740)); //设置窗口最小尺寸
 this.setvisible (true);
 (new thread(this)).start(); //启动房间状态检查线程
 }
 
 //制作菜单
 private void buildmenubar () {
 //实例菜单栏
 mb = new jmenubar ();
 
 //实例菜单
 m1 = new jmenu ("来宾登记 (b)");
 m2 = new jmenu ("收银结算 (s)");
 m3 = new jmenu ("系统维护 (w)");
 
 //实例菜单项
 mi11 = new jmenuitem ("散客开单(g)");
 mi12 = new jmenuitem ("团体开单(m)");
 mi13 = new jmenuitem ("宾客续住(z)");
 mi14 = new jmenuitem ("更换房间(a)");
 mi15 = new jmenuitem ("修改登记(j)");
 mi16 = new jmenuitem ("房间状态(z)");
 mi17 = new jmenuitem ("预订管理(t)");
 mi18 = new jmenuitem ("电子提醒(l)");
 mi19 = new jmenuitem ("退出系统(x)");
 mi21 = new jmenuitem ("宾客结帐(j)");
 mi22 = new jmenuitem ("合并帐单(e)");
 mi23 = new jmenuitem ("折分帐单(f)");
 mi24 = new jmenuitem ("宾客消费明细查询");
 mi25 = new jmenuitem ("宾客退单明细查询");
 mi31 = new jmenuitem ("网络设置(n)");
 mi32 = new jmenuitem ("系统设置(x)");
 mi33 = new jmenuitem ("系统日志(z)");
 mi34 = new jmenuitem ("数据备份(r)");
 mi35 = new jmenuitem ("软件帮助(h)");
 mi36 = new jmenuitem ("关于我们(a)");
 ///////////////////////////////////////////
 mi16.setenabled(false);//未开发完毕的功能
 mi18.setenabled(false);
 mi34.setenabled(false);
 ////////////////////////////////////////////
 //组织菜单
 m1.add (mi11); //来宾登记
 m1.add (mi12);
 m1.add (mi13);
 m1.add (mi14);
 m1.add (mi15);
 m1.add (mi16);
 m1.addseparator();
 m1.add (mi17);
 m1.add (mi18);
 m1.addseparator();
 m1.add (mi19);
 
 m2.add (mi21); //收银结算
 m2.add (mi22);
 m2.add (mi23);
 //m2.addseparator();
 //m2.add (mi24); //宾客消费明细
 //m2.add (mi25);
 m3.add (mi31); //系统维护
 m3.add (mi32);
 m3.add (mi33);
 m3.addseparator();
 m3.add (mi34);
 m3.addseparator();
 m3.add (mi35);
 m3.add (mi36);
 
 mb.add (m1); //加入菜单栏
 mb.add (m2);
 mb.add (m3);
 }
 
 //制作工具栏
 private void buildtoolbar () {
 tb = new jtoolbar();
 //制作按键
 bt1 = new tjbutton ("pic/toolbar/m01.gif", " 散客开单 ", "零散宾客入住登记", true);
 bt2 = new tjbutton ("pic/toolbar/m02.gif", " 团体开单 ", "团体入住登记", true);
 bt3 = new tjbutton ("pic/toolbar/m03.gif", " 关于我们 ", "软件信息", true);
 bt4 = new tjbutton ("pic/toolbar/m04.gif", " 宾客结帐 ", "宾客退房结算", true);
 bt5 = new tjbutton ("pic/toolbar/m05.gif", " 客房预订 ", "为宾客预定房间", true);
 bt6 = new tjbutton ("pic/toolbar/m06.gif", " 营业查询 ", "查询营业情况", true);
 bt7 = new tjbutton ("pic/toolbar/m07.gif", " 客户管理 ", "为酒店固定客户设置", true);
 bt8 = new tjbutton ("pic/toolbar/m08.gif", " 网络设置 ", "设置连接方式", true);
 bt9 = new tjbutton ("pic/toolbar/m09.gif", " 系统设置 ", "设置系统参数", true);
 bta = new tjbutton ("pic/toolbar/m10.gif", " 退出系统 ", "返回windows", true);
 
 //把按键加入工具栏
 tb.addseparator ();
 tb.add (bt1);
 tb.add (bt2);
 tb.addseparator ();
 tb.add (bt4);
 tb.add (bt5);
 tb.add (bt6);
 tb.addseparator ();
 tb.add (bt7);
 tb.add (bt8);
 tb.add (bt9);
 tb.addseparator ();
 tb.add (bt3);
 tb.addseparator ();
 tb.add (bta);
 
 //设置工具栏不可浮动
 tb.setfloatable(false);
 }
 
 //制作主面板
 private void buildspanemain () {
 
 jp1 = new lefttoppanel (); //这四个面板为功能接口//////////////
 jp2 = new leftbottpanel(); //左下面板 快速通道
 jp3 = new righttoppanel(); ///////////////////////////////
 jp4 = new rightbottpanel(); //右下面板 消费信息表
 
 //声名分割面板
 spaneleft = new jsplitpane(jsplitpane.vertical_split, true, jp1, jp2);
 spaneright = new jsplitpane(jsplitpane.vertical_split, true, jp3, jp4);
 spanemain = new jsplitpane(jsplitpane.horizontal_split, true, spaneleft, spaneright);
 
 //设置面板最小尺寸
 jp1.setminimumsize(new dimension (157, 450));
 jp2.setminimumsize(new dimension (157, 94));
 jp3.setminimumsize(new dimension (875, 300));
 jp4.setminimumsize(new dimension (875, 94));
 spaneright.setminimumsize(new dimension (875, 565));
 
 //设置分割条是否有伸缩键
 spanemain.setonetouchexpandable (true);
 spaneright.setonetouchexpandable(true);
 
 //设置各面板的初起尺寸
 spanemain.setdividerlocation (160);
 spaneleft.setdividerlocation (450);
 spaneright.setdividerlocation(450);
 
 //设置分隔条宽度
 spanemain.setdividersize (10);
 spaneleft.setdividersize (23);
 spaneright.setdividersize(23);
 }
 
 //制作bott栏
 private void buildbott () {
 jlabel lb1, lb2;
 
 lb1 = new jlabel(" 阳 光 酒 店 管 理 系 统 ");
 lb2 = new jlabel(" 当前操作员 : " + userid + "   ");
 lba = new jlabel(clue + "请选择功能项 ... ");
 lbb = new jlabel(face + "阳 光 酒 店 管 理 系 统 - ★★ 版   ");
 
 //加外框线
 lba.setborder(new lineborder(new color(87, 87, 47)));
 lbb.setborder(new lineborder(new color(87, 87, 47)));
 lb1.setborder(new lineborder(new color(87, 87, 47)));
 lb2.setborder(new lineborder(new color(87, 87, 47)));
 
 bott = new jpanel(new flowlayout(flowlayout.left, 2, 2));
 
 bott.add (lb1);
 bott.add (lba);
 bott.add (lbb);
 bott.add (lb2);
 }
 
 //加事件监听
 private void addlistener () {
 mi11.addactionlistener (this); //来宾登记
 mi12.addactionlistener (this);
 mi13.addactionlistener (this);
 mi14.addactionlistener (this);
 mi15.addactionlistener (this);
 mi16.addactionlistener (this);
 mi17.addactionlistener (this);
 mi18.addactionlistener (this);
 mi19.addactionlistener (this);
 mi21.addactionlistener (this); //收银结算
 mi22.addactionlistener (this);
 mi23.addactionlistener (this);
 mi24.addactionlistener (this);
 mi25.addactionlistener (this);
 mi31.addactionlistener (this); //系统维护
 mi32.addactionlistener (this);
 mi33.addactionlistener (this);
 mi34.addactionlistener (this);
 mi35.addactionlistener (this);
 mi36.addactionlistener (this);
 bt1.addactionlistener (this); //按键加动作监听
 bt2.addactionlistener (this);
 bt3.addactionlistener (this);
 bt4.addactionlistener (this);
 bt5.addactionlistener (this);
 bt6.addactionlistener (this);
 bt7.addactionlistener (this);
 bt8.addactionlistener (this);
 bt9.addactionlistener (this);
 bta.addactionlistener (this);
 bt1.addmouselistener (this); //按键加鼠标监听
 bt2.addmouselistener (this);
 bt3.addmouselistener (this);
 bt4.addmouselistener (this);
 bt5.addmouselistener (this);
 bt6.addmouselistener (this);
 bt7.addmouselistener (this);
 bt8.addmouselistener (this);
 bt9.addmouselistener (this);
 bta.addmouselistener (this);
 }
 
 /**=======================================================================**
 * [## private void quit () {} ]:  系统退出
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :关闭系统函数,仅类内使用
 **=======================================================================**
 */
 private void quit () {
 int flag = 0;
 string msg = "您 现 在 要 关 闭 系 统 吗 ?";
 flag = joptionpane.showconfirmdialog (null, msg, "提示", joptionpane.yes_no_option);
 if(flag == joptionpane.yes_option) {
 journal.writejournalinfo(userid, "退出本系统", journal.type_lg);//记录操作日志
 this.setvisible (false);
 system.exit (0);
 }//end if(flag == joptionpane.yes_option)
 return;
 }
 
 //刷新左房间信息栏数据
 private void initleftdata() {
 jp1.title1.settext(""); //刷房间信息
 for (int i = 0; i < 8; i++) {
 jp1.lt[i].settext("");
  }//endfor
 jp1.initroomstate();  //刷新房间总状态
 }
 
 //传数据给散客开单窗口
 private boolean initidv() {
 try {
 //从房间信息表里获得当前房间的状态和房间类型编号
 resultset rs = sunsql.executequery("select state,r_type_id from roominfo " +
 "where delmark=0 and id='" + lefttoppanel.title1.gettext() + "'");
 
 if(!rs.next()) { //如果无结果集,提示用户刷新房间数据
 if(lefttoppanel.title1.gettext().length() == 0) {
  joptionpane.showmessagedialog(null,"请选定房间后,再为宾客开设房间", 
  "提示", joptionpane.information_message);
 }else {
  joptionpane.showmessagedialog(null, "[ " + lefttoppanel.title1.gettext() + 
  " ] 房间信息已更改,请刷新房间信息,再为宾客开设房间", "提示", joptionpane.information_message);
 }
 return false;
 }else {
 if(!rs.getstring(1).equals("可供")) { //只有状态是可供房间,才能为宾客开设
  joptionpane.showmessagedialog(null, "请选择空房间,再为宾客开设房间", 
  "提示", joptionpane.information_message);
  return false;
 }//endif
 
 //传房间号到开单窗口
 individual.lba.settext(lefttoppanel.title1.gettext());
 //传房间类型到开单窗口
 individual.lbb.settext(lefttoppanel.title0.gettext().substring(0, 
   lefttoppanel.title0.gettext().length()-2));
 //传房间单价到开单窗口
 individual.lbc.settext(lefttoppanel.lt[1].gettext());
 
 //房间类型编号
 string clroom = rs.getstring(2);
 //获得此类型房间是否可以开设钟点房
 rs = sunsql.executequery("select cl_room from roomtype where " +
 "delmark=0 and id='" + clroom + "'");
 rs.next();
 if(rs.getstring(1).equals("n")) { //不能开设,则开单窗口的钟点选项不可用
  individual.chk1.setselected(false); //取消选中状态
  individual.chk1.setenabled(false); //设置不可用
 }else {
  individual.chk1.setenabled(true); //可用
 }//endif
 
 //传宾客类型数据给开单窗口
 rs = sunsql.executequery("select distinct c_type from customertype where " +
 "delmark = 0 and pk!=0");
 int ct = sunsql.reccount(rs);
 string ctype[] = new string[ct];
 for (int i = 0; i < ct; i++) {
  rs.next();
  ctype[i] = rs.getstring(1);
  }//endfor
  individual.cb2.removeallitems();
 for (int i = 0; i < ct; i++) {
  individual.cb2.additem(ctype[i]);
  }//endfor
  individual.cb2.setselecteditem("普通宾客");
 
 //初始化开单房间表---------临时表
 sunsql.executeupdate("delete from roomnum"); //清空临时表
 sunsql.executeupdate("insert into roomnum(roomid) values('" + 
 lefttoppanel.title1.gettext() + "')"); //加入当前房间信息
 //初始化开单窗口的开单房间表
 sunsql.initdtm(individual.dtm2,"select roomid 房间编号 from roomnum");
 
 //初始化追加房间表---------当前类型的除当前房间的所有可供房间
 sunsql.executeupdate("update roominfo set indimark=0"); //刷新所有房间的开单状态
 sunsql.executeupdate("update roominfo set indimark=1 where id='" + 
 lefttoppanel.title1.gettext() + "'"); //设置当前房间为开单状态
 //初始化开单窗口的可供房间表
 sunsql.initdtm(individual.dtm1,"select a.id 房间编号1 from roominfo " +
 "a,(select id from roomtype where r_type='" + individual.lbb.gettext() + 
 "') b where a.delmark=0 and a.indimark=0 and a.state='可供' and a.r_type_id=b.id");
 
 }//endif
  }
  catch (exception ex) {
  system.out.println ("hotelframe.initidv(): false");
  }//end try
  return true;
 }
 
 //传数据给团体开单窗口
 private boolean initteam() {
 try {
 //初始化开单房间表---------临时表
 sunsql.executeupdate("delete from roomnums"); //清空临时表
 //初始化开单窗口的开单房间表
 team.initdtm2();
 
 //初始化追加房间表---------当前类型的除当前房间的所有可供房间
 sunsql.executeupdate("update roominfo set indimark=0"); //刷新所有房间的开单状态
 
 //传房间类型数据给团体开单窗口
 resultset rs = sunsql.executequery("select r_type from roomtype where delmark=0");
 int ct = sunsql.reccount(rs);
 string type[] = new string[ct];
 
 //传宾客房型数据给团体开单窗口
 for (int i = 0; i < ct; i++) {
 rs.next();
 type[i] = rs.getstring(1);
 }//endfor
 team.cb.removeallitems();
 for (int i = 0; i < ct; i++) {
 team.cb.additem(type[i]);
 }//endfor
 
 //传宾客类型数据给团体开单窗口
 rs = sunsql.executequery("select distinct c_type from customertype where " +
 "delmark = 0 and pk!=0");
 ct = sunsql.reccount(rs);
 for (int i = 0; i < ct; i++) {
 rs.next();
 type[i] = rs.getstring(1);
 }//endfor
 team.cb2.removeallitems();
 for (int i = 0; i < ct; i++) {
 team.cb2.additem(type[i]);
 }//endfor
 team.cb2.setselecteditem("普通宾客");
  }
  catch (exception ex) {
  system.out.println ("hotelframe.initteam(): false");
  }//endtry
  return true;
 }
 
 //传数据给结算窗口
 private boolean initcko() {
 try {
 resultset rs = sunsql.executequery("select state,r_type_id from roominfo " +
 "where delmark=0 and id='" + lefttoppanel.title1.gettext() + "'");
 
 if(!rs.next()) { //如果无结果集,提示用户刷新房间数据
 if(lefttoppanel.title1.gettext().length() == 0) {
  joptionpane.showmessagedialog(null,"请选定宾客入住的房间后,再为宾客结算费用", 
  "提示", joptionpane.information_message);
 }else {
  joptionpane.showmessagedialog(null, "[ " + lefttoppanel.title1.gettext() + 
  " ] 房间信息已更改,请刷新房间信息,再为宾客开设房间", "提示", joptionpane.information_message);
 }//endif
 return false;
 }else {
 //只有状态是占用或钟点房间,才能为宾客结算
 if(!rs.getstring(1).equals("占用") && !rs.getstring(1).equals("钟点")) {
  joptionpane.showmessagedialog(null, "请选择宾客正在消费的房间进行结算费用操作", 
  "提示", joptionpane.information_message);
  return false;
 }//endif
 
 //传结算单号给结算窗口
 co.lba.settext(suntools.getnumber(suntools.number_js));
 //传结算房间给结算窗口
 co.lbb.settext(jp1.title1.gettext());
 //传结算宾客名称给结算窗口
 co.lbc.settext(jp1.lt[0].gettext());
 //传押金给结算窗口
 co.lbf.settext(jp1.lt[6].gettext());
 
 //清空结算中间表
 sunsql.executeupdate("delete from checkout_temp");
 
 //获得主房间号
 rs = sunsql.executequery("select main_room,in_no from livein where " +
 "delmark=0 and r_no='" + co.lbb.gettext() + "' and statemark='正在消费'");
 
 if(!rs.next()) {
  joptionpane.showmessagedialog(null, "操作失败,请检查网络情况", 
  "提示", joptionpane.information_message);
  return false;
 }//endif
 
 string mainroom = rs.getstring(1); //取出主房间号
 co.inno = rs.getstring(2); //传入住单号为结算窗口
 
 //获得主房间状态,看是普通住宿还是钟点房
 rs = sunsql.executequery("select state from roominfo where delmark=0 and id='" + mainroom + "'"); 
 rs.next();
 int mrstate = 0; //主房间状态 0:普通入住 1:钟点房
 if(rs.getstring(1).equals("钟点")) {
  mrstate = 1;
 }//endif
 
 defaulttablemodel ckodtm = new defaulttablemodel(); //主房间下的所有房间信息
 sunsql.initdtm(ckodtm, "select pk,r_no,r_type_id,c_type_id,in_time,foregift from " +
 "livein where delmark=0 and main_room='" + mainroom + "'");
 
 double total = 0; //消费总金额
 double shsh = 0; //实收金额
 double youh = 0; //优惠金额
 for (int i = 0; i < ckodtm.getrowcount(); i++) {
  //取出当前房间的标准单价
  rs = sunsql.executequery("select price,cl_price from roomtype where delmark=0 and id='" + 
  ckodtm.getvalueat(i, 2) + "'");
  rs.next();
  double rprice = 0;
  double days = 0;
  if(mrstate == 0) {
  rprice = rs.getdouble(1); //普通入住单价
  //获得入住天数
  days = suntools.getconsumefactor(ckodtm.getvalueat(i, 4) + "", journal.getnowdtime());
  }else {
  rprice = rs.getdouble(2); //钟点房单价
  days = suntools.getclockfactor(ckodtm.getvalueat(i, 4) + "", journal.getnowdtime());
  }//endif
  
  double rd = rprice * days; //当前房间的消费总金额
  total  = total + rd; //累加总消费
  rs = sunsql.executequery("select discount from customertype where delmark=0 and " +
  "id='" + ckodtm.getvalueat(i, 3) + "' and dis_attr='" + ckodtm.getvalueat(i, 2) + "'");
  rs.next();
  //取出宾客享受的折扣
  int dst = rs.getint(1);
  double ddr = rd * dst/10; //当前房间的打折后价格
  shsh = shsh + ddr; //应收金额累加
  youh = youh + rd - ddr; //优惠金额累加
  
  //向结算中间表加入数据
  sunsql.executeupdate("insert into checkout_temp(pk,r_type_id,r_no,price," +
  "discount,dis_price,account,money,in_time) values(" + ckodtm.getvalueat(i, 0) +
  ",'" + ckodtm.getvalueat(i, 2) + "','" + ckodtm.getvalueat(i, 1) + "'," + 
  rprice + "," + dst + "," + rprice * dst / 10 + "," + days + "," + ddr + ",'" + 
  ckodtm.getvalueat(i, 4) + "')");
  }
 
 //传消费金额给结算窗口
 co.lbd.settext(total + "");
 //传应收金额给结算窗口
 co.lbe.settext(shsh + "");
 //传实收金额
 co.tf1.settext(shsh + "");
 //传优惠金额给结算窗口
 co.lbg.settext(youh + "");
 //传找零金额给结算窗口
 co.lbh.settext(double.parsedouble(co.lbf.gettext()) - shsh + "");
 
 //刷新结算中间表数据
 co.initdtm();
 
 co.tf2.requestfocus(true); //给宾客支付焦点
 
 }//endif
  }
  catch (exception ex) {
  joptionpane.showmessagedialog(null, "操作失败,请检查网络情况", 
 "提示", joptionpane.information_message);
  ex.printstacktrace();
  system.out.println ("hotelframe.initcko(): false");
  return false;
  }//end try
 return true;
 }
 
 /**=======================================================================**
 * actionlistener 监听
 **=======================================================================**
 */
 public void actionperformed (actionevent ae) {
 object o = ae.getsource ();
 if(o == bt1 || o ==mi11) {//============================================
 lbb.settext(face + "散 客 开 单   -");
 if(initidv()) {  //传数据给散客开单窗口
 idv.show();  //散客开单
 initleftdata();  //刷新左房间信息栏数据
 }//endif
 }else if(o == bt2 || o == mi12) {//=====================================
 lbb.settext(face + "团 体 开 单   -");
 if(initteam()) {  //传宾客类型数据给团体开单窗口
 tm.show();  //团体开单
 initleftdata();  //刷新左房间信息栏数据
 }//endif
 }else if(o == bt3 || o == mi36) {//=====================================
 lbb.settext(face + "关 于 我 们   -");
 ab.show();   //关于我们
 }else if(o == bt4 || o == mi21) {//=====================================
 lbb.settext(face + "宾 客 结 帐   -");
 if(initcko()) {  //传数据给结算窗口
 co.show();  //宾客结帐
 initleftdata();  //刷新左房间信息栏数据
 }//endif
 }else if(o == bt5 || o == mi17) {//=====================================
 lbb.settext(face + "客 房 预 订   -");
 eg.show();   //客房预订
 initleftdata();  //刷新左房间信息栏数据
 }else if(o == bt6) {//==================================================
 lbb.settext(face + "营 业 查 询   -");
 qr.show();   //营业查询
 }else if(o == bt7) {//==================================================
 if(puil.equals("普通操作员")) { //客户管理
 string msg = "对不起,您的权限不能进入 [ 客户管理 ] 页面,请用管理员id登录 ...";
 joptionpane.showmessagedialog(null, msg, "提示", joptionpane.information_message);
 return;
 }
 lbb.settext(face + "客 户 管 理   -");
 ct.show();
 }else if(o == bt8 || o == mi31) {//=====================================
 if(puil.equals("普通操作员")) { //网络设置
 string msg = "对不起,您的权限不能进入 [ 网络设置 ] 页面,请用管理员id登录 ...";
 joptionpane.showmessagedialog(null, msg, "提示", joptionpane.information_message);
 return;
 }
 lbb.settext(face + "网 络 设 置   -");
 ns.show();
 }else if(o == bt9 || o == mi32) {//=====================================
 if(puil.equals("普通操作员")) { //系统设置
 string msg = "对不起,您的权限不能进入 [ 网络设置 ] 页面,请用管理员id登录 ...";
 joptionpane.showmessagedialog(null, msg, "提示", joptionpane.information_message);
 return;
 }
 lbb.settext(face + "系 统 设 置   -");
 st.builddtm12("");  //刷新房间信息表的房间状态
 st.show();
 initleftdata();  //刷新左房间信息栏数据
 }else if(o == bta || o == mi19) {//=====================================
 quit ();   //退出系统
 }else if(o == mi13) {//=================================================
 lbb.settext(face + "宾 客 续 住   -");
 go.show();   //宾客续住
 }else if(o == mi14) {//=================================================
 lbb.settext(face + "更 换 房 间   -");
 cg.show();   //更换房间
 }else if(o == mi15) {//=================================================
 lbb.settext(face + "修 改 登 记   -");
 idv.show();  //修改登记-------还要修改
 }else if(o == mi16) {//=================================================
 //房间状态
 }else if(o == mi18) {//=================================================
 //电子提醒
 
 }else if(o == mi22) {//=================================================
 lbb.settext(face + "合 并 帐 单   -");
 ub.show();   //合并帐单
 }else if(o == mi23) {//=================================================
 lbb.settext(face + "折 分 帐 单   -");
 ap.show();   //折分帐单
 }else if(o == mi33) {//=================================================
 lbb.settext(face + "系 统 日 志   -");
 rc.initdtm();  //刷新日志列表
 rc.show();   //系统日志
 }else if(o == mi34) {//=================================================
 //数据备份
 }else if(o == mi35) {//=================================================
 //软件帮助
 }
 lbb.settext(face + "阳 光 酒 店 管 理 系 统 - ★★ 版   ");
 }
 
 
 /**=======================================================================**
 * mouselistener 监听
 **=======================================================================**
 */
 public void mouseclicked (mouseevent me) {
 }
 
 public void mousepressed (mouseevent me) {
 }
 
 public void mousereleased(mouseevent me) {
 }
 
 public void mouseentered (mouseevent me) { //鼠标移进提示
 object o = me.getsource ();
 if(o == bt1) {
 lba.settext (clue + tooltip[0]);
 }else if(o == bt2) {
 lba.settext (clue + tooltip[1]);
 }else if(o == bt3) {
 lba.settext (clue + tooltip[2]);
 }else if(o == bt4) {
 lba.settext (clue + tooltip[3]);
 }else if(o == bt5) {
 lba.settext (clue + tooltip[4]);
 }else if(o == bt6) {
 lba.settext (clue + tooltip[5]);
 }else if(o == bt7) {
 lba.settext (clue + tooltip[6]);
 }else if(o == bt8) {
 lba.settext (clue + tooltip[7]);
 }else if(o == bt9) {
 lba.settext (clue + tooltip[8]);
 }else if(o == bta) {
 lba.settext (clue + tooltip[9]);
 }
 }
 
 public void mouseexited (mouseevent me) {
 lba.settext (clue + "请选择功能项 ... ");
 }
 
 
 /**=======================================================================**
 * [## public void run() {} ]: 
 * 参数 :无
 * 返回值 :无
 * 修饰符 :public
 * 功能 :结算后检查房间状态线程
 **=======================================================================**
 */
 public void run() {
 try {
 statement ste1 = null;
 connection conn1 = null;
 if(sunini.getinikey ("default_link").equals ("1")) { //jdbc连接方式
 string user1 = sunini.getinikey ("userid");
 string pwd1 = sunini.getinikey ("password");
 string ip1 = sunini.getinikey ("ip");
 string acc1 = sunini.getinikey ("access");
 string dbf1 = sunini.getinikey ("dbfname");
 string url1 = "jdbc:microsoft:sqlserver://" + ip1 + ":" + acc1 + ";" + "databasename=" + dbf1;
 //注册驱动
 drivermanager.registerdriver (new com.microsoft.jdbc.sqlserver.sqlserverdriver());
 //获得一个连接
 conn1 = drivermanager.getconnection (url1, user1, pwd1);
 }
 else {
 //注册驱动   //jdbcodbc连接方式
 drivermanager.registerdriver (new sun.jdbc.odbc.jdbcodbcdriver());
 //获得一个连接
 conn1 = drivermanager.getconnection ("jdbc:odbc:" + sunini.getinikey("linkname"));
 }
 
 //建立高级载体
 ste1 = conn1.createstatement (resultset.type_scroll_sensitive, resultset.concur_updatable);
 while( true ) {
 ste1.executeupdate("update roominfo set statetime=statetime-1 where statetime>0");
 ste1.executeupdate("update roominfo set state='可供' where statetime=0 and state='脏房'");
 thread.sleep(30000);
 }//end while
  }
  catch (exception ex) {
  joptionpane.showmessagedialog (null, "数据库连接失败...", "错误", joptionpane.error_message);
  system.exit(0);
  //ex.printstacktrace();
  }//end try
 }
/*
 public static void main (string sd[]) {
 sunswing.setwindowstyle (sunini.getinikey ("sys_style").charat (0));
 new hotelframe ("gujun", "管理员");
 }*/
}
2.系统设置:
/**
 *##############################################################################
 *
 * [ 项目名  ] : 阳光酒店管理系统
 * [ 公司名  ] : 清华it
 * [ 模块名  ] : 系统设置模块
 * [ 文件名  ] : setup.java
 * [ 相关文件 ] : 
 * [ 文件实现功能] : 组织系统设置窗口
 * [ 作者  ] : 董丰
 * [ 版本  ] : 1.1
 * ----------------------------------------------------------------------------
 * [ 备注  ] : 
 * ----------------------------------------------------------------------------
 * [ 修改记录 ] : 
 *
 * [ 日 期 ]  [版本]   [修改人]   [修改内容] 
 * 2006/04/19  1.0  董丰   创建
 * 2006/04/22  1.1  顾俊   实现数据保存
 * ##--------------------------------------------------------------------------
 *  版权所有(c) 2006-2007, sunshinesoft corporation
 * --------------------------------------------------------------------------##
 * 
 * [ 函数说明 ] : 看类内各函数开头
 * 
 * [ 遗留问题 ] : 
 *
 *##############################################################################
 */
package com.sunshine.setup;
 
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import com.sunshine.sunsdk.sql.*; //公共类库
import com.sunshine.sunsdk.system.*;
import com.sunshine.sunsdk.swing.*;
import com.sunshine.mainframe.hotelframe; //加载主窗口
 
 
public class setup 
extends jdialog 
implements actionlistener, mouselistener {
 
 private jlabel top,bott;
 private jtabbedpane tp;
 private jpanel panelmain;
 //=========房间项目设置
 private jtable tb11, tb12;
 private defaulttablemodel dtm11, dtm12; //房间类型列表//房间信息列表
 
 private jscrollpane sp11,sp12;
 private jcombobox cb11,cb12;
  //房间类型,可供/清理状态
 private jbutton bt11, bt12, bt13, bt14, bt15, bt16, bt17, bt18, bt19, bt20;
   //添加, 修改,删除lx,折扣,单个,批量添加,删除,修改fj,保存,筛选
 private jtextfield tf11;
 //=========客户类型设置
 private jtable tb21,tb22;
 private defaulttablemodel dtm21,dtm22;
   //客户类型列表,房间费打折列表
 private jscrollpane sp21,sp22;
 private jbutton bt21, bt22, bt23, bt24;
   //添加, 修改,删除lx,房费打折
 //=========操作员设置
 private jtable tb31;
 private defaulttablemodel dtm31;
  //操作员列表
 private jscrollpane sp31;
 private jcombobox cb31;//用户名
 private jpasswordfield tf31, tf32, tf33;
   //原密码,新密码,确认密码
 private jradiobutton rb31, rb32, rb33, rb34, rb35;
 //新用户登记, 修改密码,删除用户,普通用户,管理员
 private jbutton bt31, bt32, bt33;
   // 登记, 修改, 删除
 //=========计费设置
 private jtextfield tf41, tf42, tf43, tf44, tf45, tf46, tf47; 
 private jcheckbox ck;
 private jbutton bt41, bt42;
 
 //提示信息
 string msg0 = "您确定要删除在表格中选中的资料条目吗?";
 string msg1 = "请在相应的表格中选定条目,再点删除键 ...";
 //日志信息
 string journal;
 //ini文件中的键名
 string ini[] = { "[softinfo]", "username", "compname", "[config]", "soft_first",
  "default_link" , "default_page", "sys_style", "[number]",
  "lodgname", "lodgnumber", "enganame", "enganumber", "chouname", 
  "chounumber", "[habitus]", "ck_habitus", "ck_minute", "[parttime]", 
  "in_room", "out_room1", "out_room2", "insuday", "clockroom1", 
  "clockroom2", "insuhour1", "insuhour2", "[jdbc]", "dbfname", 
  "userid", "password", "ip", "access", "[odbc]", "linkname" };
 
 //实例化功能模块
 //========================================================================//
 addroomtype art = new addroomtype (this); //添加房间类型
 modiroomtype mrt = new modiroomtype(this); //添加房间类型
 addcustomertype act = new addcustomertype(this); //添加客户类型
 modicustomertype mct = new modicustomertype(this); //添加客户类型
 discount dis = new discount(this); //折扣设置
 addroominfo ari = new addroominfo(this); //单个添加房间
 addroominfos aris = new addroominfos(this); //批量添加房间
 modiroominfo mri = new modiroominfo(this); //修改房间信息
 //========================================================================//
 
 /**=======================================================================**
 * [## public setup(jframe frame) {} ]: 构造函数
 * 参数 :jdialog对象表示本对话框的父窗口
 * 返回值 :无
 * 修饰符 :public
 * 功能 :组建系统设置模块
 **=======================================================================**
 */
 public setup(jframe frame) {
 super (frame, "系统设置", true);
 top = new jlabel(); //假空格
 panelmain = new jpanel(new borderlayout(0,10));
 tab();  //制作系统设置项目标签面板
 addlistener(); //加入事件监听
 panelmain.add("north",top);
 panelmain.add("center",tp);
 this.setcontentpane(panelmain);
 this.setpreferredsize (new dimension (718,508));
 this.setminimumsize (new dimension (718,508));
 this.setresizable(false); //不允许改变窗口大小
 pack();
 sunswing.setwindowcenter(this); //窗口屏幕居中
 }
 
 /**=======================================================================**
 * [## private void addlistener() {} ]: 加事件监听
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :加事件监听
 **=======================================================================**
 */
 private void addlistener() {
 bt11.addactionlistener(this); //加动作监听
 bt12.addactionlistener(this);
 bt13.addactionlistener(this);
 bt14.addactionlistener(this);
 bt15.addactionlistener(this);
 bt16.addactionlistener(this);
 bt17.addactionlistener(this);
 bt18.addactionlistener(this);
 bt19.addactionlistener(this);
 bt20.addactionlistener(this);
 bt21.addactionlistener(this);
 bt22.addactionlistener(this);
 bt23.addactionlistener(this);
 bt24.addactionlistener(this);
 bt31.addactionlistener(this);
 bt32.addactionlistener(this);
 bt33.addactionlistener(this);
 bt41.addactionlistener(this);
 bt42.addactionlistener(this);
 rb31.addactionlistener(this); //操作员作操范围监听
 rb32.addactionlistener(this);
 rb33.addactionlistener(this);
 tf41.addactionlistener(this); //计费设置文本框加监听
 tf42.addactionlistener(this);
 tf43.addactionlistener(this);
 tf44.addactionlistener(this);
 tf45.addactionlistener(this);
 tf46.addactionlistener(this);
 bt11.addmouselistener(this); //加鼠标监听
 bt12.addmouselistener(this);
 bt13.addmouselistener(this);
 bt14.addmouselistener(this);
 bt15.addmouselistener(this);
 bt16.addmouselistener(this);
 bt17.addmouselistener(this);
 bt18.addmouselistener(this);
 bt19.addmouselistener(this);
 bt20.addmouselistener(this);
 bt21.addmouselistener(this);
 bt22.addmouselistener(this);
 bt23.addmouselistener(this);
 bt24.addmouselistener(this);
 bt31.addmouselistener(this);
 bt32.addmouselistener(this);
 bt33.addmouselistener(this);
 bt41.addmouselistener(this);
 bt42.addmouselistener(this);
 }
 
 /**=======================================================================**
 * [## private void tab() {} ]: 制作系统设置项目标签面板
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :制作系统设置项目标签面板
 **=======================================================================**
 */
 private void tab() {
 jpanel jp1,jp2,jp3,jp4;
 ///////////////////////////////////////////////-------模块面板接口
 jp1 = fangjian(); //房间项目设置
 jp2 = kehu(); //客户类型设置
 jp3 = caozuo(); //操作员设置
 jp4 = jifei(); //计费设置
 //////////////////////////////////////////////////////////////////
 tp = new jtabbedpane();
 tp.addtab("房间项目设置", new imageicon("pic/u01.gif"), jp1);
 tp.addtab("客户类型设置", new imageicon("pic/u02.gif"), jp2);
 tp.addtab("操作员设置", new imageicon("pic/u03.gif"), jp3);
 tp.addtab("计费设置", new imageicon("pic/u04.gif"), jp4);
 }
 
 /**=======================================================================**
 * [## private jpanel fangjian() {} ]: 
 * 参数 :无
 * 返回值 :jpanel
 * 修饰符 :private
 * 功能 :房间项目设置
 **=======================================================================**
 */
 private jpanel fangjian() {
 
 dtm11 = new defaulttablemodel();
 tb11 = new jtable(dtm11);
 sp11 = new jscrollpane(tb11);
 dtm12 = new defaulttablemodel();
 tb12 = new jtable(dtm12);
 sp12 = new jscrollpane(tb12);
 
 jpanel pfangjian,ptop,pbott,ptn,ptc,pbn,pbc,ptcc,ptcs,pbcc,pbcs;
 pfangjian = new jpanel(new gridlayout(2,1,0,5));
 ptop = new jpanel(new borderlayout());
 pbott = new jpanel(new borderlayout());
 ptn = new jpanel();  //放置保存按钮等...
 ptc = new jpanel(new borderlayout()); //放置房间类型列表及四个按钮
 pbn = new jpanel(new flowlayout(flowlayout.left,10,0));//放置下拉列表
 pbc = new jpanel(new borderlayout()); //放置房间信息列表及四个按钮
 ptcc = new jpanel(new gridlayout(1,1));//放置房间类型列表
 ptcs = new jpanel(new flowlayout(flowlayout.center,20,5));//放置四个按钮
 pbcc = new jpanel(new gridlayout(1,1));//放置房间信息列表
 pbcs = new jpanel(new flowlayout(flowlayout.center,20,5));//放置四个按钮
 
 //保存按钮等 ...
 jlabel lb1,lb2,lb3;
 lb1 = new jlabel("结帐后房间状态变为: ");
 lb2 = new jlabel("   结帐后");
 lb3 = new jlabel("分钟后变为可供状态  ");
 tf11 = new tjtextfield(sunini.getinikey(ini[17]),5); //根据ini文件给初值
 tf11.sethorizontalalignment(jtextfield.right);
 cb12 = new jcombobox();
 cb12.additem(" 可供状态  ");
 cb12.additem(" 清理状态  ");  //根据ini文件给初值
 cb12.setselectedindex(integer.parseint(sunini.getinikey(ini[16])));
 bt19 = new tjbutton ("pic/save.gif", " 保 存 ", "保存设置");
 ptn.add(lb1);
 ptn.add(cb12);
 ptn.add(lb2);
 ptn.add(tf11);
 ptn.add(lb3);
 ptn.add(bt19);
 ptn.setborder(borderfactory.createtitledborder(""));
 
 //房间类型列表及四个按钮
 bt11 = new tjbutton ("pic/new.gif", "添加类型", "添加房间类型");
 bt12 = new tjbutton ("pic/modi0.gif", "修改类型", "修改房间类型");
 bt13 = new tjbutton ("pic/del.gif", "删除类型", "删除房间类型");
 bt14 = new tjbutton ("pic/modi3.gif", "房费打折", "设置房间费折扣");
 ptcc.add(sp11);
 ptcs.add(bt11);
 ptcs.add(bt12);
 ptcs.add(bt13);
 ptcs.add(bt14);
 ptc.add(ptcc);
 ptc.add("south",ptcs);
 ptc.setborder(borderfactory.createtitledborder("房间类型"));
 
 //完成上半部分
 ptop.add("north",ptn);
 ptop.add(ptc);
 
 
 //下拉列表
 jlabel lb0 = new jlabel("按包厢类型过滤: ");
 cb11 = new jcombobox();
 bt20 = new tjbutton ("pic/choose1.gif", "筛 选", "筛选房间信息");
 bt20.setborderpainted(false);
 bt20.setfocuspainted(false);
 pbn.add(lb0);
 pbn.add(cb11);
 pbn.add(bt20);
 
 builddtm11(); //初始化房间类型列表和下拉列表的值
 builddtm12(""); //初始化房间号列表
 
 
 //房间信息列表及四个按钮
 bt15 = new tjbutton ("pic/new.gif", "单个添加", "添加单个房间信息");
 bt16 = new tjbutton ("pic/book.gif", "批量添加", "批量添加房间信息");
 bt17 = new tjbutton ("pic/del.gif", "删除房间", "删除某个房间信息");
 bt18 = new tjbutton ("pic/modi0.gif", "修改房间", "修改某个房间信息");
 pbcc.add(sp12);
 pbcs.add(bt15);
 pbcs.add(bt16);
 pbcs.add(bt17);
 pbcs.add(bt18);
 pbc.add(pbcc);
 pbc.add("south",pbcs);
 pbc.setborder ( borderfactory.createtitledborder ("房间信息") );
 
 //完成下半部分
 pbott.add("north",pbn);
 pbott.add(pbc);
 
 //组合
 pfangjian.add(ptop);
 pfangjian.add(pbott);
 
 return pfangjian;
 }
 
 //
 /**=======================================================================**
 * [## private void builddtm11() {} ]: 
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :房间类型列表和combobox
 **=======================================================================**
 */
 private void builddtm11() {
 string sqlcode2 = "select pk,sysmark,id,foregift,r_type 房间类型," +
 "price 预设单价,cl_price " + "'钟点价格/小时'" + ",bed 床位数量,cl_room "+
 "'能否按钟点计费(y/n)' from roomtype where delmark = 0";
 sunsql.initdtm(dtm11,sqlcode2);
 tb11.removecolumn(tb11.getcolumn("pk"));
 tb11.removecolumn(tb11.getcolumn("sysmark"));
 tb11.removecolumn(tb11.getcolumn("foregift"));
 tb11.removecolumn(tb11.getcolumn("id"));
 
 string sqlcode1 = "select r_type from roomtype where delmark = 0";
 sunsql.initjcombobox(cb11,sqlcode1);
 cb11.additem("显示全部房间信息");
 cb11.setselectedindex(cb11.getitemcount() - 1); //设置显示全部
 }
 
 /**=======================================================================**
 * [## private void builddtm12(string rtype) {} ]: 
 * 参数 :string rtype为刷新参数
 * 返回值 :无
 * 修饰符 :private
 * 功能 :房间信息表
 **=======================================================================**
 */
 public void builddtm12(string rtype) {
 string sqlcode = "select a.pk,a.r_type_id,a.id 房间号,b.r_type 房间类型," +
 "a.state 房间状态,a.location 所在区域,a.r_tel 房间电话 from roominfo as a," +
 "roomtype as b where a.r_type_id = b.id and a.delmark = 0 " + rtype;
 sunsql.initdtm(dtm12,sqlcode);
 tb12.removecolumn(tb12.getcolumn("pk"));
 tb12.removecolumn(tb12.getcolumn("r_type_id"));
 }
 
 /**=======================================================================**
 * [## private jpanel kehu() {} ]: 
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :客户类型设置
 **=======================================================================**
 */
 private jpanel kehu() {
 
 dtm21 = new defaulttablemodel();
 tb21 = new jtable(dtm21);
 sp21 = new jscrollpane(tb21);
 dtm22 = new defaulttablemodel();
 tb22 = new jtable(dtm22);
 sp22 = new jscrollpane(tb22);
 
 jpanel pkehu,p1,p2,p1b,p2b;
 p1 = new jpanel(new borderlayout());//客户类型面板
 p2 = new jpanel(new borderlayout());//房间费打折面板
 p1b = new jpanel(new flowlayout(flowlayout.center,30,5));//客户类型按钮面板
 p2b = new jpanel(); //房间费打折按钮面板
 
 builddtm21(); //初始化客户类型表
 bt21 = new tjbutton ("pic/new.gif", "添加类型", "添加客户类型");
 bt22 = new tjbutton ("pic/modi0.gif", "修改类型", "修改客户类型");
 bt23 = new tjbutton ("pic/del.gif", "删除类型", "删除客户类型");
 p1b.add(bt21);
 p1b.add(bt22);
 p1b.add(bt23);
 p1.add(sp21);
 p1.add("south",p1b);
 p1.setborder ( borderfactory.createtitledborder ("客户类型") );
 
 builddtm22(); //初始化房间打折表
 bt24 = new tjbutton ("pic/modi3.gif", " 房间费打折 ", "设置房间费折扣");
 p2b.add(bt24);
 p2.add(sp22);
 p2.add("south",p2b);
 p2.setborder ( borderfactory.createtitledborder ("房间费打折") );
 
 pkehu = new jpanel(new gridlayout(2,1,0,10));
 pkehu.add(p1);
 pkehu.add(p2);
 
 return pkehu;
 }
 
 /**=======================================================================**
 * [## private jpanel caozuo() {} ]: 
 * 参数 :无
 * 返回值 :jpanel
 * 修饰符 :private
 * 功能 :操作员设置
 **=======================================================================**
 */
 private jpanel caozuo() {
 jpanel panelmain,panelmain1,paneltop,panelbott1,panelbott2;
 
 dtm31 = new defaulttablemodel();
 tb31 = new jtable(dtm31);
 sp31 = new jscrollpane(tb31);
 
 panelmain = new jpanel(new gridlayout(2,1,0,5));
 panelmain1 = new jpanel (new borderlayout (0,3)); //下半面板
 paneltop = new jpanel(new gridlayout(1,1)); //操作员列表面板
 panelbott1 = new jpanel(new gridlayout (1, 2));//详细信息,操作范围,操作权限面板
 panelbott2 = new jpanel(new flowlayout (flowlayout.center,20,5));//按钮面板
 
 bt31 = new tjbutton ("pic/new.gif", " 登 记 ", "保存当前用户信息", false);
 bt32 = new tjbutton ("pic/key.gif", " 修 改 ", "修改密码", false);
 bt33 = new tjbutton ("pic/del.gif", " 删 除 ", "删除当前用户", false);
 
 bt32.setenabled(false);
 bt33.setenabled(false);
 
 panelbott2.add (bt31);
 panelbott2.add (bt32);
 panelbott2.add (bt33);
 
 //制作并加入top_left面板
 panelbott1.add (bottleft());
 
 //制作并加入top_right面板
 panelbott1.add (bottright());
 
 panelmain1.add ("center", panelbott1);
 panelmain1.add ("south", panelbott2);
 
 builddtm31();  //初始化操作员信息表
 paneltop.add(sp31);
 paneltop.setborder(borderfactory.createtitledborder("操作员列表"));
 panelmain.add(paneltop);
 panelmain.add(panelmain1);
 
 return panelmain;
 }
 
 /**=======================================================================**
 * [## private jpanel topleft () {} ]: 制作top_left面板
 * 参数 :无
 * 返回值 :jpanel表示组织好的面板
 * 修饰符 :private
 * 功能 :组建对话框的用户名和密码面板
 **=======================================================================**
 */
 private jpanel bottleft () {
 jlabel lb1, lb2, lb3, lb4;
 jpanel tl, jp1, jp2;
 
 lb1 = new jlabel ("用 户 名: ");
 lb2 = new jlabel ("原 密 码: ");
 lb3 = new jlabel ("新 密 码: ");
 lb4 = new jlabel ("确认密码: ");
 
 tf31 = new tjpasswordfield (17);
 tf32 = new tjpasswordfield (17);
 tf33 = new tjpasswordfield (17);
 
 
 tl = new jpanel ();
 jp1 = new jpanel (new gridlayout (4, 1, 0, 18));
 jp2 = new jpanel (new gridlayout (4, 1, 0, 9));
 
 //初始化用户名下拉框
 cb31 = new jcombobox ();
 cb31.seteditable (true);
 
 tf31.seteditable (false);
 
 //加入组件
 jp1.add (lb1);
 jp1.add (lb2);
 jp1.add (lb3);
 jp1.add (lb4);
 jp2.add (cb31);
 jp2.add (tf31);
 jp2.add (tf32);
 jp2.add (tf33);
 
 tl.add (jp1);
 tl.add (jp2);
 tl.setborder (borderfactory.createtitledborder (" 详细信息 "));
 return tl;
 }
 
 /**=======================================================================**
 * [## private jpanel topright () {} ]: 制作top_right面板
 * 参数 :无
 * 返回值 :jpanel表示组织好的面板
 * 修饰符 :private
 * 功能 :组建对话框操作面板
 **=======================================================================**
 */
 private jpanel bottright () {
 jpanel tr, jp1, jp2;
 buttongroup bg1,bg2;
 
 rb31 = new jradiobutton ("新用户登记", true);
 rb32 = new jradiobutton ("修改密码");
 rb33 = new jradiobutton ("删除用户");
 rb34 = new jradiobutton ("普通操作员", true);
 rb35 = new jradiobutton ("管 理 员");
 
 bg1 = new buttongroup ();
 bg2 = new buttongroup ();
 
 tr = new jpanel (new gridlayout (2, 1));
 jp1 = new jpanel ();
 jp2 = new jpanel ();
 
 //加单选组 操作范围
 bg1.add (rb31);
 bg1.add (rb32);
 bg1.add (rb33);
 
 //加单选组 操作权限
 bg2.add (rb34);
 bg2.add (rb35);
 
 jp1.add (rb31);
 jp1.add (rb32);
 jp1.add (rb33);
 
 jp2.add (rb34);
 jp2.add (rb35);
 
 jp1.setborder (borderfactory.createtitledborder (" 操作范围 "));
 jp2.setborder (borderfactory.createtitledborder (" 操作权限 "));
 
 tr.add (jp1);
 tr.add (jp2);
 
 return tr;
 }
 
 /**=======================================================================**
 * [## private void builddtm21() {} ]: 
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :初始化客户类型列表
 **=======================================================================**
 */
 private void builddtm21() {
 string sqlcode = "select pk,id 客户类型编号,id,c_type 客户类型,discount " +
 "打折比率 from customertype where delmark = 0 and dis_attr = '购物折扣' and id!='sysmark'";
 sunsql.initdtm(dtm21,sqlcode);
 tb21.removecolumn(tb21.getcolumn("pk"));
 tb21.removecolumn(tb21.getcolumn("id"));
 }
 
 /**=======================================================================**
 * [## private void builddtm22() {} ]: 
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :初始化房间打折费列表
 **=======================================================================**
 */
 private void builddtm22() {
 string sqlcode = "select pk,sysmark,id,foregift,r_type 房间类型,price 预设单价 from roomtype where delmark = 0";
 sunsql.initdtm(dtm22,sqlcode);
 tb22.removecolumn(tb22.getcolumn("pk"));
 tb22.removecolumn(tb22.getcolumn("id"));
 tb22.removecolumn(tb22.getcolumn("sysmark"));
 tb22.removecolumn(tb22.getcolumn("foregift"));
 }
 
 
 /**=======================================================================**
 * [## private void builddtm31() {} ]: 
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :初始化操作员列表
 **=======================================================================**
 */
 private void builddtm31() {
 string sqlcode = "select pk,userid 用户登录id,puis 用户权限 from pwd where delmark = 0";
 sunsql.initdtm(dtm31,sqlcode);
 tb31.removecolumn(tb31.getcolumn("pk"));
 
 sunsql.initjcombobox (cb31, "select userid from pwd where delmark=0");
 }
 
 /**=======================================================================**
 * [## private jpanel jifei() {} ]: 
 * 参数 :无
 * 返回值 :jpanel
 * 修饰符 :private
 * 功能 :计费设置
 **=======================================================================**
 */
 private jpanel jifei() {
 jlabel lb1, lb2, lb3, lb4, lb5, lb6, lb7, lb8, lb9, lb10, 
  lb11, lb12, lb13, lb14, lb15, lb16;
 //定义各方位面板
 jpanel paneljf, jftop, jfleft, jfright, jfbott;
 jpanel jp1, jp2, jp3, jp4, jp5, jp6, jp7, jp8, jp9;
 //定义标签
 lb1 = new jlabel("客人开房时间在");
 lb2 = new jlabel("点之后按新的一天开始计费");
 lb3 = new jlabel("客人退房时间在");
 lb4 = new jlabel("点之后计价天数自动追加半天");
 lb5 = new jlabel("客人退房时间在");
 lb6 = new jlabel("点之后计价天数自动追加一天");
 lb7 = new jlabel("开房后");
 lb8 = new jlabel("分钟开始计费");
 lb9 = new jlabel("最少按");
 lb10 = new jlabel("小时计费,小于这个时间的按此时间计费");
 lb11 = new jlabel("若不足一小时但超过");
 lb12 = new jlabel("分钟的部分按1小时计费");
 lb13 = new jlabel("不足上面分钟数但超过");
 lb14 = new jlabel("分钟的部分按半小时计费");
 lb15 = new jlabel("注:此设置仅限于标准计费的钟点房!");
 lb16 = new jlabel("");
 lb15.setforeground(new color(255, 138, 0));
 //初始化计时计费设置
 tf41 = new tjtextfield(sunini.getinikey("in_room"), 5);
 tf42 = new tjtextfield(sunini.getinikey("out_room1"), 5);
 tf43 = new tjtextfield(sunini.getinikey("out_room2"), 5);
 tf44 = new tjtextfield(sunini.getinikey("clockroom1"), 5);
 tf45 = new tjtextfield(sunini.getinikey("clockroom2"), 5);
 tf46 = new tjtextfield(sunini.getinikey("insuhour1"), 5);
 tf47 = new tjtextfield(sunini.getinikey("insuhour2"), 5);
 //设置文本框右对齐
 tf41.sethorizontalalignment(jtextfield.right);
 tf42.sethorizontalalignment(jtextfield.right);
 tf43.sethorizontalalignment(jtextfield.right);
 tf44.sethorizontalalignment(jtextfield.right);
 tf45.sethorizontalalignment(jtextfield.right);
 tf46.sethorizontalalignment(jtextfield.right);
 tf47.sethorizontalalignment(jtextfield.right);
 //不足一天是否按一天计价
 ck = new jcheckbox("入住时间不足一天的按一天计费");
 if(sunini.getinikey("insuday").equals("1")) {
 ck.setselected(true);
 }
 bt41 = new tjbutton ("pic/save.gif", " 保 存 ", "保存当前设置");
 bt42 = new tjbutton ("pic/exit.gif", " 返 回 ", "返回主窗口");
 
 paneljf = new jpanel(new borderlayout()); //计费主面板
 jftop = new jpanel(new gridlayout(2, 1)); //放左右面板
 jfleft = new jpanel(new gridlayout(4, 1)); //计费左面板
 jfright = new jpanel(new gridlayout(5, 1)); //计费右面板
 jfbott = new jpanel(new flowlayout(flowlayout.right, 40, 4));//按键面板
 
 jp1 = new jpanel(new flowlayout(flowlayout.left)); //左边的面板用到的
 jp2 = new jpanel(new flowlayout(flowlayout.left));
 jp3 = new jpanel(new flowlayout(flowlayout.left));
 jp4 = new jpanel(new flowlayout(flowlayout.left));
 jp5 = new jpanel(new flowlayout(flowlayout.left)); //右边的面板用到的
 jp6 = new jpanel(new flowlayout(flowlayout.left));
 jp7 = new jpanel(new flowlayout(flowlayout.left));
 jp8 = new jpanel(new flowlayout(flowlayout.left));
 jp9 = new jpanel(new flowlayout(flowlayout.right));
 
 //制作左边面板
 jp1.add(lb1);
 jp1.add(tf41);
 jp1.add(lb2);
 jp2.add(lb3);
 jp2.add(tf42);
 jp2.add(lb4);
 jp3.add(lb5);
 jp3.add(tf43);
 jp3.add(lb6);
 jp4.add(lb16); //假空格
 jp4.add(ck);
 
 jfleft.add(jp1);
 jfleft.add(jp2);
 jfleft.add(jp3);
 jfleft.add(jp4);
 
 //制作右边面板
 jp5.add(lb7);
 jp5.add(tf44);
 jp5.add(lb8);
 jp6.add(lb9);
 jp6.add(tf45);
 jp6.add(lb10);
 jp7.add(lb11);
 jp7.add(tf46);
 jp7.add(lb12);
 jp8.add(lb13);
 jp8.add(tf47);
 jp8.add(lb14);
 jp9.add(lb15);
 
 jfright.add(jp5);
 jfright.add(jp6);
 jfright.add(jp7);
 jfright.add(jp8);
 jfright.add(jp9);
 
 //组织两个表到一起
 jftop.add(jfleft);
 jftop.add(jfright);
 
 //组织按键面板
 jfbott.add(bt41);
 jfbott.add(bt42);
 
 //加入主面板
 paneljf.add("center", jftop);
 paneljf.add("south", jfbott);
 
 jfleft.setborder(borderfactory.createtitledborder("普通房间标准计费"));
 jfright.setborder ( borderfactory.createtitledborder ("钟点房标准计费") );
 return paneljf;
 }
 
 /**=======================================================================**
 * [## private boolean initmrt() {} ]: 
 * 参数 :无
 * 返回值 :boolean
 * 修饰符 :private
 * 功能 :传数据给修改房间类型窗口
 **=======================================================================**
 */
 private boolean initmrt() {
 int row = tb11.getselectedrow();
 if(row == -1) {
 joptionpane.showmessagedialog(null, "请在上面类型表中指定房间类型," +
 "才能执行修改操作", "提示", joptionpane.information_message);
 return false;
 }
 modiroomtype.tf0.settext(dtm11.getvalueat(row,2) + ""); //类型编号
 modiroomtype.tf1.settext(dtm11.getvalueat(row,4) + ""); //类型名称
 modiroomtype.tf2.settext(dtm11.getvalueat(row,7) + ""); //床位数量
 modiroomtype.tf3.settext(dtm11.getvalueat(row,5) + ""); //预设单价
 modiroomtype.tf4.settext(dtm11.getvalueat(row,3) + ""); //预设押金
 modiroomtype.tf5.settext(dtm11.getvalueat(row,6) + ""); //钟点计费
 string cl_room = dtm11.getvalueat(row, 8) + "";
 if(cl_room.equals("y")) {
 modiroomtype.chk.setselected(true); //允许提供钟点服务
 }
 else {
 modiroomtype.chk.setselected(false); //不允许提供钟点服务
 modiroomtype.tf5.setenabled(false); //设置钟点计费不可用
 }
 return true;
 }
 
 /**=======================================================================**
 * [## private boolean initmri() {} ]: 
 * 参数 :无
 * 返回值 :boolean
 * 修饰符 :private
 * 功能 :传数据给修改房间信息窗口
 **=======================================================================**
 */
 private boolean initmri() {
 int row = tb12.getselectedrow();
 if(row == -1) {
 joptionpane.showmessagedialog(null, "请在上面房间信息表中指定房间号," +
 "才能执行修改操作", "提示", joptionpane.information_message);
 return false;
 }
 modiroominfo.tf1.settext(dtm12.getvalueat(row, 2) + ""); //房间编号
 modiroominfo.tf2.settext(dtm12.getvalueat(row, 5) + ""); //所在区域
 modiroominfo.tf3.settext(dtm12.getvalueat(row, 6) + ""); //房间电话
 modiroominfo.pk = dtm12.getvalueat(row, 0) + ""; //获得当前行的pk
 try {
 resultset rs = sunsql.executequery("select r_type from roomtype " +
 "where delmark=0 and id='" + dtm12.getvalueat(row,1) + "'");
 rs.next();
 modiroominfo.cb1.setselecteditem(rs.getstring(1)); //房间类型
  }
  catch (exception ex) {
  system.out.println ("modiroominfo.initmri(): modi false");
  }//end try
  return true;
 }
 
 /**=======================================================================**
 * [## private boolean initmct() {} ]: 
 * 参数 :无
 * 返回值 :boolean
 * 修饰符 :private
 * 功能 :传数据给修改客户类型窗口
 **=======================================================================**
 */
 private boolean initmct() {
 int row = tb21.getselectedrow();
 if(row == -1) {
 joptionpane.showmessagedialog(null, "请在上面类型表中指定客户类型," +
 "才能执行修改操作", "提示", joptionpane.information_message);
 return false;
 }
 modicustomertype.tf1.settext(dtm21.getvalueat(row,1) + ""); //客户类型编号
 modicustomertype.tf2.settext(dtm21.getvalueat(row,3) + ""); //客户类型名称
 modicustomertype.tf3.settext(dtm21.getvalueat(row,4) + ""); //客户类型折扣
 modicustomertype.pk = dtm21.getvalueat(row, 0) + ""; //获得当前行的pk
 return true;
 }
 
 /**=======================================================================**
 * [## private boolean initdis(jtable dtb, defaulttablemodel ddtm) {} ]: 
 * 参数 :jtable 与 defaulttablemodel 为项目与折扣中的表
 * 返回值 :boolean
 * 修饰符 :private
 * 功能 :传数据给打折设置窗口
 **=======================================================================**
 */
 private boolean initdis(jtable dtb, defaulttablemodel ddtm) {
 int row = dtb.getselectedrow();
 if(row == -1) {
 joptionpane.showmessagedialog(null, "请在相应列表中指定房间类型," +
 "才能进行打折设置操作", "提示", joptionpane.information_message);
 return false;
 }
 try {
 discount.rt = ddtm.getvalueat(row, 2) + ""; //获得房间编号
 resultset rs = sunsql.executequery("select discount from customertype " +
 "where id='sysmark' and dis_attr='" + ddtm.getvalueat(row, 2) + "'");
 rs.next();
 int temp = rs.getint(1);
 if(temp == 10){
 discount.cb1.setselectedindex(1); //普通宾客不打折选项
 discount.tf1.setenabled(false);
 }else {
 discount.cb1.setselectedindex(0); //普通宾客打折选项
 discount.tf1.setenabled(true);
 }//endif
 discount.tf1.settext(temp + ""); //普通宾客的折扣
  }
  catch (exception ex) {
  }
 discount.lb1.settext(ddtm.getvalueat(row, 4) + ""); //房间类型名称
 discount.lb2.settext(ddtm.getvalueat(row, 5) + ""); //房间价格
 //初始化表格的dtm
 sunsql.initdtm(discount.dtm, "select c_type 客户等级,discount 享受折扣, " +
 "dis_price 折扣价格 from customertype where delmark=0 and dis_attr='" + 
 ddtm.getvalueat(row, 2) + "' and id!='sysmark'");
 //初始化会员等级combobox
 sunsql.initjcombobox(discount.cb2, "select c_type from customertype where " + 
 "delmark=0 and id!='sysmark' and dis_attr='" + ddtm.getvalueat(row, 2) + "'");
 
 return true;
 }
 
 /**=======================================================================**
 * [## private boolean delinfo (string tname, defaulttablemodel deldtm, int dr[], string m) {} ]: 
 * 参数 :sring tname 表示要执行删除的表名
 *  dtm deldtm 表示相关联的dtm
 *  int dr[] 要被执行删除的行数
 *  string m 提示信息
 * 返回值 :boolean
 * 修饰符 :private
 * 功能 :房间类型、房间信息和客户类型的删操作
 **=======================================================================**
 */
 private boolean delinfo (string tname, defaulttablemodel deldtm, int dr[], string m) {
 int rowcount = dr.length;
 int r =0;  //dtm行指针
 
 if(tname.equals ("roomtype")) { //如果删除房间类型,则删除与房间类型相关的房间信息与客户折扣设置
 rowcount = rowcount * 3;
 }//endif
 
 if(rowcount > 0) {  //判断选择记录数
 int isdel = joptionpane.showconfirmdialog (null, m, "提示", joptionpane.yes_no_option);
 if(isdel == joptionpane.yes_option) {
 string sqlcode[] = new string[rowcount];
 //生成sql语句
 for (int i = 0; i < rowcount; i++) {
  sqlcode[i] = "update " + tname +" set delmark=1 where pk=" + deldtm.getvalueat(dr[r], 0) + " and id='" + deldtm.getvalueat(dr[r],2) + "'";
  if(tname.equals ("roomtype")) { //如果删除房间类型,则同时删除相关房间信息
  i++;
  sqlcode[i] = "update roominfo set delmark=1 where id='sunhotel' or r_type_id='" + deldtm.getvalueat(dr[r],2) + "'";
  i++;
  sqlcode[i] = "update customertype set delmark=1 where id='sunhotel' or dis_attr='" + deldtm.getvalueat(dr[r],2) + "'";
  }
  r++; //dtm行指针加1
  }//endfor
  //以事务模式执行sql语句组, 确保操作正确, 返回值为成功执行sql语句的条数
  isdel = sunsql.runtransaction(sqlcode); 
  if(isdel != rowcount) { //如果成功执行的条数 = 数组长度,则表示更新成功
  string mm = "在执行第 [ " + (isdel + 1) + " ] 条记录的删除操作时出错,数据有可能被其它终端修改\n或者是网络不通畅 ...";
  joptionpane.showmessagedialog(null, mm, "错误",joptionpane.error_message);
  //更新失败,返回false
  return false;
  }//endif
  return true; //更新成功,返回true
 }//endif
 }
 else  //如果没有选中记录,则提示一下
 joptionpane.showmessagedialog(null, msg1, "提示",joptionpane.information_message);
 return false;
 }
 
 /**=======================================================================**
 * [## private void umadd () {} ]: 添加操作
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :添加新的用户id
 **=======================================================================**
 */
 private void umadd () {
 string pwd1 = string.valueof(tf32.getpassword());
 string pwd2 = string.valueof(tf33.getpassword());
 string pu = "普通操作员"; //用户权限
 if(!pwd1.equals (pwd2)) { //两次密码不相等
 joptionpane.showmessagedialog (null, "输入错误,[ 新密码 ] 与 [ 确认密码 ] " +
 "不正确,请重新输入 ...", "错误",joptionpane.error_message);
 return;
 }//endif
 string umname = cb31.geteditor ().getitem () + "";//获得用户名
 try {
 resultset rs = sunsql.executequery ("select userid from pwd where delmark=0 " +
 "and userid='" + umname + "'");
 
 int isid = sunsql.reccount(rs);
 if(isid > 0){  //当前要加入的用户名是否存在
 joptionpane.showmessagedialog (null, "管理员id [ " + umname + " ] 已存在," +
 "请重新输入 ...", "错误",joptionpane.error_message);
 return;
 }//endif
 if(rb35.isselected()) //获得是否是管理员权限
 pu = "管理员";
 long pk = sunsql.getprimarykey();//从服务获得主键
 //记入数据库
 isid = sunsql.executeupdate("insert into pwd(pk,userid,pwd,puis) values(" + pk + 
 ",'" + umname + "','" + pwd1 + "','" + pu + "')");
 
 if(isid == 0) {
 joptionpane.showmessagedialog (null, "添加操作失败,请检查网络连接是否正常 " +
 "...", "错误",joptionpane.error_message);
 return;
 }
 tf32.settext(""); //清空密码
 tf33.settext("");
  }
  catch (exception ex) {
  system.out.println ("userid.umadd(): add new id error.");
  }//end try
 }
 
 /**=======================================================================**
 * [## private void umupdate (int type) {} ]: 更新删除操作
 * 参数 :int 变量表示操作类型 0:表示修改密码 1:表示删除记录
 * 返回值 :无
 * 修饰符 :private
 * 功能 :修改密码和删除用户id
 **=======================================================================**
 */
 private void umupdate (int type) {
 string umname = cb31.getselecteditem() + ""; //获得用户名
 string pwd0;
 string pwd1 = string.valueof (tf32.getpassword ());
 string pwd2 = string.valueof (tf33.getpassword ());
 
 int isid = 0;  //用户是否存在
 if(!pwd1.equals (pwd2)) { //两次密码不相等
 joptionpane.showmessagedialog (null, "输入错误,[ 新密码 ] 与 [ 确认密码 ] " +
 "不正确,请重新输入 ...", "错误",joptionpane.error_message);
 return;
 }//endif
 if(type == 0) 
 pwd0 = string.valueof (tf31.getpassword ());//取修改操作的密码
 else
 pwd0 = string.valueof (tf32.getpassword ());//取删除操作的密码
 try {
 resultset rs = sunsql.executequery ("select pwd from pwd where delmark=0 and " +
 "userid='" + umname + "'");
 
 rs.next();
 if(!pwd0.equals(rs.getstring(1))){  //判断原密码是否正确
 joptionpane.showmessagedialog (null, "管理员id [ " + umname + " ] 的 [ 原" +
 "密码 ] 不正确,请重新输入 ...", "错误",joptionpane.error_message);
 
 return;
 }//endif
 if(type == 0) { //执行修改密码操作
 isid = sunsql.executeupdate("update pwd set pwd='" + pwd1 + "' where " +
 "delmark=0 and userid='" + umname + "'");
 }else { //执行删除操作
 isid = sunsql.executeupdate("update pwd set delmark=1 where userid='" + umname + "'");
 }//endif
  }
  catch (exception ex) {
  }//end try
 if(isid == 0) { //判断操作是否成功
 joptionpane.showmessagedialog (null, "执行操作失败,请检查网络连接是否正常 ...", "错误",joptionpane.error_message);
 }
 tf31.settext(""); //清空密码
 tf32.settext("");
 tf33.settext("");
 return;
 }
 
 //检查计费设置是否合法
 private boolean isvalidity() {
 if(!suntools.isnum(tf41.gettext(), 1, 6, 9)) {
 joptionpane.showmessagedialog(null, "[ 计费参数 1 ] 只能是数字,且范围在 6-9 之间", 
 "提示", joptionpane.information_message);
 tf41.requestfocus(true);
 return false;
 }else if(!suntools.isnum(tf42.gettext(), 2, 11, 13)) {
 joptionpane.showmessagedialog(null, "[ 计费参数 2 ] 只能是数字,且范围在 11-13 之间", 
 "提示", joptionpane.information_message);
 tf42.requestfocus(true);
 return false;
 }else if(!suntools.isnum(tf43.gettext(), 2, 17, 19)) {
 joptionpane.showmessagedialog(null, "[ 计费参数 3 ] 只能是数字,且范围在 17-19 之间", 
 "提示", joptionpane.information_message);
 tf43.requestfocus(true);
 return false;
 }else if(!suntools.isnum(tf44.gettext(), 1, 0, 5)) {
 joptionpane.showmessagedialog(null, "[ 钟点计费参数 1 ] 只能是数字,且范围在 0-5 之间", 
 "提示", joptionpane.information_message);
 tf44.requestfocus(true);
 return false;
 }else if(!suntools.isnum(tf45.gettext(), 1, 1, 5)) {
 joptionpane.showmessagedialog(null, "[ 钟点计费参数 2 ] 只能是数字,且范围在 1-5 之间", 
 "提示", joptionpane.information_message);
 tf45.requestfocus(true);
 return false;
 }else if(!suntools.isnum(tf46.gettext(), 2, 20, 40)) {
 joptionpane.showmessagedialog(null, "[ 钟点计费参数 3 ] 只能是数字,且范围在 20-40 之间", 
 "提示", joptionpane.information_message);
 tf46.requestfocus(true);
 return false;
 }else if(!suntools.isnum(tf47.gettext(), 2, 5, 15)) {
 joptionpane.showmessagedialog(null, "[ 钟点计费参数 4 ] 只能是数字,且范围在 5-15 之间", 
 "提示", joptionpane.information_message);
 tf47.requestfocus(true);
 return false;
 }//endif
 return true;
 }
 
 /**=======================================================================**
 * [## private boolean isstate(int arow[]) {} ]: 
 * 参数 :int arom[] 表示要执行删除操作的行号
 * 返回值 :boolean
 * 修饰符 :private
 * 功能 :检查房间的状态是否可以删除
 **=======================================================================**
 */
 private boolean isstate(int arow[]) {
 int ar = arow.length;
 resultset rs = null;
 string astate = "";
 try {
 for (int i = 0; i < ar; i++) {
 rs = sunsql.executequery("select state from roominfo where " +
 "delmark=0 and pk='" + dtm12.getvalueat(arow[i], 0) + "'");
 rs.next();
 astate = rs.getstring(1);
 if(astate.equals("占用")) {
  joptionpane.showmessagedialog(null, "[ " + dtm12.getvalueat(arow[i], 2) + 
  " ] 房间正处于占用状态,无法执行删除操作,系统取消了所有删除操作", "提示", joptionpane.information_message);
  return false;
 }else if(astate.equals("钟点")) {
  joptionpane.showmessagedialog(null, "[ " + dtm12.getvalueat(arow[i], 2) + 
  " ] 房间正处于钟点房状态,无法执行删除操作,系统取消了所有删除操作", "提示", joptionpane.information_message);
  return false;
 }else if(astate.equals("预订")) {
  joptionpane.showmessagedialog(null, "[ " + dtm12.getvalueat(arow[i], 2) + 
  " ] 房间正处于预订状态,无法执行删除操作,系统取消了所有删除操作", "提示", joptionpane.information_message);
  return false;
 }//endif
  }//endif
  }
  catch (exception ex) {
  ex.printstacktrace();
  system.out.println ("setup.isstate(): false");
  }//end try
  return true;
 }
 
 
 
 
 /**=======================================================================**
 * actionlistener 监听
 **=======================================================================**
 */
 public void actionperformed(actionevent ae) {
 object o = ae.getsource();
 if(o == bt11) {//=======================================================
 art.show(true);  //添加房间类型
 builddtm11();  //刷新表数据
 builddtm12("");  //刷新表数据
 builddtm22();  //刷新表数据
 
 }else if(o == bt12) {//=================================================
 if(initmrt()) {  //传数据给窗口
 mrt.show(true); //修改房间类型
 builddtm11(); //刷新表数据
 builddtm12(""); //刷新表数据
 builddtm22(); //刷新表数据
 }//endif
 
 }else if(o == bt13) {//=================================================
 int rrow[] = tb11.getselectedrows(); //删除房间类型
 int sysmark;
 for (int i = 0; i < rrow.length; i++) {
  //获得得记录的属性标志,并转成整型
  sysmark = integer.parseint(dtm11.getvalueat(rrow[i], 1) + "");
  if(sysmark == 1) {
  joptionpane.showmessagedialog(null, "[ " + dtm11.getvalueat(rrow[i], 4) + 
  " ] 类型为系统级设置,不允许被删除,系统终止了删除操作 ...", "提示",
  joptionpane.information_message);
  return; //不执行删除返回窗口
  }//endif
  }//endfor
 string msg = "注意,删除 [ 房间类型 ] 操作会将与 [ 房间类型 ] 相关" +
 "的所有 [ 房间信息 ] 一并删除。\n您确定要删除在表格中选中的类型条目吗?";
 
 if(delinfo ("roomtype", dtm11, rrow, msg)) { //执行删除操作
  builddtm11(); //刷新类型表数据
  builddtm12(""); //刷新房间表数据
  builddtm22(); //刷新类型表数据
  journal = "执行了删除房间类型的操作--删除数量:" + rrow.length;
  journal.writejournalinfo(hotelframe.userid, journal, journal.type_rt);//记录操作日志
 }//endif
 
 }else if(o == bt14) {//=================================================
 if(initdis(tb11, dtm11)) { //房间费打折
 dis.show(true);
 }//endif
 }else if(o == bt15) {//=================================================
 sunsql.initjcombobox(addroominfo.cb1, "select r_type from roomtype where delmark = 0");
 ari.show(true);  //单个添加房间信息
 builddtm12("");  //刷新表数据
 
 }else if(o == bt16) {//=================================================
 sunsql.initjcombobox(addroominfos.cb, "select r_type from roomtype where delmark = 0");
 aris.show(true); //批量添加房间信息
 builddtm12("");  //刷新表数据
 
 }else if(o == bt18) {//=================================================
 sunsql.initjcombobox(modiroominfo.cb1, "select r_type from roomtype where delmark = 0");
 if(initmri()) {  //传数据给窗口
 mri.show(true); //修改房间信息
 builddtm12(""); //刷新表数据
 }//endif
 
 }else if(o == bt17) {//=================================================
 int rrow[] = tb12.getselectedrows(); //删除房间信息
 if(isstate(rrow)) { //判断房间的状态是否可以删除
 if(delinfo ("roominfo", dtm12, rrow, msg0)) { //执行删除操作
  builddtm12(""); //刷新房间表数据
  journal = "执行了删除房间信息的操作--删除数量:" + rrow.length;
  journal.writejournalinfo(hotelframe.userid, journal, journal.type_ri);//记录操作日志
 }//endif
 }
 }else if(o == bt19) {//=================================================
 if(!suntools.isnum(tf11.gettext(),2 ,5 ,30)) { //保存退房后房间状态
 joptionpane.showmessagedialog(null, "结算后更改房间状态的时间框只能为数字,且范围在 5 - 30 之间",
 "提示", joptionpane.information_message);
 tf11.requestfocus(true);
 return;
 }
 sunini.setinikey(ini[16], cb12.getselectedindex() + ""); //将设置保存至缓冲区
 sunini.setinikey(ini[17], tf11.gettext()); 
 sunini.saveini(ini);  //将缓冲区的设置保存至ini文件
 
 }else if(o == bt20) {//=================================================
 int cbindex = cb11.getselectedindex(); //筛选信息
 if(cbindex == cb11.getitemcount() - 1) { //显示全部房间
  builddtm12("");  //刷新房间表数据
 }else {
  string rt = "and a.r_type_id = '" + dtm11.getvalueat(cbindex, 2) + "'";
  builddtm12(rt);  //根据指定房间类型刷新表数据
 }//endif
 
 }else if(o == bt21) {//=================================================
 act.show(true);  //添加客户类型
 builddtm21();
 
 }else if(o == bt22) {//=================================================
 if(initmct()) {  //传数据给窗口
 mct.show(true); //修改客户类型
 builddtm21(); //刷新表数据
 }//endif
 
 }else if(o == bt23) {//=================================================
 int rrow[] = tb21.getselectedrows(); //删除客户类型
 if(delinfo ("customertype", dtm21, rrow, msg0)) { //执行删除操作
 builddtm21(); //刷新房间表数据
 journal = "执行了删除客户类型的操作--删除数量:" + rrow.length;
 journal.writejournalinfo(hotelframe.userid, journal, journal.type_us);//记录操作日志
 }//endif
 
 }else if(o == bt24) {//=================================================
 if(initdis(tb22, dtm22)) { //房间费打折
 dis.show(true);
 }//endif
 }else if(o == bt31) {//===================================//登记操作员信息
 if(string.valueof(tf32.getpassword()).length() == 0) {
  joptionpane.showmessagedialog(null, " [ 新密码 ] 不能为空", "提示", 
  joptionpane.information_message);
  return;
 }else if(string.valueof(tf33.getpassword()).length() == 0) {
 joptionpane.showmessagedialog(null, " [ 确认密码 ] 不能为空", "提示", 
 joptionpane.information_message);
 return;
 }//endif
 umadd ();  //执行添加操作
 builddtm31(); //刷新表数据
 journal = "添加了新的操作员信息-- [ " + cb31.geteditor ().getitem () + " ]";
 journal.writejournalinfo(hotelframe.userid, journal, journal.type_cz);//记录操作日志
 
 }else if(o == bt32) {//==================================//修改操作员信息
 if(string.valueof(tf31.getpassword()).length() == 0) {
 joptionpane.showmessagedialog(null, " [ 新密码 ] 不能为空", "提示", 
 joptionpane.information_message);
 return;
 }else if(string.valueof(tf32.getpassword()).length() == 0) {
 joptionpane.showmessagedialog(null, " [ 新密码 ] 不能为空", "提示", 
 joptionpane.information_message);
 return;
 }else if(string.valueof(tf33.getpassword()).length() == 0) {
 joptionpane.showmessagedialog(null, " [ 确认密码 ] 不能为空", "提示", 
 joptionpane.information_message);
 return;
 }//endif
 umupdate (0); //执行修改密码操作
 journal = "修改了操作员 [ " + cb31.geteditor ().getitem () + " ] 的设置";
 journal.writejournalinfo(hotelframe.userid, journal, journal.type_cz);//记录操作日志
 
 }else if(o == bt33) {//=================================================//删除操作员信息
 if(string.valueof(tf32.getpassword()).length() == 0) {
 joptionpane.showmessagedialog(null, " [ 新密码 ] 不能为空", "提示", 
 joptionpane.information_message);
 return;
 }else if(string.valueof(tf33.getpassword()).length() == 0) {
 joptionpane.showmessagedialog(null, " [ 确认密码 ] 不能为空", "提示", 
 joptionpane.information_message);
 return;
 }//endif
 int wi = joptionpane.showconfirmdialog(null,"您确认要删除当前的用户id吗?", 
 "提示", joptionpane.yes_no_option);
 
 if(wi == joptionpane.yes_option) {
 umupdate (1); //执行删除用户id操作
 builddtm31(); //刷新表数据
 journal = "删除了操作员 [ " + cb31.geteditor ().getitem () + " ] 的设置";
 journal.writejournalinfo(hotelframe.userid, journal, journal.type_cz);//记录操作日志
 }//endif
 
 }else if(o == bt41) {//=================================================
 if(isvalidity()) {
 int savejf = joptionpane.showconfirmdialog(null, "您 确 实 要 保 存 " +
 "当 前 的 计 费 设 置 吗 ?","保存设置",joptionpane.yes_no_option);
 if(savejf == joptionpane.yes_option) { //保存计费设置
  sunini.setinikey("in_room", tf41.gettext()); //将设置保存至缓冲区
  sunini.setinikey("out_room1", tf42.gettext());
  sunini.setinikey("out_room2", tf43.gettext());
  sunini.setinikey("clockroom1", tf44.gettext());
  sunini.setinikey("clockroom2", tf45.gettext());
  sunini.setinikey("insuhour1", tf46.gettext());
  sunini.setinikey("insuhour2", tf47.gettext());
  if(ck.isselected()) {  //不足一天按一天收费
  sunini.setinikey("insuday","1");
  }else {
  sunini.setinikey("insuday","0");
  }//endif
  sunini.saveini(ini);  //将缓冲区的设置保存至ini文件
  journal = "修改了系统的计费设置";
  journal.writejournalinfo(hotelframe.userid, journal, journal.type_jf);//记录操作日志
 }//endif
 }//endif
 }else if(o == bt42) {//=================================================
 this.setvisible(false); //返回主窗口
 }else if(o == tf41) {
 tf42.requestfocus(true);
 }else if(o == tf42) {
 tf43.requestfocus(true);
 }else if(o == tf43) {
 tf44.requestfocus(true);
 }else if(o == tf44) {
 tf45.requestfocus(true);
 }else if(o == tf45) {
 tf46.requestfocus(true);
 }else if(o == tf46) {
 tf47.requestfocus(true);
 
 }else if(o == rb31) {//=================================================
 bt31.setenabled (true); //操作范围--添加新操作员
 bt32.setenabled (false);
 bt33.setenabled (false);
 rb34.setenabled (true);
 rb35.setenabled (true);
 tf31.seteditable(false);
 tf32.seteditable(true);
 tf33.seteditable(true);
 cb31.seteditable (true);
 
 }else if(o == rb32) { //操作范围--操作员修改密码
 bt31.setenabled (false);
 bt32.setenabled (true);
 bt33.setenabled (false);
 rb34.setenabled (false);
 rb35.setenabled (false);
 tf31.seteditable(true);
 tf32.seteditable(true);
 tf33.seteditable(true);
 cb31.seteditable (false);
 
 }else if(o == rb33) { //操作范围--删除操作员
 bt31.setenabled (false);
 bt32.setenabled (false);
 bt33.setenabled (true);
 rb34.setenabled (false);
 rb35.setenabled (false);
 tf31.seteditable(false);
 tf32.seteditable(true);
 tf33.seteditable(true);
 cb31.seteditable (false);
 }//endif
 }//end actionperformed
 
 
 /**=======================================================================**
 * mouselistener 监听
 **=======================================================================**
 */
 public void mouseclicked (mouseevent me) {
 }
 
 public void mousepressed (mouseevent me) {
 }
 
 public void mousereleased(mouseevent me) {
 }
 
 public void mouseentered (mouseevent me) { //鼠标移进提示
 object o = me.getsource ();
 if(o == bt11) {
 hotelframe.lba.settext (hotelframe.clue + 
 "添加新的房间类型 ");
 }else if(o == bt12) {
 hotelframe.lba.settext (hotelframe.clue + 
 "修改指定的房间类型 ");
 }else if(o == bt13) {
 hotelframe.lba.settext (hotelframe.clue + 
 "删除指定的房间类型 ");
 }else if(o == bt14) {
 hotelframe.lba.settext (hotelframe.clue + 
 "设置指定房间类型的消费折扣 ");
 }else if(o == bt15) {
 hotelframe.lba.settext (hotelframe.clue + 
 "为指定的房间类型添加新的客房 ");
 }else if(o == bt16) {
 hotelframe.lba.settext (hotelframe.clue + 
 "为指定的房间类型一次添加多个新客房 ");
 }else if(o == bt17) {
 hotelframe.lba.settext (hotelframe.clue + 
 "修改指定客房信息设置 ");
 }else if(o == bt18) {
 hotelframe.lba.settext (hotelframe.clue + 
 "删除指定的客房 ");
 }else if(o == bt19) {
 hotelframe.lba.settext (hotelframe.clue + 
 "保存房间退房后的状态 ");
 }else if(o == bt20) {
 hotelframe.lba.settext (hotelframe.clue + 
 "以左边指定的类型显示房间信息 ");
 } if(o == bt21) {
 hotelframe.lba.settext (hotelframe.clue + 
 "添加新的客户类型 ");
 }else if(o == bt22) {
 hotelframe.lba.settext (hotelframe.clue + 
 "修改指定的客户资料 ");
 }else if(o == bt23) {
 hotelframe.lba.settext (hotelframe.clue + 
 "删除指定的客户资料 ");
 }else if(o == bt24) {
 hotelframe.lba.settext (hotelframe.clue + 
 "设置指定房间类型的消费折扣 ");
 }else if(o == bt31) {
 hotelframe.lba.settext (hotelframe.clue + 
 "添加新的操作员 ");
 }else if(o == bt32) {
 hotelframe.lba.settext (hotelframe.clue + 
 "修改指定的操作员密码 ");
 }else if(o == bt33) {
 hotelframe.lba.settext (hotelframe.clue + 
 "删除指定的操作员 ");
 }else if(o == bt41) {
 hotelframe.lba.settext (hotelframe.clue + 
 "保存当前的计费设置至ini配置文件 ");
 }else if(o == bt42) {
 hotelframe.lba.settext (hotelframe.clue + 
 "返回主窗口 ");
 }
 }
 
 public void mouseexited (mouseevent me) {
 hotelframe.lba.settext (hotelframe.clue + 
 "请选择功能项 ... ");
 }
 
}
3.登录窗口:
/**
 *##############################################################################
 *
 * [ 项目名  ] : 阳光酒店管理系统
 * [ 公司名  ] : 清华it
 * [ 模块名  ] : 系统登陆窗口
 * [ 文件名  ] : login.java
 * [ 相关文件 ] : 
 * [ 文件实现功能] : 系统登陆窗口
 * [ 作者  ] : 顾俊
 * [ 版本  ] : 1.1
 * ----------------------------------------------------------------------------
 * [ 备注  ] : 
 * ----------------------------------------------------------------------------
 * [ 修改记录 ] : 
 *
 * [ 日 期 ]  [版本]   [修改人]   [修改内容] 
 * 2006/04/02  1.0  顾俊   创建
 * 2006/04/06  1.1  顾俊   增加注释
 * 2006/04/19  1.2  顾俊   自动记录登录日志
 * ##--------------------------------------------------------------------------
 *  版权所有(c) 2006-2007, sunshinesoft corporation
 * --------------------------------------------------------------------------##
 * 
 * [ 函数说明 ] :
 *
 * [## public login() {} ]:
 * 功能: 构造函数 组建登录窗口
 *
 * [## private void buildcenter() {} ]:
 * 功能: 组建用户名密码面板,仅类内使用
 *
 * [## private void quit() {} ]: 
 * 功能: 关闭系统函数,仅类内使用
 *
 * [## private void denglu() {} ]:
 * 功能: 密码验证通过,进入主操作界面,仅类内使用
 *
 * [ 遗留问题 ] : 
 *
 *##############################################################################
 */
//package com.sunshine.login;
 
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import com.sunshine.sunsdk.sql.*;
import com.sunshine.sunsdk.swing.*;
import com.sunshine.sunsdk.system.*;
import com.sunshine.mainframe.*;
 
 
public class login extends jframe
implements actionlistener, keylistener, itemlistener, focuslistener {
 
 jlabel top, bott;
 jcombobox cb;
 jpasswordfield pf;
 jbutton bt1, bt2;
 jpanel panelmain, panelinfo;
 string clue = " 提 示 : ";
 int flag = 0; //登记次数记数器
 
 
 
 /**=======================================================================**
 * [## public login() {} ]:  构造函数
 * 参数 :无
 * 返回值 :无
 * 修饰符 :public
 * 功能 :组建登录窗口
 **=======================================================================**
 */
 public login() {
 super("系 统 登 录");
 top = new jlabel (new imageicon("pic/login_top.gif"));
 bott = new jlabel();
 panelmain = new jpanel(new borderlayout(10, 10));
 bott.setborder(new lineborder (new color(184, 173, 151)));
 buildcenter();
 
 panelmain.add("north", top);
 panelmain.add("south", bott);
 panelmain.add(panelinfo);
 
 //加事件监听
 bt1.addactionlistener(this);
 bt2.addactionlistener(this);
 bt1.addfocuslistener (this);
 bt2.addfocuslistener (this);
 bt1.addkeylistener (this);
 bt2.addkeylistener (this);
 cb.additemlistener (this);
 cb.addfocuslistener(this);
 pf.addfocuslistener(this);
 cb.addkeylistener (this);
 pf.addkeylistener (this);
 
 //加窗口监听 new windowadapter适配器类
 this.addwindowlistener(new windowadapter() {
 public void windowclosing(windowevent we) {
 quit();
 }//end windowclosing
 });
 
 this.setcontentpane(panelmain); //设置窗口面板
 this.setsize(350, 235);
 this.setresizable (false); //设置窗口不可放大缩小
 this.setdefaultcloseoperation(jframe.do_nothing_on_close);
 sunswing.setwindowcenter(this);
 this.setvisible(true);
 pf.requestfocus(true); //设置焦点给密码框
 }
 
 /**=======================================================================**
 * [## private void buildcenter() {} ]: 制作用户名密码面板
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :组建用户名密码面板,仅类内使用
 **=======================================================================**
 */
 private void buildcenter() {
 
 jlabel lb1, lb2;
 jpanel pa1, pa2, pa3;
 
 lb1 = new jlabel("用 户 名 :");
 lb2 = new jlabel("登录密码 :");
 cb = new jcombobox();
 pf = new tjpasswordfield (15);
 bt1 = new tjbutton ("pic/key.gif", "登 录", "登录系统");
 bt2 = new tjbutton ("pic/exit.gif", "退 出", "关闭系统");
 sunsql.initjcombobox (cb, "select userid from pwd where delmark=0");
 
 //定义面板为无部局
 panelinfo = new jpanel(null);
 //加入组件
 panelinfo.add(lb1);
 panelinfo.add(lb2);
 panelinfo.add(cb);
 panelinfo.add(pf);
 panelinfo.add(bt1);
 panelinfo.add(bt2);
 
 lb1.setbounds(50,14,60,20);
 lb2.setbounds(50,48,60,20);
 bt1.setbounds(68,77,86,28);
 bt2.setbounds(186,77,86,28);
 cb.setbounds (115,12,168,23);
 pf.setbounds (115,46,170,23);
 
 //设定边框线
 panelinfo.setborder(borderfactory.createtitledborder(""));
 }
 
 /**=======================================================================**
 * [## private void quit() {} ]:  系统退出
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :关闭系统函数,仅类内使用
 **=======================================================================**
 */
 private void quit() {
 int flag = 0;
 string msg = "您 现 在 要 关 闭 系 统 吗 ?";
 flag = joptionpane.showconfirmdialog(null, msg, "提示", joptionpane.yes_no_option);
 if(flag == joptionpane.yes_option) {
 this.setvisible(false);
 system.exit(0);
 }//end if(flag == joptionpane.yes_option)
 return;
 }
 
 /**=======================================================================**
 * [## private void denglu() {} ]: 系统登录
 * 参数 :无
 * 返回值 :无
 * 修饰符 :private
 * 功能 :密码验证通过,进入主操作界面,仅类内使用
 **=======================================================================**
 */
 private void denglu() {
 string user = cb.getselecteditem() + "";
 string pwd = string.valueof(pf.getpassword());
 string code = "select pwd,puis from pwd where delmark=0 and userid='" + user + "'";
 resultset rs = sunsql.executequery (code);
 try {
 if(rs.next()) { //用户名存在
 if(pwd.equals(rs.getstring(1))) {
  bott.settext(clue + "登录成功,正在进入系统 ...");
  string puis = rs.getstring(2); //获得操作员权限
  boolean flag = journal.writejournalinfo(user, "登录本系统", journal.type_lg);
  if(flag) { //记录日志
  new com.sunshine.mainframe.hotelframe(user, puis); //进入主程序窗口(用户名, 权限)
  this.setvisible(false);
  }else {
  string msg = "写日志错误,请与系统管理员联系 ...";
  joptionpane.showmessagedialog(null, msg, "错误", joptionpane.error_message);
  system.exit(0);
  }
 }
 else {
  bott.settext(clue + "用户 [ " + user + " ] 的密码不正确,请重新输入 ...");
  flag++;
  if(flag == 3) { //三次密码验证
  joptionpane.showmessagedialog(null, "您不是本系统的管理员,系统关闭 ...", "警告", joptionpane.error_message);
  system.exit(0);
  }//end if(flag == 3)
  return;
 }//end if(pwd.equals(rs.getstring(1)))
 }
 else {
 bott.settext(clue + "用户id [ " + user + " ] 不存在 ...");
 }//end if(rs.next()) 
 }
 catch (exception ex) {
 ex.printstacktrace();
 }//end try
 }
 
 
 
 /**=======================================================================**
 * actionlistener 监听
 **=======================================================================**
 */
 public void actionperformed (actionevent ae) {
 //动作监听
 if(ae.getsource() == bt1) { //登录按键
 denglu();
 }
 else {
 quit();
 }//end if(ae.getsource() == bt1)
 }
 
 
 /**=======================================================================**
 * itemlistener 监听
 **=======================================================================**
 */
 public void itemstatechanged (itemevent ie) {
 pf.requestfocus(true);
 }
 
 
 /**=======================================================================**
 * keylistener 监听
 **=======================================================================**
 */
 public void keypressed (keyevent ke) {
 //键盘按下监听
 int key = ke.getkeycode();
 if(key == keyevent.vk_enter) {
 if(ke.getsource() == cb)
 pf.requestfocus(true); //将焦点从用户名给密码
 if(pf.getpassword().length > 0)
 denglu();  //按enter键登录系统
 }
 else if(key == keyevent.vk_escape) { //按esc键退出系统
 quit();
 }//end if
 }
 
 public void keyreleased (keyevent ke) {
 //键盘释放监听
 }
 
 public void keytyped (keyevent ke) {
 //按键型监听
 }
 
 
 /**=======================================================================**
 * focuslistener 监听
 **=======================================================================**
 */
 public void focusgained (focusevent fe) {
 //焦点监听
 if(fe.getsource() == cb) //窗口最下方的功能提示
 bott.settext(clue + "请选择操作员名称 ...");
 else
 if(fe.getsource() == pf)
 bott.settext(clue + "请输入登录密码 ...");
 else
 if(fe.getsource() == bt1)
  bott.settext(clue + "登录系统 ...");
 else
  if(fe.getsource() == bt2)
  bott.settext(clue + "退出系统 ...");
 }
 
 public void focuslost (focusevent fe) {
 //失去焦点监听
 }
 
 
 
 /**=======================================================================**
 * [## public static void main(string sd[]) {} ]: 主函数
 * 参数 :string sd[] 
 * 返回值 :无
 * 修饰符 :public static
 * 功能 :程序入口
 **=======================================================================**
 */
 public static void main(string sd[]) {
 sunswing.setwindowstyle(sunini.getinikey("sys_style").charat(0));
 new fstartwindow ("pic/login.gif", new frame(), 1200);
 new login();
 }
 
}
获取地址:java swing实现酒店管理系统
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持CodeAE代码之家
原文链接:https://blog.csdn.net/llqqxf/article/details/51886891

关注下面的标签,发现更多相似文章