<gh_stars>0
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'username.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# 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
from PyQt5.QtWidgets import QMessageBox
import sqlite3
import welcome
from welcome import Widget


class Ui_Form(object):

    def __init__(self):
        self.count = 0
        self.all_users = set()

    def showDialog(self, title, message):  # message box
        msgBox = QMessageBox()
        msgBox.setIcon(QMessageBox.Information)
        msgBox.setText(message)
        msgBox.setWindowTitle(title)
        msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
        msgBox.exec()

    def func_for_username(self):
        users = {}
        hosp = sqlite3.connect('hospital_data.db')
        curs = hosp.cursor()
        curs.execute('Select * from Employee')
        rows = curs.fetchall()
        for row in rows:
            users[row[0]] = row[1]
        if self.username_text.text().lower() in users.keys() and self.username_text.text() != '' and self.pass_text.text() != '':
            if self.pass_text.text() == users[self.username_text.text().lower()]:
                self.window = Widget()
                self.ui = welcome.Widget()
                # self.ui.setupUi(self.window)
                self.window.show()
                self.username_text.setText('')
                self.pass_text.setText('')
            else:
                self.count += 1
                if self.count <= 2:
                    self.showDialog('ERROR', 'Please enter the correct password')
                    self.pass_text.setText('')
                elif self.count > 2:
                    self.showDialog('ERROR', 'You have reached your limit')
                    quit()
        elif self.username_text.text() == '' or self.pass_text.text() == '':
            self.showDialog('ERROR', 'Please fill the credentials!!')
        else:
            self.username_text.setText('')
            self.pass_text.setText('')
            self.showDialog('ERROR', 'No such user exists""\n Please enter a valid username')

    def func_for_register(self):
        import smtplib
        import random
        dlg = QMessageBox()
        dlg.setWindowTitle('NOTE')
        dlg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
        dlg.setText(' You need to get the One time password in order to continue!!!')
        value = dlg.exec_()
        if value == 1024:
            try:
                self.loading_screen = LoadingScreen()
                self.showDialog('Wait', 'Processing...\n\n\n\n\n\nPress Ok')

                s = smtplib.SMTP('smtp.gmail.com', 587)
                s.starttls()
                s.login("Your mail id", "Your password")
                OTP = random.randint(1000, 9999)
                message = f"Your One type Verification code is {OTP}"
                s.sendmail("Your mail id", "Reciever's  mail id", message)
                s.quit()
                while (True):
                    one_time_pass, ok = QtWidgets.QInputDialog.getText(MainWindow, "OTP",
                                                                       "Please enter the OTP in order to continue:")
                    if ok == True:
                        if int(one_time_pass) == OTP:
                            while (True):
                                if ok == True:
                                    user_id, ok = QtWidgets.QInputDialog.getText(MainWindow, "USER ID",
                                                                                 "Please enter the ID:")
                                    self.all_users.clear()
                                    hosp = sqlite3.connect('hospital_data.db')
                                    curs = hosp.cursor()
                                    curs.execute('Select * from Employee')
                                    rows = curs.fetchall()
                                    for row in rows:
                                        self.all_users.add(row[0])
                                    if user_id.strip().lower() not in self.all_users:
                                        break
                                    else:
                                        self.showDialog('ERROR',
                                                        'The User Id already exists!!!\n Please create account with different ID')
                                else:
                                    break
                            if ok == True:
                                password, ok = QtWidgets.QInputDialog.getText(MainWindow, "PASSWORD",
                                                                              "Please enter the Password:")
                                if ok == True:
                                    hosp = sqlite3.connect('hospital_data.db')
                                    curs = hosp.cursor()
                                    curs.execute(
                                        f"Insert into Employee Values('{user_id.strip().lower()}','{password}')")
                                    hosp.commit()
                                    self.showDialog('SUCCESS',
                                                    'Sucessfuly created you account\n Now you can login to the Hospital')
                                    self.username_text.setText('')
                                    self.pass_text.setText('')
                                    break
                                else:
                                    break
                            else:
                                break
                        else:
                            self.showDialog('ERROR', 'Wrong Password')
                    else:
                        break
            except:
                self.showDialog('ERROR', 'Please check your network connectivity and try again after sometime!!!')

    def func_for_forgot(self):
        import smtplib
        import random
        dlg = QMessageBox()
        dlg.setWindowTitle('NOTE')
        dlg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
        dlg.setText(' You need to get the One time password in order to continue!!!')
        value = dlg.exec_()
        if value == 1024:
            try:
                self.loading_screen = LoadingScreen()
                self.showDialog('Wait', 'Processing...\n\n\n\n\n\nPress Ok')

                s = smtplib.SMTP('smtp.gmail.com', 587)
                s.starttls()
                s.login("Your mail id", "Your passsword")
                OTP = random.randint(1000, 9999)
                message = f"Your One type Verification code is {OTP}"
                s.sendmail("Your mail id", "Reciever's mail id", message)
                s.quit()
                while (True):
                    one_time_pass, ok = QtWidgets.QInputDialog.getText(MainWindow, "OTP",
                                                                       "Please enter the OTP in order to continue:")
                    if ok == True:
                        if int(one_time_pass) == OTP:
                            self.ids = set()
                            self.ids.clear()
                            hosp = sqlite3.connect('hospital_data.db')
                            curs = hosp.cursor()
                            curs.execute(f"Select [User Name] from Employee")
                            rows = curs.fetchall()
                            for row in rows:
                                self.ids.add(row[0])
                            while (True):
                                user_id, ok = QtWidgets.QInputDialog.getText(MainWindow, "ID",
                                                                             "Please enter your ID to continue:")
                                if ok == True:
                                    if user_id.lower() in self.ids:
                                        password, ok = QtWidgets.QInputDialog.getText(MainWindow, "PASSWORD",
                                                                                      "Please enter the new password:")
                                        curs.execute(
                                            f"Update Employee Set Password='{password}' where [User Name]='{user_id.lower()}'")
                                        hosp.commit()
                                        break
                                    else:
                                        self.showDialog('ERROR',
                                                        'No such User exists!!!\n Please Enter a valid Username')
                                elif ok != True:
                                    break
                            break
                        elif ok != True:
                            break
                        else:
                            self.showDialog('ERROR', 'Wrong OTP!!!\n Please enter the correct OTP')
                    else:
                        break

            except:
                self.showDialog('ERROR','Please check your network connectivity and try again after sometime!!!')


    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(496, 309)
        self.gridLayout_7 = QtWidgets.QGridLayout(Form)
        self.gridLayout_7.setContentsMargins(6, 6, 6, 6)
        self.gridLayout_7.setHorizontalSpacing(0)
        self.gridLayout_7.setVerticalSpacing(6)
        self.gridLayout_7.setObjectName("gridLayout_7")
        self.frame = QtWidgets.QFrame(Form)
        self.frame.setStyleSheet("background-image: url(:/resources/icons/w14.jpg) 0 0 0 0 stretch stretch no-repeat;\n"
                                 "border:2px;\n"
                                 "border-radius:30px;\n"
                                 "")
        self.frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.frame)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setContentsMargins(1, 3, 5, -1)
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.btn_minimize_3 = QtWidgets.QPushButton(self.frame)
        self.btn_minimize_3.setMinimumSize(QtCore.QSize(16, 16))
        self.btn_minimize_3.setMaximumSize(QtCore.QSize(17, 17))
        self.btn_minimize_3.setStyleSheet("QPushButton {\n"
                                          "    border: none;\n"
                                          "    border-radius: 8px;        \n"
                                          "    background: rgb(192, 191, 188);\n"
                                          "}\n"
                                          "QPushButton:hover {    \n"
                                          "    background-color: rgba(255, 170, 0, 150);\n"
                                          "}")
        self.btn_minimize_3.setText("")
        self.btn_minimize_3.setObjectName("btn_minimize_3")
        self.horizontalLayout.addWidget(self.btn_minimize_3)
        self.btn_close_3 = QtWidgets.QPushButton(self.frame)
        self.btn_close_3.setMinimumSize(QtCore.QSize(16, 16))
        self.btn_close_3.setMaximumSize(QtCore.QSize(17, 17))
        self.btn_close_3.setStyleSheet("QPushButton {\n"
                                       "    border: none;\n"
                                       "    border-radius: 8px;        \n"
                                       "    background: rgb(255, 0, 0);\n"
                                       "}\n"
                                       "QPushButton:hover {        \n"
                                       "    background-color: rgba(255, 0, 0, 150);\n"
                                       "}")
        self.btn_close_3.setText("")
        self.btn_close_3.setObjectName("btn_close_3")
        self.horizontalLayout.addWidget(self.btn_close_3)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.frame_2 = QtWidgets.QFrame(self.frame)
        self.frame_2.setStyleSheet("background: rgba(191, 64, 64, 0);")
        self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_2.setObjectName("frame_2")
        self.gridLayout_5 = QtWidgets.QGridLayout(self.frame_2)
        self.gridLayout_5.setContentsMargins(3, 0, 5, 3)
        self.gridLayout_5.setHorizontalSpacing(5)
        self.gridLayout_5.setVerticalSpacing(6)
        self.gridLayout_5.setObjectName("gridLayout_5")
        self.gridLayout_6 = QtWidgets.QGridLayout()
        self.gridLayout_6.setObjectName("gridLayout_6")
        self.username_text = QtWidgets.QLineEdit(self.frame_2)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        self.username_text.setFont(font)
        self.username_text.setStyleSheet("background: rgb(246, 245, 244);")
        self.username_text.setObjectName("username_text")
        self.gridLayout_6.addWidget(self.username_text, 0, 0, 1, 1)
        self.pass_text = QtWidgets.QLineEdit(self.frame_2)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        self.pass_text.setFont(font)
        self.pass_text.setStyleSheet("background: rgb(246, 245, 244);")
        self.pass_text.setEchoMode(QtWidgets.QLineEdit.Password)
        self.pass_text.setObjectName("pass_text")
        self.gridLayout_6.addWidget(self.pass_text, 1, 0, 1, 1)
        self.gridLayout_5.addLayout(self.gridLayout_6, 0, 2, 1, 1)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_5.addItem(spacerItem1, 0, 3, 1, 1)
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.gridLayout_5.addLayout(self.gridLayout, 0, 1, 1, 1)
        self.frame_6 = QtWidgets.QFrame(self.frame_2)
        self.frame_6.setStyleSheet("background: rgba(191, 64, 64, 0);")
        self.frame_6.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_6.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_6.setObjectName("frame_6")
        self.gridLayout_8 = QtWidgets.QGridLayout(self.frame_6)
        self.gridLayout_8.setObjectName("gridLayout_8")
        self.frame_5 = QtWidgets.QFrame(self.frame_6)
        self.frame_5.setMinimumSize(QtCore.QSize(0, 0))
        self.frame_5.setStyleSheet("background: rgba(191, 64, 64, 0);")
        self.frame_5.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame_5.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_5.setObjectName("frame_5")
        self.gridLayout_4 = QtWidgets.QGridLayout(self.frame_5)
        self.gridLayout_4.setContentsMargins(6, 6, 6, 6)
        self.gridLayout_4.setVerticalSpacing(6)
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.pass_label = QtWidgets.QLabel(self.frame_5)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        font.setBold(False)
        font.setWeight(50)
        self.pass_label.setFont(font)
        self.pass_label.setStyleSheet("background: rgb(61, 56, 70);\n"
                                      "color: rgb(254, 255, 150);")
        self.pass_label.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.pass_label.setObjectName("pass_label")
        self.gridLayout_4.addWidget(self.pass_label, 0, 0, 1, 1)
        self.gridLayout_8.addWidget(self.frame_5, 1, 0, 1, 1)
        self.username_label = QtWidgets.QLabel(self.frame_6)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        font.setBold(False)
        font.setWeight(50)
        font.setStyleStrategy(QtGui.QFont.PreferDefault)
        self.username_label.setFont(font)
        self.username_label.setStyleSheet("background: rgb(61, 56, 70);\n"
                                          "color: rgb(254, 255, 150);\n"
                                          "")
        self.username_label.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.username_label.setLineWidth(1)
        self.username_label.setMidLineWidth(1)
        self.username_label.setTextFormat(QtCore.Qt.AutoText)
        self.username_label.setScaledContents(False)
        self.username_label.setWordWrap(False)
        self.username_label.setIndent(-1)
        self.username_label.setObjectName("username_label")
        self.gridLayout_8.addWidget(self.username_label, 0, 0, 1, 1)
        self.gridLayout_5.addWidget(self.frame_6, 0, 0, 1, 1)
        self.verticalLayout.addWidget(self.frame_2)
        self.frame_4 = QtWidgets.QFrame(self.frame)
        self.frame_4.setStyleSheet("background: rgba(191, 64, 64, 0);")
        self.frame_4.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame_4.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_4.setObjectName("frame_4")
        self.gridLayout_3 = QtWidgets.QGridLayout(self.frame_4)
        self.gridLayout_3.setContentsMargins(3, 9, 7, 2)
        self.gridLayout_3.setHorizontalSpacing(7)
        self.gridLayout_3.setVerticalSpacing(8)
        self.gridLayout_3.setObjectName("gridLayout_3")
        spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_3.addItem(spacerItem2, 0, 0, 1, 1)
        self.submit_btn = QtWidgets.QPushButton(self.frame_4)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(12)
        self.submit_btn.setFont(font)
        self.submit_btn.setStyleSheet("background: rgb(61, 56, 70);\n"
                                      "color: rgb(254, 255, 150);\n"
                                      "height:30px;\n"
                                      "width:80px;\n"
                                      "border:2px;\n"
                                      "border-radius:30px;")
        self.submit_btn.setObjectName("submit_btn")
        self.gridLayout_3.addWidget(self.submit_btn, 0, 1, 1, 1)
        spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_3.addItem(spacerItem3, 0, 2, 1, 1)
        self.verticalLayout.addWidget(self.frame_4)
        self.frame_3 = QtWidgets.QFrame(self.frame)
        self.frame_3.setStyleSheet("background: rgba(191, 64, 64, 0);")
        self.frame_3.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_3.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_3.setObjectName("frame_3")
        self.gridLayout_2 = QtWidgets.QGridLayout(self.frame_3)
        self.gridLayout_2.setContentsMargins(6, 5, -1, -1)
        self.gridLayout_2.setObjectName("gridLayout_2")
        spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_2.addItem(spacerItem4, 1, 0, 1, 1)
        self.register_2 = QtWidgets.QCommandLinkButton(self.frame_3)
        self.register_2.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.register_2.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.register_2.setStyleSheet("background: rgb(61, 56, 70);\n"
                                      "color: rgb(254, 255, 150);")
        self.register_2.setIconSize(QtCore.QSize(0, 0))
        self.register_2.setObjectName("register_2")
        self.gridLayout_2.addWidget(self.register_2, 1, 2, 1, 1)
        spacerItem5 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.gridLayout_2.addItem(spacerItem5, 2, 1, 1, 1)
        spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_2.addItem(spacerItem6, 1, 3, 1, 1)
        self.forgot_pass = QtWidgets.QCommandLinkButton(self.frame_3)
        self.forgot_pass.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.forgot_pass.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.forgot_pass.setStyleSheet("QPushButton{background: rgb(61, 56, 70);\n"
                                       "color: rgb(254, 255, 150);\n"
                                       "font-size:12px;}")
        self.forgot_pass.setIconSize(QtCore.QSize(0, 0))
        self.forgot_pass.setObjectName("forgot_pass")
        self.gridLayout_2.addWidget(self.forgot_pass, 1, 1, 1, 1)
        spacerItem7 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.gridLayout_2.addItem(spacerItem7, 0, 2, 1, 1)
        self.verticalLayout.addWidget(self.frame_3)
        self.gridLayout_7.addWidget(self.frame, 0, 1, 1, 1)

        self.submit_btn.clicked.connect(self.func_for_username)
        self.submit_btn.setShortcut('Ctrl+Return')
        self.forgot_pass.clicked.connect(self.func_for_forgot)
        self.register_2.clicked.connect(self.func_for_register)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.btn_minimize_3.setToolTip(_translate("Form", "Minimize"))
        self.btn_close_3.setToolTip(_translate("Form", "Close"))
        self.pass_label.setText(_translate("Form", " Enter your Password:    "))
        self.username_label.setText(_translate("Form", " Enter your User Name:  "))
        self.submit_btn.setText(_translate("Form", "Submit"))
        self.register_2.setText(_translate("Form", "      Register"))
        self.forgot_pass.setText(_translate("Form", "Forgot Your Password"))


if __name__ == "__main__":
    import sys
    welcome.app
    MainWindow = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(welcome.app.exec_())

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'username.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# 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
from PyQt5.QtWidgets import QMessageBox
import sqlite3
import welcome
from welcome import Widget


class Ui_Form(object):

    def __init__(self):
        self.count = 0
        self.all_users = set()

    def showDialog(self, title, message):  # message box
        msgBox = QMessageBox()
        msgBox.setIcon(QMessageBox.Information)
        msgBox.setText(message)
        msgBox.setWindowTitle(title)
        msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
        msgBox.exec()

    def func_for_username(self):
        users = {}
        hosp = sqlite3.connect('hospital_data.db')
        curs = hosp.cursor()
        curs.execute('Select * from Employee')
        rows = curs.fetchall()
        for row in rows:
            users[row[0]] = row[1]
        if self.username_text.text().lower() in users.keys() and self.username_text.text() != '' and self.pass_text.text() != '':
            if self.pass_text.text() == users[self.username_text.text().lower()]:
                self.window = Widget()
                self.ui = welcome.Widget()
                # self.ui.setupUi(self.window)
                self.window.show()
                self.username_text.setText('')
                self.pass_text.setText('')
            else:
                self.count += 1
                if self.count <= 2:
                    self.showDialog('ERROR', 'Please enter the correct password')
                    self.pass_text.setText('')
                elif self.count > 2:
                    self.showDialog('ERROR', 'You have reached your limit')
                    quit()
        elif self.username_text.text() == '' or self.pass_text.text() == '':
            self.showDialog('ERROR', 'Please fill the credentials!!')
        else:
            self.username_text.setText('')
            self.pass_text.setText('')
            self.showDialog('ERROR', 'No such user exists""\n Please enter a valid username')

    def func_for_register(self):
        import smtplib
        import random
        dlg = QMessageBox()
        dlg.setWindowTitle('NOTE')
        dlg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
        dlg.setText(' You need to get the One time password in order to continue!!!')
        value = dlg.exec_()
        if value == 1024:
            try:
                self.loading_screen = LoadingScreen()
                self.showDialog('Wait', 'Processing...\n\n\n\n\n\nPress Ok')

                s = smtplib.SMTP('smtp.gmail.com', 587)
                s.starttls()
                s.login("Your mail id", "Your password")
                OTP = random.randint(1000, 9999)
                message = f"Your One type Verification code is {OTP}"
                s.sendmail("Your mail id", "Reciever's  mail id", message)
                s.quit()
                while (True):
                    one_time_pass, ok = QtWidgets.QInputDialog.getText(MainWindow, "OTP",
                                                                       "Please enter the OTP in order to continue:")
                    if ok == True:
                        if int(one_time_pass) == OTP:
                            while (True):
                                if ok == True:
                                    user_id, ok = QtWidgets.QInputDialog.getText(MainWindow, "USER ID",
                                                                                 "Please enter the ID:")
                                    self.all_users.clear()
                                    hosp = sqlite3.connect('hospital_data.db')
                                    curs = hosp.cursor()
                                    curs.execute('Select * from Employee')
                                    rows = curs.fetchall()
                                    for row in rows:
                                        self.all_users.add(row[0])
                                    if user_id.strip().lower() not in self.all_users:
                                        break
                                    else:
                                        self.showDialog('ERROR',
                                                        'The User Id already exists!!!\n Please create account with different ID')
                                else:
                                    break
                            if ok == True:
                                password, ok = QtWidgets.QInputDialog.getText(MainWindow, "PASSWORD",
                                                                              "Please enter the Password:")
                                if ok == True:
                                    hosp = sqlite3.connect('hospital_data.db')
                                    curs = hosp.cursor()
                                    curs.execute(
                                        f"Insert into Employee Values('{user_id.strip().lower()}','{password}')")
                                    hosp.commit()
                                    self.showDialog('SUCCESS',
                                                    'Sucessfuly created you account\n Now you can login to the Hospital')
                                    self.username_text.setText('')
                                    self.pass_text.setText('')
                                    break
                                else:
                                    break
                            else:
                                break
                        else:
                            self.showDialog('ERROR', 'Wrong Password')
                    else:
                        break
            except:
                self.showDialog('ERROR', 'Please check your network connectivity and try again after sometime!!!')

    def func_for_forgot(self):
        import smtplib
        import random
        dlg = QMessageBox()
        dlg.setWindowTitle('NOTE')
        dlg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
        dlg.setText(' You need to get the One time password in order to continue!!!')
        value = dlg.exec_()
        if value == 1024:
            try:
                self.loading_screen = LoadingScreen()
                self.showDialog('Wait', 'Processing...\n\n\n\n\n\nPress Ok')

                s = smtplib.SMTP('smtp.gmail.com', 587)
                s.starttls()
                s.login("Your mail id", "Your passsword")
                OTP = random.randint(1000, 9999)
                message = f"Your One type Verification code is {OTP}"
                s.sendmail("Your mail id", "Reciever's mail id", message)
                s.quit()
                while (True):
                    one_time_pass, ok = QtWidgets.QInputDialog.getText(MainWindow, "OTP",
                                                                       "Please enter the OTP in order to continue:")
                    if ok == True:
                        if int(one_time_pass) == OTP:
                            self.ids = set()
                            self.ids.clear()
                            hosp = sqlite3.connect('hospital_data.db')
                            curs = hosp.cursor()
                            curs.execute(f"Select [User Name] from Employee")
                            rows = curs.fetchall()
                            for row in rows:
                                self.ids.add(row[0])
                            while (True):
                                user_id, ok = QtWidgets.QInputDialog.getText(MainWindow, "ID",
                                                                             "Please enter your ID to continue:")
                                if ok == True:
                                    if user_id.lower() in self.ids:
                                        password, ok = QtWidgets.QInputDialog.getText(MainWindow, "PASSWORD",
                                                                                      "Please enter the new password:")
                                        curs.execute(
                                            f"Update Employee Set Password='{password}' where [User Name]='{user_id.lower()}'")
                                        hosp.commit()
                                        break
                                    else:
                                        self.showDialog('ERROR',
                                                        'No such User exists!!!\n Please Enter a valid Username')
                                elif ok != True:
                                    break
                            break
                        elif ok != True:
                            break
                        else:
                            self.showDialog('ERROR', 'Wrong OTP!!!\n Please enter the correct OTP')
                    else:
                        break

            except:
                self.showDialog('ERROR','Please check your network connectivity and try again after sometime!!!')


    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(496, 309)
        self.gridLayout_7 = QtWidgets.QGridLayout(Form)
        self.gridLayout_7.setContentsMargins(6, 6, 6, 6)
        self.gridLayout_7.setHorizontalSpacing(0)
        self.gridLayout_7.setVerticalSpacing(6)
        self.gridLayout_7.setObjectName("gridLayout_7")
        self.frame = QtWidgets.QFrame(Form)
        self.frame.setStyleSheet("background-image: url(:/resources/icons/w14.jpg) 0 0 0 0 stretch stretch no-repeat;\n"
                                 "border:2px;\n"
                                 "border-radius:30px;\n"
                                 "")
        self.frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.frame)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setContentsMargins(1, 3, 5, -1)
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.btn_minimize_3 = QtWidgets.QPushButton(self.frame)
        self.btn_minimize_3.setMinimumSize(QtCore.QSize(16, 16))
        self.btn_minimize_3.setMaximumSize(QtCore.QSize(17, 17))
        self.btn_minimize_3.setStyleSheet("QPushButton {\n"
                                          "    border: none;\n"
                                          "    border-radius: 8px;        \n"
                                          "    background: rgb(192, 191, 188);\n"
                                          "}\n"
                                          "QPushButton:hover {    \n"
                                          "    background-color: rgba(255, 170, 0, 150);\n"
                                          "}")
        self.btn_minimize_3.setText("")
        self.btn_minimize_3.setObjectName("btn_minimize_3")
        self.horizontalLayout.addWidget(self.btn_minimize_3)
        self.btn_close_3 = QtWidgets.QPushButton(self.frame)
        self.btn_close_3.setMinimumSize(QtCore.QSize(16, 16))
        self.btn_close_3.setMaximumSize(QtCore.QSize(17, 17))
        self.btn_close_3.setStyleSheet("QPushButton {\n"
                                       "    border: none;\n"
                                       "    border-radius: 8px;        \n"
                                       "    background: rgb(255, 0, 0);\n"
                                       "}\n"
                                       "QPushButton:hover {        \n"
                                       "    background-color: rgba(255, 0, 0, 150);\n"
                                       "}")
        self.btn_close_3.setText("")
        self.btn_close_3.setObjectName("btn_close_3")
        self.horizontalLayout.addWidget(self.btn_close_3)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.frame_2 = QtWidgets.QFrame(self.frame)
        self.frame_2.setStyleSheet("background: rgba(191, 64, 64, 0);")
        self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_2.setObjectName("frame_2")
        self.gridLayout_5 = QtWidgets.QGridLayout(self.frame_2)
        self.gridLayout_5.setContentsMargins(3, 0, 5, 3)
        self.gridLayout_5.setHorizontalSpacing(5)
        self.gridLayout_5.setVerticalSpacing(6)
        self.gridLayout_5.setObjectName("gridLayout_5")
        self.gridLayout_6 = QtWidgets.QGridLayout()
        self.gridLayout_6.setObjectName("gridLayout_6")
        self.username_text = QtWidgets.QLineEdit(self.frame_2)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        self.username_text.setFont(font)
        self.username_text.setStyleSheet("background: rgb(246, 245, 244);")
        self.username_text.setObjectName("username_text")
        self.gridLayout_6.addWidget(self.username_text, 0, 0, 1, 1)
        self.pass_text = QtWidgets.QLineEdit(self.frame_2)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        self.pass_text.setFont(font)
        self.pass_text.setStyleSheet("background: rgb(246, 245, 244);")
        self.pass_text.setEchoMode(QtWidgets.QLineEdit.Password)
        self.pass_text.setObjectName("pass_text")
        self.gridLayout_6.addWidget(self.pass_text, 1, 0, 1, 1)
        self.gridLayout_5.addLayout(self.gridLayout_6, 0, 2, 1, 1)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_5.addItem(spacerItem1, 0, 3, 1, 1)
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.gridLayout_5.addLayout(self.gridLayout, 0, 1, 1, 1)
        self.frame_6 = QtWidgets.QFrame(self.frame_2)
        self.frame_6.setStyleSheet("background: rgba(191, 64, 64, 0);")
        self.frame_6.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_6.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_6.setObjectName("frame_6")
        self.gridLayout_8 = QtWidgets.QGridLayout(self.frame_6)
        self.gridLayout_8.setObjectName("gridLayout_8")
        self.frame_5 = QtWidgets.QFrame(self.frame_6)
        self.frame_5.setMinimumSize(QtCore.QSize(0, 0))
        self.frame_5.setStyleSheet("background: rgba(191, 64, 64, 0);")
        self.frame_5.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame_5.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_5.setObjectName("frame_5")
        self.gridLayout_4 = QtWidgets.QGridLayout(self.frame_5)
        self.gridLayout_4.setContentsMargins(6, 6, 6, 6)
        self.gridLayout_4.setVerticalSpacing(6)
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.pass_label = QtWidgets.QLabel(self.frame_5)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        font.setBold(False)
        font.setWeight(50)
        self.pass_label.setFont(font)
        self.pass_label.setStyleSheet("background: rgb(61, 56, 70);\n"
                                      "color: rgb(254, 255, 150);")
        self.pass_label.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.pass_label.setObjectName("pass_label")
        self.gridLayout_4.addWidget(self.pass_label, 0, 0, 1, 1)
        self.gridLayout_8.addWidget(self.frame_5, 1, 0, 1, 1)
        self.username_label = QtWidgets.QLabel(self.frame_6)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        font.setBold(False)
        font.setWeight(50)
        font.setStyleStrategy(QtGui.QFont.PreferDefault)
        self.username_label.setFont(font)
        self.username_label.setStyleSheet("background: rgb(61, 56, 70);\n"
                                          "color: rgb(254, 255, 150);\n"
                                          "")
        self.username_label.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.username_label.setLineWidth(1)
        self.username_label.setMidLineWidth(1)
        self.username_label.setTextFormat(QtCore.Qt.AutoText)
        self.username_label.setScaledContents(False)
        self.username_label.setWordWrap(False)
        self.username_label.setIndent(-1)
        self.username_label.setObjectName("username_label")
        self.gridLayout_8.addWidget(self.username_label, 0, 0, 1, 1)
        self.gridLayout_5.addWidget(self.frame_6, 0, 0, 1, 1)
        self.verticalLayout.addWidget(self.frame_2)
        self.frame_4 = QtWidgets.QFrame(self.frame)
        self.frame_4.setStyleSheet("background: rgba(191, 64, 64, 0);")
        self.frame_4.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame_4.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_4.setObjectName("frame_4")
        self.gridLayout_3 = QtWidgets.QGridLayout(self.frame_4)
        self.gridLayout_3.setContentsMargins(3, 9, 7, 2)
        self.gridLayout_3.setHorizontalSpacing(7)
        self.gridLayout_3.setVerticalSpacing(8)
        self.gridLayout_3.setObjectName("gridLayout_3")
        spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_3.addItem(spacerItem2, 0, 0, 1, 1)
        self.submit_btn = QtWidgets.QPushButton(self.frame_4)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(12)
        self.submit_btn.setFont(font)
        self.submit_btn.setStyleSheet("background: rgb(61, 56, 70);\n"
                                      "color: rgb(254, 255, 150);\n"
                                      "height:30px;\n"
                                      "width:80px;\n"
                                      "border:2px;\n"
                                      "border-radius:30px;")
        self.submit_btn.setObjectName("submit_btn")
        self.gridLayout_3.addWidget(self.submit_btn, 0, 1, 1, 1)
        spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_3.addItem(spacerItem3, 0, 2, 1, 1)
        self.verticalLayout.addWidget(self.frame_4)
        self.frame_3 = QtWidgets.QFrame(self.frame)
        self.frame_3.setStyleSheet("background: rgba(191, 64, 64, 0);")
        self.frame_3.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_3.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_3.setObjectName("frame_3")
        self.gridLayout_2 = QtWidgets.QGridLayout(self.frame_3)
        self.gridLayout_2.setContentsMargins(6, 5, -1, -1)
        self.gridLayout_2.setObjectName("gridLayout_2")
        spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_2.addItem(spacerItem4, 1, 0, 1, 1)
        self.register_2 = QtWidgets.QCommandLinkButton(self.frame_3)
        self.register_2.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.register_2.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.register_2.setStyleSheet("background: rgb(61, 56, 70);\n"
                                      "color: rgb(254, 255, 150);")
        self.register_2.setIconSize(QtCore.QSize(0, 0))
        self.register_2.setObjectName("register_2")
        self.gridLayout_2.addWidget(self.register_2, 1, 2, 1, 1)
        spacerItem5 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.gridLayout_2.addItem(spacerItem5, 2, 1, 1, 1)
        spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_2.addItem(spacerItem6, 1, 3, 1, 1)
        self.forgot_pass = QtWidgets.QCommandLinkButton(self.frame_3)
        self.forgot_pass.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.forgot_pass.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.forgot_pass.setStyleSheet("QPushButton{background: rgb(61, 56, 70);\n"
                                       "color: rgb(254, 255, 150);\n"
                                       "font-size:12px;}")
        self.forgot_pass.setIconSize(QtCore.QSize(0, 0))
        self.forgot_pass.setObjectName("forgot_pass")
        self.gridLayout_2.addWidget(self.forgot_pass, 1, 1, 1, 1)
        spacerItem7 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.gridLayout_2.addItem(spacerItem7, 0, 2, 1, 1)
        self.verticalLayout.addWidget(self.frame_3)
        self.gridLayout_7.addWidget(self.frame, 0, 1, 1, 1)

        self.submit_btn.clicked.connect(self.func_for_username)
        self.submit_btn.setShortcut('Ctrl+Return')
        self.forgot_pass.clicked.connect(self.func_for_forgot)
        self.register_2.clicked.connect(self.func_for_register)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.btn_minimize_3.setToolTip(_translate("Form", "Minimize"))
        self.btn_close_3.setToolTip(_translate("Form", "Close"))
        self.pass_label.setText(_translate("Form", " Enter your Password:    "))
        self.username_label.setText(_translate("Form", " Enter your User Name:  "))
        self.submit_btn.setText(_translate("Form", "Submit"))
        self.register_2.setText(_translate("Form", "      Register"))
        self.forgot_pass.setText(_translate("Form", "Forgot Your Password"))


if __name__ == "__main__":
    import sys
    welcome.app
    MainWindow = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(welcome.app.exec_())
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'username.ui' # # Created by: PyQt5 UI code generator 5.15.4 # # 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. # message box # self.ui.setupUi(self.window)