Beispiel #1
0
class Ui_Client_New(Ui):
  def __init__(self, window):
    self.form = Form_Client()
    super(Ui_Client_New, self).__init__(window)

  def init(self):
    client = Client()
    #print client._get_FIELD_display()	
    print dir(client)

    for field in Client._meta.fields:
      print field.name
      print field.verbose_name
      print field.get_internal_type()


    layoutForm = self.form.formFields()
    layoutButtons = self.form.formButtons()

    self.form.saveButton.clicked.connect(self.save)
    self.form.cancelButton.clicked.connect(self.showClient)
    self.form.backButton.clicked.connect(self.showMain)

    layout = QtGui.QVBoxLayout()
    layout.addLayout(layoutForm)
    layout.addLayout(layoutButtons)

    self.setLayout(layout)

  def save(self):
    client = Client()
    
    for k, v in self.form.elements.items():
      setattr(client, k, v.text())

    round_nbr = self.form.group.checkedId()
    setattr(client, 'round_nbr', round_nbr)

    for listWidget in self.form.listWidget.selectedItems():
      order = listWidget.type()

    if order == -1:
      order = Client.objects.filter(round_nbr = round_nbr).count()
      order = order
    else:
      Client.objects.filter(round_nbr = round_nbr, order__gte = order).update(order = F('order') + 1)
    
    setattr(client, 'order', order)

    print "order:" + str(order)

    client.save()
    self.showClient()
    self.window.destroyFrame('Ui_Client_New')
    self.window.setMessage("Nieuwe klant met nummer " + str(client.id) + " aangemaakt!")
Beispiel #2
0
class Ui_Client_View(Ui):
  def __init__(self, window):
    super(Ui_Client_View, self).__init__(window)

  def createSearchForm(self):
    self.clientNumber = QtGui.QLineEdit()
    self.clientName = QtGui.QLineEdit()
    self.clientFirstname = QtGui.QLineEdit()
    self.searchButton = QtGui.QPushButton("zoek")

    self.searchButton.clicked.connect(self.search)

    layoutSearch = QtGui.QVBoxLayout()

    number = QtGui.QHBoxLayout()
    number.addWidget(QtGui.QLabel("Klantnummer"))
    number.addWidget(self.clientNumber)
    layoutSearch.addLayout(number)

    name = QtGui.QHBoxLayout()
    name.addWidget(QtGui.QLabel("Naam"))
    name.addWidget(self.clientName)
    layoutSearch.addLayout(name)
    
    firstname = QtGui.QHBoxLayout()
    firstname.addWidget(QtGui.QLabel("Voornaam"))
    firstname.addWidget(self.clientFirstname)
    layoutSearch.addLayout(firstname)
    
    layoutSearch.addWidget(self.searchButton)
 
    return layoutSearch

  def createBackButtons(self):
    layout = QtGui.QHBoxLayout()

    self.backButton = QtGui.QPushButton("Terug")
    self.backButton.clicked.connect(self.showClient)
    
    self.backMainButton = QtGui.QPushButton("Terug naar hoofdmenu")
    self.backMainButton.clicked.connect(self.showMain)
    
    layout.addWidget(self.backButton)
    layout.addWidget(self.backMainButton)

    return layout

  def init(self):
    self.layout = QtGui.QVBoxLayout()
    self.layout.addLayout(self.createSearchForm())

    self.formSearch = Form_Client()
    layoutForm = self.formSearch.formFields()
    self.formSearch.disableFormFields()

    self.layout.addLayout(layoutForm)
    self.layout.addLayout(self.createBackButtons())
  
    self.setLayout(self.layout)

  def search(self):

    if len(self.clientNumber.text()):
      client = Client.objects.get(id = int(self.clientNumber.text()))
    elif len(self.clientName.text()):
      client = Client.objects.get(name = self.clientName.text())
    elif len(self.clientFirstname.text()):
      client = Client.objects.get(firstname = self.clientFirstname.text())
    
    self.formSearch.populateFormFields(client)