more tweaking of the display all list
This commit is contained in:
parent
c4d8ea9c08
commit
39b41430f6
@ -84,6 +84,7 @@
|
|||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
contactId = db~lastInsertRowId() /* the row id of 'contacts' table is the master id */
|
contactId = db~lastInsertRowId() /* the row id of 'contacts' table is the master id */
|
||||||
|
|
||||||
self~addPhoneNumber(contactId, contactDict["PHONE_TYPE"], contactDict["PHONE_NUMBER"])
|
self~addPhoneNumber(contactId, contactDict["PHONE_TYPE"], contactDict["PHONE_NUMBER"])
|
||||||
self~addEmailAddress(contactId, contactDict["EMAIL_TYPE"], contactDict["EMAIL_ADDRESS"])
|
self~addEmailAddress(contactId, contactDict["EMAIL_TYPE"], contactDict["EMAIL_ADDRESS"])
|
||||||
self~addRealAddress(contactId, contactDict~addressType, contactDict~street, contactDict~city, contactDict~state,
|
self~addRealAddress(contactId, contactDict~addressType, contactDict~street, contactDict~city, contactDict~state,
|
||||||
@ -109,10 +110,29 @@
|
|||||||
END
|
END
|
||||||
return contacts[1] /* Rexx is 1-indexed */
|
return contacts[1] /* Rexx is 1-indexed */
|
||||||
|
|
||||||
|
/***************************
|
||||||
|
* GET ALL CONTACT INFO *
|
||||||
|
***************************/
|
||||||
::METHOD getAllContacts
|
::METHOD getAllContacts
|
||||||
expose db
|
expose db
|
||||||
sql = "SELECT * FROM contacts ORDER BY last_name, first_name"
|
sql = "SELECT * FROM contacts ORDER BY last_name, first_name"
|
||||||
contacts = db~exec(sql, .true, .ooSQLite~OO_ARRAY_OF_DIRECTORIES)
|
contacts = db~exec(sql, .true, .ooSQLite~OO_ARRAY_OF_DIRECTORIES)
|
||||||
|
|
||||||
|
do contact over contacts
|
||||||
|
/* Get Phone Numbers */
|
||||||
|
psql = "SELECT * FROM phone_numbers WHERE contact_id = "contact["ID"]
|
||||||
|
phones = db~exec(psql,.true,.ooSQLite~OO_ARRAY_OF_DIRECTORIES)
|
||||||
|
phone = phones[1] /* just grab the first phone */
|
||||||
|
contact["PHONE_NUMBER"] = phone["NUMBER"]
|
||||||
|
contact["PHONE_TYPE"] = phone["TYPE"]
|
||||||
|
|
||||||
|
/* Now get email addresses */
|
||||||
|
esql = "SELECT * FROM email_addresses WHERE contact_id = "contact["ID"]
|
||||||
|
emails = db~exec(esql,.true,.ooSQLite~OO_ARRAY_OF_DIRECTORIES)
|
||||||
|
email = emails[1]
|
||||||
|
contact["EMAIL_ADDRESS"] = email["EMAIL"]
|
||||||
|
contact["EMAIL_TYPE"] = email["TYPE"]
|
||||||
|
END
|
||||||
return contacts
|
return contacts
|
||||||
|
|
||||||
::METHOD searchContacts
|
::METHOD searchContacts
|
||||||
@ -144,6 +164,9 @@
|
|||||||
end
|
end
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
|
/**************************
|
||||||
|
* DELETE CONTACT *
|
||||||
|
*************************/
|
||||||
::METHOD deleteContact
|
::METHOD deleteContact
|
||||||
expose db
|
expose db
|
||||||
use arg contactId
|
use arg contactId
|
||||||
|
@ -87,6 +87,9 @@
|
|||||||
panel~refresh
|
panel~refresh
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
|
/***********************
|
||||||
|
* SETUP MAIN MENU *
|
||||||
|
***********************/
|
||||||
::method setupMainMenu
|
::method setupMainMenu
|
||||||
expose mainMenu menuwin menu_items menu_keys selected
|
expose mainMenu menuwin menu_items menu_keys selected
|
||||||
use arg win
|
use arg win
|
||||||
@ -106,12 +109,14 @@
|
|||||||
menu_items = .array~of("[A]dd Contact", "[D]elete Contact", "[E]dit Contact", "[S]earch", "[L]ist All", "[Q]uit")
|
menu_items = .array~of("[A]dd Contact", "[D]elete Contact", "[E]dit Contact", "[S]earch", "[L]ist All", "[Q]uit")
|
||||||
menu_keys = .array~of("a", "d", "e", "s", "l", "q")
|
menu_keys = .array~of("a", "d", "e", "s", "l", "q")
|
||||||
|
|
||||||
/* Display menu items */
|
|
||||||
.environment~selected = 1
|
.environment~selected = 1
|
||||||
self~DrawMenu(menuwin, menu_items, .environment~selected, win)
|
self~DrawMenu(menuwin, menu_items, .environment~selected, win)
|
||||||
menuwin~refresh
|
menuwin~refresh
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
|
/***********************
|
||||||
|
* DRAW MENU *
|
||||||
|
***********************/
|
||||||
::method DrawMenu
|
::method DrawMenu
|
||||||
expose win menu_items menu_keys selected mainwin
|
expose win menu_items menu_keys selected mainwin
|
||||||
use arg menuwin, items, selected, mainwin
|
use arg menuwin, items, selected, mainwin
|
||||||
@ -131,6 +136,9 @@
|
|||||||
menuwin~refresh
|
menuwin~refresh
|
||||||
return
|
return
|
||||||
|
|
||||||
|
/***********************
|
||||||
|
* DROP WINDOW *
|
||||||
|
***********************/
|
||||||
::method dropWindow
|
::method dropWindow
|
||||||
expose win menuwin
|
expose win menuwin
|
||||||
use arg window
|
use arg window
|
||||||
@ -153,7 +161,7 @@
|
|||||||
max_y = win~lines
|
max_y = win~lines
|
||||||
max_x = win~cols
|
max_x = win~cols
|
||||||
form_height = 14
|
form_height = 14
|
||||||
form_width = 50
|
form_width = 55
|
||||||
start_y = (max_y - form_height) % 2
|
start_y = (max_y - form_height) % 2
|
||||||
start_x = (max_x - form_width) % 2
|
start_x = (max_x - form_width) % 2
|
||||||
formwin = self~DrawSubPanel(form_height, form_width, start_y, start_x, 0, "Add New Contact", .true)
|
formwin = self~DrawSubPanel(form_height, form_width, start_y, start_x, 0, "Add New Contact", .true)
|
||||||
@ -161,8 +169,8 @@
|
|||||||
/* Create form fields */
|
/* Create form fields */
|
||||||
formwin~mvaddstr(3, 2, "First Name: ")
|
formwin~mvaddstr(3, 2, "First Name: ")
|
||||||
formwin~mvaddstr(4, 2, "Last Name: ")
|
formwin~mvaddstr(4, 2, "Last Name: ")
|
||||||
formwin~mvaddstr(5, 2, "Phone: ")
|
formwin~mvaddstr(5, 2, "Phone: "); formwin~mvaddstr(5, 35, "Type: ");
|
||||||
formwin~mvaddstr(6, 2, "Email: ")
|
formwin~mvaddstr(6, 2, "Email: "); formwin~mvaddstr(7, 2, "Email Type: ");
|
||||||
formwin~mvaddstr(form_height-2, 2, "[Enter] to save, [Esc] to cancel")
|
formwin~mvaddstr(form_height-2, 2, "[Enter] to save, [Esc] to cancel")
|
||||||
formwin~refresh()
|
formwin~refresh()
|
||||||
|
|
||||||
@ -178,11 +186,21 @@
|
|||||||
RETURN
|
RETURN
|
||||||
END
|
END
|
||||||
phone = self~getInputField(formwin, 5, 14, 15)
|
phone = self~getInputField(formwin, 5, 14, 15)
|
||||||
|
if phone = .nil then do
|
||||||
|
self~dropWindow(formwin)
|
||||||
|
RETURN
|
||||||
|
END
|
||||||
|
phone_type = self~getInputField(formwin, 5, 45, 15)
|
||||||
if phone = .nil then do
|
if phone = .nil then do
|
||||||
self~dropWindow(formwin)
|
self~dropWindow(formwin)
|
||||||
RETURN
|
RETURN
|
||||||
END
|
END
|
||||||
email = self~getInputField(formwin, 6, 14, 30)
|
email = self~getInputField(formwin, 6, 14, 30)
|
||||||
|
if email = .nil then do
|
||||||
|
self~dropWindow(formwin)
|
||||||
|
RETURN
|
||||||
|
END
|
||||||
|
email_type = self~getInputField(formwin, 7, 14, 15)
|
||||||
if email = .nil then do
|
if email = .nil then do
|
||||||
self~dropWindow(formwin)
|
self~dropWindow(formwin)
|
||||||
RETURN
|
RETURN
|
||||||
@ -198,8 +216,10 @@
|
|||||||
contactDict = .Directory~new()
|
contactDict = .Directory~new()
|
||||||
contactDict["FIRST_NAME"] = firstName
|
contactDict["FIRST_NAME"] = firstName
|
||||||
contactDict["LAST_NAME"] = lastName
|
contactDict["LAST_NAME"] = lastName
|
||||||
contactDict["PHONE"] = phone
|
contactDict["PHONE_NUMBER"] = phone
|
||||||
contactDict["EMAIL"] = email
|
contactDict["PHONE_TYPE"] = phone_type
|
||||||
|
contactDict["EMAIL_ADDRESS"] = email
|
||||||
|
contactDict["EMAIL_TYPE"] = email_type
|
||||||
result = db~addContact(contactDict)
|
result = db~addContact(contactDict)
|
||||||
|
|
||||||
/* Display result message */
|
/* Display result message */
|
||||||
@ -267,7 +287,7 @@
|
|||||||
max_y = win~lines
|
max_y = win~lines
|
||||||
max_x = win~cols
|
max_x = win~cols
|
||||||
list_height = max_y - 5
|
list_height = max_y - 5
|
||||||
list_width = 70
|
list_width = max_x - 23
|
||||||
start_y = (max_y - list_height) % 2
|
start_y = (max_y - list_height) % 2
|
||||||
start_x = (max_x - list_width) % 2
|
start_x = (max_x - list_width) % 2
|
||||||
|
|
||||||
@ -277,27 +297,25 @@
|
|||||||
|
|
||||||
/* Display column headers */
|
/* Display column headers */
|
||||||
listwin~attron(listwin~A_BOLD)
|
listwin~attron(listwin~A_BOLD)
|
||||||
listwin~mvaddstr(3, 2, "ID")
|
listwin~mvaddstr(4, 2, "ID")
|
||||||
listwin~mvaddstr(3, 6, "First Name")
|
listwin~mvaddstr(4, 6, "First Name")
|
||||||
listwin~mvaddstr(3, 22, "Last Name")
|
listwin~mvaddstr(4, 18, "Last Name")
|
||||||
listwin~mvaddstr(4, 2, "-- ---------- ---------")
|
listwin~mvaddstr(4, 30, "Phone")
|
||||||
/* listwin~mvaddstr(2, 38, "Phone")
|
listwin~mvaddstr(4, 50, "Email")
|
||||||
listwin~mvaddstr(2, 54, "Email") */
|
listwin~mvaddstr(5, 2, "-- ---------- --------- --------------- ------------------")
|
||||||
listwin~attroff(listwin~A_BOLD)
|
listwin~attroff(listwin~A_BOLD)
|
||||||
|
|
||||||
/* Get all contacts */
|
|
||||||
contacts = db~getAllContacts()
|
contacts = db~getAllContacts()
|
||||||
|
|
||||||
/* Display contacts */
|
/* Display contacts */
|
||||||
if contacts~items > 0 then do
|
if contacts~items > 0 then do
|
||||||
do i = 1 to contacts~items
|
do i = 1 to contacts~items
|
||||||
contact = contacts[i]
|
contact = contacts[i]
|
||||||
listwin~mvaddstr(i+4, 2, contact['ID'])
|
listwin~mvaddstr(i+5, 2, contact['ID'])
|
||||||
listwin~mvaddstr(i+4, 6, contact['FIRST_NAME'])
|
listwin~mvaddstr(i+5, 6, contact['FIRST_NAME'])
|
||||||
listwin~mvaddstr(i+4, 22, contact['LAST_NAME'])
|
listwin~mvaddstr(i+5, 18, contact['LAST_NAME'])
|
||||||
/* listwin~mvaddstr(i+3, 38, contact['phone'])
|
listwin~mvaddstr(i+5, 30, contact['PHONE_NUMBER'])
|
||||||
listwin~mvaddstr(i+3, 54, contact['email']) */
|
listwin~mvaddstr(i+5, 50, contact['EMAIL_ADDRESS'])
|
||||||
|
|
||||||
/* Break if we run out of screen space */
|
/* Break if we run out of screen space */
|
||||||
if i > list_height-7 then LEAVE
|
if i > list_height-7 then LEAVE
|
||||||
end
|
end
|
||||||
@ -305,12 +323,7 @@
|
|||||||
else do
|
else do
|
||||||
listwin~mvaddstr(5, 5, "No contacts found.")
|
listwin~mvaddstr(5, 5, "No contacts found.")
|
||||||
end
|
end
|
||||||
/*
|
|
||||||
listwin~mvaddstr(list_height-1, 2, "Press any key to return to main menu")
|
|
||||||
listwin~refresh()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Wait for any key */
|
|
||||||
listwin~getch()
|
listwin~getch()
|
||||||
self~dropWindow(listwin)
|
self~dropWindow(listwin)
|
||||||
RETURN
|
RETURN
|
||||||
@ -352,6 +365,9 @@
|
|||||||
self~displaySearchResults(term)
|
self~displaySearchResults(term)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
/**************************
|
||||||
|
* DISPLAY SEARCH RESULTS *
|
||||||
|
**************************/
|
||||||
::METHOD displaySearchResults
|
::METHOD displaySearchResults
|
||||||
expose win menuwin db
|
expose win menuwin db
|
||||||
use arg term
|
use arg term
|
||||||
@ -408,7 +424,9 @@
|
|||||||
end
|
end
|
||||||
return buffer
|
return buffer
|
||||||
|
|
||||||
|
/***************/
|
||||||
/** MAIN LOOP **/
|
/** MAIN LOOP **/
|
||||||
|
/***************/
|
||||||
::method mainLoop
|
::method mainLoop
|
||||||
expose win mainMenu menuwin selected menu_items menu_keys
|
expose win mainMenu menuwin selected menu_items menu_keys
|
||||||
menuwin~refresh
|
menuwin~refresh
|
||||||
@ -462,7 +480,9 @@
|
|||||||
end /* do while running */
|
end /* do while running */
|
||||||
return
|
return
|
||||||
|
|
||||||
/* Process selection */
|
/***********************
|
||||||
|
* PROCESS SELECTION *
|
||||||
|
***********************/
|
||||||
::METHOD ProcessSelection
|
::METHOD ProcessSelection
|
||||||
expose menu_items menu_keys
|
expose menu_items menu_keys
|
||||||
use arg menuwin, key_char
|
use arg menuwin, key_char
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user