-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete.py
116 lines (98 loc) · 4.28 KB
/
delete.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'C:\Users\Dnyanu\PycharmProjects\details\delete.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
import mysql.connector
from product import *
import mysql as mdb
# from PyQt5.QtWidgets import QApplication,QWidget,QLabel
from PyQt5.QtGui import *
from PyQt5.QtCore import *
# from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class Ui_delete(object):
def HOME(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_abc()
self.ui.setupUi(self.window)
MainWindow.hide()
self.window.show()
def alertmsg(self, title, Message):
warn = QtWidgets.QMessageBox()
warn.setIcon(QtWidgets.QMessageBox.Information)
warn.setWindowTitle(title)
warn.setText(Message)
warn.setStandardButtons(QtWidgets.QMessageBox.Ok)
warn.setWindowIcon(QtGui.QIcon('erroe.png'))
warn.exec_()
def ok(self, title, Message):
ok1 = QtWidgets.QMessageBox()
ok1.setIcon(QtWidgets.QMessageBox.Information)
ok1.setWindowTitle(title)
ok1.setText(Message)
ok1.setStandardButtons(QtWidgets.QMessageBox.Ok)
ok1.setWindowIcon(QtGui.QIcon('ok.png'))
ok1.exec_()
def delete(self):
a = self.lineEdit.text()
# print(a, "Deleted")
mydb = mysql.connector.connect(host="localhost", user="root", password="root", database='testapp')
cursor = mydb.cursor()
# for pid in ('pro'):
# aaa = "DELETE FROM `pro` WHERE pid = %s"
# cursor.execute(aaa,(pid,))
if a=="" or a== "null":
(self.alertmsg("error", "Please Enter ID"))
else:
cursor.execute(aaa, (a,))
mydb.commit()
cursor.close()
mydb.close()
(self.ok("Successfull", "Deleted"))
def setupUi(self, MainWindow):
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(270, 170, 181, 61))
self.lineEdit.setText("")
self.lineEdit.setAlignment(QtCore.Qt.AlignCenter)
self.lineEdit.setCursorMoveStyle(QtCore.Qt.LogicalMoveStyle)
self.lineEdit.setObjectName("lineEdit")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(310, 270, 93, 28))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(310, 350, 93, 28))
self.pushButton_2.setObjectName("pushButton_2")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.pushButton.clicked.connect(self.delete)
self.pushButton_2.clicked.connect(self.HOME)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.lineEdit.setPlaceholderText(_translate("MainWindow", "Enter Product ID here"))
self.pushButton.setText(_translate("MainWindow", "DELETE "))
self.pushButton_2.setText(_translate("MainWindow", "HOME "))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_delete()
# window = Window()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())