-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBugTrackingSystem.py
More file actions
1351 lines (1046 loc) · 54.9 KB
/
BugTrackingSystem.py
File metadata and controls
1351 lines (1046 loc) · 54.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import db
import mysql.connector
# Establish database connection
def admin_module():
print("Admin Module")
while True:
print("Admin Services:")
print("1. Manage Services (View, Search)")
print("2. Manage Employee (Add, View, Search, Edit, Activate/Deactivate)")
print("3. Manage Bug (View, Search, Assign Bug to Expert)")
print("4. Logout")
choice = input("Enter your choice: ")
if choice == "1":
# Code for managing services
def manage_services ( ) :
print( "Manage Services" )
while True :
print( "1. View Services" )
print( "2. Search Services" )
print( "3. Add Service" )
print( "4. Update Service" )
print( "5. Delete Service" )
print( "6. Go back" )
choice = input( "Enter your choice: " )
if choice == "1" :
# Code for viewing services
def view_services ( ) :
print( "View Services" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor()
try :
# SQL query to fetch all services
query = "SELECT * FROM services"
# Execute the query
cursor.execute( query )
# Fetch all the results
services = cursor.fetchall()
if services :
# Display the services
for service in services :
print( service ) # Modify this to format the output as per your requirement
else :
print( "No services found." )
except mysql.connector.Error as err :
print( "Error occurred while fetching services:" , err )
cursor.close( )
cnx.close( )
pagebreak()
view_services( )
elif choice == "2" :
# Code for searching services
def search_services ( ) :
print ( "Search Services" )
# Connect to the database
cnx = getBTSdatabase ( )
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
try :
# Prompt the user to enter search criteria
criteria = input ( "Enter search criteria: " )
# SQL query to search services based on criteria
query = f"SELECT * FROM services WHERE name LIKE '%{criteria}%'"
# Execute the query
cursor.execute ( query )
# Fetch all the results
search_results = cursor.fetchall ( )
if search_results :
# Display the search results
for result in search_results :
print ( result ) # Modify this to format the output as per your requirement
else :
print ( "No services found with the specified criteria." )
except mysql.connector.Error as err :
print ( "Error occurred while searching services:" , err )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
pagebreak()
search_services ( )
elif choice == "3" :
# Code for adding a new service
def add_service ( ) :
print( "Add Service" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor( )
try :
# Prompt the user to enter service details
service_name = input( "Enter service name: " )
service_description = input( "Enter service description: " )
# SQL query to add a new service
query = f"INSERT INTO services (name, description) VALUES ('{service_name}', '{service_description}')"
# Execute the query
cursor.execute( query )
# Commit the changes to the database
cnx.commit( )
print( "Service added successfully." )
except mysql.connector.Error as err :
print( "Error occurred while adding a service:" , err )
# Close the cursor and database connection
cursor.close( )
cnx.close( )
pagebreak()
add_service( )
elif choice == "4" :
# Code for updating a service
def update_service ( ) :
print( "Update Service" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor( )
try :
# Prompt the user to enter the service ID to update
service_id = input( "Enter the service ID to update: " )
# Prompt the user to enter the updated service details
updated_name = input( "Enter updated service name: " )
updated_description = input( "Enter updated service description: " )
# SQL query to update the service
query = f"UPDATE services SET name = '{updated_name}', description = '{updated_description}' WHERE id = '{service_id}'"
# Execute the query
cursor.execute( query )
# Commit the changes to the database
cnx.commit( )
print( "Service updated successfully." )
except mysql.connector.Error as err :
print( "Error occurred while updating a service:" , err )
# Close the cursor and database connection
cursor.close( )
cnx.close( )
pagebreak()
update_service( )
elif choice == "5" :
# Code for deleting a service
def delete_service ( ) :
print( "Delete Service" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor( )
try :
# Prompt the user to enter the service ID to delete
service_id = input( "Enter the service ID to delete: " )
# SQL query to delete the service
query = f"DELETE FROM services WHERE id = '{service_id}'"
# Execute the query
cursor.execute( query )
# Commit the changes to the database
cnx.commit( )
print( "Service deleted successfully." )
except mysql.connector.Error as err :
print( "Error occurred while deleting a service:" , err )
# Close the cursor and database connection
cursor.close( )
cnx.close( )
pagebreak()
delete_service( )
elif choice == "6" :
# Go back to the previous menu
break
else :
print( "Invalid choice. Please try again." )
pagebreak()
manage_services()
elif choice == "2":
# Code for managing employees
def manage_employees ( ) :
print ( "Manage Employees" )
print ( "1. Add New (Admin or Expert)" )
print ( "2. View All" )
print ( "3. Search - by Employee Name" )
print ( "4. Search - by Employee Login Id" )
print ( "5. Search - by Employee Type" )
print ( "6. Activate or Deactivate" )
print ( "7. Change Password" )
employee_choice = input ( "Enter your choice: " )
if employee_choice == "1" :
# Code for adding a new employee
def add_employee ( ) :
# Code for adding a new employee
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
# Get employee details from user input
empLoginId = input ( "Enter employee login ID: " )
empPassword = input ( "Enter employee password: " )
empType = input ( "Enter employee type (Admin or Expert): " )
empName = input ( "Enter employee name: " )
empPhone = input ( "Enter employee phone number: " )
empEmail = input ( "Enter employee email address: " )
# Insert the employee details into the database
insert_query = "INSERT INTO employee (empLoginId, empPassword, empType, empName, empPhone, empEmail) VALUES (%s, %s, %s, %s, %s, %s)"
values = (empLoginId , empPassword , empType , empName , empPhone , empEmail) ##empLoginId, empPassword, empType, empName, empPhone, empEmail
cursor.execute ( insert_query , values )
cnx.commit()
print ( "Employee added successfully." )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
pagebreak()
add_employee ( )
elif employee_choice == "2" :
# Code for viewing all employees
def view_all_employees ( ) :
# Code for viewing all employees
# Connect to the database
cnx = getBTSdatabase ( )
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
# Retrieve all employees from the database
select_query = "SELECT * FROM employee"
cursor.execute ( select_query )
results = cursor.fetchall ( )
# Display the retrieved employee data
if results :
print ( "All Employees:" )
for row in results :
print ( "Employee Login ID:" , row [ 0] )
print ( "Employee Password:" , row [ 1 ] )
print ( "Employee Type:" , row [ 2 ] )
print ( "Employee Name:" , row [ 3 ] )
print ( "Employee Phone:" , row [ 4 ] )
print ( "Employee Email:" , row [ 5 ] )
print ( "Employee Status:" , row [ 6 ] )
print ( "----------------------" )
else :
print ( "No employees found." )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
pagebreak()
view_all_employees ( )
elif employee_choice == "3" :
# Code for searching employees by name
def search_employee_by_name ( ) :
# Code for searching employees by name
emp_name = input ( "Enter employee name: " )
# Connect to the database
cnx = getBTSdatabase ( )
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
# Retrieve employees by name from the database
select_query = "SELECT * FROM employee WHERE empName LIKE %s"
cursor.execute ( select_query , (f'%{emp_name}%' ,) )
results = cursor.fetchall ( )
# Display the retrieved employee data
if results :
print ( "Employees with name containing" , emp_name + ":" )
for row in results :
print ( "Employee ID:" , row [ 0 ] )
print ( "Employee Login ID:" , row [ 1 ] )
print ( "Employee Password:" , row [ 2 ] )
print ( "Employee Type:" , row [ 3 ] )
print ( "Employee Phone:" , row [ 4 ] )
print ( "Employee Email:" , row [ 5 ] )
print ( "Employee Status:" , row [ 6 ] )
print ( "----------------------" )
else :
print ( "No employees found with name containing" , emp_name )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
pagebreak ( )
search_employee_by_name ( )
elif employee_choice == "4" :
# Code for searching employees by login ID
def search_employee_by_login_id ( ) :
# Code for searching employees by login ID
emp_login_id = input ( "Enter employee login ID: " )
# Connect to the database
cnx = getBTSdatabase ( )
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
# Retrieve employee by login ID from the database
select_query = "SELECT * FROM employee WHERE empLoginId = %s"
cursor.execute ( select_query , (emp_login_id ,) )
result = cursor.fetchone ( )
# Display the retrieved employee data
if result :
print ( "Employee ID:" , result [ 0 ] )
print ( "Employee Password:" , result [ 1 ] )
print ( "Employee Type:" , result [ 2 ] )
print ( "Employee Name:" , result [ 3 ] )
print ( "Employee Phone:" , result [ 4 ] )
print ( "Employee Email:" , result [ 5 ] )
print ( "Employee Status:" , result [ 6 ] )
else :
print ( "No employee found with login ID" , emp_login_id )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
pagebreak()
pass
search_employee_by_login_id ( )
elif employee_choice == "5" :
# Code for searching employees by type
def search_employee_by_type ( ) :
# Code for searching employees by type
emp_type = input ( "Enter employee type (ADMIN/EXPERT): " )
# Connect to the database
cnx = getBTSdatabase ( )
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
# Retrieve employees by type from the database
select_query = "SELECT * FROM employee WHERE empType = %s"
cursor.execute ( select_query , (emp_type ,) )
results = cursor.fetchall ( )
# Display the retrieved employee data
if results :
print ( "Employees of type" , emp_type + ":" )
for row in results :
print ( "Employee ID:" , row [ 0 ] )
print ( "Employee Name:" , row [ 3 ] )
print ( "Employee Phone:" , row [ 4 ] )
print ( "Employee Email:" , row [ 5 ] )
print ( "Employee Status:" , row [ 6 ] )
print ( "----------------------" )
else :
print ( "No employees found for type" , emp_type )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
pagebreak()
pass
search_employee_by_type ( )
elif employee_choice == "6" :
# Code for activating or deactivating an employee
def activate_deactivate_employee ( ) :
# Code for activating or deactivating an employee
emp_login_id = input ( "Enter employee login ID: " )
action = input ( "Enter 'activate' or 'deactivate': " )
# Connect to the database
cnx = getBTSdatabase ( )
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
# Update the employee status in the database
update_query = "UPDATE employee SET empStatus = %s WHERE empLoginId = %s"
cursor.execute ( update_query , (action.upper ( ) , emp_login_id) )
cnx.commit ( )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
print ( "Employee status updated successfully." )
pass
pagebreak ( )
activate_deactivate_employee ( )
elif employee_choice == "7" :
# Code for changing employee password
def change_employee_password ():
# Code for changing employee password
emp_login_id = input ( "Enter employee login ID: " )
new_password = input ( "Enter new password: " )
# Connect to the database
cnx = getBTSdatabase ( )
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
# Update the employee password in the database
update_query = "UPDATE employee SET empPassword = %s WHERE empLoginId = %s"
cursor.execute ( update_query , (new_password , emp_login_id) )
cnx.commit ( )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
print ( "Employee password updated successfully." )
pass
pagebreak ( )
change_employee_password ( )
manage_employees()
elif choice == "3":
# Code for managing bugs
def manage_bugs ( ) :
print ( "Manage Bugs" )
# Code for managing bugs goes here
while True :
print ( "1. View All Bugs" )
print ( "2. Search Bugs by Bug ID" )
print ( "3. Search Bugs by Status" )
print ( "4. Assign Bug to Expert" )
print ( "5. Go back" )
choice = input ( "Enter your choice: " )
if choice == "1" :
# Code for viewing all bugs
def view_all_bugs ( ) :
print ( "View All Bugs" )
# Fetch and display all bugs from the database
# Example code:
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
try :
# SQL query to fetch all bugs
query = "SELECT * FROM Bug"
# Execute the query
cursor.execute ( query )
# Fetch all the bugs
Bug = cursor.fetchall ( )
if Bug :
# Display the bug details
for Bug in Bug :
print ( Bug ) # Modify this to format the output as per your requirement
else :
print ( "No bugs found." )
except mysql.connector.Error as err :
print ( "Error occurred while viewing all bugs:" , err )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
pagebreak ( )
view_all_bugs ( )
elif choice == "2" :
# Code for searching bugs by bug ID
def search_bugs_by_id ( ) :
print ( "Search Bugs by Bug ID" )
# Prompt the user to enter the bug ID to search
bugId = input ( "Enter the bug ID: " )
# Search bugs by bug ID in the database
# Example code:
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
try :
# SQL query to search bugs by bug ID
query = f"SELECT * FROM Bug WHERE bugId = '{bugId}'"
# Execute the query
cursor.execute ( query )
# Fetch the bug
Bug = cursor.fetchone ( )
if Bug :
print ( Bug ) # Modify this to format the output as per your requirement
else :
print ( "Bug not found." )
except mysql.connector.Error as err :
print ( "Error occurred while searching bugs by ID:" , err )
# Close the cursor and database connection
cursor.close ( )
cnx.close ()
search_bugs_by_id ( )
elif choice == "3" :
# Code for searching bugs by status
def search_bugs_by_status ( ):
print ( "Search Bugs by Status" )
# Prompt the user to enter the bug status to search
bugStatus = input ( "Enter the bug status: " )
# Search bugs by status in the database
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
try :
# SQL query to search bugs by status
query = f"SELECT * FROM Bug WHERE bugStatus = '{bugStatus}'"
# Execute the query
cursor.execute ( query )
# Fetch all the bugs
Bug = cursor.fetchall ( )
if Bug :
# Display the bug details
for Bug in Bug :
print ( Bug ) # Modify this to format the output as per your requirement
else :
print ( "No bugs found with the specified status." )
except mysql.connector.Error as err :
print ( "Error occurred while searching bugs by status:" , err )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
pagebreak ( )
search_bugs_by_status ( )
elif choice == "4" :
# Code for assigning bug to expert
from datetime import datetime
def assign_bug_to_expert ( ) :
print ( "Assign Bug to Expert" )
# Prompt the user to enter the bug ID and expert ID
bugId = input ( "Enter the bug ID: " )
expertLoginId = input ( "Enter the expert ID: " )
# Assign bug to an expert in the database
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor ( )
try :
# SQL query to update the bug with the expert ID
expertAssignedDate = datetime.now ( )
query = f"UPDATE Bug SET expertLoginId = '{expertLoginId}', expertAssignedDate = '{expertAssignedDate}' WHERE bugId = '{bugId}'"
# Execute the query
cursor.execute ( query )
# Commit the changes to the database
cnx.commit ( )
print ( "Bug assigned to expert successfully." )
except mysql.connector.Error as err :
print ( "Error occurred while assigning bug to expert:" , err )
# Close the cursor and database connection
cursor.close ( )
cnx.close ( )
pagebreak ( )
assign_bug_to_expert ( )
elif choice == "5" :
# Go back to the previous menu
break
else :
print ( "Invalid choice. Please try again." )
manage_bugs()
elif choice == "4":
# Code for logout
from flask import session , redirect , url_for
def logout ( ) :
print ( "Logout" )
# Clear session data
session.clear ( )
# Redirect to the login page
return redirect ( url_for ( 'login' ) )
logout ( )
break
else:
print("Invalid choice. Please try again.")
# Customer Module
def customer_module():
print("Customer Module")
while True:
print("Customer Services:")
print("1. Create Account")
print("2. Update Account")
print("3. Post New Bug")
print("4. View All Bugs")
print("5. Search Bugs based on status")
print("6. View Bug Solution")
print("7. Change Password")
print("8. Logout")
choice = input("Enter your choice: ")
if choice == "1":
def create_account ( ) :
print( "Create Account" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor( )
try :
# Prompt the admin to enter the customer details
cust_login_id = input( "Enter customer login ID: " )
cust_password = input( "Enter customer password: " )
cust_name = input( "Enter customer name: " )
cust_age = int( input( "Enter customer age: " ) )
cust_phone = input( "Enter customer phone number: " )
cust_email = input( "Enter customer email: " )
# SQL query to insert the customer details into the database
query = f"INSERT INTO customer (custLoginId, custPassword, custName, custAge, custPhone, custEmail) " \
f"VALUES ('{cust_login_id}', '{cust_password}', '{cust_name}', {cust_age}, '{cust_phone}', '{cust_email}')"
# Execute the query
cursor.execute( query )
# Commit the changes to the database
cnx.commit( )
print( "Account created successfully." )
except mysql.connector.Error as err :
print( "Error occurred while creating an account:" , err )
# Close the cursor and database connection
cursor.close( )
cnx.close( )
pagebreak ( )
create_account ()
elif choice == "2":
def update_account ( ) :
print( "Update Account" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor( )
try :
# Prompt the admin to enter the customer login ID
cust_login_id = input( "Enter customer login ID: " )
# SQL query to check if the customer exists
check_query = f"SELECT * FROM customer WHERE custLoginId = '{cust_login_id}'"
# Execute the query
cursor.execute( check_query )
# Fetch the result
result = cursor.fetchone( )
if result :
print( "Customer found." )
print( "Enter new account details:" )
# Prompt the admin to enter the updated customer details
cust_password = input( "Enter customer password: " )
cust_name = input( "Enter customer name: " )
cust_age = int( input( "Enter customer age: " ) )
cust_phone = input( "Enter customer phone number: " )
cust_email = input( "Enter customer email: " )
# SQL query to update the customer details in the database
update_query = f"UPDATE customer SET custPassword = '{cust_password}', " \
f"custName = '{cust_name}', custAge = {cust_age}, " \
f"custPhone = '{cust_phone}', custEmail = '{cust_email}' " \
f"WHERE custLoginId = '{cust_login_id}'"
# Execute the query
cursor.execute( update_query )
# Commit the changes to the database
cnx.commit( )
print( "Account details updated successfully." )
else :
print( "Customer not found." )
except mysql.connector.Error as err :
print( "Error occurred while updating account details:" , err )
# Close the cursor and database connection
cursor.close( )
cnx.close( )
pagebreak ( )
update_account ( )
elif choice == "3":
def post_new_bug ( ) :
print( "Post New Bug" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor( )
try :
# Prompt the customer to enter the bug details
cust_login_id = input( "Enter your login ID: " )
product_name = input( "Enter product name: " )
bug_desc = input( "Enter bug description: " )
# SQL query to insert the bug details into the database
query = f"INSERT INTO bug (custLoginId, productName, bugDesc) " \
f"VALUES ('{cust_login_id}', '{product_name}', '{bug_desc}')"
# Execute the query
cursor.execute( query )
# Commit the changes to the database
cnx.commit( )
print( "Bug posted successfully." )
except mysql.connector.Error as err :
print( "Error occurred while posting a new bug:" , err )
# Close the cursor and database connection
cursor.close( )
cnx.close( )
pagebreak ( )
post_new_bug ( )
elif choice == "4":
def view_all_bugs ( ) :
print( "View All Bugs" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor( )
try :
# SQL query to fetch all bugs from the database
query = "SELECT * FROM bug"
# Execute the query
cursor.execute( query )
# Fetch all the bugs
bugs = cursor.fetchall( )
if bugs :
# Print the bug details
for bug in bugs :
bug_id = bug [ 0 ]
bug_posting_date = bug [ 1 ]
cust_login_id = bug [ 2 ]
bug_status = bug [ 3 ]
product_name = bug [ 4 ]
bug_desc = bug [ 5 ]
expert_assigned_date = bug [ 6 ]
expert_login_id = bug [ 7 ]
bug_solved_date = bug [ 8 ]
solution = bug [ 9 ]
print( f"Bug ID: {bug_id}" )
print( f"Posting Date: {bug_posting_date}" )
print( f"Customer Login ID: {cust_login_id}" )
print( f"Bug Status: {bug_status}" )
print( f"Product Name: {product_name}" )
print( f"Bug Description: {bug_desc}" )
print( f"Expert Assigned Date: {expert_assigned_date}" )
print( f"Expert Login ID: {expert_login_id}" )
print( f"Bug Solved Date: {bug_solved_date}" )
print( f"Solution: {solution}" )
print( )
else :
print( "No bugs found." )
except mysql.connector.Error as err :
print( "Error occurred while viewing all bugs:" , err )
# Close the cursor and database connection
cursor.close( )
cnx.close( )
pagebreak ( )
view_all_bugs()
elif choice == "5":
def search_bugs_by_status ( ) :
print( "Search Bugs by Status" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor( )
try :
# Prompt the admin to enter the bug status
bug_status = input( "Enter bug status to search: " )
# SQL query to search bugs by status
query = f"SELECT * FROM bug WHERE bugStatus = '{bug_status}'"
# Execute the query
cursor.execute( query )
# Fetch the bugs
bugs = cursor.fetchall( )
if bugs :
# Print the bug details
for bug in bugs :
bug_id = bug [ 0 ]
bug_posting_date = bug [ 1 ]
cust_login_id = bug [ 2 ]
bug_status = bug [ 3 ]
product_name = bug [ 4 ]
bug_desc = bug [ 5 ]
expert_assigned_date = bug [ 6 ]
expert_login_id = bug [ 7 ]
bug_solved_date = bug [ 8 ]
solution = bug [ 9 ]
print( f"Bug ID: {bug_id}" )
print( f"Posting Date: {bug_posting_date}" )
print( f"Customer Login ID: {cust_login_id}" )
print( f"Bug Status: {bug_status}" )
print( f"Product Name: {product_name}" )
print( f"Bug Description: {bug_desc}" )
print( f"Expert Assigned Date: {expert_assigned_date}" )
print( f"Expert Login ID: {expert_login_id}" )
print( f"Bug Solved Date: {bug_solved_date}" )
print( f"Solution: {solution}" )
print( )
else :
print( "No bugs found with the specified status." )
except mysql.connector.Error as err :
print( "Error occurred while searching bugs by status:" , err )
# Close the cursor and database connection
cursor.close( )
cnx.close( )
pagebreak ( )
search_bugs_by_status ( )
elif choice == "6":
def view_bug_solution ( ) :
print( "View Bug Solution" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor( )
try :
# Prompt the customer to enter the bug ID
bug_id = input( "Enter the Bug ID to view the solution: " )
# SQL query to fetch the bug solution from the database
query = f"SELECT solution FROM bug WHERE bugId = {bug_id}"
# Execute the query
cursor.execute( query )
# Fetch the bug solution
bug_solution = cursor.fetchone( )
if bug_solution :
solution = bug_solution [ 0 ]
print( f"Bug Solution: {solution}" )
else :
print( "No solution found for the specified bug ID." )
except mysql.connector.Error as err :
print( "Error occurred while viewing bug solution:" , err )
# Close the cursor and database connection
cursor.close( )
cnx.close( )
pagebreak ( )
view_bug_solution ( )
elif choice == "7":
def change_password ( ) :
print( "Change Password" )
# Connect to the database
cnx = getBTSdatabase()
# Create a cursor to execute SQL queries
cursor = cnx.cursor( )
try :