Guest User

Untitled

a guest
Feb 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.79 KB | None | 0 0
  1. '''
  2. By Ronald Colyar 1/26/18
  3. '''
  4. #MODULES
  5. import tkinter as tk
  6. import sqlite3
  7. from tkinter import *
  8. from tkinter import ttk
  9. #files
  10. conn = sqlite3.connect('login.db')
  11. c = conn.cursor()
  12. conn2 = sqlite3.connect('investments.db')
  13. c2 = conn2.cursor()
  14.  
  15.  
  16. class SignUp:
  17. def __init__(self , master):
  18. self.master = master
  19. master.config(background = 'black')
  20. master.title(string = 'Sign Up window')
  21. master.iconbitmap('phantex.ico')
  22. #placing of the window
  23. w = 270
  24. h = 380
  25. ws = master.winfo_screenwidth()
  26. hs = master.winfo_screenheight()
  27. x = (ws/2) - (w/2)
  28. y = (hs/2) - (h/2)
  29. master.geometry('%dx%d+%d+%d' % (w,h,x , y))
  30. #creation of labels
  31. self.signup_label = tk.Label(master, text = 'Sign Up', fg = 'white' , bg = 'black', font = 'times 15 bold').grid(row = 0 , column = 0 ,columnspan = 2, sticky = 'we')
  32. self.firstname_label =tk.Label(master, text = 'First ( Atleast 3)', fg = 'white' , bg = 'black').grid(row = 1 , column = 0 , sticky = 'we')
  33. self.lastname_label =tk.Label(master, text = 'Last (Atleast 3)', fg = 'white' , bg = 'black').grid(row = 1 , column = 1 , sticky = 'we')
  34. self.username_label = tk.Label(master, text = 'Username (Atleast 6)', fg = 'white' , bg = 'black').grid(row = 3 , column = 0 ,columnspan = 2, sticky = 'we')
  35. self.password_label = tk.Label(master, text= 'Password (Atleast 6)' , fg = 'white' , bg = 'black').grid(row = 5 , column = 0 ,columnspan = 2,sticky = 'we')
  36. self.acctype_label = tk.Label(master, text= 'Type of Investment account' , fg = 'white' , bg = 'black').grid(row = 7 , column = 0 ,columnspan = 2, sticky = 'we')
  37. self.titletype_label = tk.Label(master, text= 'Title' , fg = 'white' , bg = 'black').grid(row = 9 , column = 0 ,columnspan = 2, sticky = 'we')
  38. self.buisness_label = tk.Label(master, text= 'Buisness Name (Optional)' , fg = 'white' , bg = 'black').grid(row = 11 , column = 0 ,columnspan = 2, sticky = 'we')
  39. self.verification_label = tk.Label(master, text= 'Status:' , fg = 'white' , bg = 'black')
  40. self.verification_label.grid(row = 15 , column = 0 ,columnspan = 3, sticky = 'we')
  41. #creation of entrys
  42. self.firstname = ttk.Entry(master)
  43. self.firstname.grid(row = 2 , column = 0 , sticky = 'we')
  44. self.lastname = ttk.Entry(master)
  45. self.lastname.grid(row = 2 , column = 1 , sticky = 'we', padx = 5, pady = 5)
  46. self.username = ttk.Entry(master)
  47. self.username.grid(row = 4 , column = 0 ,columnspan = 2, sticky = 'we')
  48. self.password = ttk.Entry(master, show ='*')
  49. self.password.grid(row = 6 , column = 0 ,columnspan = 2, sticky = 'we')
  50. self.buisness = ttk.Entry(master)
  51. self.buisness.grid(row = 12 , column = 0 ,columnspan = 2, sticky = 'we')
  52. #creation of option menus
  53. self.options = ['Select' ,'Stock' ,'multiple', 'Real Estate' , 'Bonds' , 'intellectual property' , 'Buisness','Other']
  54. self.accvar = StringVar()
  55. self.accounttype = ttk.OptionMenu(master , self.accvar, *self.options ).grid(row = 8, column = 0 ,columnspan = 2, sticky = 'we')
  56. self.options2 = ['Dr.' , 'Mr.' , 'Mrs.' , 'Ms.' , 'Sir.','Miss.']
  57. self.titlevar = StringVar()
  58. self.titletype = ttk.OptionMenu(master , self.titlevar, *self.options2 ).grid(row = 10, column = 0 ,columnspan = 2, sticky = 'we')
  59. #creation of buttons
  60. submit = tk.Button(master, text = 'Submit', fg = 'white' , bg = 'black' , command = submit_mthd).grid(row = 13 , column = 0 , sticky = 'we' , columnspan =3)
  61. backwardsbutton = tk.Button(master , text = 'Back <--', fg = 'white' , bg = 'black' , command = signupback_mthd).grid(row = 14 , column = 0 , sticky = 'we' , columnspan =3)
  62.  
  63. def change(self , verification):
  64. self.verification_label.configure(text =verification )
  65.  
  66. def submit_mthd():
  67. #storing the values in variables makes it a bit easier to read
  68. firstname_data = signup_obj.firstname.get()
  69. lastname_data = signup_obj.lastname.get()
  70. username_data = signup_obj.username.get()
  71. password_data = signup_obj.password.get()
  72. buisness_data = signup_obj.buisness.get()
  73. accounttype_data = signup_obj.accvar.get()
  74. title_data = signup_obj.titlevar.get()
  75. c.execute("SELECT * FROM login WHERE user =:user", {'user' : str(username_data)})
  76. contents = c.fetchall()
  77.  
  78. #checking the length of the entrys
  79. if len(str(firstname_data)) < 3 or len(str(lastname_data)) < 3 or len(str(username_data)) < 6 or len(str(password_data))<6:
  80. signup_obj.change('Status: Please Fill Out Full Application')
  81.  
  82. elif len(contents) > 0:
  83. signup_obj.change( 'Username Already Taken on this system')
  84.  
  85. #saving all information and updating the status
  86. else:
  87. c.execute("INSERT INTO login VALUES (?, ? , ?, ?, ? , ? , ?)", ((firstname_data) , (lastname_data) , (username_data) ,(password_data) , (accounttype_data) , (title_data) , (buisness_data)))
  88. signup_obj.change('Status : Account created')
  89. conn.commit()
  90.  
  91.  
  92. class SignInGui:
  93. def __init__(self , master):
  94. self.master = master
  95. master.title(string = 'Sign In')
  96. master.resizable(width = False , height = False)
  97. master.iconbitmap('phantex.ico')
  98. #aesthetics
  99. master.config(background='black')
  100. photo = PhotoImage(file = 'Phantex.png')
  101. Phantex_image = tk.Label(master, image = photo, fg = 'white' , bg = 'black')
  102. Phantex_image.image = photo
  103. Phantex_image.grid(row =7 , column = 0 , sticky = 'we' )
  104. #placing of the window
  105. w = 370
  106. h = 250
  107. ws = master.winfo_screenwidth()
  108. hs = master.winfo_screenheight()
  109. x = (ws/2) - (w/2)
  110. y = (hs/2) - (h/2)
  111. master.geometry('%dx%d+%d+%d' % (w,h,x , y))
  112. #creation of entrys
  113. self.username = ttk.Entry(master)
  114. self.username.grid(row = 2 , column = 0 , sticky = 'we')
  115. self.password = ttk.Entry(master, show ='*')
  116. self.password.grid(row = 4 , column = 0 , sticky = 'we')
  117. #creation of labels
  118. self.title = tk.Label(master, text = 'Investment Tracker',font = 'times 14 bold', fg = 'white' , bg = 'black' ).grid(row = 0 , column = 0 , sticky ='we' )
  119. self.username_label = tk.Label(master, text = 'Username', fg = 'white' , bg = 'black').grid(row = 1 , column = 0 , sticky = 'we')
  120. self.password_label = tk.Label(master, text= 'Password' , fg = 'white' , bg = 'black').grid(row = 3 , column = 0 , sticky = 'we')
  121. self.status_label = tk.Label(master, text= None , fg = 'Red' , bg = 'black' , font = 'times 9')
  122. self.status_label.grid(row = 8 , column = 0 , sticky = 'we')
  123. #creation of buttons
  124. self.login_button = tk.Button(master, text = 'Sign In', fg = 'white' , bg = 'black' , command = signin_check).grid(row = 5, column = 0 , sticky = 'we')
  125. self.signup_button= tk.Button(master, text= 'Create An Account', command = signup_mthd, fg = 'white' , bg = 'black').grid(row = 6 , column = 0 , sticky = 'we')
  126. #making the mainwindow scale when resized
  127. master.grid_rowconfigure(0,weight=1)
  128. master.grid_rowconfigure(1,weight=1)
  129. master.grid_rowconfigure(2,weight=1)
  130. master.grid_rowconfigure(3,weight=1)
  131. master.grid_rowconfigure(4,weight=1)
  132. master.grid_rowconfigure(5,weight=1)
  133. master.grid_rowconfigure(6,weight=1)
  134. master.grid_rowconfigure(7,weight=1)
  135. master.grid_rowconfigure(8,weight=1)
  136. master.grid_columnconfigure(0,weight=1)
  137.  
  138. class mainpagegui:
  139.  
  140. def __init__(self , master):
  141. self.master = master
  142. master.resizable(width = False, height = True)
  143. master.iconbitmap('phantex.ico')
  144. w = 420
  145. h = 490
  146. ws = master.winfo_screenwidth()
  147. hs = master.winfo_screenheight()
  148. x = (ws/2) - (w/2)
  149. y = (hs/2) - (h/2)
  150. master.geometry('%dx%d+%d+%d' % (w,h,x , y))
  151. #creation of the menus
  152. self.titlebaroptions = tk.Menu(master)
  153. self.savemenu = tk.Menu(master,tearoff = False)
  154. self.savemenu.add_command(label = 'Save Investment' , command = save_inv_mthd)
  155. self.advancedmenu = tk.Menu(master,tearoff = False)
  156. self.advancedmenu.add_command(label = 'Advanced Investment Information' , command = advanced_mthd)
  157. self.removemenu = tk.Menu(master,tearoff = False)
  158. self.removemenu.add_command(label = 'Remove Investment Record' , command = remove_inv_mthd)
  159. #adding menus to the main bar
  160. self.titlebaroptions.add_cascade(label = 'Save Investment' , menu = self.savemenu)
  161. self.titlebaroptions.add_cascade(label = 'Advanced Statistics' , menu = self.advancedmenu)
  162. self.titlebaroptions.add_cascade(label = 'Remove Investment' , menu = self.removemenu)
  163. self.master.config(menu = self.titlebaroptions)
  164.  
  165. #creation of labels
  166. self.Greeting = tk.Label(master ,text = usergreeting() ,bg= 'black', fg ='white').grid(row = 0 , column = 0 , sticky = W , columnspan = 2)
  167. self.price_label = tk.Label(master ,text = 'Price',bg= 'black', fg ='white').grid(row = 1 , column = 0 , sticky = 'we')
  168. self.date_label = tk.Label(master, text = 'Date',bg= 'black', fg ='white').grid(row = 1 , column = 1 , sticky = 'we')
  169. self.estimatedprofit_label = tk.Label(master ,text = 'Estimated Profit',bg= 'black', fg ='white').grid(row = 3 , column = 0 , sticky = 'we')
  170. self.aos_label = tk.Label(master, text = 'Amount of shares(Stock Investment)',bg= 'black', fg ='white').grid(row = 3 , column = 1 , sticky = 'we')
  171. self.seller_label = tk.Label(master, text = 'seller',bg= 'black', fg ='white').grid(row = 5 , column = 0 , sticky = 'we')
  172. self.buyer_label = tk.Label(master ,text = 'Buyer',bg= 'black', fg ='white').grid(row = 5 , column = 1 , sticky = 'we')
  173. self.pps_label = tk.Label(master ,text = 'Price per share(Stock Investment)',bg= 'black', fg ='white').grid(row = 7 , column = 0 , sticky = 'we')
  174. self.Lop_label = tk.Label(master ,text = 'Location of property(RealEstate)',bg= 'black', fg ='white').grid(row = 7 , column = 1 , sticky = 'we')
  175. self.dpr_label = tk.Label(master ,text = 'Dividend Pay Rate(Stock)',bg= 'black', fg ='white').grid(row = 9 , column = 0 , sticky = 'we')
  176. self.PI_label = tk.Label(master ,text = 'Passive Income',bg= 'black', fg ='white').grid(row = 9 , column = 1 , sticky = 'we')
  177. self.ID_label = tk.Label(master, text = 'ID Number(very important)',bg= 'black', fg ='white').grid(row = 11 , column = 0 , sticky = 'we')
  178. self.intERROR = tk.Message(master, text = None ,bg= 'black', fg ='red')
  179. self.intERROR.grid(row = 13, column = 0 , sticky = 'we')
  180. self.lenerror = tk.Label(master, text = None ,bg= 'black', fg ='red')
  181. self.lenerror.grid(row = 14, column = 0 , sticky = 'we')
  182. #creation of entrys
  183. self.price_entry = ttk.Entry(master)
  184. self.price_entry.grid(row = 2 , column = 0 , sticky = 'we')
  185. self.date_entry = ttk.Entry(master)
  186. self.date_entry.grid(row = 2 , column = 1 , sticky = 'we')
  187. self.estimatedprofit_entry = ttk.Entry(master)
  188. self.estimatedprofit_entry.grid(row = 4 , column =0 , sticky = 'we')
  189. self.aos_entry = ttk.Entry(master)
  190. self.aos_entry.grid(row = 4 , column = 1 , sticky = 'we')
  191. self.seller_entry = ttk.Entry(master)
  192. self.seller_entry.grid(row = 6 , column = 0 , sticky = 'we')
  193. self.buyer_entry = ttk.Entry(master)
  194. self.buyer_entry.grid(row = 6 , column = 1 , sticky = 'we')
  195. self.pps_entry = ttk.Entry(master)
  196. self.pps_entry.grid(row = 8 , column = 0 , sticky = 'we')
  197. self.Lop_entry = ttk.Entry(master)
  198. self.Lop_entry.grid(row = 8 , column = 1 , sticky = 'we')
  199. self.dpr_entry = ttk.Entry(master)
  200. self.dpr_entry.grid(row = 10 , column = 0 , sticky = 'we')
  201. self.PI_entry = ttk.Entry(master)
  202. self.PI_entry.grid(row = 10 , column = 1 , sticky = 'we')
  203. self.ID_entry = ttk.Entry(master)
  204. self.ID_entry.grid(row = 12 , column = 0 ,columnspan = 2, sticky = 'we')
  205. #back button
  206. self.backbutton = tk.Button(master, command = mainpageback_mthd , text = 'Back<--',bg= 'black', fg ='white').grid(row = 15 , column = 0 , columnspan = 2, sticky = 'we')
  207.  
  208. master.grid_rowconfigure(0,weight=1)
  209. master.grid_rowconfigure(1,weight=1)
  210. master.grid_rowconfigure(2,weight=1)
  211. master.grid_rowconfigure(3,weight=1)
  212. master.grid_rowconfigure(4,weight=1)
  213. master.grid_rowconfigure(5,weight=1)
  214. master.grid_rowconfigure(6,weight=1)
  215. master.grid_rowconfigure(7,weight=1)
  216. master.grid_rowconfigure(8,weight=1)
  217. master.grid_columnconfigure(0,weight=1)
  218.  
  219. def interrorchange(self , message):
  220. self.intERROR.configure(text =message )
  221.  
  222. def lenerrorchange(self , message):
  223. self.lenerror.configure(text =message )
  224.  
  225. def usergreeting():
  226.  
  227. global username_information
  228. title = c.execute("SELECT title FROM login WHERE user = :user" , {'user' : str(username_information)})
  229. #grabbing the title of user and commiting it to 'total'
  230. for row in title:
  231. total= 'Welcome ' + str(row[0])
  232.  
  233. last = c.execute("SELECT last FROM login WHERE user = :user" , {'user' : str(username_information)})
  234. #grabbing the last name and adding it after the user's title
  235. for row2 in last:
  236. total += row2[0]
  237.  
  238.  
  239. account_type = c.execute("SELECT accounttype FROM login WHERE user = :user" , {'user' : str(username_information)})
  240. for row3 in account_type:
  241. total+= ' Account Type:' + str(row3[0])
  242. return total
  243.  
  244. def main():
  245. global sign_in_window , obj
  246. sign_in_window = tk.Tk()
  247. sign_in_window.iconbitmap('phantex.ico')
  248. obj = SignInGui(sign_in_window)
  249. sign_in_window.mainloop()
  250. def mainpage(bool):
  251. global sign_in_window, mainpage_gui , mainpage_window
  252. if bool == True:
  253. sign_in_window.destroy()
  254.  
  255. mainpage_window =tk.Tk()
  256. mainpage_window.config(background = 'black')
  257. mainpage_window.title(string = 'Main Page')
  258. mainpage_gui = mainpagegui(mainpage_window)
  259.  
  260. def signin_check():
  261. global obj , username_information
  262. username_information = obj.username.get()
  263. password_information = obj.password.get()
  264. #checking the database to see if the info matches
  265. c.execute("SELECT * FROM login WHERE password =? and user = ?" , (str(password_information) , str(username_information)))
  266. if c.fetchall() == []:
  267. result= False
  268. #update the user on the status of login
  269. obj.status_label.config(text = 'Incorrect password or username')
  270. else:
  271. result = True
  272. mainpage(result)
  273. def signup_mthd():
  274. global sign_up_window , sign_in_window ,signup_obj
  275. sign_in_window.destroy()
  276. sign_up_window = tk.Tk()
  277. sign_up_window.iconbitmap('phantex.ico')
  278. signup_obj = SignUp(sign_up_window )
  279. def signupback_mthd():
  280. sign_up_window.destroy()
  281. main()
  282. def mainpageback_mthd():
  283. global mainpage_window
  284. mainpage_window.destroy()
  285. main()
  286. def combiner(category):
  287. global username_information
  288. placeholder = 0
  289. total = 0
  290. #searching for the price of the user
  291. info = c2.execute("SELECT "+ category+ " FROM investments WHERE user = :user" , {'user' : str(username_information)})
  292. for row in info:
  293. #turning the row(tuple) , into a int
  294. placeholder = int(row[0])
  295. #adding all the results together
  296. total += placeholder
  297. return total
  298.  
  299.  
  300. def advance_search_mthd(category , value):
  301. global username_information , information_box, search_box
  302. #removing whats currently in the box
  303. information_box.delete(0 , 'end')
  304. #searching for all investments
  305. results = c2.execute("SELECT * FROM investments WHERE "+str(category)+" = ?" , (value,))
  306.  
  307. number_of_row = 0
  308.  
  309. for row in results:
  310. number_of_row += 1
  311.  
  312. information_box.insert(0 ,'#' + str(number_of_row)+ str(row) )
  313. def single_search():
  314. advance_search_mthd('investment_id_number' , search_box.get())
  315. def all_search():
  316. advance_search_mthd('user' , str(username_information))
  317. def advanced_mthd():
  318. global information_box , search_box
  319. advanced_window = tk.Tk()
  320. advanced_window.iconbitmap('phantex.ico')
  321. advanced_window.config(background = 'black')
  322. advanced_window.title(string = 'Advance Statistics')
  323.  
  324.  
  325. #placement of window
  326. w = 1040
  327. h = 290
  328. ws = advanced_window.winfo_screenwidth()
  329. hs = advanced_window.winfo_screenheight()
  330. x = (ws/2) - (w/2)
  331. y = (hs/2) - (h/2)
  332. advanced_window.geometry('%dx%d+%d+%d' % (w,h,x , y))
  333. #creation of labels
  334. overal_price_invested = tk.Label(advanced_window , text = str('Total Spent On investments :' + ' ' +str(combiner('price'))),bg= 'black', fg ='white').grid(row = 2 , column = 0 , sticky= 'we')
  335. estimated_profit =tk.Label(advanced_window , text = str('Total Estimated_profit :' + ' ' +str(combiner('estimated_profit'))),bg= 'black', fg ='white').grid(row = 3 , column = 0 , sticky= 'we')
  336. amount_of_shares =tk.Label(advanced_window , text = str('Total Shares :' + ' ' +str(combiner('amount_of_shares'))),bg= 'black', fg ='white').grid(row = 4 , column = 0 , sticky= 'we')
  337. price_per_share =tk.Label(advanced_window , text = str('Total Estimated_profit :' + ' ' +str(combiner('price_per_share'))),bg= 'black', fg ='white').grid(row = 5 , column = 0 , sticky= 'we')
  338. passive_income =tk.Label(advanced_window , text = str('Combined Passive income :' + ' ' +str(combiner('passive_income'))),bg= 'black', fg ='white').grid(row = 6 , column = 0 , sticky= 'we')
  339. search_label = tk.Label(advanced_window , text = 'Search for investment using id number',bg= 'black', fg ='white').grid(row = 8 , column = 0 , sticky = 'we')
  340. header = tk.Label(advanced_window , text = 'Price , Date, Estimated profit , amount of shares , seller, buyer , price per share , user , location of property , dividend price rate , passive_income , id number',bg= 'black', fg ='white').grid(row = 0 , column = 1 , sticky = 'we')
  341. #creation of listbox
  342.  
  343. information_box = tk.Listbox(advanced_window , width = 50)
  344. information_box.grid(row = 1 ,column = 1 ,rowspan = 6, sticky = 'we')
  345. #creation of Entrys
  346. search_box = ttk.Entry(advanced_window)
  347. search_box.grid(row = 9 , column = 0 , sticky = 'we')
  348. #creation of buttons
  349. submit_button = tk.Button(advanced_window , text = 'Submit' ,bg= 'black', fg ='white', command = single_search)
  350. submit_button.grid(row = 11 , column = 0 , sticky = 'we')
  351. all_info_button = tk.Button(advanced_window,text = 'Import all investments',bg= 'black', fg ='white', command =all_search )
  352. all_info_button.grid(row = 12 ,column = 0 , sticky = 'we')
  353.  
  354.  
  355. def remove_algo():
  356. global username_information , main_entry , error_msg
  357. #checking to see if the investment is in the database
  358. c2.execute("""SELECT * FROM investments WHERE user= ? and investment_id_number = ?""" , (username_information, main_entry.get()))
  359. if c2.fetchall() == []:
  360. #updating the user on the status of the request if there is no investment there
  361. error_msg.config(text = 'No Investment Under That ID number')
  362. else:
  363. error_msg.config(text = 'Investment Deleted')
  364. #updating the user on the status of the request if there is an investment there
  365. c2.execute("""DELETE FROM investments WHERE user = ? and investment_id_number = ? """ , (username_information , main_entry.get()))
  366. conn2.commit()
  367. def remove_inv_mthd():
  368. global main_entry ,error_msg
  369. #configuring window
  370. remove_window = tk.Tk()
  371. remove_window.title(string = 'Remove Window')
  372. remove_window.iconbitmap('phantex.ico')
  373. remove_window.config(background = 'black')
  374. w = 380
  375. h = 220
  376. ws = remove_window.winfo_screenwidth()
  377. hs = remove_window.winfo_screenheight()
  378. x = (ws/2) - (w/2)
  379. y = (hs/2) - (h/2)
  380. remove_window.geometry('%dx%d+%d+%d' % (w,h,x , y))
  381.  
  382.  
  383. #widgets
  384. main_message = tk.Message(remove_window , text = 'Welcome To the Delete section , where you can remove an investment, Keep in mind once you remove an investment it cannot be recovered' , font = 'times 13 bold ',bg= 'black', fg ='white')
  385. main_message.grid(row = 1, column = 0 , sticky = 'we')
  386. note_message = tk.Label(remove_window, text= 'NOTE : ENTER THE Investment ID , CHECK HELP FOR MORE INFO',bg= 'black', fg ='white')
  387. note_message.grid(row = 2, column = 0 , sticky = 'we')
  388. main_entry = ttk.Entry(remove_window)
  389. main_entry.grid(row= 3 , column = 0 , sticky = 'we')
  390. delete_button = tk.Button(remove_window ,text='Remove**' , command = remove_algo,bg= 'black', fg ='white')
  391. delete_button.grid(row = 4 , column = 0 , sticky = 'we')
  392. error_msg = tk.Label(remove_window , text = None ,bg= 'black', fg ='red' )
  393. error_msg.grid(row = 5 , column = 0 , sticky = 'we')
  394.  
  395.  
  396. def intcheck(value):
  397. try:
  398. int(value)
  399. return True
  400. except ValueError:
  401. return False
  402.  
  403.  
  404. def save_inv_mthd():
  405. global username_information , mainpage_gui
  406. #storing the values in variables makes it a bit easier to read
  407. price_data = mainpage_gui.price_entry.get()
  408. date_data = mainpage_gui.date_entry.get()
  409. estimated_profit_data = mainpage_gui.estimatedprofit_entry.get()
  410. amount_of_shares_data = mainpage_gui.aos_entry.get()
  411. seller_data = mainpage_gui.seller_entry.get()
  412. buyer_data = mainpage_gui.buyer_entry.get()
  413. price_per_share_data = mainpage_gui.pps_entry.get()
  414. location_of_propery_data =mainpage_gui.Lop_entry.get()
  415. dividend_price_rate_data = mainpage_gui.dpr_entry.get()
  416. passive_income_data = mainpage_gui.PI_entry.get()
  417. investment_id_data = mainpage_gui.ID_entry.get()
  418. intcheck_results = True
  419. len_results = True
  420.  
  421. if len(price_data) < 3 or len(date_data)<3 or len(passive_income_data) <3 or len(seller_data)<3 or len(buyer_data)<3 or len(estimated_profit_data) <3 :
  422. len_results = False
  423. if intcheck(price_data) == False or intcheck(estimated_profit_data) == False or intcheck(amount_of_shares_data)== False or intcheck(price_per_share_data)== False or intcheck(passive_income_data) == False:
  424. intcheck_results = False
  425.  
  426. if intcheck_results == False:
  427. mainpage_gui.interrorchange('ERROR #1 :Price,estimated profit,amount of shares,price per share,passive income must be all numbers no letters')
  428. if len_results == False:
  429. mainpage_gui.lenerrorchange('ERROR #2 :Must have 3 or more characters in all boxes')
  430.  
  431. else:
  432. mainpage_gui.interrorchange (None)
  433. mainpage_gui.lenerrorchange('SUCCESSFULLY SAVED')
  434. c2.execute("INSERT INTO investments VALUES (?, ? , ?, ?, ? , ? , ?, ? , ? , ? , ? , ?)",
  435. ((price_data) , (date_data) , (estimated_profit_data) ,(amount_of_shares_data) , (seller_data) , (buyer_data) , (price_per_share_data) ,
  436. (username_information), (location_of_propery_data) , (dividend_price_rate_data) , (passive_income_data), (investment_id_data) ))
  437. conn2.commit()
  438.  
  439.  
  440. if __name__ == "__main__":
  441. main()
  442.  
  443. conn.close()
  444. conn2.close()][1]
Add Comment
Please, Sign In to add comment