首页>代码>基于C/S的java swing游泳管理系统>/数据库/系统/swim/src/system/Control.java
package system;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JOptionPane;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

public class Control {

	protected Shell shell;
	private Table table;
	private Text text_1;
	private Text text;
	ResultSet resultSet = null;
	ResultSet rs = null;
	PreparedStatement pstm = null;
	Connection conn = null;
	Manage mm2 = new Manage();

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

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.setLocation(Display.getCurrent().getClientArea().width / 2 - shell.getShell().getSize().x / 2,
				Display.getCurrent().getClientArea().height / 2 - shell.getSize().y / 2);
		
		Label label = new Label(shell, SWT.NONE);
		label.setImage(SWTResourceManager.getImage("./pictures/0151a1576bb4ab0000018c1bdcb70e.png"));
		label.setBounds(0, 0, 683, 244);
		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("./pictures/imagestore20150824d2d9e96c-85be-4d8e-8a96-57c3ca60d350.jpg"));
		shell.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		shell.setSize(705, 578);
		shell.setText("\u5361\u7247\u67E5\u8BE2");
		shell.setLayout(null);

		Composite composite = new Composite(shell, SWT.NONE);
		composite.setBounds(0, 231, 683, 291);

		table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);

		table.setBounds(0, 0, 683, 291);
		table.setHeaderVisible(true);
		table.setLinesVisible(true);

		TableColumn tableColumn = new TableColumn(table, SWT.NONE);
		tableColumn.setWidth(100);

		TableColumn tableColumn_1 = new TableColumn(table, SWT.NONE);
		tableColumn_1.setWidth(148);

		TableColumn tableColumn_2 = new TableColumn(table, SWT.NONE);
		tableColumn_2.setWidth(75);

		TableColumn tableColumn_3 = new TableColumn(table, SWT.NONE);
		tableColumn_3.setWidth(140);

		TableColumn tableColumn_4 = new TableColumn(table, SWT.NONE);
		tableColumn_4.setWidth(123);

		TableColumn tableColumn_5 = new TableColumn(table, SWT.NONE);
		tableColumn_5.setWidth(100);

		Menu menu = new Menu(table);
		table.setMenu(menu);

		MenuItem menuItem = new MenuItem(menu, SWT.NONE);
		menuItem.setText("\u4FEE\u6539");

		menuItem.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {

				int n = table.getSelectionIndex();// n为选中那一列的坐标
				TableItem b = table.getItem(n);
				String a = b.getText(0);
				String a1 = b.getText(1);
				String a2 = b.getText(2);
				String a3 = b.getText(3);
				String a4 = b.getText(4);
				String a5 = b.getText(5);
				XiugaiMem Xiu = new XiugaiMem();
				Xiu.open(a, a1,a2,a3,a4,a5);
			}
		});

		Label label = new Label(shell, SWT.NONE);
		label.setBackground(SWTResourceManager.getColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
		label.setBounds(10, 24, 144, 24);
		label.setText("\u8EAB\u4EFD\u8BC1\u53F7\u7801");

		text_1 = new Text(shell, SWT.BORDER);
		text_1.setBounds(198, 21, 227, 30);

		Label label_2 = new Label(shell, SWT.NONE);
		label_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
		label_2.setBounds(10, 96, 144, 24);
		label_2.setText("\u5361\u53F7");

		text = new Text(shell, SWT.BORDER);
		text.setBounds(198, 90, 227, 30);

		Button button = new Button(shell, SWT.NONE);
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				table.removeAll();
				String g = text_1.getText();
				if (g == "") {
					JOptionPane.showMessageDialog(null, "请输入身份证号码!");
				} else if (!mm2.CheckSFZ(g)) {
					JOptionPane.showMessageDialog(null, "没有此身份证号或者身份证号输入错误!");
					text_1.setText("");
				} else {
					try {
						String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
						String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=YYG";
						String userName = "sa";
						String pwd = "sa2008";
						Class.forName(driver);
						conn = DriverManager.getConnection(url, userName, pwd);
					} catch (Exception e1) {
						e1.printStackTrace();
					}
					try {
						tableColumn.setText("姓名");
						tableColumn_1.setText("身份证号");
						tableColumn_2.setText("性别");
						tableColumn_3.setText("联系电话");
						tableColumn_4.setText("所在省市");
						tableColumn_5.setText("备注");
						String sql = "select * from Member Where 身份证号=?";
						pstm = conn.prepareStatement(sql);
						pstm.setString(1, g);
						resultSet = pstm.executeQuery();

						while (resultSet.next()) {
							TableItem item = new TableItem(table, SWT.LEFT);
							String a = resultSet.getString("姓名");
							String b = resultSet.getString("身份证号");
							String c = resultSet.getString("性别");
							String d = resultSet.getString("联系电话");
							String e1 = resultSet.getString("所在省市");
							String f = resultSet.getString("备注");
							item.setText(new String[] { a, b, c, d, e1, f });
							text_1.setText("");
						}
					} catch (SQLException e1) {

						e1.printStackTrace();

					}

				}
			}
		});
		button.setForeground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_FOREGROUND));
		button.setBounds(493, 19, 132, 34);
		button.setText("\u6309\u8EAB\u4EFD\u8BC1\u53F7\u67E5\u8BE2");

		Button button_1 = new Button(shell, SWT.NONE);
		button_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				table.removeAll();
				String g1 = text.getText();
				if (g1 == "") {
					JOptionPane.showMessageDialog(null, "请输入卡号!");
					text.setText("");
				} else if (!mm2.CheckKH(g1)) {
					JOptionPane.showMessageDialog(null, "没有此卡号或者卡号输入错误!");
					text.setText("");
				}

				else {
					try {
						String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
						String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=YYG";
						String userName = "sa";
						String pwd = "sa2008";
						Class.forName(driver);
						conn = DriverManager.getConnection(url, userName, pwd);
					} catch (Exception e1) {
						e1.printStackTrace();
					}
					try {
						tableColumn.setText("姓名");
						tableColumn_1.setText("身份证号");
						tableColumn_2.setText("性别");
						tableColumn_3.setText("联系电话");
						tableColumn_4.setText("所在省市");
						tableColumn_5.setText("备注");
						
						String m=null;
						String m1=null;

						String sql = "select * from Member where 身份证号=?";
						String sql2 = "select distinct 身份证号 from Spend  Where 卡号=?";
						pstm = conn.prepareStatement(sql2);
						pstm.setString(1, g1);
						rs = pstm.executeQuery();
						while(rs.next()) {
							m=rs.getString("身份证号");
						}
						m1=m.toString();
						pstm = conn.prepareStatement(sql);
						pstm.setString(1, m1);
						resultSet = pstm.executeQuery();
						while (resultSet.next()) {

							TableItem item = new TableItem(table, SWT.LEFT);
							String a = resultSet.getString("姓名");
							String b = resultSet.getString("身份证号");
							String c = resultSet.getString("性别");
							String d = resultSet.getString("联系电话");
							String e1 = resultSet.getString("所在省市");
							String f = resultSet.getString("备注");
							item.setText(new String[] { a, b, c, d, e1, f });
						}
					} catch (Exception e1) {
						e1.printStackTrace();
					}
				}

			}
		});
		button_1.setBounds(493, 91, 132, 34);
		button_1.setText("\u6309\u5361\u53F7\u67E5\u8BE2");

		Button button_2 = new Button(shell, SWT.NONE);
		button_2.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				shell.dispose();
				new Tools().main(null);
			}
		});
		button_2.setBounds(481, 169, 139, 34);
		button_2.setText("\u8FD4\u56DE");

		Button button_3 = new Button(shell, SWT.NONE);
		button_3.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {

				table.removeAll();

				try {
					String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
					String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=YYG";
					String userName = "sa";
					String pwd = "sa2008";
					Class.forName(driver);
					conn = DriverManager.getConnection(url, userName, pwd);
				} catch (Exception e1) {
					e1.printStackTrace();
				}
				try {
					tableColumn.setText("姓名");
					tableColumn_1.setText("身份证号");
					tableColumn_2.setText("性别");
					tableColumn_3.setText("联系电话");
					tableColumn_4.setText("所在省市");
					tableColumn_5.setText("备注");

					String sql = "select * from Member ";
					pstm = conn.prepareStatement(sql);
					resultSet = pstm.executeQuery();
					while (resultSet.next()) {

						TableItem item = new TableItem(table, SWT.LEFT);
						String a = resultSet.getString("姓名");
						String b = resultSet.getString("身份证号");
						String c = resultSet.getString("性别");
						String d = resultSet.getString("联系电话");
						String e1 = resultSet.getString("所在省市");
						String f = resultSet.getString("备注");
						item.setText(new String[] { a, b, c, d, e1, f });
					}
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
		});
		button_3.setBounds(67, 169, 132, 34);
		button_3.setText("\u663E\u793A\u6240\u6709\u8BB0\u5F55");

	}
}
最近下载更多
泰州市斑驳时光  LV4 2023年9月15日
queueandstack  LV3 2022年12月2日
计算机暴龙战士  LV19 2022年11月19日
testuser1234567  LV24 2022年5月31日
微信网友_5872158626074624  LV3 2022年3月17日
lmj0911  LV3 2021年9月6日
ericxu1116  LV24 2021年6月23日
zktotti 2021年6月23日
暂无贡献等级
wanglinddad  LV54 2021年6月11日
纯纯粹粹112332  LV6 2021年6月8日
最近浏览更多
lshlsh 2023年12月25日
暂无贡献等级
李朝磊  LV18 2023年12月3日
夜猫子111  LV2 2023年11月6日
jkjfdgbkl  LV2 2023年11月2日
dsadasdwf  LV12 2023年10月23日
sunshine9920  LV12 2023年10月19日
泰州市斑驳时光  LV4 2023年9月15日
阳光男孩阿葵 2023年7月14日
暂无贡献等级
KAIzx11  LV7 2023年6月25日
LongTory  LV2 2023年6月6日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友