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

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.SWTResourceManager;

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

import javax.swing.JOptionPane;

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

public class CardCon {

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

	/**
	 * Launch the application.
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			CardCon window = new CardCon();
			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, -9, 755, 237);
		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/timg.jpg"));
		shell.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		shell.setSize(777, 523);
		shell.setText("\u5361\u7247\u4FE1\u606F\u67E5\u8BE2");

		Label label = new Label(shell, SWT.NONE);
		label.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		label.setBounds(20, 30, 90, 24);
		label.setText("\u8EAB\u4EFD\u8BC1\u53F7");

		text = new Text(shell, SWT.BORDER);
		text.setBounds(183, 30, 224, 30);

		Label label_1 = new Label(shell, SWT.NONE);
		label_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		label_1.setBounds(20, 107, 90, 24);
		label_1.setText("\u5361\u53F7");

		text_1 = new Text(shell, SWT.BORDER);
		text_1.setBounds(183, 107, 224, 30);

		Composite composite = new Composite(shell, SWT.NONE);
		composite.setBounds(0, 230, 755, 237);

		table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
		table.setBounds(0, 0, 755, 237);
		table.setHeaderVisible(true);
		table.setLinesVisible(true);

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

		TableColumn tblclmnNewColumn = new TableColumn(table, SWT.NONE);
		tblclmnNewColumn.setWidth(110);

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

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

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

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

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

		MenuItem menuItem = new MenuItem(menu, SWT.NONE);
		menuItem.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {

				int n = table.getSelectionIndex();// n为选中那一列的坐标
				TableItem a = table.getItem(n);
				String a1 = a.getText(0);
				String a2 = a.getText(1);
				String a3 = a.getText(2);
				String a4 = a.getText(3);
				System.out.println(a1 + a2 + a3 + a4);
				XiugaiCar xiuc = new XiugaiCar();
				xiuc.open(a1, a2, a3, a4);
			}
		});
		menuItem.setText("\u4FEE\u6539\u6570\u636E");

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

				table.removeAll();
				String g = text.getText();
				if (g == "") {
					JOptionPane.showMessageDialog(null, "请输入身份证号!");
					text.setText("");
				} else if (!m.CheckSFZ(g)) {
					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("卡号");
						tblclmnNewColumn.setText("金额");
						tableColumn_3.setText("折扣");
						tableColumn_4.setText("类型");
						tableColumn_5.setText("日期");
						tableColumn_6.setText("挂失");

						String sql = "select a.* from Card a ,Spend b Where a.卡号=b.卡号 AND b.身份证号=?";
						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 c = resultSet.getString("金额");
							String d = resultSet.getString("折扣");
							String e1 = resultSet.getString("类型");
							String f = resultSet.getString("日期");
							String h = resultSet.getString("挂失");
							item.setText(new String[] { a, c, d, e1, f, h });
						}
					} catch (Exception e1) {
						e1.printStackTrace();
					}
				}
			}
		});
		button.setBounds(539, 30, 145, 34);
		button.setText("\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_1.getText();
				if (g1 == "") {
					JOptionPane.showMessageDialog(null, "请输入卡号!");
					text.setText("");
				} else if (!m.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("卡号");
						tblclmnNewColumn.setText("金额");
						tableColumn_3.setText("折扣");
						tableColumn_4.setText("类型");
						tableColumn_5.setText("日期");
						tableColumn_6.setText("挂失");

						String sql = "select * from Card  Where 卡号=?";
						pstm = conn.prepareStatement(sql);
						pstm.setString(1, g1);
						resultSet = pstm.executeQuery();

						while (resultSet.next()) {
							TableItem item = new TableItem(table, SWT.LEFT);
							String a = resultSet.getString("卡号");
							String c = resultSet.getString("金额");
							String d = resultSet.getString("折扣");
							String e1 = resultSet.getString("类型");
							String f = resultSet.getString("日期");
							String h = resultSet.getString("挂失");
							item.setText(new String[] { a, c, d, e1, f, h });
						}
					} catch (Exception e1) {
						e1.printStackTrace();
					}
				}
			}

		});
		button_1.setBounds(539, 95, 145, 34);
		button_1.setText("\u5361\u53F7\u67E5\u8BE2");

		Button button_2 = new Button(shell, SWT.NONE);
		button_2.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("卡号");
					tblclmnNewColumn.setText("金额");
					tableColumn_3.setText("折扣");
					tableColumn_4.setText("类型");
					tableColumn_5.setText("日期");
					tableColumn_6.setText("挂失");

					String sql = "select * from Card ";
					pstm = conn.prepareStatement(sql);
					resultSet = pstm.executeQuery();
					while (resultSet.next()) {
						TableItem item = new TableItem(table, SWT.LEFT);
						String a = resultSet.getString("卡号");
						String c = resultSet.getString("金额");
						String d = resultSet.getString("折扣");
						String e1 = resultSet.getString("类型");
						String f = resultSet.getString("日期");
						String h = resultSet.getString("挂失");
						item.setText(new String[] { a, c, d, e1, f, h });
					}
				} catch (Exception e1) {
					e1.printStackTrace();
				}

			}
		});
		button_2.setBounds(31, 180, 114, 34);
		button_2.setText("\u663E\u793A\u6240\u6709\u4FE1\u606F");

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

	}
}
最近下载更多
泰州市斑驳时光  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日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友