【数据库实验】,java 语言零基础自学
-- Table structure for flight
DROP TABLE IF EXISTS flight
;
CREATE TABLE flight
(
f_id
char(8) NOT NULL,
f_src
varchar(15) DEFAULT NULL,
f_des
varchar(15) DEFAULT NULL,
f_date
date NOT NULL,
f_start_time
char(6) DEFAULT NULL,
f_end_time
char(6) DEFAULT NULL,
f_remain_seats
int(4) DEFAULT NULL,
f_fares
float(8,0) DEFAULT NULL,
f_discount_nums
float(8,0) DEFAULT NULL,
f_discount
float(8,0) DEFAULT NULL,
f_subordinate_company
varchar(20) DEFAULT NULL,
PRIMARY KEY (f_id
,f_date
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Records of flight
INSERT INTO flight
VALUES ('F001', '扬州', '苏州', '2012-12-12', '15:30', '14:20', '5', '99', '5', '1', '振宇有限公司');
INSERT INTO flight
VALUES ('F002', '扬州', '苏州', '2012-12-13', '12:20', '15:50', '20', '99', '5', '1', '振宇有限公司');
INSERT INTO flight
VALUES ('F003', '扬州', '北京', '2012-12-13', '12:20', '17:50', '4', '99', '5', '1', '振宇有限公司');
INSERT INTO flight
VALUES ('F004', '扬州', '泰国', '2012-12-13', '7:20', '8:50', '2', '99', '5', '1', '振宇有限公司');
INSERT INTO flight
VALUES ('F005', '扬州', '广州', '2012-12-14', '5:20', '14:50', '40', '99', '5', '1', '振宇有限公司');
=======================================================================
注意,我们的界面都是通过 Qt designer 拖拽制作的 .ui
文件,再通过 pyuic5 工具转为 .py
文件
简单起见,总共就只有三个界面文件:
主界面
hello.py
登陆界面
login.py
操作界面
operate.py
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(510, 300)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout_3 = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout_3.setObjectName("gridLayout_3")
self.gridLayout_2 = QtWidgets.QGridLayout()
self.gridLayout_2.setObjectName("gridLayout_2")
self.label = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(22)
self.label.setFont(font)
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setContentsMargins(-1, -1, -1, 15)
self.gridLayout.setHorizontalSpacing(10)
self.gridLayout.setVerticalSpacing(15)
self.gridLayout.setObjectName("gridLayout")
self.queryButton = QtWidgets.QPushButton(self.centralwidget)
self.queryButton.setMinimumSize(QtCore.QSize(250, 40))
self.queryButton.setMaximumSize(QtCore.QSize(250, 40))
self.queryButton.setObjectName("queryButton")
self.gridLayout.addWidget(self.queryButton, 1, 0, 1, 1)
self.manageButton = QtWidgets.QPushButton(self.centralwidget)
self.manageButton.setMinimumSize(QtCore.QSize(250, 40))
self.manageButton.setMaximumSize(QtCore.QSize(250, 40))
self.manageButton.setObjectName("manageButton")
self.gridLayout.addWidget(self.manageButton, 0, 0, 1, 1)
self.gridLayout_2.addLayout(self.gridLayout, 1, 0, 1, 1)
self.gridLayout_3.addLayout(self.gridLayout_2, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "主界面"))
self.label.setText(_translate("MainWindow", "欢迎使用票务管理系统"))
self.queryButton.setText(_translate("MainWindow", "票务查询"))
self.manageButton.setText(_translate("MainWindow", "票务管理"))
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(510, 290)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout_2.setObjectName("gridLayout_2")
self.label = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
self.label.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(25)
self.label.setFont(font)
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setContentsMargins(-1, -1, -1, 15)
self.gridLayout.setSpacing(20)
self.gridLayout.setObjectName("gridLayout")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
self.label_2.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(12)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1)
self.userText = QtWidgets.QLineEdit(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.userText.sizePolicy().hasHeightForWidth())
self.userText.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(12)
self.userText.setFont(font)
self.userText.setAlignment(QtCore.Qt.AlignCenter)
self.userText.setObjectName("userText")
self.gridLayout.addWidget(self.userText, 0, 1, 1, 1)
self.label_3 = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
self.label_3.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(12)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.gridLayout.addWidget(self.label_3, 1, 0, 1, 1)
self.pwdText = QtWidgets.QLineEdit(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fi
xed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pwdText.sizePolicy().hasHeightForWidth())
self.pwdText.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(12)
self.pwdText.setFont(font)
self.pwdText.setAlignment(QtCore.Qt.AlignCenter)
self.pwdText.setObjectName("pwdText")
self.gridLayout.addWidget(self.pwdText, 1, 1, 1, 1)
self.gridLayout_2.addLayout(self.gridLayout, 1, 0, 1, 1)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setContentsMargins(-1, -1, -1, 12)
self.horizontalLayout.setSpacing(20)
self.horizontalLayout.setObjectName("horizontalLayout")
self.okButton = QtWidgets.QPushButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.okButton.sizePolicy().hasHeightForWidth())
self.okButton.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(12)
self.okButton.setFont(font)
self.okButton.setObjectName("okButton")
self.horizontalLayout.addWidget(self.okButton)
self.cancelButton = QtWidgets.QPushButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.cancelButton.sizePolicy().hasHeightForWidth())
self.cancelButton.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(12)
self.cancelButton.setFont(font)
self.cancelButton.setObjectName("cancelButton")
self.horizontalLayout.addWidget(self.cancelButton)
self.gridLayout_2.addLayout(self.horizontalLayout, 2, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", " 登陆界面"))
self.label.setText(_translate("MainWindow", "请输入用户信息"))
self.label_2.setText(_translate("MainWindow", "用户名"))
self.label_3.setText(_translate("MainWindow", "密码"))
self.okButton.setText(_translate("MainWindow", "确定"))
self.cancelButton.setText(_translate("MainWindow", "取消"))
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(750, 460)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
self.tableWidget.setGeometry(QtCore.QRect(0, 90, 731, 161))
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(11)
self.tableWidget.setRowCount(9)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(4, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(5, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(6, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(7, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(8, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(4, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(5, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(6, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(7, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(8, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(9, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(10, item)
self.layoutWidget = QtWidgets.QWidget(self.centralwidget)
self.layoutWidget.setGeometry(QtCore.QRect(100, 380, 208, 35))
self.layoutWidget.setObjectName("layoutWidget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.layoutWidget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setSpacing(20)
self.horizontalLayout.setObjectName("horizontalLayout")
self.pushButton = QtWidgets.QPushButton(self.layoutWidget)
font = QtGui.QFont()
font.setPointSize(13)
self.pushButton.setFont(font)
self.pushButton.setObjectName("pushButton")
self.horizontalLayout.addWidget(self.pushButton)
self.exitButton = QtWidgets.QPushButton(self.layoutWidget)
font = QtGui.QFont()
font.setPointSize(13)
self.exitButton.setFont(font)
self.exitButton.setObjectName("exitButton")
self.horizontalLayout.addWidget(self.exitButton)
self.layoutWidget1 = QtWidgets.QWidget(self.centralwidget)
self.layoutWidget1.setGeometry(QtCore.QRect(50, 290, 241, 74))
self.layoutWidget1.setObjectName("layoutWidget1")
self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget1)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setSpacing(20)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.label = QtWidgets.QLabel(self.layoutWidget1)
font = QtGui.QFont()
font.setPointSize(15)
self.label.setFont(font)
self.label.setObjectName("label")
self.horizontalLayout_3.addWidget(self.label)
self.lineEdit = QtWidgets.QLineEdit(self.layoutWidget1)
font = QtGui.QFont()
font.setPointSize(15)
self.lineEdit.setFont(font)
self.lineEdit.setObjectName("lineEdit")
self.horizontalLayout_3.addWidget(self.lineEdit)
self.verticalLayout.addLayout(self.horizontalLayout_3)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setSpacing(20)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label_2 = QtWidgets.QLabel(self.layoutWidget1)
font = QtGui.QFont()
font.setPointSize(15)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.horizontalLayout_2.addWidget(self.label_2)
self.dateEdit = QtWidgets.QDateEdit(self.layoutWidget1)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.dateEdit.sizePolicy().hasHeightForWidth())
self.dateEdit.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(13)
self.dateEdit.setFont(font)
self.dateEdit.setObjectName("dateEdit")
self.horizontalLayout_2.addWidget(self.dateEdit)
self.verticalLayout.addLayout(self.horizontalLayout_2)
self.layoutWidget2 = QtWidgets.QWidget(self.centralwidget)
self.layoutWidget2.setGeometry(QtCore.QRect(200, 40, 321, 41))
self.layoutWidget2.setObjectName("layoutWidget2")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.layoutWidget2)
self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_4.setSpacing(20)
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.pushButton_3 = QtWidgets.QPushButton(self.layoutWidget2)
self.pushButton_3.setObjectName("pushButton_3")
self.horizontalLayout_4.addWidget(self.pushButton_3)
self.pushButton_4 = QtWidgets.QPushButton(self.layoutWidget2)
self.pushButton_4.setObjectName("pushButton_4")
self.horizontalLayout_4.addWidget(self.pushButton_4)
self.pushButton_5 = QtWidgets.QPushButton(self.layoutWidget2)
self.pushButton_5.setObjectName("pushButton_5")
self.horizontalLayout_4.addWidget(self.pushButton_5)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "操作界面"))
item = self.tableWidget.verticalHeaderItem(0)
item.setText(_translate("MainWindow", "1"))
item = self.tableWidget.verticalHeaderItem(1)
item.setText(_translate("MainWindow", "2"))
item = self.tableWidget.verticalHeaderItem(2)
item.setText(_translate("MainWindow", "3"))
item = self.tableWidget.verticalHeaderItem(3)
item.setText(_translate("MainWindow", "4"))
item = self.tableWidget.verticalHeaderItem(4)
item.setText(_translate("MainWindow", "5"))
item = self.tableWidget.verticalHeaderItem(5)
item.setText(_translate("MainWindow", "6"))
item = self.tableWidget.verticalHeaderItem(6)
item.setText(_translate("MainWindow", "7"))
item = self.tableWidget.verticalHeaderItem(7)
item.setText(_translate("MainWindow", "8"))
item = self.tableWidget.verticalHeaderItem(8)
item.setText(_translate("MainWindow", "9"))
item = self.tableWidget.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "航班号"))
item = self.tableWidget.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "起点"))
item = self.tableWidget.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "终点"))
item = self.tableWidget.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "日期"))
item = self.tableWidget.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "起飞时刻"))
item = self.tableWidget.horizontalHeaderItem(5)
item.setText(_translate("MainWindow", "到达时刻"))
item = self.tableWidget.horizontalHeaderItem(6)
item.setText(_translate("MainWindow", "票价"))
item = self.tableWidget.horizontalHeaderItem(7)
item.setText(_translate("MainWindow", "折扣票数"))
item = self.tableWidget.horizontalHeaderItem(8)
item.setText(_translate("MainWindow", "剩余座位数"))
item = self.tableWidget.horizontalHeaderItem(9)
item.setText(_translate("MainWindow", "折扣率"))
item = self.tableWidget.horizontalHeaderItem(10)
评论