def Staff_delete2(): global window_function global v24 window_function=tk.Toplevel() window_function.title("超市零售信息管理系统") window_function.geometry('500x400') window_function["bg"] = "lightblue" tk.Label(window_function,fg="red",
时间: 2023-06-27 08:02:24 浏览: 137
text="请填写要删除的员工编号:",bg="lightblue",font=("微软雅黑",12)).place(x=50,y=50)
v24 = tk.StringVar() tk.Entry(window_function, textvariable=v24,font=("微软雅黑",12)).place(x=200,y=50)
tk.Button(window_function,text="确认删除",bg="lightblue",font=("微软雅黑",12),command=Staff_delete3).place(x=200,y=100)
def Staff_delete3(): global window_function global v24 num = v24.get() if num == "": tk.messagebox.showwarning("警告","请输入员工编号!") return conn = sqlite3.connect("Supermarket.db") c = conn.cursor() sql = "SELECT id FROM staff WHERE id='%s'" %num cursor = c.execute(sql) result = cursor.fetchall() if len(result) == 0: tk.messagebox.showwarning("警告","该员工不存在!") return sql = "DELETE FROM staff WHERE id='%s'" %num c.execute(sql) conn.commit() conn.close() tk.messagebox.showinfo("提示","员工删除成功!") window_function.destroy()
这是一个删除员工信息的函数,首先弹出一个窗口,用户输入要删除的员工编号,然后点击确认删除按钮,程序会在数据库中查找是否有该员工,如果存在则删除该员工信息,否则提示用户该员工不存在。最后弹出提示窗口,告诉用户员工删除成功。
阅读全文