Advertisement
Guest User

Untitled

a guest
Apr 30th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 61.22 KB | None | 0 0
  1. indexing
  2. description: "Objects that represent an EV_TITLED_WINDOW.%
  3. %The original version of this class was generated by EiffelBuild."
  4. date: "$Date: 2003/09/11 21:03:35 $"
  5. revision: "$Revision: 1.3 $"
  6.  
  7. class
  8. MAIN_WINDOW
  9.  
  10. inherit
  11. MAIN_WINDOW_IMP
  12. FINE_LAYOUTS
  13. undefine default_create,copy
  14. end
  15. ITEM_LAYOUTS
  16. undefine default_create,copy
  17. end
  18. LOAN_LAYOUTS
  19. undefine default_create,copy
  20. end
  21. MEMBER_LAYOUTS
  22. undefine default_create,copy
  23. end
  24. RESERVATION_LAYOUTS
  25. undefine default_create,copy
  26. end
  27.  
  28.  
  29. feature {NONE} -- Initialization
  30.  
  31. user_initialization is
  32. -- called by `initialize'.
  33. -- Any custom user initialization that
  34. -- could not be performed in `initialize',
  35. -- (due to regeneration of implementation class)
  36. -- can be added here.
  37. do
  38. create db.make
  39. end
  40.  
  41.  
  42. feature {NONE} -- Implementation
  43.  
  44.  
  45.  
  46. close_window is
  47. -- Called by `close_request_actions' of `Current'.
  48. do
  49. exit_system
  50. end
  51.  
  52. feature -- Member Functions
  53.  
  54. logged_in_user:MEMBER
  55. set_user(s:STRING) is
  56. --
  57. do
  58. -- logged_in_user ?= db.members.item(s)
  59. -- if logged_in_user.member_type /= "Administrator" then
  60. if not(db.members.item(s).member_type.is_equal("Administrator")) then
  61. members_frame.destroy
  62. addcopybutton.hide
  63. add_item_button.hide
  64. delete_item_button.hide
  65. amend_item_button.hide
  66. view_item_copy_button.hide
  67. search_loan_button.hide
  68. add_loan_button.hide
  69. returns_loan_button.hide
  70. reservations_frame.destroy
  71. fines_frame.destroy
  72. add_loan_button.hide
  73. returns_loan_button.hide
  74. search_loan_button.hide
  75. lending_rights_button.hide
  76. overdue_button.hide
  77.  
  78. list_current_loans_button.select_actions.extend(agent g_list_current_loans(s))
  79. list_finished_loans_button.select_actions.extend(agent g_list_finished_loans(s))
  80.  
  81. end
  82.  
  83. end
  84.  
  85.  
  86.  
  87. add_member is
  88. -- Called by `select_actions' of `add_member_button'.
  89. do
  90. delete_member_button.disable_sensitive
  91. amend_member_button.disable_sensitive
  92. show_member_frame.wipe_out
  93. show_member_frame.extend (add_member_layout)
  94.  
  95. administrator_layout
  96. member_type.change_actions.extend (agent change_member_type)
  97. submit_button.select_actions.extend (agent add_member_to_members)
  98. clear_member_button.select_actions.extend (agent add_member)
  99. end
  100.  
  101.  
  102. change_member_type is
  103. --
  104. do
  105. if member_type.text.is_equal("Administrator") then
  106. main_area.wipe_out
  107. administrator_layout
  108.  
  109. elseif member_type.text.is_equal("Staff") then
  110. main_area.wipe_out
  111. staff_layout
  112.  
  113. elseif member_type.text.is_equal("Undergraduate") then
  114. main_area.wipe_out
  115. undergraduate_layout
  116.  
  117. elseif member_type.text.is_equal("Postgraduate") then
  118. main_area.wipe_out
  119. postgraduate_layout
  120.  
  121. elseif member_type.text.is_equal("Visitor") then
  122. main_area.wipe_out
  123. visitor_layout
  124. end
  125. end
  126.  
  127. add_member_to_members is
  128.  
  129. local
  130. a:ADMINISTRATOR
  131. sf:STAFF
  132. u:UNDERGRADUATE
  133. p:POSTGRADUATE
  134. v:VISITOR
  135. nid:STRING
  136. d:DATE
  137. year1,year2:STRING
  138. added:EV_INFORMATION_DIALOG
  139. do
  140. create d.make_now
  141. year1 := d.year.out.substring(3,3)
  142. year2 := d.year.out.substring(4,4)
  143. if not(validate("^Administrator|Staff|Undergraduate|Postgraduate|Visitor$",member_type.text,false)) then
  144. message_dialog("Invalid Member Type. Please select one from the list.")
  145. elseif not(validate("^[\w]{5}[\w]*$",password_field.text,false)) then
  146. message_dialog("Password must be at least 5 characters")
  147. elseif not(validate("^Active|Suspended|Inactive$",status.text,false)) then
  148. message_dialog("Invalid Status. Please select one from the list")
  149. elseif not(validate("^[A-Za-z]{2,4}$",name_title_field.text,false)) then
  150. message_dialog("Invalid Title. Please do not include a .")
  151. elseif not(validate("^[A-Z]{1}[A-Z]{0,1}$",initials_field.text,false)) then
  152. message_dialog("Please enter up to 2 initials without a space.")
  153. elseif not(validate("^[A-Za-z-']{2,30}$",last_name_field.text,false)) then
  154. message_dialog("Invalid Surname")
  155. elseif not(validate("^[\w\-\'0-9 ]{5,30}$",address1_field.text,false)) then
  156. message_dialog("Invalid Address1")
  157. elseif not(validate("^[\w-'0-9 ]{5,30}$",address2_field.text,false)) then
  158. message_dialog("Invalid Address2")
  159. elseif not(validate("^[A-Za-z-' ]{5,30}$",town_field.text,false)) then
  160. message_dialog("Invalid Town")
  161. elseif not(validate("^[A-Za-z-' ]{5,30}$",county_field.text,false)) then
  162. message_dialog("Invalid County")
  163. elseif not(validate("^[A-Z0-9]{3,4} [A-Z0-9]{3,4}$",postcode_field.text,false)) then
  164. message_dialog("Invalid Postcode. Letters must be uppercase and in the format: XXX[X] XXX[X]")
  165. elseif not(validate("^([0-2][0-9]|3[0-1])/(1[0-2]|0[0-9])/(19[0-9]{2})|2000$",dob_field.text,false))then
  166. message_dialog("Invalid Date of birth. Must be in the format DD/MM/YYYY.")
  167. else
  168.  
  169. nid:=db.next_user_id(member_type.text)
  170. if member_type.text.is_equal("Administrator") then
  171. create a
  172. a.make(nid, password_field.text, member_type.text, status.text, name_title_field.text, initials_field.text, last_name_field.text, address1_field.text, address2_field.text,
  173. town_field.text, county_field.text, postcode_field.text, dob_field.text, senior_button.is_selected)
  174. db.members.put(a,nid)
  175. create added.make_with_text ("New Member Added")
  176. added.set_title("Saved")
  177. added.show_modal_to_window (Current)
  178.  
  179. elseif member_type.text.is_equal("Staff") then
  180. if not(validate("^[A-Za-z-' ]{5,30}$",department_field.text,false)) then
  181. message_dialog("Invalid Department")
  182. else
  183. create sf
  184. sf.make(nid, password_field.text, member_type.text, status.text,name_title_field.text, initials_field.text, last_name_field.text, address1_field.text, address2_field.text,
  185. town_field.text, county_field.text, postcode_field.text, dob_field.text, department_field.text)
  186. db.members.extend(sf,nid)
  187. create added.make_with_text ("New Member Added")
  188. added.set_title("Saved")
  189. added.show_modal_to_window (Current)
  190. end
  191.  
  192. elseif member_type.text.is_equal("Undergraduate") then
  193. if not(validate("^[A-Z]{3}[A-Z]{4}$",course_field.text,false)) then
  194. message_dialog("Invalid Course. Must be in format AAAAAAA e.g. BSCCOMP")
  195. else
  196. create u
  197. u.make(nid, password_field.text, member_type.text, status.text, name_title_field.text, initials_field.text, last_name_field.text, address1_field.text, address2_field.text,
  198. town_field.text, county_field.text, postcode_field.text, dob_field.text, course_field.text, parttime_button.is_selected)
  199. db.members.extend(u,nid)
  200. create added.make_with_text ("New Member Added")
  201. added.set_title("Saved")
  202. added.show_modal_to_window (Current)
  203. end
  204.  
  205. elseif member_type.text.is_equal("Postgraduate") then
  206. if not(validate("^[A-Z]{3}[A-Z]{4}$",course_field.text,false)) then
  207. message_dialog("Invalid Course. Must be in format AAAAAAA e.g. BSCCOMP")
  208. else
  209. create p
  210. p.make(nid, password_field.text, member_type.text, status.text, name_title_field.text, initials_field.text, last_name_field.text, address1_field.text, address2_field.text,
  211. town_field.text, county_field.text, postcode_field.text, dob_field.text, course_field.text, parttime_button.is_selected)
  212. db.members.extend(p,nid)
  213. create added.make_with_text ("New Member Added")
  214. added.set_title("Saved")
  215. added.show_modal_to_window (Current)
  216. end
  217.  
  218. elseif member_type.text.is_equal("Visitor") then
  219. create v
  220. v.make(nid, password_field.text, member_type.text, status.text, name_title_field.text, initials_field.text, last_name_field.text, address1_field.text, address2_field.text,
  221. town_field.text, county_field.text, postcode_field.text, dob_field.text)
  222. db.members.extend(v,nid)
  223. create added.make_with_text ("New Member Added")
  224. added.set_title("Saved")
  225. added.show_modal_to_window (Current)
  226. end
  227. end
  228. end -- add_member
  229.  
  230. delete_member is
  231. -- Called by `select_actions' of `delete_member_button'.
  232. -- require
  233. -- s: members_list.selected_item /= void
  234. do
  235. show_member_frame.wipe_out
  236. delete_member_button.disable_sensitive
  237. amend_member_button.disable_sensitive
  238.  
  239. if db.members.item(members_list.selected_item.i_th(1)).num_of_items_out /= 0 then
  240. message_dialog("You cannot delete a member who has items on loan")
  241. else
  242. db.members.remove(members_list.selected_item.i_th(1))
  243. list_member
  244. end
  245.  
  246.  
  247. end -- delete_member
  248.  
  249.  
  250. amend_member is
  251. -- Called by `select_actions' of `amend_member_button'.
  252. local
  253. a:ADMINISTRATOR
  254. sf:STAFF
  255. u:UNDERGRADUATE
  256. p:POSTGRADUATE
  257. v:VISITOR
  258. memberid:STRING
  259. do
  260. delete_member_button.disable_sensitive
  261. amend_member_button.disable_sensitive
  262.  
  263. if members_list.selected_item /= void then
  264. create a
  265. create sf
  266. create u
  267. create p
  268. create v
  269. memberid := members_list.selected_item.i_th(1)
  270.  
  271. a ?= db.members.item(memberid)
  272. sf ?= db.members.item(memberid)
  273. u ?= db.members.item(memberid)
  274. p ?= db.members.item(memberid)
  275. v ?= db.members.item(memberid)
  276.  
  277. show_member_frame.wipe_out
  278. show_member_frame.extend(add_member_layout)
  279. member_type.disable_sensitive
  280. if a /= void then
  281. administrator_layout
  282. password_field.set_text(a.password)
  283. member_type.set_text(a.member_type)
  284. status.set_text(a.status)
  285. name_title_field.set_text(a.name_title)
  286. initials_field.set_text(a.initials)
  287. last_name_field.set_text(a.last_name)
  288. address1_field.set_text(a.address1)
  289. address2_field.set_text(a.address2)
  290. town_field.set_text(a.town)
  291. county_field.set_text(a.county)
  292. postcode_field.set_text(a.postcode)
  293. dob_field.set_text(a.date_of_birth.out)
  294. if a.senior = true
  295. then
  296. senior_button.enable_select
  297. end
  298.  
  299. submit_button.select_actions.extend (agent update_member("Administrator",memberid))
  300.  
  301. elseif sf /= void then
  302. staff_layout
  303. password_field.set_text(sf.password)
  304. member_type.set_text(sf.member_type)
  305. status.set_text(sf.status)
  306. name_title_field.set_text(sf.name_title)
  307. initials_field.set_text(sf.initials)
  308. last_name_field.set_text(sf.last_name)
  309. address1_field.set_text(sf.address1)
  310. address2_field.set_text(sf.address2)
  311. town_field.set_text(sf.town)
  312. county_field.set_text(sf.county)
  313. postcode_field.set_text(sf.postcode)
  314. dob_field.set_text(sf.date_of_birth.out)
  315. department_field.set_text(sf.department)
  316.  
  317. submit_button.select_actions.extend (agent update_member("Staff",memberid))
  318.  
  319. elseif u /= void then
  320. undergraduate_layout
  321. password_field.set_text(u.password)
  322. member_type.set_text(u.member_type)
  323. status.set_text(u.status)
  324. name_title_field.set_text(u.name_title)
  325. initials_field.set_text(u.initials)
  326. last_name_field.set_text(u.last_name)
  327. address1_field.set_text(u.address1)
  328. address2_field.set_text(u.address2)
  329. town_field.set_text(u.town)
  330. county_field.set_text(u.county)
  331. postcode_field.set_text(u.postcode)
  332. dob_field.set_text(u.date_of_birth.out)
  333. course_field.set_text(u.course)
  334. if u.parttime = true
  335. then
  336. parttime_button.enable_select
  337. end
  338. submit_button.select_actions.extend (agent update_member("Undergraduate",memberid))
  339.  
  340. elseif p /= void then
  341. postgraduate_layout
  342. password_field.set_text(p.password)
  343. member_type.set_text(p.member_type)
  344. status.set_text(p.status)
  345. name_title_field.set_text(p.name_title)
  346. initials_field.set_text(p.initials)
  347. last_name_field.set_text(p.last_name)
  348. address1_field.set_text(p.address1)
  349. address2_field.set_text(p.address2)
  350. town_field.set_text(p.town)
  351. county_field.set_text(p.county)
  352. postcode_field.set_text(p.postcode)
  353. dob_field.set_text(p.date_of_birth.out)
  354. course_field.set_text(p.course)
  355. if p.parttime = true
  356. then
  357. parttime_button.enable_select
  358. end
  359. submit_button.select_actions.extend (agent update_member("Postgraduate",memberid))
  360.  
  361. elseif v /= void then
  362. visitor_layout
  363. password_field.set_text(v.password)
  364. member_type.set_text(v.member_type)
  365. status.set_text(v.status)
  366. name_title_field.set_text(v.name_title)
  367. initials_field.set_text(v.initials)
  368. last_name_field.set_text(v.last_name)
  369. address1_field.set_text(v.address1)
  370. address2_field.set_text(v.address2)
  371. town_field.set_text(v.town)
  372. county_field.set_text(v.county)
  373. postcode_field.set_text(v.postcode)
  374. dob_field.set_text(v.date_of_birth.out)
  375.  
  376.  
  377. end
  378. end
  379. end
  380.  
  381.  
  382. update_member(type:STRING;memberid:STRING) is
  383. local
  384. a:ADMINISTRATOR
  385. sf:STAFF
  386. u:UNDERGRADUATE
  387. p:POSTGRADUATE
  388. v:VISITOR
  389. updated:EV_INFORMATION_DIALOG
  390. do
  391. if not(validate("^Administrator|Staff|Undergraduate|Postgraduate|Vistor$",member_type.text,false)) then
  392. message_dialog("Invalid Member Type. Please select one from the list.")
  393. elseif not(validate("^[\w]{5}[\w]*$",password_field.text,false)) then
  394. message_dialog("Password must be at least 5 characters")
  395. elseif not(validate("^Active|Suspended|Inactive$",status.text,false)) then
  396. message_dialog("Invalid Status. Please select one from the list")
  397. elseif not(validate("^[A-Za-z]{2,4}$",name_title_field.text,false)) then
  398. message_dialog("Invalid Title. Please do not include a .")
  399. elseif not(validate("^[A-Z]{1}[A-Z]{0,1}$",initials_field.text,false)) then
  400. message_dialog("Please enter up to 2 initials without a space.")
  401. elseif not(validate("^[A-Za-z-']{2,30}$",last_name_field.text,false)) then
  402. message_dialog("Invalid Surname")
  403. elseif not(validate("^[\w\-\'0-9 ]{5,30}$",address1_field.text,false)) then
  404. message_dialog("Invalid Address1")
  405. elseif not(validate("^[\w-'0-9 ]{5,30}$",address2_field.text,false)) then
  406. message_dialog("Invalid Address2")
  407. elseif not(validate("^[A-Za-z-' ]{5,30}$",town_field.text,false)) then
  408. message_dialog("Invalid Town")
  409. elseif not(validate("^[A-Za-z-' ]{5,30}$",county_field.text,false)) then
  410. message_dialog("Invalid County")
  411. elseif not(validate("^[A-Z0-9]{3,4} [A-Z0-9]{3,4}$",postcode_field.text,false)) then
  412. message_dialog("Invalid Postcode. Letters must be uppercase and in the format: XXX[X] XXX[X]")
  413. elseif not(validate("^[0-3][0-9]/[0-1][0-9]/[1-2][90][0-9][0-9]$",dob_field.text,false)) then
  414. message_dialog("Invalid Date of birth. Must be in the format DD/MM/YYYY")
  415. else
  416.  
  417. if type.is_equal("Administrator") then
  418. create a
  419. a.make(memberid, password_field.text, member_type.text, status.text, name_title_field.text, initials_field.text, last_name_field.text, address1_field.text, address2_field.text,
  420. town_field.text, county_field.text, postcode_field.text, dob_field.text, senior_button.is_selected)
  421. db.members.replace(a,memberid)
  422. create updated.make_with_text ("Member Details Updated")
  423. updated.set_title("Saved")
  424. updated.show_modal_to_window (Current)
  425. elseif type.is_equal("Staff") then
  426. if not(validate("^[A-Za-z-' ]{5,30}$",department_field.text,false)) then
  427. message_dialog("Invalid Department")
  428. else
  429. create sf
  430. sf.make(memberid, password_field.text, member_type.text, status.text, name_title_field.text, initials_field.text, last_name_field.text, address1_field.text, address2_field.text,
  431. town_field.text, county_field.text, postcode_field.text, dob_field.text, department_field.text)
  432. db.members.replace(sf,memberid)
  433. create updated.make_with_text ("Member Details Updated")
  434. updated.set_title("Saved")
  435. updated.show_modal_to_window (Current)
  436. end
  437. elseif type.is_equal("Undergraduate") then
  438. if not(validate("^[A-Za-z-' ]{5,30}$",course_field.text,false)) then
  439. message_dialog("Invalid Course")
  440. else
  441. create u
  442. u.make(memberid, password_field.text, member_type.text, status.text, name_title_field.text, initials_field.text, last_name_field.text, address1_field.text, address2_field.text,
  443. town_field.text, county_field.text, postcode_field.text, dob_field.text, course_field.text, parttime_button.is_selected)
  444. db.members.replace(u,memberid)
  445. create updated.make_with_text ("Member Details Updated")
  446. updated.set_title("Saved")
  447. updated.show_modal_to_window (Current)
  448. end
  449. elseif type.is_equal("Postgraduate") then
  450. if not(validate("^[A-Za-z-' ]{5,30}$",course_field.text,false)) then
  451. message_dialog("Invalid Course")
  452. else
  453. create p
  454. p.make(memberid, password_field.text, member_type.text, status.text, name_title_field.text, initials_field.text, last_name_field.text, address1_field.text, address2_field.text,
  455. town_field.text, county_field.text, postcode_field.text, dob_field.text, course_field.text, parttime_button.is_selected)
  456. db.members.replace(p,memberid)
  457. create updated.make_with_text ("Member Details Updated")
  458. updated.set_title("Saved")
  459. updated.show_modal_to_window (Current)
  460. end
  461. elseif type.is_equal("Visitor") then
  462. create v
  463. v.make(memberid, password_field.text, member_type.text, status.text, name_title_field.text, initials_field.text, last_name_field.text, address1_field.text, address2_field.text,
  464. town_field.text, county_field.text, postcode_field.text, dob_field.text)
  465. db.members.replace(v,memberid)
  466. create updated.make_with_text ("Member Details Updated")
  467. updated.set_title("Saved")
  468. updated.show_modal_to_window (Current)
  469. end
  470.  
  471. end
  472.  
  473. end -- update_member
  474.  
  475. search_member is
  476. -- Called by `select_actions' of `search_member_button'.
  477.  
  478. local
  479. types: ARRAY [STRING]
  480. do
  481. show_member_frame.wipe_out
  482. show_member_frame.extend(search_layout)
  483. delete_member_button.disable_sensitive
  484. amend_member_button.disable_sensitive
  485. create types.make(1,3)
  486. types.put("Member ID",1)
  487. types.put("Surname",2)
  488. types.put("Date Of Birth",3)
  489. search_combo.set_strings(types)
  490. search_button.select_actions.extend (agent search_for_member)
  491. clear_button.select_actions.extend (agent search_member)
  492. end
  493.  
  494. search_for_member is
  495. local
  496. search_field,search_text:STRING
  497. regexp:RX_PCRE_REGULAR_EXPRESSION
  498. m:MEMBER
  499.  
  500. do
  501. search_text := search_info_field.text
  502. search_field := search_combo.text
  503. create regexp.make
  504. regexp.set_caseless (true)
  505. regexp.compile(search_text)
  506. check
  507. is_compiled: regexp.is_compiled
  508. end
  509.  
  510. show_member_frame.wipe_out
  511. show_member_frame.extend(list_members_layout)
  512.  
  513. if search_field.is_equal("Member ID") then
  514. from
  515. db.members.start
  516. until
  517. db.members.off
  518. loop
  519. regexp.match(db.members.item_for_iteration.memberid.out)
  520. if regexp.has_matched then
  521. members_list.extend(db.members.item_for_iteration.row_representation)
  522. end
  523. db.stock.forth
  524. end
  525.  
  526. elseif search_field.is_equal("Surname") then
  527. from
  528. db.members.start
  529. until
  530. db.members.off
  531. loop
  532. regexp.match(db.members.item_for_iteration.last_name)
  533. if regexp.has_matched then
  534. members_list.extend(db.members.item_for_iteration.row_representation)
  535. end
  536. db.members.forth
  537. end
  538.  
  539. elseif search_field.is_equal("Date Of Birth") then
  540. from
  541. db.members.start
  542. until
  543. db.members.off
  544. loop
  545. m ?= db.members.item_for_iteration
  546. if not(m = void) then
  547. regexp.match(m.date_of_birth)
  548. if regexp.has_matched then
  549. members_list.extend(db.members.item_for_iteration.row_representation)
  550. end
  551. end
  552. db.members.forth
  553. end
  554. end
  555. set_member_column_names
  556.  
  557. end -- search_members
  558.  
  559. list_member is
  560. -- Called by `select_actions' of `list_member_button'.
  561. do
  562. show_member_frame.wipe_out
  563. show_member_frame.extend(list_members_layout)
  564. delete_member_button.disable_sensitive
  565. amend_member_button.disable_sensitive
  566. from
  567. db.members.start
  568. until
  569. db.members.off
  570. loop
  571. members_list.extend(db.members.item_for_iteration.row_representation)
  572. db.members.forth
  573. end
  574.  
  575. set_member_column_names
  576. end -- list_member
  577.  
  578. member_on_list_selected(an_item: EV_MULTI_COLUMN_LIST_ROW) is
  579. --
  580. do
  581.  
  582. delete_member_button.enable_sensitive
  583. amend_member_button.enable_sensitive
  584. end
  585. member_on_list_deselected(an_item: EV_MULTI_COLUMN_LIST_ROW) is
  586. --
  587. do
  588. delete_member_button.disable_sensitive
  589. amend_member_button.disable_sensitive
  590. end
  591. exit_member is
  592. -- Called by `select_actions' of `exit_member_button'.
  593. local
  594. pixmap:EV_PIXMAP
  595. do
  596. create pixmap
  597. show_member_frame.wipe_out
  598. pixmap.set_with_named_file (".\library.png")
  599. show_member_frame.extend (pixmap)
  600. end -- exit_member
  601.  
  602.  
  603.  
  604. feature --Item Functions
  605. currently_editing:STRING
  606.  
  607. add_item is
  608. -- Called by `select_actions' of `add_item_button'.
  609. do
  610. delete_item_button.disable_sensitive
  611. amend_item_button.disable_sensitive
  612. addcopybutton.disable_sensitive
  613. view_item_copy_button.disable_sensitive
  614.  
  615. show_item_frame.wipe_out
  616. show_item_frame.extend(add_item_layout)
  617. book_layout
  618. item_type.change_actions.extend (agent change_stock_type)
  619. submit_item_button.select_actions.extend (agent add_item_to_stock)
  620. -- clear_item_button.select_actions.extend (agent clear_item_button)
  621. end
  622.  
  623. change_stock_type is
  624. --
  625. do
  626. --rather than layouts just rename the text labels.
  627. --They all use the same number of fields.
  628.  
  629. if item_type.text.is_equal("Book") then
  630. main_area.wipe_out
  631. book_layout
  632. elseif item_type.text.is_equal("CD") then
  633. main_area.wipe_out
  634. cd_layout
  635. elseif item_type.text.is_equal("Journal") then
  636. main_area.wipe_out
  637. journal_layout
  638.  
  639. elseif item_type.text.is_equal("Video/DVD") then
  640. main_area.wipe_out
  641. video_layout
  642. end
  643. end
  644.  
  645. add_item_to_stock is
  646. --
  647. local
  648. b:BOOK
  649. j:JOURNAL
  650. d:DVD
  651. cd:CD
  652. isbnstr,issnstr,gid:STRING
  653. date:DATE
  654. do
  655. create date.make_now
  656. if item_type.text.is_equal("Book") then
  657. isbnstr := isbn_field.text
  658. isbnstr := reg_replace(" |-","",isbnstr,true)--remove spaces and dashes from the isbn.
  659. isbnstr := reg_replace("x","X",isbnstr,true)--convert x's to uppercase.
  660. if not(validate_modulo_11(isbn_field.text,10)) then
  661. message_dialog("Invalid ISBN")
  662. elseif db.stock.item(isbnstr) /= void then
  663. message_dialog("This book is already in the Library. Check the ISBN?")
  664. elseif not(validate("^[A-Za-z0-9\ \-\.]{3,50}$",item_title_field.text,false)) then
  665. message_dialog("Invalid Title")
  666. elseif not(validate("^[\w \-]{5,200}$",author_field.text,false)) then
  667. message_dialog("Invalid Author(s) Name")
  668. elseif not(validate("^[\w ]{3,25}$",publisher_field.text,false)) then
  669. message_dialog("Invalid Publisher")
  670. elseif not(validate("^[0-9]{1,3}$",edition_field.text,false)) then
  671. message_dialog("Edition must be up to 3 digit number.")
  672. elseif not(validate("^[\w -]{3,24}$",genre_field.text,false)) then
  673. message_dialog("Invalid Genre")
  674. elseif not(validate("^[0-9]{4}$",year_field.text,false)) then
  675. message_dialog("Year must be in format YYYY")
  676. elseif year_field.text.to_integer > date.year then
  677. message_dialog("Invalid Year.")
  678. elseif not(validate("^[0-9]{3}[\.0-9]*$",classification_field.text,false)) then
  679. message_dialog("Invalid Classification. Classification must be in format 000[.000]")
  680. else
  681.  
  682. create b
  683. b.make(isbnstr,item_title_field.text,author_field.text,publisher_field.text,genre_field.text,year_field.text.to_integer,edition_field.text.to_integer,classification_field.text.to_real,db.next_accession_number)
  684. db.stock.put(b,isbnstr)
  685. message_dialog("Book added.")
  686. end --add book
  687.  
  688. elseif item_type.text.is_equal("CD") then
  689. if not(validate("^[A-Za-z0-9\ \-\.]{3,25}$",item_title_field.text,false)) then
  690. message_dialog("Invalid Title")
  691. elseif not(validate("^[\w \-]{5,200}$",artist_field.text,false)) then
  692. message_dialog("Invalid Artist(s) Name")
  693. elseif not(validate("^[\w ]{3,25}$",publisher_field.text,false)) then
  694. message_dialog("Invalid Publisher")
  695. elseif not(validate("^[\w -]{3,24}$",genre_field.text,false)) then
  696. message_dialog("Invalid Genre")
  697. else
  698. create cd
  699. gid := db.next_generated_id
  700. cd.make(gid, item_title_field.text,artist_field.text,publisher_field.text,genre_field.text, db.next_accession_number)
  701. db.stock.put(cd,gid)
  702. message_dialog("CD added.")
  703. end
  704.  
  705. elseif item_type.text.is_equal("Journal") then
  706.  
  707. issnstr := issn_field.text
  708. issnstr := reg_replace(" |-","",issnstr,true)--remove spaces and dashes from the isbn.
  709. issnstr := reg_replace("x","X",issnstr,true)--convert x's to uppercase.
  710. if not(validate_modulo_11(issn_field.text,8)) then
  711. message_dialog("Invalid ISSN")
  712. elseif db.stock.item(issnstr) /= void then
  713. message_dialog("This Journal is already in the Library. Check the ISSN?")
  714. elseif not(validate("^[A-Za-z0-9\ \-\.]{3,25}$",item_title_field.text,false)) then
  715. message_dialog("Invalid Title")
  716. elseif not(validate("^[\w \-]{5,200}$",author_field.text,false)) then
  717. message_dialog("Invalid Author(s) Name")
  718. elseif not(validate("^[\w ]{3,25}$",publisher_field.text,false)) then
  719. message_dialog("Invalid Publisher")
  720. elseif not(validate("^[0-9]{4}$",year_field.text,false)) then
  721. message_dialog("Year must be in format YYYY")
  722. elseif year_field.text.to_integer > date.year then
  723. message_dialog("Invalid Year.")
  724. elseif not(validate("^[\w -]{3,24}$",subject_field.text,false)) then
  725. message_dialog("Invalid Subject")
  726. else
  727. create j
  728. j.make(issnstr,item_title_field.text,author_field.text,publisher_field.text,year_field.text,subject_field.text,db.next_accession_number)
  729. db.stock.put(j,issnstr)
  730. message_dialog("Journal added.")
  731. end
  732. elseif item_type.text.is_equal("Video/DVD") then
  733. if not(validate("^[A-Za-z0-9\ \-\.]{3,25}$",item_title_field.text,false)) then
  734. message_dialog("Invalid Title")
  735. elseif not(validate("^[\w ]{3,25}$",publisher_field.text,false)) then
  736. message_dialog("Invalid Publisher")
  737. elseif not(validate("^[\w -]{3,24}$",genre_field.text,false)) then
  738. message_dialog("Invalid Genre")
  739. elseif not(validate("^[0-9]{4}$",year_field.text,false)) then
  740. message_dialog("Year must be in format YYYY")
  741. elseif year_field.text.to_integer > date.year then
  742. message_dialog("Invalid Year.")
  743. elseif not(validate("^[\w ]{3,25}$",director_field.text,false)) then
  744. message_dialog("Invalid Director Name")
  745. elseif not(validate("^[0-9]+\:[0-5][0-9]$",length_field.text,false)) then
  746. message_dialog("Invalid Length. Format: [h]h:mm")
  747. else
  748.  
  749. create d
  750. gid := db.next_generated_id
  751. d.make(gid,item_title_field.text,publisher_field.text,genre_field.text,year_field.text,director_field.text,length_field.text,db.next_accession_number)
  752. db.stock.put(d,gid)
  753. message_dialog("Video/DVD Added")
  754. end
  755. end
  756.  
  757.  
  758. end
  759.  
  760.  
  761.  
  762. delete_item is
  763. -- Called by `select_actions' of `delete_item_button'.
  764. local
  765. unable:BOOLEAN
  766. do
  767. delete_item_button.disable_sensitive
  768. amend_item_button.disable_sensitive
  769. addcopybutton.disable_sensitive
  770. view_item_copy_button.disable_sensitive
  771.  
  772. if currently_editing.is_equal("Title") then
  773. unable := false
  774. from
  775. db.stock.item(items_list.selected_item.i_th(1)).copies.start
  776. until
  777. db.stock.item(items_list.selected_item.i_th(1)).copies.off
  778. loop
  779. if db.stock.item(items_list.selected_item.i_th(1)).copies.item_for_iteration.is_on_loan then
  780. unable:= true
  781. end
  782.  
  783. db.stock.item(items_list.selected_item.i_th(1)).copies.forth
  784. end
  785.  
  786.  
  787. if items_list.selected_item /= void then
  788. if unable = true then
  789. message_dialog("You cannot remove an item with copies that are currently on loan")
  790. else
  791. db.stock.remove(items_list.selected_item.i_th(1))
  792. list_item
  793. end
  794. end
  795. elseif currently_editing.is_equal("Copy") then
  796. if copies_list.selected_item /= void then
  797. if db.stock.item(ref_no).copies.item(copies_list.selected_item.i_th(1)).is_on_loan then
  798. message_dialog("You cannot delete a copy that is currently on loan")
  799.  
  800. else
  801. db.stock.item(ref_no).copies.remove(copies_list.selected_item.i_th(1))
  802. view_copies
  803. end
  804. end
  805. end
  806. end
  807.  
  808.  
  809.  
  810. amend_item is
  811. -- Called by `select_actions' of `amend_item_button'.
  812. local
  813. b:BOOK
  814. j:JOURNAL
  815. d:DVD
  816. c:CD
  817. do
  818.  
  819.  
  820.  
  821. delete_item_button.disable_sensitive
  822. amend_item_button.disable_sensitive
  823. addcopybutton.disable_sensitive
  824. view_item_copy_button.disable_sensitive
  825. if currently_editing.is_equal("Title") then
  826.  
  827.  
  828. if items_list.selected_item /= void then
  829. create b
  830. create j
  831. create d
  832. create c
  833. b ?= db.stock.item(items_list.selected_item.i_th(1))
  834. j ?= db.stock.item(items_list.selected_item.i_th(1))
  835. d ?= db.stock.item(items_list.selected_item.i_th(1))
  836. c ?= db.stock.item(items_list.selected_item.i_th(1))
  837.  
  838. show_item_frame.wipe_out
  839. show_item_frame.extend(add_item_layout)
  840. if b /= void then
  841. book_layout
  842. isbn_field.set_text(b.reference_number)
  843. isbn_field.disable_sensitive
  844. author_field.set_text(b.author)
  845. genre_field.set_text(b.genre)
  846. item_title_field.set_text(b.title)
  847. publisher_field.set_text(b.publisher)
  848. year_field.set_text(b.year.out)
  849. item_type.set_text("Book")
  850. item_type.disable_sensitive
  851. classification_field.set_text(b.classification.out)
  852. edition_field.set_text(b.edition.out)
  853. submit_item_button.select_actions.extend (agent amend_item_in_stock(isbn_field.text))
  854.  
  855. elseif j /= void then
  856.  
  857. item_type.set_text("Journal")
  858. item_type.disable_sensitive
  859. journal_layout
  860. issn_field.set_text(j.reference_number)
  861. issn_field.disable_sensitive
  862. author_field.set_text(j.author)
  863. item_title_field.set_text(j.title)
  864. subject_field.set_text(j.subject)
  865. year_field.set_text(j.year)
  866. publisher_field.set_text(j.publisher)
  867. submit_item_button.select_actions.extend (agent amend_item_in_stock(issn_field.text))
  868.  
  869. elseif c /= void then
  870.  
  871. item_type.set_text("CD")
  872. item_type.disable_sensitive
  873. cd_layout
  874. artist_field.set_text(c.artist)
  875. genre_field.set_text(c.genre)
  876. item_title_field.set_text(c.title)
  877. publisher_field.set_text(c.publisher)
  878. end
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885. end
  886. elseif currently_editing.is_equal("Copy") then
  887. show_item_frame.wipe_out
  888. show_item_frame.extend(amend_copy_layout)
  889. accession_number_field.set_text(db.stock.item(ref_no).copies.item(copies_list.selected_item.i_th(1)).accession_number)
  890. accession_number_field.disable_sensitive
  891.  
  892. if db.stock.item(ref_no).copies.item(copies_list.selected_item.i_th(1)).is_on_loan then
  893. on_loan_button.enable_select
  894. end
  895. on_loan_button.disable_sensitive
  896.  
  897. if db.stock.item(ref_no).copies.item(copies_list.selected_item.i_th(1)).is_reference_only then
  898. reference_button.enable_select
  899. end
  900.  
  901. if db.stock.item(ref_no).copies.item(copies_list.selected_item.i_th(1)).is_for_part_time_students_only then
  902. parttime_button.enable_select
  903. end
  904.  
  905. submit_button.select_actions.extend (agent update_copy)
  906. end
  907. end
  908.  
  909.  
  910.  
  911.  
  912. update_copy is
  913. do
  914. --update copy
  915. db.stock.item(ref_no).copies.item(copies_list.selected_item.i_th(1)).set_for_part_time_students_only(parttime_button.is_selected)
  916. db.stock.item(ref_no).copies.item(copies_list.selected_item.i_th(1)).set_reference_only(reference_button.is_selected)
  917. message_dialog("Copy Updated")
  918. view_copies
  919. end
  920. amend_item_in_stock(i:STRING) is
  921. local
  922. b:BOOK
  923. j:JOURNAL
  924. c:CD
  925. d:DVD
  926. issnstr,isbnstr:STRING
  927. date:DATE
  928. do
  929. b ?= db.stock.item(i)
  930. j ?= db.stock.item(i)
  931. c ?= db.stock.item(i)
  932. d ?= db.stock.item(i)
  933. create date.make_now
  934. if b /= void then
  935.  
  936. isbnstr := isbn_field.text
  937. isbnstr := reg_replace(" |-","",isbnstr,true)--remove spaces and dashes from the isbn.
  938. isbnstr := reg_replace("x","X",isbnstr,true)--convert x's to uppercase.
  939. if not(validate_modulo_11(isbn_field.text,10)) then
  940. message_dialog("Invalid ISBN")
  941. elseif not(validate("^[A-Za-z0-9\ \-\.]{3,50}$",item_title_field.text,false)) then
  942. message_dialog("Invalid Title")
  943. elseif not(validate("^[\w \-]{5,200}$",author_field.text,false)) then
  944. message_dialog("Invalid Author(s) Name")
  945. elseif not(validate("^[\w ]{3,25}$",publisher_field.text,false)) then
  946. message_dialog("Invalid Publisher")
  947. elseif not(validate("^[0-9]{1,3}$",edition_field.text,false)) then
  948. message_dialog("Edition must be up to 3 digit number.")
  949. elseif not(validate("^[\w -]{3,24}$",genre_field.text,false)) then
  950. message_dialog("Invalid Genre")
  951. elseif not(validate("^[0-9]{4}$",year_field.text,false)) then
  952. message_dialog("Year must be in format YYYY")
  953. elseif year_field.text.to_integer > date.year then
  954. message_dialog("Invalid Year.")
  955. elseif not(validate("^[0-9]{3}[\.0-9]*$",classification_field.text,false)) then
  956. message_dialog("Invalid Classification. Classification must be in format 000[.000]")
  957. else
  958. b.amend(isbn_field.text,item_title_field.text,author_field.text,publisher_field.text,genre_field.text,year_field.text.to_integer,edition_field.text.to_integer,classification_field.text.to_real)
  959. db.stock.replace(b,isbn_field.text)
  960. message_dialog("Book Updated")
  961. end
  962. elseif j /= void then
  963.  
  964. issnstr := issn_field.text
  965. issnstr := reg_replace(" |-","",issnstr,true)--remove spaces and dashes from the isbn.
  966. issnstr := reg_replace("x","X",issnstr,true)--convert x's to uppercase.
  967. if not(validate_modulo_11(issn_field.text,8)) then
  968. message_dialog("Invalid ISSN")
  969. elseif db.stock.item(issnstr) /= void then
  970. message_dialog("This Journal is already in the Library. Check the ISSN?")
  971. elseif not(validate("^[A-Za-z0-9\ \-\.]{3,25}$",item_title_field.text,false)) then
  972. message_dialog("Invalid Title")
  973. elseif not(validate("^[\w \-]{5,200}$",author_field.text,false)) then
  974. message_dialog("Invalid Author(s) Name")
  975. elseif not(validate("^[\w ]{3,25}$",publisher_field.text,false)) then
  976. message_dialog("Invalid Publisher")
  977. elseif not(validate("^[0-9]{4}$",year_field.text,false)) then
  978. message_dialog("Year must be in format YYYY")
  979. elseif year_field.text.to_integer > date.year then
  980. message_dialog("Invalid Year.")
  981. elseif not(validate("^[\w -]{3,24}$",subject_field.text,false)) then
  982. message_dialog("Invalid Subject")
  983. else
  984. j.amend(issn_field.text,item_title_field.text,author_field.text,publisher_field.text,year_field.text,subject_field.text)
  985. db.stock.replace(b,issn_field.text)
  986. message_dialog("Journal Updated")
  987. end
  988. elseif c /= void then
  989. if not(validate("^[A-Za-z0-9\ \-\.]{3,25}$",item_title_field.text,false)) then
  990. message_dialog("Invalid Title")
  991. elseif not(validate("^[\w \-]{5,200}$",artist_field.text,false)) then
  992. message_dialog("Invalid Artist(s) Name")
  993. elseif not(validate("^[\w ]{3,25}$",publisher_field.text,false)) then
  994. message_dialog("Invalid Publisher")
  995. elseif not(validate("^[\w -]{3,24}$",genre_field.text,false)) then
  996. message_dialog("Invalid Genre")
  997. else
  998. c.amend(c.reference_number,item_title_field.text,artist_field.text,publisher_field.text,genre_field.text)
  999. db.stock.replace(c,c.reference_number)
  1000. message_dialog("CD Updated")
  1001. end
  1002. elseif d /= void then
  1003. if not(validate("^[A-Za-z0-9\ \-\.]{3,25}$",item_title_field.text,false)) then
  1004. message_dialog("Invalid Title")
  1005. elseif not(validate("^[\w ]{3,25}$",publisher_field.text,false)) then
  1006. message_dialog("Invalid Publisher")
  1007. elseif not(validate("^[\w -]{3,24}$",genre_field.text,false)) then
  1008. message_dialog("Invalid Genre")
  1009. elseif not(validate("^[0-9]{4}$",year_field.text,false)) then
  1010. message_dialog("Year must be in format YYYY")
  1011. elseif year_field.text.to_integer > date.year then
  1012. message_dialog("Invalid Year.")
  1013. elseif not(validate("^[\w ]{3,25}$",director_field.text,false)) then
  1014. message_dialog("Invalid Director Name")
  1015. elseif not(validate("^[0-9]+\:[0-5][0-9]$",length_field.text,false)) then
  1016. message_dialog("Invalid Length. Format: [h]h:mm")
  1017. else
  1018. d.amend(d.reference_number,item_title_field.text,publisher_field.text,genre_field.text,year_field.text,director_field.text,length_field.text)
  1019. db.stock.replace(d,d.reference_number)
  1020. message_dialog("DVD/Video Updated")
  1021. end
  1022. end
  1023.  
  1024. end
  1025.  
  1026.  
  1027. search_item is
  1028. -- Called by `select_actions' of `search_item_button'.
  1029. local
  1030. types: ARRAY [STRING]
  1031.  
  1032. do
  1033. delete_item_button.disable_sensitive
  1034. amend_item_button.disable_sensitive
  1035. addcopybutton.disable_sensitive
  1036. view_item_copy_button.disable_sensitive
  1037. show_item_frame.wipe_out
  1038. show_item_frame.extend(search_layout)
  1039. create types.make(1,3)
  1040. types.put("Reference Number (isbn, issn, etc)",1)
  1041. types.put("Title",2)
  1042. types.put("Author",3)
  1043. search_combo.set_strings(types)
  1044. search_button.select_actions.extend (agent search_for_item)
  1045. clear_button.select_actions.extend (agent search_item)
  1046. end
  1047.  
  1048. search_for_item is
  1049. local
  1050. search_field,search_text:STRING
  1051. regexp:RX_PCRE_REGULAR_EXPRESSION
  1052. b:BOOK
  1053. --
  1054. do
  1055. search_text := search_info_field.text
  1056. search_text := reg_replace(" |-","",search_text,true)
  1057. search_text := reg_replace("x","X",search_text,true)
  1058. search_field := search_combo.text
  1059. create regexp.make
  1060. regexp.set_caseless (true)
  1061.  
  1062. regexp.compile(search_text)
  1063.  
  1064. check
  1065. is_compiled: regexp.is_compiled
  1066. end
  1067.  
  1068. show_item_frame.wipe_out
  1069. show_item_frame.extend(list_items_layout)
  1070. if search_field.is_equal("Reference Number (isbn, issn, etc)") then
  1071. from
  1072. db.stock.start
  1073. until
  1074. db.stock.off
  1075. loop
  1076. regexp.match(db.stock.item_for_iteration.reference_number)
  1077. if regexp.has_matched then
  1078. items_list.extend(db.stock.item_for_iteration.row_representation)
  1079. end
  1080. db.stock.forth
  1081. end
  1082. elseif search_field.is_equal("Title") then
  1083. from
  1084. db.stock.start
  1085. until
  1086. db.stock.off
  1087. loop
  1088. regexp.match(db.stock.item_for_iteration.title)
  1089. if regexp.has_matched then
  1090. items_list.extend(db.stock.item_for_iteration.row_representation)
  1091. end
  1092. db.stock.forth
  1093. end
  1094.  
  1095. elseif search_field.is_equal("Author") then
  1096. from
  1097. db.stock.start
  1098. until
  1099. db.stock.off
  1100. loop
  1101. b ?= db.stock.item_for_iteration
  1102. if not(b = void) then
  1103. regexp.match(b.author)
  1104. if regexp.has_matched then
  1105. items_list.extend(db.stock.item_for_iteration.row_representation)
  1106. end
  1107. end
  1108. db.stock.forth
  1109. end
  1110. end
  1111.  
  1112.  
  1113. set_item_column_names
  1114. end
  1115.  
  1116. list_item is
  1117. -- Called by `select_actions' of `list_item_button'.
  1118.  
  1119. do
  1120. delete_item_button.disable_sensitive
  1121. amend_item_button.disable_sensitive
  1122. addcopybutton.disable_sensitive
  1123. view_item_copy_button.disable_sensitive
  1124. show_item_frame.wipe_out
  1125. show_item_frame.extend(list_items_layout)
  1126.  
  1127.  
  1128. from
  1129. db.stock.start
  1130. until
  1131. db.stock.off
  1132. loop
  1133. items_list.extend(db.stock.item_for_iteration.row_representation)
  1134. db.stock.forth
  1135. end
  1136.  
  1137. set_item_column_names
  1138. -- message_dialog(db.stock.count.out)
  1139.  
  1140.  
  1141. end
  1142.  
  1143. item_on_list_selected(an_item: EV_MULTI_COLUMN_LIST_ROW) is
  1144. --
  1145. do
  1146. currently_editing := "Title"
  1147. delete_item_button.enable_sensitive
  1148. amend_item_button.enable_sensitive
  1149. addcopybutton.enable_sensitive
  1150. view_item_copy_button.enable_sensitive
  1151. end
  1152.  
  1153. item_on_list_deselected(an_item: EV_MULTI_COLUMN_LIST_ROW) is
  1154. --
  1155. do
  1156. delete_item_button.disable_sensitive
  1157. amend_item_button.disable_sensitive
  1158. addcopybutton.disable_sensitive
  1159. view_item_copy_button.disable_sensitive
  1160. end
  1161.  
  1162.  
  1163.  
  1164. add_copy is
  1165. --
  1166. local
  1167. scopy:STOCK_COPY
  1168. an:STRING
  1169. do
  1170. delete_item_button.disable_sensitive
  1171. amend_item_button.disable_sensitive
  1172. addcopybutton.disable_sensitive
  1173. view_item_copy_button.disable_sensitive
  1174. if items_list /= void and then items_list.selected_item /= void then
  1175. an := db.next_accession_number
  1176. create scopy.make(an)
  1177. db.stock.item(items_list.selected_item.i_th(1)).copies.put(scopy,an)
  1178.  
  1179.  
  1180. list_item
  1181. end
  1182. end
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188. exit_item is
  1189. -- Called by `select_actions' of `exit_item_button'.
  1190. local
  1191. pixmap:EV_PIXMAP
  1192. do
  1193. create pixmap
  1194. show_item_frame.wipe_out
  1195. pixmap.set_with_named_file (".\library.png")
  1196. show_item_frame.extend (pixmap)
  1197.  
  1198. end
  1199.  
  1200. ref_no:STRING
  1201. view_copies is
  1202. --
  1203. do
  1204.  
  1205. delete_item_button.disable_sensitive
  1206. amend_item_button.disable_sensitive
  1207. addcopybutton.disable_sensitive
  1208. view_item_copy_button.disable_sensitive
  1209.  
  1210.  
  1211. addcopybutton.disable_sensitive
  1212. show_item_frame.wipe_out
  1213. show_item_frame.extend(list_copies_layout)
  1214. ref_no := items_list.selected_item.i_th(1)
  1215. from
  1216. db.stock.item(items_list.selected_item.i_th(1)).copies.start
  1217. until
  1218. db.stock.item(items_list.selected_item.i_th(1)).copies.off
  1219. loop
  1220. copies_list.extend(db.stock.item(items_list.selected_item.i_th(1)).copies.item_for_iteration.row_representation)
  1221. db.stock.item(items_list.selected_item.i_th(1)).copies.forth
  1222. end
  1223.  
  1224. set_copies_column_names
  1225. end
  1226.  
  1227.  
  1228. item_on_copies_list_selected(an_item: EV_MULTI_COLUMN_LIST_ROW) is
  1229. --
  1230. do
  1231. currently_editing := "Copy"
  1232. delete_item_button.enable_sensitive
  1233. amend_item_button.enable_sensitive
  1234.  
  1235.  
  1236. end
  1237. item_on_copies_list_deselected(an_item: EV_MULTI_COLUMN_LIST_ROW) is
  1238. --
  1239. do
  1240. delete_item_button.disable_sensitive
  1241. amend_item_button.disable_sensitive
  1242.  
  1243. end
  1244. feature --Loan Functions
  1245. found:INTEGER
  1246. add_loan is
  1247. -- Called by `select_actions' of `add_loan_button'.
  1248. do
  1249. show_loan_frame.wipe_out
  1250. show_loan_frame.extend(add_loan_layout)
  1251.  
  1252. returns_loan_button.disable_sensitive
  1253. renew_loan_button.disable_sensitive
  1254.  
  1255. found := 0
  1256. submit_button.disable_sensitive
  1257.  
  1258. enter_itemid_field.enable_sensitive
  1259. find_item_button.enable_sensitive
  1260. enter_memberid_field.enable_sensitive
  1261. find_member_button.enable_sensitive
  1262.  
  1263. find_member_button.select_actions.extend (agent find_member)
  1264. find_item_button.select_actions.extend (agent find_item)
  1265.  
  1266. submit_button.select_actions.extend (agent submit_loan)
  1267. clear_loan_button.select_actions.extend (agent add_loan)
  1268. end -- add_loan
  1269.  
  1270.  
  1271. find_item is
  1272. local
  1273. itemstr,accstr:STRING
  1274. do
  1275. itemstr := enter_itemid_field.text
  1276. accstr := enter_accessionid_field.text
  1277. if itemstr.is_equal("") or accstr.is_equal("") then
  1278. message_dialog("Please enter an item ID and accession number id")
  1279. else
  1280. itemstr := reg_replace(" |-","",itemstr,true)
  1281. itemstr := reg_replace("x","X",itemstr,true)
  1282. accstr := reg_replace(" |-","",accstr,true)
  1283. accstr := reg_replace("x","X",accstr,true)
  1284.  
  1285. if not(validate_modulo_11(itemstr,itemstr.count)) then
  1286. message_dialog("Invalid Item ID")
  1287. elseif not(validate_modulo_11(accstr,10)) then
  1288. message_dialog("Invalid accession number")
  1289. else
  1290. if db.stock.item(itemstr) = void then
  1291. message_dialog("Item not found")
  1292. else
  1293. if db.stock.item(itemstr).copies.item(accstr) = void then
  1294. message_dialog("Accession number does not belong to that book.")
  1295. else
  1296. item_title_field.set_text(db.stock.item(itemstr).title)
  1297.  
  1298. if db.stock.item(itemstr).copies.item(accstr).is_on_loan = false then
  1299. available.enable_select
  1300. end
  1301. enter_itemid_field.disable_sensitive
  1302. enter_accessionid_field.disable_sensitive
  1303. find_item_button.disable_sensitive
  1304.  
  1305. found := found + 1
  1306. if found = 2 then
  1307. submit_button.enable_sensitive
  1308. end
  1309. end
  1310. end
  1311. end
  1312. end
  1313. end -- find_item
  1314.  
  1315. find_member is
  1316. local
  1317. memberstr:STRING
  1318. do
  1319. memberstr := enter_memberid_field.text
  1320. if memberstr.is_equal("") then
  1321. message_dialog("Please enter a member id")
  1322. else
  1323. memberstr := reg_replace(" |-","",memberstr,true)
  1324. memberstr := reg_replace("x","X",memberstr,true)
  1325. if not(validate_modulo_11(memberstr,8)) then
  1326. message_dialog("Invalid Member ID")
  1327. else
  1328. if db.members.item(memberstr) = void then
  1329. message_dialog("Member not found")
  1330. else
  1331. last_name_field.set_text(db.members.item(memberstr).last_name)
  1332. dob_field.set_text(db.members.item(memberstr).date_of_birth)
  1333. member_type_field.set_text(db.members.item(memberstr).member_type)
  1334. enter_memberid_field.disable_sensitive
  1335. find_member_button.disable_sensitive
  1336. found := found + 1
  1337. if found = 2 then
  1338. submit_button.enable_sensitive
  1339. end
  1340. end
  1341. end
  1342. end
  1343. end
  1344.  
  1345. submit_loan is
  1346. --
  1347. local
  1348. l:LOAN
  1349. d:DATE
  1350. lid:STRING
  1351. do
  1352. if db.stock.item(enter_itemid_field.text).copies.item(enter_accessionid_field.text).is_on_loan then
  1353. message_dialog("Sorry, that copy is already on loan")
  1354. elseif db.stock.item(enter_itemid_field.text).copies.item(enter_accessionid_field.text).is_reference_only then
  1355. message_dialog("That item is reference only and cannot be taken out of the library")
  1356. elseif not(db.members.item(enter_memberid_field.text).status.is_equal("Active")) then
  1357. message_dialog("Only active members can take out items")
  1358. elseif db.members.item(enter_memberid_field.text).num_of_items_out >= db.loan_limit.item(db.members.item(enter_memberid_field.text).member_type) then
  1359. message_dialog("Member at lending limit")
  1360. else
  1361. create d.make_now
  1362. lid := db.next_loan_id
  1363. create l.make(lid,enter_itemid_field.text,db.members.item(enter_memberid_field.text),db.stock.item(enter_itemid_field.text).copies.item(enter_accessionid_field.text),d,db)
  1364. db.loans.put(l,lid)
  1365. db.stock.item(enter_itemid_field.text).copies.item(enter_accessionid_field.text).set_on_loan(true)
  1366. db.members.item(enter_memberid_field.text).increase_num_of_items
  1367. message_dialog("Loan Created")
  1368. submit_button.disable_sensitive
  1369. enter_itemid_field.set_text("")
  1370. enter_itemid_field.enable_sensitive
  1371. enter_accessionid_field.set_text("")
  1372. enter_accessionid_field.enable_sensitive
  1373. find_member_button.enable_sensitive
  1374. find_item_button.enable_sensitive
  1375. enter_memberid_field.enable_sensitive
  1376. last_name_field.set_text("")
  1377. dob_field.set_text("")
  1378. member_type_field.set_text("")
  1379. available.disable_select
  1380. found := 0
  1381. end
  1382. end
  1383.  
  1384.  
  1385. search_loan is
  1386. -- Called by `select_actions' of `search_loan_button'.
  1387. local
  1388. types: ARRAY [STRING]
  1389. do
  1390. show_loan_frame.wipe_out
  1391. show_loan_frame.extend(search_layout)
  1392.  
  1393. renew_loan_button.disable_sensitive
  1394. returns_loan_button.disable_sensitive
  1395.  
  1396. create types.make(1,3)
  1397. types.put("Member ID",1)
  1398. types.put("Reference No. (ISBN, ISSN,ect)",2)
  1399. types.put("Accession no.",3)
  1400. search_combo.set_strings(types)
  1401.  
  1402. search_button.select_actions.extend (agent search_for_loan)
  1403. clear_button.select_actions.extend (agent search_loan)
  1404. end
  1405.  
  1406.  
  1407. search_for_loan is
  1408. local
  1409. search_field,search_text:STRING
  1410. regexp:RX_PCRE_REGULAR_EXPRESSION
  1411. -- b:BOOK
  1412. --
  1413. do
  1414. search_text := search_info_field.text
  1415. search_field := search_combo.text
  1416. create regexp.make
  1417. regexp.set_caseless (true)
  1418.  
  1419. regexp.compile(search_text)
  1420.  
  1421. check
  1422. is_compiled: regexp.is_compiled
  1423. end
  1424.  
  1425. show_loan_frame.wipe_out
  1426. show_loan_frame.extend(list_loan_layout)
  1427. if search_field.is_equal("Member ID") then
  1428. from
  1429. db.loans.start
  1430. until
  1431. db.loans.off
  1432. loop
  1433. regexp.match(db.loans.item_for_iteration.member.memberid)
  1434. if regexp.has_matched then
  1435. loan_list.extend(db.loans.item_for_iteration.row_representation)
  1436. end
  1437. db.loans.forth
  1438. end
  1439. elseif search_field.is_equal("Reference No. (ISBN, ISSN,ect)") then
  1440. from
  1441. db.loans.start
  1442. until
  1443. db.loans.off
  1444. loop
  1445. regexp.match(db.stock.item(db.loans.item_for_iteration.itemid).reference_number)
  1446. if regexp.has_matched then
  1447. loan_list.extend(db.loans.item_for_iteration.row_representation)
  1448. end
  1449. db.loans.forth
  1450. end
  1451.  
  1452. elseif search_field.is_equal("Accession no.") then
  1453. from
  1454. db.loans.start
  1455. until
  1456. db.loans.off
  1457. loop
  1458. regexp.match(db.loans.item_for_iteration.item.accession_number)
  1459. if regexp.has_matched then
  1460. loan_list.extend(db.loans.item_for_iteration.row_representation)
  1461. end
  1462. db.loans.forth
  1463. end
  1464. end
  1465.  
  1466.  
  1467. set_loan_column_names
  1468. end
  1469.  
  1470.  
  1471. list_loan is
  1472. -- Called by `select_actions' of `list_loans_button'.
  1473. do
  1474. show_loan_frame.wipe_out
  1475. show_loan_frame.extend(list_loan_layout)
  1476.  
  1477. renew_loan_button.disable_sensitive
  1478. returns_loan_button.disable_sensitive
  1479.  
  1480. from
  1481. db.loans.start
  1482. until
  1483. db.loans.off
  1484. loop
  1485. loan_list.extend(db.loans.item_for_iteration.row_representation)
  1486. db.loans.forth
  1487. end
  1488.  
  1489. set_loan_column_names
  1490.  
  1491. end -- list_loan
  1492.  
  1493. item_on_loan_list_selected(an_item: EV_MULTI_COLUMN_LIST_ROW) is
  1494. --
  1495. do
  1496. renew_loan_button.enable_sensitive
  1497. returns_loan_button.enable_sensitive
  1498. end
  1499. item_on_loan_list_deselected(an_item: EV_MULTI_COLUMN_LIST_ROW) is
  1500. --
  1501. do
  1502. renew_loan_button.disable_sensitive
  1503. returns_loan_button.disable_sensitive
  1504.  
  1505. end
  1506.  
  1507.  
  1508. list_finished_loan is
  1509. do
  1510. show_loan_frame.wipe_out
  1511. show_loan_frame.extend(list_finished_loan_layout)
  1512.  
  1513. renew_loan_button.disable_sensitive
  1514. returns_loan_button.disable_sensitive
  1515.  
  1516. from
  1517. db.finished_loans.start
  1518. until
  1519. db.finished_loans.off
  1520. loop
  1521.  
  1522.  
  1523.  
  1524. finished_loan_list.extend(db.finished_loans.item_for_iteration.row_representation)
  1525.  
  1526. db.finished_loans.forth
  1527. end
  1528.  
  1529. set_finished_loan_column_names
  1530.  
  1531. end
  1532. renew_loan is
  1533. -- Called by `select_actions' of `returns_loan_button'.
  1534. do
  1535. -- renew loan
  1536. if loan_list.selected_item /= void then
  1537.  
  1538.  
  1539. if db.loans.item(loan_list.selected_item.i_th(1)).renew_count /= 3 then
  1540. db.loans.item(loan_list.selected_item.i_th(1)).increase_renew_count
  1541. db.loans.item(loan_list.selected_item.i_th(1)).return_date.day_add((db.loan_duration.item(db.loans.item(loan_list.selected_item.i_th(1)).member.member_type) / 4).truncated_to_integer)
  1542. list_loan
  1543. else
  1544. message_dialog("The maximum loan duration for this member type has been met. You canoot renew this item any more.")
  1545. end
  1546. end
  1547. end
  1548.  
  1549. returns_loan is
  1550. -- Called by `select_actions' of `returns_loan_button'.
  1551. local
  1552. f:FINISHED_LOAN
  1553. d:DATE
  1554. do
  1555. -- returns loan
  1556.  
  1557. if loan_list.selected_item /= void then
  1558. create d.make_now
  1559. -- create f.make(db.loans.item(loan_list.selected_item.i_th(1)).id,db.loans.item(loan_list.selected_item.i_th(1)).member.memberid,db.loans.item(loan_list.selected_item.i_th(1)).item_id,db.loans.item(loan_list.selected_item.i_th(1))
  1560. create f.make(db.loans.item(loan_list.selected_item.i_th(1)).id,db.loans.item(loan_list.selected_item.i_th(1)).member.memberid,db.loans.item(loan_list.selected_item.i_th(1)).itemid,db.loans.item(loan_list.selected_item.i_th(1)).item.accession_number,db.loans.item(loan_list.selected_item.i_th(1)).start_date,d,db.loans.item(loan_list.selected_item.i_th(1)).renew_count,db)
  1561. --create f.make()
  1562. db.finished_loans.put(f,db.loans.item(loan_list.selected_item.i_th(1)).id)
  1563. db.loans.item(loan_list.selected_item.i_th(1)).item.set_on_loan(false)
  1564. db.loans.remove(db.loans.item(loan_list.selected_item.i_th(1)).id)
  1565. db.members.item(loan_list.selected_item.i_th(7)).decrease_num_of_items
  1566. list_loan
  1567. end
  1568.  
  1569. end
  1570.  
  1571. lending_rights is
  1572. -- Called by `select_actions' of `lending_rights_button'
  1573. do
  1574. show_loan_frame.wipe_out
  1575. show_loan_frame.extend(lending_rights_layout)
  1576.  
  1577.  
  1578. a_loan_limit.set_text(db.loan_limit.item("Administrator").out)
  1579. s_loan_limit.set_text(db.loan_limit.item("Staff").out)
  1580. u_loan_limit.set_text(db.loan_limit.item("Undergraduate").out)
  1581. p_loan_limit.set_text(db.loan_limit.item("Postgraduate").out)
  1582. v_loan_limit.set_text(db.loan_limit.item("Visitor").out)
  1583. a_duration.set_text(db.loan_duration.item("Administrator").out)
  1584. s_duration.set_text(db.loan_duration.item("Staff").out)
  1585. u_duration.set_text(db.loan_duration.item("Undergraduate").out)
  1586. p_duration.set_text(db.loan_duration.item("Postgraduate").out)
  1587. v_duration.set_text(db.loan_duration.item("Visitor").out)
  1588. submit_button.select_actions.extend (agent amend_lending_rights)
  1589. end
  1590.  
  1591. amend_lending_rights is
  1592. --
  1593. do
  1594. if not(validate("^[0-9]+$",a_loan_limit.text,false)) then
  1595. message_dialog("Invalid administrator loan limit")
  1596. elseif not(validate("^[0-9]+$",s_loan_limit.text,false)) then
  1597. message_dialog("Invalid Staff loan limit")
  1598. elseif not(validate("^[0-9]+$",u_loan_limit.text,false)) then
  1599. message_dialog("Invalid undergraduate loan limit")
  1600. elseif not(validate("^[0-9]+$",p_loan_limit.text,false)) then
  1601. message_dialog("Invalid postgraduate loan limit")
  1602. elseif not(validate("^[0-9]+$",v_loan_limit.text,false)) then
  1603. message_dialog("Invalid visitor loan limit")
  1604.  
  1605. elseif not(validate("^[0-9]+$",a_duration.text,false)) then
  1606. message_dialog("Invalid administrator loan duration")
  1607. elseif not(validate("^[0-9]+$",s_duration.text,false)) then
  1608. message_dialog("Invalid staff loan duration")
  1609. elseif not(validate("^[0-9]+$",u_duration.text,false)) then
  1610. message_dialog("Invalid undergraduate loan duration")
  1611. elseif not(validate("^[0-9]+$",p_duration.text,false)) then
  1612. message_dialog("Invalid postgraduate loan duration")
  1613. elseif not(validate("^[0-9]+$",v_duration.text,false)) then
  1614. message_dialog("Invalid visitor loan duration")
  1615.  
  1616. else
  1617. db.loan_limit.replace(a_loan_limit.text.to_integer,"Administrator")
  1618. db.loan_limit.replace(s_loan_limit.text.to_integer,"Staff")
  1619. db.loan_limit.replace(u_loan_limit.text.to_integer,"Undergraduate")
  1620. db.loan_limit.replace(p_loan_limit.text.to_integer,"Postgraduate")
  1621. db.loan_limit.replace(v_loan_limit.text.to_integer,"Visitor")
  1622.  
  1623. db.loan_duration.replace(a_duration.text.to_integer,"Administrator")
  1624. db.loan_duration.replace(s_duration.text.to_integer,"Staff")
  1625. db.loan_duration.replace(u_duration.text.to_integer,"Undergraduate")
  1626. db.loan_duration.replace(p_duration.text.to_integer,"Postgraduate")
  1627. db.loan_duration.replace(v_duration.text.to_integer,"Visitor")
  1628.  
  1629. message_dialog("Lending rights updated!")
  1630. end
  1631. -- only by an administrator
  1632. end
  1633.  
  1634. loans_overdue is
  1635. --
  1636. do
  1637. show_loan_frame.wipe_out
  1638. show_loan_frame.extend(list_loan_layout)
  1639.  
  1640. from
  1641. db.loans.start
  1642. until
  1643. db.loans.off
  1644.  
  1645.  
  1646. loop
  1647. if db.loans.item_for_iteration.is_overdue then
  1648. loan_list.extend(db.loans.item_for_iteration.row_representation)
  1649. end
  1650. db.loans.forth
  1651. end
  1652.  
  1653. set_loan_column_names
  1654. end
  1655.  
  1656.  
  1657. exit_loan is
  1658. -- Called by `select_actions' of `exit_loans_button'.
  1659. local
  1660. pixmap:EV_PIXMAP
  1661. do
  1662. create pixmap
  1663. show_loan_frame.wipe_out
  1664. pixmap.set_with_named_file (".\library.png")
  1665. show_loan_frame.extend(pixmap)
  1666.  
  1667. end
  1668.  
  1669.  
  1670.  
  1671. g_list_current_loans(s:STRING) is
  1672. --
  1673. do
  1674. show_loan_frame.wipe_out
  1675. show_loan_frame.extend(list_loan_layout)
  1676.  
  1677. renew_loan_button.disable_sensitive
  1678. returns_loan_button.disable_sensitive
  1679.  
  1680. from
  1681. db.loans.start
  1682. until
  1683. db.loans.off
  1684. loop
  1685. if db.loans.item_for_iteration.member.memberid.is_equal(s) then
  1686.  
  1687. loan_list.extend(db.loans.item_for_iteration.row_representation)
  1688. end
  1689. db.loans.forth
  1690. end
  1691.  
  1692. set_loan_column_names
  1693.  
  1694. end -- list_loan
  1695.  
  1696.  
  1697.  
  1698. g_list_finished_loans(s:STRING) is
  1699. --
  1700. do
  1701. show_loan_frame.wipe_out
  1702. show_loan_frame.extend(list_finished_loan_layout)
  1703.  
  1704. renew_loan_button.disable_sensitive
  1705. returns_loan_button.disable_sensitive
  1706.  
  1707. from
  1708. db.finished_loans.start
  1709. until
  1710. db.finished_loans.off
  1711. loop
  1712. if db.finished_loans.item_for_iteration.member_id.is_equal(s) then
  1713. finished_loan_list.extend(db.finished_loans.item_for_iteration.row_representation)
  1714. end
  1715. db.finished_loans.forth
  1716. end
  1717.  
  1718. set_finished_loan_column_names
  1719.  
  1720. end
  1721.  
  1722.  
  1723. feature --Reservation Functions
  1724.  
  1725. create_reservation is
  1726. -- Called by `select_actions' of `create_reservation_button'.
  1727. do
  1728. show_reservation_frame.wipe_out
  1729. show_reservation_frame.extend(create_reservation_layout)
  1730.  
  1731. find_member_button.select_actions.extend (agent find_member)
  1732. find_item_button.select_actions.extend (agent find_item)
  1733.  
  1734. reserve_button.select_actions.extend (agent reserve)
  1735. clear_button.select_actions.extend (agent create_reservation)
  1736. end
  1737.  
  1738. reserve is
  1739.  
  1740. -- local
  1741. -- l:LOAN
  1742. -- d:DATE
  1743. -- rid:STRING
  1744. do
  1745. -- if db.stock.item(enter_itemid_field.text).copies.item(enter_accessionid_field.text).is_available then
  1746. -- message_dialog("There is an available copy in the library")
  1747. -- else
  1748. -- create d.make_now
  1749. -- rid := db.next_reservations_id
  1750. -- create l.make(rid,enter_itemid_field.text,db.members.item(enter_memberid_field.text),db.stock.item(enter_itemid_field.text).copies.item(enter_accessionid_field.text),d,db)
  1751. -- db.reservations.put(l,rid)
  1752. -- db.reservations.item(enter_itemid_field.text).copies.item(enter_accessionid_field.text).set_on_reservations(true)
  1753. -- end
  1754. end -- reserve
  1755.  
  1756.  
  1757.  
  1758. cancel_reservation is
  1759. -- Called by `select_actions' of `cancel_reservation_button'.
  1760. do
  1761. end
  1762.  
  1763.  
  1764. search_reservation is
  1765. -- Called by `select_actions' of `search_reservation_button'.
  1766. do
  1767. end
  1768.  
  1769.  
  1770. list_reservation is
  1771. -- Called by `select_actions' of `list_reservation_button'.
  1772. do
  1773. end
  1774.  
  1775. exit_reservation is
  1776. -- Called by `select_actions' of `exit_reservation_button'.
  1777. local
  1778. pixmap:EV_PIXMAP
  1779. do
  1780. create pixmap
  1781. show_reservation_frame.wipe_out
  1782. pixmap.set_with_named_file (".\library.png")
  1783. show_reservation_frame.extend (pixmap)
  1784. end -- exit_reservation
  1785.  
  1786. feature --Loan Functions
  1787.  
  1788. add_fine is
  1789. -- Called by `select_actions' of `add_fine_button'.
  1790. do
  1791. end
  1792.  
  1793.  
  1794. pay_fine is
  1795. -- Called by `select_actions' of `pay_fine_button'.
  1796. do
  1797. end
  1798.  
  1799.  
  1800. amend_fine is
  1801. -- Called by `select_actions' of `amend_fines_button'.
  1802. do
  1803. end
  1804.  
  1805.  
  1806. list_fine is
  1807. -- Called by `select_actions' of `list_fines_button'.
  1808. do
  1809. end
  1810.  
  1811.  
  1812. feature --Other Functions
  1813.  
  1814. load_system is
  1815.  
  1816. do
  1817. db.load
  1818.  
  1819. end
  1820.  
  1821. save_system is
  1822.  
  1823. do
  1824. db.save
  1825.  
  1826. end
  1827.  
  1828. exit_system is
  1829. --
  1830. do
  1831. hide
  1832. create login
  1833. login.show
  1834.  
  1835. end
  1836.  
  1837. show_about_box is
  1838. --
  1839. local
  1840. about_dialog: EV_INFORMATION_DIALOG
  1841. do
  1842. create about_dialog.make_with_text (" Library System%N by: %N Eif' had a Vision2")
  1843. about_dialog.set_title("About Library")
  1844. about_dialog.show_modal_to_window (Current)
  1845. end
  1846.  
  1847. reports is
  1848. --
  1849. local
  1850. reports_dialog: EV_INFORMATION_DIALOG
  1851. do
  1852. create reports_dialog.make_with_text ("Not yet functional")
  1853. reports_dialog.set_title("Reports")
  1854. reports_dialog.show_modal_to_window (Current)
  1855. end
  1856.  
  1857. letters is
  1858. --
  1859. local
  1860. letters_dialog: EV_INFORMATION_DIALOG
  1861. do
  1862. create letters_dialog.make_with_text ("Not yet functional")
  1863. letters_dialog.set_title("Letters")
  1864. letters_dialog.show_modal_to_window (Current)
  1865. end
  1866.  
  1867.  
  1868. login:LOGIN_BOX
  1869. end -- class MAIN_WINDOW
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement