home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2001 July
/
PCWorld_2001-07_cd.bin
/
Software
/
Komercni
/
software602
/
cnv_ifp.exe
/
I_IMPEX0.PGM
< prev
next >
Wrap
Text File
|
2001-02-12
|
9KB
|
268 lines
{$$3249893653 . }include
var
impexp_path : string[256];
impexp_tabname : string[256];
function ImpExp_ExpAllExternal;
begin
ImpExp_ExExpAllExternal(path, Current_application);
end;
function ImpExp_ExExpAllExternal;
var
curs : cursor;
err : boolean;
i : integer;
recnum : trecnum;
tabname : string[62];
tabname2 : string[31];
filename : string[254];
statustext : string[254];
sqlstat : string[254];
begin
Set_cursor(1);
sqlstat := "DELETE FROM _export_tables";
if SQL_execute(sqlstat) then Signalize;
sqlstat := "SELECT Tab_name FROM Tabtab WHERE Tab_name<>""_export_tables"" AND Apl_uuid=(SELECT Apl_uuid FROM Objtab WHERE Obj_name="""+app_name+""" AND Category=chr(CATEG_APPL))";
if Open_SQL_cursor(curs, sqlstat) then
begin
Signalize;
ImpExp_ExExpAllExternal := false
end
else
begin
Rec_cnt(curs,recnum);
ProgressInit((recnum+1)*2,"Exportuji databßzi...","");
Set_cursor(1);
i := 0; err := false;
while ((i<recnum) and not err) do begin
tabname := curs[i].tab_name;
tabname2 := app_name+"."+tabname;
if path[StrLength(path)]<>"\" then path := path+"\";
filename := path+tabname+".tdt";
Upcase(tabname);
Set_cursor(1);
statustext := "Uvol≥uji zßznamy v tabulce "+tabname+". Prosφm, Φekejte...";
Set_status_text(statustext);
ProgressStep("Exportuji databßzi...",statustext);
sqlstat := "CALL Free_deleted("""+tabname2+""")";
if Sql_execute(sqlstat) then
begin
Set_cursor(0);
MessageBox(nil, "Nastala chyba p°i uvol≥ovßnφ zßznam∙. Lze vÜak pokraΦovat.", "Chyba!", mb_ok+mb_stop);
end;
statustext := "Exportuji tabulku "+tabname2+" do souboru "+filename+". Prosφm, Φekejte...";
Set_status_text(statustext);
ProgressStep("Exportuji databßzi...",statustext);
Set_cursor(1);
if not Move_data(-1,tabname2,-1,filename,10,0,-1,-1,true) then
begin
Set_cursor(0);
if MessageBox(nil, "P°i exportu nastala chyba. P°ejete si v exportu"#13#10"p°esto pokraΦovat dßle?", "Chyba!", mb_yes_no+mb_stop) = 6 then
err := false
else
err := true;
end
else
begin
impexp_tabname := tabname;
sqlstat :="INSERT INTO _export_tables (tabname) VALUES (:<impexp_tabname)";
SQL_execute(sqlstat);
end;
i := i+1;
end;
close_cursor(curs);
if not err then begin
filename := path+"_export_tables.tdt";
// uvoln∞nφ zßznam∙ v _export_tables
Set_cursor(1);
statustext := "Uvol≥uji zßznamy v tabulce _EXPORT_TABLES. Prosφm, Φekejte...";
Set_status_text(statustext);
ProgressStep("Exportuji databßzi...",statustext);
sqlstat := "CALL Free_deleted(""_EXPORT_TABLES"")";
if Sql_execute(sqlstat) then
begin
Set_cursor(0);
MessageBox(nil, "Nastala chyba p°i uvol≥ovßnφ zßznam∙. Lze vÜak pokraΦovat.", "Chyba!", mb_ok+mb_stop);
end;
Set_cursor(1);
statustext := "Exportuji tabulku _EXPORT_TABLES do souboru "+filename+". Prosφm, Φekejte...";
Set_status_text(statustext);
ProgressStep("Exportuji databßzi...",statustext);
err := not Move_data(-1,"_export_tables",-1,filename,10,0,-1,-1,true);
end;
Set_status_text("");
ProgressDone;
Set_cursor(0);
if not err then ImpExp_ExExpAllExternal := true
else ImpExp_ExExpAllExternal := false
end;
end;
function ImpExp_ImpAllExternal;
begin
ImpExp_ExImpAllExternal(path, Current_application);
end;
function ImpExp_ExImpAllExternal;
var
curs : cursor;
err : boolean;
i : integer;
recnum : trecnum;
tabname : string[31];
filename : string[254];
statustext : string[254];
sqlstat : string[254];
infotext : string[255];
begin
err := false;
Set_cursor(1);
#sqlbegin
DELETE FROM _export_tables
#sqlend
sqlstat := "CALL Free_deleted (""_EXPORT_TABLES"")";
statustext := "Uvol≥uji zruÜenΘ zßznamy z tabulky _EXPORT_TABLES. Prosφm, Φekejte...";
Set_status_text(statustext);
if SQL_execute(sqlstat) then
begin
Set_cursor(0);
MessageBox(nil, "Nastala chyba p°i uvol≥ovßnφ zßznam∙. Lze vÜak pokraΦovat.", "Chyba!", mb_ok+mb_stop);
end;
Set_cursor(1);
if path[StrLength(path)]<>"\" then path := path+"\";
filename := path+"_export_tables.tdt";
statustext := "Importuji tabulku _export_tables.tdt ze souboru "+filename+". Prosφm, Φekejte...";
Set_status_text(statustext);
if Move_data(-1,filename,-1,"_export_tables",0,10,-1,-1,true) then
begin
#sqlbegin
FOR row AS curs SENSITIVE CURSOR FOR
SELECT * FROM _export_tables
DO
UPDATE _export_tables SET _order=Ri_impexporder(row.tabname) WHERE tabname=row.tabname;
END FOR;
#sqlend
if Open_SQL_cursor(curs,"SELECT * FROM _export_tables WHERE tabname<>""_export_tables"" ORDER BY `_order`") then
begin
Signalize;
err := true;
end
else
begin
rec_cnt(curs,recnum);
ProgressInit(recnum*3,"Importuji databßzi...","");
// smazat obsah vÜech indexovan²ch tabulek
i := 0;
while ((i<recnum) and (not err)) do
begin
tabname := curs[i].tabname;
sqlstat := "DELETE FROM `"+tabname+"`";
statustext := "Ma₧u obsah tabulky "+tabname+". Prosφm, Φekejte...";
ProgressStep("Importuji databßzi...",statustext);
Set_status_text(statustext);
if SQL_execute(sqlstat) then
begin
Signalize;
err := true;
end
else
begin
sqlstat := "CALL Free_deleted ("""+tabname+""")";
statustext := "Uvol≥uji zruÜenΘ zßznamy z tabulky "+tabname+". Prosφm, Φekejte...";
ProgressStep("Importuji databßzi...",statustext);
Set_status_text(statustext);
if SQL_execute(sqlstat) then
begin
Set_cursor(0);
MessageBox(nil, "Nastala chyba p°i uvol≥ovßnφ zßznam∙. Lze vÜak pokraΦovat.", "Chyba!", mb_ok+mb_stop);
end;
end;
i := i+1;
end;
Set_cursor(1);
i := 0;
while ((i<recnum) and (not err)) do
begin
tabname := curs[i].tabname;
filename := path+tabname+".tdt";
statustext := "Importuji tabulku "+tabname+" ze souboru "+filename+". Prosφm, Φekejte...";
ProgressStep("Importuji databßzi...",statustext);
Set_status_text(statustext);
if not Move_data(-1,filename,-1,tabname,0,10,-1,-1,true) then
begin
err := true;
infotext := "Nastala chyba p°i importu tabulky "+tabname+" ze souboru "+filename+".";
MessageBox(nil, infotext, "Chyba!", mb_ok+mb_stop);
end;
i := i+1;
end;
close_cursor(curs);
end;
end
else
err := true;
ProgressDone;
Set_status_text("");
Set_cursor(0);
if not err then ImpExp_ExImpAllExternal := true
else
ImpExp_ExImpAllExternal := false
end;
procedure ImpExp_AImpExp;
begin
impexp_path := path;
Vi_089.OPEN(nil);
end;
procedure ImpExpSelectDir;
var
dirname : string[255];
begin
dirname := Vi_089.EDIT5.VALUE;
if Select_directory(Vi_089.HANDLE, dirname) then
Vi_089.EDIT5.VALUE := dirname;
end;
procedure ImpExp_ImpExecute;
begin
if MessageBox(nil, "VÜechna souΦasnß data budou zruÜena. Opravdu si"#13#10"p°ejete provΘst import?", "Dotaz", mb_yes_no+mb_quest) = 6 then begin
Vi_089.CLOSE;
ImpExp_ImpAllExternal(impexp_path);
MessageBox(nil, "Provedeno.", "Info", mb_ok+mb_info);
end;
end;
procedure ImpExp_ExpExecute;
begin
if MessageBox(nil, "Opravdu si p°ejete provΘst export databßze?", "Dotaz", mb_yes_no+mb_quest) = 6 then begin
Vi_089.CLOSE;
ImpExp_ExpAllExternal(impexp_path);
MessageBox(nil, "Provedeno.", "Info", mb_ok+mb_info);
end;
end;
function ImpExp_GetLastDir;
begin
ImpExp_GetLastDir := impexp_path;
end;