# -*- 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_())


[((5584, 5616), 'PyQt5.QtWidgets.QApplication', 'QtWidgets.QApplication', (['sys.argv'], {}), '(sys.argv)\n', (5606, 5616), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((5634, 5657), 'PyQt5.QtWidgets.QMainWindow', 'QtWidgets.QMainWindow', ([], {}), '()\n', (5655, 5657), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((742, 755), 'PyQt5.QtGui.QIcon', 'QtGui.QIcon', ([], {}), '()\n', (753, 755), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((982, 1011), 'PyQt5.QtWidgets.QWidget', 'QtWidgets.QWidget', (['MainWindow'], {}), '(MainWindow)\n', (999, 1011), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((1095, 1136), 'PyQt5.QtWidgets.QPushButton', 'QtWidgets.QPushButton', (['self.centralwidget'], {}), '(self.centralwidget)\n', (1116, 1136), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((1221, 1234), 'PyQt5.QtGui.QIcon', 'QtGui.QIcon', ([], {}), '()\n', (1232, 1234), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((1495, 1536), 'PyQt5.QtWidgets.QPushButton', 'QtWidgets.QPushButton', (['self.centralwidget'], {}), '(self.centralwidget)\n', (1516, 1536), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((1740, 1777), 'PyQt5.QtWidgets.QWidget', 'QtWidgets.QWidget', (['self.centralwidget'], {}), '(self.centralwidget)\n', (1757, 1777), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((1950, 1996), 'PyQt5.QtWidgets.QGridLayout', 'QtWidgets.QGridLayout', (['self.gridLayoutWidget_2'], {}), '(self.gridLayoutWidget_2)\n', (1971, 1996), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((2133, 2174), 'PyQt5.QtWidgets.QLabel', 'QtWidgets.QLabel', (['self.gridLayoutWidget_2'], {}), '(self.gridLayoutWidget_2)\n', (2149, 2174), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((2311, 2352), 'PyQt5.QtWidgets.QLabel', 'QtWidgets.QLabel', (['self.gridLayoutWidget_2'], {}), '(self.gridLayoutWidget_2)\n', (2327, 2352), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((2505, 2546), 'PyQt5.QtWidgets.QLabel', 'QtWidgets.QLabel', (['self.gridLayoutWidget_2'], {}), '(self.gridLayoutWidget_2)\n', (2521, 2546), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((2699, 2743), 'PyQt5.QtWidgets.QLineEdit', 'QtWidgets.QLineEdit', (['self.gridLayoutWidget_2'], {}), '(self.gridLayoutWidget_2)\n', (2718, 2743), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((2887, 2931), 'PyQt5.QtWidgets.QLineEdit', 'QtWidgets.QLineEdit', (['self.gridLayoutWidget_2'], {}), '(self.gridLayoutWidget_2)\n', (2906, 2931), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((3073, 3117), 'PyQt5.QtWidgets.QLineEdit', 'QtWidgets.QLineEdit', (['self.gridLayoutWidget_2'], {}), '(self.gridLayoutWidget_2)\n', (3092, 3117), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((3252, 3293), 'PyQt5.QtWidgets.QLabel', 'QtWidgets.QLabel', (['self.gridLayoutWidget_2'], {}), '(self.gridLayoutWidget_2)\n', (3268, 3293), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((3424, 3468), 'PyQt5.QtWidgets.QDateEdit', 'QtWidgets.QDateEdit', (['self.gridLayoutWidget_2'], {}), '(self.gridLayoutWidget_2)\n', (3443, 3468), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((3754, 3786), 'PyQt5.QtWidgets.QStatusBar', 'QtWidgets.QStatusBar', (['MainWindow'], {}), '(MainWindow)\n', (3774, 3786), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((3933, 3982), 'PyQt5.QtCore.QMetaObject.connectSlotsByName', 'QtCore.QMetaObject.connectSlotsByName', (['MainWindow'], {}), '(MainWindow)\n', (3970, 3982), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((4224, 4237), 'PyQt5.QtGui.QIcon', 'QtGui.QIcon', ([], {}), '()\n', (4235, 4237), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((4333, 4370), 'PyQt5.QtWidgets.QMessageBox.setWindowIcon', 'QMessageBox.setWindowIcon', (['self', 'icon'], {}), '(self, icon)\n', (4358, 4370), False, 'from PyQt5.QtWidgets import QMessageBox, QWidget, QMainWindow\n'), ((779, 812), 'PyQt5.QtGui.QPixmap', 'QtGui.QPixmap', (['"""../heartbeat.png"""'], {}), "('../heartbeat.png')\n", (792, 812), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((1172, 1203), 'PyQt5.QtCore.QRect', 'QtCore.QRect', (['(180)', '(150)', '(121)', '(31)'], {}), '(180, 150, 121, 31)\n', (1184, 1203), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((1259, 1289), 'PyQt5.QtGui.QPixmap', 'QtGui.QPixmap', (['"""../avatar.png"""'], {}), "('../avatar.png')\n", (1272, 1289), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((1572, 1603), 'PyQt5.QtCore.QRect', 'QtCore.QRect', (['(310)', '(150)', '(121)', '(31)'], {}), '(310, 150, 121, 31)\n', (1584, 1603), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((1822, 1852), 'PyQt5.QtCore.QRect', 'QtCore.QRect', (['(10)', '(10)', '(571)', '(128)'], {}), '(10, 10, 571, 128)\n', (1834, 1852), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((4259, 4289), 'PyQt5.QtGui.QPixmap', 'QtGui.QPixmap', (['"""heartbeat.png"""'], {}), "('heartbeat.png')\n", (4272, 4289), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((4653, 4718), 'PyQt5.QtWidgets.QMessageBox.information', 'QMessageBox.information', (['self', '"""BİLGİLENDİRME"""', '"""İşlem Başarılı."""'], {}), "(self, 'BİLGİLENDİRME', 'İşlem Başarılı.')\n", (4676, 4718), False, 'from PyQt5.QtWidgets import QMessageBox, QWidget, QMainWindow\n'), ((4741, 4806), 'PyQt5.QtWidgets.QMessageBox.information', 'QMessageBox.information', (['self', '"""BİLGİLENDİRME"""', '"""İşlem Başarısız"""'], {}), "(self, 'BİLGİLENDİRME', 'İşlem Başarısız')\n", (4764, 4806), False, 'from PyQt5.QtWidgets import QMessageBox, QWidget, QMainWindow\n'), ((3562, 3586), 'PyQt5.QtCore.QDate', 'QtCore.QDate', (['(2019)', '(1)', '(1)'], {}), '(2019, 1, 1)\n', (3574, 3586), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n'), ((3588, 3609), 'PyQt5.QtCore.QTime', 'QtCore.QTime', (['(0)', '(0)', '(0)'], {}), '(0, 0, 0)\n', (3600, 3609), False, 'from PyQt5 import QtCore, QtGui, QtWidgets\n')]