Python Project: Properties Maintenance System P10
Subject: Writing a Full Application for Properties Maintenance System [Property: Delete a Record]
Learning : Python, Math, SQL, Logeic
[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]
In this part we will write the Following:
1. Writing the Maintenance Request Menu.
2. Writing the Functions header for Four Functions:
- Add a Maintenance Request.
- Edit a Maintenance Request.
- Delete a Maintenance Request.
- Show Maintenance Requests.
3. Writing the code for the first Function: Add a Maintenance Request.
4. Writing the code to Validate the Date.[The code will be coped in from my Archive]
First: Maintenance Request Menu: We will use our standard template in all application we write it, so here is the code ..
![]() |
And here is the header of each Functions:
def add_maintenance_request() :
pass
def edit_maintenance_request() :
pass
def delete_maintenance_request() :
pass
def show_maintenance_request(inside) :
pass
First Function: def add_maintenance_request() : In this Function we will ask the user to select the ID of the Property that need Maintenance also to select the ID of Maintenance Job requered. If the Maintenance Job is Not Available in the List, then the user MUST go first to add it in the system, then come back and select it. During this Function coding we will use two Functions we have in this application [check_availability and show_lookup_data] also we will use the [Date Validation] Function we have develop some time ago [Click to Read the Post Ver.2019] {Updated Ver. used in this code.}
Here is a sample code for Selecting the Maintenance Job Requiered.
# Selecting the Maintenance Job Requiered print('\n\t Select an Item from the List for the Maintenance Job Requiered:\n') show_lookup_data('Yes' ,'main_job_list_t', 'ml_id') main_j_id = input ('\n\t Enter the ID of the Maintenance Job. [E to Exit] > ') if main_j_id in ['e','E'] : input('\n\t You Select to Exit from the Function.. Press any Key .. ') return if (check_availability('main_job_list_t', 'ml_id', int(main_j_id)) == None ) : input('\n\t The ID is NOT Available. Press any Key .. ') return
After collecting all information from the user, we will Insert/Add the data into the database using this SQL Statement..
# Add to the DataBase.
c.execute (“INSERT INTO maint_request_t (p_id , maint_for, date_time, job_s_id, notes) VALUES(:p_id , :maint_for, :date_time, :job_s_id, :notes)”,{“p_id”:mainte_req_id , “maint_for”:main_j_id, “date_time”:main_date, “job_s_id”:job_st_id, “notes”:the_note})
db_conn.commit()
Now we have the ability to add a Maintenance Request to our system.
NOTE: If you Download this Part you MUST Run the Option 82 (82. Delete the Data-Base and Start Again.) from the Main Menu to do the following Updates:
- Updates some attributes in the database level.
## Highly recommended ##
In Part-11 In the Next Part, we will write a function to show all Maintenance Request in the system.
:: PMS Parts ::
Part 1 | Part 2 | Part 3 | Part 4 |
Part 5 | Part 6 | Part 7 | Part 8 |
Part 9 | Part 10 | Part 11 | Part 12 |
..:: Have Fun with Coding ::.. 🙂
To Download my Python code (.py) files Click-Here
By: Ali Radwani
-
February 20, 2022 at 7:10 amPython Project: Properties Maintenance System P11 | Ali's Photography Space...
-
February 27, 2022 at 7:13 amPython Project: Properties Maintenance System P12 | Ali's Photography Space...