def log(): if user.userlogcheck(): user.userlogout() user.changeuserbar(homeui) homeui.status.setText("logged out successfully") else: login.login(homeui)
def delaccount(): userid = user.getuser() user.userlogout() conn = sqlite3.connect("database.db") with conn: cmd = conn.cursor() cmd.execute(''' delete from users where user_id=? ''', (userid, )) cmd.execute( ''' delete from investment where user_id=? ''', (userid, )) cmd.execute( ''' delete from user_status where userid=? ''', (userid, )) cmd.execute( ''' delete from user_phone where user_id=? ''', (userid, )) cmd.execute( ''' delete from gen_account where user_id=? ''', (userid, )) cmd.execute( ''' delete from pro_account where user_id=? ''', (userid, )) conn.close() os.remove("userimg/" + str(userid) + ".jpg") user.changeuserbar(homeui) homeui.status.setText("account deleted successfully") exitb()
def validate_id(): userid = loginui.userid.text() pwd = loginui.pwd.text() err = loginui.err err.hide() s = True if len(userid) == 0: err.setText("enter userid") err.show() s = False return False if len(pwd) == 0: err.setText("enter password") err.show() s = False return False conn = sqlite3.connect("database.db") with conn: cmd = conn.cursor() cmd.execute( ''' select * from users where user_id=? ''', (userid, )) r = cmd.fetchall() conn.close() if len(r) == 0: err.setText("no account found.") err.show() s = False return False else: u = r[0] if pwd != u[4]: err.setText("password incorrect.") err.show() s = False return False if s: user.userlogout() user.userlogin(userid) user.changeuserbar(homeui) homeui.status.setText("logged in successfully") exitb()
def validate_reg(): s = True fname = regui.fname.text() lname = regui.lname.text() email = regui.email.text() userid = regui.userid.text() pwd = regui.pwd.text() repwd = regui.repwd.text() phonep = regui.phonep.text() phones = regui.phones.text() acctype = regui.acctype.currentText() phoneperr = regui.phoneperr phoneserr = regui.phoneserr phoneperr.hide() phoneserr.hide() ferr = regui.fname_error ferr.hide() eerr = regui.email_error eerr.hide() iderr = regui.id_error iderr.hide() pwderr = regui.pwd_error pwderr.hide() if len(fname) < 2: ferr.setText("enter valid name") ferr.show() s = False if check_email(email) == False: eerr.setText("enter valid email") eerr.show() s = False if len(userid) < 7: iderr.setText("userid should be more than 7 character") iderr.show() s = False if pwd != repwd: pwderr.setText("password does not match") pwderr.show() s = False if len(pwd) < 8: pwderr.setText("password should be more than 8 character") pwderr.show() s = False if check_phone(phonep) == False: phoneperr.setText("enter valid phone number") phoneperr.show() s = False if check_phone(phones) == False: phoneserr.setText("enter valid phone number") phoneserr.show() s = False conn = sqlite3.connect("database.db") with conn: cmd = conn.cursor() cmd.execute("select * from users where user_id=?", (userid, )) u = cmd.fetchall() cmd.execute("select * from users where email=?", (email, )) e = cmd.fetchall() cmd.execute("select * from user_phone where phone_number=?", (phonep, )) p = cmd.fetchall() cmd.execute("select * from user_phone where phone_number=?", (phones, )) pp = cmd.fetchall() conn.close() if len(u) > 0: iderr.setText("userid not availaible") iderr.show() s = False if len(e) > 0: eerr.setText("email already registered") eerr.show() s = False if len(p) > 0: phoneperr.setText("number already registered") phoneperr.show() s = False if len(pp) > 0: phoneserr.setText("number already registered") phoneserr.show() s = False if phonep == phones: phoneserr.setText("enter another phone number") phoneserr.show() s = False if s: t = (userid, fname, lname, email, pwd, acctype, 0) conn = sqlite3.connect("database.db") with conn: cmd = conn.cursor() cmd.execute("insert into users values(?,?,?,?,?,?,?)", t) cmd.execute("insert into user_phone values(?,?)", (userid, phonep)) cmd.execute("insert into user_phone values(?,?)", (userid, phones)) if acctype == "general": cmd.execute( ''' insert into gen_account values(?,?) ''', (userid, user.perstockprice)) elif acctype == "professional": cmd.execute( ''' insert into pro_account values(?,?) ''', (userid, user.peryearprice)) conn.close() user.userlogout() user.userlogin(userid) user.changeuserbar(homeui) uploadimg(userid) homeui.status.setText("registered successfully") exitb()
def stockdbsearch(): searchdb.searchdb(homeui) def deal(): if user.userlogcheck(): homeui.status.setText("") dealing.dealing(homeui) else: homeui.status.setText("login to buy and sell stocks") def hidnotify(): homeui.status.setText("") user.changeuserbar(homeui) homeui.logbutton.clicked.connect(log) homeui.regbutton.clicked.connect(reg) homeui.stockdata.clicked.connect(sdata) homeui.stocksearch.clicked.connect(stksearch) homeui.profile.clicked.connect(prof) homeui.searchdbbutton.clicked.connect(stockdbsearch) homeui.dealbutton.clicked.connect(deal) homeui.exitbutton.clicked.connect(exit) homeui.status.setAlignment(QtCore.Qt.AlignCenter) homeui.userid.setAlignment(QtCore.Qt.AlignCenter) homeui.show() app.exec()
def logb(): user.userlogout() user.changeuserbar(homeui) homeui.status.setText("logged out successfully") exitb()