Update professional history
[biacv.git] / biacv_mainwindow.py
index e58aa37..0af93bc 100644 (file)
@@ -9,6 +9,36 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                self.setupUi (self)
                self.currentfile = None
 
+       # update professional history button is clicked
+       def on_update_profession (self):
+               # get the selected item
+               selitems = self.professionlist.selectedItems ()
+               if selitems == []:
+                       PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "No item selected.")
+                       return
+               selitem = selitems[0]
+               # if designation is not set
+               if self.designation.text () == "":
+                       PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "A required field is missing.")
+                       return
+               # if currently employed in that position, leaving date is to be disabled
+               # and set to "current"
+               if self.currentemployment.isChecked ():
+                       leavedatestr = "current"
+               else:
+                       # if the leaving date is < join date
+                       if self.leavedate.date () < self.joindate.date ():
+                               PyQt4.QtGui.QMessageBox.critical (self, "Cannot add",
+                                       "Leaving date cannot be earlier than join date.")
+                               return
+                       leavedatestr = self.leavedate.date ().toString ("dd MMM, yyyy")
+
+               selitem.setText (0, self.designation.text ())
+               selitem.setText (1, self.joindate.date ().toString ("dd MMM, yyyy"))
+               selitem.setText (2, leavedatestr)
+               selitem.setText (3, self.organization.text ())
+               selitem.setText (4, self.additionalinfo.text ())
+
        # delete professional history button is clicked
        def on_delete_profession (self):
                # get the selected items
@@ -31,10 +61,16 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                if self.designation.text () == "":
                        PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", "A required field is missing.")
                        return
-
+               # if currently employed in that position, leaving date is to be disabled
+               # and set to "current"
                if self.currentemployment.isChecked ():
                        leavedatestr = "current"
                else:
+                       # if the leaving date is < join date
+                       if self.leavedate.date () < self.joindate.date ():
+                               PyQt4.QtGui.QMessageBox.critical (self, "Cannot add",
+                                       "Leaving date cannot be earlier than join date.")
+                               return
                        leavedatestr = self.leavedate.date ().toString ("dd MMM, yyyy")
 
                professionitem = PyQt4.QtGui.QTreeWidgetItem (