@@ -139,6 +139,11 @@ def initial_check():
139
139
| | | | | | | | |
140
140
| | | | | | | | |
141
141
| | | | | | | | |
142
+ | | | | | | | | |
143
+ | | | | | | | | |
144
+ | | | | | | | | |
145
+ | | | | | | | | |
146
+ | | | | | | | | |
142
147
+-----------+----------+-------+--------+-----------+-------+-------------+------------+
143
148
\n \n
144
149
""" )
@@ -152,9 +157,15 @@ def initial_check():
152
157
| | | | | | |
153
158
| | | | | | |
154
159
| | | | | | |
160
+ | | | | | | |
161
+ | | | | | | |
162
+ | | | | | | |
163
+ | | | | | | |
164
+ | | | | | | |
155
165
+-------------+-------------+----------------+-------+-----------+--------------+
156
166
\n \n """ )
157
167
168
+
158
169
def addition_of_records_Member ():
159
170
'''
160
171
This function adds additional records to the table titled
@@ -270,7 +281,57 @@ def modify_records_in_member_table():
270
281
pass
271
282
272
283
273
- def return_of_books_and_fine_calculator ():#Not complete, add the returning book function
284
+ def issuing_books_to_member ():
285
+ '''
286
+ This function issues the book to the member
287
+ if the number of books issued is less than the alloted number of books
288
+ else it displays an appropriate message
289
+ '''
290
+
291
+ mem_code = int (input ('Enter the Member Code: ' ))
292
+
293
+ cur .execute ('select * from member where Member_Code = {}' .format (mem_code ))
294
+ member_record = cur .fetchall ()
295
+
296
+ for i in member_record :
297
+ max_limit = i [4 ]
298
+ number_of_issued_books = i [5 ]
299
+
300
+ if (max_limit - number_of_issued_books ) == 0 :
301
+ print ('You cannot issue any book.\n Kindly return some of the book(s) which you have issued.' )
302
+
303
+ else :
304
+ cur .execute ('select Book_Code, Sub_Code, Title, Author from library where Member_Code = 0' )
305
+ available_books = cur .fetchall ()
306
+
307
+ print ('\n \t Books which are available Currently: \n ' )
308
+ for i in available_books :
309
+ print ('Book Code: ' , i [0 ])
310
+ print ('Subject Code: ' , i [1 ])
311
+ print ('Title: ' , i [2 ])
312
+ print ('Author: ' , i [3 ])
313
+ print ('\n ' )
314
+
315
+ book_code_req_issue = i [0 ]
316
+
317
+ query = input ('Is this the book which you want to issue?(Y/n): ' )
318
+
319
+ if query .lower () == 'n' :
320
+ pass
321
+
322
+ else :
323
+ cur .execute ('select CURDATE' )
324
+ current_date = cur .fetchall ()
325
+
326
+ number_of_issued_books += 1
327
+ cur .execute ('update library set Member_Code = {} where Book_Code = {}' .format (mem_code , book_code_req_issue ))
328
+ cur .execute ('update library set Issue_Date = {} where Book_Code = {}' .format (current_date , book_code_req_issue ))
329
+ cur .execute ('update member set N_O_B_Issued = {} where Member_Code = {}' .format (number_of_issued_books , mem_code ))
330
+ cur .execute ('commit' )
331
+ break
332
+
333
+
334
+ def return_of_books_and_fine_calculator ():
274
335
'''
275
336
This function allows the returning of books and calculates the amount to be paid as fine
276
337
@@ -300,6 +361,9 @@ def return_of_books_and_fine_calculator():#Not complete, add the returning book
300
361
cur .execute ('select Book_Code from Library where Member_Code = {}' .format (m_code ))
301
362
issued_books_by_member = cur .fetchall ()
302
363
364
+ cur .execute ('select N_O_B_Issued from Member where Member_Code = {}' .format (m_code ))
365
+ books_issued = cur .fetchall ()
366
+
303
367
for j in issued_books_by_member :
304
368
if (book_code ,) == j :
305
369
print ("Book Found\n " )
@@ -332,6 +396,20 @@ def return_of_books_and_fine_calculator():#Not complete, add the returning book
332
396
333
397
else :
334
398
pass
399
+
400
+ return_query = input ('Do you want to return the book(Y/n): ' )
401
+ if return_query .lower () == 'y' :
402
+ for i in issued_books_by_member :
403
+ cur .execute ('update library set Issue_Date = "{}" and Member_Code = {}' .format (("1111-01-01" ), 0 ))
404
+ cur .execute ('update Member set N_O_B_Issued = {} where Member_Code = {}' .format ((books_issued - 1 ), m_code ))
405
+ cur .execute ('commit' )
406
+
407
+ else :
408
+ print ('Book not returned' )
409
+ print ('Setting issue date as Current date: {}' .format (curdate ))
410
+ cur .execute ('update library set Issue_Date = {} where Member_Code = {} and Book_Code = {}' .format (curdate , m_code , book_code ))
411
+ cur .execute ('commit' )
412
+
335
413
336
414
def availability_of_a_certain_book ():
337
415
'''
@@ -364,7 +442,6 @@ def availability_of_a_certain_book():
364
442
print ("Price: " , i [5 ])
365
443
print ('\n \n ' )
366
444
367
-
368
445
book_code = int (input ("Enter the Book Code: " ))
369
446
370
447
cur .execute ('select * from Library where Sub_Code like ("{}") and Book_Code = {}' .format (book_sub , book_code ))
@@ -425,6 +502,7 @@ def availability_of_a_certain_book():
425
502
else :
426
503
print ('The Book is Issued by another member\n ' )
427
504
505
+
428
506
def book_report ():
429
507
'''
430
508
Generates a Book Report which is ordered by
@@ -457,6 +535,7 @@ def book_report():
457
535
for i in list_subject :
458
536
print (i )
459
537
538
+
460
539
def books_issued_by_member ():
461
540
'''
462
541
This function generates a report which displays
@@ -490,6 +569,7 @@ def books_issued_by_member():
490
569
491
570
print ('Number of books issued by Member {} is/are: {}' .format (i , book_count ))
492
571
572
+
493
573
def available_books ():
494
574
'''
495
575
This function generates a report for
@@ -522,6 +602,7 @@ def available_books():
522
602
523
603
print ('There is / are {} available book(s)' .format (count_available ))
524
604
605
+
525
606
def book_defaulter ():
526
607
'''
527
608
This function displays the defaulters
@@ -562,6 +643,7 @@ def book_defaulter():
562
643
for i in defaulter_lst :
563
644
print (i )
564
645
646
+
565
647
def members_in_the_library ():
566
648
'''
567
649
This function displays all the
@@ -579,6 +661,7 @@ def members_in_the_library():
579
661
580
662
print ('There are {} registered members' .format (count_member ))
581
663
664
+
582
665
def Report_of_DataBase ():
583
666
'''
584
667
This function generates a report which consists of the following
@@ -614,22 +697,59 @@ def Report_of_DataBase():
614
697
else :
615
698
print ('Invalid Option Entered' )
616
699
700
+
701
+ def exit ():
702
+ '''
703
+ This function exists the code
704
+ and
705
+ Closes the connection to the DataBase
706
+ '''
707
+
708
+ print ('Closing connection to Server DataBase in....' )
709
+ for i in range (3 , 0 , - 1 ):
710
+ print (i , '\n ' )
711
+ time .sleep (1 )
712
+
713
+ print ('Connection Closed Successfully' )
714
+
715
+ cur .close ()
716
+
717
+
617
718
ans = 'y'
618
719
while ans .lower () == 'y' :
619
720
print ('\t \t \t \t Main Menu\n \n ' )
620
- print ('1. Addition of Books\n 2. Addition of Members\n 3. Modifying Records \n 4. Modifying Member info\n 5 . Issue Book\n 6 . Return Books' )
621
- print ('7 . Availability of a certain book\n 8 . Report\n \n ' )
721
+ print ('1. Addition of Books\n 2. Addition of Members\n 3. Modifying Member info\n 4 . Issue Book\n 5 . Return Books' )
722
+ print ('6 . Availability of a certain book\n 7 . Report\n 8. Exit \n \n ' )
622
723
623
724
choice = int (input ("Enter your choice: " ))
624
725
625
-
726
+ if choice == 1 :
727
+ addition_of_records_Library ()
728
+
729
+ elif choice == 2 :
730
+ addition_of_records_Member ()
731
+
732
+ elif choice == 3 :
733
+ modify_records_in_member_table ()
734
+
735
+ elif choice == 4 :
736
+ issuing_books_to_member ()
626
737
738
+ elif choice == 5 :
739
+ return_of_books_and_fine_calculator ()
627
740
628
- print ('Closing connection to Server DataBase in....' )
629
- for i in range (3 , 0 , - 1 ):
630
- print (i , '\n ' )
631
- time .sleep (1 )
741
+ elif choice == 6 :
742
+ availability_of_a_certain_book ()
632
743
633
- print ('Connection Closed Successfully' )
744
+ elif choice == 7 :
745
+ Report_of_DataBase ()
634
746
635
- cur .close ()
747
+ elif choice == 8 :
748
+ exit ()
749
+
750
+ else :
751
+ print ('Invalid Option Entered' )
752
+
753
+ print ('\n ' )
754
+ ans = input ('Do you wish to continue?(Y/n): ' )
755
+ print ()
0 commit comments