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

  1. include
  2.  
  3. procedure VlozeniSch(id2 : window_id);
  4. {*******************************************}
  5. {vlo₧enφ novΘho zßpisu o kontaktu - tlaΦφtko OK v pohledu SchNew }
  6. begin
  7.   if Commit_view(id2,false,true) then begin
  8.     Close_view(id2);
  9.     if not Set_ext_pos(idsch,cislof-1,-1) then Set_ext_pos(idsch,cislof+1,-1);
  10.     Set_ext_pos(idsch,cislof,-1);
  11.   end;
  12. end;
  13.  
  14. procedure EditSch(id2 : window_id);
  15. {*******************************************}
  16. {tlaΦφtko v pohledu SchSuper}
  17. var
  18.   idsubs : window_id;
  19.   ct,ic,ec : integer;
  20.   cx : cursor;
  21.   vlozname : CSIstring[10];
  22.  pocetx : integer;
  23. begin
  24.   idsubs := GetDlgItem(id2,10);
  25.   Get_view_pos(idsubs,ic,ec);
  26.   if ec <> -1 then begin
  27.     Get_fcursor(idsubs,cx,nil);
  28.     Translate(cx,ec,0,ct);
  29.     vlozname := Tschuzky[ct].vlozil;
  30.     if (myName=vlozname) or (myName='DB_ADMIN') or (vlozname='') then
  31.       Open_view('*Schedit',no_redir,modal_view,-ct,0,nil) 
  32.     else
  33.       Open_view('*Schedit',no_redir,modal_view+no_edit,-ct,0,nil); 
  34.   end;  
  35. end;
  36.  
  37. procedure VlozitOpravu(id2 : window_id);
  38. {*******************************************}
  39. {tlaΦφtko OK v pohledu SchEdit}
  40. begin
  41.   if Commit_view(id2,false,true) then begin
  42.     Close_view(id2);
  43.     if not Set_ext_pos(idsch,cislof-1,-1) then Set_ext_pos(idsch,cislof+1,-1);
  44.     Set_ext_pos(idsch,cislof,-1);
  45.   end;
  46. end;
  47.  
  48. procedure SmazatSCh(id2 : window_id);
  49. {*******************************************}
  50. {tlaΦφtko Smazat v pohledu SchEdit}
  51. var
  52.   i : integer;
  53. begin
  54.   i := Send_message(id2,1603,0,0);
  55.   Close_view(id2);
  56.   if not Set_ext_pos(idsch,cislof-1,-1) then Set_ext_pos(idsch,cislof+1,-1);
  57.   Set_ext_pos(idsch,cislof,-1);
  58. end;
  59.   
  60. procedure NovyZapis(cis : short);
  61. {*******************************************}
  62. {vytvo°enφ novΘho zßpisu o kontaktu - tlaΦ. Vlo₧it nov² v pohledu SchSuper}
  63. var
  64.   idns : window_id;
  65. begin
  66.   pomocglob := cis;      // impl.hodnota pohledu Schnew
  67.   Open_view('*Schnew',no_redir,modal_view,0,0,idns);
  68. end;
  69.  
  70. function TestVlozeni(idv : window_id) : boolean;
  71. {*******************************************}
  72. var
  73.   cxv : cursor;
  74.   vlozname : CSIstring[10];
  75.   i,pocetc : integer;
  76.   
  77. begin
  78.   if myName = 'DB_ADMIN' then TestVlozeni := true
  79.   else begin
  80.     if not Get_fcursor(idv,cxv,nil) then Info_box('','');
  81.     if Rec_cnt(cxv,pocetc) then begin
  82.       Signalize;   
  83.       TestVlozeni := false;
  84.     end
  85.     else begin        
  86.       TestVlozeni := true;
  87.       for i := 0 to pocetc-1 do begin
  88.         vlozname := cxv[i].vlozil;
  89.         if (myName <> vlozname) and (vlozname <> '') then TestVlozeni := false;
  90.       end;
  91.     end;
  92.   end;  
  93. end;
  94.  
  95. procedure SmazatVse(fir : string[50]; cis : short);
  96. {*******************************************}
  97. var
  98.   sstr : string[120];
  99.   sqldel : string[50];
  100.   idsubs : window_id;
  101.   ic,ec : integer;
  102. begin
  103.   idsubs := GetDlgItem(idsch,10);
  104.   Get_view_pos(idsubs,ic,ec);
  105.   if ec <> -1 then begin      // jsou tam n∞jakΘ zßpisy
  106.     sstr := ' Opravdu chcete smazat vÜechny zßpisy'#10' o kontaktech s firmou '+fir+'?';
  107.     if YesNo_box('Varovßnφ',sstr) then begin
  108.       if TestVlozeni(idsubs) then begin
  109.         sqldel := 'DELETE from Tschuzky WHERE cislo='+Int2str(cis);
  110.         if SQL_execute(sqldel) then Signalize;
  111.         if not Set_ext_pos(idsch,cislof-1,-1) then Set_ext_pos(idsch,cislof+1,-1);
  112.         Set_ext_pos(idsch,cislof,-1);
  113.       end else begin
  114.         Info_box('Nelze','N∞kterΘ zßpisy nemßte prßvo smazat.');
  115.       end;
  116.     end;
  117.   end;
  118. end;
  119.  
  120. procedure Schuzky(idf : window_id; rec : integer);
  121. {*******************************************}
  122. {tlaΦφtko v pohledu Pfirma - otev°enφ pohledu na stejn² zßznam}
  123. var
  124.   cx : cursor;
  125. begin
  126. //  pomrec := rec;                        // uschovßnφ pro pozd∞jÜφ p°ekreslenφ Pfirma
  127.   if Get_fcursor(idf,cx,nil) then
  128.     if not Translate(cx,rec,0,cislof) then
  129.       Open_view('*Schsuper',no_redir,0,-cislof,0,idsch);
  130. end;
  131.  
  132. procedure Detail(idf : window_id; rec : integer);
  133. {*******************************************}
  134. {tlaΦφtko v pohledu PrehledSch - otev°enφ pohledu na stejn² zßznam}
  135. var
  136.   cx : cursor;
  137. begin
  138.   if Get_fcursor(idf,cx,nil) then
  139.     if not Translate(cx,rec,1,cislof) then begin
  140.       if id=0 then Open_view('*Pfirma',no_redir,0,-cislof,0,idsch)
  141.       else begin
  142.         Set_ext_pos(id, cislof, -1);
  143.         Pick_window(id);
  144.       end;  
  145.     end;
  146. end;
  147.  
  148. procedure PrehledKontaktu;
  149. {*******************************************}
  150. var
  151.   strpom : string[200];
  152. begin
  153.    if id_prsch = 0 then begin
  154.      strpom := 'SELECT * FROM Tschuzky, Tfirma WHERE (Tfirma.SKUPINA='+Int2str(skup)+') AND (Tfirma.CISLO=Tschuzky.CISLO) ORDER BY Tschuzky.dat1';
  155.      if Open_sql_cursor(ckontakty,strpom) then Signalize
  156.      else begin
  157.        Open_view('*PrehledSup',ckontakty,0,0,0,id_prsch);
  158.      end;
  159.    end else Pick_window(id_prsch);  
  160. end;  
  161.  
  162. procedure ZavritKurzorKont;
  163. {*******************************************}
  164. begin
  165.   Close_cursor(ckontakty);
  166. end;
  167.