Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. class managercreateevent(QMainWindow, Ui_ManagerCreateEvent):
  2. def __init__(self, parent= None):
  3. super(managercreateevent, self).__init__(parent)
  4. self.setupUi(self)
  5. self.BackButton.clicked.connect(self.back_button)
  6. self.createButton.clicked.connect(self.create_button)
  7. connection = pymysql.connect(host="localhost",
  8. user="root",
  9. password="12345678",
  10. db="beltline")
  11. cursor = connection.cursor()
  12. showStaff = f"select concat(user.firstname, " ", user.lastname) from employee join user on employee.username = user.username where employee.employeetype = 'Staff'"
  13. df = pd.read_sql(showStaff, connection)
  14. model = PandasModel(df)
  15. self.tableView.setModel(model)
  16.  
  17. def back_button(self):
  18. self.window = managermanageevent()
  19. self.close()
  20. self.window.show()
  21.  
  22.  
  23. def create_button(self):
  24. name = self.nameEdit.text()
  25. price = self.priceEdit.text()
  26. capacity = self.capacityEdit.text()
  27. minStaffRequired = self.minStaffEdittext()
  28. startDate = self.startDateEdit.text()
  29. endDate = self.endDateEdit.text()
  30. description = self.textBrowser.text()
  31. connection = pymysql.connect(host="localhost",
  32. user="root",
  33. password="12345678",
  34. db="beltline")
  35. cursor = connection.cursor()
  36.  
  37. userlist = self.tableView.selectionModel().selectedRows()
  38. for i in userlist:
  39. index = i.row()
  40.  
  41. createQuery = f"select concat(user.firstname, " ", user.lastname) from employee join user on employee.username = user.username where employee.employeetype = 'Staff'"
  42. cursor.execute(createQuery)
  43. assignStaff = cursor.fetchall()[index][0]
  44.  
  45. # for now, hard-coding the site name as atl beltline center
  46. createEvent = f"insert into event (Name, StartDate, SiteName, EndDate, Price, Capacity, Description, MinStaffReq) values ('{name}', '{startDate}', 'Atlanta Beltline Center', '{endDate}', '{price}', '{capacity}', '{description}', '{minStaffRequired}')"
  47. connection.commit()
  48. self.window = managermanageevent()
  49. self.close()
  50. self.window.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement