function TForm1.EGN_OLD(s: String): Boolean;
var
a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,suma,meseca, ostatak, god, posledno: Integer;
egn :String;
data1,mesec1,godina,d : String;
alldata1: TDateTime;
begin
ShortDateFormat := 'dd/mm/yyyy';
DateSeparator := '/';
egn :=Edit1.Text;
a1 := strtoint(Copy(egn,1,1));
a2 := strtoint(Copy(egn,2,1));
a3 := strtoint(Copy(egn,3,1));
a4 := strtoint(Copy(egn,4,1));
a5 := strtoint(Copy(egn,5,1));
a6 := strtoint(Copy(egn,6,1));
a7 := strtoint(Copy(egn,7,1));
a8 := strtoint(Copy(egn,8,1));
a9 := strtoint(Copy(egn,9,1));
posledno := strtoint(Copy(egn,10,1));
godina := (Copy(egn,1,1))+(Copy(egn,2,1));
god := strtoint(godina);
if god <=05 then begin
god := god+2000; //0542040458 7406069151 7911044644
end
else begin
god := god+1900;
end;
Label2.Caption := 'Ãîäèíà íà ðàæäàíå:'+ IntToStr(god);
{
if ((god > 2005) AND (god < 1900)) then begin
ShowMessage('Ãðåøíà ãîäèíà');
Exit;
end;
}
{
a10:= strtoint(Copy(egn,10,1));
godina := Copy(egn,1,2);
mesec1 := Copy(egn,3,2);
meseca := strtoint(Copy(egn,3,2));
data1 := Copy(egn,5,2);
d := data1+'/'+mesec1+'/'+'19'+godina;
alldata1 := StrToDate(d);
if alldata1 < strtodate('01/01/1900') then begin
meseca := meseca+20
end;
if alldata1 > strtodate('31/12/1999') then begin
meseca := meseca+40
end;
if ((a9 = 2) or (a9 = 4)) or
((a9 = 6) or (a9 = 8)) or
(a9 = 0) then begin
ShowMessage('maj');
end;
if ((a9 = 1) or (a9 = 3)) or
((a9 = 5) or (a9 = 7)) or
(a9 = 9) then begin
ShowMessage('jena');
end;
}
//strtodate(d); + meseca
// true (èñòèíà - 1) èëè false (ëúæà - 0), â çà
// íîìåð íà ïîçèöèÿòà â ÅÃÍ 1 2 3 4 5 6 7 8 9
// óìíîæåíèå * * * * * * * * *
// òåãëà 2 4 8 5 10 9 7 3 6
suma := ((a1*2)+(a2*4)+(a3*8)+(a4*5)+(a5*10)+(a6*9)+(a7*7)+(a8*3)+(a9*6));
Label1.Caption := 'Ñóìà:'+ inttostr(suma);
if god < 1900 then begin
suma := (a1*2)+(a2*4)+((a3*8)+20)+((a4*5))+(a5*10)+(a6*9)+(a7*7)+(a8*3)+(a9*6);
Label1.Caption := 'Ñóìà:'+ inttostr(suma) + ' Âëèçà â óñëîâèåòî';
end;
if god > 2000 then begin
suma := (a1*2)+(a2*4)+((a3*8)+40)+((a4*5))+(a5*10)+(a6*9)+(a7*7)+(a8*3)+(a9*6);
Label1.Caption := 'Ñóìà:'+ inttostr(suma) + ' Âëèçà â óñëîâèåòî';
end;
ostatak := suma mod 11;
Label3.Caption := 'Îñòàúê: '+ inttostr(ostatak);
//ShowMessage('îñòàòúê e:'+ inttostr(ostatak));
if ostatak < 10 then begin
a10 := ostatak; //(èñòèíà - 1)
ShowMessage('Âÿðíî ÅÃÍ ');
Result := True;
end;
if ostatak = 10 then begin
a10 := 0; // (ëúæà - 0)
ShowMessage('Ãðåøíî ÅÃÍ');
Result := False;
end;
{
if a10 = 0 then begin
ShowMessage('Ãðåøíî ÅÃÍ');
Result := False;
end
else begin
ShowMessage(' Âÿðíî ÅÃÍ');
Result := True;
end;
}
{
if a10 <> 0 then begin
ShowMessage('Âÿðíî ÅÃÍ ');
Result := True;
end
else begin
ShowMessage('Ãðåøíî ÅÃÍ');
Result := False;
end;
}
end;
|