if Active_view = id_sez then Prepnuti; // otev°enφ Pfirma na stejnΘm zßznamu
if Get_fcursor(id,cx,nil) then
if Get_view_pos(id,ic,ec) then begin
cis := cx[ec].cislo;
if cis = noneshort then Send_message(id,1603,0,0)
else begin
spom := 'SELECT * FROM Tschuzky WHERE cislo='+Int2str(cis);
if not Open_sql_cursor(ct,spom) then begin
if not Rec_cnt(ct,pocett) then begin
if pocett = 0 then begin // nejsou kontakty
Send_message(id,1603,0,0); // smazat
end
else begin
if YesNo_box('Varovßnφ','Adresu nelze smazat, proto₧e v tabulce kontakt∙ existujφ odpovφdajφcφ zßpisy.'#10'Majφ se smazat zßpisy v tabulce kontakt∙ souΦasn∞?') then
begin
if not Delete_all_records(ct) then begin
Send_message(id,1603,0,0);
end else Info_box('Cbyba','Nezda°ilo se');
end;
end;
end else Signalize;
Close_cursor(ct);
end else Signalize;
end;
end;
end;
function VymazatZKontaktu(cis : integer) : boolean;
{**************************************}
var
spom : string[60];
ct : cursor;
begin
VymazatZKontaktu := false;
spom := 'SELECT * FROM Tschuzky WHERE cislo='+Int2str(cis);
if not Open_sql_cursor(ct,spom) then begin
if Delete_all_records(ct) then Signalize else VymazatZKontaktu := true;
Close_cursor(ct);
end else Signalize;
end;
procedure SmazatVsechnyZaznamy;
{**************************************}
var
zam : boolean;
sp : string[200];
cpom : cursor;
spom : string[100];
i,pocetpom : integer;
begin
zam := false;
// if myName <> 'DB_ADMIN' then Info_box('Nelze',' Smazat vÜechna data m∙₧e provΘst pouze sprßvce databßze!')
// else begin
if vsechnysk then sp := 'Opravdu chcete vymazat z Adresß°e vÜechny firmy'#10'vÜech skupin a zßznamy o kontaktech s nimi?'
else sp := 'Opravdu chcete vymazat z Adresß°e vÜechny firmy'#10'skupiny > '+nazskup+' < a zßznamy o kontaktech s nimi?';
if YesNo_box('Varovßnφ',sp) then begin
if id > 0 then Close_view(id);
if id_sez > 0 then Close_view(id_sez);
if Close_cursor(curmain) then Signalize;
if not (Write_lock_table(Tfirma) or Write_lock_table(Tschuzky)) then begin
if vsechnysk then spom := 'SELECT * FROM Tfirma'
else spom := 'SELECT * FROM Tfirma WHERE skupina='+Int2str(skup);
if jeden = 1 then begin // zm∞na u jednoho zßznamu
if Active_view = id_sez then Prepnuti;
if (Get_view_item(id,54) = '') then PosledniCislo;
Get_view_pos(id,ic,ec);
cis := cx[ec].cislo;
Start_transaction;
cx[ec].skupina := skup;
cx[ec].prep1 := false;
cx[ec].prep2 := false;
cx[ec].prep3 := false;
cx[ec].prep4 := false;
cx[ec].prep5 := false;
cx[ec].prep6 := false;
cx[ec].prep7 := false;
cx[ec].prep8 := false;
Commit;
dotaz := 'SELECT * FROM Tfirma where skupina='+Int2str(skup);
UplatnitDotaz;
DoplnitTexty;
u := cis;
res := Look_up(curmain,'cislo',u); // zjiÜt∞nφ zßznamu s Φφslem cis
if res <> -1 then Set_ext_pos(id,res,-1);
SetWindowText(id,s2);
Reset_view(id,-1,reset_cache+reset_controls);
if id_sez>0 then SetWindowText(id_sez,s4);
end else begin // zm∞na u vÜech sejmut²ch zßznam∙
Rec_cnt(cx,pocetzaz);
if pocetzaz <> -1 then begin
for i := 0 to pocetzaz-1 do begin
Set_status_nums(i+1,pocetzaz);
Start_transaction;
cx[i].skupina := skup;
cx[i].prep1 := false;
cx[i].prep2 := false;
cx[i].prep3 := false;
cx[i].prep4 := false;
cx[i].prep5 := false;
cx[i].prep6 := false;
cx[i].prep7 := false;
cx[i].prep8 := false;
Commit;
end;
dotaz := 'SELECT * FROM Tfirma where skupina='+Int2str(skup);
UplatnitDotaz;
DoplnitTexty;
SetWindowText(id,s2);
Reset_view(id,-1,reset_cache+reset_controls);
if id_sez>0 then SetWindowText(id_sez,s4);
end;
end;
end else Info_box('Chyba','Get_fcursor');
end;
end;
end;
procedure Najit;
{**************************************}
{vyhledß zßznamy, kterΘ v sob∞ obsahujφ zadan² °et∞zec}
var
id_f,id_zal,id_vyb : window_id;
wherestr : string[200];
costr : string[30];
sel : string[300];
pstr : string[30];
begin
column := 1;
zrusitAkci := true;
Open_view('*Pfind',no_redir,modal_view,0,0,id_f);
repeat Peek_message until id_f=0;
SmazatFrontu;
if not zrusitAkci then begin
pstr := " .=."""+search+"""";
case column of
1 : begin
wherestr := 'firma'+pstr+' OR firma2'+pstr+' OR prijmeni'+pstr+' OR ulice'+pstr+' OR mesto'+pstr+' OR pozn'+pstr ;
costr := '';
end;
3 : begin
wherestr := 'firma'+pstr+' OR firma2'+pstr;
costr := 'v nßzvu firmy ';
end;
2 : begin
wherestr := 'prijmeni'+pstr;
costr := 've jmΘnu odp. pracovnφka ';
end;
4 : begin
wherestr := 'ulice'+pstr+' OR mesto'+pstr;
costr := 'v adrese firmy ';
end;
5 : begin
wherestr := 'pozn'+pstr;
costr := 'v poznßmce ';
end;
end;
sel :='SELECT * FROM Tfirma WHERE '+wherestr;
if Open_sql_cursor(cfind,sel) then Signalize;
if Rec_cnt(cfind,pocetNalez) then Signalize; // pro podmφnku aktivity v pohledu Pvybrsuper
s := 'V tabulce firem byly nalezeny tyto zßznamy obsahujφcφ '+costr+'°et∞zec '''+search+'''. TlaΦφtkem Firma si zobrazφte podrobn² popis vybranΘ firmy.';
Open_view('*pvybrsuper',no_redir,0,0,0,id_vyb);
id_subvyb := GetDlgItem(id_vyb,3);
if not Set_fcursor(id_subvyb,cfind,0) then Info_box('Chyba','Set_fcursor');
// vsechnysk := true;
end;
end;
procedure ZavritKurzor;
{**************************************}
//akce po zav°enφ pohledu Pvybrsuper
begin
Close_cursor(cfind);
end;
procedure Prepni;
{**************************************}
{tlaΦφtko v pohledu Pvybrsuper s vybran²mi zßznamy - p°epne do formulß°e na stejn² zßznam}
begin
dotaz := 'SELECT * FROM Tfirma';
vsechnysk := true;
s2 := 'VÜechny skupiny';
s4 := 'P°ehled firem vÜech skupin';
UplatnitDotaz;
DoplnitTexty;
if id=0 then begin
Open_view('*pfirma',curmain,0,0,0,id);
SetWindowText(id,s2);
end;
Synchronizace(id_subvyb,id);
if id_sez > 0 then SetWindowText(id_sez,s4);
end;
function TestDotazu(odkud : short; dot : string[255]) : boolean;