from tkinter import *
from tkinter import messagebox
import sqlite3
from tkinter import PhotoImage
from tkinter import ttk
#Base de datos de control de Usuarios
def BaseRegistroU():
Conexion = sqlite3.connect("Base Registro_de_Usuario")
miCursor = Conexion.cursor()
try:
miCursor.execute('''
CREATE TABLE DATOSUSUARIO (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
Usuario VARCHAR(50),
Departamento VARCHAR(50),
TipoU VARCHAR(50),
Contra VARCHAR(50))
''')
messagebox.showinfo("AVISO", "La Base de datos fue creada")
prec=messagebox.askquestion("Aviso","¿Desea continuar?")
if prec=="yes":
I.destroy()
VentanaU()
else:
I.destroy()
except:
messagebox.showwarning("AVISO", "La Base de datos funciona correctamente")
prec = messagebox.askquestion("Aviso", "¿Desea continuar?")
if prec == "yes":
I.destroy()
VentanaU()
else:
I.destroy()
#---------------------------------------------------------------------
#Aviso de integrantes
def PreL():
messagebox.showinfo("Integrantes","Miguel Alejandro Isla Villacaña\n\nDaniel Gaytan Davila\n\nJuan Miguel Reyes Robledo")
#---------------------------------------------------------------------
def VentanaR():
def CrearU():
miConexion = sqlite3.connect("Base Registro_de_Usuario")
miCursor = miConexion.cursor()
miCursor.execute("INSERT INTO DATOSUSUARIO VALUES (NULL, '" + miU.get() +
"','" + miC.get() +"')")
miConexion.commit()
messagebox.showinfo("Base de Datos", "Usuario Registrado con exito")
VR=Tk()
VR.resizable(0,0)
VR.title("Registrar Cuenta")
VR.iconbitmap("iconop.ico")
VR.geometry("650x650+370+25")
VR.config(bg="black")
#--------Imagen de fondo----------
Logo = PhotoImage(file="LogoRU.png")
Label(VR, image=Logo, bg='black').place(x=0,y=0)
miU = StringVar()
miC = StringVar
miD = StringVar()
miTU = StringVar()
# -----------Label------------
lb1 = Label(VR, text="Usuario:")
lb1.place(x=80, y=180)
lb1.config(width=10, font='Helvetica 20 bold', relief=RIDGE)
lb2 = Label(VR, text="Contraseña:", relief=RIDGE)
lb2.place(x=80, y=240)
lb2.config(width=10, font='Helvetica 20 bold')
#-------Cajas de texto---------
CuadroU = Entry(VR, textvariable=miU, font='Helvetica 20 bold', width=14)
CuadroU.place(x=270, y=180)
CuadroC = Entry(VR, textvariable=miC, font='Helvetica 20 bold', width=14)
CuadroC.place(x=270, y=240)
CuadroC.config(show="*")
#--------Comobo Box---------
CBD= ttk.Combobox(VR,state="readonly")#Creamos el comobobox y lo ponemos que solo pueda leer para que no se pueda escibir en el
CBD.place(x=80,y=320)
CBD ['values'] = ('Produccion','Ventas','Personal','Franquicias','Mermas')
CBD.set("Departamentos")#Establemos el valor que va a tener al inicio
CBD.config(width=25, font='Helvetica 20 bold')
CBU= ttk.Combobox(VR,state="readonly") # Creamos el comobobox y lo ponemos que solo pueda leer para que no se pueda escibir en el
CBU.place(x=80, y=380)
CBU['values'] = ('Empleado','Administrador')
CBU.set("Tipo de cuenta") # Establemos el valor que va a tener al inicio
CBU.config(width=25, font='Helvetica 20 bold')
#----switch Departamento-----
if CBD.get() == "Produccion":
miD="Produccion"
elif CBD.get() == "Ventas":
miD="Ventas"
elif CBD.get() == "Personal":
miD="Personal"
elif CBD.get() == "Franquicias":
miD="Franquicias"
elif CBD.get() == "Mermas":
miD="Mermas"
#---Switch Usuario----
if CBU.get() == "Empleado":
miTU="Empleado"
elif CBU.get() == "Administrador":
miTU="Administrador"
#------Botones------
botonRF = Button(VR, text="Crear", command=CrearU)
botonRF.place(x=80, y=580)
botonRF.config(width=12, height=2, font='Helvetica 10 bold', relief=RIDGE)
VR.mainloop()
#---------------------------------------------------
def VentanaU():
VU=Tk()
VU.resizable(0,0)
VU.title("Inicio de Sesion")
VU.iconbitmap("iconop.ico")
VU.geometry("650x650+370+25")
VU.config(bg="black")
#-----------Label------------
lb1 = Label(VU, text="Usuario:")
lb1.place(x=105, y=440)
lb1.config(width=10, font='Helvetica 20 bold',relief=RIDGE)
lb2 = Label(VU, text="Contraseña:",relief=RIDGE)
lb2.place(x=105, y=500)
lb2.config(width=10,font='Helvetica 20 bold')
#-----Cajas de texto-----
CuadroU = Entry(VU, textvariable=miUsuario, font='Helvetica 20 bold', width=14)
CuadroU.place(x=290, y=440)
CuadroC = Entry(VU, textvariable=miContra, font='Helvetica 20 bold', width=14)
CuadroC.place(x=290, y=500)
CuadroC.config(show="*")
def cerrarVU():
VU.destroy()
VentanaR()
#----------------------Botones---------
botonR = Button(VU, text="Registrarse", command=cerrarVU)
botonR.place(x=180, y=590)
botonR.config(width=12, height=2, font='Helvetica 10 bold', relief=RIDGE)
botonC = Button(VU, text="Continuar")
botonC.place(x=350,y=590)
botonC.config(width=12, height=2, font='Helvetica 10 bold', relief=RIDGE)
#Logo Usuario
img = PhotoImage(file="LogoUP.png")
botonIm = Button(VU, image=img,width=400, height=400,relief=FLAT, command=PreL, bg='black').place(x=118,y=10)
VU.mainloop()
#---------------------------------------------------------------------
#----------------------------Ventana Inicio Programa-----------------
I=Tk()
I.resizable(0,0)
I.title("Inicio")
I.iconbitmap("iconop.ico")
I.geometry("1366x700+0+0")
miUsuario = StringVar()
miContra = StringVar
miDepartamento = StringVar()
miTipoU = StringVar ()
miI=Frame(I, width=650, height=650)
miI.pack()
Logo=PhotoImage(file="logo.png")
Label(miI, image=Logo).pack()
BotonInicio=Button(miI, text="Inicio", command=BaseRegistroU)
BotonInicio.config(width=10, height=1, font='Helvetica 40 bold', relief=RIDGE)
BotonInicio.pack()
I.mainloop()
#--------------------------------------------------------------------