0% found this document useful (0 votes)
9 views

This Is A Basic Implementation of The Frontend Logic

Uploaded by

Sajeev Sbce
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

This Is A Basic Implementation of The Frontend Logic

Uploaded by

Sajeev Sbce
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

# This is a basic implementation of the frontend logic.

# You can extend it by integrating additional tables and improving the UI for better visual appeal.

import tkinter as tk
from tkinter import messagebox
import mysql.connector

# Database connection
def connect_db():
return mysql.connector.connect(
host="localhost",
user="appuser",
password="apppassword",
database="expFinal"
)

# Insert into college table


def insert_college():
conn = connect_db()
cursor = conn.cursor()

# Fetch input values


college_code, college_name, col_add = entry_college_code.get(), entry_college_name.get(), entry_college_address.get()

if not college_code or not college_name or not col_add:


messagebox.showwarning("Input Error", "All fields are required!")
return

try:
cursor.execute(
"INSERT INTO college (college_code, college_name, col_add) VALUES (%s, %s, %s)",
(college_code, college_name, col_add)
)
conn.commit()
messagebox.showinfo("Success", "College added successfully!")
except Exception as e:
messagebox.showerror("Error", str(e))
finally:
cursor.close()
conn.close()

# Setup UI
root = tk.Tk()
root.title("College Management")
root.geometry("400x300")

# College inputs
tk.Label(root, text="College Code").pack(pady=5)
entry_college_code = tk.Entry(root)
entry_college_code.pack(pady=5)

tk.Label(root, text="College Name").pack(pady=5)


entry_college_name = tk.Entry(root)
entry_college_name.pack(pady=5)

tk.Label(root, text="College Address").pack(pady=5)


entry_college_address = tk.Entry(root)
entry_college_address.pack(pady=5)
# Insert button
insert_button = tk.Button(root, text="Insert College", command=insert_college)
insert_button.pack(pady=20)

# Run the app


root.mainloop()

You might also like