Package com. Databasejdbc;
Import the Java. The awt. *;
The import com. HotelGui. *;
Import the Java. The awt. Event. An ActionEvent;
Import the Java. The awt. Event. ActionListener;
Import the Java. Util. Vector;
The import javax.mail. Swing. *;
The import javax.mail. Swing. Event. AncestorListener;
import javax.xml.crypto.Data;
The import com. HotelGui. MyHotelMainGui;
The import com.com mon. *;
Public class CheckOut extends the CheckIn implements ActionListener {
JLabel jl.
Public final JTextField JTF;
Public JButton check_bt checkout_bt;
Public CheckOut (String str1, String path) {
Super (str1, path);
Jl=new JLabel (" check out room number ");
Jl. SetBounds (250120, 80, 28).
Jl. SetFont (new Font (" tahoma ", the Font HANGING_BASELINE, 14));
Jl. SetForeground (Color. RED);
JTF=new JTextField (10);
JTF. SetBounds (330, 120, 60, 28).
Cancel_bt. SetVisible (false);
Checkout_bt=new JButton (new ImageIcon (path));
Checkout_bt. SetBounds (160, 500, 85, 30);
Checkout_bt. SetOpaque (false);
Checkout_bt. SetActionCommand (" 1 ");
Checkin_bt. SetVisible (false);
Check_bt=new JButton (" look for ");
Check_bt. SetBounds (410, 120, 70, 28).
Check_bt. SetOpaque (false);
Checkin_bt. SetActionCommand (" 2 ");
This. The add (jl);
This. The add (JTF);
This. The add (checkout_bt);
This. The add (check_bt);
}
Public static void main (String [] args) {
//TODO Auto - generated method stub
CheckOut co=new CheckOut (" guests check out ", "images \ \ checkout_bt JPG");
}
/*===========================JOptionPane. YES_OPTION========================* *
* [# # public void checkout_Bt () {}] check-out button action
No
* and number:* the return value: no
* modifier: public
* function: point to repel room, update the database in the state of the room from 2 to 0
*===================================================*/
Public void checkout_Bt ()
{
DataBaseConnect dc new DataBaseConnect ();
Try {
Dc. The updateData (" update room_table set roomatate=0 where roomnum="+ Integer. The valueOf (JTF. The getText ()));
Dc. The updateData (" update costomer_table set isliving=0 where roomnum="+ Integer. The valueOf (JTF. The getText ()));
{} the catch (Exception e1)
e1.printStackTrace();
}
MyHotelMainGui hm=new MyHotelMainGui (1);
Hm. UpdateRoomState ();
}
/*===================================================* *
* [# # public void check_BT () {}] check-out button action
No
* and number:* the return value: no
* modifier: public
* function: click on the query, return the data from the database to the elder sister interface
*===================================================*/
Public void check_Bt (String STR) throws the Exception
{
DataBaseConnect dc new DataBaseConnect ();
Vector data=https://bbs.csdn.net/topics/dc.getDataFromCostomer (Integer. The valueOf (JTF getText (). The trim ()));
The Vector data1=dc. RoomOperation (Integer. The valueOf (JTF. The getText (). The trim ()));
if(! Data1. Get (2) equals (2))
{
JOptionPane. ShowMessageDialog (this, STR);
}
The else
{
Room_num_jf. SetText (data. The get (0). The toString ());
Name_jf. SetText (data. The get (1). The toString ());
Gender_jb. SetSelectedItem (data. The get (2));
Id_jf. SetText (data. The get (3). The toString ());
Checkin_jf. SetText (data. The get (4). The toString ());
Checkout_jf. SetText (data. The get (5). The toString ());
Charge_jf. SetText (data. The get (6). The toString ());
Despoit_jf. SetText (data. The get (7). The toString ());
Price_jf. SetText (data1. Get (3). The toString ());
Room_type_jb. SetSelectedItem (data. The get (1));
}
}
@ Override
Public void actionPerformed (an ActionEvent e) {
//TODO Auto - generated method stub
If (um participant etActionCommand (.) the equals (" 1 "))
{
Int flag=JOptionPane. ShowConfirmDialog (null, "has been check out!" , "tip", JOptionPane. PLAIN_MESSAGE);
If (flag==JOptionPane. YES_OPTION)
{
Checkout_Bt ();
}
return;
}
If (um participant etActionCommand (.) the equals (" 2 "))
{
Try {
Check_Bt (room did not stay! "" );
{} the catch (Exception e1)
//TODO Auto - generated the catch block,
e1.printStackTrace();
}
}
}
}