home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / tema / 602propc / disk5 / data.5 / WINTIME / APPS / I_UDRZBA.PGM < prev    next >
Text File  |  1996-12-03  |  23KB  |  601 lines

  1. Include
  2.  
  3. function Info1 : integer;
  4. {*******************************************}
  5. {funkce vracφ poΦet platn²ch zßznam∙ v tabulce}
  6. var
  7.   cc : cursor;
  8.   pocet : integer;
  9. begin
  10.   Info1 := -1;
  11.   if not Open_sql_cursor(cc,'SELECT * FROM Tfirma') then begin
  12.     if not Rec_cnt(cc,pocet) then
  13.       Info1 := pocet;
  14.     Close_cursor(cc);
  15.   end;    
  16. end;
  17.  
  18. function Info2 : integer;
  19. {*******************************************}
  20. {funkce vracφ poΦet zßznam∙ vybran²ch do kurzoru curmain}
  21. var
  22.   pocet : integer;
  23. begin
  24.   Info2 := -1;
  25.   if not Rec_cnt(curmain,pocet) then
  26.     Info2 := pocet;
  27. end;
  28.  
  29. procedure Kontrola;
  30. {**************************************}
  31. {prob∞hne kontrola integrity databßze a nahlßsφ v²sledek}
  32. var
  33.   id2 : window_id;
  34.   ss : string[100];
  35. begin
  36.   if myName <> 'DB_ADMIN' then Info_box('Nelze','  Kontrolu integrity dat m∙₧e provΘst pouze sprßvce databßze!')
  37.   else begin
  38.     Set_cursor(1);
  39.     e1 := 0;e2 := 0; e3 := 0; e4 := 0; e5 := 0;
  40.     if id > 0 then Close_view(id);
  41.     if id_sez > 0 then Close_view(id_sez);
  42.     if Close_cursor(curmain) then Signalize;  // p°ed kontrolou je nutnΘ vÜe uzav°φt
  43.     Peek_message;                             // ...aby se doruΦily zprßvy o zav°enφ pohledu
  44.     Uninst_table(-1);
  45.     Set_status_text("Probφhß kontrola databßze, prosφm Φekejte...");
  46.     if Database_integrity(true, e1,e2,e3,e4,e5) then Signalize
  47.     else begin
  48.       Set_cursor(1);
  49.       Set_status_text("");
  50.       if e1+e2+e3+e4+e5=0 then 
  51.         Info_box('Provedeno','vÜe OK')
  52.       else
  53.         Open_view("*Pkontrola",no_redir,0,0,0,id2);
  54.         repeat Peek_message until id2 = 0;
  55.     end;
  56.     if vsechnysk then ss := 'SELECT * FROM Tfirma'
  57.     else ss := 'SELECT * FROM Tfirma WHERE skupina='+Int2str(skup);
  58.     if Open_sql_cursor(curmain,ss) then Signalize;
  59.   end;
  60. end;
  61.  
  62. procedure Uvolneni;
  63. {**************************************}
  64. {procedura uvolnφ smazanΘ zßznamy aby nezabφraly mφsto}
  65. var
  66.   err : boolean;
  67.   ss : string[100];
  68. begin
  69.   err := false;
  70.   if id > 0 then Close_view(id);
  71.   if id_sez > 0 then Close_view(id_sez);
  72.   if Close_cursor(curmain) then Signalize;
  73.   Peek_message;
  74.  
  75.   Free_deleted(TABTAB);
  76.   Uninst_table(-1);
  77.   if Free_deleted(Tfirma) then Info_box('Chyba','Operace neprob∞hla, n∞kdo jin² jeÜt∞ pracuje s Adresß°em')
  78.   else Info_box('Tabulka adres','OK');
  79.   if Free_deleted(Tschuzky) then Info_box('Chyba','Operace neprob∞hla, n∞kdo jin² jeÜt∞ pracuje s Adresß°em')
  80.   else Info_box('Tabulka sch∙zek','OK');
  81.   if vsechnysk then ss := 'SELECT * FROM Tfirma'
  82.   else ss := 'SELECT * FROM Tfirma WHERE skupina='+Int2str(skup);
  83.   if Open_sql_cursor(curmain,ss) then Signalize;
  84. end;
  85.  
  86. procedure OpravitIndexy;
  87. {**************************************}
  88. {opravφ p°φpadn∞ poÜkozenΘ indexy}
  89. var
  90.   err : boolean;
  91.   ss : string[100];
  92. begin
  93.   err := false;
  94.   if id > 0 then Close_view(id);
  95.   if id_sez > 0 then Close_view(id_sez);
  96.   if Close_cursor(curmain) then Signalize;
  97.   Peek_message;
  98.   
  99.   Uninst_table(-1);
  100.   if not Write_lock_table(Tfirma) then begin
  101.     Set_cursor(1);
  102.     Enable_index(Tfirma,-1,false);                           //
  103.     if Enable_index(Tfirma,-1,true) then err := true;        //  p°ebudovßnφ index∙
  104.     Set_cursor(0);
  105.     Write_unlock_table(Tfirma);
  106.     if err then Info_box('Chyba','Chyba p°i vytvß°enφ index∙ v tabulce adres!')
  107.     else Info_box('Tabulka adres','OK');
  108.   end else Info_box('Chyba','Tabulka adres je pou₧φvßna n∞k²m jin²m,'#10'nenφ mo₧no p°ebudovat indexy');
  109.   if not Write_lock_table(Tschuzky) then begin
  110.     Set_cursor(1);
  111.     Enable_index(Tschuzky,-1,false);                           //
  112.     if Enable_index(Tschuzky,-1,true) then err := true;        //  p°ebudovßnφ index∙
  113.     Set_cursor(0);
  114.     Write_unlock_table(Tschuzky);
  115.     if err then Info_box('Chyba','Chyba p°i vytvß°enφ index∙ v tabulce sch∙zek!')
  116.     else Info_box('Tabulka sch∙zek','OK');
  117.   end else Info_box('Chyba','Tabulka sch∙zek je pou₧φvßna n∞k²m jin²m,'#10'nenφ mo₧no p°ebudovat indexy');
  118.   if vsechnysk then ss := 'SELECT * FROM Tfirma'
  119.   else ss := 'SELECT * FROM Tfirma WHERE skupina='+Int2str(skup);
  120.   if Open_sql_cursor(curmain,ss) then Signalize;
  121. end;
  122.  
  123. procedure NastavitZalohu;
  124. {**************************************}
  125. begin
  126.   Open_view('*Zaloha',-1,0,0,0,nil);
  127. end;
  128.  
  129. procedure Zaloha;
  130. {**************************************}
  131. {provede export tabulek ve vnit°nφm formßtu}
  132. var
  133.   path : string[80];
  134.   sst : string[100];
  135.   err : boolean;
  136. begin
  137.    err := false;
  138.    if YesNo_box('Export tabulek','Majφ se vyexportovat tabulky'#10' podle nastavenφ v parametrech zßlohy?') then begin
  139.      Set_status_text("Probφhß export dat, prosφm Φekejte...");
  140.      with Parametry[0] do begin
  141.        path := cesta;
  142.        if path[StrLength(path)]='\' then StrDelete(path,StrLength(path),1);
  143.        Make_directory(path);
  144.        if adresy then begin
  145.          sst := path+'\Adresy.TDT';
  146.          if not Data_export(Tfirma,categ_table,sst,0,0) then begin Signalize; err := true; end;
  147.        end;
  148.        if schuzky then begin
  149.          sst := path+'\Schuzky.TDT';
  150.          if not Data_export(Tschuzky,categ_table,sst,0,0) then begin Signalize; err := true; end;
  151.        end;
  152.        if dotazy then begin
  153.          sst := path+'\Tdotazy.TDT';
  154.          if not Data_export(Tdotazy,categ_table,sst,0,0) then begin Signalize; err := true; end;
  155.        end;
  156.        if inserty then begin
  157.          sst := path+'\Tinserty.TDT';
  158.          if not Data_export(Tinserty,categ_table,sst,0,0) then begin Signalize; err := true; end;
  159.        end;
  160.        if kategorie then begin
  161.        end;
  162.        if kategorie then begin
  163.          sst := path+'\Skupiny.TDT';
  164.          if not Data_export(Skupiny,categ_table,sst,0,0) then begin Signalize; err := true; end;
  165.        end;
  166.        if sablony then begin
  167.          sst := path+'\Tsablony.TDT';
  168.          if not Data_export(Tsablonywt,categ_table,sst,0,0) then begin Signalize; err := true; end;
  169.        end;
  170.  
  171.        // bez ptanφ
  172.        sst := path+'\Param.TDT';
  173.        if not Data_export(Parametry,categ_table,sst,0,0) then begin Signalize; err := true; end;
  174.        sst := path+'\Tool_res.TDT';
  175.        if not Data_export(Tool_res,categ_table,sst,0,0) then begin Signalize; err := true; end;
  176.  
  177.      end;  
  178.     Set_status_text("");
  179. //    Uninst_table(Parametry);
  180.     if err then Info_box('Export dat','P°i exportu doÜlo k chyb∞') 
  181.       else Info_box('Provedeno','OK');
  182.   end;  
  183. end;
  184.  
  185. procedure Obnoveni;
  186. {**************************************}
  187. {naΦte d°φve vytvo°enΘ zßlo₧nφ kopie dat}
  188. var
  189.   sst : string[100];
  190.   path : string[80];
  191.   err : boolean;
  192.   f : file;
  193.   ss : string[100];
  194. begin
  195.   if myName <> 'DB_ADMIN' then Info_box('Nelze','  Obnovenφ dat m∙₧e provΘst pouze sprßvce databßze!')
  196.   else begin
  197.     if YesNo_Box("Upozorn∞nφ","VÜechna data budou smazßna a nahrazena daty nov²mi."#10"Chcete opravdu pokraΦovat?") then begin
  198.       if id > 0 then Close_view(id);
  199.       if id_sez > 0 then Close_view(id_sez);
  200.       Close_cursor(curmain);
  201.       Set_status_text("Probφhß export dat, prosφm Φekejte...");
  202.       err := false;
  203.  
  204.       if YesNo_box('Obnovenφ','NaΦφst tabulku adres firem?') then begin
  205.         sst  := 'c:\Adresy.tdt';
  206.         if Select_file(0,sst) then begin
  207.           if Read_lock_table(Tfirma) then Info_box('Nelze','Nelze uzamknout tabulku s adresami firem.'#10'Operace neprob∞hla')
  208.           else begin
  209.             if Delete_all_records(Tfirma) then begin Signalize; err := true; end
  210.             else 
  211.               if Free_deleted(Tfirma) then begin Signalize; err := true; end
  212.               else begin
  213.                 if not Data_import("Tfirma",true,sst,0,0) then begin Signalize; err := true; end;
  214.               end;  
  215.             Read_unlock_table(Tfirma);  
  216.           end;
  217.         end;  
  218.  
  219.         StrDelete(sst,StrLength(sst)-9,10);
  220.         path := sst; 
  221.  
  222.         if YesNo_box('Obnovenφ','NaΦφst tabulku sch∙zek?') then begin
  223.           sst := path+'Schuzky.TDT ';
  224.           if Reset(f,sst) then begin
  225.             if Read_lock_table(Tschuzky) then Info_box('Nelze','Nelze uzamknout tabulku sch∙zek.'#10'Operace neprob∞hla')
  226.             else begin
  227.               if Delete_all_records(Tschuzky) then begin Signalize; err := true; end
  228.               else 
  229.                 if Free_deleted(Tschuzky) then begin Signalize; err := true; end
  230.                 else begin
  231.                   if not Data_import("Tschuzky",true,sst,0,0) then begin Signalize; err := true; end;
  232.                 end;  
  233.               Read_unlock_table(Tschuzky);  
  234.             end;
  235.             Close(f);
  236.           end else begin Info_box('Chyba','Soubor nelze otev°φt'); err := true; end;
  237.         end;
  238.  
  239.         if YesNo_box('Obnovenφ','NaΦφst tabulku dotaz∙?') then begin
  240.           sst := path+'Tdotazy.TDT ';
  241.           if Reset(f,sst) then begin
  242.             if Read_lock_table(Tdotazy) then Info_box('Nelze','Nelze uzamknout tabulku s dotazy.'#10'Operace neprob∞hla')
  243.             else begin
  244.               if Delete_all_records(Tdotazy) then begin Signalize; err := true; end
  245.               else 
  246.                 if Free_deleted(Tdotazy) then begin Signalize; err := true; end
  247.                 else begin
  248.                   if not Data_import("Tdotazy",true,sst,0,0) then begin Signalize; err := true; end;
  249.                 end;  
  250.               Read_unlock_table(Tdotazy);  
  251.             end;
  252.             Close(f);
  253.           end else begin Info_box('Chyba','Soubor nelze otev°φt'); err := true; end;
  254.         end;
  255.  
  256.         if YesNo_box('Obnovenφ','NaΦφst tabulku import∙?') then begin
  257.           sst := path+'Tinserty.TDT ';
  258.           if Reset(f,sst) then begin
  259.             if Read_lock_table(Tinserty) then Info_box('Nelze','Nelze uzamknout tabulku s importy.'#10'Operace neprob∞hla')
  260.             else begin
  261.               if Delete_all_records(Tinserty) then begin Signalize; err := true; end
  262.               else 
  263.                 if Free_deleted(Tinserty) then begin Signalize; err := true; end
  264.                 else begin
  265.                   if not Data_import("Tinserty",true,sst,0,0) then begin Signalize; err := true; end;
  266.                 end;  
  267.               Read_unlock_table(Tinserty);  
  268.             end;
  269.             Close(f);
  270.           end else begin Info_box('Chyba','Soubor nelze otev°φt'); err := true; end;
  271.         end;
  272.  
  273.         if YesNo_box('Obnovenφ','NaΦφst tabulku skupin a kategoriφ?') then begin
  274.           sst := path+'Skupiny.TDT ';
  275.           if Reset(f,sst) then begin
  276.             if Read_lock_table(Skupiny) then Info_box('Nelze','Nelze uzamknout tabulku skupin.'#10'Operace neprob∞hla')
  277.             else begin
  278.               if Delete_all_records(Skupiny) then begin Signalize; err := true; end
  279.               else 
  280.                 if Free_deleted(Skupiny) then begin Signalize; err := true; end
  281.                 else begin
  282.                   if not Data_import("Skupiny",true,sst,0,0) then begin Signalize; err := true; end;
  283.                 end;  
  284.               Read_unlock_table(Skupiny);  
  285.             end;
  286.             Close(f);
  287.           end else begin Info_box('Chyba','Soubor nelze otev°φt'); err := true; end;
  288.         end;
  289.  
  290.         if YesNo_box('Obnovenφ','NaΦφst tabulku Üablon WinTextu?') then begin
  291.           sst := path+'Tsablony.TDT ';
  292.           if Reset(f,sst) then begin
  293.             if Read_lock_table(Tsablonywt) then Info_box('Nelze','Nelze uzamknout tabulku se Üablonami.'#10'Operace neprob∞hla')
  294.             else begin
  295.               if Delete_all_records(Tsablonywt) then begin Signalize; err := true; end
  296.               else 
  297.                 if Free_deleted(Tsablonywt) then begin Signalize; err := true; end
  298.                 else begin
  299.                   if not Data_import("Tsablonywt",true,sst,0,0) then begin Signalize; err := true; end;
  300.                 end;  
  301.               Read_unlock_table(Tsablonywt);  
  302.             end;
  303.             Close(f);
  304.           end else begin Info_box('Chyba','Soubor nelze otev°φt'); err := true; end;
  305.         end;
  306.  
  307.           sst := path+'Param.TDT ';
  308.           if Reset(f,sst) then begin
  309.             if Read_lock_table(Parametry) then Info_box('Nelze','Nelze uzamknout pomocnou tabulku s parametry.'#10'Operace neprob∞hla')
  310.             else begin
  311.               if Delete_all_records(Parametry) then begin Signalize; err := true; end
  312.               else 
  313.                 if Free_deleted(Parametry) then begin Signalize; err := true; end
  314.                 else begin
  315.                   if not Data_import("Parametry",true,sst,0,0) then begin Signalize; err := true; end;
  316.                 end;  
  317.               Read_unlock_table(Parametry);  
  318.             end;
  319.             Close(f);
  320.           end else begin Info_box('Chyba','Soubor nelze otev°φt'); err := true; end;
  321.  
  322.           sst := path+'Tool_res.TDT ';
  323.           if Reset(f,sst) then begin
  324.             if Read_lock_table(Tool_res) then Info_box('Nelze','Nelze uzamknout pomocnou tabulku.'#10'Operace neprob∞hla')
  325.             else begin
  326.               if Delete_all_records(Tool_res) then begin Signalize; err := true; end
  327.               else 
  328.                 if Free_deleted(Tool_res) then begin Signalize; err := true; end
  329.                 else begin
  330.                   if not Data_import("Tool_res",true,sst,0,0) then begin Signalize; err := true; end;
  331.                 end;  
  332.               Read_unlock_table(Tool_res);  
  333.             end;
  334.             Close(f);
  335.           end else begin Info_box('Chyba','Soubor nelze otev°φt'); err := true; end;
  336.  
  337.       end;      // konec
  338.       
  339.       Set_status_text("");
  340.       if err then Info_box('Obnovenφ dat','Export neprob∞hl v po°ßdku.'#10'Zkontrolujte data!') 
  341.         else Info_box('Provedeno','OK');
  342.  
  343.       if vsechnysk then ss := 'SELECT * FROM Tfirma'
  344.       else ss := 'SELECT * FROM Tfirma WHERE skupina='+Int2str(skup);
  345.       if Open_sql_cursor(curmain,ss) then Signalize;
  346.       Open_view("*Pseznam",curmain,0,0,0, id_sez);
  347.       SetWindowText(id_sez,s4);
  348.     end;  
  349.   end;
  350. end;
  351.  
  352. procedure WT;
  353. {**************************************}
  354. {nastavenφ cest k programu WinText602}
  355. begin
  356.   Open_view("*Pwintext",no_redir,modal_view,0,0,id_wt);
  357.   repeat Peek_message until id_wt=0;
  358.   SmazatFrontu;
  359. end;
  360.  
  361. procedure Sablony;
  362. {**************************************}
  363. var
  364.   id_sab : window_id;
  365. begin
  366.   Open_view("*Psablony",no_redir,0,0,0,id_sab);  
  367.   repeat Peek_message until id_sab=0;
  368. end;
  369.  
  370. procedure SdilenyAdresar;
  371. {**************************************}
  372. var
  373.   id_sb : window_id;
  374. begin
  375. //  if myName <> 'DB_ADMIN' then Info_box('Nelze',' Nastavenφ sdφlenΘho adresß°e m∙₧e provΘst pouze sprßvce databßze!')
  376. //  else begin
  377.     Open_view("*Sabloadr",no_redir,0,0,0,id_sb);  
  378.     repeat Peek_message until id_sb=0;
  379. //  end;    
  380. end;
  381.  
  382. procedure DoplnitTexty;
  383. {**************************************}
  384. var
  385.   i : short;
  386. begin
  387.   if not vsechnysk then begin
  388.     Err_mask(true);
  389.     t[1] := Skupiny[skup].tprep1;
  390.     t[2] := Skupiny[skup].tprep2;
  391.     t[3] := Skupiny[skup].tprep3;
  392.     t[4] := Skupiny[skup].tprep4;
  393.     t[5] := Skupiny[skup].tprep5;
  394.     t[6] := Skupiny[skup].tprep6;
  395.     t[7] := Skupiny[skup].tprep7;
  396.     t[8] := Skupiny[skup].tprep8;
  397.     Err_mask(false);
  398.   end 
  399.   else begin
  400.     for i := 1 to 8 do t[i] := '';
  401.   end;
  402.   for i := 1 to 8 do
  403.      Tool_res[i+14].nazev := t[i];
  404. end;
  405.  
  406. procedure Kategorie;
  407. {**************************************}
  408. var
  409.   id_pr : window_id;
  410. begin
  411.   if myName <> 'DB_ADMIN' then Info_box('Nelze',' Nastavenφ kategoriφ m∙₧e provΘst pouze sprßvce databßze!')
  412.   else begin
  413.     if vsechnysk then begin
  414.       Info_box('Nelze','Nenφ mo₧nΘ definovat kategorie jednΘ skupiny,'#10'jsou-li vybrßny skupiny vÜechny');
  415.     end 
  416.     else begin
  417.       if id > 0 then Close_view(id);
  418.       if id_sez > 0 then Close_view(id_sez);
  419.       s3 := 'Kategorie pro skupinu: '+nazskup;
  420.       Open_view("*Pkategorie", no_redir,0,-skup,0,id_pr);       // Φφslo skupiny odpovφdß Φφslu zßznamu
  421.       SetWindowText(id_pr,s3);
  422.       repeat Peek_message until id_pr=0;
  423.       SmazatFrontu;
  424.       DoplnitTexty;
  425.     end;
  426.   end;
  427. end;
  428.  
  429. procedure VycistitKategorii(kat:short);
  430. {**************************************}
  431. var
  432.   st : string[200];
  433.   poms : string[10];
  434.   updatestr : string[200];
  435. begin
  436.   st := 'Opravdu si p°ejete, aby vÜechny zßznamy skupiny > '+nazskup+' < m∞ly '
  437.   ''#10'p°epφnaΦ oznaΦen² > '+t[kat]+' < nastaven na hodnotu Ne (False)?';
  438.   if YesNo_box('Otßzka',st) then begin
  439.     poms := 'Prep'+int2str(kat);
  440.     updatestr := 'UPDATE Tfirma SET '+poms+' = false WHERE skupina='+Int2str(skup);
  441.     if SQL_execute(updatestr) then Signalize
  442.     else Info_box('Provedeno','Operace prob∞hla ·sp∞Ün∞');
  443.   end;
  444. end;
  445.  
  446. procedure ResetCursor;
  447. {**************************************}
  448. // naplnφ pohled aktußlnφmi daty
  449. var
  450.   cz : cursor;
  451.   c1,c2 : integer;
  452.   ss : string[100];
  453.   irec, erec : integer;
  454.   cislopom : short;
  455.   unt : untyped;
  456.   idpom : window_id;
  457. begin
  458.   idpom := Active_view;
  459.   if Get_fcursor(idpom,cz,nil) then 
  460.     if Get_view_pos(idpom,irec,erec) then 
  461.       unt := cz[erec].cislo;                          // zapamatovßnφ si Φφsla firmy
  462.  
  463.     if id > 0 then Send_message(id,1599,0,0);         // odstran∞nφ p°φpadnΘho QBE dotazu
  464.     if id_sez > 0 then Send_message(id_sez,1599,0,0);
  465.  
  466.   if Close_cursor(curmain) then Signalize else begin
  467.     if vsechnysk then ss := 'SELECT * FROM Tfirma'
  468.     else ss := 'SELECT * FROM Tfirma WHERE skupina='+Int2str(skup);
  469.     if Open_sql_cursor(curmain,ss) then Signalize;
  470.   end;
  471.  
  472.   Set_fcursor(idpom,curmain,-1);               // vnucenφ novΘho obsahu
  473.   irec := Look_up(curmain,'cislo',unt);        // Üet°φm prom∞nnΘ (irec u₧ nenφ pot°eba)
  474.   if irec <> -1 then
  475.     Set_ext_pos(idpom, irec, -1);              // nastavenφ se na p∙vodnφ zßznam
  476. end;
  477.  
  478. procedure DefSkupin;
  479. {**************************************}
  480. var
  481.   id_sk : window_id;
  482. begin
  483.   if myName <> 'DB_ADMIN' then Info_box('Nelze','  Nastavenφ skupin m∙₧e provΘst pouze sprßvce databßze!')
  484.   else begin
  485.     if id > 0 then Close_view(id);
  486.     Open_view("*Skupiny", no_redir,modal_view,0,0,id_sk);
  487.     repeat Peek_message until id_sk=0;
  488.     SmazatFrontu;
  489.   end;
  490. end;  
  491.  
  492. procedure DoplnJmeno(idx : window_id; rec : integer);
  493. {**************************************}
  494. var
  495.   u : untyped;
  496.   spom : string[80];
  497.   
  498. begin
  499.   spom := Parametry[0].sablonywt+'\*.WPT';
  500.   if Select_file(idx,spom) then begin
  501.     while SubStr("\",spom) do
  502.       StrDelete(spom,1,StrPos("\",spom));
  503.     if SubStr(".",spom) then
  504.       StrDelete(spom,StrPos(".",spom),StrLength(spom)-StrPos(".",spom)+1);
  505.     u := spom;
  506.     if not Set_item_value(idx,rec,6,u) then Info_box('Chyba','Set_item_value');
  507.   end;
  508. end;
  509.  
  510. function GoodName(aplname : string[10]) : boolean;
  511. {**************************************}
  512. var
  513.   objnum : short;
  514. begin
  515.   GoodName := true;
  516.   if Find_object(aplname,CATEG_APPL, objnum) then begin
  517.     Info_box('Chyba','Takovßto aplikace v databßzi nenφ!!');
  518.     GoodName := false;
  519.   end;;
  520. end;
  521.  
  522. procedure Prenosz2x;
  523. {**************************************}
  524. var
  525.   SQLstring : string[500];
  526.   apln : string[10];
  527.   b : boolean;
  528.   ss : string[100];
  529. begin
  530. //  if myName <> 'DB_ADMIN' then Info_box('Nelze',' P°enos dat m∙₧e provΘst pouze sprßvce databßze!')
  531. //  else begin
  532.     apln := 'ADRES┴╪';
  533.     repeat
  534.       b := Input_box('JmΘno aplikace (p∙vodn∞ Adresß°)',apln,10);
  535.     until not b or GoodName(apln);
  536.  
  537.     if b then begin
  538.       if id > 0 then Close_view(id);
  539.       if id_sez > 0 then Close_view(id_sez);
  540.       if Close_cursor(curmain) then Signalize;
  541.  
  542.       SQLstring := "INSERT INTO Tfirma (SKUPINA,FIRMA,FIRMA2"
  543.          ",PRIJMENI,MUZ,FUNKCE,ULICE,MESTO,PSC,STAT,TELEFON,FAX,MAIL,ICO"
  544.          ",DIC,BANKA,POZN,PREP1,PREP2,PREP3,PREP4,PREP5,PREP6,PREP7,PREP8"
  545.          ",CISLO,VLOZIL,DATUM_VLOZ)"
  546.          "SELECT 0,FIRMA,FIRMA2,JMENO,MUZ,FUNKCE,ULICE,MESTO,PSC,STAT"
  547.          ",TELEFON,FAX,MAIL,ICO,DIC,BANKA,POZN,PREP1,PREP2,PREP3,PREP4,PREP5"
  548.          ",PREP6,PREP7,PREP8,CISLO,VLOZIL,DATUM_VLOZ"
  549.          " FROM .Tfirma";
  550.       StrInsert(apln,SQLstring,StrLength(SQLstring)-6);      //dopln∞nφ jmΘna aplikace
  551.  
  552.       if not ((Info1 > 0) and not YesNo_box('Varovßnφ','V Adresß°i jsou ji₧ n∞jakΘ zßznamy. NaΦtenφm dat se zruÜφ.'#10#10'Majφ se opravdu naΦφst data ze starÜφ verze?')) then 
  553.       begin
  554.         Set_status_text('Probφhß mazßnφ dat v souΦasnΘm Adresß°i...');
  555.         Delete_all_records(Tfirma); Free_deleted(Tfirma);
  556.         Signalize;
  557.         Delete_all_records(Tschuzky); Free_deleted(Tschuzky);
  558.         Signalize;
  559.         Set_status_text('Probφhß p°enos dat ze starΘ verze...');
  560.         Enable_index(Tfirma,-1,false);
  561.         if SQL_execute(SQLstring) then Signalize
  562.         else begin
  563.           Set_status_text('Probφhß p°ebudovßnφ index∙...');
  564.           Enable_index(Tfirma,-1,true);
  565.  
  566.           SQLstring := "INSERT INTO Tschuzky (CISLO,DAT1,DOBA1,VLOZIL,POPIS1,POPIS2,POZN1) "
  567.                        "SELECT CISLO,DAT1,DOBA1,VLOZIL,POPIS1,POPIS2,POZN1 FROM .Tschuzky";
  568.           StrInsert(apln,SQLstring,StrLength(SQLstring)-8);      //dopln∞nφ jmΘna aplikace
  569.           Set_status_text('Probφhß p°enos kontakt∙ ze starΘ verze...');
  570.           if SQL_execute(SQLstring) then Info_box('Chyba','Tabulka kontakt∙ nebyla p°enesena');
  571.  
  572.           if vsechnysk then ss := 'SELECT * FROM Tfirma'
  573.           else ss := 'SELECT * FROM Tfirma WHERE skupina='+Int2str(skup);
  574.           if Open_sql_cursor(curmain,ss) then Signalize;
  575.  
  576.           if YesNo_box('Otßzka','P°enΘst i nßzvy kategoriφ ze starΘ verze do zßkladnφ skupiny verze novΘ?') then
  577.           begin
  578.             SQLstring := 'SELECT * FROM '+apln+'.Tkategorie';
  579.             if Open_sql_cursor(cpom, SQLstring) then Signalize else begin
  580.               Skupiny[0].Tprep1 := cpom[0].Tprep1;
  581.               Skupiny[0].Tprep2 := cpom[0].Tprep2;
  582.               Skupiny[0].Tprep3 := cpom[0].Tprep3;
  583.               Skupiny[0].Tprep4 := cpom[0].Tprep4;
  584.               Skupiny[0].Tprep5 := cpom[0].Tprep5;
  585.               Skupiny[0].Tprep6 := cpom[0].Tprep6;
  586.               Skupiny[0].Tprep7 := cpom[0].Tprep7;
  587.               Skupiny[0].Tprep8 := cpom[0].Tprep8;
  588.               Close_cursor(cpom);
  589.               DoplnitTexty;
  590.             end;
  591.           end;  
  592.           Open_view("*Pseznam",curmain,0,0,0, id_sez);
  593.           SetWindowText(id_sez,s4);
  594.           Set_status_text('');
  595.           Info_box('Provedeno','OK');
  596.         end;   // neprob∞hl p°enos do Tfirma
  597.       end;   // neprovßd∞t kv∙li souΦ. obsahu
  598.     end;   // if b
  599. //  end;
  600. end;
  601.