def delete():
	#check if no records in list
	if(s.recv(1024).decode() != "empty"):
		name = input("Enter Name : ")
		s.send(name.encode())
		
		res = s.recv(1024).decode()
		
		if(res == "empty"):
			return "data is empty so insert records"
			
		elif(res == "success"):
			temp_emp = Emp()
			temp_emp = s.recv(2048)
			temp_emp = pickle.loads(temp_emp)
			print("Name\t\tAge\tSalary")	
			temp_emp.disp()
			
			choice = input("Do You want to delete this Record? Y/N : ")

			s.send(choice.encode())
			return s.recv(1024).decode()
		else:
			return "Record not found"
	else:
		return "No records Found"
def insert():
	e = Emp()
	e.set(input("Name : "),input ("Age : "),input("Sal : "))
	if(e.valid()):
		#if valid record is there
		s.send("insert".encode())
		e = pickle.dumps(e)
		s.send(e)
		res = s.recv(1024).decode()
		return res
	else:
		#if invalid record is there
		s.send("error".encode())
		return s.recv(1024).decode()
Beispiel #3
0
def getinfo(empno):
    with open(filepath) as f:
        lines = f.readlines()
        for line in lines:
            empdata = line.split()
            if int(empdata[0]) == empno:
                emp = Emp()  # 객체 생성
                emp.empno = int(empdata[0])
                emp.ename = empdata[1]
                emp.dept = int(empdata[2])
                emp.sal = int(empdata[3])
                emp.loc = empdata[4]
                emp.tel = empdata[5]
                emp.email = empdata[6]
                return emp
Beispiel #4
0
def getlist():
    with open(filepath) as f:
        lines = f.readlines()
        emplist = []
        for line in lines:
            empdata = line.split()
            emp = Emp() # 객체 생성
            emp.empno = int(empdata[0])
            emp.ename = empdata[1]
            emp.dept = int(empdata[2])
            emp.sal = int(empdata[3])
            emp.loc = empdata[4]
            emp.tel = empdata[5]
            emp.email = empdata[6]
            emplist.append(emp)
        return emplist
Beispiel #5
0
def string2dic(string):
    info = string.split()
    infodic = {}
    infodic['empno'] = int(info[0])
    infodic['ename'] = info[1]
    infodic['salary'] = int(info[2])
    infodic['deptno'] = int(info[3])
    # Emp instance 생성
    e = Emp(infodic['empno'], infodic['ename'], infodic['salary'],
            infodic['deptno'])
    return infodic
def update():
	#check if no records in list
	if(s.recv(1024).decode() != "empty"):
		name = input("Enter Name of Employee: ")
		s.send(name.encode())
		
		res=s.recv(1024).decode()
		
		if(res == "success"):
			e = s.recv(1024)
			e = pickle.loads(e)
			
			print("Name\t\tAge\tSalary")	
			e.disp()
			
			temp_emp = Emp()
			
			temp_emp.name = input("Enter Name : ")
			temp_emp.age = input("Enter Age : ")
			temp_emp.sal = input("Enter Salary : ")
			
			if(temp_emp.valid()):
				s.send("update".encode())
				temp_emp = pickle.dumps(temp_emp)
				s.send(temp_emp)
				res = s.recv(1024).decode()
				return res
				
			else:
				s.send("keep safe".encode())
				return s.recv(1024).decode()
			
		else:
			return "Record Not Found"
	else:
		return "No records Found"
from emp import Emp

emp1 = Emp("john", "Engineer", 3000, "R&D", 4, 2)

emp1.Canpromote()
# result = emp1.Canpromote()
# print(result)

result = emp1.CP()
print(result)