Esempio n. 1
0
class second(QtGui.QDialog):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.bye)
        QtCore.QObject.connect(self.ui.pushButton_2, QtCore.SIGNAL("clicked()"), self.add)
        self.CX = sqlite3.connect("data.db")
        self.CU = self.CX.cursor()

    def add(self):
        code = self.ui.lineEdit.text()
        name = self.ui.lineEdit_2.text()
        isProduct = self.ui.checkBox.isChecked()
        self.CU.execute("select * from material where code = '"+str(code)+"'")
        ans = self.CU.fetchmany(1)
        if len(ans) > 0:
            QMessageBox.warning(self, "Wrong", 'Code Name has already exist!')
        else:
            self.CU.execute("insert into material values(?,?,?,?)",(None, str(code), str(name), isProduct))
            self.CX.commit()
            myapp.update_memory()
            myapp.update_tree()
            self.close()

    def bye(self):
        self.close()
Esempio n. 2
0
 def __init__(self, parent=None):
     QtGui.QWidget.__init__(self, parent)
     self.ui = Ui_Dialog()
     self.ui.setupUi(self)
     QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.bye)
     QtCore.QObject.connect(self.ui.pushButton_2, QtCore.SIGNAL("clicked()"), self.add)
     self.CX = sqlite3.connect("data.db")
     self.CU = self.CX.cursor()