Esempio n. 1
0
def update(show_key, table, con_key):

    if table == "" or show_key == "":
        print("update需要输入参数")
    else:
        if "=" in show_key:
            show_list = show_key.strip().split("=")
            if show_list[0].strip() == "staff_id":
                exit("staff_id不允许改动")
            else:
                message = file_read(table)
                title = message[0]
                context = message[1]

                if show_list[0] == "phone":
                    if not show_list[1].isdigit() or len(show_list[1]) != 11 or [True for line in context if show_list[1] in line]:
                        exit("phone键值对冲突")
                    else:
                        pass
                else:
                    pass

                show_index = title.index(show_list[0].strip())
                suit_list = handle(table, con_key)

                for line in suit_list:
                    staff_index = int(line[0]) - 1
                    context[staff_index][show_index] = show_list[1].strip("\",\'")

                print("\033[32mupdate语句执行完成\033[0m")
                print("影响条数:\033[31m%s\033[0m" % len(suit_list))
                file_write(message, table)
        else:
            exit("update语句错误")
Esempio n. 2
0
def uninstall(tablename):
    message = file_read(tablename)
    context = message[1]
    staff_id = input("输入staff_id值:").strip()
    if staff_id.isdigit():
        if 0 < int(staff_id) <= len(context):
            del_info = context[int(staff_id) - 1]
            context.remove(del_info)
            file_write(message, tablename)
            print("\033[31m staff_id: %s删除成功\033[0m" % staff_id)
        else:
            print("\033[41m staff_id超出范围\033[0m")
    else:
        print("\033[41m staff_id字符类型错误\033[0m")
Esempio n. 3
0
def addition(tablename):
    userdate = []
    message = file_read(tablename)
    title = message[0]
    context = message[1]
    staff_id = len(context) + 1
    userdate.append(staff_id)
    for titlename in title[1:]:
        while True:
            info = input("%s:" % titlename).strip()
            if info:
                if titlename == "age" and not info.isdigit():
                    print("%s值不符,请重新输入" % titlename)
                    continue
                elif titlename == "phone":
                    if info.isdigit() and len(info) == 11:
                        if [True for line in context
                                if info in line]:  # info是否存在line中
                            print("phone值冲突")
                            continue
                        else:
                            pass
                    else:
                        print("%s值不符,请重新输入" % titlename)
                        continue

                userdate.append(info)
                break
            else:
                print("\033[31m%s is NULL\033[0m" % titlename)

    context.append(userdate)

    file_write(message, tablename)

    print("用户添加成功")
Esempio n. 4
0
              sg.Button("Delete"),
              sg.Button("Edit"),
              sg.Button("Exit")
          ]]

window = sg.Window("ToDo App", layout)
while True:
    events, values = window.Read()
    if events == 'add_save':
        tasks.append(values['todo_item'])
        window.FindElement('items').Update(values=tasks)
        window.FindElement('add_save').Update("Add")
        window.FindElement('todo_item').Update('')

    elif events == "Delete":
        tasks.remove(values["items"][0])
        window.FindElement('items').Update(values=tasks)
        file_write(fname, tasks)

    elif events == "Edit":
        edit_val = values["items"][0]
        tasks.remove(values["items"][0])
        window.FindElement('items').Update(values=tasks)
        window.FindElement('todo_item').Update(value=edit_val)
        window.FindElement('add_save').Update("Save")
        file_write(fname, tasks)

    elif events == None or events == "Exit":
        break

window.Close()