def LoadPhongBan(self): conn = create_connection("DataConnect/DiemDanhDatabse.db") rows = GetPhongBan(conn) self.txtPhongBan.clear() for row in rows: self.txtPhongBan.addItem(row[1])
def ThemMoi(self): KiemTra = self.CheckForm() if (KiemTra == 0): self.ShowWarning("Vui Lòng Nhập đầy đủ thông tin") else: conn = create_connection('DataConnect/DiemDanhDatabse.db') with conn: tenNhanVien = self.txtHoTen.text() tuoi = self.txtTuoi.value() gioitinh = self.txtGioiTinh.currentText() dienthoai = self.txtSoDienThoai.text() chucvu = self.txtChucVu.currentText() MaChucVu = getMaChucVu(conn, chucvu) phongban = self.txtPhongBan.currentText() MaPhongBan = getMaPhongBan(conn, phongban) DiaChi = self.txtDiaChi.text() Email = self.txtEmail.text() DienThoai = self.txtSoDienThoai.text() task = TaskNhanVien(tenNhanVien, gioitinh, tuoi, DiaChi, Email, DienThoai, MaChucVu, MaPhongBan) result = InsertNhanVien(conn, task) if result == 0: self.ShowWarning("Thông tin trùng khớp, vui lòng xem lại") else: self.MaNV = GetLastIDNhanVien(conn) self.GhiMANV(str(self.MaNV)) self.ShowRequest() self.ClearForm() self.ShowListNhanVien()
def SuaNhanVien(self): self.MaNV = self.LbMaNhanVien.text() if (self.MaNV.strip()): conn = create_connection('DataConnect/DiemDanhDatabse.db') with conn: if (self.CheckForm() == 1): tenNhanVien = self.txtHoTen.text() tuoi = self.txtTuoi.value() gioitinh = self.txtGioiTinh.currentText() chucvu = self.txtChucVu.currentText() MaChucVu = getMaChucVu(conn, chucvu) phongban = self.txtPhongBan.currentText() MaPhongBan = getMaPhongBan(conn, phongban) DiaChi = self.txtDiaChi.text() Email = self.txtEmail.text() DienThoai = self.txtSoDienThoai.text() task = TaskNhanVien(tenNhanVien, gioitinh, tuoi, DiaChi, Email, DienThoai, MaChucVu, MaPhongBan) result = UpdateNhanvien(conn, self.MaNV, task) if result == 0: self.ShowWarning( "Thông tin trùng khớp, vui lòng xem lại") else: self.GhiMANV(self.MaNV) self.ShowRequest() self.ClearForm() else: print("Nhập đầy đủ thông tin đi ba") else: self.ShowWarning("Vui Lòng Nhập Chọn Nhân Viên Cần Chỉnh Sửa") self.ShowListNhanVien()
def Chup(self,GrayID,MaNV): if (MaNV == None): conn = create_connection('DataConnect/DiemDanhDatabse.db') MaNV = GetLastIDNhanVien(conn) print("Mã nhân viên cuối cùng là " + str(MaNV)) self.count+=1 if self.count <=100 : cv2.imwrite("Face_Recognition/DataSet/ImageLibrary/User." + str(MaNV) + '.' + str(self.count) + ".jpg",GrayID)
def __init__(self): super(MyWindow,self).__init__() uic.loadUi('Gui/Login.ui',self) self.DataBase = "DataConnect/DiemDanhDatabse.db" self.Conn = create_connection(self.DataBase) self.setWindowTitle('Đăng nhập') self.txtPassWord.setEchoMode(QtWidgets.QLineEdit.Password) self.btnHuy.clicked.connect(self.ExitApp) self.btnDangNhap.clicked.connect(self.DangNhap)
def XoaNhanVien(self): MaNV = self.LbMaNhanVien.text() if (MaNV.strip()): conn = create_connection('DataConnect/DiemDanhDatabse.db') with conn: DeleteNhanVien(conn, MaNV) self.ClearForm() else: self.ShowWarning("Vui Lòng Chọn Nhân Viên Cần Xóa") self.ShowListNhanVien()
def __init__(self): super(MyWindow,self).__init__() uic.loadUi('Gui/CreateAccount.ui',self) self.txtPassword.setEchoMode(QtWidgets.QLineEdit.Password) self.txtConfirm.setEchoMode(QtWidgets.QLineEdit.Password) self.DataBase = "DataConnect/DiemDanhDatabse.db" self.Conn = create_connection(self.DataBase) self.setWindowTitle('Tạo mới tài khoản') self.btnCancel.clicked.connect(self.ExitApp) self.btnCreateAccount.clicked.connect(self.ThemTaiKhoan)
def __init__(self): super(MyWindow, self).__init__() uic.loadUi('Gui/QuanLyPhongBan.ui', self) self.setWindowTitle('Quản Lý Phòng Ban') self.TablePhongBan.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.ShowListPhongBan() self.DataBase = "DataConnect/DiemDanhDatabse.db" self.Conn = create_connection(self.DataBase) self.btnThemPhong.clicked.connect(self.ThemPhongBan) self.btnCapNhat.clicked.connect(self.SuaPhongBan)
def __init__(self): super(MyWindow, self).__init__() uic.loadUi('Gui/ChangePass.ui', self) self.DataBase = "DataConnect/DiemDanhDatabse.db" self.Conn = create_connection(self.DataBase) self.setWindowTitle('Đổi Mật Khẩu') self.txtOldPass.setEchoMode(QtWidgets.QLineEdit.Password) self.txtNewPass.setEchoMode(QtWidgets.QLineEdit.Password) self.txtConfirm.setEchoMode(QtWidgets.QLineEdit.Password) self.btnChangePass.clicked.connect(self.DoiPass) self.btnCancel.clicked.connect(self.ExitApp) self.Email = self.ReadFileSecc() self.txtEmail.setText(self.Email)
def __init__(self, parent=None): super(MyWindow, self).__init__(parent) #self.resize(300, 200) uic.loadUi('Gui/QuanLyChucVu.ui', self) self.setWindowTitle('Quản Lý Chức Vụ') self.TableChucVu.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.ShowListChucVu() self.txtMaChucVu.setText("") self.DataBase = "DataConnect/DiemDanhDatabse.db" self.Conn = create_connection(self.DataBase) self.btnThemChucVu.clicked.connect(self.ThemChucVu) self.btnSuaChucVu.clicked.connect(self.SuaChucVu)
def ExportCSV(): conn = create_connection("DataConnect/DiemDanhDatabse.db") conn.text_factory = str ## my current (failed) attempt to resolve this cur = conn.cursor() data = cur.execute("select * from DiemDanh") f = open("Report.csv", "w+") for row in data: numberCol = len(row) indexCol = 0 for col in row: indexCol += 1 if indexCol == numberCol: f.write(str(col) + "\n") else: f.write(str(col) + ",")
def Export_DiemDanh(MaNV, StartDate, EndDate, file): conn = create_connection("DataConnect/DiemDanhDatabse.db") conn.text_factory = str ## my current (failed) attempt to resolve this cur = conn.cursor() data = cur.execute("select Ngay,Gio from DiemDanh where MaNV=" + str(MaNV) + " and Ngay >= '" + str(StartDate) + "' and Ngay <= '" + str(EndDate) + "'") file.write( "Date,In,Out,In,Out,In,Out,In,Out,In,Out,In,Out,In,Out,In,Out,In,Out,In,Out\n" ) index = 0 for row in data: if index == 0: this.Ngay = row[0] file.write(str(this.Ngay) + ",") index += 1 else: GetTimeViaDay(row, file)
def DoiPass(self): Email = self.txtEmail.text() OldPass = self.txtOldPass.text() NewPass = self.txtNewPass.text() Confirm = self.txtConfirm.text() result = self.CheckForm(OldPass, NewPass, Confirm) CheckPass = Login(self.Conn, self.Email, OldPass) if result == 1: if CheckPass == 1: Conn = create_connection('DataConnect/DiemDanhDatabse.db') with Conn: KQ = ChangePassWord(Conn, Email, NewPass) if KQ == 1: self.showQMessageBox("Đổi Mật Khẩu Thành Công") else: self.ShowWarning("Thay Đổi Thất Bại") else: self.ShowWarning("Password Không Chính xác !!!")
def DiemDanh(self, GrayID): self.MaNV = self.recognizer.predict(GrayID) if self.face_ID == None: self.face_ID = self.MaNV[0] self.completed = 0 self.default = 50 else: if self.MaNV[0] == self.face_ID: self.count += 1 self.completed += 100 / self.default else: self.face_ID = self.MaNV[0] self.Count = 0 self.completed = 0 if self.count >= self.default: self.Conn = create_connection('DataConnect/DiemDanhDatabse.db') self.Profile = GetNhanVien(self.Conn, self.MaNV[0]) if self.Profile != None: for row in self.Profile: print(row) self.txtTen.setText(row[1]) self.txtPhong.setText(str(row[8])) self.txtMaNV.setText(str(row[0])) time = QTime.currentTime().toString() self.txtTime.setText(time) self.progress.setValue(100) self.lbWaitting.setText("Xin Cám Ơn") with self.Conn: InsertDiemDanh(self.Conn, self.MaNV[0]) self.face_enable = False else: self.txtTen.setText("Unknow") self.txtPhong.setText("Unknow") self.txtMaNV.setText("Unknow") self.progress.setValue(self.completed) if self.lbWaitting.text() == "Xin Cám Ơn": self.ReSet()
def LoadChucVu(self): conn = create_connection("DataConnect/DiemDanhDatabse.db") rows = GetChucVu(conn) self.txtChucVu.clear() for row in rows: self.txtChucVu.addItem(row[1])