Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Codice Fiscale 2.0 - CodFisc.pas

CodFisc.pas

Caricato da: K.Mitnick
Scarica il programma completo

  1. unit CodFisc;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, CodFiscImp, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ExtCtrls, jpeg, Menus;
  8.  
  9. type
  10.   TCodiceFiscale = class(TForm)
  11.     Panel1: TPanel;
  12.     Panel2: TPanel;
  13.     Cognome: TEdit;
  14.     Nome: TEdit;
  15.     Anno: TEdit;
  16.     Mese: TComboBox;
  17.     Giorno: TComboBox;
  18.     Sesso: TComboBox;
  19.     CODIC: TEdit;
  20.     Panel5: TPanel;
  21.     Panel3: TPanel;
  22.     Calcola: TButton;
  23.     Panel6: TPanel;
  24.     Panel4: TPanel;
  25.     Esci: TButton;
  26.     Panel7: TPanel;
  27.     Timer1: TTimer;
  28.     MainMenu1: TMainMenu;
  29.     File1: TMenuItem;
  30.     Close1: TMenuItem;
  31.     Info1: TMenuItem;
  32.     Disclamer1: TMenuItem;
  33.     Label1: TLabel;
  34.     Label2: TLabel;
  35.     Label3: TLabel;
  36.     Image1: TImage;
  37.     Provincia: TEdit;
  38.     Scadenza: TLabel;
  39.     Comune: TComboBox;
  40.     procedure CalcolaClick(Sender: TObject);
  41.     procedure EsciClick(Sender: TObject);
  42.     procedure Timer1Timer(Sender: TObject);
  43.     procedure Disclamer1Click(Sender: TObject);
  44.     procedure Close1Click(Sender: TObject);
  45.     procedure Label2Click(Sender: TObject);
  46.     procedure Label1Click(Sender: TObject);
  47.     procedure CognomeClick(Sender: TObject);
  48.     procedure NomeClick(Sender: TObject);
  49.     procedure AnnoClick(Sender: TObject);
  50.     procedure ComuneClick(Sender: TObject);
  51.     procedure GiornoClick(Sender: TObject);
  52.     procedure MeseClick(Sender: TObject);
  53.     procedure SessoClick(Sender: TObject);
  54.   private
  55.     { Private declarations }
  56.   public
  57.     { Public declarations }
  58.   end;
  59.  
  60. const
  61.  CRLF = #13 + #10;
  62.  
  63. var
  64.   CodiceFiscale: TCodiceFiscale;
  65.   x,i,lungcom,lng4,Scad: integer;
  66.   comuneprov,l1,Scadtmp,Scadtmp1,Scadtmp2,Scad1:string;
  67.  
  68. implementation
  69.  
  70.  
  71. {$R *.dfm}
  72.  
  73.  
  74. procedure TCodiceFiscale.EsciClick(Sender: TObject);
  75. begin
  76.      showmessage('Grazie per aver utilizzato il programma e arrivederci');
  77.      close;
  78. end;
  79.  
  80. procedure TCodiceFiscale.CalcolaClick(Sender: TObject);
  81. var errore,inesistente,bisestile:boolean;
  82.     year,month,day,limmin,limmax,lenganno,lengmese,lenggiorno,testlong:integer;
  83.  
  84. begin
  85. errore:=false;
  86. inesistente:=false;
  87. bisestile:=false;
  88. {controlla se il sesso è corretto}
  89. if (Sesso.text<>'M') and (Sesso.text<>'F')  or (Comune.text='Comune') or (Nome.text='Nome') or (Cognome.text='Cognome') or (Giorno.text='Giorno') or (Mese.text='Mese') or (Anno.text='Anno') or (Comune.text='') or (Nome.text='') or (Cognome.text='') or (Giorno.text='') or (Mese.text='') or (Anno.text='') then
  90. begin
  91.      errore:=true;
  92. end;
  93. {imposto i limiti massimi per la data}
  94. if (Anno.text>'9999') or (Anno.text<'1500') then
  95. begin
  96.      inesistente:=true;
  97. end;
  98.  
  99. {controllo la validità dell data, tenendo conto se l'anno in questione è bisestile o meno}
  100. if (errore=false) and (inesistente=false) then
  101. begin
  102.      limmin:=1;
  103.      try
  104.         year:=strtoint(Anno.text);
  105.         month:=strtoint(Mese.text);
  106.         day:=strtoint(Giorno.text);
  107.      except
  108.      on EConvertError do
  109.         errore:=true;
  110.      end;
  111. end;
  112. {controllo se l'anno è bisestile}
  113. if ((year mod 4=0) and ((year mod 100<>0) or (year mod 400=0)))  then
  114. begin
  115.      bisestile:=true;
  116. end;
  117.  
  118.   case month of
  119.      2:
  120.        begin
  121.             if (bisestile=false) then
  122.             begin
  123.                  limmax:=28;
  124.             end;
  125.                 if (bisestile=true) then
  126.                 begin
  127.                      limmax:=29;
  128.                 end;
  129.        end;
  130.      4,6,9,11:
  131.               begin
  132.                    limmax:=30;
  133.               end;
  134.      1,3,5,7,8,10,12:
  135.                      begin
  136.                           limmax:=31;
  137.                      end;
  138. end;
  139.  
  140. if ((day<limmin) or (day>limmax)) then
  141. begin
  142.      inesistente:=true;
  143. end;
  144.  
  145. if ((errore=true) and (inesistente=false)) then
  146. begin
  147.      showmessage('Dati non completi.Controllare i dati.');
  148. end;
  149.  
  150. if ((inesistente=true) and (errore=false)) then
  151. begin
  152.      showmessage('Dati non validi.Controllare i dati.');
  153. end;
  154.  
  155. if ((inesistente=true) and (errore=true)) then
  156. begin
  157.      showmessage('Dati incompleti e/o non validi.Controllare i dati.');
  158. end;
  159.  
  160. { passaggio dati globali }
  161.  codic.Text:='';
  162.  
  163.  codfiscimp.cognome:=Cognome.Text;     { cognome }
  164.  codfiscimp.nome:=nome.Text;           { nome }
  165.  codfiscimp.anno:=Anno.Text;           { anno }
  166.  val(mese.Text,codfiscimp.g,x);        { mese }
  167.  val(giorno.Text,codfiscimp.gio,x);    { giorno }
  168.  if Sesso.Text='M' then
  169.   begin
  170.        codfiscimp.maschio:=true
  171.   end   { sesso }
  172.   else
  173.       begin
  174.            codfiscimp.maschio:=false;
  175.       end;
  176.  
  177.  codfiscimp.comu:=comune.text;
  178.  
  179.  
  180.  Main_control();
  181.  
  182.  if (errore=false) and (inesistente=false) then
  183.  begin
  184.       for i:=1 to 16 do
  185.       begin
  186.            codic.Text:=codic.text+codfiscimp.codice[i];
  187.            comuneprov:=Comune.text;
  188.            lungcom:=(Length(Comune.text)-9);
  189.            l1:=copy(comuneprov,lungcom,2);
  190.            Provincia.text:=l1;
  191.            testlong:=Length(CODIC.text);
  192.       end;
  193.                    if (testlong<>16) then  //ulteriore controllo se il codice fiscale è corretto
  194.                    begin
  195.                         CODIC.text:='ERRORE: Controllare i dati!';
  196.                    end;
  197.  end;
  198. end;
  199.  
  200.  
  201.  
  202. procedure TCodiceFiscale.Timer1Timer(Sender: TObject);
  203. begin
  204.      Label2.caption:=timetostr(time);                  //serve per calcolare la data di scadenza della carta d'identità
  205.      Scadtmp:=datetostr(date);
  206.      lng4:=((length(Scadtmp))-3);
  207.      Scadtmp1:=copy(Scadtmp,lng4,4);
  208.      Scad:=((strtoint(Scadtmp1))+5);
  209.      Scad1:=(inttostr(Scad));
  210.      Scadtmp2:=Scadtmp;
  211.      Delete(Scadtmp2,lng4,4);
  212.      insert(Scad1,Scadtmp2,lng4);
  213.      Scadenza.caption:=Scadtmp2;
  214. end;
  215.  
  216. procedure TCodiceFiscale.Disclamer1Click(Sender: TObject);
  217. begin
  218.      showmessage('Il codice fiscale viene calcolato mediante le modalità di calcolo descritte' + #10 + #13 +
  219.      'dal Decreto ministeriale del Ministero delle Finanze del 23 dicembre 1976 '+ #10 + #13 +
  220.      '''Sistemi di codificazione dei soggetti da iscrivere all''anagrafe tributaria'' (GU n. 345 del 29-12-1976).' + #10 + #13 +
  221.      'In caso omocodia il codice fiscale viene modificato arbitrariamente dall''Agenzia delle Entrate'+ #10 + #13 +
  222.      'e quindi il codice calcolato dal programma non può esser ritenuto valido.'+ #10 + #13 +
  223.      'Il codice fiscale generato è quindi corretto sotto il punto di vista formale ma potrebbe non corrispondere realmente alla persona indicata.'+ #10 + #13 +
  224.      ''+ #10 + #13 +
  225.      '                                                                                                                                              K.Mitnick.');
  226. end;
  227.  
  228.  
  229. procedure TCodiceFiscale.Close1Click(Sender: TObject);
  230. begin
  231.      showmessage('Grazie per aver utilizzato il programma e arrivederci');
  232.      halt;
  233. end;
  234.  
  235. procedure TCodiceFiscale.Label2Click(Sender: TObject);
  236. var msg:string;
  237. begin
  238.      msg:=label1.caption+' '+label2.caption;
  239.      showmessage(msg);
  240. end;
  241.  
  242. procedure TCodiceFiscale.Label1Click(Sender: TObject);
  243. var msg:string;
  244. begin
  245.      msg:=label1.caption+' '+label2.caption;
  246.      showmessage(msg);
  247. end;
  248. procedure TCodiceFiscale.CognomeClick(Sender: TObject);
  249. begin
  250.      Cognome.text:='';
  251. end;
  252.  
  253. procedure TCodiceFiscale.NomeClick(Sender: TObject);
  254. begin
  255.      Nome.text:='';
  256. end;
  257.  
  258. procedure TCodiceFiscale.AnnoClick(Sender: TObject);
  259. begin
  260.      Anno.text:='';
  261. end;
  262.  
  263.  
  264. procedure TCodiceFiscale.ComuneClick(Sender: TObject);
  265. begin
  266.      Comune.text:='';
  267. end;
  268.  
  269. procedure TCodiceFiscale.GiornoClick(Sender: TObject);
  270. begin
  271.      Giorno.text:='';
  272. end;
  273.  
  274. procedure TCodiceFiscale.MeseClick(Sender: TObject);
  275. begin
  276.      Mese.text:='';
  277. end;
  278.  
  279. procedure TCodiceFiscale.SessoClick(Sender: TObject);
  280. begin
  281.      Sesso.text:='';
  282. end;
  283.  
  284. end.