Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if request.method == "POST" and 'Click' in request.POST:
- if request.method == "POST" and 'Click' in request.POST:
- print("ID is : ")
- print(id)
- name = request.POST['name']
- designation = request.POST['designation']
- salary = request.POST['salary']
- password = request.POST['password']
- username = request.POST['username']
- #
- branch = request.POST['branch']
- branch_no = ""
- if branch :
- branch_no = branch[len(branch) - 1]
- #
- hashed_password = hashlib.md5(password.encode('utf-8')).hexdigest()
- if not branch_no:
- sql = "SELECT BRANCH_ID FROM BRANCH_EMPLOYEE WHERE EMPLOYEE_ID = %s"
- cursor = connection.cursor()
- cursor.execute(sql, [id])
- result = cursor.fetchall()
- cursor.close()
- name = result[0][0]
- if not name:
- sql = "SELECT NAME FROM EMPLOYEES WHERE EMPLOYEE_ID = %s"
- cursor = connection.cursor()
- cursor.execute(sql, [id])
- result = cursor.fetchall()
- cursor.close()
- name = result[0][0]
- if not designation:
- sql = "SELECT DESIGNATION FROM EMPLOYEES WHERE EMPLOYEE_ID = %s"
- cursor = connection.cursor()
- cursor.execute(sql, [id])
- result = cursor.fetchall()
- cursor.close()
- designation = result[0][0]
- if not salary:
- sql = "SELECT SALARY FROM EMPLOYEES WHERE EMPLOYEE_ID = %s"
- cursor = connection.cursor()
- cursor.execute(sql, [id])
- result = cursor.fetchall()
- cursor.close()
- salary = result[0][0]
- if not password:
- sql = "SELECT PASSWORD FROM EMPLOYEES WHERE EMPLOYEE_ID = %s"
- cursor = connection.cursor()
- cursor.execute(sql, [id])
- result = cursor.fetchall()
- cursor.close()
- hashed_password = result[0][0]
- if not username:
- sql = "SELECT USERNAME FROM EMPLOYEES WHERE EMPLOYEE_ID = %s"
- cursor = connection.cursor()
- cursor.execute(sql, [id])
- result = cursor.fetchall()
- cursor.close()
- username = result[0][0]
- cursor = connection.cursor()
- print([name, designation, salary, username, hashed_password, id])
- sql = "UPDATE EMPLOYEES SET NAME = '" + name + "',DESIGNATION = '" + designation + "' ,SALARY = " \
- + salary + " ,USERNAME='" + username + "' ,PASSWORD='" + hashed_password + "' WHERE EMPLOYEE_ID=" + str(
- id)
- cursor.execute(sql)
- connection.commit()
- cursor.close()
- cursor = connection.cursor()
- print(branch_no)
- sql = "UPDATE BRANCH_EMPLOYEE SET BRANCH_ID = %s WHERE EMPLOYEE_ID = %s"
- cursor.execute(sql,[branch_no, id])
- connection.commit()
- cursor.close()
- return redirect(show_employees)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement