【文章內(nèi)容簡介】
etSelectedRows if tb2getRowCount arowslength 1 JOptionPaneshowMessageDialog null [ 散客開單 ] 至少要開設一個房間 提示 JOptionPaneINFORMATION_MESSAGE return int ar 0 int zr zRooms 記錄房間數(shù)量配合事務工作 String sqlCode[] new String[arowslength 2] if arowslength 0 for int i 0 i arowslength i sqlCode[ar] dtm2getValueAt arows[i] 0 if sqlCode[ar]equals lbAgetText 判斷主房間不能刪除 sqlCode[ar] delete from roomnum where roomid dtm2getValueAt arows[i] 0 移除開單列表 ar 清除可供列表 sqlCode[ar] update roominfo set indimark 0 where delmark 0 and id dtm2getValueAt arows[i] 0 ar zRooms 記數(shù)器 1 else JOptionPaneshowMessageDialog null [ dtm2getValueAt arows[i] 0 ] 房間是主房間不能移除 提示 JOptionPaneINFORMATION_MESSAGE zRooms ar return Endif Endfor int flag sunsqlrunTransaction sqlCode if flag arowslength JOptionPaneshowMessageDialog null 移除失敗請檢查網(wǎng)絡情況 提示 JOptionPaneINFORMATION_MESSAGE zRooms zr return Endif initDTM1 刷新可供列表 initDTM2 刷新開單列表 else JOptionPaneshowMessageDialog null 請在開單列表中選中指定房間 再移除 提示 JOptionPaneINFORMATION_MESSAGE return endif String sqlCode[] new String[tb2getRowCount 2] 要存數(shù)數(shù)還要改狀態(tài)所以是兩倍大小的 SQL 數(shù)組 try int rcss 0 表格記錄指針 for int i 0 i tb2getRowCount 2 i sqlCode[i] insert into livein pkin_nor_nor_type_idmain_room main_pkc_type_idc_namesexzj_typezj_noaddressrenshuin_timedays foregiftremarkuseridcluemark values pkMain rcss inNumber dtm2getValueAt rcss 0 roomType roomMain pkMain cType cName sex zjType zjNo address renShu inTime days foregift reMark userid cluemark 寫入了一條入住信息 i if chk1isSelected sqlCode[i] update roominfo set state 鐘點 where delmark 0 and id dtm2getValueAt rcss 0 鐘點房狀態(tài)設置 更換房間狀態(tài)圖片 RightTopPanelsetViewListButtonImage roomType dtm2getValueAt rcss 0 鐘點 else sqlCode[i] update roominfo set state 占用 where delmark 0 and id dtm2getValueAt rcss 0 普通入住狀態(tài)設置 更換房間狀態(tài)圖片 RightTopPanelsetViewListButtonImage roomType dtm2getValueAt rcss 0 占用 Endif rcss DTM 指針 1 Endfor 以事務的方式提交給數(shù)據(jù)庫 int livins sunsqlrunTransaction sqlCode if livins tb2getRowCount 2 JOptionPaneshowMessageDialog null 開設房間操作失敗請檢查網(wǎng)絡 連 接 或 聯(lián) 系 管 理 員 提示 JOptionPaneINFORMATION_MESSAGE 如果事務失敗的話則恢復狀態(tài)圖片 for int i 0 i tb2getRowCount i RightTopPanelsetViewListButtonImage roomType dtm2getValueAt rcss 0 可供 return 用戶繼續(xù)輸入 Endif 旅客續(xù)住 賓客入住酒店 后如果如果想續(xù)住原來的房間操作員通過賓客續(xù)住界面可以對續(xù)住的天數(shù)和賓客的押金進行追改賓客續(xù)住界面如圖 45 所示 圖 45 旅客續(xù)住 賓客續(xù)住主要代碼 public GoOn JFrame frame super frame 賓客續(xù)住 true JLabel lb new JLabel panelMain new JPanel new BorderLayout 07 主面板為邊界布局 ps new JPanel new FlowLayout FlowLayoutCENTER207 pc new JPanel new FlowLayout FlowLayoutCENTER107 buildPC buildPS panelMainadd Northlb panelMainadd pc panelMainadd Southps addListener thissetContentPane panelMain thissetPreferredSize new Dimension 270195 thissetMinimumSize new Dimension 270195 thissetResizable false 不允許改變窗口大小 pack sunswingsetWindowCenter this 窗口屏幕居中 更換房間 賓客入住后對房間如果不滿意操作員可以為其調(diào)整新的房間和修改新房間的房價更換房間界面如圖 46 所示 圖 46 更換房間 下圖是更換房間的主要的代碼 public class Change extends JDialog implements ActionListener private JLabel lbA private JTextField tf1tf2 private JCheckBox chk private JButton bt1bt2 private JPanel panelMain public Change JFrame frame super frame更換房間 true buildPanel addListener thissetContentPane panelMain thissetPreferredSize new Dimension 270200 thissetMinimumSize new Dimension 270200 thissetResizable false 不允許改變窗口大小 pack sunswingsetWindowCenter this 窗口屏幕居中 private void saveCKO long ckPK sunsqlgetPrimaryKey 獲得結算記錄首 PK String chNO suntoolsgetNumber suntoolsNumber_JS 獲得結算單號 String chkTime JournalgetNowDTime 結算時間 String reMark tf3getText 備注 int count tbgetRowCount 得到有幾點結算記錄 String sqlCode[] new String[count 3] 創(chuàng)建 SQL 語句數(shù)組 String riState 可供 房間狀態(tài) int flag IntegerparseInt suninigetIniKey Ck_Habitus 結算后的房間狀態(tài) 0 可供 1 清理 if flag 1 riState 臟房 Endif int sc 0 for int i 0 i count 3 i 向結算表加數(shù)據(jù) sqlCode[i] insert into checkout pkchk_noin_nodaysmoneychk_timeremark values ckPK sc chNO inNo dtmgetValueAt sc 6 dtmgetValueAt sc 7 chkTime reMark i 更改入住信息表里的記錄狀態(tài)為已結算 sqlCode[i] update livein set statemark 已結算 where pk dtmgetValueAt sc 0 i 更改房間狀態(tài) sqlCode[i] update roominfo set state riState where delmark 0 and id dtmgetValueAt sc 2 sc DTM 指針 1 Endfor public void actionPerformed ActionEvent ae Object o aegetSource if o bt1 增加預定信息 sunsqlexecuteUpdate delete from engage1 String sqlCode select ar_type 預定規(guī)格 br_no 房間 from roomtype as aengage1 as b where aid br_type_id sunsqlinitDTM eidtm1sqlCode elected false eishow true initDTM suns