Advertisement
Nosyguest

Dewey/Library System by Grade 10 Entrepreneurs

Sep 20th, 2023 (edited)
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 10.77 KB | Source Code | 0 0
  1. DECLARE SUB Search ()
  2. DECLARE SUB main ()
  3. DECLARE SUB layout ()
  4. DECLARE SUB add ()
  5. DECLARE SUB Disp ()
  6. DECLARE SUB Srch ()
  7. DECLARE SUB Categry ()
  8. DECLARE SUB edit ()
  9. DECLARE SUB delete ()
  10. DECLARE SUB bye ()
  11. DIM ou AS STRING
  12. TOP:
  13. CLS
  14. ou = TIME$
  15. COLOR 7, 1
  16. INV:
  17. CALL main
  18. LOCATE 20, 28:
  19. PRINT "Enter your choice:: 1-7"; : INPUT C
  20.  
  21. SELECT CASE C
  22.     CASE 1
  23.         CALL add
  24.     CASE 2
  25.         CALL Disp
  26.     CASE 3
  27.         CALL Search
  28.     CASE 4
  29.         CALL Categry
  30.     CASE 5
  31.         CALL edit
  32.     CASE 6
  33.         CALL delete
  34.     CASE 7
  35.         GOTO Bottom
  36.     CASE ELSE
  37.         CLS
  38.         PRINT "Case invalid"
  39.         GOTO INV
  40.  
  41. END SELECT
  42. LOCATE 22, 25
  43.  
  44. PRINT "Press any key to go to main menu"
  45. a$ = INPUT$(1)
  46. GOTO TOP
  47. Bottom:
  48. CALL bye
  49. END
  50.  
  51. SUB add
  52. avg:
  53. COLOR 7, 1
  54.  
  55. OPEN "Inv.TXT" FOR APPEND AS #1
  56.  
  57. REDIM N(100)
  58.  
  59.     OPEN "Inv.TXT" FOR INPUT AS #2
  60.  
  61.     I = 1
  62.     WHILE NOT EOF(2)
  63.         INPUT #2, C, N$, C$, R, S, SQ, P
  64.         N(I) = C
  65.         I = I + 1
  66.     WEND
  67.     CLOSE #2
  68.  
  69.  
  70.     CLS
  71. Wro:
  72.     CALL layout
  73.     LOCATE 6, 36: PRINT "Add Book"
  74.     LOCATE 10, 25: PRINT "Enter Item Code"; : INPUT IC
  75.     FOR j = 1 TO 100
  76.         IF IC = N(j) THEN
  77.             CLS
  78.             LOCATE 10, 22: PRINT "Invalid Item Code.. TRY AGAIN!!"
  79.             GOTO Wro
  80.         END IF
  81.     NEXT j
  82.  
  83.     LOCATE 11, 25: PRINT "Enter Book Name"; : INPUT N$
  84.     LOCATE 12, 25: PRINT "Enter Book Category"; : INPUT C$
  85.     LOCATE 13, 25: PRINT "Enter Received Quantity"; : INPUT R
  86.     LOCATE 14, 25: PRINT "Enter Sold Quantity"; : INPUT S
  87.     LOCATE 15, 25: PRINT "Enter Price"; : INPUT P
  88.     SQ = R - S
  89.     WRITE #1, IC, N$, C$, R, S, SQ, P
  90. CLOSE #1
  91.     LOCATE 20, 23: PRINT "DO YOU WANT TO ADD MORE DATA(Y/N)?"; : INPUT CHECK$
  92.     IF UCASE$(CHECK$) = "Y" THEN GOTO avg
  93. END SUB
  94.  
  95. SUB bye
  96. COLOR 7, 1
  97. CLS
  98.  
  99. LOCATE 6, 18: PRINT STRING$(44, CHR$(196))
  100. LOCATE 6, 17: PRINT CHR$(218)
  101. LOCATE 6, 62: PRINT CHR$(191)
  102. LOCATE 8, 20: PRINT STRING$(40, CHR$(196))
  103. LOCATE 8, 19: PRINT CHR$(218)
  104. LOCATE 8, 60: PRINT CHR$(191)
  105. FOR I = 7 TO 20
  106.     LOCATE I, 17: PRINT CHR$(179)
  107.     LOCATE I, 62: PRINT CHR$(179)
  108.     IF I < 18 THEN
  109.         LOCATE I + 2, 19: PRINT CHR$(179)
  110.         LOCATE I + 2, 60: PRINT CHR$(179)
  111.     END IF
  112. NEXT
  113.  
  114. LOCATE 21, 17: PRINT CHR$(192)
  115. LOCATE 21, 18: PRINT STRING$(44, CHR$(196))
  116. LOCATE 21, 62: PRINT CHR$(217)
  117. LOCATE 19, 20: PRINT STRING$(40, CHR$(196))
  118. LOCATE 19, 19: PRINT CHR$(192)
  119. LOCATE 19, 60: PRINT CHR$(217)
  120. LOCATE 13, 20: PRINT STRING$(40, CHR$(196))
  121. COLOR 15 + 16
  122. LOCATE 7, 18: PRINT STRING$(44, CHR$(2))
  123. FOR I = 7 TO 19
  124.     LOCATE I, 18: PRINT "*"
  125.     LOCATE I, 61: PRINT "*"
  126. NEXT I
  127. LOCATE 20, 18: PRINT STRING$(44, CHR$(2))
  128. dtv = VAL(TIME$)
  129. dt = dtv - dtu
  130. COLOR 7
  131. LOCATE 10, 28: PRINT "Current Time:- "; TIME$
  132. LOCATE 13, 28: PRINT "Time Spent Logged in:"; dt; "secs"
  133. LOCATE 16, 30: PRINT "Logged off already?"
  134. LOCATE 18, 29: PRINT "Comeback for more soon ";
  135. END SUB
  136.  
  137. SUB Categry
  138. oof:
  139. OPEN "Inv.txt" FOR INPUT AS #1
  140. LOCATE 20, 24: PRINT "Enter item category to be searched"; : INPUT SD$
  141. COLOR 7, 1
  142. CLS
  143. CALL layout
  144. LOCATE 6, 31: PRINT "Category:"; SD$
  145. FLAG = 0
  146. a = 11
  147. ch = 8
  148. WHILE NOT EOF(1)
  149.     INPUT #1, C, N$, C$, R, S, SQ, P
  150.     IF UCASE$(SD$) = UCASE$(C$) THEN
  151.         LOCATE 10, 8: PRINT "Dew Code"
  152.         LOCATE 10, 21: PRINT "Book Name"
  153.         LOCATE 10, 33: PRINT "Category"
  154.         LOCATE 10, 46: PRINT "Stock Qty"
  155.         LOCATE 10, 63: PRINT "Price"
  156.  
  157.         FLAG = 1
  158.         IF ch MOD 8 = 0 THEN
  159.             LOCATE 20, 24: PRINT "Press any key to view more datas"; : a$ = INPUT$(1)
  160.             CLS
  161.             CALL layout
  162.             LOCATE 6, 35: PRINT "Display Items"
  163.             LOCATE 10, 8: PRINT "Dew Code"
  164.             LOCATE 10, 21: PRINT "Book Name"
  165.             LOCATE 10, 33: PRINT "Category"
  166.             LOCATE 10, 46: PRINT "Stock Qty"
  167.             LOCATE 10, 63: PRINT "Price"
  168.             a = 11
  169.         END IF
  170.  
  171.         LOCATE a, 10: PRINT C
  172.         LOCATE a, 21: PRINT N$
  173.         LOCATE a, 33: PRINT C$
  174.         LOCATE a, 49: PRINT SQ
  175.         LOCATE a, 64: PRINT SP
  176.         a = a + 1
  177.         ch = ch + 1
  178.  
  179.     END IF
  180. WEND
  181. CLOSE #1
  182. IF FLAG = 0 THEN LOCATE 15, 33: PRINT "DATA NOT FOUND"
  183. LOCATE 20, 28: PRINT "SEARCH ANOTHER DATA(Y/N)?"; : INPUT SE$
  184. IF UCASE$(SE$) = "Y" THEN GOTO oof
  185. END SUB
  186.  
  187. SUB delete
  188. OPEN "Inv.TXT" FOR INPUT AS #1
  189. OPEN "NEW.TXT" FOR OUTPUT AS #2
  190. LOCATE 22, 22: PRINT "Enter the Code of item to be deleted"; : INPUT D
  191. COLOR 7, 1
  192. CLS
  193. CALL layout
  194. LOCATE 6, 35: PRINT "Delete Item"
  195. FLAG = 0
  196. WHILE NOT EOF(1)
  197.     INPUT #1, C, N$, C$, R, S, SQ, P
  198.     IF D = C THEN
  199.         LOCATE 10, 8: PRINT "Dew Code"
  200.         LOCATE 10, 21: PRINT "Book Name"
  201.         LOCATE 10, 33: PRINT "Category"
  202.         LOCATE 10, 46: PRINT "Stock Qty"
  203.         LOCATE 10, 63: PRINT "Price"
  204.         LOCATE 11, 9: PRINT C
  205.         LOCATE 11, 21: PRINT N$
  206.         LOCATE 11, 33: PRINT C$
  207.         LOCATE 11, 49: PRINT SQ
  208.         LOCATE 11, 64: PRINT P
  209.         FLAG = 1
  210.         LOCATE 20, 20: PRINT "Are you sure to delete this record(Y/N)?"; : INPUT DI$
  211.         IF UCASE$(DI$) <> "Y" THEN
  212.             WRITE #2, C, N$, C$, R, S, SQ, P
  213.         ELSE
  214.             LOCATE 16, 33: PRINT "Record Deleted"
  215.         END IF
  216.     ELSE
  217.         WRITE #2, C, N$, C$, R, S, SQ, P
  218.     END IF
  219. WEND
  220. IF FLAG = 0 THEN LOCATE 15, 33: PRINT "DATA NOT FOUND"
  221. CLOSE #1, #2
  222. KILL "Inv.txt"
  223. NAME "NEW.TXT" AS "Inv.txt"
  224.  
  225. END SUB
  226.  
  227. SUB Disp
  228. OPEN "Inv.TXT" FOR INPUT AS #1
  229. COLOR 7, 1
  230. CLS
  231. CALL layout
  232. LOCATE 6, 35: PRINT "Books"
  233. LOCATE 10, 8: PRINT "Dew Code"
  234. LOCATE 10, 21: PRINT "Book Name"
  235. LOCATE 10, 33: PRINT "Category"
  236. LOCATE 10, 46: PRINT "Stock Qty"
  237. LOCATE 10, 63: PRINT "Price"
  238. a = 11
  239. ch = 1
  240. WHILE NOT EOF(1)
  241.     INPUT #1, C, N$, C$, R, S, SQ, P
  242.     IF ch MOD 8 = 0 THEN
  243.         LOCATE 20, 24: PRINT "Press any key to view more datas"; : a$ = INPUT$(1)
  244.         CLS
  245.         CALL layout
  246.         LOCATE 6, 35: PRINT "Display Items"
  247.         LOCATE 10, 8: PRINT "Item Code"
  248.         LOCATE 10, 21: PRINT "Item Name"
  249.         LOCATE 10, 33: PRINT "Category"
  250.         LOCATE 10, 46: PRINT "Stock Qty"
  251.         LOCATE 10, 63: PRINT "Price"
  252.         a = 11
  253.     END IF
  254.     LOCATE a, 10: PRINT C
  255.     LOCATE a, 21: PRINT N$
  256.     LOCATE a, 33: PRINT C$
  257.     LOCATE a, 49: PRINT SQ
  258.     LOCATE a, 64: PRINT P
  259.     a = a + 1
  260.     ch = ch + 1
  261. WEND
  262. CLOSE #1
  263.  
  264. END SUB
  265.  
  266. SUB edit
  267. OPEN "Inv.TXT" FOR INPUT AS #1
  268. OPEN "Inv.TXT" FOR INPUT AS #3
  269. OPEN "TEMP.TXT" FOR OUTPUT AS #2
  270. LOCATE 22, 15: PRINT "Enter code of item whose data is to be edited"; : INPUT E
  271. COLOR 7, 1
  272. FLAG = 0
  273. CLS
  274. CALL layout
  275. LOCATE 6, 35: PRINT "Edit Item"
  276.  
  277. WHILE NOT EOF(1)
  278.     INPUT #1, C, N$, C$, R, S, SQ, P
  279.     IF E = C THEN
  280.         FLAG = 1
  281.         LOCATE 10, 8: PRINT "Book Code"
  282.         LOCATE 10, 21: PRINT "Book Name"
  283.         LOCATE 10, 33: PRINT "Category"
  284.         LOCATE 10, 46: PRINT "Stock Qty"
  285.         LOCATE 10, 62: PRINT "Price"
  286.         LOCATE 11, 9: PRINT C
  287.         LOCATE 11, 21: PRINT N$
  288.         LOCATE 11, 33: PRINT C$
  289.         LOCATE 11, 49: PRINT SQ
  290.         LOCATE 11, 64: PRINT P
  291.         LOCATE 20, 20: PRINT "Do you want to edit this record(Y/N)?"; : INPUT ED$
  292.         IF UCASE$(ED$) = "Y" THEN
  293.  
  294.             CLS
  295.             DIM N(100)
  296.             ctr = 1
  297.             WHILE NOT EOF(3)
  298.                 INPUT #3, IC, N$, C$, R, S, SQ, P
  299.                 IF IC <> C THEN N(ctr) = IC
  300.                 ctr = ctr + 1
  301.             WEND
  302.             CLOSE #3
  303. here:
  304.             CALL layout
  305.             LOCATE 6, 35: PRINT "Edit Item"
  306.             LOCATE 10, 25: PRINT "Enter Item Code"; : INPUT C
  307.             FOR tt = 1 TO 100
  308.                 IF C = N(tt) THEN
  309.                     CLS
  310.                     LOCATE 10, 22: PRINT "Invalid item code.. TRY AGAIN!!"
  311.                     GOTO here
  312.                 END IF
  313.             NEXT tt
  314.  
  315.             LOCATE 11, 25: PRINT "Enter Book Name"; : INPUT N$
  316.             LOCATE 12, 25: PRINT "Enter Book Category"; : INPUT C$
  317.             LOCATE 13, 25: PRINT "Enter Received Quantity"; : INPUT R
  318.             LOCATE 14, 25: PRINT "Enter Sold Quantity"; : INPUT S
  319.             LOCATE 15, 25: PRINT "Enter Price"; : INPUT P
  320.  
  321.             SQ = R - S
  322.             WRITE #2, C, N$, C$, R, S, SQ, P
  323.             LOCATE 18, 33: PRINT "DATA EDITED"
  324.         ELSE
  325.             WRITE #2, C, N$, C$, R, S, SQ, P
  326.         END IF
  327.     ELSE
  328.         WRITE #2, C, N$, C$, R, S, SQ, P
  329.     END IF
  330. WEND
  331. IF FLAG = 0 THEN LOCATE 15, 33: PRINT "Data Not Found"
  332. CLOSE
  333. KILL "Inv.TXT"
  334. NAME "TEMP.TXT" AS "Inv.TXT"
  335. END SUB
  336.  
  337. SUB layout
  338. LOCATE 4, 6: PRINT CHR$(201)
  339. LOCATE 4, 73: PRINT CHR$(187)
  340. LOCATE 4, 7: PRINT STRING$(66, CHR$(205))
  341. LOCATE 6, 7: PRINT STRING$(66, CHR$(205))
  342. LOCATE 7, 30: PRINT "*"
  343. LOCATE 7, 51: PRINT "*"
  344. LOCATE 8, 30: PRINT STRING$(22, "*")
  345. LOCATE 9, 7: PRINT STRING$(66, CHR$(196))
  346. LOCATE 24, 7: PRINT STRING$(66, CHR$(205))
  347.  
  348. FOR I = 4 TO 22
  349.     LOCATE I, 6: PRINT CHR$(186)
  350.     LOCATE I, 73: PRINT CHR$(186)
  351. NEXT I
  352. LOCATE 5, 6: PRINT CHR$(204)
  353. LOCATE 5, 73: PRINT CHR$(185)
  354. LOCATE 8, 73: PRINT CHR$(182)
  355. LOCATE 8, 6: PRINT CHR$(199)
  356.  
  357.  
  358.  
  359. LOCATE 19, 6: PRINT CHR$(199)
  360. LOCATE 19, 7: PRINT STRING$(66, CHR$(196))
  361. LOCATE 19, 73: PRINT CHR$(182)
  362. LOCATE 21, 73: PRINT CHR$(185)
  363. LOCATE 21, 6: PRINT CHR$(204)
  364. LOCATE 23, 6: PRINT CHR$(200)
  365. LOCATE 23, 73: PRINT CHR$(188)
  366.  
  367. LOCATE 21, 7: PRINT STRING$(66, CHR$(205))
  368. COLOR 7, 1: LOCATE 4, 25: PRINT "The Dewey/Library Management System"
  369. COLOR 7, 1
  370.  
  371.  
  372.  
  373. END SUB
  374.  
  375. SUB main
  376. CLS
  377. CALL layout
  378. LOCATE 6, 36: PRINT "Main Menu"
  379. LOCATE 8, 11: PRINT CHR$(210)
  380. LOCATE 19, 11: PRINT CHR$(208)
  381. FOR j = 9 TO 18
  382.     LOCATE j, 11: PRINT CHR$(186)
  383. NEXT j
  384.  
  385. FOR k = 1 TO 7
  386.     a = k + 9
  387.     LOCATE a, 7: PRINT k
  388. NEXT k
  389.  
  390.  
  391.  
  392. LOCATE 10, 15
  393. PRINT "Add Book"
  394. LOCATE 11, 15
  395. PRINT "Display Books"
  396. LOCATE 12, 15
  397. PRINT "Search Book by Code"
  398. LOCATE 13, 15
  399. PRINT "Search Book by Category"
  400. LOCATE 14, 15
  401. PRINT "Edit Books"
  402. LOCATE 15, 15
  403. PRINT "Delete Book"
  404. LOCATE 16, 15
  405. PRINT "Exit"
  406.  
  407. END SUB
  408.  
  409. SUB Search
  410. agn:
  411. OPEN "Inv.TXT" FOR INPUT AS #1
  412.  
  413. LOCATE 20, 24: PRINT "Enter item code to be searched"; : INPUT SE
  414. COLOR 7, 1
  415. CLS
  416. CALL layout
  417. FLAG = 0
  418. LOCATE 6, 31: PRINT "Item  Code:"; SE
  419. a = 11
  420. WHILE NOT EOF(1)
  421.     INPUT #1, C, N$, C$, R, S, SQ, P
  422.     IF SE = C THEN
  423.         LOCATE 10, 8: PRINT "Item Code"
  424.         LOCATE 10, 21: PRINT "Item Name"
  425.         LOCATE 10, 33: PRINT "Category"
  426.         LOCATE 10, 46: PRINT "Stock Qty"
  427.         LOCATE 10, 63: PRINT "Price"
  428.  
  429.         FLAG = 1
  430.  
  431.         LOCATE a, 10: PRINT C
  432.         LOCATE a, 21: PRINT N$
  433.         LOCATE a, 33: PRINT C$
  434.         LOCATE a, 49: PRINT SQ
  435.         LOCATE a, 64: PRINT P
  436.         a = a + 1
  437.  
  438.     END IF
  439. WEND
  440. CLOSE #1
  441.  
  442. IF FLAG = 0 THEN LOCATE 15, 33: PRINT "DATA NOT FOUND"
  443. LOCATE 20, 28: PRINT "SEARCH ANOTHER DATA(Y/N)?"; : INPUT SE$
  444. IF UCASE$(SE$) = "Y" THEN GOTO agn
  445. END SUB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement