当前位置:   article > 正文

基于PysimpleGUI+pymysql建立的简单管理系统(5)—修改功能_pysimplegui连接mysql

pysimplegui连接mysql

         紧接上文,我们接下来来讲revise.py

        通过之前文章的menu.py登录界面,我们选择第三个功能,修改功能。

         我们在已有的数据表和列表框元素的基础上,我们需要考虑的是如何去修改客户的信息。相对于让用户全部重新再输入一次信息,不如给出一条信息提示,让用户去选择修改什么地方。除此之外,对于数据量较大的情况下,我增添了查找功能,可以更快更迅速的找出某个客户的所有信息。

        revise.py代码如下:(代码量较大,有很大一部分的结构是重复的)

  1. import pymysql #导入库文件
  2. import PySimpleGUI as sg
  3. import pandas as pd
  4. import os
  5. import time
  6. import threading
  7. import datetime
  8. conn = pymysql.connect(host="localhost", #建立mysql的连接
  9. user="root",
  10. password="",
  11. db="user_information",
  12. charset="utf8")
  13. cursor = conn.cursor()
  14. sql ="select * from custome_information" #导入mysql数据表信息
  15. cursor.execute(sql)
  16. result = cursor.fetchall()
  17. all = list(result) #将数据列表化
  18. cursor.close()
  19. conn.close()
  20. layout = [[sg.Text("客户名 订单名 时间 材料 尺寸 数量 单价 金额")], #gui界面设计
  21. [sg.Listbox(all, key='-TEXT-', select_mode='single',size=(80, 6))],
  22. [sg.Button('返回'),sg.Button('修改'),sg.Button('查找'),sg.Button('退出')]]
  23. window = sg.Window('修改客户账单', layout)
  24. while True:
  25. event, values = window.read() #获取用户动作以及值
  26. if event == sg.WINDOW_CLOSED or event == '退出':
  27. break
  28. if event == '返回': #返回菜单界面
  29. time.sleep(0.5)
  30. window.close()
  31. os.system('python menu.py')
  32. break
  33. if event == '修改': #修改功能
  34. values = pd.DataFrame.from_dict(values,orient='index')
  35. str1 = str(values.iat[0,0]) #提取相应字符串
  36. custome_name = str1.split("\'")[1]
  37. order_name = str1.split("\'")[3]
  38. material = str1.split("\'")[5]
  39. size = str1.split("\'")[7]
  40. quantity = str1.split(",")[9]
  41. price = str1.split(",")[10]
  42. amount = str1.split(",")[11].strip(')')
  43. time.sleep(0.5)
  44. window.close()
  45. layout = [[sg.Text("请输入要修改的序号:")], #修改位置界面
  46. [sg.Text("1.客户名 2.订单名 3.时间 4.材料 ")],
  47. [sg.Text("5.尺寸 6.数量 7.单价 8.金额 ")],
  48. [sg.Input(key='-INPUT-')],
  49. [sg.Button('确定'),sg.Button('返回')]]
  50. window = sg.Window('修改', layout)
  51. while True:
  52. event, values = window.read()
  53. if event == sg.WINDOW_CLOSED :
  54. break
  55. if event == '返回': #返回修改界面
  56. time.sleep(0.5)
  57. window.close()
  58. os.system('python revise.py')
  59. break
  60. if event == '确定':
  61. values = pd.DataFrame([values])
  62. if values.iat[0,0] == '': #判断为空报错
  63. window.close()
  64. layout = [[sg.Text("填写为空!")],
  65. [sg.Button('返回')]]
  66. window = sg.Window('错误', layout)
  67. while True:
  68. event, values = window.read()
  69. if event == sg.WINDOW_CLOSED:
  70. break
  71. if event == '返回': #返回修改界面
  72. time.sleep(0.5)
  73. window.close()
  74. os.system('python revise.py')
  75. break
  76. choice = int(values.iat[0,0])
  77. time.sleep(0.5)
  78. window.close()
  79. if choice == 1:
  80. layout = [[sg.Text("请输入要修改的内容:")], #修改内容界面
  81. [sg.Input(key='-INPUT-')],
  82. [sg.Button('确定'),sg.Button('返回')]]
  83. window = sg.Window('修改', layout)
  84. while True:
  85. event, values = window.read()
  86. if event == sg.WINDOW_CLOSED :
  87. break
  88. if event == '返回': #返回修改界面
  89. time.sleep(0.5)
  90. window.close()
  91. os.system('python revise.py')
  92. break
  93. if event == '确定':
  94. values = pd.DataFrame([values])
  95. content = str(values.iat[0,0])
  96. cursor = conn.cursor()
  97. conn.ping(reconnect=True) #添加互斥锁,以防mysql连接丢失
  98. thread_lock = threading.Lock()
  99. thread_lock.acquire()
  100. sql ="update custome_information set custome_name = '%s' where order_name = '%s' and material = '%s' and size = '%s' and quantity = '%s' and price = '%s' and amount = '%s'" %(content,order_name,material,size,quantity,price,amount)
  101. cursor.execute(sql)
  102. conn.commit()
  103. conn.close()
  104. thread_lock.release()
  105. time.sleep(0.5)
  106. window.close()
  107. os.system('python revise.py')
  108. break
  109. if choice == 2: #同上,唯一区别在于mysql语句不同
  110. layout = [[sg.Text("请输入要修改的内容:")],
  111. [sg.Input(key='-INPUT-')],
  112. [sg.Button('确定'),sg.Button('返回')]]
  113. window = sg.Window('修改', layout)
  114. while True:
  115. event, values = window.read()
  116. if event == sg.WINDOW_CLOSED :
  117. break
  118. if event == '返回':
  119. time.sleep(0.5)
  120. window.close()
  121. os.system('python revise.py')
  122. break
  123. if event == '确定':
  124. values = pd.DataFrame([values])
  125. content = str(values.iat[0,0])
  126. cursor = conn.cursor()
  127. conn.ping(reconnect=True)
  128. thread_lock = threading.Lock()
  129. thread_lock.acquire()
  130. sql ="update custome_information set order_name = '%s' where custome_name = '%s' and material = '%s' and size = '%s' and quantity = '%s' and price = '%s' and amount = '%s'" %(content,custome_name,material,size,quantity,price,amount)
  131. cursor.execute(sql)
  132. conn.commit()
  133. conn.close()
  134. thread_lock.release()
  135. time.sleep(0.5)
  136. window.close()
  137. os.system('python revise.py')
  138. break
  139. if choice == 3:
  140. layout = [[sg.Text("请输入要修改的内容:(年.月.日)")],
  141. [sg.Input(key='-INPUT-')],
  142. [sg.Button('确定'),sg.Button('返回')]]
  143. window = sg.Window('修改', layout)
  144. while True:
  145. event, values = window.read()
  146. if event == sg.WINDOW_CLOSED :
  147. break
  148. if event == '返回':
  149. time.sleep(0.5)
  150. window.close()
  151. os.system('python revise.py')
  152. break
  153. if event == '确定':
  154. values = pd.DataFrame([values])
  155. content = str(values.iat[0,0])
  156. format_str = '%Y.%m.%d'
  157. content = datetime.datetime.strptime(content, format_str)
  158. cursor = conn.cursor()
  159. conn.ping(reconnect=True)
  160. thread_lock = threading.Lock()
  161. thread_lock.acquire()
  162. sql ="update custome_information set time = '%s' where custome_name = '%s'and order_name = '%s' and material = '%s' and size = '%s' and quantity = '%s' and price = '%s' and amount = '%s'" %(content,custome_name,order_name,material,size,quantity,price,amount)
  163. cursor.execute(sql)
  164. conn.commit()
  165. conn.close()
  166. thread_lock.release()
  167. time.sleep(0.5)
  168. window.close()
  169. os.system('python revise.py')
  170. break
  171. if choice == 4:
  172. layout = [[sg.Text("请输入要修改的内容:")],
  173. [sg.Input(key='-INPUT-')],
  174. [sg.Button('确定'),sg.Button('返回')]]
  175. window = sg.Window('修改', layout)
  176. while True:
  177. event, values = window.read()
  178. if event == sg.WINDOW_CLOSED :
  179. break
  180. if event == '返回':
  181. time.sleep(0.5)
  182. window.close()
  183. os.system('python revise.py')
  184. break
  185. if event == '确定':
  186. values = pd.DataFrame([values])
  187. content = str(values.iat[0,0])
  188. cursor = conn.cursor()
  189. conn.ping(reconnect=True)
  190. thread_lock = threading.Lock()
  191. thread_lock.acquire()
  192. sql ="update custome_information set material = '%s' where custome_name = '%s' and order_name= '%s' and size = '%s' and quantity = '%s' and price = '%s' and amount = '%s'" %(content,custome_name,order_name,size,quantity,price,amount)
  193. cursor.execute(sql)
  194. conn.commit()
  195. conn.close()
  196. thread_lock.release()
  197. time.sleep(0.5)
  198. window.close()
  199. os.system('python revise.py')
  200. break
  201. if choice == 5:
  202. layout = [[sg.Text("请输入要修改的内容:")],
  203. [sg.Input(key='-INPUT-')],
  204. [sg.Button('确定'),sg.Button('返回')]]
  205. window = sg.Window('修改', layout)
  206. while True:
  207. event, values = window.read()
  208. if event == sg.WINDOW_CLOSED :
  209. break
  210. if event == '返回':
  211. time.sleep(0.5)
  212. window.close()
  213. os.system('python revise.py')
  214. break
  215. if event == '确定':
  216. values = pd.DataFrame([values])
  217. content = str(values.iat[0,0])
  218. cursor = conn.cursor()
  219. conn.ping(reconnect=True)
  220. thread_lock = threading.Lock()
  221. thread_lock.acquire()
  222. sql ="update custome_information set size = '%s' where custome_name = '%s' and order_name= '%s' and material= '%s' and quantity = '%s' and price = '%s' and amount = '%s'" %(content,custome_name,order_name,material,quantity,price,amount)
  223. cursor.execute(sql)
  224. conn.commit()
  225. conn.close()
  226. thread_lock.release()
  227. time.sleep(0.5)
  228. window.close()
  229. os.system('python revise.py')
  230. break
  231. if choice == 6:
  232. layout = [[sg.Text("请输入要修改的内容:")],
  233. [sg.Input(key='-INPUT-')],
  234. [sg.Button('确定'),sg.Button('返回')]]
  235. window = sg.Window('修改', layout)
  236. while True:
  237. event, values = window.read()
  238. if event == sg.WINDOW_CLOSED :
  239. break
  240. if event == '返回':
  241. time.sleep(0.5)
  242. window.close()
  243. os.system('python revise.py')
  244. break
  245. if event == '确定':
  246. values = pd.DataFrame([values])
  247. content = int(values.iat[0,0])
  248. cursor = conn.cursor()
  249. conn.ping(reconnect=True)
  250. thread_lock = threading.Lock()
  251. thread_lock.acquire()
  252. sql ="update custome_information set quantity = '%s' where custome_name = '%s' and order_name= '%s' and material= '%s' and size = '%s' and price = '%s' and amount = '%s'" %(content,custome_name,order_name,material,size,price,amount)
  253. cursor.execute(sql)
  254. conn.commit()
  255. conn.close()
  256. thread_lock.release()
  257. time.sleep(0.5)
  258. window.close()
  259. os.system('python revise.py')
  260. break
  261. if choice == 7:
  262. layout = [[sg.Text("请输入要修改的内容:")],
  263. [sg.Input(key='-INPUT-')],
  264. [sg.Button('确定'),sg.Button('返回')]]
  265. window = sg.Window('修改', layout)
  266. while True:
  267. event, values = window.read()
  268. if event == sg.WINDOW_CLOSED :
  269. break
  270. if event == '返回':
  271. time.sleep(0.5)
  272. window.close()
  273. os.system('python revise.py')
  274. break
  275. if event == '确定':
  276. values = pd.DataFrame([values])
  277. content = float(values.iat[0,0])
  278. cursor = conn.cursor()
  279. conn.ping(reconnect=True)
  280. thread_lock = threading.Lock()
  281. thread_lock.acquire()
  282. sql ="update custome_information set price = '%s' where custome_name = '%s' and order_name= '%s' and material= '%s' and size = '%s' and quantity= '%s' and amount = '%s'" %(content,custome_name,order_name,material,size,quantity,amount)
  283. cursor.execute(sql)
  284. conn.commit()
  285. conn.close()
  286. thread_lock.release()
  287. time.sleep(0.5)
  288. window.close()
  289. os.system('python revise.py')
  290. break
  291. if choice == 8:
  292. layout = [[sg.Text("请输入要修改的内容:")],
  293. [sg.Input(key='-INPUT-')],
  294. [sg.Button('确定'),sg.Button('返回')]]
  295. window = sg.Window('修改', layout)
  296. while True:
  297. event, values = window.read()
  298. if event == sg.WINDOW_CLOSED :
  299. break
  300. if event == '返回':
  301. time.sleep(0.5)
  302. window.close()
  303. os.system('python revise.py')
  304. break
  305. if event == '确定':
  306. values = pd.DataFrame([values])
  307. content = float(values.iat[0,0])
  308. cursor = conn.cursor()
  309. conn.ping(reconnect=True)
  310. thread_lock = threading.Lock()
  311. thread_lock.acquire()
  312. sql ="update custome_information set amount = '%s' where custome_name = '%s' and order_name= '%s' and material= '%s' and size = '%s' and quantity= '%s' and price = '%s'" %(content,custome_name,order_name,material,size,quantity,price)
  313. cursor.execute(sql)
  314. conn.commit()
  315. conn.close()
  316. thread_lock.release()
  317. time.sleep(0.5)
  318. window.close()
  319. os.system('python revise.py')
  320. break
  321. if event == '查找': #查找功能界面
  322. window.close()
  323. layout = [[sg.Text("请输入要查找的客户名:")],
  324. [sg.Input(key='-INPUT-')],
  325. [sg.Button('确定'),sg.Button('返回'),sg.Button('退出')]]
  326. window = sg.Window('查找', layout)
  327. while True:
  328. event, values = window.read()
  329. if event == sg.WINDOW_CLOSED or event == '退出':
  330. break
  331. if event == '返回': #返回修改界面
  332. time.sleep(0.5)
  333. window.close()
  334. os.system('python revise.py')
  335. break
  336. if event == '确定':
  337. window.close()
  338. values = pd.DataFrame([values])
  339. custome_name = str(values.iat[0,0])
  340. cursor = conn.cursor()
  341. conn.ping(reconnect=True) #添加互斥锁,以防mysql连接丢失
  342. thread_lock = threading.Lock()
  343. thread_lock.acquire()
  344. sql ="select * from custome_information where custome_name = '%s'"%(custome_name)
  345. cursor.execute(sql)
  346. result = cursor.fetchall()
  347. all = list(result)
  348. cursor.close()
  349. conn.close()
  350. thread_lock.release()
  351. layout = [[sg.Text("客户名 订单名 时间 材料 尺寸 数量 单价 金额")],
  352. [sg.Listbox(all, key='-TEXT-', select_mode='single',size=(80, 6))],
  353. [sg.Button('返回'),sg.Button('修改'),sg.Button('退出')]]
  354. window = sg.Window('查找', layout)
  355. while True:
  356. event, values = window.read()
  357. if event == sg.WINDOW_CLOSED or event == '退出':
  358. break
  359. if event == '返回':
  360. time.sleep(0.5)
  361. window.close()
  362. os.system('python revise.py')
  363. break
  364. if event == '修改': #同上操作
  365. values = pd.DataFrame.from_dict(values,orient='index')
  366. str1 = str(values.iat[0,0])
  367. custome_name = str1.split("\'")[1]
  368. order_name = str1.split("\'")[3]
  369. material = str1.split("\'")[5]
  370. size = str1.split("\'")[7]
  371. quantity = str1.split(",")[9]
  372. price = str1.split(",")[10]
  373. amount = str1.split(",")[11].strip(')')
  374. time.sleep(0.5)
  375. window.close()
  376. layout = [[sg.Text("请输入要修改的序号:")],
  377. [sg.Text("1.客户名 2.订单名 3.时间 4.材料 ")],
  378. [sg.Text("5.尺寸 6.数量 7.单价 8.金额 ")],
  379. [sg.Input(key='-INPUT-')],
  380. [sg.Button('确定'),sg.Button('返回')]]
  381. window = sg.Window('修改', layout)
  382. while True:
  383. event, values = window.read()
  384. if event == sg.WINDOW_CLOSED :
  385. break
  386. if event == '返回':
  387. time.sleep(0.5)
  388. window.close()
  389. os.system('python revise.py')
  390. break
  391. if event == '确定':
  392. values = pd.DataFrame([values])
  393. choice = int(values['-INPUT-'])
  394. time.sleep(0.5)
  395. window.close()
  396. if choice == 1:
  397. layout = [[sg.Text("请输入要修改的内容:")],
  398. [sg.Input(key='-INPUT-')],
  399. [sg.Button('确定'),sg.Button('返回')]]
  400. window = sg.Window('修改', layout)
  401. while True:
  402. event, values = window.read()
  403. if event == sg.WINDOW_CLOSED :
  404. break
  405. if event == '返回':
  406. time.sleep(0.5)
  407. window.close()
  408. os.system('python revise.py')
  409. break
  410. if event == '确定':
  411. values = pd.DataFrame([values])
  412. content = str(values.iat[0,0])
  413. cursor = conn.cursor()
  414. conn.ping(reconnect=True)
  415. thread_lock = threading.Lock()
  416. thread_lock.acquire()
  417. sql ="update custome_information set custome_name = '%s' where order_name = '%s' and material = '%s' and size = '%s' and quantity = '%s' and price = '%s' and amount = '%s'" %(content,order_name,material,size,quantity,price,amount)
  418. cursor.execute(sql)
  419. conn.commit()
  420. conn.close()
  421. thread_lock.release()
  422. time.sleep(0.5)
  423. window.close()
  424. os.system('python revise.py')
  425. break
  426. if choice == 2:
  427. layout = [[sg.Text("请输入要修改的内容:")],
  428. [sg.Input(key='-INPUT-')],
  429. [sg.Button('确定'),sg.Button('返回')]]
  430. window = sg.Window('修改', layout)
  431. while True:
  432. event, values = window.read()
  433. if event == sg.WINDOW_CLOSED :
  434. break
  435. if event == '返回':
  436. time.sleep(0.5)
  437. window.close()
  438. os.system('python revise.py')
  439. break
  440. if event == '确定':
  441. values = pd.DataFrame([values])
  442. content = str(values.iat[0,0])
  443. cursor = conn.cursor()
  444. conn.ping(reconnect=True)
  445. thread_lock = threading.Lock()
  446. thread_lock.acquire()
  447. sql ="update custome_information set order_name = '%s' where custome_name = '%s' and material = '%s' and size = '%s' and quantity = '%s' and price = '%s' and amount = '%s'" %(content,custome_name,material,size,quantity,price,amount)
  448. cursor.execute(sql)
  449. conn.commit()
  450. conn.close()
  451. thread_lock.release()
  452. time.sleep(0.5)
  453. window.close()
  454. os.system('python revise.py')
  455. break
  456. if choice == 3:
  457. layout = [[sg.Text("请输入要修改的内容:(年.月.日)")],
  458. [sg.Input(key='-INPUT-')],
  459. [sg.Button('确定'),sg.Button('返回')]]
  460. window = sg.Window('修改', layout)
  461. while True:
  462. event, values = window.read()
  463. if event == sg.WINDOW_CLOSED :
  464. break
  465. if event == '返回':
  466. time.sleep(0.5)
  467. window.close()
  468. os.system('python revise.py')
  469. break
  470. if event == '确定':
  471. values = pd.DataFrame([values])
  472. content = str(values.iat[0,0])
  473. format_str = '%Y.%m.%d'
  474. content = datetime.datetime.strptime(content, format_str)
  475. cursor = conn.cursor()
  476. conn.ping(reconnect=True)
  477. thread_lock = threading.Lock()
  478. thread_lock.acquire()
  479. sql ="update custome_information set time = '%s' where custome_name = '%s'and order_name = '%s' and material = '%s' and size = '%s' and quantity = '%s' and price = '%s' and amount = '%s'" %(content,custome_name,order_name,material,size,quantity,price,amount)
  480. cursor.execute(sql)
  481. conn.commit()
  482. conn.close()
  483. thread_lock.release()
  484. time.sleep(0.5)
  485. window.close()
  486. os.system('python revise.py')
  487. break
  488. if choice == 4:
  489. layout = [[sg.Text("请输入要修改的内容:")],
  490. [sg.Input(key='-INPUT-')],
  491. [sg.Button('确定'),sg.Button('返回')]]
  492. window = sg.Window('修改', layout)
  493. while True:
  494. event, values = window.read()
  495. if event == sg.WINDOW_CLOSED :
  496. break
  497. if event == '返回':
  498. time.sleep(0.5)
  499. window.close()
  500. os.system('python revise.py')
  501. break
  502. if event == '确定':
  503. values = pd.DataFrame([values])
  504. content = str(values.iat[0,0])
  505. cursor = conn.cursor()
  506. conn.ping(reconnect=True)
  507. thread_lock = threading.Lock()
  508. thread_lock.acquire()
  509. sql ="update custome_information set material = '%s' where custome_name = '%s' and order_name= '%s' and size = '%s' and quantity = '%s' and price = '%s' and amount = '%s'" %(content,custome_name,order_name,size,quantity,price,amount)
  510. cursor.execute(sql)
  511. conn.commit()
  512. conn.close()
  513. thread_lock.release()
  514. time.sleep(0.5)
  515. window.close()
  516. os.system('python revise.py')
  517. break
  518. if choice == 5:
  519. layout = [[sg.Text("请输入要修改的内容:")],
  520. [sg.Input(key='-INPUT-')],
  521. [sg.Button('确定'),sg.Button('返回')]]
  522. window = sg.Window('修改', layout)
  523. while True:
  524. event, values = window.read()
  525. if event == sg.WINDOW_CLOSED :
  526. break
  527. if event == '返回':
  528. time.sleep(0.5)
  529. window.close()
  530. os.system('python revise.py')
  531. break
  532. if event == '确定':
  533. values = pd.DataFrame([values])
  534. content = str(values.iat[0,0])
  535. cursor = conn.cursor()
  536. conn.ping(reconnect=True)
  537. thread_lock = threading.Lock()
  538. thread_lock.acquire()
  539. sql ="update custome_information set size = '%s' where custome_name = '%s' and order_name= '%s' and material= '%s' and quantity = '%s' and price = '%s' and amount = '%s'" %(content,custome_name,order_name,material,quantity,price,amount)
  540. cursor.execute(sql)
  541. conn.commit()
  542. conn.close()
  543. thread_lock.release()
  544. time.sleep(0.5)
  545. window.close()
  546. os.system('python revise.py')
  547. break
  548. if choice == 6:
  549. layout = [[sg.Text("请输入要修改的内容:")],
  550. [sg.Input(key='-INPUT-')],
  551. [sg.Button('确定'),sg.Button('返回')]]
  552. window = sg.Window('修改', layout)
  553. while True:
  554. event, values = window.read()
  555. if event == sg.WINDOW_CLOSED :
  556. break
  557. if event == '返回':
  558. time.sleep(0.5)
  559. window.close()
  560. os.system('python revise.py')
  561. break
  562. if event == '确定':
  563. values = pd.DataFrame([values])
  564. content = int(values.iat[0,0])
  565. cursor = conn.cursor()
  566. conn.ping(reconnect=True)
  567. thread_lock = threading.Lock()
  568. thread_lock.acquire()
  569. sql ="update custome_information set quantity = '%s' where custome_name = '%s' and order_name= '%s' and material= '%s' and size = '%s' and price = '%s' and amount = '%s'" %(content,custome_name,order_name,material,size,price,amount)
  570. cursor.execute(sql)
  571. conn.commit()
  572. conn.close()
  573. thread_lock.release()
  574. time.sleep(0.5)
  575. window.close()
  576. os.system('python revise.py')
  577. break
  578. if choice == 7:
  579. layout = [[sg.Text("请输入要修改的内容:")],
  580. [sg.Input(key='-INPUT-')],
  581. [sg.Button('确定'),sg.Button('返回')]]
  582. window = sg.Window('修改', layout)
  583. while True:
  584. event, values = window.read()
  585. if event == sg.WINDOW_CLOSED :
  586. break
  587. if event == '返回':
  588. time.sleep(0.5)
  589. window.close()
  590. os.system('python revise.py')
  591. break
  592. if event == '确定':
  593. values = pd.DataFrame([values])
  594. content = float(values.iat[0,0])
  595. cursor = conn.cursor()
  596. conn.ping(reconnect=True)
  597. thread_lock = threading.Lock()
  598. thread_lock.acquire()
  599. sql ="update custome_information set price = '%s' where custome_name = '%s' and order_name= '%s' and material= '%s' and size = '%s' and quantity= '%s' and amount = '%s'" %(content,custome_name,order_name,material,size,quantity,amount)
  600. cursor.execute(sql)
  601. conn.commit()
  602. conn.close()
  603. thread_lock.release()
  604. time.sleep(0.5)
  605. window.close()
  606. os.system('python revise.py')
  607. break
  608. if choice == 8:
  609. layout = [[sg.Text("请输入要修改的内容:")],
  610. [sg.Input(key='-INPUT-')],
  611. [sg.Button('确定'),sg.Button('返回')]]
  612. window = sg.Window('修改', layout)
  613. while True:
  614. event, values = window.read()
  615. if event == sg.WINDOW_CLOSED :
  616. break
  617. if event == '返回':
  618. time.sleep(0.5)
  619. window.close()
  620. os.system('python revise.py')
  621. break
  622. if event == '确定':
  623. values = pd.DataFrame([values])
  624. content = float(values.iat[0,0])
  625. cursor = conn.cursor()
  626. conn.ping(reconnect=True)
  627. thread_lock = threading.Lock()
  628. thread_lock.acquire()
  629. sql ="update custome_information set amount = '%s' where custome_name = '%s' and order_name= '%s' and material= '%s' and size = '%s' and quantity= '%s' and price = '%s'" %(content,custome_name,order_name,material,size,quantity,price)
  630. cursor.execute(sql)
  631. conn.commit()
  632. conn.close()
  633. thread_lock.release()
  634. time.sleep(0.5)
  635. window.close()
  636. os.system('python revise.py')
  637. break
  638. else:
  639. window['-OUTPUT-'].update("请输入正确的序号!")

代码运行截图:

 

 

 

之后将持续更新,search.py查找操作。 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/955552
推荐阅读
相关标签
  

闽ICP备14008679号