PayBill Management System Full Program
PayBill Management System Full Program
py
# config.py
DB_CONFIG = {
"host": "localhost",
"user": "root",
"password": "",
"database": "PayBillDB"
EMAIL_CONFIG = {
"email": "[email protected]",
"password": "yourpassword",
"smtp_server": "smtp.gmail.com",
"port": 587
database.py
# database.py
import mysql.connector
def connect_db():
try:
return mysql.connector.connect(**DB_CONFIG)
return None
if not conn:
return None
try:
cursor = conn.cursor(dictionary=True)
cursor.execute(query, params)
conn.commit()
if fetch_one:
return cursor.fetchone()
elif fetch_all:
return cursor.fetchall()
finally:
if conn.is_connected():
conn.close()
email_utils.py
# email_utils.py
import smtplib
import os
sender_email = EMAIL_CONFIG["email"]
sender_password = EMAIL_CONFIG["password"]
msg = MIMEMultipart()
msg['From'] = sender_email
msg['To'] = to_email
msg['Subject'] = subject
msg.attach(MIMEText(body, 'plain'))
if os.path.exists(pdf_path):
part.set_payload(attachment.read())
encoders.encode_base64(part)
part.add_header(
"Content-Disposition",
f"attachment; filename={os.path.basename(pdf_path)}",
msg.attach(part)
try:
server.starttls()
server.login(sender_email, sender_password)
except Exception as e:
finally:
server.quit()
reporting.py
# reporting.py
def generate_payment_trends():
query = """
"""
if not data:
return
plt.xlabel("Month")
plt.ylabel("Total Payments")
plt.xticks(rotation=45)
plt.tight_layout()
plt.savefig("payment_trends.png")
main.py
# main.py
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)
pdf.output(pdf_path)
def admin_dashboard():
print("4. Logout")
if choice == '1':
view_users()
view_bills()
generate_payment_trends()
print("Logging out...")
else:
print("Invalid choice!")
admin_dashboard()
if __name__ == "__main__":