示例#1
0
 def delete_position_name(self):
     # Create a connection
     con = Connection()
     db = con.connect()
     cursor = db.cursor()
     query = "DELETE FROM positions WHERE position_id=%s"
     value = (self._position_id, )
     cursor.execute(query, value)
     db.commit()
     db.close()
示例#2
0
 def insert_position_name(self):
     # Create a connection
     con = Connection()
     db = con.connect()
     cursor = db.cursor()
     query = "INSERT INTO positions(position_name) VALUES(%s)"
     value = (self._position_name, )
     cursor.execute(query, value)
     db.commit()
     db.close()
示例#3
0
 def update_position_name(self):
     # Create a connection
     con = Connection()
     db = con.connect()
     cursor = db.cursor()
     query = "UPDATE positions SET position_name=%s WHERE position_id=%s"
     values = (self._position_name, self._position_id)
     cursor.execute(query, values)
     db.commit()
     db.close()
 def update_department_name(self):
     # Create a connection
     con = Connection()
     db = con.connect()
     cursor = db.cursor()
     query = "UPDATE departments SET department_name=%s WHERE department_id=%s"
     values = (self._department_name, self._department_id)
     cursor.execute(query, values)
     db.commit()
     db.close()
 def delete_department_name(self):
     # Create a connection
     con = Connection()
     db = con.connect()
     cursor = db.cursor()
     query = "DELETE FROM departments WHERE department_id=%s"
     value = (self._department_id, )
     cursor.execute(query, value)
     db.commit()
     db.close()
示例#6
0
 def delete_employee_record(self):
     # Create a connection
     con = Connection()
     db = con.connect()
     cursor = db.cursor()
     query = "DELETE FROM employees WHERE uid=%s;"
     value = (self._uid,)
     cursor.execute(query, value)
     db.commit()
     db.close()
示例#7
0
 def extract_employee_info(self, uid_to_extract):
     # Create a connection
     con = Connection()
     db = con.connect()
     cursor = db.cursor()
     query = "SELECT * FROM employees WHERE rfid_uid=%s;"
     value = (uid_to_extract,)
     cursor.execute(query, value)
     result = cursor.fetchall()
     db.close()
     return result
示例#8
0
 def check_if_uid_already_exist(self, uid_to_check):
     # Create a connection
     con = Connection()
     db = con.connect()
     cursor = db.cursor()
     query = "SELECT * FROM employees WHERE rfid_uid=%s;"
     value = (uid_to_check,)
     cursor.execute(query, value)
     cursor.fetchall()
     db.close()
     return cursor.rowcount > 0
示例#9
0
 def update_employee_record(self):
     # Create a connection
     con = Connection()
     db = con.connect()
     cursor = db.cursor()
     query = "UPDATE employees SET first_name=%s, middle_name=%s, last_name=%s, age=%s, address=%s, \
         email=%s, contact_number=%s, employee_image=%s WHERE rfid_uid=%s;"
     values = (self._first_name, self._middle_name, self._last_name, self._age, self._address, \
         self._email, self._contact_number, self.employee_image, self._uid)
     cursor.execute(query, values)
     db.commit()
     db.close()
示例#10
0
 def insert_employee_record(self):
     # Create a connection
     con = Connection()
     db = con.connect()
     cursor = db.cursor()
     query = "INSERT INTO employees(rfid_uid, first_name, middle_name, \
         last_name, age, gender, address, email, contact_number, employee_image) \
         VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s);"
     values = (self._uid, self._first_name, self._middle_name, self._last_name, self._age, 
         self._gender, self._address, self._email, self._contact_number, self._employee_image)
     cursor.execute(query, values)
     db.commit()
     db.close()
示例#11
0
        print("Department Called")


######### POSITION CLASS ########
class Position:
    def __init__(self):
        print("Position Called")


########## FUNCTION FOR CHOOSED WINDOW ############
def switch_to_other_window(choosed_window):
    if choosed_window == 1:
        employee = Employee()

    elif choosed_window == 2:
        department = Department()

    else:
        position = Position()


choosed_window = choose_window()

switch_to_other_window(choosed_window)

###TESTING####
connectDB = Connection()

time.sleep(2)
print(connectDB.connect())
示例#12
0
from tkinter import *
from tkinter import ttk, filedialog, messagebox
from PIL import ImageTk, Image
from classes.Employee import Employee

# If database not found, create one then delete the 'con' object
try:
    from classes.Connection import Connection
    con = Connection()
except:
    con.create_database('msc_database')
finally:
    del con

# If table 'employees' not found, create one then delete the 'con' object
try:
    from classes.Connection import Connection
    con = Connection()
    con.create_employee_table('employees')
except Exception:
    pass
finally:
    del con

root = Tk()


class MainWindow:
    #para widget ng mainform
    def __init__(self, root, *args, **kwargs):
示例#13
0
from classes.Connection import Connection
from classes.ArrayConfig import ArrayConfig

# Dependency Injection
# Purpose : To implement a loosely coupled architecture in order to get better stable, maintainable and extendable code
# ArrayConfig is injected into Connection.
# A Connection (client) just use two functions get and set of config object is defined from an interface Parameters
# and don't care about how config object is implemented

config = ArrayConfig({})
config.set('host', 'localhost')

connection = Connection(config)
connection.connect()
print(connection.get_host())