在超市管理系统中增加一个users表,该表包括,Id(工号),name(姓名), password(密码)修改程序,完成收银员登录和管理员登录的程序。登录过程是:用户输入工号和密码,查询users表是否存在记录,如果查询结果为真,则登录成功,否则登录失败。

下面是修改后的代码:

# Supermarket management system
# Author - BHAVESH L and JOHNEY B

from tkinter import *
from tkinter.font import Font
import os
from tkinter import messagebox
Main_Interface = Tk()
import sqlite3


# Creating Mysql connection
dbconn = sqlite3.connect("./Database/RSgroceries.db")

# Create a cursor to give commands
cursor = dbconn.cursor()

# Create Tables
# category Table
cursor.execute("""CREATE TABLE if not exists category(
category varchar(100) NOT NULL primary key
    )
    """)
dbconn.commit()
cursor.execute("""CREATE TABLE if not exists products(
    product_id int  not null primary key,
    product_name varchar(100) not null,
    product_rate int not null,
    category varchar(100) not null references category(category)
    )
    """)
dbconn.commit()

# Create users table
cursor.execute("""CREATE TABLE if not exists users(
    id int not null primary key,
    name varchar(100) not null,
    password varchar(100) not null
    )
    """)
dbconn.commit()

products = [
    ['101', 'Maaza 1 litre', '65', 'Beverages'],
    ['102', 'Coco Cola 1 litre', '70', 'Beverages'],
    ['103', 'Fanta 1 litre', '66', 'Beverages'],
    ['104', 'Miranda 1 litre', '72', 'Beverages'],
    ['105', '7 UP 1 litre', '60', 'Beverages'],
    ['106', 'Bovanto 1/2 litre', '35', 'Beverages'],
    ['107', 'Frooti 1/2 litre', '40', 'Beverages'],
    ['108', 'Pepsi 1/2 litre', '30', 'Beverages'],
    ['109', 'Apple Juice 1/2 litre', '25', 'Beverages'],
    ['110', 'Sprite 1/2 litre', '35', 'Beverages'],
    ['111', 'Aavin Milk 1 litre', '50', 'Dairy'],
    ['112', 'Aavin Milk 1/2 litre', '26', 'Dairy'],
    ['113', 'Aavin Milk 250 ml', '12', 'Dairy'],
    ['114', 'Amul Butter 100 g', '46', 'Dairy'],
    ['115', 'Arokya Curd 1 litre', '55', 'Dairy'],
    ['116', 'Aavin Curd 1 litre', '54', 'Dairy'],
    ['117', 'Amul Ghee 500 g', '245', 'Dairy'],
    ['118', 'MM Paneer', '230', 'Dairy'],
    ['119', 'Bhav Cheese 500g', '75', 'Dairy'],
    ['120', 'Cond. Milk 250ml', '90', 'Dairy'],
    ['121', 'Chilli Sauce 500g', '118', 'Sauce'],
    ['122', 'Sweent&Chilli Sauce 500g', '108', 'Sauce'],
    ['123', 'Tomato Sauce 500g', '100', 'Sauce'],
    ['124', 'Soya Sauce 500g', '110', 'Sauce'],
    ['125', 'Hot Tomato Sauce 500g', '115', 'Sauce'],
    ['126', 'Salt Bread', '21', 'Bread'],
    ['127', 'Milk Bread', '22', 'Bread'],
    ['128', 'Wheat Bread', '20', 'Bread'],
    ['129', 'Chicken Wings 400g', '270', 'Meat'],
    ['130', 'Chicken Breast 250g', '240', 'Meat'],
    ['131', 'Pork 500g', '200', 'Meat'],
    ['132', 'Beaf 1Kg', '290', 'Meat'],
    ['133', 'Chicken Boneless 500g', '250', 'Meat'],
    ['134', 'Chicken Leg Pie 1Kg', '190', 'Meat'],
    ['135', 'Full Chicken  ', '470', 'Meat'],
    ['136', '1Kg Basmati Rice', '200', 'Rice'],
    ['137', '1Kg Idli Rice ', '275', 'Rice'],
    ['138', '1Kg Tiffin Rice', '230', 'Rice'],
    ['139', '1Kg Basmati Rice', '200', 'Rice'],
    ['140', 'Ashir Atta 1Kg ', '45', 'Cereals'],
    ['141', 'RS Oats 500g ', '30', 'Cereals'],
    ['142', 'RS Frosted Flakes 500g ', '50', 'Cereals'],
    ['143', 'RS Oats 500g ', '30', 'Cereals'],
    ['
# Supermarket management system# Author - BHAVESH L and JOHNEY Bfrom tkinter import from tkinterfont import Fontimport osfrom tkinter import messageboxMain_Interface = Tkimport sqlite3# Creating Mysql

原文地址: https://www.cveoy.top/t/topic/i8og 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录