示例#1
0
    def __init__(self, RestPage):
        self.setupUi(RestPage)
        self.db = pymysql.connect(host="localhost",
                                  port=3306,
                                  user=gl.get_value('sql_account'),
                                  passwd=gl.get_value('sql_passwd'),
                                  db="Takeout",
                                  charset="utf8")
        self.cursor = self.db.cursor()

        self.get_rest_info()
        RestPage.setWindowTitle('Rest--{}'.format(self.restName))
        self.update()
        self.updateInfoPage()

        self.timer = QTimer()
        self.timer.timeout.connect(self.update)
        self.timer.start(1000)  # flush 1hz

        self.tableWidget_course.currentCellChanged.connect(self.courseChanged)
        self.addCourse.clicked.connect(self.add_clicked)
        self.saveCourse.clicked.connect(self.save_clicked)
        self.deleteCourse.clicked.connect(self.delete_clicked)

        self.tableWidget_order.currentCellChanged.connect(self.update)
        self.acceptOrder.clicked.connect(self.accept_clicked)
        self.rejectOrder.clicked.connect(self.reject_clicked)

        self.tableWidget_history.currentCellChanged.connect(self.update)
        self.saveChange.clicked.connect(self.saveChange_clicked)
        self.abandonChange.clicked.connect(self.abandonChange_clicked)
示例#2
0
    def login(self):
        if self.radioButton_user.isChecked():
            type_ = self.radioButton_user.text()
        elif self.radioButton_rest.isChecked():
            type_ = self.radioButton_rest.text()
        elif self.radioButton_rider.isChecked():
            type_ = self.radioButton_rider.text()

        self.sqlvisitor.login(int(self.lineEdit_ID.text()),
                              self.lineEdit_passwd.text(), type_)
        if gl.get_login_state():
            print("%d: %s" % (gl.get_value('account'), gl.get_value('type')))
            self.jump_page()
示例#3
0
    def register(self):
        print('button pushed')
        if self.radioButton_user_.isChecked():
            type_ = self.radioButton_user_.text()
        elif self.radioButton_rest_.isChecked():
            type_ = self.radioButton_rest_.text()
        elif self.radioButton_rider_.isChecked():
            type_ = self.radioButton_rider_.text()

        self.sqlvisitor.register(int(self.lineEdit_ID_.text()),
                                 self.lineEdit_passwd_.text(), type_)
        if gl.get_login_state():
            print("%d: %s" % (gl.get_value('account'), gl.get_value('type')))
            self.jump_page()
示例#4
0
    def jump_page(self):
        self.LoginPage.close()
        self.sqlvisitor.db.close()

        if gl.get_value('type') == 'User':
            dialog_ = QtWidgets.QDialog()
            ui_ = userPage_.myuserPage(dialog_)
        elif gl.get_value('type') == 'Rest':
            dialog_ = QtWidgets.QDialog()
            ui_ = restPage_.myrestPage(dialog_)
        elif gl.get_value('type') == 'Rider':
            dialog_ = QtWidgets.QDialog()
            ui_ = riderPage_.myriderPage(dialog_)

        dialog_.show()
        dialog_.exec_()
        gl.reset_state()
        self.delete_all_input()
        #self.LoginPage.show()
示例#5
0
 def get_rest_info(self):
     self.restAccount = gl.get_value('account')
     cmd = 'select RestID, RestName, RestTel, RestScore, LocX, LocY ' +\
      'from rest where AccountID = "{}"'.format(self.restAccount)
     count = self.cursor.execute(cmd)
     if count > 0:
         result = self.cursor.fetchone()
         self.restID = result[0]
         self.restName = result[1]
         self.restTel = result[2]
         self.restScore = result[3]
         self.locX = result[4]
         self.locY = result[5]
示例#6
0
	def get_rider_info(self):
		self.rider_account = gl.get_value('account')
		cmd = 'select riderID, riderName, riderTel from rider where rider.accountID={}'.format(self.rider_account)
		count = self.cursor.execute(cmd)
		result = self.cursor.fetchone()

		self.riderID = result[0]
		self.riderName = result[1]
		self.riderTel = result[2]

		# create view for this rider
		cmd = 'create or replace view tmp_order as (select OrderID, UserID, LocIdx, RestID, OrderTime, State from orders where (riderID is NULL or riderID={}) and restID in (select restID from restrider \
				where riderID={}));'.format(self.riderID, self.riderID)
		count = self.cursor.execute(cmd)
示例#7
0
	def __init__(self, RiderPage):
		self.setupUi(RiderPage)

		self.db = pymysql.connect(host="localhost", port=3306,
								  user=gl.get_value('sql_account'), 
								  passwd=gl.get_value('sql_passwd'),
								  db="Takeout", charset="utf8")
		self.cursor = self.db.cursor()

		self.get_rider_info()
		self.update() # flush
		self.updateRiderInfo() # not flush

		RiderPage.setWindowTitle('Rider--{}'.format(self.riderName))

		self.acceptOrder.clicked.connect(self.accpet_clicked)
		self.rejectOrder.clicked.connect(self.reject_clicked)

		self.saveChange.clicked.connect(self.saveChange_clicked)
		self.abandonChange.clicked.connect(self.updateRiderInfo)

		self.timer = QTimer()
		self.timer.timeout.connect(self.update) 
		self.timer.start(1000)
示例#8
0
    def __init__(self, MainPage):
        self.UserPage = MainPage
        self.setupUi(MainPage)

        self.db = pymysql.connect(host="localhost",
                                  port=3306,
                                  user="******",
                                  passwd="123456",
                                  db="Takeout",
                                  charset="utf8")
        self.cursor = self.db.cursor()

        #self.sqlvisitor = connector.sqlConnector()
        self.restName = self.show_all_rest_names()
        self.restName_ = ''
        self.courseName = []
        self.orders = []
        self.orderID = None
        self.fillListRest()

        #		self.axWidget.setControl("{8856F961-340A-11D0-A96B-00C04FD705A2}")
        #		self.axWidget.setObjectName("webWidget")
        #		self.axWidget.setFocusPolicy(Qt.StrongFocus)
        #		self.axWidget.setProperty("DisplayAlerts",False)
        #		self.axWidget.setProperty("DisplayScrollBars",True)
        #		webstr = "www.baidu.com"
        #		self.axWidget.dynamicCall("Navigate(const QString&)",webstr)
        '''---user info---'''
        self.accountID = gl.get_value('account')
        self.addLoginTime()
        self.userID_, self.userName_, self.userTel_ = self.query_user_info()
        print("{}: {}, {}".format(self.userID_, self.userName_, self.userTel_))
        self.locNum = 0
        self.locTitles = ['Address', 'Longitude', 'Latitude']
        self.locTitles_ = []
        self.LocRowClicked = None
        self.changeRecord = None
        self.locs = ()
        self.initTableLoc()
        self.showinfo()
        MainPage.setWindowTitle('User--{}'.format(self.userName_))
        '''---interface---'''
        self.listWidget_rest.currentRowChanged.connect(self.restClicked)
        self.listWidget_course.currentRowChanged.connect(self.courseClicked)
        self.checkBox.stateChanged.connect(self.selectClicked)
        self.spinBox.valueChanged.connect(self.numChanged)
        self.placeOrder.clicked.connect(self.commitOrder)
        self.pushButton_confirmReceipt.clicked.connect(self.confirmReceipt)
        self.addAddress.clicked.connect(self.add_address)
        self.deleteAddress.clicked.connect(self.delete_address)
        self.modifyAddress.clicked.connect(self.modify_address)
        self.saveChange.clicked.connect(self.saveInfoChange)
        self.abandonChange.clicked.connect(self.abandonInfoChange)
        '''---init history orders state---'''
        self.cursor.execute(
            "select orderID,state from Orders where UserID={} and state<3;".
            format(self.userID_))
        self.historyIncompleteOrder = self.cursor.fetchall()
        if self.historyIncompleteOrder:
            tmp = self.historyIncompleteOrder[0][0]
            state = self.historyIncompleteOrder[0][1]
            print("Incomplete orderID: {}, state:{}".format(tmp, state))
            if state == 0:
                self.label_deliverState.setText(
                    "Waiting for being accepted by restaurant")
            elif state == 1:
                self.label_deliverState.setText("Order accepted by restaurant")
            elif state == 2:
                self.label_deliverState.setText("Order delivering")
        else:
            self.label_deliverState.setText("No Order")
        '''---init table of orders and Loc---'''
        self.recordNum = 0
        self.recordTitles = []
        self.titles = [
            'Course', 'RestName', 'RiderName', 'State', 'Timestamp',
            'Score_Rest', 'Score_Rider', 'Comment'
        ]
        self.historyOrders = (
        )  # (orderID(hide), restID, riderID, state, "course", timestamp, score1, score2, "comment")
        self.initTableOrder()
        self.recordRowClicked = None
        self.doubleSpinBox_rest.setRange(0, 5)
        self.doubleSpinBox_rider.setRange(0, 5)
        self.commit_comment.clicked.connect(self.commitComment)

        self.timer = QTimer()
        self.timer.timeout.connect(self.update)
        self.timer.start(1000)