酒店管理系统雏形

@[------------------本次实训中老师要求用swt做一个项目,但时间很紧,仅有一天半的时间,因此虽然我及时的完成了任务,但这个项目自己不是很满意,还有许多缺陷,至此自己加以补充,完成了一个酒店管理系统的雏形!]

(一)制作登录程序

1.设计登录界面

根据账号与密码
在这里插入图片描述

package Test1;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Window;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;



import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.wb.swt.SWTResourceManager;

public class Login {

	protected Shell shell;
	private Text text;
	private Text text_1;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Login window = new Login();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\4DA1A3AB085D07B842F233AC8E7F523C.jpg"));
		shell.setSize(544, 371);
		shell.setText("大寒客栈");
		
		Label lblNewLabel = new Label(shell, SWT.NONE);
		lblNewLabel.setBounds(148, 79, 67, 17);
		lblNewLabel.setText("\u8D26\u53F7\uFF1A");
		
		text = new Text(shell, SWT.BORDER);
		text.setBackgroundImage(null);
		text.setBounds(221, 79, 157, 23);
		
		Label lblNewLabel_1 = new Label(shell, SWT.NONE);
		lblNewLabel_1.setBounds(148, 131, 61, 17);
		lblNewLabel_1.setText("\u5BC6\u7801\uFF1A");
		
		text_1 = new Text(shell, SWT.BORDER | SWT.PASSWORD);
		text_1.setText("");
		text_1.setBounds(221, 128, 157, 23);
		
		Button btnNewButton = new Button(shell, SWT.NONE);
		btnNewButton.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\4BA259E5CDAD782FAFF5D86EB7210E2E.jpg"));
		btnNewButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				Register  register=new  Register();
			}
		});
		btnNewButton.setBounds(187, 223, 80, 27);
		btnNewButton.setText("\u6CE8\u518C\u8D26\u6237");
		
		Button button = new Button(shell, SWT.NONE);
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			      String  uid=text.getText();
		          String  upwd=text_1.getText();
		          Loginmodel    loginmodel=new Loginmodel();
				  int  flag=loginmodel.checkUser(uid,upwd);
				  if(flag==0){
					  shell.dispose();
					  System.out.println("登录用户界面");
					  Userview  userview=new Userview(uid);
					 
				  }
				  if(flag==1){
					  shell.dispose();
					  System.out.println("登录管理界面");
					  Manageview  manageview=new Manageview(uid);
					  
				  }
				  if(flag==2){
					  MessageBox  box=new  MessageBox(shell);
					  box.setText("登录失败");
					  box.setMessage("账号或密码错误");
					  box.open();
				  }
				
				
			}
		});
		button.setText("\u767B\u5F55");
		button.setBounds(318, 223, 80, 27);
		
		         //获取屏幕高度和宽度
		        int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
		        int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
		        //获取对象窗口高度和宽度
		        int shellH = shell.getBounds().height;
		        int shellW = shell.getBounds().width;
		        shell.setLocation(((screenW - shellW) / 2), ((screenH - shellH) / 2));
		
	}
	
}

登录验证

package Test1;
import java.sql.ResultSet;
public class Loginmodel {
	
	//定义连接数据库需要的组
	    Sqlconnection sqlconn;
		ResultSet rs;
		String sql,pwd,usf;
		int flag;
		public int checkUser(String uid,String upwd)
		{
			 flag=0;
			 sql="select * from user where uid='"+uid+"'";
			 sqlconn=new Sqlconnection();
			 rs=sqlconn.sqlQuery(sql);//返回一个记录集
			try {
				while(rs.next())  
				{
					pwd=rs.getString(3).trim();
					usf=rs.getString(5).trim();
					System.out.println("test1="+usf);
					
				}
				if(upwd.equals(pwd))
				{
					if(usf.equals("普通用户")||usf.equals("VIP"))
					{
						flag=0;
					}
					else if(usf.equals("管理员"))
					{
						flag=1;
					}
				}
				else 
				{
					flag=2;
				}
				
				
			} catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}
			finally
			{
				sqlconn.closeSqlConn();
				
			}
			return flag;
		}
	
}

2.完成注册设计

在这里插入图片描述

(二)

1.连接数据库

package Test1;

import java.sql.*;


public class Sqlconnection {
	  Connection ct=null;
	  PreparedStatement ps=null;
	  ResultSet rs=null;
	  String driverName="com.mysql.jdbc.Driver";
	  String dbURL="jdbc:mysql://localhost:3306/Test";
	  String userName="root";
	  String userPwd="3";
	 
	//实现查询功能的方法
		
		public ResultSet sqlQuery(String sql)
		{
			
			try {
				//加载驱动
				Class.forName(driverName);
				ct=DriverManager.getConnection(dbURL,userName,userPwd);
				ps=ct.prepareStatement(sql);
				rs=ps.executeQuery();
				
			} catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}
			return rs;
		}
		//实现添加,修改功能 的方法
		public void sqlUpdate(String sql)
		{
			try {
				//加载驱动
				Class.forName(driverName);
				ct=DriverManager.getConnection(dbURL,userName,userPwd);
				ps=ct.prepareStatement(sql);
				//执行添加,更新操作
				int i=ps.executeUpdate();//返回一个值,如果为1则表示添加成功。
				if(i==1)
				{
					System.out.println("数据添加/修改成功!");
				}
				else
				{
					System.out.println("数据添加/修改失败!");
				}
			} catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}
		}
		//实现删除学生记录的方法
		public void sqlDelete(String sql)
		{
			try {
				//加载驱动
				System.out.println("ok");
				Class.forName(driverName);
				ct=DriverManager.getConnection(dbURL,userName,userPwd);
				ps=ct.prepareStatement(sql);
				System.out.println("ok1");
				//执行添加,更新操作
				int i=ps.executeUpdate();//返回一个值,如果为1则表示删除成功。
				if(i==1)
				{
					System.out.println("数据删除成功!");
				}
				else
				{
					System.out.println("数据删除失败!");
				}
			} catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}
		}
		//实现关闭数据库连接的功能
		public void closeSqlConn()
		{
			try {
				if(rs!=null)rs.close();
				if(ps!=null)ps.close();
				if(ct!=null)ct.close();
			} catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}
		}
	  
	  
	  
}



2.在数据库建立房间表格与用户表格

在这里插入图片描述
在这里插入图片描述

3.增加,删除,修改,查询

(三)制作管理员界面

1.实现用户信息,管理员信息,房间信息的任意切换

在这里插入图片描述

package Test1;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.FillLayout;

import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.wb.swt.SWTResourceManager;

public class Manageview {

	protected Shell shell;
	private Table table;
	private Table table_1;
	private Table table_2;
	private Text text;
	private Text text_1;
	private Text text_2;
	private Text text_5;
	private Text text_4;
	String  uid;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Manageview window = new Manageview("1");
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public Manageview(String  uid) {
		this.uid=uid;
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setBackgroundImage(null);
		shell.setSize(659, 511);
		shell.setText("大寒客栈");
		shell.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		SashForm sashForm = new SashForm(shell, SWT.NONE);
		
		Group group = new Group(sashForm, SWT.NONE);
		group.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\[I0H5D@BQINA95@3R)KL]%H.jpg"));
		
		Button button_3 = new Button(group, SWT.NONE);
		
		button_3.setBounds(21, 10, 84, 35);
		button_3.setText("\u7528\u6237\u4FE1\u606F");
		
		
		
		Button button_4 = new Button(group, SWT.NONE);
		
		button_4.setText("\u7BA1\u7406\u5458\u4FE1\u606F");
		button_4.setBounds(21, 72, 84, 35);
		
		Button button_5 = new Button(group, SWT.NONE);
		button_5.setText("\u623F\u95F4\u4FE1\u606F");
		button_5.setBounds(21, 137, 84, 35);
		
		Button button_6 = new Button(group, SWT.NONE);
		button_6.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				Cheakmessage  cheakmessage=new  Cheakmessage();
			
			}
		});
		button_6.setText("\u67E5\u770B\u7559\u8A00\u677F");
		button_6.setBounds(21, 212, 84, 35);
		
		Button button_1 = new Button(group, SWT.NONE);
		button_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				shell.dispose();
			}
		});
		button_1.setText("\u9000\u51FA\u7CFB\u7EDF");
		button_1.setBounds(21, 287, 84, 35);
		
		Group group_1 = new Group(sashForm, SWT.NONE);
		group_1.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\[I0H5D@BQINA95@3R)KL]%H.jpg"));
		group_1.setLayout(new FormLayout());
		
		Composite composite = new Composite(group_1, SWT.NONE);
		composite.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\[I0H5D@BQINA95@3R)KL]%H.jpg"));
		final StackLayout layout = new StackLayout();
		composite.setLayout(layout);
		
		FormData fd_composite = new FormData();
		fd_composite.bottom = new FormAttachment(0, 254);
		fd_composite.right = new FormAttachment(0, 515);
		fd_composite.top = new FormAttachment(0, -7);
		fd_composite.left = new FormAttachment(0, -3);
		composite.setLayoutData(fd_composite);
		
		
		ScrolledComposite scrolledComposite = new ScrolledComposite(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
		scrolledComposite.setExpandHorizontal(true);
		scrolledComposite.setExpandVertical(true);
		
		
		table = new Table(scrolledComposite, SWT.BORDER | SWT.FULL_SELECTION);
		
		table.setHeaderVisible(true);
		table.setLinesVisible(true);
		
		TableColumn tblclmnUid = new TableColumn(table, SWT.NONE);
		tblclmnUid.setWidth(85);
		tblclmnUid.setText(" \u8D26\u53F7");
		
		TableColumn tableColumn = new TableColumn(table, SWT.NONE);
		tableColumn.setWidth(77);
		tableColumn.setText("\u59D3\u540D");
		
		TableColumn tableColumn_1 = new TableColumn(table, SWT.NONE);
		tableColumn_1.setWidth(77);
		tableColumn_1.setText("\u9884\u8BA2\u623F\u95F4");
		
		TableColumn tableColumn_2 = new TableColumn(table, SWT.NONE);
		tableColumn_2.setWidth(77);
		tableColumn_2.setText("\u7528\u6237\u6743\u9650");
		
		TableColumn tableColumn_3 = new TableColumn(table, SWT.NONE);
		tableColumn_3.setText("\u4F59\u989D");
		tableColumn_3.setWidth(77);
		
		TableColumn tblclmnTel = new TableColumn(table, SWT.NONE);
		tblclmnTel.setWidth(99);
		tblclmnTel.setText("\u7535\u8BDD\u53F7\u7801");
		scrolledComposite.setContent(table);
		scrolledComposite.setMinSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		ScrolledComposite scrolledComposite_1 = new ScrolledComposite(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
		scrolledComposite_1.setExpandHorizontal(true);
		scrolledComposite_1.setExpandVertical(true);
		
		table_1 = new Table(scrolledComposite_1, SWT.BORDER | SWT.FULL_SELECTION);
		table_1.setHeaderVisible(true);
		table_1.setLinesVisible(true);
		
		TableColumn tableColumn_8 = new TableColumn(table_1, SWT.NONE);
		tableColumn_8.setWidth(95);
		tableColumn_8.setText("\u8D26\u53F7");
		
		TableColumn tableColumn_9 = new TableColumn(table_1, SWT.NONE);
		tableColumn_9.setWidth(95);
		tableColumn_9.setText("\u59D3\u540D");
		
		TableColumn tableColumn_10 = new TableColumn(table_1, SWT.NONE);
		tableColumn_10.setWidth(95);
		tableColumn_10.setText("\u5DE5\u4F5C\u65F6\u95F4");
		
		TableColumn tableColumn_11 = new TableColumn(table_1, SWT.NONE);
		tableColumn_11.setWidth(95);
		tableColumn_11.setText("\u6743\u9650");
		
		TableColumn tableColumn_13 = new TableColumn(table_1, SWT.NONE);
		tableColumn_13.setWidth(111);
		tableColumn_13.setText("\u7535\u8BDD\u53F7\u7801");
		scrolledComposite_1.setContent(table_1);
		scrolledComposite_1.setMinSize(table_1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		
		ScrolledComposite scrolledComposite_2 = new ScrolledComposite(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
		scrolledComposite_2.setExpandHorizontal(true);
		scrolledComposite_2.setExpandVertical(true);
		
		table_2 = new Table(scrolledComposite_2, SWT.BORDER | SWT.FULL_SELECTION);
		table_2.setHeaderVisible(true);
		table_2.setLinesVisible(true);
		
		TableColumn tableColumn_4 = new TableColumn(table_2, SWT.NONE);
		tableColumn_4.setWidth(120);
		tableColumn_4.setText("\u623F\u95F4\u53F7");
		
		TableColumn tableColumn_5 = new TableColumn(table_2, SWT.NONE);
		tableColumn_5.setWidth(120);
		tableColumn_5.setText("\u623F\u95F4\u540D");
		
		TableColumn tableColumn_6 = new TableColumn(table_2, SWT.NONE);
		tableColumn_6.setWidth(120);
		tableColumn_6.setText("\u4EF7\u683C");
		
		TableColumn tableColumn_7 = new TableColumn(table_2, SWT.NONE);
		tableColumn_7.setWidth(120);
		tableColumn_7.setText("\u5907\u6CE8");
		scrolledComposite_2.setContent(table_2);
		scrolledComposite_2.setMinSize(table_2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		Composite composite_1 = new Composite(group_1, SWT.NONE);
		composite_1.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\[I0H5D@BQINA95@3R)KL]%H.jpg"));
		
		
		FormData fd_composite_1 = new FormData();
		fd_composite_1.top = new FormAttachment(composite, 6);
		fd_composite_1.right = new FormAttachment(composite, -10, SWT.RIGHT);
		fd_composite_1.bottom = new FormAttachment(100, -4);
		fd_composite_1.left = new FormAttachment(0, 7);
		composite_1.setLayoutData(fd_composite_1);
		
		Label label = new Label(composite_1, SWT.NONE);
		label.setBounds(33, 21, 36, 17);
		label.setText(" \u8D26\u53F7\uFF1A");
		
		text = new Text(composite_1, SWT.BORDER);
		text.setEditable(false);
		text.setBounds(100, 18, 87, 23);
		
		Label label_1 = new Label(composite_1, SWT.NONE);
		label_1.setBounds(33, 59, 36, 17);
		label_1.setText(" \u59D3\u540D\uFF1A");
		
		text_1 = new Text(composite_1, SWT.BORDER);
		text_1.setBounds(100, 56, 61, 23);
		
		Label label_2 = new Label(composite_1, SWT.NONE);
		label_2.setBounds(33, 96, 61, 17);
		label_2.setText(" \u9884\u8BA2\u623F\u95F4\uFF1A");
		
		text_2 = new Text(composite_1, SWT.BORDER);
		text_2.setBounds(100, 90, 87, 23);
		
		Label label_3 = new Label(composite_1, SWT.NONE);
		label_3.setBounds(250, 21, 61, 17);
		label_3.setText(" \u7528\u6237\u6743\u9650\uFF1A");
		
		Label label_4 = new Label(composite_1, SWT.NONE);
		label_4.setBounds(272, 59, 36, 17);
		label_4.setText(" \u4F59\u989D\uFF1A");
		
		Label label_5 = new Label(composite_1, SWT.NONE);
		label_5.setBounds(250, 96, 61, 17);
		label_5.setText(" \u7535\u8BDD\u53F7\u7801\uFF1A");
		
		text_5 = new Text(composite_1, SWT.BORDER);
		text_5.setBounds(317, 96, 99, 23);
		
		Button button = new Button(composite_1, SWT.NONE);
		
		button.setBounds(32, 132, 80, 27);
		button.setText("\u4FEE\u6539\u7528\u6237\u4FE1\u606F");
		
		Button btnNewButton = new Button(composite_1, SWT.NONE);
		
		btnNewButton.setBounds(197, 132, 80, 27);
		btnNewButton.setText("\u5220\u9664\u7528\u6237\u4FE1\u606F");
		
		Button btnNewButton_1 = new Button(composite_1, SWT.NONE);
	
		btnNewButton_1.setBounds(351, 132, 80, 27);
		btnNewButton_1.setText("\u589E\u52A0\u7528\u6237\u4FE1\u606F");
		
		Combo combo = new Combo(composite_1, SWT.NONE);
		combo.add("普通用户");
		combo.add("VIP");
		combo.setBounds(317, 13, 88, 25);
		
		text_4 = new Text(composite_1, SWT.BORDER);
		text_4.setBounds(317, 53, 73, 23);
		sashForm.setWeights(new int[] {122, 518});
		
		composite_1.setVisible(true);
		usertable();
		layout.topControl =scrolledComposite;
		 composite.layout();
		
		button_3.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				composite_1.setVisible(true);
				usertable();
				layout.topControl =scrolledComposite;
				composite.layout();
			}
		});
		button_4.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				composite_1.setVisible(false);
				managetable();
				layout.topControl =scrolledComposite_1;
				 composite.layout();
			}
		});
		button_5.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				composite_1.setVisible(false);
				roomtable();
				layout.topControl =scrolledComposite_2;
				composite.layout();
			}
		});
		table.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				TableItem  ti=(TableItem)e.item;
				text.setText(ti.getText(0));
				text_1.setText(ti.getText(1));
				text_2.setText(ti.getText(2));
				combo.setText(ti.getText(3));
				text_4.setText(ti.getText(4));
				text_5.setText(ti.getText(5));
				
			}
		});
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MessageBox  box=new  MessageBox(shell);
			 int  row=table.getSelectionIndex();
			 System.out.println(row);
				
				if(row==-1){
					box.setText("错误提醒");
					box.setMessage("未选中任意一行");
					box.open();
					
				}
				else{
					String  uid=text.getText();
					String  uname=text_1.getText();
					String  proom=text_2.getText();
					String  psf=combo.getText();
					String  balance=text_4.getText();
					String  tel=text_5.getText();
					Sqlconnection  con=new  Sqlconnection();
					String  sql="Update  user  set  uname='"+uname+"',proom='"+proom+"',psf='"+psf+"',balance='"+balance+"',tel='"+tel+"'  where  uid='"+uid+"'";
					con.sqlUpdate(sql);
					usertable();
					text.setText("");
					text_1.setText("");
					text_2.setText("");
					combo.setText("");
					text_4.setText("");
					text_5.setText("");
					}
				
			}
			
		});
		btnNewButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MessageBox  box=new  MessageBox(shell);
				 int  row=table.getSelectionIndex();
				 System.out.println(row);
					
					if(row==-1){
						box.setText("错误提醒");
						box.setMessage("未选中任意一行");
						box.open();
						
					}
					else{
						String  uid=text.getText();
						Sqlconnection  con=new  Sqlconnection();
						String sql="delete   from  user where uid='"+uid+"'";
						con.sqlDelete(sql);
						usertable();
						text.setText("");
						text_1.setText("");
						text_2.setText("");
						combo.setText("");
						text_4.setText("");
						text_5.setText("");
						
					}
				
				
			}
		});
		btnNewButton_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			Addlogin  addlogin=new  Addlogin();
			addlogin.open();
			usertable();
			
			}
		});
		  //获取屏幕高度和宽度
        int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
        int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
        //获取对象窗口高度和宽度
        int shellH = shell.getBounds().height;
        int shellW = shell.getBounds().width;
        shell.setLocation(((screenW - shellW) / 2), ((screenH - shellH) / 2));
	}
	public  void  usertable(){
		table.removeAll();
		try{
			Sqlconnection  con=new  Sqlconnection();
			String  sql="select  uid,uname,proom,psf,balance,tel  from  user  where psf='普通用户'or psf='VIP'";
			ResultSet  rs=con.sqlQuery(sql);
			while(rs.next()){
				TableItem  ti=new  TableItem(table,SWT.NONE);
				ti.setText(new  String[]{rs.getString("uid")+"",rs.getString("uname")+"",rs.getString("proom")+"",rs.getString("psf")+"",rs.getString("balance")+"",rs.getString("tel")});	
			}
		}catch(SQLException  e){
			e.printStackTrace();
		}
	}
	public  void   managetable(){
		table_1.removeAll();
		try{
			Sqlconnection  con=new  Sqlconnection();
			String  sql="select  uid,uname,worktime,psf,tel  from  user where  psf='管理员'";
			ResultSet  rs=con.sqlQuery(sql);
			while(rs.next()){
				TableItem  ti=new  TableItem(table_1,SWT.NONE);
				ti.setText(new  String[]{rs.getString("uid")+"",rs.getString("uname")+"",rs.getString("worktime")+"",rs.getString("psf")+"",rs.getString("tel")});	
			}
		}catch(SQLException  e){
			e.printStackTrace();
		}
	}
	public  void    roomtable(){
		table_2.removeAll();
		try{
			Sqlconnection  con=new  Sqlconnection();
			String  sql="select  rid,rname,price,occupy  from  room";
			ResultSet  rs=con.sqlQuery(sql);
			while(rs.next()){
				TableItem  ti=new  TableItem(table_2,SWT.NONE);
				ti.setText(new  String[]{rs.getString("rid")+"",rs.getString("rname")+"",rs.getString("price")+"",rs.getString("occupy")});	
			}
		}catch(SQLException  e){
			e.printStackTrace();
		}
	}
}

2.修改,增加,删除用户信息

在这里插入图片描述

package Test1;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;

import java.awt.Toolkit;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.wb.swt.SWTResourceManager;

public class Addlogin {

   protected Shell shell;
   private Text text;
   private Text text_1;
   private Text text_2;
   private Text text_3;
   private Text text_4;
   private Text text_5;

   /**
    * Launch the application.
    * @param args
    */
   public static void main(String[] args) {
   	try {
   		Addlogin window = new Addlogin();
   		window.open();
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }

   /**
    * Open the window.
    */
   public void open() {
   	Display display = Display.getDefault();
   	createContents();
   	shell.open();
   	shell.layout();
   	while (!shell.isDisposed()) {
   		if (!display.readAndDispatch()) {
   			display.sleep();
   		}
   	}
   }

   /**
    * Create contents of the window.
    */
   protected void createContents() {
   	shell = new Shell();
   	shell.setImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\41EEF30A30BDC9EF6BD96157BBFB4AB6.jpg"));
   	shell.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\[I0H5D@BQINA95@3R)KL]%H.jpg"));
   	shell.setSize(450, 300);
   	shell.setText("大寒客栈");
   	
   	Label label = new Label(shell, SWT.NONE);
   	label.setBounds(57, 22, 36, 17);
   	label.setText(" \u8D26\u53F7\uFF1A");
   	
   	text = new Text(shell, SWT.BORDER);
   	text.setBounds(99, 16, 97, 23);
   	
   	Label label_1 = new Label(shell, SWT.NONE);
   	label_1.setBounds(57, 62, 36, 17);
   	label_1.setText(" \u5BC6\u7801\uFF1A");
   	
   	text_1 = new Text(shell, SWT.BORDER);
   	text_1.setBounds(99, 62, 97, 23);
   	
   	Label label_2 = new Label(shell, SWT.NONE);
   	label_2.setText(" \u59D3\u540D\uFF1A");
   	label_2.setBounds(57, 106, 36, 17);
   	
   	text_2 = new Text(shell, SWT.BORDER);
   	text_2.setBounds(99, 106, 50, 23);
   	
   	Label label_3 = new Label(shell, SWT.NONE);
   	label_3.setText(" \u623F\u95F4\uFF1A");
   	label_3.setBounds(57, 157, 36, 17);
   	
   	text_3 = new Text(shell, SWT.BORDER);
   	text_3.setBounds(99, 151, 79, 23);
   	
   	Label label_4 = new Label(shell, SWT.NONE);
   	label_4.setText(" \u6743\u9650\uFF1A");
   	label_4.setBounds(233, 22, 43, 17);
   	
   	Combo combo = new Combo(shell, SWT.NONE);
   	combo.setBounds(286, 14, 88, 25);
   	combo.add("普通用户");
   	combo.add("VIP");
   	
   	Label label_5 = new Label(shell, SWT.NONE);
   	label_5.setBounds(233, 68, 43, 17);
   	label_5.setText(" \u5145\u503C:");
   	
   	text_4 = new Text(shell, SWT.BORDER);
   	text_4.setBounds(292, 62, 79, 23);
   	
   	Label label_6 = new Label(shell, SWT.NONE);
   	label_6.setText(" \u8054\u7CFB\u7535\u8BDD\uFF1A");
   	label_6.setBounds(233, 112, 63, 17);
   	
   	text_5 = new Text(shell, SWT.BORDER);
   	text_5.setBounds(319, 110, 97, 23);
   	
   	Button button = new Button(shell, SWT.NONE);
   	button.addSelectionListener(new SelectionAdapter() {
   		@Override
   		public void widgetSelected(SelectionEvent e) {
   			String  uid=text.getText();
   			String  upwd=text_1.getText();
   			String  uname=text_2.getText();
   			String  proom=text_3.getText();
   			String  psf=combo.getText();
   			String  balance=text_4.getText();
   			String  tel=text_5.getText();
   			Sqlconnection con=new  Sqlconnection();
   			String  sql="insert  into  user  values('"+uid+"','"+uname+"','"+upwd+"','"+proom+"','"+psf+"','"+tel+"','"+balance+"',null)";
   			con.sqlUpdate(sql);
   			shell.dispose();
   		
   		}
   	});
   	button.setBounds(69, 209, 80, 27);
   	button.setText("\u786E\u5B9A");
   	
   	Button button_1 = new Button(shell, SWT.NONE);
   	button_1.setBounds(265, 209, 80, 27);
   	button_1.setText("\u8FD4\u56DE");
   	  //获取屏幕高度和宽度
       int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
       int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
       //获取对象窗口高度和宽度
       int shellH = shell.getBounds().height;
       int shellW = shell.getBounds().width;
       shell.setLocation(((screenW - shellW) / 2), ((screenH - shellH) / 2));

   }

}

3.查看留言板

在这里插入图片描述

package Test1;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;

import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class Cheakmessage{

  protected Shell shell;
  private Table table;
  private TableColumn tableColumn;
  private TableColumn tblclmnNewColumn;
  private Button btnNewButton;

  /**
   * Launch the application.
   * @param args
   */
  public static void main(String[] args) {
  	try {
  		Cheakmessage window = new Cheakmessage();
  	
  	} catch (Exception e) {
  		e.printStackTrace();
  	}
  }

  /**
   * Open the window.
   */
  public Cheakmessage() {
  	Display display = Display.getDefault();
  	createContents();
  	mestable();
  	shell.open();
  	shell.layout();
  	while (!shell.isDisposed()) {
  		if (!display.readAndDispatch()) {
  			display.sleep();
  		}
  	}
  }

  /**
   * Create contents of the window.
   */
  protected void createContents() {
  	shell = new Shell();
  	shell.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\[I0H5D@BQINA95@3R)KL]%H.jpg"));
  	shell.setSize(450, 300);
  	shell.setText("\u5BA2\u6237\u7559\u8A00");
  	
  	table = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
  	table.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
  	table.setBounds(0, 0, 434, 204);
  	table.setHeaderVisible(true);
  	table.setLinesVisible(true);
  	
  	tableColumn = new TableColumn(table, SWT.NONE);
  	tableColumn.setWidth(100);
  	tableColumn.setText("     \u8D26\u53F7\u4E0E\u59D3\u540D");
  	
  	tblclmnNewColumn = new TableColumn(table, SWT.NONE);
  	tblclmnNewColumn.setWidth(330);
  	tblclmnNewColumn.setText("                                \u7559\u8A00");
  	
  	btnNewButton = new Button(shell, SWT.NONE);
  	btnNewButton.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			shell.dispose();
  		}
  	});
  	btnNewButton.setBounds(331, 224, 80, 27);
  	btnNewButton.setText("\u8FD4\u56DE");
  	  //获取屏幕高度和宽度
      int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
      int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
      //获取对象窗口高度和宽度
      int shellH = shell.getBounds().height;
      int shellW = shell.getBounds().width;
      shell.setLocation(((screenW - shellW) / 2), ((screenH - shellH) / 2));
  }
     public  void  mestable(){
  	   table.removeAll();
     
  	   try{
  			Sqlconnection  con=new  Sqlconnection();
  			String  sql="select idname,mes  from  message";
  			ResultSet  rs=con.sqlQuery(sql);
  			while(rs.next()){
  				TableItem  ti=new  TableItem(table,SWT.NONE);
  				ti.setText(new  String[]{rs.getString("idname")+"",rs.getString("mes")});	
  			}
  		}catch(SQLException  e){
  			e.printStackTrace();
  		}
  	   
  	   
     }
  
}

4.退出系统

(三)制作用户使用界面

登录成功后,上方会根据不同的账后,得到不同的名字,从而表示欢迎在这里插入图片描述

package Test1;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;

import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableCursor;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.ExpandBar;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

public class Userview {

  protected Shell shell;
  private Table table;
  String  uid;
  String  uname;
  String  balance;
  int  balan;
  private Text text;

  /**
   * Launch the application.
   * @param args
   */
//	public static void main(String[] args) {
//		try {
//			Userview window = new Userview("201703");
//			
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}

  /**
   * Open the window.
   */
  public Userview(String  uid) {
  	this.uid=uid;
  	Display display = Display.getDefault();
  	
  	createContents();
  	usertable();
  	shell.setText("账户 "+uid+"  "+uname+"   欢迎您");
  	shell.open();
  	shell.layout();
  	while (!shell.isDisposed()) {
  		if (!display.readAndDispatch()) {
  			display.sleep();
  		}
  	}
  }

  /**
   * Create contents of the window.
   */
  protected void createContents() {
  	shell = new Shell();
  	shell.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\[I0H5D@BQINA95@3R)KL]%H.jpg"));
  	shell.setSize(492, 377);
  
  	
  	SashForm sashForm = new SashForm(shell, SWT.NONE);
  	sashForm.setLocation(0, 0);
  	
  	Label label = new Label(shell, SWT.NONE);
  	label.setBounds(0, 0, 90, 17);
  	label.setText("\u5927\u5BD2\u516C\u5BD3\u6B22\u8FCE\u60A8");
  	
  	Link link = new Link(shell, SWT.NONE);
  	link.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			shell.dispose();
  			Message  message=new  Message(uid);
  		}
  	});
  	link.setBounds(423, 321, 53, 17);
  	link.setText("<a>\u8054\u7CFB\u5BA2\u670D</a>");
  	
  	Button button = new Button(shell, SWT.NONE);
  	
  	button.setBounds(60, 144, 80, 27);
  	button.setText("\u9884\u5B9A\u623F\u95F4");
  	
  	Button btnvip = new Button(shell, SWT.NONE);
  
  	btnvip.setBounds(60, 209, 80, 27);
  	btnvip.setText("\u5347\u7EA7VIP");
  	
  	Button button_1 = new Button(shell, SWT.NONE);
  	button_1.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			shell.dispose();
  		}
  	});
  	button_1.setBounds(312, 209, 80, 27);
  	button_1.setText("\u9000\u51FA");
  	
  	Button button_2 = new Button(shell, SWT.NONE);
  	
  	    
  	button_2.setBounds(60, 282, 80, 27);
  	button_2.setText("\u5145\u503C");
  	button_2.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			int  money=Integer.parseInt(text.getText());
  			balan=balan+money;
  			balance=String.valueOf(balan);
  			MessageBox box = new MessageBox(shell,SWT.ICON_QUESTION | SWT.OK| SWT.CANCEL);
  			box.setText("充值提醒");
  			box.setMessage("确定充值"+money+"元么");	 
  			 int  rc=box.open();
  			 if (e.doit == (rc == SWT.OK)){
  				Sqlconnection  con=new  Sqlconnection();
  				String  sql="Update  user  set  balance='"+balance+"' where  uid='"+uid+"'";
  				con.sqlUpdate(sql);
  				usertable(); 
  				text.setText("");
  				 }	 
  			 else{
  				 
  			 }
  	}
  		
  	});
  			
  	
  	
  	Button button_3 = new Button(shell, SWT.NONE);
  	button_3.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			
  			Changepwd  changepwd=new  Changepwd(uid);
  			
  		}
  	});
  	button_3.setBounds(312, 144, 80, 27);
  	button_3.setText("\u4FEE\u6539\u4FE1\u606F");
  	
  	table = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION);
  	table.setLinesVisible(true);
  	table.setHeaderVisible(true);
  	table.setBounds(1, 41, 475, 51);
  	
  	
  	TableColumn tableColumn = new TableColumn(table, SWT.NONE);
  	tableColumn.setWidth(63);
  	tableColumn.setText("\u8D26\u53F7");
  	
  	TableColumn tableColumn_1 = new TableColumn(table, SWT.NONE);
  	tableColumn_1.setWidth(69);
  	tableColumn_1.setText("\u59D3\u540D");
  	
  	TableColumn tableColumn_2 = new TableColumn(table, SWT.NONE);
  	tableColumn_2.setWidth(95);
  	tableColumn_2.setText("\u9884\u8BA2\u623F\u95F4");
  	
  	TableColumn tableColumn_3 = new TableColumn(table, SWT.NONE);
  	tableColumn_3.setWidth(70);
  	tableColumn_3.setText("\u6743\u9650");
  	
  	TableColumn tableColumn_4 = new TableColumn(table, SWT.NONE);
  	tableColumn_4.setWidth(65);
  	tableColumn_4.setText("\u8D26\u6237\u4F59\u989D");
  	
  	TableColumn tableColumn_5 = new TableColumn(table, SWT.NONE);
  	tableColumn_5.setWidth(101);
  	tableColumn_5.setText("\u8054\u7CFB\u7535\u8BDD");
  	
  	text = new Text(shell, SWT.BORDER);
  	text.setBounds(152, 284, 112, 23);
  	button.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			shell.dispose();
  			Reserve  reserve=new  Reserve(uid);
  			
  			
  		}
  	});
  	btnvip.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			MessageBox box = new MessageBox(shell,SWT.ICON_QUESTION | SWT.OK| SWT.CANCEL);
  			 box.setText("充值提醒");
  			 box.setMessage("确定花费105元升级为VIP么");
  			 
  			 int  rc=box.open();
  			 if (e.doit == (rc == SWT.OK)){
  				 if(balan>=105){
  				    balan=balan-105;
  					balance=String.valueOf(balan);
  					
  					Sqlconnection  con=new  Sqlconnection();
  					String  sql="Update  user  set  balance='"+balance+"',psf='VIP'  where  uid='"+uid+"'";
  					con.sqlUpdate(sql);
  					usertable();
  				 }
  				 else{
  					 MessageBox  mb=new  MessageBox(shell);
  					 mb.setText("充值提醒");
  					 mb.setMessage("余额不足");
  					 mb.open();
  				 }
  			 }
  			 else{
  				 
  			 }
  
  		}
  	});
  	  //获取屏幕高度和宽度
      int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
      int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
      //获取对象窗口高度和宽度
      int shellH = shell.getBounds().height;
      int shellW = shell.getBounds().width;
      shell.setLocation(((screenW - shellW) / 2), ((screenH - shellH) / 2));

  }
  public  void  usertable(){
  	table.removeAll();
  	try{
  		Sqlconnection  con=new  Sqlconnection();
  		String  sql="select  uid,uname,proom,psf,balance,tel  from  user where  uid='"+uid+"'";
  		ResultSet  rs=con.sqlQuery(sql);
  		while(rs.next()){
  			TableItem  ti=new  TableItem(table,SWT.NONE);
  			ti.setText(new  String[]{rs.getString("uid")+"",rs.getString("uname")+"",rs.getString("proom")+"",rs.getString("psf")+"",rs.getString("balance")+"",rs.getString("tel")});
  			balance=rs.getString("balance");
  			uname=rs.getString("uname");
  		}
  		
  		balan=Integer.parseInt(balance);
  		
  		con.closeSqlConn();
  	}catch(SQLException  e){
  		e.printStackTrace();
  	}
  }
  
  
  
}

1.预订房间

在这里插入图片描述

package Test1;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.custom.ScrolledComposite;

import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.DateTime;

public class Reserve {

  protected Shell shell;
  private Text text;
  String  uid;
  
  String  balance;
  int  balan;

  /**
   * Launch the application.
   * @param args
   */
//	public static void main(String[] args) {
//		try {
//			Reserve window = new Reserve("201703");
//			
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}

  /**
   * Open the window.
   */
  public Reserve(String  uid) {
  	this.uid=uid;
  	Display display = Display.getDefault();
  	
  	Sqlconnection  con=new  Sqlconnection();
  	String  sql="select  *  from  user  where  uid='"+uid+"'";
  	ResultSet  rs=con.sqlQuery(sql);
  	try {
  		while(rs.next()){
  			balance=rs.getString("balance");
  		}
  	} catch (SQLException e) {
  		// TODO Auto-generated catch block
  		e.printStackTrace();
  	}
  	balan=Integer.parseInt(balance);
  	createContents();
  	shell.open();
  	shell.layout();
  	while (!shell.isDisposed()) {
  		if (!display.readAndDispatch()) {
  			display.sleep();
  		}
  	}
  }

  /**
   * Create contents of the window.
   */
  protected void createContents() {
  	shell = new Shell();
  	shell.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\[I0H5D@BQINA95@3R)KL]%H.jpg"));
  	shell.setForeground(SWTResourceManager.getColor(SWT.COLOR_TITLE_FOREGROUND));
  	shell.setSize(652, 490);
  	shell.setText("SWT Application");
  	
  	Label label = new Label(shell, SWT.NONE);
  	label.setBounds(0, 0, 90, 17);
  	label.setText("\u5927\u5BD2\u9152\u5E97\u6B22\u8FCE\u60A8");
  	
  	Link link = new Link(shell, SWT.NONE);
  	link.setBounds(583, 434, 53, 17);
  	link.setText("<a>\u8054\u7CFB\u5BA2\u670D</a>");
  	
  	Group group_1 = new Group(shell, SWT.NONE);
  	group_1.setText("\u6807\u51C6\u5355\u4EBA\u95F4");
  	group_1.setBounds(0, 21, 626, 51);
  	
  	Label label_1 = new Label(group_1, SWT.NONE);
  	label_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
  	label_1.setBounds(23, 24, 61, 17);
  	label_1.setText("\uFFE5100");
  	
  	Button button = new Button(group_1, SWT.NONE);
  	button.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			MessageBox  box=new  MessageBox(shell);
  			if(balan<100){
  				box.setText("充值提醒");
  				box.setMessage("余额不足,请充值");
  				box.open();
  			}
  			else{
  				shell.dispose();
  				Room  r=new  Room("select rid,rname,price,occupy from  room  where  rname='标准单人间'",uid,100);
  			}
  		}
  	});
  	button.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
  	button.setBounds(536, 24, 80, 27);
  	button.setText("\u9884\u5B9A");
  	
  	DateTime dateTime = new DateTime(group_1, SWT.BORDER);
  	dateTime.setBounds(270, 24, 88, 24);
  	
  	DateTime dateTime_1 = new DateTime(group_1, SWT.BORDER);
  	dateTime_1.setBounds(395, 24, 88, 24);
  	
  	Label lblNewLabel = new Label(group_1, SWT.NONE);
  	lblNewLabel.setBounds(370, 29, 19, 17);
  	lblNewLabel.setText("\u5230");
  	
  	Label label_10 = new Label(group_1, SWT.NONE);
  	label_10.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 7, SWT.NORMAL));
  	label_10.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
  	label_10.setBounds(90, 29, 80, 17);
  	label_10.setText("\u4F1A\u5458\u53EF\u4EAB\u516B\u6298\u4F18\u60E0");
  	
  	Group group_2 = new Group(shell, SWT.NONE);
  	group_2.setText("\u6807\u51C6\u53CC\u4EBA\u95F4");
  	group_2.setBounds(0, 78, 626, 51);
  	
  	Button button_1 = new Button(group_2, SWT.NONE);
  	button_1.setForeground(SWTResourceManager.getColor(255, 0, 0));
  	button_1.setText("\u9884\u5B9A");
  	button_1.setBounds(536, 24, 80, 27);
  	button_1.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			MessageBox  box=new  MessageBox(shell);
  			if(balan<150){
  				box.setText("充值提醒");
  				box.setMessage("余额不足,请充值");
  				box.open();
  			}
  			else{
  				shell.dispose();
  				Room  r=new  Room("select rid,rname,price,occupy from  room  where  rname='标准双人间'",uid,150);
  			}
  						
  		}
  	});
  	
  	Label label_2 = new Label(group_2, SWT.NONE);
  	label_2.setText("\uFFE5150");
  	label_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
  	label_2.setBounds(24, 29, 61, 17);
  	
  	DateTime dateTime_2 = new DateTime(group_2, SWT.BORDER);
  	dateTime_2.setBounds(271, 24, 88, 24);
  	
  	Label label_6 = new Label(group_2, SWT.NONE);
  	label_6.setText("\u5230");
  	label_6.setBounds(371, 29, 19, 17);
  	
  	DateTime dateTime_3 = new DateTime(group_2, SWT.BORDER);
  	dateTime_3.setBounds(396, 24, 88, 24);
  	
  	Label label_11 = new Label(group_2, SWT.NONE);
  	label_11.setText("\u4F1A\u5458\u53EF\u4EAB\u516B\u6298\u4F18\u60E0");
  	label_11.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
  	label_11.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 7, SWT.NORMAL));
  	label_11.setBounds(91, 31, 80, 17);
  	
  	Group group_3 = new Group(shell, SWT.NONE);
  	group_3.setText("\u8C6A\u534E\u5355\u4EBA\u95F4");
  	group_3.setBounds(0, 135, 626, 51);
  	
  	Button button_2 = new Button(group_3, SWT.NONE);
  	
  	button_2.setText("\u9884\u5B9A");
  	button_2.setBounds(536, 24, 80, 27);
  	button_2.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			MessageBox  box=new  MessageBox(shell);
  			
  			if(balan<200){
  				box.setText("充值提醒");
  				box.setMessage("余额不足,请充值");
  				box.open();
  			}
  			else{
  				shell.dispose();
  				Room  r=new  Room("select rid,rname,price,occupy from  room  where  rname='豪华单人间'",uid,200);
  			}
  		
  		}
  	});
  	
  	Label label_3 = new Label(group_3, SWT.NONE);
  	label_3.setText("\uFFE5200");
  	label_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
  	label_3.setBounds(25, 29, 61, 17);
  	
  	DateTime dateTime_4 = new DateTime(group_3, SWT.BORDER);
  	dateTime_4.setBounds(270, 24, 88, 24);
  	
  	Label label_7 = new Label(group_3, SWT.NONE);
  	label_7.setText("\u5230");
  	label_7.setBounds(370, 29, 19, 17);
  	
  	DateTime dateTime_5 = new DateTime(group_3, SWT.BORDER);
  	dateTime_5.setBounds(395, 24, 88, 24);
  	
  	Label label_12 = new Label(group_3, SWT.NONE);
  	label_12.setText("\u4F1A\u5458\u53EF\u4EAB\u516B\u6298\u4F18\u60E0");
  	label_12.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
  	label_12.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 7, SWT.NORMAL));
  	label_12.setBounds(92, 31, 80, 17);
  	
  	Group group_4 = new Group(shell, SWT.NONE);
  	group_4.setText("\u8C6A\u534E\u53CC\u4EBA\u95F4");
  	group_4.setBounds(0, 192, 626, 51);
  	
  	Button button_3 = new Button(group_4, SWT.NONE);
  	
  	button_3.setText("\u9884\u5B9A");
  	button_3.setBounds(536, 24, 80, 27);
  	button_3.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			MessageBox  box=new  MessageBox(shell);
  			if(balan<250){
  				box.setText("充值提醒");
  				box.setMessage("余额不足,请充值");
  				box.open();
  			}
  			else{
  				shell.dispose();
  				Room  r=new  Room("select rid,rname,price,occupy from  room  where  rname='豪华双人间'",uid,250);
  			}
  		
  		}
  	});
  	
  	Label label_4 = new Label(group_4, SWT.NONE);
  	label_4.setText("\uFFE5250");
  	label_4.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
  	label_4.setBounds(23, 29, 61, 17);
  	
  	DateTime dateTime_6 = new DateTime(group_4, SWT.BORDER);
  	dateTime_6.setBounds(269, 24, 88, 24);
  	
  	Label label_8 = new Label(group_4, SWT.NONE);
  	label_8.setText("\u5230");
  	label_8.setBounds(369, 29, 19, 17);
  	
  	DateTime dateTime_7 = new DateTime(group_4, SWT.BORDER);
  	dateTime_7.setBounds(394, 24, 88, 24);
  	
  	Label label_13 = new Label(group_4, SWT.NONE);
  	label_13.setText("\u4F1A\u5458\u53EF\u4EAB\u516B\u6298\u4F18\u60E0");
  	label_13.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
  	label_13.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 7, SWT.NORMAL));
  	label_13.setBounds(93, 29, 80, 17);
  	
  	Group group_5 = new Group(shell, SWT.NONE);
  	group_5.setText("\u603B\u7EDF\u5957\u623F");
  	group_5.setBounds(0, 251, 626, 51);
  	
  	Button button_4 = new Button(group_5, SWT.NONE);
  	
  	button_4.setText("\u9884\u5B9A");
  	button_4.setBounds(536, 24, 80, 27);
  	button_4.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			MessageBox  box=new  MessageBox(shell);
  			if(balan<400){
  				box.setText("充值提醒");
  				box.setMessage("余额不足,请充值");
  				box.open();
  			}
  			else{
  				shell.dispose();
  				Room  r=new  Room("select rid,rname,price,occupy from  room  where  rname='总统套房'",uid,400);
  			}
  		}
  	});
  	
  	Label label_5 = new Label(group_5, SWT.NONE);
  	label_5.setText("\uFFE5400");
  	label_5.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
  	label_5.setBounds(21, 29, 61, 17);
  	
  	DateTime dateTime_8 = new DateTime(group_5, SWT.BORDER);
  	dateTime_8.setBounds(271, 24, 88, 24);
  	
  	Label label_9 = new Label(group_5, SWT.NONE);
  	label_9.setText("\u5230");
  	label_9.setBounds(371, 29, 19, 17);
  	
  	DateTime dateTime_9 = new DateTime(group_5, SWT.BORDER);
  	dateTime_9.setBounds(396, 24, 88, 24);
  	
  	Label label_14 = new Label(group_5, SWT.NONE);
  	label_14.setText("\u4F1A\u5458\u53EF\u4EAB\u516B\u6298\u4F18\u60E0");
  	label_14.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
  	label_14.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 7, SWT.NORMAL));
  	label_14.setBounds(94, 31, 80, 17);
  	
  	Button btnNewButton_1 = new Button(shell, SWT.NONE);
  	btnNewButton_1.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			shell.dispose();
  		}
  	});
  	btnNewButton_1.setBounds(27, 414, 80, 27);
  	btnNewButton_1.setText("\u53D6\u6D88\u9884\u5B9A");
  	
  	Button button_5 = new Button(shell, SWT.NONE);
  	button_5.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			shell.dispose();
  			Userview  userview=new  Userview(uid);
  			
  		}
  	});
  	button_5.setBounds(426, 414, 80, 27);
  	button_5.setText("\u8FD4\u56DE");
  	
  	Button btnNewButton = new Button(shell, SWT.NONE);
  	btnNewButton.setBounds(231, 414, 80, 27);
  	btnNewButton.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			MessageBox box = new MessageBox(shell,SWT.ICON_QUESTION | SWT.OK| SWT.CANCEL);
  			 box.setText("充值提醒");
  			 box.setMessage("确定花费105元升级为VIP么");
  			 
  			 int  rc=box.open();
  			 if (e.doit == (rc == SWT.OK)){
  				 if(balan>=105){
  				    balan=balan-105;
  					balance=String.valueOf(balan);
  					text.setText(balance);
  					Sqlconnection  con=new  Sqlconnection();
  					String  sql="Update  user  set  balance='"+balance+"',psf='VIP'  where  uid='"+uid+"'";
  					con.sqlUpdate(sql);
  				 }
  				 else{
  					 MessageBox  mb=new  MessageBox(shell);
  					 mb.setText("充值提醒");
  					 mb.setMessage("余额不足");
  					 mb.open();
  				 }
  			 }
  			 else{
  				 
  			 }
  		
  			
  		}
  	});
  	btnNewButton.setText("\u5347\u7EA7VIP");
  	
  	Label label_15 = new Label(shell, SWT.NONE);
  	label_15.setBounds(27, 339, 36, 17);
  	label_15.setText("\u4F59\u989D\uFF1A");
  	
  	text = new Text(shell, SWT.BORDER);
  	text.setBounds(72, 339, 73, 23);
  	text.setText(balance);
  	  //获取屏幕高度和宽度
      int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
      int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
      //获取对象窗口高度和宽度
      int shellH = shell.getBounds().height;
      int shellW = shell.getBounds().width;
      shell.setLocation(((screenW - shellW) / 2), ((screenH - shellH) / 2));
  }
}

1.1选择各种房间

在这里插入图片描述

package Test1;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Button;
import org.eclipse.wb.swt.SWTResourceManager;

public class Room {

	protected Shell shell;
	private Table table;
	String  sql;
	String  uid;
	String  rid;
	String  rname;
	String  balance;
	int  balan;
	int  price;
	

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Room window = new Room("select rid,rname,price,occupy  from  room  where  rname='总统套房' ","201703",100);
		
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public   Room(String  sql,String  uid,int  price) {
		this.sql=sql;
		this.uid=uid;
		this.price=price;
		Display display = Display.getDefault();
		Sqlconnection  con=new  Sqlconnection();
		String  sql3="select  *  from  user  where  uid='"+uid+"'";
		ResultSet  rs=con.sqlQuery(sql3);
		try {
			while(rs.next()){
				balance=rs.getString("balance");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		balan=Integer.parseInt(balance);
		createContents();
		shell.open();
		shell.layout();
		roomtable();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\[I0H5D@BQINA95@3R)KL]%H.jpg"));
		shell.setSize(573, 414);
		shell.setText("SWT Application");
		
		ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
		scrolledComposite.setBounds(10, 0, 537, 266);
		scrolledComposite.setExpandHorizontal(true);
		scrolledComposite.setExpandVertical(true);
		
		table = new Table(scrolledComposite, SWT.BORDER | SWT.FULL_SELECTION);
		table.setHeaderVisible(true);
		table.setLinesVisible(true);
		
		TableColumn tblclmnNewColumn = new TableColumn(table, SWT.NONE);
		tblclmnNewColumn.setWidth(120);
		tblclmnNewColumn.setText("\u623F\u53F7");
		
		TableColumn tblclmnNewColumn_1 = new TableColumn(table, SWT.NONE);
		tblclmnNewColumn_1.setWidth(120);
		tblclmnNewColumn_1.setText(" \u623F\u95F4\u540D");
		
		TableColumn tblclmnNewColumn_2 = new TableColumn(table, SWT.NONE);
		tblclmnNewColumn_2.setWidth(120);
		tblclmnNewColumn_2.setText("\u4EF7\u683C");
		
		TableColumn tblclmnNewColumn_3 = new TableColumn(table, SWT.NONE);
		tblclmnNewColumn_3.setWidth(120);
		tblclmnNewColumn_3.setText(" \u5907\u6CE8");
		scrolledComposite.setContent(table);
		scrolledComposite.setMinSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		Button btnNewButton = new Button(shell, SWT.NONE);
	
		btnNewButton.setBounds(117, 314, 80, 27);
		btnNewButton.setText("\u786E\u5B9A\u9884\u8BA2");
		
		Button btnNewButton_1 = new Button(shell, SWT.NONE);
		
		btnNewButton_1.setBounds(329, 314, 80, 27);
		btnNewButton_1.setText("\u8FD4\u56DE");
		
		//获取屏幕高度和宽度
        int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
        int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
        //获取对象窗口高度和宽度
        int shellH = shell.getBounds().height;
        int shellW = shell.getBounds().width;
        shell.setLocation(((screenW - shellW) / 2), ((screenH - shellH) / 2));
		
		table.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				TableItem  ti=(TableItem)e.item;
				rid=ti.getText(0);
				rname=ti.getText(1)+rid+"号";
				
			}
		});
		
		btnNewButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				 MessageBox  box=new  MessageBox(shell);
				 int  row=table.getSelectionIndex();
				 System.out.println(row);
					
					if(row==-1){
						box.setText("错误提醒");
						box.setMessage("未选中任意一行");
						box.open();
						
					}
					else{
						box.setText("成功提醒");
						box.setMessage("预订成功");
						box.open();
						System.out.println(rid);
						Sqlconnection  con=new  Sqlconnection();
						String  sql1="update  room  set  occupy='已预订' where  rid='"+rid+"' ";
						String  sql2="update  user  set  proom='"+rname+"'  where  uid='"+uid+"'";
						con.sqlUpdate(sql1);
						con.sqlUpdate(sql2);
						balan=balan-price;
						balance=String.valueOf(balan);
						String  sql4="Update  user  set  balance='"+balance+"'  where  uid='"+uid+"'";
						con.sqlUpdate(sql4);
						roomtable();
					}
							
			}
		});	
		
		btnNewButton_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				shell.dispose();
				Reserve  reserve=new  Reserve(uid);
				
			
			}
		});
	}
	 public  void  roomtable(){
		 table.removeAll();
		 Sqlconnection  con=new  Sqlconnection();
			ResultSet  rs=con.sqlQuery(sql);
			try{
			while(rs.next()){
				TableItem  ti=new  TableItem(table,SWT.NONE);
				ti.setText(new  String[]{rs.getString("rid")+"",rs.getString("rname")+"",rs.getString("price")+"",rs.getString("occupy")});	
			}
		}catch(SQLException  e){
			e.printStackTrace();
		}
	 }
}

2.修改信息

3.升级为VIP

4.充值

5.留言

在这里插入图片描述

package Test1;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;

import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class   Message {

  protected Shell shell;
  private Text text;
  String  uid;
  String  uname;

  /**
   * Launch the application.
   * @param args
   */
  public static void main(String[] args) {
  	try {
  		Message window = new Message("201703");
  	
  	} catch (Exception e) {
  		e.printStackTrace();
  	}
  }

  /**
   * Open the window.
   */
  public Message(String  uid) {
  	this.uid=uid;
  	Sqlconnection  con=new  Sqlconnection();
  	String  sql="select *  from  user  where  uid='"+uid+"'";
  	ResultSet  rs=con.sqlQuery(sql);
  	try {
  		while(rs.next()){
  			uname=rs.getString("uname");
  		}
  	} catch (SQLException e) {
  		// TODO Auto-generated catch block
  		e.printStackTrace();
  	}
  	Display display = Display.getDefault();
  	createContents();
  	shell.open();
  	shell.layout();
  	while (!shell.isDisposed()) {
  		if (!display.readAndDispatch()) {
  			display.sleep();
  		}
  	}
  }

  /**
   * Create contents of the window.
   */
  protected void createContents() {
  	shell = new Shell();
  	shell.setForeground(SWTResourceManager.getColor(0, 0, 0));
  	shell.setBackgroundImage(SWTResourceManager.getImage("C:\\Users\\Administrator\\Desktop\\[I0H5D@BQINA95@3R)KL]%H.jpg"));
  	shell.setSize(450, 288);
  	shell.setText("大寒客栈");
  	
  	Label label = new Label(shell, SWT.NONE);
  	label.setBounds(0, 0, 36, 17);
  	label.setText("\u7559\u8A00\u677F");
  	
  	text = new Text(shell, SWT.BORDER | SWT.MULTI);
  	text.setBounds(0, 20, 434, 120);
  	
  	Label label_1 = new Label(shell, SWT.NONE);
  	label_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_CYAN));
  	label_1.setBounds(0, 140, 176, 17);
  	label_1.setText("\u60A8\u53EF\u4EE5\u5728\u8FD9\u91CC\u7559\u4E0B\u60A8\u5B9D\u8D35\u7684\u610F\u89C1");
  	
  	Button button = new Button(shell, SWT.NONE);
  	button.addSelectionListener(new SelectionAdapter() {
  		@Override
  		
  		public void widgetSelected(SelectionEvent e) {
  			String  mes=text.getText();
  			String  idname=uid+" "+uname;
  			Sqlconnection con=new  Sqlconnection();
  			String  sql="insert  into message  values('"+idname+"','"+mes+"')";
  			    con.sqlUpdate(sql);   
  				MessageBox  box=new  MessageBox(shell);
  				box.setText("恭喜");
  				box.setMessage("提交成功");
  				box.open();
  			}
  		
  	});
  	button.setBounds(354, 146, 80, 27);
  	button.setText("\u63D0\u4EA4");
  	
  	Button button_1 = new Button(shell, SWT.NONE);
  	button_1.addSelectionListener(new SelectionAdapter() {
  		@Override
  		public void widgetSelected(SelectionEvent e) {
  			shell.dispose();
  			Userview  userview=new  Userview(uid);
  		}
  	});
  	
  	button_1.setBounds(171, 212, 80, 27);
  	button_1.setText("\u8FD4\u56DE\u9996\u9875");
  	  //获取屏幕高度和宽度
      int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
      int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
      //获取对象窗口高度和宽度
      int shellH = shell.getBounds().height;
      int shellW = shell.getBounds().width;
      shell.setLocation(((screenW - shellW) / 2), ((screenH - shellH) / 2));
  }
}

本次项目中,已基本实现各种功能,关于注册时,邮箱验证码也已实现,因为需要不同的网易账户,自己不方便,没放进去,亮点是预订房间那一块,花了很长时间去调整,不同的房间型号,有着不同的价格,客户预定后会修改用户预订信息

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值