コード例 #1
0
class App:
    def __init__(self):
        self.db = DbManager()

    def initApp(self):
        msg = "*****\n1-Öğrenci Listesi\n2-Öğrenci Ekle\n3-Öğrenci Güncelle\n4-Öğrenci Sil\n5-Öğretmen Ekle\n6-Sınıflara Göre Dersler\n7-Çıkış(E/Ç)"
        while True:
            print(msg)
            islem = input("Seçim: ")
            if islem == '1':
                self.displayStudents()
            elif islem == '2':
                self.addStudent()
            elif islem == '3':
                self.editStudent()
            elif islem == '4':
                self.deleteStudent()
            elif islem == 'E' or islem == 'Ç':
                break
            else:
                print('yanlış seçim')

    def deleteStudent(self):
        classid = self.displayStudents()
        studentid = int(input('öğrenci id: '))

        self.db.deleteStudent(studentid)

    def editStudent(self):
        classid = self.displayStudents()
        studentid = int(input('öğrenci id: '))

        student = self.db.getStudentById(studentid)

        student[0].name = input('name:') or student[0].name
        student[0].surname = input('surname:') or student[0].surname
        student[0].gender = input('cinsiyet (E/K):') or student[0].gender
        student[0].classid = input('sınıf: ') or student[0].classid

        #or student[0].x demek kullanıcı herhangi bir degisiklik yapmazsa eski hali kalsın dedik.

        year = input("yıl: ") or student[0].birthdate.year
        month = input("ay: ") or student[0].birthdate.month
        day = input("gün: ") or student[0].birthdate.day

        student[0].birthdate = datetime.date(year, month, day)
        self.db.editStudent(student[0])

    def addStudent(self):
        self.displayClasses()

        classid = int(input('hangi sınıf: '))
        number = input('numara: ')
        name = input('ad')
        surname = input('soyad')
        year = int(input('yıl'))
        month = int(input('ay'))
        day = int(input('gün'))
        birthdate = datetime.date(year, month, day)
        gender = input('cinsiyet (E/K)')

        student = Student(None, number, name, surname, birthdate, gender,
                          classid)
        self.db.addStudent(student)

    def displayClasses(self):
        classes = self.db.getClasses()
        for c in classes:
            print(f'{c.id}: {c.name}')

    def displayStudents(self):
        self.displayClasses()
        classid = int(input('hangi sınıf: '))

        students = self.db.getStudentsByClassId(classid)
        print("Öğrenci Listesi")
        for std in students:
            print(f'{std.id}-{std.name} {std.surname}')

        return classid
コード例 #2
0
class App:
    def __init__(self):
        self.db = DbManager()

    def initApp(self):
        msg = "*****\n1-Öğrenci Listesi\n2-Öğrenci Ekle\n3-Öğrenci Güncelle\n4-Öğrenci Sil\n5-Öğretmen Listesi\n6-Öğretmen Ekle\n7-Öğretmen Güncelle\n8-Öğretmen Sil\n9-Sınıflara Göre Dersler\n7-Çıkış(E/Ç)"
        while True:
            print(msg)
            islem = input("Seçim: ")
            if islem == '1':
                self.displayStudents()
            elif islem == '2':
                self.addStudent()
            elif islem == '3':
                self.editStudent()
            elif islem == '4':
                self.deleteStudent()
            elif islem == '5':
                self.displayTeachers()
            elif islem == '6':
                self.addTeacher()
            elif islem == '7':
                self.editTeacher()
            elif islem == '8':
                self.deleteTeacher()
            elif islem == '9':
                self.getLessonsByClass()
            elif islem == 'E' or islem == 'Ç':
                break
            else:
                print("yanlış seçim")

    def deleteStudent(self):
        classid = self.displayStudents()
        studentid = int(input("öğrenci id: "))

        self.db.deleteStudent(studentid)

    def editStudent(self):
        classid = self.displayStudents()
        studentid = int(input("öğrenci id: "))

        student = self.db.getStudentById(studentid)

        student[0].name = input("name: ") or student[0].name
        student[0].surname = input("surname: ") or student[0].surname
        student[0].gender = input("gender (E/K): ") or student[0].gender
        student[0].classid = input("class: ") or student[0].classid

        year = input("year: ") or student[0].birthdate.year
        month = input("month: ") or student[0].birthdate.month
        day = input("day: ") or student[0].birthdate.day

        student[0].birthdate = datetime.date(year, month, day)
        self.db.editStudent(student[0])

    def addStudent(self):
        self.displayClasses()

        classid = int(input("hangi sınıf: "))
        number = input("numara: ")
        name = input("ad: ")
        surname = input("soyad: ")
        year = int(input("yıl: "))
        month = int(input("ay: "))
        day = int(input("gün: "))
        birthdate = datetime.date(year, month, day)
        gender = input("cinsiyet (E/K)")

        student = Student(None, number, name, surname, birthdate, gender,
                          classid)
        self.db.addStudent(student)

    def displayClasses(self):
        classes = self.db.getClasses()
        for c in classes:
            print(f"{c.id}: {c.name}")

    def displayStudents(self):

        self.displayClasses()
        classid = int(input("hangi sınıf: "))

        students = self.db.getStudentsByClassId(classid)
        print("Öğrenci Listesi")
        for std in students:
            print(f"{std.id}-{std.name} {std.surname}")

        return classid

    def deleteTeacher(self):
        self.displayTeachers()
        ogretmenid = int(input("öğretmen id: "))

        self.db.deleteTeacher(ogretmenid)

    def editTeacher(self):
        self.displayTeachers()
        ogretmenid = int(input("öğretmen id: "))

        ogretmen = self.db.getTeacherById(ogretmenid)

        ogretmen[0].branch = input("branch: ") or ogretmen[0].branch
        ogretmen[0].name = input("name: ") or ogretmen[0].name
        ogretmen[0].surname = input("surname: ") or ogretmen[0].surname
        ogretmen[0].gender = input("gender (E/K): ") or ogretmen[0].gender

        year = input("year: ") or ogretmen[0].birthdate.year
        month = input("month: ") or ogretmen[0].birthdate.month
        day = input("day: ") or ogretmen[0].birthdate.day

        ogretmen[0].birthdate = datetime.date(year, month, day)
        self.db.editTeacher(ogretmen[0])

    def addTeacher(self):

        branch = input("branş: ")
        name = input("ad: ")
        surname = input("soyad: ")
        year = int(input("yıl: "))
        month = int(input("ay: "))
        day = int(input("gün: "))
        birthdate = datetime.date(year, month, day)
        gender = input("cinsiyet (E/K)")

        ogretmen = Teacher(None, branch, name, surname, birthdate, gender)
        self.db.addTeacher(ogretmen)

    def displayTeachers(self):

        ogretmenler = self.db.getTeachers()
        print("Öğretmen Listesi")
        for std in ogretmenler:
            print(f"{std.id}-{std.name} {std.surname}")

    def getLessonsByClass(self):

        self.cursor = connection.cursor()
        self.cursor.execute(
            "SELECT class.Name, lesson.Name FROM lesson INNER JOIN class ON lesson.Id = class.Id GROUP BY(class.Id)"
        )
        result = self.cursor.fetchall()
        for i in result:
            print(f"Sınıf: {i[0]} - Dersler: {i[1]}")
コード例 #3
0
class App:
    def __init__(self):
        self.db = DbManager()

    def initApp(self):
        msg = "*****\n1-Öğrenci Listesi\n2-Öğrenci Ekle\n3-Öğrenci Güncelle\n4-Öğrenci Sil\n5-Öğretmen Ekle\n6-Sınıflara Göre Dersler\n7-Çıkış(E/Ç)"
        while True:
            print(msg)
            islem = input("Seçim : ")
            if islem == '1':
                self.displayStudents()
            elif islem == '2':
                self.addStudent()
            elif islem == '3':
                self.editStudent()
            elif islem == '4':
                self.deleteStudent()
            elif islem == 'E' or islem == 'Ç':
                break
            else:
                print("yanlış seçim")

    def displayClasses(self):
        classes = self.db.getClasses()
        for sinif in classes:
            print(f'{sinif.id} : {sinif.name}')

    def displayStudents(self):
        self.displayClasses()
        classid = int(input("hangi sınıf :"))
        students = self.db.getStudentsByClassId(classId=classid)
        print("\n\nÖĞRENCİ LİSTESİ\n")
        for index, std in enumerate(students):
            print(f'{std.id}- {std.name} {std.surname}')
        return classid

    def addStudent(self):
        self.displayClasses()
        classid = int(input("hangi sınıf :"))
        studentNumber = input("Numara: ")
        name = input("Ad: ")
        surname = input("Soyad: ")

        year = int(input("Doğum Tarihi Yılı: "))
        month = int(input("Doğum Tarihi Ay: "))
        day = int(input("Doğum Tarihi Gün: "))
        birthdate = datetime(year, month, day)

        gender = input("Cinsiyet (E/K): ")

        student = Student(None, studentNumber, name, surname, birthdate,
                          gender, classid)
        self.db.addStudent(student)

    def editStudent(self):
        classid = self.displayStudents()
        studentid = int(input("Öğrenci id : "))
        student = self.db.getStudentById(studentid)

        student[0].name = input('adı : ') or student[0].name
        student[0].surname = input('soyadı : ') or student[0].surname
        student[0].gender = input('cinsiyet (E/K) : ') or student[0].gender
        student[0].classId = input('Sınıf : ') or student[0].classId

        year = input("Doğum Tarihi Yılı: ") or student[0].birthdate.year
        month = input("Doğum Tarihi Ay: ") or student[0].birthdate.month
        day = input("Doğum Tarihi Gün: ") or student[0].birthdate.day

        birthdate = datetime(year, month, day)

        student[0].birthdate = datetime(year, month, day)
        self.db.editStudent(student[0])

    def deleteStudent(self):
        classid = self.displayStudents()
        studentid = int(input("öğrenci no : "))

        student = self.db.getStudentById(studentid)
        self.db.deleteStudent(student[0])
コード例 #4
0
ファイル: app.py プロジェクト: Ayseekinci/Python
class App:
    def __init__(self):
        self.db = DbManager()

    def initApp(self):
        msg = "*****\n1-Öğrenci Listesi\n2-Öğrenci Ekle\n3-Öğrenci Güncelle\n4-Öğrenci Sil\n5-Çıkış(E/Ç)"
        while True:
            print(msg)
            islem = input("İşlem Seçiniz")
            if islem == '1':
                self.displayStudents()

            elif islem == '2':
                self.addStudent()

            elif islem == '3':
                self.editStudent()
            elif islem == '4':
                self.deleteStudent()
                pass
            elif islem == 'E' or islem == 'Ç':
                break
            else:
                print("Yanlış Seçim Yaptınız.")

    def displayClasses(self):
        classes = self.db.getClasses()
        for i in classes:
            print(f'{i.id}: {i.name}')

    # Öğrenci Ekler.
    def addStudent(self):
        self.displayClasses()

        ClassId = int(input('Hangi sınıfın bilgileri ?'))
        number = input("Öğrenci Numarası :")
        name = input("Öğrenci Adı :")
        surname = input("Öğrenci Soyad :")
        birthdate = input("Birthdate (YYYY,MM,DD): ")
        gender = input("Cinsiyet (E/K) :")
        student = Student(None, number, name, surname, birthdate, gender,
                          ClassId)

        self.db.addStudent(student)

    def deleteStudent(self):
        self.displayStudents()
        studentid = int(input("Öğrenci İD:"))
        self.db.deleteStudent(studentid)

    # Öğrenci Güncelleme

    def editStudent(self):
        self.displayStudents()
        # ClassId = int(input('Hangi sınıfın bilgileri ?'))
        studentid = int(input("Öğrenci İD:"))
        student = self.db.getStudentById(studentid)
        print(student[0].Ad, student[0].Soyad)

        student[0].Ad = input("Ad:") or student[0].Ad
        student[0].Soyad = input("Soyad:") or student[0].Soyad
        student[0].DogumTarihi = input(
            "Doğum Tarihi(YYYY/MM/DD) :") or student[0].DogumTarihi
        student[0].Cinsiyet = input("Cinsiyet: ") or student[0].Cinsiyet
        # student[0].ClassId = input("Sınıf :") or student[0].ClassId

        self.db.editStudent(student[0])

    # Öğrenci listesi

    def displayStudents(self):
        self.displayClasses()

        ClassId = int(input('Hangi sınıfın bilgileri ?'))
        student = self.db.getStudentsByClassId(ClassId)
        print("Öğrenci Listesi : ")

        for std in student:
            print(f"{std.id}-{std.Ad} {std.Soyad}")
コード例 #5
0
class App:
    def __init__(self):
        self.db = DbManager()

    def initApp(self):
        msg = '****\n1-Öğrenci Listesi\n2-Öğrenci Ekle\n3-Öğrenci Güncelle\n4-Öğrenci Sil\nÇıkış(E/Ç)'
        while True:
            print(msg)
            islem = input('Seçim: ')
            if islem == '1':
                self.displayStudents()
            elif islem == '2':
                self.addStudent()
            elif islem == '3':
                self.editStudent()
            elif islem == '4':
                pass
            elif islem == 'E' or islem == 'Ç':
                break
            else:
                print('Yanlış Seçim yaptınız')
    def editStudent(self):


    def displayClasses(self):

        classes = self.db.getClasses()
        for c in classes:
            print(c.id, c.name)


    def displayStudents(self):
        self.displayClasses()

        classid = int(input('Hangi Sınıf:'))

        students = self.db.getStudentsByClassId(classid)
        print('Öğrenci Listesi')
        for index,std in enumerate(students):
            print((index+1),std.name,std.surname)


    def addStudent(self):
        self.displayClasses()
        classid = int(input('Hangi Sınıf:'))
        number = input('Numara: ')
        name = input('isim: ')
        surname = input('soyisim: ')
        year = int(input('yıl: '))
        month = int(input('ay: '))
        day = int(input('gün: '))
        birthdate = datetime.date(year,month,day)
        gender = input('E/K: ')

        student = Student(None,number,name,surname,birthdate,gender,classid)
        self.db.addStudent(student)




app = App()
app.initApp()