I have created a Program that first searches and returns the contents of a file into a richedit then opens up the next file finds the matching record and displays that in the rich edit and then the same again with another file.
My problem is that when i search it displays an EinOut Error File Not Found but the File Is there becasuse i wrote the records to it from the program.
Just so you can get an idea here is my code for the Procedure that fails it fails at the 'reset(productfile)' and 'reset(Servicefile)' i've highlighted them in red.
Any help would be majorly appreciated because i have to get this finished thanks in advance.
procedure TForm12.Button1Click(Sender: TObject);
var found:boolean; buyer:string; warranty:string; service:string; billing:string; product:string; postcode:string; name:string;
begin
found := false;
RichEdit1.clear;
assignfile(CustomerFile, Customer);
reset(CustomerFile);
while not eof (CustomerFile) do
read(CustomerFile, CustomerRecord);
begin
if (CustomerRecord.Name = Edit1.text) or (CustomerRecord.Postcode = edit2.Text) or (CustomerRecord.Surname = edit3.Text) then
begin
Richedit1.Lines.Add('Customer Details');
Richedit1.Lines.Add('');
Richedit1.Lines.Add('Title: '+ CustomerRecord.Title);
Richedit1.Lines.Add('Name: '+ CustomerRecord.Name);
Richedit1.Lines.Add('Surname: '+ CustomerRecord.Surname);
Richedit1.Lines.Add('Street: '+ CustomerRecord.Street);
Richedit1.Lines.Add('Town: '+ CustomerRecord.Town);
Richedit1.Lines.Add('County: '+ CustomerRecord.County);
Richedit1.Lines.Add('Postcode '+ CustomerRecord.Postcode);
Richedit1.Lines.Add('Telephone '+ CustomerRecord.Telephone);
Richedit1.Lines.Add('Mobile: '+ CustomerRecord.Mobile);
Richedit1.Lines.Add('Email: '+ CustomerRecord.Email);
Richedit1.Lines.Add('Notes: '+ CustomerRecord.Notes);
Richedit1.Lines.Add('');
Richedit1.Lines.Add('');
billing := CustomerRecord.billing;
buyer := CustomerRecord.Buying;
service := CustomerRecord.Service;
warranty := CustomerRecord.Warranty;
product := CustomerRecord.ProductS;
Postcode := CustomerRecord.Postcode;
name := CustomerRecord.Name;
found := true;
end;
If billing = 'y' then
Begin
Richedit1.Lines.Add('Billing Details');
Richedit1.Lines.Add('');
Richedit1.Lines.Add('Billing Title: '+ CustomerRecord.BTitle);
Richedit1.Lines.Add('Billing Name: '+ CustomerRecord.BName);
Richedit1.Lines.Add('Billing Surname: '+ CustomerRecord.BSurname);
Richedit1.Lines.Add('Billing Street: '+ CustomerRecord.BStreet);
Richedit1.Lines.Add('Billing Town: '+ CustomerRecord.BTown);
Richedit1.Lines.Add('Billing County: '+ CustomerRecord.BCounty);
Richedit1.Lines.Add('Billing Postcode: '+ CustomerRecord.BPostcode);
Richedit1.Lines.Add('Billing Telephone: '+ CustomerRecord.BTelephone);
Richedit1.Lines.Add('Billing Mobile: '+ CustomerRecord.BMobile);
Richedit1.Lines.Add('Billing Email: '+ CustomerRecord.BEmail);
Richedit1.Lines.Add('');
Richedit1.Lines.Add('');
End;
If warranty = 'y' then
Begin
Richedit1.Lines.Add('Warranty Details');
Richedit1.Lines.Add('');
Richedit1.Lines.Add('Warranty Start: '+ CustomerRecord.Wstart);
Richedit1.Lines.Add('Warranty Length: '+ CustomerRecord.WLength);
Richedit1.Lines.Add('');
Richedit1.Lines.Add('');
End;
If service = 'y' then
Begin
Richedit1.Lines.Add('Service Details');
Richedit1.Lines.Add('');
Richedit1.Lines.Add('Installation date: '+ CustomerRecord.IDate);
Richedit1.Lines.Add('New / Refurbished: '+ CustomerRecord.NR);
Richedit1.Lines.Add('Service Interval: '+ CustomerRecord.SInterval);
Richedit1.Lines.Add('Next Service: '+ CustomerRecord.NxtSDate);
Richedit1.Lines.Add('');
Richedit1.Lines.Add('');
End;
end;
closefile(CustomerFile);
assignfile(ProductFile, Product);
reset(ProductFile);
while not eof (ProductFile) do
read(ProductFile, ProductRecord);
begin
if ProductRecord.Serial = product then
Begin
Richedit1.Lines.Add('Product Details');
Richedit1.Lines.Add('');
Richedit1.Lines.Add('Product Serial: '+ ProductRecord.Serial);
Richedit1.Lines.Add('Make / Model: '+ ProductRecord.MakeModel);
Richedit1.Lines.Add('Date Of Purchase: '+ ProductRecord.DOP);
Richedit1.Lines.Add('Colour: '+ ProductRecord.Colour);
Richedit1.Lines.Add('Elec Or Manual: '+ ProductRecord.EorM);
Richedit1.Lines.Add('Price: '+ ProductRecord.Cost);
Richedit1.Lines.Add('Reference No.: '+ ProductRecord.RefNo);
End;
end;
closefile(ProductFile);
assignfile(ServiceFile, Service);
reset(ServiceFile);
while not eof (ServiceFile) do
read(ServiceFile, ServiceRecord);
begin
if (ServiceRecord.Nameofcustomer = name) and (ServiceRecord.postcodeofcustomer = postcode) then
Begin
Richedit1.Lines.Add('Date Of Service: '+ ServiceRecord.Dateofservice);
Richedit1.Lines.Add('Parts Used: '+ ServiceRecord.PartsUsed);
Richedit1.Lines.Add('Notes: '+ ServiceRecord.Notes);
End;
end;
closefile(ServiceFile);
if found = false then
Begin
showmessage('not on the file');
End;
end;