Although you won't be able to actually run this program since you don't have the Access Database, you can see how to use the file open dialog and other features of Win32:GUI Regards, Eric Hansen # Eric Hansen, ITSi Dallas, TX # [EMAIL PROTECTED] use Win32::GUI; use Win32::ODBC; use Win32::Sound; use IO::Handle; # Hide the Dos Window since it does not look professional being visible ($DOShwnd, $DOShinstance) = GUI::GetPerlWindow(); GUI::Hide($DOShwnd); $B = new GUI::Bitmap('MCLogo.bmp'); #------------------------------------# # Window OBJECTS #------------------------------------# # must define as DialogBox not Window or else tabs won't work $W = new GUI::DialogBox ( -title => "Create CRM File - Batch Select", -left => 100, -top => 20, -width => 550, -height => 550, -style => ws_sysmenu, -name => "Window", ); $BITMAP = $W->AddLabel( -left => 0, -top => 0, -style => 14 | WS_VISIBLE, -name => "Bitmap", ); $BITMAP->SetImage($B); $SFont = new Win32::GUI::Font( -name => "Tahoma", -size => 8, -weight => 700, -height => -11, ); $Font = new Win32::GUI::Font( -name => "Courier New", -size => 12, -weight => 700, -height => -14, ); $Status = $W->AddStatusBar( -text => " ", -font => $SFont, ); $List1_l = $W->AddLabel(-name => "List1_l", -text => "Available", -left => 40, -top => 265, -width => 50, -height => 18 ); $List1 = $W->AddListbox(-name => "List1", -font => $SFont, -foreground => 0xC08080, -style => WS_CHILD | WS_VISIBLE | WS_VSCROLL | 1 | WS_TABSTOP, -left => 40, -top => 48, -height => 217, -width => 185); $List2_l = $W->AddLabel(-name => "List2_l", -text => "Selected", -left => 320, -top => 30, -width => 50, -height => 18 ); $List2 = $W->AddListbox(-name => "List2", -font => $SFont, -foreground => 0xC08080, -style => WS_CHILD | WS_VISIBLE | WS_VSCROLL | 1 | WS_TABSTOP, -left => 320, -top => 48, -height => 217, -width => 185); $Add = $W->AddButton(-name => "Add", -text => "&Add >", -left => 237, -top => 120, -group => 1, -tabstop => 1, -height => 25, -width => 73 ); $Remove = $W->AddButton(-name => "Remove", -text => "< &Remove", -left => 237, -top => 168, -group => 1, -tabstop => 1, -height => 25, -width => 73 ); $Ponumber_l = $W->AddLabel(-name => "Ponumber_l", -text => "Po_Number - Ship_Date - Count:", -left => 135, -top => 288, -height => 18, -align => right, -width => 185 ); $Ponumber = $W->AddTextfield(-name => "Ponumber", -font => $SFont, -text => "", -left => 320, -top => 288, -readonly => 1, -height => 19, -width => 185 ); $Company_l = $W->AddLabel(-name => "Company_l", -text => " Company:", -left => 135, -top => 312, -align => right, -height => 18, -width => 185 ); $Company = $W->AddTextfield(-name => "Company", -font => $Font, -foreground => 0x8080FF, -text => "", -left => 320, -top => 312, -group => 1, -tabstop => 1, -height => 20, -width => 40 ); $Company->SendMessage(197, 3, 0); # limit to 3 characters input $Customer_l = $W->AddLabel(-name => "Customer_l", -text => " Customer Number:", -left => 135, -top => 336, -align => right, -height => 18, -width => 185 ); $Customer = $W->AddTextfield(-name => "Customer", -font => $Font, -foreground => 0x8080FF, -text => "", -left => 320, -top => 336, -group => 1, -tabstop => 1, -height => 20, -width => 60 ); $Customer->SendMessage(197, 6, 0); # limit to 6 characters input $Order_l = $W->AddLabel(-name => "Order_l", -text => " Order Number:", -left => 135, -top => 360, -align => right, -height => 18, -width => 185 ); $Order = $W->AddTextfield(-name => "Order", -text => "", -font => $Font, -foreground => 0x8080FF, -left => 320, -top => 360, -group => 1, -tabstop => 1, -height => 20, -width => 60 ); $Order->SendMessage(197, 6, 0); # limit to 6 characters input $Location_l = $W->AddLabel(-name => "Location_l", -text => " Location:", -left => 135, -top => 384, -align => right, -height => 18, -width => 185 ); $Location = $W->AddTextfield(-name => "Location", -font => $Font, -foreground => 0x8080FF, -text => "", -left => 320, -top => 384, -group => 1, -tabstop => 1, -height => 20, -width => 20); $Location->SendMessage(197, 1, 0); # limit to 1 characters input $Service_l = $W->AddLabel(-name => "Service_l", -text => " Service Type:", -left => 135, -top => 408, -align => right, -height => 18, -width => 185 ); $Service = $W->AddTextfield(-name => "Service", -font => $Font, -foreground => 0x8080FF, -text => "", -left => 320, -top => 408, -group => 1, -tabstop => 1, -height => 20, -width => 30 ); $Service->SendMessage(197, 2, 0); # limit to 2 characters input $Purprice_l = $W->AddLabel(-name => "Purprice_l", -text => " Purchase Price:", -left => 135, -top => 432, -align => right, -height => 18, -width => 185 ); $Purprice_l2 = $W->AddLabel(-name => "Purprice_l2", -text => "i.e. #.##", -left => 400, -top => 432, -align => left, -height => 18, -width => 70 ); $Purprice = $W->AddTextfield(-name => "Purprice", -font => $Font, -foreground => 0x8080FF, -text => "", -left => 320, -top => 432, -group => 1, -tabstop => 1, -height => 20, -width => 75 ); $Purprice->SendMessage(197, 8, 0); # limit to 8 characters input $Purdate_l = $W->AddLabel(-name => "Purdate_l", -text => " Purchase Date:", -left => 135, -top => 456, -align => right, -height => 18, -width => 185 ); $Purdate_l2 = $W->AddLabel(-name => "Purdate_l2", -text => "i.e. yymmdd", -left => 400, -top => 456, -align => left, -height => 18, -width => 70 ); $Purdate = $W->AddTextfield(-name => "Purdate", -font => $Font, -foreground => 0x8080FF, -text => "", -left => 320, -top => 456, -group => 1, -tabstop => 1, -height => 20, -width => 60 ); $Purdate->SendMessage(197, 6, 0); # limit to 6 characters input $Okay = $W->AddButton(-name => "Okay", -text => "&OK", -left => 40, -top => 339, -group => 1, -tabstop => 1, -height => 25, -width => 73 ); $Cancel = $W->AddButton(-name => "Cancel", -text => "&Cancel", -left => 40, -top => 384, -group => 1, -tabstop => 1, -height => 25, -width => 73 ); $About = $W->AddButton(-name => "About", -text => "A&bout", -left => 40, -top => 429, -group => 1, -tabstop => 1, -height => 25, -width => 73 ); #------------------------------------# # Window Dialog #------------------------------------# $W->Show; LoadFreqArr(); LoadSchemeArr(); ConnectToDatabase(); LoadListBox(); $restart="Y"; GUI::Dialog(); #------------------------------------# # Non-Event Subroutines #------------------------------------# sub LoadFreqArr { $ret="Y"; open(FREQ,"freq.txt") || do {$ret="N";}; if ($ret eq "Y") { while($rec=<FREQ>) { chomp($rec); # remove linefeed @fields=(); @fields=split(/,/,$rec); $f_from=$fields[0]; $f_to=$fields[1]; $freq_arr{$f_from}=$f_to; } close(FREQ); if (defined($freq_arr{" "})) {;} # make sure we have a default else { Win32::GUI::MessageBox( $W, "No default frequency found in freq.txt", "Create CRM File - Error", 16, ); Win32::GUI::MessageBox( $W, "Shutting Down the Application", "Create CRM File - Status", 64, ); exit; } } else { Win32::GUI::MessageBox( $W, "Can't open freq.txt for input", "Create CRM File - Error", 16, ); Win32::GUI::MessageBox( $W, "Shutting Down the Application", "Create CRM File - Status", 64, ); exit; } } sub LoadSchemeArr { $ret="Y"; open(SCHEME,"scheme.txt") || do {$ret="N";}; if ($ret eq "Y") { while($rec=<SCHEME>) { chomp($rec); # remove linefeed @fields=(); @fields=split(/,/,$rec); $s_from=$fields[0]; $s_to=$fields[1]; $scheme_arr{$s_from}=$s_to; } close(SCHEME); if (defined($scheme_arr{" "})) {;} # make sure we have a default else { Win32::GUI::MessageBox( $W, "No default scheme found in scheme.txt", "Create CRM File - Error", 16, ); Win32::GUI::MessageBox( $W, "Shutting Down the Application", "Create CRM File - Status", 64, ); exit; } } else { Win32::GUI::MessageBox( $W, "Can't open scheme.txt for input", "Create CRM File - Error", 16, ); Win32::GUI::MessageBox( $W, "Shutting Down the Application", "Create CRM File - Status", 64, ); exit; } } sub LoadListBox { $Status->Text("Searching for active PO#s. Please Wait..."); $Status->Update(); sleep 2; $sqltxt = "SELECT deleted_flag,po_number,ship_date,count(*)"; $sqltxt = $sqltxt . " AS cnt_of_rows FROM EDItbl"; $sqltxt = $sqltxt . " WHERE deleted_flag = 'N'"; $sqltxt = $sqltxt . " GROUP BY deleted_flag,po_number,ship_date"; $sqltxt = $sqltxt . " ORDER BY deleted_flag,po_number,ship_date"; $ret = $db->Sql($sqltxt); if ($ret) { $error=$db->Error(); # database error msg $db->Close(); Win32::GUI::MessageBox( $W, $error, "Create CRM File - Error", 16, ); Win32::GUI::MessageBox( $W, "Shutting Down the Application", "Create CRM File - Status", 64, ); exit; } while ($db->FetchRow()) { $shipdate=$db->Data("ship_date"); $ponumber=$db->Data("po_number"); $groupcnt=$db->Data("cnt_of_rows"); $string=$ponumber . "-" . $shipdate . "-" . $groupcnt; $List1->AddString($string); } if ($List1->Count == 0) { Win32::GUI::MessageBox( $W, "There are no active PO#s in the Database", "Create CRM File - Status", 64, ); Win32::GUI::MessageBox( $W, "Shutting Down the Application", "Create CRM File - Status", 64, ); exit; } $Status->Text(" "); $Status->Update(); $List1->Select(0); $List1->SetFocus(); } sub ConnectToDatabase { $DSN="EDIdsn"; $db = new Win32::ODBC($DSN); if (! $db) { Win32::GUI::MessageBox( $W, "Can't Establish Database Connection to DSN '$DSN'", "Create CRM File - Error", 16, ); Win32::GUI::MessageBox( $W, "Shutting Down the Application", "Create CRM File - Status", 64, ); exit; } } sub Verify_Date { if ($TestDt=~/^[0-9]+$/) {;} # date must be all digits else {return 1;} if (length($TestDt) != 6) {return 1;} $mm_n=(substr($TestDt,2,2)+0); $mm_a=substr($TestDt,2,2); $dd_n=(substr($TestDt,4,2)+0); $dd_a=substr($TestDt,4,2); $yy_n=(substr($TestDt,0,2)+0); $yy_a=substr($TestDt,0,2); $rmdr=($yy_n % 4); if ($mm_a eq "01") {$maxday=31;} elsif ($mm_a eq "02") { if ($rmdr == 0) {$maxday=29;} else {$maxday=28;} } elsif ($mm_a eq "03") {$maxday=31;} elsif ($mm_a eq "04") {$maxday=30;} elsif ($mm_a eq "05") {$maxday=31;} elsif ($mm_a eq "06") {$maxday=30;} elsif ($mm_a eq "07") {$maxday=31;} elsif ($mm_a eq "08") {$maxday=31;} elsif ($mm_a eq "09") {$maxday=30;} elsif ($mm_a eq "10") {$maxday=31;} elsif ($mm_a eq "11") {$maxday=30;} elsif ($mm_a eq "12") {$maxday=31;} else {return 1;} if ($dd_n<1 || $dd_n>$maxday) {return 1;} return 0; } sub Verify_AlphaNumeric { $AlpNum=~tr/A-Za-z0-9/*/c; # convert all non-alphanumerics to * $AlpNum=~tr/*//d; # delete asterisks $len=length($AlpNum); # how many alphanumerics? if ($len==0) {return 1;} return 0; } sub Verify_Money { if ($Money=~/^[0-9.]+$/) {;} # must be digits and decimal else {return 1;} $len=length($Money); if ($len < 4) {return 1;} $Decimal=substr($Money,$len-3,1); if ($Decimal ne ".") {return 1;} $Decs=0; for ($i=0;$i<$len;$i++) { if (substr($Money,$i,1) eq ".") {$Decs++;} } if ($Decs != 1) {return 1;} return 0; } sub Verify_Input { foreach $key (keys %selected) { $Comp=$selected{$key}->{"Company"}; $Cust=$selected{$key}->{"Customer"}; $Orde=$selected{$key}->{"Order"}; $Loca=$selected{$key}->{"Location"}; $Serv=$selected{$key}->{"Service"}; $Purp=$selected{$key}->{"Purprice"}; $Purd=$selected{$key}->{"Purdate"}; $AlpNum=$Comp; $rtn=Verify_AlphaNumeric(); if ($rtn) {return "$key,1";} $AlpNum=$Cust; $rtn=Verify_AlphaNumeric(); if ($rtn) {return "$key,2";} $AlpNum=$Orde; $rtn=Verify_AlphaNumeric(); if ($rtn) {return "$key,3";} $AlpNum=$Loca; $rtn=Verify_AlphaNumeric(); if ($rtn) {return "$key,4";} $AlpNum=$Serv; $rtn=Verify_AlphaNumeric(); if ($rtn) {return "$key,5";} $Serv_1=substr($Serv,0,1); if (($Serv_1 ne "D") && ($Serv_1 ne "A")) {return "$key,5";} $Money=$Purp; $rtn=Verify_Money(); if ($rtn) {return "$key,6";} $TestDt=$Purd; $rtn=Verify_Date(); if ($rtn) {return "$key,7";} } return "0,0"; } sub UnloadEDI { #----------------------------------------------------------# # Open File Dialog Box - specify the CRM output file # show files with *.txt extension starting in C:\ directory #----------------------------------------------------------# my $file = "*.txt\0" . " " x 256; $file = GUI::GetOpenFileName( -owner => $W, -directory => "C:\\", -title => "Create CRM File - Specify Output File", -file => $file, ); if (length($file) == 0) {return;} $ret="Y"; open(CRM,"> $file") || do {$ret="N";}; if ($ret eq "Y") { CRM->autoflush(1); # flush the output buffer each print } else { Win32::GUI::MessageBox( $W, "Can't open $file for output", "Create CRM File - Error", 16, ); return; } #----------------------------------# # display a message on status line #----------------------------------# $Status->Text("Outputing to $file ..."); $Status->Update(); #----------------------------------------# # process each po#/shipdt group selected #----------------------------------------# $savekeys=""; $tmpfile=$file . ".t"; foreach $key (keys %selected) { #----------------------------------------------------------------# # open output on a temp file to be later appended to the CRM file #----------------------------------------------------------------# $ret="Y"; open(CRMtmp,"> $tmpfile") || do {$ret="N";}; if ($ret eq "Y") { CRMtmp->autoflush(1); # flush the output buffer each print } else { $db->Close(); # close the database connection close(CRM); # close the CRM file Win32::GUI::MessageBox( $W, "Can't open a temp file for output", "Create CRM File - Error", 16, ); Win32::GUI::MessageBox( $W, "Shutting Down the Application", "Create CRM File - Status", 64, ); if (length($savekeys) > 0) { ShowFinalResults(); exit; } else {exit;} } #---------------------------# # split the key into fields #---------------------------# @fields=(); # clear the array @fields=split(/-/,$key); $Ponu=$fields[0]; # po_number $Ship=$fields[1]; # ship_date i.e. yyyymmdd $Tcnt=($fields[2]+0); # batch detail count #---------------------------------------------------------# # get runtime variables for this key group from the array # "selected". #---------------------------------------------------------# $Comp=$selected{$key}->{"Company"}; $Cust=$selected{$key}->{"Customer"}; $Orde=$selected{$key}->{"Order"}; $Loca=$selected{$key}->{"Location"}; $Serv=$selected{$key}->{"Service"}; $Purp=$selected{$key}->{"Purprice"}; $Purp=~s/\.//g; # remove decimal since should be implied decimal in output file $Purd=$selected{$key}->{"Purdate"}; # yymmdd #------------------------------------------------------------# # Ward (or Warranty expiration date) is 1 year from Purchase # date, so calculate it. #------------------------------------------------------------# $yr=(substr($Purd,0,2) + 0); if ($yr < 80) {$yr+=2000;} else {$yr+=1900;} $yr+=1; # add 1 year $mody=substr($Purd,2,4); if ($mody eq "0229") {$mody="0301";} $Ward=substr($yr,2,2) . $mody; # yymmdd #-----------------------------------------# # get the database rows matching this key #-----------------------------------------# $sqltxt="SELECT * FROM EDItbl"; $sqltxt=$sqltxt . " WHERE deleted_flag = 'N'"; $sqltxt=$sqltxt . " AND po_number = '" . $Ponu . "'"; $sqltxt=$sqltxt . " AND ship_date = '" . $Ship . "'"; $ret = $db->Sql($sqltxt); if ($ret) { $error=$db->Error(); # get the sql error msg $db->Close(); close(CRM); close(CRMtmp); system("erase $tmpfile"); Win32::GUI::MessageBox($W,$error, "Create CRM File - Error",16, ); Win32::GUI::MessageBox($W, "Shutting Down the Application", "Create CRM File - Status",64, ); if (length($savekeys) > 0) { ShowFinalResults(); exit; } else {exit;} } #-------------------------------------------# # write out each detail record for this key #-------------------------------------------# while ($db->FetchRow()) { $Ship_Date=$db->Data("ship_date"); $Ship_Date=substr($Ship_Date,2,6); # yymmdd $Sku=$db->Data("sku"); $Serial_Number=$db->Data("serial_number"); $Code=$db->Data("code"); # derive model,freq,scheme from sku and do some conversions $Model=substr($Sku,0,4); $Freq=substr($Sku,4,2); $Scheme=substr($Sku,6,1); if (defined($freq_arr{$Freq})) { $Freq=$freq_arr{$Freq}; } else { $Freq=" "; # get default conversion $Freq=$freq_arr{$Freq}; } if (defined($scheme_arr{$Scheme})) { $Scheme=$scheme_arr{$Scheme}; } else { $Scheme=" "; # get default conversion $Scheme=$scheme_arr{$Scheme}; } write CRMtmp; # output to temp file per format template } #---------------------------------------------------------# # check if record count in temp file matches batch detail # count originally reported in listbox1. Also load array # of records from temp file. #---------------------------------------------------------# close(CRMtmp); open(CRMtmp,"$tmpfile"); $cnt=0; @CRMtmp_arr=(); # clear the list while($rec=<CRMtmp>) { chomp($rec); # remove linefeed chop($rec); # remove last character (a tilde ~) $cnt++; $CRMtmp_arr[$cnt]=$rec; # 1 based array, not zero based } close(CRMtmp); system("erase $tmpfile"); if ($cnt != $Tcnt) { $db->Close(); close(CRM); @CRMtmp_arr=(); Win32::GUI::MessageBox($W, "$cnt/$Tcnt - Could not completely unload batch: $key", "Create CRM File - Error",16, ); Win32::GUI::MessageBox($W, "Shutting Down the Application", "Create CRM File - Status",64, ); if (length($savekeys) > 0) { ShowFinalResults(); exit; } else {exit;} } #------------------------------------------# # append temp file records to the CRM file #------------------------------------------# for($i=1;$i<=$cnt;$i++) { $rec=$CRMtmp_arr[$i]; print CRM "$rec\n"; } #---------------------------------------# # Show this batch as exported #---------------------------------------# $savekeys=$savekeys . $key . " "; $sel = $List1->FindStringExact($key); $List1->RemoveItem($sel); # remove PO# from Available List #------------------------------------------------------# # flag rows from database for this po_number/ship_date # so that they don't continue to show up in listbox1 # as available. #------------------------------------------------------# $sqltxt="UPDATE EDItbl SET deleted_flag = 'Y'"; $sqltxt=$sqltxt . " WHERE deleted_flag = 'N'"; $sqltxt=$sqltxt . " AND po_number = '" . $Ponu . "'"; $sqltxt=$sqltxt . " AND ship_date = '" . $Ship . "'"; $ret = $db->Sql($sqltxt); if ($ret) { $restart="N"; $error=$db->Error(); # database error msg close(CRM); $db->Close(); Win32::GUI::MessageBox( $W, $error, "Create CRM File - Error", 16, ); $error="Need to flag po_number/ship_date rows\n"; $error=$error . "in database matching $Ponum/$Ship\n"; $error=$error . "as DELETED after this run completes."; Win32::GUI::MessageBox( $W, $error, "Create CRM File - Call Help Desk", 16, ); } } # end foreach loop close(CRM); ShowFinalResults(); if ($restart eq "Y") { $Status->Text(" "); $Status->Update(); ResetTextBoxes(); # clear the Text boxes $List2->Reset(); # clear listbox2 %selected=(); # clear the selected item array } else {exit;} } sub Showme { $msg=$item; $msg=$msg . "," . $selected{$item}->{"Company"}; $msg=$msg . "," . $selected{$item}->{"Customer"}; $msg=$msg . "," . $selected{$item}->{"Order"}; $msg=$msg . "," . $selected{$item}->{"Location"}; $msg=$msg . "," . $selected{$item}->{"Service"}; $msg=$msg . "," . $selected{$item}->{"Purprice"}; $msg=$msg . "," . $selected{$item}->{"Purdate"}; $Status->Text($msg); $Status->Update(); } sub ShowFinalResults { Win32::GUI::MessageBox( $W, "Successfully unloaded batches: $savekeys", "Create CRM File - Final Results", 64, ); } sub ResetTextBoxes { $Ponumber->Text(""); $Company->Text(""); $Customer->Text(""); $Order->Text(""); $Location->Text(""); $Service->Text(""); $Purprice->Text(""); $Purdate->Text(""); } END { if ($db) {$db->Close();} GUI::Show($DOShwnd); } #------------------------------------# # Window Events #------------------------------------# sub List2_Click { $sel = $List2->SelectedItem(); # sel is zero based index if($sel >= 0) { $item = $List2->GetString($sel); $Comp=$selected{$item}->{"Company"}; $Cust=$selected{$item}->{"Customer"}; $Orde=$selected{$item}->{"Order"}; $Loca=$selected{$item}->{"Location"}; $Serv=$selected{$item}->{"Service"}; $Purp=$selected{$item}->{"Purprice"}; $Purd=$selected{$item}->{"Purdate"}; $Ponumber->Text($item); $Company->Text($Comp); $Customer->Text($Cust); $Order->Text($Orde); $Location->Text($Loca); $Service->Text($Serv); $Purprice->Text($Purp); $Purdate->Text($Purd); } else { Win32::Sound::Play("SystemDefault", SND_ASYNC); } } sub Add_Click { # sel is the zero based index of the item in the listbox $sel = $List1->SelectedItem(); if($sel >= 0) { $item = $List1->GetString($sel); $ret = $List2->FindStringExact($item); if ($ret == -1) { $new = $List2->InsertItem($item); $List2->Select($new); $selected{$item}->{"Company"}=""; $selected{$item}->{"Customer"}=""; $selected{$item}->{"Order"}=""; $selected{$item}->{"Location"}=""; $selected{$item}->{"Service"}=""; $selected{$item}->{"Purprice"}=""; $selected{$item}->{"Purdate"}=""; List2_Click(); } else { # item was already added once to Listbox2 Win32::Sound::Play("SystemDefault", SND_ASYNC); } } else { Win32::Sound::Play("SystemDefault", SND_ASYNC); } } sub Remove_Click { $sel = $List2->SelectedItem(); if($sel >= 0) { $item=$List2->GetString($sel); $List2->RemoveItem($sel); delete $selected{$item}; if ($List2->Count() > 0) { $sel=($List2->Count()-1); $List2->Select($sel); # index is zero based List2_Click(); } else { # do this if no items remain in listbox2. # since Ponumber is blank, on change event logic # will automatically be bypassed, like we want. $List2->Reset(); %selected=(); ResetTextBoxes(); $Status->Text(" "); $Status->Update(); $List1->SetFocus(); } } else { Win32::Sound::Play("SystemDefault", SND_ASYNC); } } sub Okay_Click { if ($List2->Count() > 0) { $ret=Verify_Input(); @fields=(); @fields=split(/,/,$ret); $key=$fields[0]; $ret=($fields[1]+0); # no errors in runtime vars if ($ret == 0) { UnloadEDI(); return; } # an error has occured. show the effected PO# # and set focus on the bad runtime var $sel = $List2->FindStringExact($key); $List2->Select($sel); List2_Click(); if ($ret == 1) { $msg="Invalid Company Field"; Win32::GUI::MessageBox($W,$msg, "Create CRM File - User Data Input Error",16, ); $Company->SetFocus(); $Company->Select(0,length($Company->Text())); } elsif ($ret == 2) { $msg="Invalid Customer Field"; Win32::GUI::MessageBox($W,$msg, "Create CRM File - User Data Input Error",16, ); $Customer->SetFocus(); $Customer->Select(0,length($Customer->Text())); } elsif ($ret == 3) { $msg="Invalid Order Field"; Win32::GUI::MessageBox($W,$msg, "Create CRM File - User Data Input Error",16, ); $Order->SetFocus(); $Order->Select(0,length($Order->Text())); } elsif($ret == 4) { $msg="Invalid Location Field"; Win32::GUI::MessageBox($W,$msg, "Create CRM File - User Data Input Error",16, ); $Location->SetFocus(); $Location->Select(0,length($Location->Text())); } elsif ($ret == 5) { $msg="Invalid Service Field"; Win32::GUI::MessageBox($W,$msg, "Create CRM File - User Data Input Error",16, ); $Service->SetFocus(); $Service->Select(0,length($Service->Text())); } elsif ($ret == 6) { $msg="Invalid Price Field"; Win32::GUI::MessageBox($W,$msg, "Create CRM File - User Data Input Error",16, ); $Purprice->SetFocus(); $Purprice->Select(0,length($Purprice->Text())); } elsif ($ret == 7) { $msg="Invalid Date Field"; Win32::GUI::MessageBox($W,$msg, "Create CRM File - User Data Input Error",16, ); $Purdate->SetFocus(); $Purdate->Select(0,length($Purdate->Text())); } else { $msg="Invalid Unknown Field"; Win32::GUI::MessageBox($W,$msg, "Create CRM File - User Data Input Error",16, ); $Company->SetFocus(); $Company->Select(0,length($Company->Text())); } } else { $Status->Text("No PO#/ShipDt(s) Selected!"); $Status->Update(); sleep 1; %selected=(); $List2->Reset(); ResetTextBoxes(); $Status->Text(" "); $Status->Update(); $Okay->SetFocus(); } } sub Cancel_Click { Window_Terminate(); } sub About_Click { $msg=""; $msg=$msg . "Program: Create CRM File\n"; $msg=$msg . " Version: r2.3\n"; $msg=$msg . " Date: July 1999\n"; $msg=$msg . " By: Eric Hansen\n"; $msg=$msg . " Information Technology Services, Inc.\n"; $msg=$msg . " Dallas, TX\n"; Win32::GUI::MessageBox($W,$msg,"About - Create CRM File",64,); $About->SetFocus(); } sub Window_Terminate { if ($db) {$db->Close();} GUI::Show($DOShwnd); exit; } sub Company_Change { $item=$Ponumber->Text(); if (length($item) > 0) { $Comp=$Company->Text(); $selected{$item}->{"Company"}=$Comp; Showme(); } } sub Customer_Change { $item=$Ponumber->Text(); if (length($item) > 0) { $Cust=$Customer->Text(); $selected{$item}->{"Customer"}=$Cust; Showme(); } } sub Order_Change { $item=$Ponumber->Text(); if (length($item) > 0) { $Orde=$Order->Text(); $selected{$item}->{"Order"}=$Orde; Showme(); } } sub Location_Change { $item=$Ponumber->Text(); if (length($item) > 0) { $Loca=$Location->Text(); $selected{$item}->{"Location"}=$Loca; Showme(); } } sub Service_Change { $item=$Ponumber->Text(); if (length($item) > 0) { $Serv=$Service->Text(); $selected{$item}->{"Service"}=$Serv; Showme(); } } sub Purprice_Change { $item=$Ponumber->Text(); if (length($item) > 0) { $Purp=$Purprice->Text(); $selected{$item}->{"Purprice"}=$Purp; Showme(); } } sub Purdate_Change { $item=$Ponumber->Text(); if (length($item) > 0) { $Purd=$Purdate->Text(); $selected{$item}->{"Purdate"}=$Purd; Showme(); } } #----------------------------------------------------------------------- ----------------- # OUTPUT TEMPLATE # # Have to terminate record with a constant character such as a tilde (~) or else record # is chopped to the last non-blank character. Since we want fixed length records, we must # prevent this. We will strip off the tilde(~) when we move the records to the CRM file # from the CRM tmp file. #----------------------------------------------------------------------- ----------------- format CRMtmp= @<<<<<@<<@<<<<<@<<<<<@<@@@@@<@@<@<<<@@<@#################@<<<<<@<<<<<@<< <<<<<@<<<<<<<<<<<@<<<@<<<<<<<<<<<<<@<<<<<<<<<<<<<@<<<<<<<<<<<<@<<<<<<<<< <<<@ $Ship_Date,$Comp,$Cust,$Orde," ","A","N","P",$Loca,$Scheme,$Freq,"M",$Model,"N",$Serv,$Purp,$Purd,$Ward," "," ","0001",$Code," ",$Serial_Number," ","~"