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

# Form implementation generated from reading ui file '.\hastakayit_gui.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
import mysql.connector
from PyQt5.QtWidgets import QMessageBox,QWidget,QMainWindow

from PyQt5.QtCore import  Qt, QDate, QDateTime

# Veritabanı bağlantısı için sql cümleciği oluşturuldu.
db = mysql.connector.connect(
    host="localhost",
    user="root",
    passwd="12345",
    database="cilth_vt"
)
cursor = db.cursor()

class Ui_MainWindow2(QMainWindow):
    def setupUi2(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(600, 205)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("../heartbeat.png"), QtGui.QIcon.Normal, QtGui.QIcon.On)
        MainWindow.setWindowIcon(icon)
        MainWindow.setTabShape(QtWidgets.QTabWidget.Triangular)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.btn_kayit = QtWidgets.QPushButton(self.centralwidget)
        self.btn_kayit.setGeometry(QtCore.QRect(180, 150, 121, 31))
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap("../avatar.png"), QtGui.QIcon.Normal, QtGui.QIcon.On)
        self.btn_kayit.setIcon(icon1)
        self.btn_kayit.setObjectName("btn_kayit")
        self.btn_kayit.clicked.connect(self.kayitekle)
        self.btn_cikis = QtWidgets.QPushButton(self.centralwidget)
        self.btn_cikis.setGeometry(QtCore.QRect(310, 150, 121, 31))
        self.btn_cikis.setObjectName("btn_cikis")
        self.btn_cikis.clicked.connect(self.close)
        self.gridLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
        self.gridLayoutWidget_2.setGeometry(QtCore.QRect(10, 10, 571, 128))
        self.gridLayoutWidget_2.setObjectName("gridLayoutWidget_2")
        self.gridLayout_3 = QtWidgets.QGridLayout(self.gridLayoutWidget_2)
        self.gridLayout_3.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.lbl_htc = QtWidgets.QLabel(self.gridLayoutWidget_2)
        self.lbl_htc.setObjectName("lbl_htc")
        self.gridLayout_3.addWidget(self.lbl_htc, 0, 0, 1, 1)
        self.lbl_hadsoyad = QtWidgets.QLabel(self.gridLayoutWidget_2)
        self.lbl_hadsoyad.setObjectName("lbl_hadsoyad")
        self.gridLayout_3.addWidget(self.lbl_hadsoyad, 1, 0, 1, 1)
        self.lbl_hcinsiyet = QtWidgets.QLabel(self.gridLayoutWidget_2)
        self.lbl_hcinsiyet.setObjectName("lbl_hcinsiyet")
        self.gridLayout_3.addWidget(self.lbl_hcinsiyet, 2, 0, 1, 1)
        self.lineEdit_2 = QtWidgets.QLineEdit(self.gridLayoutWidget_2)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.gridLayout_3.addWidget(self.lineEdit_2, 1, 1, 1, 1)
        self.lineEdit_3 = QtWidgets.QLineEdit(self.gridLayoutWidget_2)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.gridLayout_3.addWidget(self.lineEdit_3, 2, 1, 1, 1)
        self.lineEdit = QtWidgets.QLineEdit(self.gridLayoutWidget_2)
        self.lineEdit.setObjectName("lineEdit")
        self.gridLayout_3.addWidget(self.lineEdit, 0, 1, 1, 1)
        self.lbl_hdt = QtWidgets.QLabel(self.gridLayoutWidget_2)
        self.lbl_hdt.setObjectName("lbl_hdt")
        self.gridLayout_3.addWidget(self.lbl_hdt, 3, 0, 1, 1)
        self.dt_hdt = QtWidgets.QDateEdit(self.gridLayoutWidget_2)
        self.dt_hdt.setObjectName("dt_hdt")
        self.dt_hdt.setDateTime(QtCore.QDateTime(QtCore.QDate(2019, 1, 1), QtCore.QTime(0, 0, 0)))
        self.gridLayout_3.addWidget(self.dt_hdt, 3, 1, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

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


    def kayitekle(self):
      # k_ad/k_sfire lineedit'ten alınan verileri sorguya gönderir.
      h_tc=self.lineEdit.text()
      h_ads=self.lineEdit_2.text()
      h_csyt=self.lineEdit_3.text()
      h_dt=self.dt_hdt.text()
      icon = QtGui.QIcon()
      icon.addPixmap(QtGui.QPixmap("heartbeat.png"), QtGui.QIcon.Normal, QtGui.QIcon.On)
      QMessageBox.setWindowIcon(self, icon)


      try:
         hasta_ekle = ("INSERT INTO hasta(h_tc,h_ad_sad,h_cins,h_dt) VALUES (%s,%s,%s,%s)")
         cursor.execute(hasta_ekle,(h_tc,h_ads,h_csyt,h_dt))
         db.commit()
         veri = cursor.rowcount
      except:
         veri=2

      if (veri == 1):

         QMessageBox.information(self, 'BİLGİLENDİRME', "İşlem Başarılı.")
      else:
          QMessageBox.information(self, 'BİLGİLENDİRME', "İşlem Başarısız")
    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Cilt Hastalıkları Tespit Uygulaması-Hasta Kayıt Ekranı"))
        self.btn_kayit.setText(_translate("MainWindow", "ONAYLA"))
        self.btn_cikis.setText(_translate("MainWindow", "İPTAL"))
        self.lbl_htc.setText(_translate("MainWindow", "TC Kimlik No:"))
        self.lbl_hadsoyad.setText(_translate("MainWindow", "Hasta Adı Soyadı:"))
        self.lbl_hcinsiyet.setText(_translate("MainWindow", "Cinsiyet: "))
        self.lbl_hdt.setText(_translate("MainWindow", "Doğum Tarihi:"))
        self.dt_hdt.setDisplayFormat(_translate("MainWindow", "yyyy.MM.dd"))

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


[((122, 10, 122, 42), 'PyQt5.QtWidgets.QApplication', 'QtWidgets.QApplication', ({(122, 33, 122, 41): 'sys.argv'}, {}), '(sys.argv)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((123, 17, 123, 40), 'PyQt5.QtWidgets.QMainWindow', 'QtWidgets.QMainWindow', ({}, {}), '()', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((28, 15, 28, 28), 'PyQt5.QtGui.QIcon', 'QtGui.QIcon', ({}, {}), '()', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((32, 29, 32, 58), 'PyQt5.QtWidgets.QWidget', 'QtWidgets.QWidget', ({(32, 47, 32, 57): 'MainWindow'}, {}), '(MainWindow)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((34, 25, 34, 66), 'PyQt5.QtWidgets.QPushButton', 'QtWidgets.QPushButton', ({(34, 47, 34, 65): 'self.centralwidget'}, {}), '(self.centralwidget)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((36, 16, 36, 29), 'PyQt5.QtGui.QIcon', 'QtGui.QIcon', ({}, {}), '()', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((41, 25, 41, 66), 'PyQt5.QtWidgets.QPushButton', 'QtWidgets.QPushButton', ({(41, 47, 41, 65): 'self.centralwidget'}, {}), '(self.centralwidget)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((45, 34, 45, 71), 'PyQt5.QtWidgets.QWidget', 'QtWidgets.QWidget', ({(45, 52, 45, 70): 'self.centralwidget'}, {}), '(self.centralwidget)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((48, 28, 48, 74), 'PyQt5.QtWidgets.QGridLayout', 'QtWidgets.QGridLayout', ({(48, 50, 48, 73): 'self.gridLayoutWidget_2'}, {}), '(self.gridLayoutWidget_2)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((51, 23, 51, 64), 'PyQt5.QtWidgets.QLabel', 'QtWidgets.QLabel', ({(51, 40, 51, 63): 'self.gridLayoutWidget_2'}, {}), '(self.gridLayoutWidget_2)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((54, 28, 54, 69), 'PyQt5.QtWidgets.QLabel', 'QtWidgets.QLabel', ({(54, 45, 54, 68): 'self.gridLayoutWidget_2'}, {}), '(self.gridLayoutWidget_2)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((57, 29, 57, 70), 'PyQt5.QtWidgets.QLabel', 'QtWidgets.QLabel', ({(57, 46, 57, 69): 'self.gridLayoutWidget_2'}, {}), '(self.gridLayoutWidget_2)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((60, 26, 60, 70), 'PyQt5.QtWidgets.QLineEdit', 'QtWidgets.QLineEdit', ({(60, 46, 60, 69): 'self.gridLayoutWidget_2'}, {}), '(self.gridLayoutWidget_2)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((63, 26, 63, 70), 'PyQt5.QtWidgets.QLineEdit', 'QtWidgets.QLineEdit', ({(63, 46, 63, 69): 'self.gridLayoutWidget_2'}, {}), '(self.gridLayoutWidget_2)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((66, 24, 66, 68), 'PyQt5.QtWidgets.QLineEdit', 'QtWidgets.QLineEdit', ({(66, 44, 66, 67): 'self.gridLayoutWidget_2'}, {}), '(self.gridLayoutWidget_2)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((69, 23, 69, 64), 'PyQt5.QtWidgets.QLabel', 'QtWidgets.QLabel', ({(69, 40, 69, 63): 'self.gridLayoutWidget_2'}, {}), '(self.gridLayoutWidget_2)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((72, 22, 72, 66), 'PyQt5.QtWidgets.QDateEdit', 'QtWidgets.QDateEdit', ({(72, 42, 72, 65): 'self.gridLayoutWidget_2'}, {}), '(self.gridLayoutWidget_2)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((77, 25, 77, 57), 'PyQt5.QtWidgets.QStatusBar', 'QtWidgets.QStatusBar', ({(77, 46, 77, 56): 'MainWindow'}, {}), '(MainWindow)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((82, 8, 82, 57), 'PyQt5.QtCore.QMetaObject.connectSlotsByName', 'QtCore.QMetaObject.connectSlotsByName', ({(82, 46, 82, 56): 'MainWindow'}, {}), '(MainWindow)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((91, 13, 91, 26), 'PyQt5.QtGui.QIcon', 'QtGui.QIcon', ({}, {}), '()', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((93, 6, 93, 43), 'PyQt5.QtWidgets.QMessageBox.setWindowIcon', 'QMessageBox.setWindowIcon', ({(93, 32, 93, 36): 'self', (93, 38, 93, 42): 'icon'}, {}), '(self, icon)', False, 'from PyQt5.QtWidgets import QMessageBox, QWidget, QMainWindow\n'), ((29, 23, 29, 56), 'PyQt5.QtGui.QPixmap', 'QtGui.QPixmap', ({(29, 37, 29, 55): '"""../heartbeat.png"""'}, {}), "('../heartbeat.png')", False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((35, 35, 35, 66), 'PyQt5.QtCore.QRect', 'QtCore.QRect', ({(35, 48, 35, 51): '(180)', (35, 53, 35, 56): '(150)', (35, 58, 35, 61): '(121)', (35, 63, 35, 65): '(31)'}, {}), '(180, 150, 121, 31)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((37, 24, 37, 54), 'PyQt5.QtGui.QPixmap', 'QtGui.QPixmap', ({(37, 38, 37, 53): '"""../avatar.png"""'}, {}), "('../avatar.png')", False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((42, 35, 42, 66), 'PyQt5.QtCore.QRect', 'QtCore.QRect', ({(42, 48, 42, 51): '(310)', (42, 53, 42, 56): '(150)', (42, 58, 42, 61): '(121)', (42, 63, 42, 65): '(31)'}, {}), '(310, 150, 121, 31)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((46, 44, 46, 74), 'PyQt5.QtCore.QRect', 'QtCore.QRect', ({(46, 57, 46, 59): '(10)', (46, 61, 46, 63): '(10)', (46, 65, 46, 68): '(571)', (46, 70, 46, 73): '(128)'}, {}), '(10, 10, 571, 128)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((92, 21, 92, 51), 'PyQt5.QtGui.QPixmap', 'QtGui.QPixmap', ({(92, 35, 92, 50): '"""heartbeat.png"""'}, {}), "('heartbeat.png')", False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((106, 9, 106, 82), 'PyQt5.QtWidgets.QMessageBox.information', 'QMessageBox.information', ({(106, 33, 106, 37): 'self', (106, 39, 106, 57): '"""BİLGİLENDİRME"""', (106, 59, 106, 81): '"""İşlem Başarılı."""'}, {}), "(self, 'BİLGİLENDİRME', 'İşlem Başarılı.')", False, 'from PyQt5.QtWidgets import QMessageBox, QWidget, QMainWindow\n'), ((108, 10, 108, 83), 'PyQt5.QtWidgets.QMessageBox.information', 'QMessageBox.information', ({(108, 34, 108, 38): 'self', (108, 40, 108, 58): '"""BİLGİLENDİRME"""', (108, 60, 108, 82): '"""İşlem Başarısız"""'}, {}), "(self, 'BİLGİLENDİRME', 'İşlem Başarısız')", False, 'from PyQt5.QtWidgets import QMessageBox, QWidget, QMainWindow\n'), ((74, 49, 74, 73), 'PyQt5.QtCore.QDate', 'QtCore.QDate', ({(74, 62, 74, 66): '(2019)', (74, 68, 74, 69): '(1)', (74, 71, 74, 72): '(1)'}, {}), '(2019, 1, 1)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((74, 75, 74, 96), 'PyQt5.QtCore.QTime', 'QtCore.QTime', ({(74, 88, 74, 89): '(0)', (74, 91, 74, 92): '(0)', (74, 94, 74, 95): '(0)'}, {}), '(0, 0, 0)', False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n')]