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

  1. INCLUDE
  2.  
  3. procedure NastaveniTiskarny;
  4. {**************************************}
  5. begin
  6.   Printer_dialog(0);
  7. end;
  8.  
  9. procedure KontrolaUzivSt(idpom : window_id);
  10. {**************************************}
  11. var
  12.  pozice : short;
  13. begin
  14.   if Parametry[0].velik = 10 then
  15.     if Find_object("LABELXX",categ_view,pozice) then begin
  16.      Info_box('Nenalezen navr₧en² pohled',
  17.         'Nßvrh Ütφtku se provßdφ ve v²vojovΘm prost°edφ WinBase602.'#10''
  18.         'Z aplikace nenφ mo₧no Ütφtek navrhnout.'#10#10''
  19.         'Tato volba je zde proto, aby bylo mo₧no bez velkΘ nßmahy'#10''
  20.         'doplnit aplikaci o nov² rozm∞r Ütφtku, kter² chybφ v nabφdce.'#10''
  21.         'Jak vytvo°it vlastnφ Ütφtek se doΦtete v nßpov∞d∞.');
  22.      Parametry[0].velik := 1;
  23.      Reset_view(idpom,-1,5);
  24.    end;     
  25. end;
  26.  
  27. procedure VyberStitku;
  28. {**************************************}
  29. var
  30.   id_s : window_id;
  31. begin
  32.   Open_view("*Pdefstitku",no_redir,modal_view,0,0,id_s);
  33.   repeat Peek_message until id_s=0;
  34.   SmazatFrontu;
  35.  
  36.   Err_mask(true);
  37.    labeltype := Parametry[0].typst;
  38.    labelsize := Parametry[0].velik;
  39.   Err_mask(false);
  40. end;
  41.  
  42. function NoveJmenoTabulky : string[10];
  43. {**************************************}
  44. // vytvo°φ jedineΦnΘ jmΘno pomocnΘ tabulky _tmpx
  45. var
  46.   tabname : string[10];
  47.   objnum : short;
  48.   i : short;
  49. begin
  50.   i := 0;
  51.   tabname := '_tmp0';
  52.   if not Find_object(tabname, categ_table, objnum) then
  53.   repeat   //tak dlouho, dokud jeÜt∞ neexistuje (pro p°φpad, ₧e souΦasn∞ tiskne vφc lidφ)
  54.     i := i+1;
  55.     tabname := StrCopy(tabname,1,4)+Int2Str(i);
  56.   until Find_object(tabname, categ_table, objnum);
  57.   NoveJmenoTabulky := tabname;
  58. end;
  59.  
  60. function NovaTabulka : string[10];
  61. {**************************************}
  62. // vytvo°φ pomocnou tabulku pro kopii dat pro tisk
  63. // pokud se to nepovede, vrßtφ jmΘno tabulky, jinak prßzdn² string
  64. var
  65.   tabname : string[10];
  66.   SQL_stat : string[1000];
  67.   pomstr : string[30];
  68. begin
  69.   tabname := NoveJmenoTabulky;
  70.   SQL_stat := ' ( CISLO SMALLINT, '
  71.     'FIRMA CHAR(50) COLLATE CSISTRING, '
  72.     'FIRMA2 CHAR(50) COLLATE CSISTRING, '
  73.     'JMENO CHAR(20) COLLATE CSISTRING, '
  74.     'PRIJMENI CHAR(20) COLLATE CSISTRING, '
  75.     'TITUL CHAR(10) COLLATE CSISTRING, '
  76.     'FUNKCE CHAR(50) COLLATE CSISTRING, '
  77.     'MUZ BIT, '
  78.     'ULICE CHAR(50) COLLATE CSISTRING, '
  79.     'MESTO CHAR(50) COLLATE CSISTRING, '
  80.     'PSC CHAR(6), '
  81.     'STAT CHAR(30), '
  82.     'TELEFON CHAR(20) PREALLOC 5 COLLATE CSISTRING, '
  83.     'FAX CHAR(20) PREALLOC 5 COLLATE CSISTRING )';
  84.   pomstr := 'CREATE TABLE '+ tabname; 
  85.   StrInsert(pomstr,SQL_stat,1);
  86.  
  87.   if SQL_execute(SQL_stat) then begin 
  88.     Signalize;
  89.     NovaTabulka := "";
  90.   end else NovaTabulka := tabname;  
  91. end;
  92.  
  93. procedure Smazat(co : string[10]);
  94. {**************************************}
  95. //sma₧e tabulku
  96. var
  97.   SQL_str : string[100];
  98. begin
  99.   SQL_str :='DROP TABLE '+co;
  100.   if SQL_execute(SQL_str) then Signalize;
  101.   SIgnalize;
  102. end;
  103.  
  104. procedure Tisk2x(idx : window_id);
  105. {**************************************}
  106. //tisk Ütφtk∙ firem tlaΦφtkem z pohledu Seznam2Tis  (p°i editTisk=true)
  107. var
  108.   cf : cursor;
  109.   i,j,pocet,icislo : integer;
  110.   strpom : string[40];
  111. begin
  112.   Close_cursor(curtisk);
  113.   strpom := 'SELECT * FROM '+tabul+' WHERE false';
  114.   if Open_sql_cursor(curtisk, strpom) then Signalize;
  115.   
  116.   if Get_fcursor(idx,cf,nil) then begin
  117.     for i := 1 to kolikpred do        // prßzdnß mφsta p°ed tiskem prvnφho
  118.       Insert(curtisk);
  119.     Rec_cnt(cf,pocet);
  120.     for i := 0 to pocet-1 do begin
  121.       Translate(cf, i, 0, icislo);    // p°epoΦet na Φφslo v tabulce _tmpx
  122.       if icislo <> -1 then
  123.         for j := 1 to kolikrat do            
  124.           Add_record(curtisk,icislo,1);      // p°idßnφ zßznamu do kurzoru curtisk 
  125.     end;
  126.     Print_view(labelname,curtisk,-1,-1);
  127.   end;
  128. end;
  129.  
  130. procedure Tiskx(idx : window_id);                 
  131. {**************************************}
  132. //tisk seznamu firem tlaΦφtkem z pohledu SeznamTisk   (p°i editTisk=true)
  133. begin
  134.   if Get_fcursor(idx,curtisk,nil) then begin
  135.      Set_printer(0,99999,1,99999,preview,"",10);
  136.      Print_margins(0,5,10,10);
  137.      Print_copies(kolikrat,true);
  138.      Print_view("*Ptseznam",curtisk,-1,-1);
  139.   end else Signalize;
  140. end;  
  141.  
  142. procedure TiskSeznamu;
  143. {**************************************}
  144. var
  145.   id_kol : window_id;
  146.   id_pom : window_id;
  147.   pocetx,i,j,rec : integer;
  148.   spom : string[30];
  149.   id_seztisk : window_id;
  150.   sss : string[30];
  151.   idx,idx2 : window_id;
  152.   res : integer;
  153.  
  154. begin 
  155.   Open_view("*Pkolik2",no_redir,modal_view,0,0,id_kol);
  156.   repeat Peek_message until id_kol=0;
  157.   SmazatFrontu;
  158.  
  159.   if not zrusitAkci then begin
  160.  
  161.     id_pom := Active_view;
  162.     if id_pom <> 0 then begin
  163.       Get_fcursor(id_pom, cx, nil);     //sejmutφ kurzoru z obrazovky, m∙₧e b²t zm∞n∞n dφky QBE
  164.     end else cx := curmain;             //nenφ otev°en pohled do dat
  165.     Rec_cnt(cx, pocetx);
  166.     Signalize;
  167.     
  168.     if editTisk then begin                            // bude se vytvß°et pomocnß tabulka, aby v nφ Ülo editovat
  169.       Set_cursor(1);
  170.       Set_status_text('Vytvß°φ se kopie tabulky...');
  171.       tabul := NovaTabulka;
  172.       if tabul = "" then Info_box('Chyba','Nepoda°ilo se vytvo°it pomocnou tabulku.'#10'Tisk je zruÜen.')
  173.       else begin
  174.         spom := 'SELECT * FROM '+tabul;
  175.         if not Open_sql_cursor(cpom,spom) then begin
  176.   
  177.           Set_status_text('Probφhß p°enos zßznam∙ do kopie tabulky...');
  178.           for i := 0 to Pocetx-1 do begin
  179.             Set_cursor(1);
  180.             Set_status_nums(i+1,Pocetx);
  181.             Translate(cx,i,0,res);
  182.             if res <> -1 then begin          // zßznam v kurzoru nebyl zruÜen
  183.               Start_transaction;
  184.               rec := Insert(cpom);
  185.               if rec <> -1 then begin
  186.                 cpom[rec].titul   := cx[i].titul;
  187.                 cpom[rec].prijmeni := cx[i].prijmeni;
  188.                 cpom[rec].jmeno   :=  cx[i].jmeno; 
  189.                 cpom[rec].cislo   := cx[i].cislo;
  190.                 cpom[rec].firma   := cx[i].firma;
  191.                 cpom[rec].firma2  := cx[i].firma2;
  192.                 cpom[rec].funkce  := cx[i].funkce;
  193.                 cpom[rec].muz     := cx[i].muz;
  194.                 cpom[rec].ulice   := cx[i].ulice;
  195.                 cpom[rec].mesto   := cx[i].mesto;
  196.                 cpom[rec].psc     := cx[i].psc;
  197.                 cpom[rec].stat    := cx[i].stat;
  198.                 for j := 0 to 4 do
  199.                   cpom[rec].telefon[j] := cx[i].telefon[j];
  200.                 for j := 0 to 4 do
  201.                   cpom[rec].fax[j] := cx[i].fax[j];
  202.                 Commit;
  203.               end
  204.             end;
  205.           end;
  206.     
  207.           Open_view('*SeznamTisk',cpom,0,0,0,id_seztisk);       // tisk prob∞hne v procedu°e volanΘ tlaΦφtkem
  208.           repeat Peek_message until id_seztisk=0;
  209.   
  210.         end; //neotev°el se kurzor
  211.         Close_cursor(cpom);
  212.         Smazat(tabul);                                          // sma₧e se pomocnß tabulka
  213.       end; //nevytvo°ila se tabulka  
  214.     end                            
  215.     else begin                                        // tisk rovnou, bez ·pravy  (editTisk=false)
  216.       Set_printer(0,99999,1,99999,preview,"",0);
  217.       Print_margins(0,5,10,10);
  218.       Print_copies(kolikrat,true);
  219.       Print_view("*Ptseznam",cx,-1,-1);               // tiskne se kurzor cx sejmut² Get_fcursor
  220.     
  221.     end;
  222.     Set_status_text('');
  223.     Set_status_nums(-1,-1);
  224.                                    
  225.   end; //zrusitAkci
  226. end;
  227.  
  228. procedure TiskStitku(cislo : integer);
  229. {**************************************}
  230. {cislo=-1 : tisk vÜech vybran²ch zßznam∙, }
  231. {cislo >0 : tisk jednoho Ütφtku}
  232. var
  233.   id_kol : window_id;
  234.   s : string[20];
  235.   idp : window_id;
  236.   id_pom : window_id;
  237.   fx : short;
  238.   pocetx,i,j,rec : integer;
  239.   spom : string[30];
  240.   id_seztisk : window_id;
  241.   icislo : integer;
  242.   cx : cursor;
  243.   strpom : string[40];
  244.   res : integer;
  245.  
  246. begin
  247.   zrusitAkci := true;
  248.   pomocny := cislo=-1?true: false;  // pro podmφnku aktivity v pohledu Pkolik
  249.   Open_view("*Pkolik",no_redir,modal_view,0,0,id_kol);
  250.   repeat Peek_message until id_kol=0;
  251.   SmazatFrontu;
  252.  
  253.   if not zrusitAkci then begin
  254.     if labeltype = 3 then begin
  255.          osloveni1 := "Vß₧en² pan ";
  256.          osloveni2 := "Vß₧enß panφ ";
  257.     end;
  258.     if labelsize = 10 then labelname := "*LABELXX"   // u₧ivatelem definovan² Ütφtek
  259.     else labelname := "*LABEL"+int2str(labeltype)+int2str(labelsize);  
  260.     Set_printer(0,99999,str_od,str_do,preview,"",0);
  261.     Print_margins(0,0,0,0);
  262.  
  263.     if cislo > -1 then begin                                         // tisk Ütφtk∙ jednΘ firmy tlaΦφtkem
  264.       if not Get_fcursor(Active_view,cx,nil) then Info_box('Chyba','Get_fcursor')
  265.       else begin
  266.         if not Open_sql_cursor(curtisk,'SELECT * FROM Tfirma WHERE false') then begin
  267.           for j := 0 to kolikpred-1 do
  268.             Insert(curtisk);
  269.           Translate(cx,cislo,0,icislo);   
  270.           for j := 1 to kolikrat do            
  271.             Add_record(curtisk,icislo,1);
  272.         end;  
  273.         Print_view(labelname,curtisk,-1,-1);
  274.         Close_cursor(curtisk);
  275.       end;
  276.     end else begin                                                  // tisk mno₧iny Ütφtk∙
  277.  
  278.       id_pom := Active_view;
  279.       if id_pom <> 0 then begin
  280.           Get_fcursor(id_pom, cx, fx);      // sejmutφ kurzoru z obrazovky, m∙₧e b²t zm∞n∞n dφky QBE
  281.       end else cx := curmain;               // nenφ otev°en pohled do dat
  282.        
  283.       if editTisk then begin                  // bude se vytvß°et pomocnß tabulka, aby v nφ Ülo editovat
  284.         Set_cursor(1);
  285.         Set_status_text('Vytvß°φ se kopie tabulky...');
  286.         tabul := NovaTabulka;
  287.         if tabul = "" then Info_box('Chyba','Nepoda°ilo se vytvo°it pomocnou tabulku.'#10'Tisk je zruÜen.')
  288.         else begin
  289.           spom := 'SELECT * FROM '+tabul;
  290.           if not Open_sql_cursor(cpom,spom) then begin
  291.      
  292.             Rec_cnt(cx, pocetx);
  293.             Set_status_text('Probφhß p°enos zßznam∙ do kopie tabulky...');
  294.             for i := 0 to Pocetx-1 do begin
  295.               Set_cursor(1);
  296.               Set_status_nums(i+1,Pocetx);
  297.               Translate(cx,i,0,res);
  298.               if res <> -1 then begin          // zßznam v kurzoru nebyl zruÜen
  299.                 rec := Insert(cpom);
  300.                 if rec <> -1 then begin
  301.                   Start_transaction;
  302.                   cpom[rec].titul   := cx[i].titul;
  303.                   cpom[rec].prijmeni := cx[i].prijmeni;
  304.                   cpom[rec].jmeno   :=  cx[i].jmeno; 
  305.                   cpom[rec].cislo   := cx[i].cislo;
  306.                   cpom[rec].firma   := cx[i].firma;
  307.                   cpom[rec].firma2  := cx[i].firma2;
  308.                   cpom[rec].muz     := cx[i].muz;
  309.                   cpom[rec].ulice   := cx[i].ulice;
  310.                   cpom[rec].mesto   := cx[i].mesto;
  311.                   cpom[rec].psc     := cx[i].psc;
  312.                   cpom[rec].stat    := cx[i].stat;
  313.                   Commit;
  314.                 end
  315.               end;
  316.             end;
  317.                  
  318.             strpom := 'SELECT * FROM '+tabul+' WHERE false';
  319.             if not Open_sql_cursor(curtisk, strpom) then begin
  320.               Open_view('*Seznam2Tis',cpom,0,0,0,id_seztisk);       // tisk se zavolß v procedu°e volanΘ tlaΦφtkem z pohledu
  321.               repeat Peek_message until id_seztisk=0;
  322.               Close_cursor(curtisk);
  323.             end;    // open cursor curtisk
  324.             Close_cursor(cpom);
  325.           end;      // open cursor cpom
  326.           Smazat(tabul);
  327.         end;        // nevytvo°ila se tabulka  
  328.       end
  329.       else begin               // tisk rovnou, bez ·pravy  (editTisk=false)
  330.  
  331.         strpom := 'SELECT * FROM TFirma WHERE false';
  332.         if not Open_sql_cursor(curtisk, strpom) then begin
  333.  
  334.           for i := 1 to kolikpred do        // prßzdnß mφsta p°ed tiskem prvnφho
  335.             Insert(curtisk);
  336.           Rec_cnt(cx,pocetx);
  337.           for i := 0 to pocetx-1 do begin
  338.             Translate(cx, i, 0, icislo);      // p°epoΦet na Φφslo v tabulce _tmpx
  339.             if icislo <> -1 then
  340.               for j := 1 to kolikrat do            
  341.                 Add_record(curtisk,icislo,1);   // p°idßnφ zßznamu do kurzoru curtisk, aby byly kopie Ütφtk∙ za sebou 
  342.           end;
  343.           Print_view(labelname,curtisk,-1,-1);
  344.           Close_cursor(curtisk);
  345.         end;        // open cursor curtisk
  346.       end;
  347.     end;          // tisk mno₧iny Ütφtk∙
  348.     Set_status_text('');
  349.     Set_status_nums(-1,-1);
  350.   end;  
  351. end;
  352.  
  353.  
  354.