input
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user