Re: Help with Progressive Find dialog
After some more studying - PTL I figured it out. The Search_name (Progressive Find) now will populate the search variable with the information in the first row.
User can type in search criteria and when the first row satisfies the criteria, user can hit the enter button and the correct record is displayed.
User can switch on the fly if they want to change search criteria.
After some more studying - PTL I figured it out. The Search_name (Progressive Find) now will populate the search variable with the information in the first row.
User can type in search criteria and when the first row satisfies the criteria, user can hit the enter button and the correct record is displayed.
User can switch on the fly if they want to change search criteria.
Code:
'Date Created: 04-Dec-2007 12:28:46 AM 'Last Updated: 14-May-2009 01:55:12 PM 'Created By : David 'Updated By : David 'Inline-Xbasic. Converted from: Create an XDialog dialog box to prompt for parameters. 'Create an XDialog dialog box to prompt for parameters. OPTION break DIM SHARED vLastname as C DIM SHARED vName as C DIM SHARED vFirstname as C DIM SHARED vSpouse as C DIM SHARED vSSN as C DIM SHARED vClientid as C DIM SHARED vAddress as C DIM SHARED vCity as C DIM SHARED vState as C DIM SHARED vZipCode as C DIM SHARED vHomephone as C DIM SHARED vWorkphone as C DIM SHARED vCellphone as C DIM SHARED vFaxphone as C DIM SHARED vE_Mail as C DIM SHARED vE_Mail1 as C DIM SHARED vEmployer as C DIM SHARED vProspects as L DIM SHARED vReferrals as L DIM SHARED varC_result as C vProspects = .f. vReferrals = .f. vName = "" DIM vName_FuncCode as C = <<%CodeFunctions% FUNCTION DoSort AS V (byref CurrentSortField AS C , byref CurrentSortDirection AS C, NewSortField AS C, Filter AS C, pLV AS P, rs AS P ) DIM cResult AS C DIM SortDirection AS C DIM SortField AS C IF NewSortField = CurrentSortField ' clicked on same field, reverse sort IF CurrentSortDirection = "D" CurrentSortDirection = "A" ELSE CurrentSortDirection = "D" END IF ELSE CurrentSortField = NewSortField CurrentSortDirection = "A" END IF SortDirection = CurrentSortDirection SortField = CurrentSortField IF SortDirection = "D" SortField = "invert(" + SortField + ")" END IF ' actual sorting code goes here pLV.RowView.Close() pLV.RowView = rs.OpenView(1, SortField, Filter) DoSort = cResult END FUNCTION FUNCTION GetArguments AS C ( pTableDef AS P, lv AS P ) DIM cResult AS C DIM pv AS P FOR EACH x IN pTableDef.pArgs.arrArgs IF (":"+x.Name) $ pTableDef.Filter pv = A5_ArgGetValue(x, lv) x.value = pv.value END IF NEXT cResult = a5_ArgumentsReplace(pTableDef.filter, pTableDef.pArgs.arrArgs) GetArguments = cResult END FUNCTION %CodeFunctions% DIM vName_Funcs as P = compile_template(vName_FuncCode) DIM SHARED vName as C DIM vName_CurrentSortField as C = "lastname" DIM vName_CurrentSortDirection as C = "A" DIM vName_Filter as C DIM vName_pTableDef as P DIM vName_pTableDef.ReturnValueExpression as C = "Client_id" DIM vName_pTableDef.FieldList as C = <<%txt% Client_id Lastname Firstname Suffix Soc_sec_no Spouse Sp_ss_no trim(Address1) + " " + trim(Address2) City State Zip_code %txt% DIM vName_pTableDef.TitleRow as C = "{WIDTH=0.5}Id|{WIDTH=1.5}Lastname|{WIDTH=1.2}Firstname|{WIDTH=.3}S|{WIDTH=1}Soc_sec_no|{WIDTH=1.2}Spouse|{WIDTH=1}Sp_ss_no|{WIDTH=1.5}Address|{WIDTH=1.2}City|{WIDTH=0.4}St|{WIDTH=.7}Zip_code" DIM vName_pTableDef.Arguments as C = <<%txt% <lastbutton="ok"> <arrArgs<[1]<Name="argLastname"> <DataType="Character"> <Source="Variable"> <SourceType="Local Variable"> <DefaultValue=""> <Prompt=.F.> <PromptText=""> <PromptControlType="Text Box"> <PromptChoices=""> <PromptDlgTitle="Missing Argument"> <PromptTextAbove=""> <SourceDisplay="Get value from variable"> <VariableScope="Session Variable"> <VariableName="vLastname"> <VariableWithScope="vLastname (Session Variable)"> <PreviewValue=""> %txt% DIM vName_pTableDef.pArgs as P property_from_string(vName_pTableDef.pArgs, vName_pTableDef.Arguments) DIM vName_pTableDef.TableName as C = "all_clients" DIM vName_pTableDef.Filter as C = "left(trim(lastname) + \" \" + trim(Firstname) + \" \" + trim(Suffix), len(:argLastname)) = :argLastname .AND. (recno() > 0)" ' recno() > 0 is required in order to avoid showing deleted variables DIM vName_pTableDef.Order as C = "Lastname+Firstname+Suffix" DIM vName_pTableDef.pAdvFormatting as P DIM vName_pTableDef.pAdvFormatting.alternating_bands as L = .t. DIM vName_pTableDef.pAdvFormatting.group_size as N = 2 DIM vName_pTableDef.pAdvFormatting.odd_row_color as C = "White" DIM vName_pTableDef.pAdvFormatting.even_row_color as C = "#214+214+255" DIM vName_pTableDef.pAdvFormatting.odd_selected_color as C = "Dark Blue" DIM vName_pTableDef.pAdvFormatting.even_selected_color as C = "Dark Blue" DIM vName_pTableDef.pAdvFormatting.font as C = "Arial,8" DIM vName_pTableDef.pAdvFormatting.font_color_unselected as C = "Dark Blue" DIM vName_pTableDef.pAdvFormatting.font_color_selected as C = "White" DIM vName_pTableDef.pAdvFormatting.number_rows as L = .f. DIM vName_pTableDef.pAdvFormatting.tab_stops as C = "" vName_pLV.titlerow = vName_pTableDef.titlerow vName_pLV.titleevents = "vName_Sort_Client_id|vName_Sort_Lastname|vName_Sort_Suffix|vName_Sort_Firstname|vName_Sort_Soc_sec_no|vName_Sort_Spouse|vName_Sort_Sp_ss_no|vName_Sort_Address1|vName_Sort_City|vName_Sort_State|vName_Sort_Zip_code" vName_pLV.style = "report,singlesel,gridlines,fullrowselect" vName_pLV.dragbehaviour = "" vName_pLV.dropbehaviour = "" DIM vName_t as P DIM vName_rr as Alpha5::RowRelation DIM vName_rs as P IF .NOT. file.exists(table.filename_get(vName_pTableDef.TableName)) END' END IF vName_t = table.open(vName_pTableDef.TableName, FILE_RO_SHARED) vName_t.persist() vName_rs = vName_rr.TableToRowSource(vName_t) vName_Filter = vName_Funcs.GetArguments(vName_pTableDef, local_variables()) vName_pLV.rowview = vName_rs.OpenView(1, vName_pTableDef.Order, vName_Filter) vName_pLV.RowSeparator = crlf() vName_pLV.ColumnSeparator = "|" vName_pLV.Key = vName_pTableDef.ReturnValueExpression vName_pLV.Columns = a5_owner_draw_list_fmt(vName_pTableDef.FieldList, vName_pTableDef.pAdvFormatting, "listviewvirtual") vName_pLV.events = <<%code% FUNCTION OnRightClick as C(lv as P, listView as P, args as P) WITH lv listView.Selection = listView.GetRowValue(args.GetClickRow()) OnSelectionChanged(lv, listView) END WITH END FUNCTION FUNCTION OnDoubleClick as C(lv as P, listView as P, args as P) WITH lv vName = listView.GetRowValue(args.GetClickRow()) END WITH END FUNCTION FUNCTION OnSelectionChanged AS V (lv as P, listView as P) WITH lv vName = listView.Selection END WITH END FUNCTION FUNCTION OnKeyDown as v(vars as P, listView as P, args as P) DIM key as C DIM KeyName as C key = args.GetKeyName() KeyName = key IF key = "{Delete}" .OR. key = "{Num Del}" KeyName = "{Delete}" ELSE IF args.keycode = 13 ' enter KeyName = "{Enter}" ELSE IF args.keycode = 8 ' backspace KeyName = "{Backspace}" END IF END FUNCTION %code% ok_button_label = "&OK" cancel_button_label = "&Cancel" varC_result = ui_dlg_box("Search by Last Name", <<%dlg% {background=Blue White}{font= tahoma, 10} {region} | [.40vLastname]; | {listviewvirtual=205,25vName^=vName_pLV}; {watch=vLastname!vName_refresh} {watch=vName!foo}; {endregion}; {line=1,0}; {region} <%B=M%15Last Name!last> |<%B=M%15First Name!first> |<%B=M%15Client SSN!c_ssn> | <%B=M%15Address!address> |<%B=M%15State!state> |<%B=M%15Home Phone!hphone> | <%B=M%15Cell Phone!cphone> | <%B=M%15EMail!email> |<%B=M%15Employer!employer>; <%B=M%15Client Id!c_id> |<%B=M%15Spouse!spouse> |<%B=M%15Spouse SSN!s_ssn> | <%B=M%15City!city> |<%B=M%15Zip Code!zip> |<%B=M%15Work Phone!wphone> | <%B=M%15Fax Phone!fphone> | <%B=M%15EMail_1!email1>; {endregion}; {line=1,0}; {region} <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL> {endregion}; %dlg%,<<%code% '<*15=ok_button_label!OK?vName<\>""> <15=cancel_button_label!CANCEL> IF left(a_dlg_button, len("vName_Sort_")) = "vName_Sort_" DIM NewSortField as C NewSortField = substr(a_dlg_button, len("vName_Sort_") + 1) vName_Funcs.DoSort(vName_CurrentSortField, vName_CurrentSortDirection, NewSortField, vName_Filter, vName_pLV, vName_rs) a_dlg_button = "" END IF IF a_Dlg_button = "vName_refresh" a_dlg_button = "" vName_Filter = vName_Funcs.GetArguments(vName_pTableDef, local_variables()) vName_pLV.RowView.Close() vName_pLV.RowView = vName_rs.OpenView(1, vName_CurrentSortField, vName_Filter) END IF IF a_dlg_button = "foo" debug(1) a_dlg_button = "" ' do nothing END IF 'This populates search variable vName with search criteria found in first row '=================== vname_t.index_primary_put("name") vName_t.fetch_find(vLastname) dim vName_ck as c vName_ck = vname_t.client_id vName_t.index_primary_put("client_id") '=================== %code%) vName_t.close() IF vname = "" .and. varC_result = "OK" vName = vName_ck END IF IF varC_result = "Cancel" END' END IF script_play("Search_Finish") END'
Code:
'Date Created: 04-Dec-2007 12:28:46 AM 'Last Updated: 13-May-2009 10:44:07 AM 'Created By : David 'Updated By : David DIM SHARED vLastname as C DIM SHARED vFirstname as C DIM SHARED vSpouse as C DIM SHARED vSSN as C DIM SHARED vClientid as C DIM SHARED vAddress as C DIM SHARED vCity as C DIM SHARED vState as C DIM SHARED vZipCode as C DIM SHARED vHomephone as C DIM SHARED vWorkphone as C DIM SHARED vCellphone as C DIM SHARED vFaxphone as C DIM SHARED vE_Mail as C DIM SHARED vE_Mail1 as C DIM SHARED vProspects as L DIM SHARED vReferrals as L DIM SHARED varC_result as C DIM SHARED vName as C vProspects = .f. vReferrals = .f. SELECT CASE varC_result = "cancel" END' CASE varC_result = "last" vLastname = vFirstname IF vFirstname > "" vLastname = vFirstname ELSE vLastname = vSpouse END IF script_play("Search_Name") CASE varC_result = "first" IF vLastname > "" vFirstname = vLastname ELSE vFirstname = vSpouse END IF vFirstname = vLastname script_play("Search_FirstName") CASE varC_result = "spouse" IF vLastname > "" vSpouse = vLastname ELSE vSpouse = vFirstname END IF script_play("Search_Spouse") CASE varC_result = "c_ssn" script_play("Search_SSN") CASE varC_result = "s_ssn" script_play("Search_SpouseSSN") CASE varC_result = "c_id" script_play("Search_ClientId") CASE varC_result = "address" script_play("Search_Address") CASE varC_result = "city" script_play("Search_City") CASE varC_result = "state" script_play("Search_State") CASE varC_result = "zip" script_play("Search_ZipCode") CASE varC_result = "hphone" vWorkphone = vHomephone vCellphone = vHomephone vFaxphone = vHomephone script_play("Search_HomePhone") CASE varC_result = "wphone" vHomephone = vWorkphone vCellphone = vWorkphone vFaxphone = vWorkphone script_play("Search_WorkPhone") CASE varC_result = "cphone" vHomephone = vCellphone vWorkphone = vCellphone vFaxphone = vCellphone script_play("Search_CellPhone") CASE varC_result = "fphone" vHomephone = vFaxphone vWorkphone = vFaxphone vCellphone = vFaxphone script_play("Search_FaxPhone") CASE varC_result = "email" vE_Mail = vE_Mail1 script_play("Search_EMail") CASE varC_result = "email1" vE_Mail1 = vE_Mail script_play("Search_EMail1") CASE varC_result = "employer" script_play("Search_Employer") END SELECT ON ERROR goto restart IF left(vName, 2) = "CL" IF is_object(":MDC Prospect System") .and. is_object(":MDC Credit System") MDC_Prospect_System.close() MDC_Credit_System.Index_Set("client_id") MDC_Credit_System.find(vName) topparent.resynch() MDC_Credit_System.Query_Clear() MDC_Credit_System.Index_Set("name") ELSE IF is_object(":MDC Referral System") .and. is_object(":MDC Credit System") MDC_Referral_System.close() MDC_Credit_System.Index_Set("client_id") MDC_Credit_System.find(vName) topparent.resynch() MDC_Credit_System.Query_Clear() MDC_Credit_System.Index_Set("name") ELSE DIM f as P f = obj(":MDC Credit System") IF .not. is_object(f) THEN filter = "client_id= '" + vName + "'" f = :form.ViewQueried("MDC Credit System", filter) f.show() f.activate() IF is_object(":MDC Referral System") MDC_Referral_System.close() END IF IF is_object(":MDC Prospect System") MDC_Prospect_System.close() END IF ELSE DIM t as P t = table.get("client") t.index_primary_put("client_id") t.fetch_find(vName) t.index_primary_put("name") topparent.resynch() END IF END IF ELSE IF left(vName, 2) = "VN" vReferrals = .t. IF is_object(":MDC Prospect System") MDC_Prospect_System.close() END IF IF Systemname <> "MDC Referral System" DIM f as P filter = "vendor_id= '" + vName + "'" f = :form.ViewQueried("MDC Referral System", filter) f.show() f.activate() ELSE MDC_Referral_System.Index_Set("vendor_id") MDC_Referral_System.find(vName) xbasic_wait_for_idle() topparent.resynch() END IF ELSE vProspects = .t. IF is_object(":MDC Referral System") MDC_Referral_System.close() END IF IF Systemname <> "MDC Prospect System" DIM f as P filter = "client_id= '" + vName + "'" f = :form.ViewQueried("MDC Prospect System", filter) f.show() f.activate() ELSE DIM t as P MDC_Prospect_System.Index_Set("client_id") MDC_Prospect_System.find(vName) topparent.resynch() END IF END IF '--------------- restart: '--------------- END'
Comment