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

# Form implementation generated from reading ui file 'cricket_game.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# 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.

import sqlite3
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMessageBox, QInputDialog, QWidget, QListWidget, QDialog
from EvaluateDialog import Ui_Dialog

Cricket = sqlite3.connect("Cricket_Players_Database.db")

class Ui_MainWindow(QtWidgets.QWidget):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1500, 900)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        icon0 = QtGui.QIcon()
        icon0.addPixmap(QtGui.QPixmap("Images/logo.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon0)
        MainWindow.setStyleSheet("QMenuBar{\n"
"color: red;\n"
"font: bold 20px;}\n")
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")
        self.widget = QtWidgets.QWidget(self.centralwidget)
        self.widget.setStyleSheet("QWidget{\n"
"background-color: rgb(214, 214, 214);}")
        self.widget.setObjectName("widget")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.widget)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.label = QtWidgets.QLabel(self.widget)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.verticalLayout_2.addWidget(self.label)
        self.verticalLayout_3.addLayout(self.verticalLayout_2)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label_5 = QtWidgets.QLabel(self.widget)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.horizontalLayout.addWidget(self.label_5)
        self.lineEdit_4 = QtWidgets.QLineEdit(self.widget)
        self.lineEdit_4.setEnabled(False)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.lineEdit_4.setFont(font)
        self.lineEdit_4.setStyleSheet("QLineEdit{\n"
"    color: rgb(0, 85, 255);}")
        self.lineEdit_4.setFrame(False)
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.horizontalLayout.addWidget(self.lineEdit_4)
        self.label_4 = QtWidgets.QLabel(self.widget)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.horizontalLayout.addWidget(self.label_4)
        self.lineEdit_3 = QtWidgets.QLineEdit(self.widget)
        self.lineEdit_3.setEnabled(False)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.lineEdit_3.setFont(font)
        self.lineEdit_3.setStyleSheet("QLineEdit{\n"
"    color: rgb(0, 85, 255);}")
        self.lineEdit_3.setFrame(False)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.horizontalLayout.addWidget(self.lineEdit_3)
        self.label_3 = QtWidgets.QLabel(self.widget)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.horizontalLayout.addWidget(self.label_3)
        self.lineEdit_2 = QtWidgets.QLineEdit(self.widget)
        self.lineEdit_2.setEnabled(False)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.lineEdit_2.setFont(font)
        self.lineEdit_2.setStyleSheet("QLineEdit{\n"
"    color: rgb(0, 85, 255);}")
        self.lineEdit_2.setText("")
        self.lineEdit_2.setFrame(False)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.horizontalLayout.addWidget(self.lineEdit_2)
        self.label_2 = QtWidgets.QLabel(self.widget)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout.addWidget(self.label_2)
        self.lineEdit = QtWidgets.QLineEdit(self.widget)
        self.lineEdit.setEnabled(False)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.lineEdit.setFont(font)
        self.lineEdit.setStyleSheet("QLineEdit{\n"
"    color: rgb(0, 85, 255);}")
        self.lineEdit.setFrame(False)
        self.lineEdit.setObjectName("lineEdit")
        self.horizontalLayout.addWidget(self.lineEdit)
        self.verticalLayout_3.addLayout(self.horizontalLayout)
        self.verticalLayout.addWidget(self.widget)
        self.widget_2 = QtWidgets.QWidget(self.centralwidget)
        self.widget_2.setEnabled(False)
        self.widget_2.setObjectName("widget_2")
        self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.widget_2)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.horizontalLayout_8 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_8.setObjectName("horizontalLayout_8")
        self.label_8 = QtWidgets.QLabel(self.widget_2)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.label_8.setFont(font)
        self.label_8.setObjectName("label_8")
        self.horizontalLayout_8.addWidget(self.label_8)
        self.lineEdit_11 = QtWidgets.QLineEdit(self.widget_2)
        self.lineEdit_11.setEnabled(False)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.lineEdit_11.setFont(font)
        self.lineEdit_11.setStyleSheet("QLineEdit{\n"
"    color: rgb(0, 85, 255);}")
        self.lineEdit_11.setFrame(False)
        self.lineEdit_11.setObjectName("lineEdit_11")
        self.horizontalLayout_8.addWidget(self.lineEdit_11)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_8.addItem(spacerItem)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_8.addItem(spacerItem1)
        spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_8.addItem(spacerItem2)
        spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_8.addItem(spacerItem3)
        self.label_7 = QtWidgets.QLabel(self.widget_2)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.label_7.setFont(font)
        self.label_7.setObjectName("label_7")
        self.horizontalLayout_8.addWidget(self.label_7)
        self.lineEdit_14 = QtWidgets.QLineEdit(self.widget_2)
        self.lineEdit_14.setEnabled(False)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.lineEdit_14.setFont(font)
        self.lineEdit_14.setStyleSheet("QLineEdit{\n"
"    color: rgb(0, 85, 255);}")
        self.lineEdit_14.setFrame(False)
        self.lineEdit_14.setObjectName("lineEdit_14")
        self.horizontalLayout_8.addWidget(self.lineEdit_14)
        spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_8.addItem(spacerItem4)
        self.verticalLayout_4.addLayout(self.horizontalLayout_8)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem5)
        self.radioButton_4 = QtWidgets.QRadioButton(self.widget_2)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.radioButton_4.setFont(font)
        self.radioButton_4.setObjectName("radioButton_4")
        self.horizontalLayout_2.addWidget(self.radioButton_4)
        self.radioButton = QtWidgets.QRadioButton(self.widget_2)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.radioButton.setFont(font)
        self.radioButton.setObjectName("radioButton")
        self.horizontalLayout_2.addWidget(self.radioButton)
        self.radioButton_2 = QtWidgets.QRadioButton(self.widget_2)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.radioButton_2.setFont(font)
        self.radioButton_2.setObjectName("radioButton_2")
        self.horizontalLayout_2.addWidget(self.radioButton_2)
        self.radioButton_3 = QtWidgets.QRadioButton(self.widget_2)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.radioButton_3.setFont(font)
        self.radioButton_3.setObjectName("radioButton_3")
        self.horizontalLayout_2.addWidget(self.radioButton_3)
        spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem6)
        spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem7)
        spacerItem8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem8)
        spacerItem9 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem9)
        spacerItem10 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem10)
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        spacerItem11 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_4.addItem(spacerItem11)
        self.label_6 = QtWidgets.QLabel(self.widget_2)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.horizontalLayout_4.addWidget(self.label_6)
        self.lineEdit_5 = QtWidgets.QLineEdit(self.widget_2)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.lineEdit_5.setFont(font)
        self.lineEdit_5.setStyleSheet("QLineEdit{\n"
"    color: rgb(0, 85, 255);}")
        self.lineEdit_5.setFrame(False)
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.horizontalLayout_4.addWidget(self.lineEdit_5)
        spacerItem12 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_4.addItem(spacerItem12)
        spacerItem13 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_4.addItem(spacerItem13)
        self.horizontalLayout_2.addLayout(self.horizontalLayout_4)
        self.verticalLayout_4.addLayout(self.horizontalLayout_2)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.listWidget = QtWidgets.QListWidget(self.widget_2)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        self.listWidget.setFont(font)
        self.listWidget.setObjectName("listWidget")
        self.horizontalLayout_3.addWidget(self.listWidget)
        spacerItem14 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem14)
        self.listWidget_2 = QtWidgets.QListWidget(self.widget_2)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        self.listWidget_2.setFont(font)
        self.listWidget_2.setObjectName("listWidget_2")
        self.horizontalLayout_3.addWidget(self.listWidget_2)
        self.verticalLayout_4.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_9 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_9.setObjectName("horizontalLayout_9")
        spacerItem15 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_9.addItem(spacerItem15)
        self.label_10 = QtWidgets.QLabel(self.widget_2)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        self.label_10.setFont(font)
        self.label_10.setObjectName("label_10")
        self.horizontalLayout_9.addWidget(self.label_10)
        self.horizontalLayout_10 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_10.setObjectName("horizontalLayout_10")
        self.horizontalLayout_9.addLayout(self.horizontalLayout_10)
        spacerItem16 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_9.addItem(spacerItem16)
        spacerItem17 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_9.addItem(spacerItem17)
        spacerItem18 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_9.addItem(spacerItem18)
        spacerItem19 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_9.addItem(spacerItem19)
        self.horizontalLayout_11 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_11.setObjectName("horizontalLayout_11")
        self.horizontalLayout_9.addLayout(self.horizontalLayout_11)
        spacerItem20 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_9.addItem(spacerItem20)
        self.label_9 = QtWidgets.QLabel(self.widget_2)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        self.label_9.setFont(font)
        self.label_9.setObjectName("label_9")
        self.horizontalLayout_9.addWidget(self.label_9)
        spacerItem21 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_9.addItem(spacerItem21)
        self.verticalLayout_4.addLayout(self.horizontalLayout_9)
        self.verticalLayout.addWidget(self.widget_2)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        font = QtGui.QFont()
        font.setFamily("Calibri")
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1000, 40))
        self.menubar.setObjectName("menubar")
        self.menuManage_Teams = QtWidgets.QMenu(self.menubar)
        self.menuManage_Teams.setObjectName("menuManage_Teams")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionNew = QtWidgets.QAction(MainWindow)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("Images/new.jpg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionNew.setIcon(icon)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.actionNew.setFont(font)
        self.actionNew.setObjectName("actionNew")
        self.actionOpen = QtWidgets.QAction(MainWindow)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap("Images/open.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionOpen.setIcon(icon1)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.actionOpen.setFont(font)
        self.actionOpen.setObjectName("actionOpen")
        self.actionEdit = QtWidgets.QAction(MainWindow)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap("Images/edit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionEdit.setIcon(icon2)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.actionEdit.setFont(font)
        self.actionEdit.setObjectName("actionEdit")
        self.actionSave = QtWidgets.QAction(MainWindow)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap("Images/save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionSave.setIcon(icon3)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.actionSave.setFont(font)
        self.actionSave.setObjectName("actionsave")
        self.actionEvaluate = QtWidgets.QAction(MainWindow)
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap("Images/evaluate.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionEvaluate.setIcon(icon4)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.actionEvaluate.setFont(font)
        self.actionEvaluate.setObjectName("actionEvaluate")
        self.actionExit = QtWidgets.QAction(MainWindow)
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap("Images/exit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionExit.setIcon(icon5)
        font = QtGui.QFont()
        font.setPointSize(10)
        self.actionExit.setFont(font)
        self.actionExit.setObjectName("actionExit")
        self.menuManage_Teams.addAction(self.actionNew)
        self.menuManage_Teams.addAction(self.actionOpen)
        self.menuManage_Teams.addAction(self.actionEdit)
        self.menuManage_Teams.addAction(self.actionSave)
        self.menuManage_Teams.addAction(self.actionEvaluate)
        self.menuManage_Teams.addAction(self.actionExit)
        self.menubar.addAction(self.menuManage_Teams.menuAction())

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


        self.actionNew.triggered.connect(self.NewDialog)
        self.radioButton_4.toggled.connect(self.Batsman_stats)
        self.radioButton.toggled.connect(self.Bowler_stats)
        self.radioButton_2.toggled.connect(self.AllRounder_stats)
        self.radioButton_3.toggled.connect(self.Wicketkeeper_stats)

        self.listWidget.itemDoubleClicked.connect(self.removelistWidget1)
        self.listWidget_2.itemDoubleClicked.connect(self.removelistWidget2)

        self.actionSave.triggered.connect(self.addingData)
        self.actionOpen.triggered.connect(self.RetreivingData)
        self.actionEdit.triggered.connect(self.EditingData)
        self.actionExit.triggered.connect(self.ExitApp)
        self.actionEvaluate.triggered.connect(self.EvaluateDialog)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Fantasy Cricket game"))
        self.label.setText(_translate("MainWindow", "Your Selections: "))
        self.label_5.setText(_translate("MainWindow", "Batsman (BAT): "))
        self.lineEdit_4.setPlaceholderText(_translate("MainWindow", "##"))
        self.label_4.setText(_translate("MainWindow", "Bowler (Bow): "))
        self.lineEdit_3.setPlaceholderText(_translate("MainWindow", "##"))
        self.label_3.setText(_translate("MainWindow", "All-Rounders (AR): "))
        self.lineEdit_2.setPlaceholderText(_translate("MainWindow", "##"))
        self.label_2.setText(_translate("MainWindow", "Wicket-Keeper (WK): "))
        self.lineEdit.setPlaceholderText(_translate("MainWindow", "##"))
        self.label_8.setText(_translate("MainWindow", "Points Available: "))
        self.lineEdit_11.setPlaceholderText(_translate("MainWindow", "####"))
        self.label_7.setText(_translate("MainWindow", "Points Used: "))
        self.lineEdit_14.setPlaceholderText(_translate("MainWindow", "####"))
        self.radioButton_4.setText(_translate("MainWindow", "BAT"))
        self.radioButton.setText(_translate("MainWindow", "BOWL"))
        self.radioButton_2.setText(_translate("MainWindow", "AR"))
        self.radioButton_3.setText(_translate("MainWindow", "WK"))
        self.label_6.setText(_translate("MainWindow", "Team name:"))
        self.lineEdit_5.setPlaceholderText(_translate("MainWindow", "Displayed Here"))
        self.label_10.setText(_translate("MainWindow", "Available Players"))
        self.label_9.setText(_translate("MainWindow", "Selected Players"))
        self.menuManage_Teams.setTitle(_translate("MainWindow", "MANAGE TEAMS"))
        self.actionNew.setText(_translate("MainWindow", "New "))
        self.actionNew.setShortcut(_translate("MainWindow", "Ctrl+N"))
        self.actionEdit.setText(_translate("MainWindow", "Edit"))
        self.actionEdit.setShortcut(_translate("MainWindow", "Ctrl+E"))
        self.actionOpen.setText(_translate("MainWindow", "Open"))
        self.actionOpen.setShortcut(_translate("MainWindow", "Ctrl+O"))
        self.actionSave.setText(_translate("MainWindow", "Save"))
        self.actionSave.setShortcut(_translate("MainWindow", "Ctrl+S"))
        self.actionEvaluate.setText(_translate("MainWindow", "Evaluate"))
        self.actionEvaluate.setShortcut(_translate("MainWindow", "Ctrl+R"))
        self.actionExit.setText(_translate("MainWindow", "Exit"))
        self.actionExit.setShortcut(_translate("MainWindow", "Alt+X"))

    def NewDialog(self):
        text,result = QInputDialog.getText(self, "New team", "Enter the name of Team:")
        if result == True:
            self.lineEdit_5.setText(str(text))
            self.widget_2.setEnabled(True)
            self.lineEdit_4.setText("0")
            self.lineEdit_3.setText("0")
            self.lineEdit_2.setText("0")
            self.lineEdit.setText("0")
            self.lineEdit_14.setText("0")
            self.lineEdit_11.setText("1000")
            self.listWidget.clear()
            self.listWidget_2.clear()
       
    def Batsman_stats(self):
        self.listWidget.clear()
        c = Cricket.cursor()
        batsman = "SELECT Player from Stats WHERE Category = 'BAT';"
        c.execute(batsman)
        global re1
        re1 = c.fetchall()
        if self.radioButton_4.isChecked() == True:
            items = []
            for x in range(self.listWidget_2.count()):
                items.append(self.listWidget_2.item(x).text())
            for i in re1:
                if i[0] in items:
                    pass
                else:
                    self.listWidget.addItem(i[0])


    def Bowler_stats(self):
        self.listWidget.clear()
        c = Cricket.cursor()
        bowler = "SELECT Player from Stats WHERE Category = 'BWL';"
        c.execute(bowler)
        re2 = c.fetchall()
        if self.radioButton.isChecked() == True:
            items = []
            for x in range(self.listWidget_2.count()):
                items.append(self.listWidget_2.item(x).text())
            for i in re2:
                if i[0] in items:
                    pass
                else:
                    self.listWidget.addItem(i[0])


    def AllRounder_stats(self):
        self.listWidget.clear()
        c = Cricket.cursor()
        ar = "SELECT Player from Stats WHERE Category = 'AR';"
        c.execute(ar)
        re3 = c.fetchall()
        if self.radioButton_2.isChecked() == True:
            items = []
            for x in range(self.listWidget_2.count()):
                items.append(self.listWidget_2.item(x).text())
            for i in re3:
                if i[0] in items:
                    pass
                else:
                    self.listWidget.addItem(i[0])

    def Wicketkeeper_stats(self):
        self.listWidget.clear()
        c = Cricket.cursor()
        wk = "SELECT Player from Stats WHERE Category = 'WK';"
        c.execute(wk)
        re4 = c.fetchall()
        if self.radioButton_3.isChecked() == True:
            items = []
            for x in range(self.listWidget_2.count()):
                items.append(self.listWidget_2.item(x).text())
            for i in re4:
                if i[0] in items:
                    pass
                else:
                    self.listWidget.addItem(i[0])

    def removelistWidget1(self, item):
        c = Cricket.cursor()
        batsman = "SELECT Player from Stats WHERE Category = 'BAT';"
        c.execute(batsman)
        re1 = c.fetchall()
        bowler = "SELECT Player from Stats WHERE Category = 'BWL';"
        c.execute(bowler)
        re2 = c.fetchall()
        ar = "SELECT Player from Stats WHERE Category = 'AR';"
        c.execute(ar)
        re3 = c.fetchall()
        wk = "SELECT Player from Stats WHERE Category = 'WK';"
        c.execute(wk)
        re4 = c.fetchall()
        bts = []
        for i in re1:
            bts.append(i[0])
        bwls = []
        for i in re2:
            bwls.append(i[0])
        ars = []
        for i in re3:
            ars.append(i[0])
        wks = []
        for i in re4:
            wks.append(i[0])
        items = []
        if self.listWidget_2.count() == 0:
            pass
        else:
            for x in range(self.listWidget_2.count()):
                if self.listWidget_2.item(x).text() in bts:
                    items.append("BAT") 
                elif self.listWidget_2.item(x).text() in bwls:
                    items.append("BWL") 
                elif self.listWidget_2.item(x).text() in ars:
                    items.append("AR") 
                elif self.listWidget_2.item(x).text() in wks:
                    items.append("WK") 
        c = Cricket.cursor()
        final = self.lineEdit_14.text()
        self.listWidget.takeItem(self.listWidget.row(item))
        cat = "SELECT * from Stats WHERE Player = '"+item.text()+"';"
        c.execute(cat)
        d = c.fetchall()
        items.append(d[0][6])
        p = items.count("BAT")
        q = items.count("BWL")
        r = items.count("WK")
        s = items.count("AR")
        if p <= 4 and q <= 4 and r <= 1 and s <= 2:
            points = d[0][5]
            ava = int(self.lineEdit_11.text())
            tot = ava - points
            used = int(self.lineEdit_14.text())
            usedtot = points + used
            if usedtot < 1000:
                self.lineEdit_11.setText(str(tot))
                self.lineEdit_14.setText(str(usedtot))
                self.listWidget_2.addItem(item.text())
                if d[0][6] == "BAT":
                    self.lineEdit_4.setText(str(p))
                elif d[0][6] =="BWL":
                    self.lineEdit_3.setText(str(q))
                elif d[0][6] =="WK":
                    self.lineEdit.setText(str(r))
                elif d[0][6] =="AR":
                    self.lineEdit_2.setText(str(s))
            else:
                self.listWidget.addItem(d[0][0])
                self.show_popup1()
        else:
            self.listWidget.addItem(d[0][0])
            self.show_popup()


    def show_popup(self):
        msg = QMessageBox()
        msg.setWindowTitle("Error Message")
        msg.setText("Players Limit Crossed.!")
        msg.setIcon(QMessageBox.Critical)
        msg.setStandardButtons(QMessageBox.Cancel|QMessageBox.Retry|QMessageBox.Ignore)
        msg.setDefaultButton(QMessageBox.Retry)
        msg.setInformativeText("Players number out of range..!")
        x = msg.exec_()
    def show_popup1(self):
        msg = QMessageBox()
        msg.setWindowTitle("Error Message")
        msg.setText("Out of Points...!")
        msg.setIcon(QMessageBox.Warning)
        msg.setStandardButtons(QMessageBox.Cancel|QMessageBox.Retry|QMessageBox.Ignore)
        msg.setDefaultButton(QMessageBox.Retry)
        msg.setDetailedText('''You need to select the Players within points range.
        Please modify your selected players List...:)''')
        x = msg.exec_()

    def removelistWidget2(self, item): 
        self.listWidget_2.takeItem(self.listWidget_2.row(item))
        c = Cricket.cursor()
        avai = self.lineEdit_11.text()
        fi = self.lineEdit_14.text()
        cat = "SELECT * from Stats WHERE Player = '"+item.text()+"';"
        c.execute(cat)
        d = c.fetchall()  
        point = d[0][5]
        dec = int(fi)- point
        if d[0][6] == "BAT":
            num = self.lineEdit_4.text()
            self.lineEdit_4.setText(str(int(num)-1))
        elif d[0][6] =="BWL":
            num = self.lineEdit_3.text()
            self.lineEdit_3.setText(str(int(num)-1))
        elif d[0][6] =="WK":
            num = self.lineEdit.text()
            self.lineEdit.setText(str(int(num)-1))
        elif d[0][6] =="AR":
            num = self.lineEdit_2.text()
            self.lineEdit_2.setText(str(int(num)-1))
        self.listWidget.addItem(item.text())
        self.lineEdit_14.setText(str(dec))
        self.lineEdit_11.setText(str(int(avai)+point))

    def addingData(self):
        c = Cricket.cursor()
        Saved_Teams = "SELECT Name FROM Teams;"
        c.execute(Saved_Teams)
        f = c.fetchall()
        items = []
        for i in f:
            items.append(i[0])
        Team_Name = self.lineEdit_5.text()
        if Team_Name not in items:
            if self.listWidget_2.count() == 11:
                players_list = []
                for x in range(self.listWidget_2.count()):
                    players_list.append(self.listWidget_2.item(x).text())
                c = Cricket.cursor()
                Players_string = ','.join(str(e) for e in players_list)
                points_used = self.lineEdit_14.text()
                points_avail = self.lineEdit_11.text()
                self.Database(Team_Name, Players_string, points_used, points_avail)
                msg = QMessageBox()
                msg.setWindowTitle("Confirm Message")
                msg.setText(" Team Saved Successfully.!")
                msg.setIcon(QMessageBox.Information)
                x = msg.exec_()
            else:
                msg = QMessageBox()
                msg.setWindowTitle("Error Message")
                msg.setText("Players Not Sufficient.!")
                msg.setIcon(QMessageBox.Critical)
                msg.setStandardButtons(QMessageBox.Cancel|QMessageBox.Retry|QMessageBox.Ignore)
                msg.setDefaultButton(QMessageBox.Retry)
                msg.setInformativeText("Players number must be equal to 11..!")
                x = msg.exec_()
        else:
            msg = QMessageBox()
            msg.setWindowTitle("Error Message")
            msg.setText("Team Name is Already Used..!")
            msg.setIcon(QMessageBox.Warning)
            msg.setStandardButtons(QMessageBox.Cancel|QMessageBox.Retry|QMessageBox.Ignore)
            msg.setDefaultButton(QMessageBox.Retry)
            msg.setInformativeText("Please choose different Team name!")
            x = msg.exec_()

    def Database(self, Team_Name, Players_string,points_used,points_avail):
        Cricket2 = sqlite3.connect("Cricket_Players_Database.db")
        cur = Cricket2.cursor()
        cur.execute('''INSERT INTO Teams VALUES(?,?,?,?);''',(Team_Name, Players_string, points_used, points_avail))
        Cricket2.commit()

    def RetreivingData(self):
        self.listWidget_2.clear()
        self.listWidget.clear()
        c = Cricket.cursor()
        Saved_Teams = "SELECT Name FROM Teams;"
        c.execute(Saved_Teams)
        f = c.fetchall()
        items = []
        for i in f:
            items.append(i[0])
        if items != []:
            teamname, result = QInputDialog.getItem(self, "Saved Teams", "List of Saved Teams:", items, 0, False)
            if result == True:
                names = "SELECT * FROM Teams WHERE Name = '"+teamname+"';"
                c.execute(names)
                g = c.fetchall()
                h = list(g[0])
                x = h[1].split(",")
                for i in x:
                    self.listWidget_2.addItem(i)
                self.widget_2.setEnabled(False)
                self.lineEdit_4.setText("4")
                self.lineEdit_3.setText("4")
                self.lineEdit_2.setText("2")
                self.lineEdit.setText("1")
                self.lineEdit_14.setText(str(h[2]))
                self.lineEdit_11.setText(str(h[3]))
                self.lineEdit_5.setText(h[0])
        else:
            msg = QMessageBox()
            msg.setWindowTitle("Error Message")
            msg.setText("Sorry!.The Database is Empty..")
            msg.setIcon(QMessageBox.Warning)
            msg.setStandardButtons(QMessageBox.Retry|QMessageBox.Ignore|QMessageBox.Cancel)
            msg.setDefaultButton(QMessageBox.Retry)
            msg.setInformativeText("Create 'New team' in Manage Teams menu")
            x = msg.exec_()
            
    def EditingData(self):
        self.RetreivingData()
        msg = QMessageBox()
        msg.setWindowTitle("Warning..!")
        msg.setText("After editing your team, Dont forget to SAVE the team again..!")
        msg.setIcon(QMessageBox.Warning)
        msg.setStandardButtons(QMessageBox.Ok|QMessageBox.Ignore|QMessageBox.Cancel)
        msg.setDefaultButton(QMessageBox.Retry)
        msg.setInformativeText("Otherwise, you will lose your previous team too")
        x = msg.exec_()
        self.widget_2.setEnabled(True)
        n = self.lineEdit_5.text()
        c = Cricket.cursor()
        Deleted_Team = "DELETE FROM Teams WHERE Name='"+n+"';"
        c.execute(Deleted_Team)
        Cricket.commit()

    def ExitApp(self):
        msg = QMessageBox()
        msg.setWindowTitle("Exit")
        msg.setText("Are you sure you want to Exit.?")
        msg.setIcon(QMessageBox.Question)
        msg.setStandardButtons(QMessageBox.Yes|QMessageBox.No)
        msg.setDefaultButton(QMessageBox.No)
        msg.setInformativeText("click 'Yes' to exit")
        msg.buttonClicked.connect(self.popup)
        x = msg.exec_()
       
    def popup(self,i):
        if  i.text() == "&No":
            pass
        else:
            exit()
        
    def EvaluateDialog(self):
        self.widget_2.setEnabled(False)
        Dialog = QtWidgets.QDialog()
        ui = Ui_Dialog()
        ui.setupUi(Dialog)
        Dialog.show()
        Dialog.exec_()

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())