Archive

Posts Tagged ‘system’

Drafting New System

September 22, 2021 Leave a comment

Start to write down some notes and ideas for a new system/application using a self-brainstorming session.

I am always using the MindJet Maps app to draw the basic outlines of the application I want to work on.

Here is the first Draft of a Payroll System that I want to do in coming weeks. Not sure if I will use Python or MS-Excel to do this project.

Python: My Orders Tracker P-4

March 17, 2021 Leave a comment


Learning : Pythn, sqlite, Database, SQL
Subject: Create a system to track the orders

In this last part we will write the code to Edit an Order, in editing an order function first we will show all orders and will ask the user to select the one to be EDIT, then we will display that order detail on the screen and ask the user to confirm the action by entering ‘Y’ [our code will handel both y and Y]. We will ask the user about each attribute in the Order details if it need to be change or [Just press Enter to Keep the Current Data], also if the user enter ‘e’ or ‘E’ we will exit from the Editing mode.

Here is the code ..

# Function to Edit an Order

def edit_order():
    os.system('clear')
    print("\n==========[ Edit Orders ]==========")
    
    show_order('yes')
    
    edit_order = input('   Select the Order ID to be Edited. [E to Exit] > ')
    
    if edit_order in ['e','E'] : 
        return
    elif not edit_order.isnumeric() :
        input('\n   You need to enter an Order''s ID [Numeric]. .. Press any Key .. ')
        return 
               
    try:        
        
        c.execute ("select * from orders where o_id ={}".format(edit_order))  
        order_list = c.fetchone() 
        
        if order_list == [] :
            input('\n   ID {} Not Exsist. .. Press any key to continue.  '.format(edit_order))
            return
        
        os.system('clear')
        print("\n==========[ Edit Orders ]==========\n")
        print('\n   Details of the Order you select:\n ')
    
        print(" "*15,"ID: ",order_list[0])  
        print(" "*13,"Date: ",order_list[1])
        print(" "*5,"Order Number: ",order_list[2])
        print(" "*12,"Price: ",order_list[4])
        print(" "*9,"Quantity: ",order_list[5])
        print(" "*3,"Shipment Price: ",order_list[6])
        print(" "*7,"Total Cost:  {:.2f}".format((order_list[4]*order_list[5]) + order_list[6]))
        print(" "*6,"Description: ",order_list[3])
        print(" "*12,"Image:",order_list[8])
        print(" "*13,"Link:",order_list[7])
    
        user_confirm = input("\n\n   You Select to EDIT the above Order, Enter Y to confirm, E to Exit. > ") 
        if user_confirm in ['e','E'] : 
            input('\n   You entered ''E'' to Exit. Nothing  will be change. Press any key. ')
            return 
        
        if user_confirm in ['y','Y'] :
            #To Edit the order.. 
            
            print("#"*57)
            print("##"," "*51,"##")
            print("##   NOTE: Enter E any time to EXIT/Quit."," "*12,"##")
            print("##     OR  JUST Press Enter to keep the Current data."," ##")
            print("##"," "*51,"##")
            print("#"*57,)
            
            while True :
                 
                new_date = input (f'\n   The current date is: {order_list[1]}, Enter the New date as[dd-mm-yyyy] > ')
                
                if e_to_exit(new_date) =='e' : return
                if new_date =="" : break   # Break the while loop if the user want to keep the current Date.
                
                if date_validation (new_date) == 'valid' :
                    break           
                else :
                    print(date_validation (new_date))    
        
                      
            new_onum = input (f'\n   The current Order Number is: {order_list[2]}, Enter the New Order Number. [E to Exit]. > ')
            if e_to_exit(new_onum) =='e' : return           
            
            new_qunt = input (f'\n   The current Quantity is: {order_list[5]}, Enter the New Quantity. [E to Exit]. > ')
            if e_to_exit(new_qunt) =='e' : return
            
            new_price = input (f'\n   The current Price is: {order_list[4]}, Enter the New Price. [E to Exit]. > ')
            if e_to_exit(new_price) =='e' : return
            
            new_ship_price = input (f'\n   The current shipment Price is: {order_list[6]}, Enter the New Quantity. [E to Exit]. > ')
            if e_to_exit(new_ship_price) =='e' : return
            
            new_link = input (f'\n   The current link is: {order_list[7]}, Enter the New Link. [E to Exit]. > ')
            if e_to_exit(new_link) =='e' : return
            
            new_image = input (f'\n   The current Image is: {order_list[8]}, Enter the New Image (path). [E to Exit]. > ')
            if e_to_exit(new_image) =='e' : return
                        
            
            new_desc = input (f'\n   The current Description is:\n     {order_list[3]}.\n\n      Enter the New Description. [E to Exit]. > ')
            if e_to_exit(new_image) =='e' : return
            
            
            # Updating the record in the DataBase. 
            if new_date > '' and new_date != "e" :
                c.execute("update orders set order_date = '{}' where o_id = {}".format(new_date,int(order_list[0]))) 
                db_conn.commit()
            
            if new_onum > '' and new_onum != "e" :
                c.execute("update orders set order_num = '{}' where o_id = {}".format(new_onum,int(order_list[0]))) 
                db_conn.commit() 
        
            if new_qunt > '' and new_qunt != "e" :
                c.execute("update orders set order_quantity = '{}' where o_id = {}".format(new_qunt,int(order_list[0]))) 
                db_conn.commit() 
                        
            if new_price > '' and new_price != "e" :
                c.execute("update orders set order_price = '{}' where o_id = {}".format(new_price,int(order_list[0]))) 
                db_conn.commit() 
            
            if new_ship_price > '' and new_ship_price != "e" :
                c.execute("update orders set order_price = '{}' where o_id = {}".format(new_ship_price,int(order_list[0]))) 
                db_conn.commit() 
                                
            if new_link > '' and new_link != "e" :
                c.execute("update orders set order_link = '{}' where o_id = {}".format(new_link,int(order_list[0]))) 
                db_conn.commit() 
                           
            if new_image > '' and new_image != "e" :
                c.execute("update orders set order_img = '{}' where o_id = {}".format(new_image,int(order_list[0]))) 
                db_conn.commit() 
             
            if new_desc > '' and new_image != "e" : 
                new_desc = " ".join([word.capitalize() for word in new_desc.split(" ")]) 
    
                c.execute("update orders set order_desc = '{}' where o_id = {}".format(new_desc,int(order_list[0]))) 
                db_conn.commit() 
            
            input('\n   One record has been EDITED and Saved... \n      ... Press any key to Continue ...')   
    
        else:        
            input('\n      Wrong input ... Press any key to continue ..')    
    
    except:
        pass

[All the System Codes available in Download Page.]



Finish: Now we have an application that will store and retrieve our simple order data.
Enhancement:
We can do some enhancement in [link and image] data part to show and display them in better way.


Part 1 Part 2 Part 3 Part 4



To Download my Python code (.py) files Click-Here




Follow me on Twitter..




By: Ali Radwani




Python: My Orders Tracker P-3

March 10, 2021 1 comment


Learning : Pythn, sqlite, Database, SQL
Subject: Create a system to track the orders

In this part we will write the code to Delete an Order that we have from our system, also we will add some validations on the user input, like if the user enter something not from the menu, or to do so, first we will re-call the show_orders() function that we have and passing the ‘yes’ parameter which means we are calling the function from inside another function [we will not print the function header, and will not clear the screen]. Then we will ask the user to select/Enter the ID of the order to be Deleted, after that we will print tha order details again on the screen and ask the user to confirm Deleting command by entering ‘Y’ … thats it.. let’s write the code..

# Delete Order

def del_order():
os.system('clear')
print("\n==========[ Delete Orders ]==========\n")

show_order('yes')

del_order = input(' Select the Order ID to be Deleted. [E to Exit] > ')

if not del_order.isnumeric() :
input('\n You need to enter an Orders ID [Numeric]. .. Press any Key .. ')
return

elif del_order in ['e','E'] :
return

try:
c.execute ("select * from orders where o_id ={}".format(del_order))
order_list = c.fetchone()

if order_list == [] :
input('\n ID {} not exsist.'.format(del_order))
return

os.system('clear')
print("\n==========[ Delete Orders ]==========\n")
print('\n Details of the Order you select:\n ')

print(" ID: ",order_list[0])
print(" Date: ",order_list[1])
print(" Order Number: ",order_list[2])
print(" Price: ",order_list[4])
print(" Quantity: ",order_list[5])
print(" Shipment Price: ",order_list[6])
print(" Total Cost: {:.2f}".format((order_list[4]*order_list[5]) + order_list[6]))
print("\n Description:",order_list[3])
print(" Image:",order_list[8])
print(" Link:",order_list[7])

user_confirm = input("\n\n You Select to DELETE the above Order, Enter Y to confirm, E to Exit. > ")
if user_confirm in ['y','Y'] :
#To Delete the order..
c.execute ("delete from orders where o_id ={}".format(int(del_order)))
db_conn.commit()

input('\n One record has been DELETED ... \n ... Press any key to Continue ...')

elif user_confirm in ['n','N']:
input("\n You select not to DELETE any thing. Press any key to Continue .. ")

elif user_confirm in ['e','E']:
input("\n You select stop the process and EXIT. ... Press any key to Continue .. ")
return

else:
input('\n Wrong input ... Press any key to continue ..')

except:
pass
The user select #3 from the menu to Delete an Order
ali radwani python project learning sql codeing
The screen display the list of orders we have in the system, and the user select Order ID Number 3 to delete it.
The screen display the details of the order ID 3 and ask the user to confirm the deleting by entering ‘Y’

In Next Post: In the coming post P4 , we will write the codes to Edit an order information.

Part 1 Part 2 Part 3 Part 4

To Download my Python code (.py) files Click-Here


Follow me on Twitter..


By: Ali Radwani

Library System with Excel -P1

November 11, 2020 3 comments


Learning :Excel formulas and VBA Cods
Subject: To Develop a Library System with Excel

Someone asked if we can do the Library Management system using Excel, so in the coming several posts we will try to develop an Excel File to store our Books. So I will stop the CRM Project and will work on Library System, we will use MS-EXCEL and VBA code to create a simple spreadsheet looking after our Books.

To start, do the following:
1. We will create an empty Excel file and call it “my Library System” and save it as “Excel Macro-Enabled Workbook.xlsm”
2. Create 7 Tabs(Sheets), name them as:
Menu, Books, Authors, Classifications, Data, Setting, Summary

In this post (Part-1), we will work on the Menu sheet, I will not concern about the themes and colors or fonts all this is back to each user to do formating as needed. So let’s begin with creating four buttons using the insert – shapes Rectangle: Rounded Corners.

We need to create four Rectangle: Rounded Corners, align them as you want and use any theme color, then give each a Captions as in the coming image..

Now, select the Books Button and with Right-Mouse-button select “Assign Macro” and from the new Assign Macro pop-up screen click on New.

This will launch the VBA Application with an open window to write our code, here is the code that if the user clicks on ‘SAY’: Books-Button the Books Sheet will be selected. In coming image, you will find the codes for all buttons we have in the Menu.

Also, we create a code to take us back to the Menu sheets and we call the button MENU, we will add this Button to all sheets we have.


    Recap this part:

  • 1. We Create an Excel file.
  • 2. We Create 7 Sheets and named them.
  • 3. We Create Buttons for the Menu Sheet.
  • 4. We Create the Home Button.
  • 5. We wrote the VBA code so we /the user can navigate thrugh the system.



:: Library System with Excel ::

Part 1 Part 2 Part 3 Part 4



To Download EXCEL (.xlsm) files Click-Here




Follow me on Twitter..




By: Ali Radwani