员工管理信息的删增功能

# ##员工信息
# 1.可进行模糊查询,语法至少支持下面3中:
#     1.select name ,age from staff_table where age>22
#     选择姓名,年龄在22岁以上的员工的年龄
#     2.select * from staff_table where dept = "it"
#     从员工表中选择“it”
#     3.select * from staff_table where enroll like "2013"
#     从员工表中选择“2013”
#     4.查到的信息,打印后,到最后还要显示查到的条数
# 2.可创建新员工记录,以phone做唯一键,staff_id需要自增
# 3.可删除指定员工信息,输入id名即可删除
# 4.可修改员工信息,语法如下:
#     update staff_table set dept = “Market” where dept = “IT”
#     更新stafftable集dept="Market",其中部门="IT"

##读取数据列表
EmployeesList = []
def CirculationList(ReaDinG):
    for ReaDLine in ReaDinG:
        ReaDList = ReaDLine.strip("\n").split(",")
        EmployeesList.append(ReaDList)
        # print(ReaDList)
def list_():
    print("编号\t姓名\t\t性别\t年龄\t职位\t电话\t\t 入职日期")
    for Employees in EmployeesList:
        print("%s\t\t%s\t\t%s\t\t %s\t\t%s\t\t%s\t %s" % (Employees[0],
                                                          Employees[1],
                                                          Employees[2],
                                                          Employees[3],
                                                          Employees[4],
                                                          Employees[5],
                                                          Employees[6]))

##员工读取数据列表
ReaDing = open("file_1.txt","r",encoding="utf-8")
ReaDinG = ReaDing.readlines()
ReaDList = CirculationList(ReaDinG)
ReaDing.close()
n = 0
while n<1:
    list_()
    print("*"*65)
    print("查询/创建/删除/修改")
    EmployeesInput = input("选择您的操作->")
    if EmployeesInput == "查询":
        print("姓名/年龄/2013")
    elif EmployeesInput =="创建":
        serialNumber = "G%d"% (len(EmployeesList)+ 1)
        nameIn = input("请您输入姓名:-》")
        genderIn = input("请您输入性别:-》")
        ageIn = input("请您输入年龄:-》")
        jobIn = input("请您输入职位:-》")
        phoneIn = input("请您输入电话:-》")
        dateIn = input("请您输入入职日期:-》")
        creator = [serialNumber,nameIn,genderIn,ageIn,jobIn,phoneIn,dateIn]

        EmployeesList.append(creator)
        print("您成功添加了%s" % nameIn)
        continue
    elif EmployeesInput =="删除":
        nameInr = input("请输入要删除的员工:")
        for NameInr in EmployeesList:
            i = 0
            if NameInr[1] == nameInr:
                print(NameInr[1])
                EmployeesList.remove(NameInr)

                Reaing = open("file_1.txt", "w", encoding="utf-8")
                for ReainG in EmployeesList:
                    ReanG = ','.join(ReainG)+"\n"
                    Reaing.write(ReanG)

                Reaing.close()

                break
            i += 1
    else:##修改
        pass
    n+=1

 

posted @ 2018-04-24 20:35  Caionk  阅读(229)  评论(0编辑  收藏  举报