Ejemplo n.º 1
0
	def search(id):
		cnx=DBconnection.connect()
		cur=cnx.cursor()
		query="select * from user where userid=%s"
		data=[]
		data.append(id)
		cur.execute(query,data)
		d=cur.fetchall()
		if cur.rowcount==0:
			cur.close()
			cnx.close()
			return None
		for i in d:
			u=User()
			u.setUserid(int(i[0]))
			u.setUsername(i[1])
			u.setPassword(i[2])
			u.setUsertype(i[3])
			u.setUserstatus(bool(i[4]))
			u.setName(i[5])
			u.setEmail(i[6])
			u.setContact(i[7])
			u.setAddress(i[8])
			u.setGender(bool(i[9]))
		cur.close()
		cnx.close()
		return u
Ejemplo n.º 2
0
 def btn_save_clicked(self):
     self.userid.config(state="normal")
     usr = User()
     usr.setUserid(self.userid.get())
     self.userid.config(state="disabled")
     usr.setName(self.name.get())
     usr.setEmail(self.email.get())
     usr.setContact(self.contact.get())
     usr.setAddress(self.address.get(1.0, "end"))
     usr.setGender(int(self.gender.get()))
     if UMS.updateProfile(usr):
         messagebox.showinfo("Edit user record",
                             "User record updated successfully")
     else:
         messagebox.showerror("Edit user record", "Error")
     self.btn_save.config(state="disabled")
     self.btn_edit.config(state="normal")
     self.usr = UMS.search(self.uid)
     self.showrecord()
Ejemplo n.º 3
0
	def view():
		ulist=[]
		cnx=DBconnection.connect()
		cur=cnx.cursor()
		query="select * from user"
		cur.execute(query)
		d=cur.fetchall()
		for i in d:
			u=User()
			u.setUserid(int(i[0]))
			u.setUsername(i[1])
			u.setPassword(i[2])
			u.setUsertype(i[3])
			u.setUserstatus(bool(i[4]))
			u.setName(i[5])
			u.setEmail(i[6])
			u.setContact(i[7])
			u.setAddress(i[8])
			u.setGender(bool(i[9]))
			ulist.append(u)
		cur.close()
		cnx.close()
		return ulist
Ejemplo n.º 4
0
 def btn_save_clicked(self):
     usr = User()
     usr.setUsertype(self.usertype.get())
     usr.setUserstatus(int(self.userstatus.get()))
     usr.setName(self.name.get())
     usr.setEmail(self.email.get())
     usr.setContact(self.contact.get())
     usr.setAddress(self.address.get(1.0, "end"))
     usr.setGender(int(self.gender.get()))
     if self.add_edit_flag == "add":
         usr.setUsername(self.username.get())
         usr.setPassword("user")
         if UMS.add(usr) == True:
             messagebox.showinfo(
                 "Add User",
                 "User record added Succesfully, default password is 'user'"
             )
         else:
             messagebox.showerror("Add User", "User record already exists")
     elif self.add_edit_flag == "edit":
         self.userid.config(state="normal")
         usr.setUserid(self.userid.get())
         self.userid.config(state="disabled")
         if UMS.updateUser(usr):
             messagebox.showinfo("Edit user record",
                                 "User record updated successfully")
         else:
             messagebox.showerror("Edit user record", "Error")
     self.btn_save.config(state="disabled")
     self.btn_add.config(state="normal")
     self.btn_edit.config(state="normal")
     self.userlist = UMS.view()
     if self.add_edit_flag == "add":
         self.current_index = len(self.userlist) - 1
     self.add_edit_flag = "view"
     self.showrecord()