Example #1
0
 def __init__(self, parent=None):
     QtGui.QWidget.__init__(self, parent)
     self.addUnitWidget = Ui_addGoods()
     self.addUnitWidget.setupUi(self)
     QtCore.QObject.connect(self.addUnitWidget.buttonBox,
                            QtCore.SIGNAL(_fromUtf8("accepted()")),
                            self.save_unit)
     self.addUnitWidget.NdsEdit.setText(str(NDS))
Example #2
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.editUnitWidget = Ui_addGoods()
        self.editUnitWidget.setupUi(self)
        QtCore.QObject.connect(self.editUnitWidget.buttonBox,
                               QtCore.SIGNAL(_fromUtf8("accepted()")),
                               self.save_unit)
        #self.editUnitWidget.addGoods.setWindowTitle(QtGui.QApplication.translate("addGoods", "Изменение позиции", None, QtGui.QApplication.UnicodeUTF8))

        self.units = myapp.ui.tableWidget.selectedItems()
        self.row = myapp.ui.tableWidget.row(self.units[0])
        self.name = myapp.ui.tableWidget.item(
            myapp.ui.tableWidget.row(self.units[0]), 1).text()
        #print (self.name)

        conn = sqlite3.connect(str(db_filename))
        cur = conn.cursor()
        row = cur.execute('select * from goodscatalog where name=?',
                          (self.name, ))
        keyss = tuple([d[0] for d in cur.description])  # Получаем имена полей

        conn.commit()

        # Создаём словарь из строки базы >>
        for field in row:
            #print (field)
            row1 = field
        #print ('Ключи ', keyss)
        #print('ROW1 = ', row1)

        self.dictionary = dict(zip(keyss, row1))
        #print (self.dictionary)

        # << Создаём словарь из строки базы

        # Вывод данных и словаря в форму >>

        self.editUnitWidget.ArticleEdit.setText(str(
            self.dictionary['article']))
        self.editUnitWidget.NameEdit.setText(str(self.dictionary['name']))
        self.editUnitWidget.PriceEdit.setText(str(self.dictionary['price']))
        self.editUnitWidget.BrendEdit.setText(str(self.dictionary['brand']))
        self.editUnitWidget.CountryEdit.setText(str(
            self.dictionary['country']))
        self.editUnitWidget.NdsEdit.setText(str(self.dictionary['nds']))
Example #3
0
class addUnitDialog(QtGui.QDialog):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.addUnitWidget = Ui_addGoods()
        self.addUnitWidget.setupUi(self)
        QtCore.QObject.connect(self.addUnitWidget.buttonBox,
                               QtCore.SIGNAL(_fromUtf8("accepted()")),
                               self.save_unit)
        self.addUnitWidget.NdsEdit.setText(str(NDS))

    def save_unit(self):
        #print ("Сохранить позицию")
        #print (self.addUnitWidget.NameEdit.text())
        #print (type(self.addUnitWidget.NameEdit.text()))
        if db_filename:
            if self.addUnitWidget.NameEdit.text():
                conn = sqlite3.connect(str(db_filename))
                cur = conn.cursor()
                # Для наглядности -
                # goodscatalog(article integer, name text, price real, brand text, country text, barcode0 integer, barcode1 integer, minimal integer, gruppa text, measure text, nds integer)
                cur.execute(
                    'insert into goodscatalog values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
                    (int(self.addUnitWidget.ArticleEdit.text()),
                     self.addUnitWidget.NameEdit.text(),
                     float(self.addUnitWidget.PriceEdit.text()),
                     self.addUnitWidget.BrendEdit.text(),
                     self.addUnitWidget.CountryEdit.text(), 0, 0,
                     int(self.addUnitWidget.MinimalEdit.text()), 'Группа',
                     self.addUnitWidget.MeasureEdit.text(),
                     int(self.addUnitWidget.NdsEdit.text())))

                conn.commit()
                self.close()
                myapp.load_data('goodscatalog')
            else:
                err = QtGui.QMessageBox(self)
                err.setText('Введите название !')
                err.setIcon(2)
                err.show()
        else:
            #print ("База данных не выбрана !")
            err = QtGui.QMessageBox(self)
            err.setText('База данных не выбрана !')
            err.setIcon(2)
            err.show()
Example #4
0
class addUnitDialog(QtGui.QDialog):
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self,parent)
        self.addUnitWidget = Ui_addGoods()
        self.addUnitWidget.setupUi(self)
        QtCore.QObject.connect(self.addUnitWidget.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.save_unit)
        self.addUnitWidget.NdsEdit.setText(str(NDS))



    def save_unit(self):
        #print ("Сохранить позицию")
        #print (self.addUnitWidget.NameEdit.text())
        #print (type(self.addUnitWidget.NameEdit.text()))
        if db_filename:
            if self.addUnitWidget.NameEdit.text():
                conn = sqlite3.connect(str(db_filename))
                cur = conn.cursor()
# Для наглядности -
# goodscatalog(article integer, name text, price real, brand text, country text, barcode0 integer, barcode1 integer, minimal integer, gruppa text, measure text, nds integer)
                cur.execute('insert into goodscatalog values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', (int(self.addUnitWidget.ArticleEdit.text()),
                    self.addUnitWidget.NameEdit.text(), float(self.addUnitWidget.PriceEdit.text()),
                    self.addUnitWidget.BrendEdit.text(), self.addUnitWidget.CountryEdit.text(), 0, 0,
                    int(self.addUnitWidget.MinimalEdit.text()), 'Группа', self.addUnitWidget.MeasureEdit.text(), int(self.addUnitWidget.NdsEdit.text())))

                conn.commit()
                self.close()
                myapp.load_data('goodscatalog')
            else:
                err = QtGui.QMessageBox(self)
                err.setText('Введите название !')
                err.setIcon(2)
                err.show()
        else:
            #print ("База данных не выбрана !")
            err = QtGui.QMessageBox(self)
            err.setText('База данных не выбрана !')
            err.setIcon(2)
            err.show()
Example #5
0
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self,parent)
        self.editUnitWidget = Ui_addGoods()
        self.editUnitWidget.setupUi(self)
        QtCore.QObject.connect(self.editUnitWidget.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.save_unit)
        #self.editUnitWidget.addGoods.setWindowTitle(QtGui.QApplication.translate("addGoods", "Изменение позиции", None, QtGui.QApplication.UnicodeUTF8))

        self.units = myapp.ui.tableWidget.selectedItems()
        self.row = myapp.ui.tableWidget.row(self.units[0])
        self.name = myapp.ui.tableWidget.item(myapp.ui.tableWidget.row(self.units[0]), 1).text()
        #print (self.name)

        conn=sqlite3.connect(str(db_filename))
        cur=conn.cursor()
        row = cur.execute('select * from goodscatalog where name=?', (self.name,))
        keyss = tuple([d[0] for d in cur.description]) # Получаем имена полей

        conn.commit()

        # Создаём словарь из строки базы >>
        for field in row:
            #print (field)
            row1 = field
        #print ('Ключи ', keyss)
        #print('ROW1 = ', row1)

        self.dictionary = dict(zip(keyss, row1))
        #print (self.dictionary)

        # << Создаём словарь из строки базы

        # Вывод данных и словаря в форму >>

        self.editUnitWidget.ArticleEdit.setText(str(self.dictionary['article']))
        self.editUnitWidget.NameEdit.setText(str(self.dictionary['name']))
        self.editUnitWidget.PriceEdit.setText(str(self.dictionary['price']))
        self.editUnitWidget.BrendEdit.setText(str(self.dictionary['brand']))
        self.editUnitWidget.CountryEdit.setText(str(self.dictionary['country']))
        self.editUnitWidget.NdsEdit.setText(str(self.dictionary['nds']))
Example #6
0
class editUnitDialog(addUnitDialog):
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self,parent)
        self.editUnitWidget = Ui_addGoods()
        self.editUnitWidget.setupUi(self)
        QtCore.QObject.connect(self.editUnitWidget.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.save_unit)
        #self.editUnitWidget.addGoods.setWindowTitle(QtGui.QApplication.translate("addGoods", "Изменение позиции", None, QtGui.QApplication.UnicodeUTF8))

        self.units = myapp.ui.tableWidget.selectedItems()
        self.row = myapp.ui.tableWidget.row(self.units[0])
        self.name = myapp.ui.tableWidget.item(myapp.ui.tableWidget.row(self.units[0]), 1).text()
        #print (self.name)

        conn=sqlite3.connect(str(db_filename))
        cur=conn.cursor()
        row = cur.execute('select * from goodscatalog where name=?', (self.name,))
        keyss = tuple([d[0] for d in cur.description]) # Получаем имена полей

        conn.commit()

        # Создаём словарь из строки базы >>
        for field in row:
            #print (field)
            row1 = field
        #print ('Ключи ', keyss)
        #print('ROW1 = ', row1)

        self.dictionary = dict(zip(keyss, row1))
        #print (self.dictionary)

        # << Создаём словарь из строки базы

        # Вывод данных и словаря в форму >>

        self.editUnitWidget.ArticleEdit.setText(str(self.dictionary['article']))
        self.editUnitWidget.NameEdit.setText(str(self.dictionary['name']))
        self.editUnitWidget.PriceEdit.setText(str(self.dictionary['price']))
        self.editUnitWidget.BrendEdit.setText(str(self.dictionary['brand']))
        self.editUnitWidget.CountryEdit.setText(str(self.dictionary['country']))
        self.editUnitWidget.NdsEdit.setText(str(self.dictionary['nds']))

        # Дописать !!

        # <<Вывод данных и словаря в форму

    def save_unit(self):
        #print ('Схранить изменения')
        if db_filename:
            if self.editUnitWidget.NameEdit.text():
                conn = sqlite3.connect(str(db_filename))
                cur = conn.cursor()
# Для наглядности -
# goodscatalog(article integer, name text, price real, brand text, country text, barcode0 integer, barcode1 integer, minimal integer, gruppa text, measure text, nds integer)
                cur.execute('delete from goodscatalog where name=?', (self.dictionary['name'],))
                cur.execute('insert into goodscatalog values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', (int(self.editUnitWidget.ArticleEdit.text()),
                    self.editUnitWidget.NameEdit.text(), float(self.editUnitWidget.PriceEdit.text()),
                    self.editUnitWidget.BrendEdit.text(), self.editUnitWidget.CountryEdit.text(), 0, 0,
                    int(self.editUnitWidget.MinimalEdit.text()), 'Группа', self.editUnitWidget.MeasureEdit.text(), int(self.editUnitWidget.NdsEdit.text())))

                conn.commit()

                self.close()
                myapp.load_data('goodscatalog')
            else:
                err = QtGui.QMessageBox(self)
                err.setText('Введите название !')
                err.setIcon(2)
                err.show()
        else:
            #print ("База данных не выбрана !")
            err = QtGui.QMessageBox(self)
            err.setText('База данных не выбрана !')
            err.setIcon(2)
            err.show()


        self.close()
        myapp.load_data('goodscatalog')
Example #7
0
 def __init__(self, parent = None):
     QtGui.QWidget.__init__(self,parent)
     self.addUnitWidget = Ui_addGoods()
     self.addUnitWidget.setupUi(self)
     QtCore.QObject.connect(self.addUnitWidget.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.save_unit)
     self.addUnitWidget.NdsEdit.setText(str(NDS))
Example #8
0
class editUnitDialog(addUnitDialog):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.editUnitWidget = Ui_addGoods()
        self.editUnitWidget.setupUi(self)
        QtCore.QObject.connect(self.editUnitWidget.buttonBox,
                               QtCore.SIGNAL(_fromUtf8("accepted()")),
                               self.save_unit)
        #self.editUnitWidget.addGoods.setWindowTitle(QtGui.QApplication.translate("addGoods", "Изменение позиции", None, QtGui.QApplication.UnicodeUTF8))

        self.units = myapp.ui.tableWidget.selectedItems()
        self.row = myapp.ui.tableWidget.row(self.units[0])
        self.name = myapp.ui.tableWidget.item(
            myapp.ui.tableWidget.row(self.units[0]), 1).text()
        #print (self.name)

        conn = sqlite3.connect(str(db_filename))
        cur = conn.cursor()
        row = cur.execute('select * from goodscatalog where name=?',
                          (self.name, ))
        keyss = tuple([d[0] for d in cur.description])  # Получаем имена полей

        conn.commit()

        # Создаём словарь из строки базы >>
        for field in row:
            #print (field)
            row1 = field
        #print ('Ключи ', keyss)
        #print('ROW1 = ', row1)

        self.dictionary = dict(zip(keyss, row1))
        #print (self.dictionary)

        # << Создаём словарь из строки базы

        # Вывод данных и словаря в форму >>

        self.editUnitWidget.ArticleEdit.setText(str(
            self.dictionary['article']))
        self.editUnitWidget.NameEdit.setText(str(self.dictionary['name']))
        self.editUnitWidget.PriceEdit.setText(str(self.dictionary['price']))
        self.editUnitWidget.BrendEdit.setText(str(self.dictionary['brand']))
        self.editUnitWidget.CountryEdit.setText(str(
            self.dictionary['country']))
        self.editUnitWidget.NdsEdit.setText(str(self.dictionary['nds']))

        # Дописать !!

        # <<Вывод данных и словаря в форму

    def save_unit(self):
        #print ('Схранить изменения')
        if db_filename:
            if self.editUnitWidget.NameEdit.text():
                conn = sqlite3.connect(str(db_filename))
                cur = conn.cursor()
                # Для наглядности -
                # goodscatalog(article integer, name text, price real, brand text, country text, barcode0 integer, barcode1 integer, minimal integer, gruppa text, measure text, nds integer)
                cur.execute('delete from goodscatalog where name=?',
                            (self.dictionary['name'], ))
                cur.execute(
                    'insert into goodscatalog values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
                    (int(self.editUnitWidget.ArticleEdit.text()),
                     self.editUnitWidget.NameEdit.text(),
                     float(self.editUnitWidget.PriceEdit.text()),
                     self.editUnitWidget.BrendEdit.text(),
                     self.editUnitWidget.CountryEdit.text(), 0, 0,
                     int(self.editUnitWidget.MinimalEdit.text()), 'Группа',
                     self.editUnitWidget.MeasureEdit.text(),
                     int(self.editUnitWidget.NdsEdit.text())))

                conn.commit()

                self.close()
                myapp.load_data('goodscatalog')
            else:
                err = QtGui.QMessageBox(self)
                err.setText('Введите название !')
                err.setIcon(2)
                err.show()
        else:
            #print ("База данных не выбрана !")
            err = QtGui.QMessageBox(self)
            err.setText('База данных не выбрана !')
            err.setIcon(2)
            err.show()

        self.close()
        myapp.load_data('goodscatalog')