This commit is contained in:
2025-12-07 18:32:03 +07:00
parent 7daa9875a5
commit 5cb88dc669
12 changed files with 229 additions and 1 deletions
Binary file not shown.
Binary file not shown.
+57
View File
@@ -0,0 +1,57 @@
import tkinter as tk
from tkinter import messagebox
import sqlite3
from database import connect
from screens.admin_dashboard import AdminDashboard
from screens.kasir_dashboard import KasirDashboard
from screens.waiter_dashboard import WaiterDashboard
from screens.pembeli_menu import PembeliMenu
class LoginScreen(tk.Frame):
def __init__(self, parent, controller):
super().__init__(parent)
self.controller = controller
self.pack(fill="both", expand=True)
tk.Label(self, text="LOGIN SISTEM CAFE", font=("Arial", 22, "bold")).pack(pady=30)
tk.Label(self, text="Username").pack()
self.username_entry = tk.Entry(self, width=30)
self.username_entry.pack()
tk.Label(self, text="Password").pack()
self.password_entry = tk.Entry(self, width=30, show="*")
self.password_entry.pack()
tk.Button(self, text="Login", width=20, command=self.login).pack(pady=10)
def login(self):
username = self.username_entry.get()
password = self.password_entry.get()
db = connect()
cur = db.cursor()
cur.execute("SELECT role FROM users WHERE username=? AND password=?",
(username, password))
result = cur.fetchone()
if result:
role = result[0]
messagebox.showinfo("Success", f"Login sebagai {role}")
if role == "pemilik cafe":
AdminDashboard(self.controller.container, self.controller)
elif role == "admin":
AdminDashboard(self.controller.container, self.controller)
elif role == "kasir":
KasirDashboard(self.controller.container, self.controller)
elif role == "waiter":
WaiterDashboard(self.controller.container, self.controller)
elif role == "pembeli":
PembeliMenu(self.controller.container, self.controller)
else:
messagebox.showerror("Error", "Username atau password salah")
db.close()
+27
View File
@@ -0,0 +1,27 @@
import tkinter as tk
from tkinter import ttk, messagebox
from database import connect
class AdminDashboard(tk.Frame):
def __init__(self, parent, controller):
super().__init__(parent)
self.controller = controller
self.pack(fill="both", expand=True)
tk.Label(self, text="ADMIN DASHBOARD", font=("Arial", 20, "bold")).pack(pady=20)
tk.Button(self, text="Kelola Menu", command=self.open_menu_crud).pack(pady=5)
tk.Button(self, text="Lihat Laporan", command=self.open_laporan).pack(pady=5)
tk.Button(self, text="Logout", command=self.logout).pack(pady=5)
def open_menu_crud(self):
from screens.menu_crud import MenuCRUD
MenuCRUD(self.controller.container, self.controller)
def open_laporan(self):
from screens.laporan_screen import LaporanScreen
LaporanScreen(self.controller.container, self.controller)
def logout(self):
from screens.login_screen import LoginScreen
LoginScreen(self.controller.container, self.controller)
+13
View File
@@ -0,0 +1,13 @@
class KasirDashboard(tk.Frame):
def __init__(self, parent, controller):
super().__init__(parent)
self.controller = controller
self.pack(fill="both", expand=True)
tk.Label(self, text="KASIR DASHBOARD", font=("Arial", 18, "bold")).pack(pady=20)
tk.Button(self, text="Proses Pembayaran", command=self.open_payment).pack(pady=10)
def open_payment(self):
from screens.payment_screen import PaymentScreen
PaymentScreen(self.controller.container, self.controller)