home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sw602 / wintext / disk1 / data.1 / budsml.txt < prev    next >
Text File  |  1997-03-12  |  9KB  |  291 lines

  1. program Smlouva_budoucφ;
  2.  
  3. const
  4.   { dialog Wizard : }
  5.   ID_BMP             = 1001;
  6.   ID_BACK            = 1002;
  7.   ID_NEXT            = 1003;
  8.   ID_DLG_ID          = 1004;
  9.   ID_CHECK_NOPRINT   = 1005;
  10.  
  11.   STRLEN             = 250;
  12.  
  13.   DLG_COUNT          =  4;
  14.   ITEM_COUNT         = 13;
  15.  
  16.   DLG_CAPTION        = "Smlouva o uzav°enφ smlouvy budoucφ";
  17.  
  18.  
  19. type
  20.   strTxt = string[100];
  21.   strPath = string[255];
  22.  
  23.  
  24. var
  25.   iResult, iDlg, i : short;
  26.   s : string[STRLEN];
  27.   d : date;
  28.   bKonec, bExit : boolean;
  29.   szBmpFile : string[255];
  30.  
  31.   dlg : array[1..DLG_COUNT] of short;         // id dialog∙
  32.   dlgItems : array[1..DLG_COUNT] of short;    // poΦet polo₧ek v jedn. dialozφch
  33.   szItem, szMark : array[1..ITEM_COUNT] of string[STRLEN];  // vstupnφ texty, zßlo₧ky
  34.   id : array[1..ITEM_COUNT] of short;         // id polo₧ek
  35.  
  36.   szQuestEnd, szCheckPrint : strTxt;
  37.  
  38.  
  39. function WritePrivateProfileString (
  40.   var szSection : strTxt;
  41.   var szEntry : const strTxt;
  42.   var szString : const strTxt;
  43.   var szFilename : strPath ) : short;
  44.     external 'KERNEL32.DLL' name 'WritePrivateProfileStringA';
  45.  
  46. function GetPrivateProfileString (
  47.   var szSection : strTxt;
  48.   var szEntry : strTxt;
  49.   var szDefault : const strTxt;
  50.   var szReturnBuffer : const strTxt;
  51.   cbReturnBuffer : integer;
  52.   var szFilename : strPath ) : integer;
  53.     external 'KERNEL32.DLL' name 'GetPrivateProfileStringA';
  54.  
  55.  
  56.  
  57. procedure GetPath_Macro(
  58.   var s : strPath );
  59. var
  60.   bOk, bFirst : boolean;
  61.   i : short;
  62. begin
  63.   bOk := false; bFirst := false;
  64.   s := ExeFileName;
  65.   i := Strlength(s);
  66.   while not(bOk) do begin
  67.     bOk := (bFirst = true) and (s[i] = '\');
  68.     if (!bOk) then begin
  69.       if (!bFirst) then bFirst := (s[i] = '\');
  70.       dec(i);
  71.       bOk := i = 0;
  72.     end;
  73.   end;
  74.   s := StrCopy(s, 1, i);
  75.   s := s + 'Makra\';
  76. end;
  77.  
  78.  
  79. function GetDlgID(
  80.   i : short ) : strTxt;
  81. var s : strTxt;
  82. begin
  83.   s := "Dialog:  " + int2str(i) + " ze " + int2str(DLG_COUNT);
  84.   GetDlgID := s;
  85. end;
  86.  
  87.  
  88. procedure Init;
  89. var
  90.   i, v : short;
  91.   szPath : strPath;
  92.   s, szSection, szEntry : strTxt;
  93. begin
  94.   GetPath_Macro(szPath);
  95.   szBmpFile := szPath + "paragraf.bmp";
  96.  
  97.   for i:=1 to ITEM_COUNT do begin
  98.     szItem[i] := '';
  99.     szMark[i] := '__' + int2str(i);
  100.     id[i] := 100 + i;
  101.   end;
  102.  
  103.   { poΦet polo₧ek v jednotliv²ch dialozφch : }
  104.   dlgItems[1] := 5;
  105.   dlgItems[2] := 5;
  106.   dlgItems[3] := 1;
  107.   dlgItems[4] := 2;
  108.   v := 0;
  109.   for i:=1 to DLG_COUNT do inc(v,dlgItems[i]);
  110.   if (v <> ITEM_COUNT) then
  111.     info_box('fn. Init', 'PoΦet polo₧ek v dlgItems neodpovφdß konstant∞ ITEM_COUNT!');
  112.  
  113.   { °et∞zce : }
  114.   szQuestEnd := "Opravdu si p°ejete ukonΦit vypl≥ovßnφ smlouvy?";
  115.   szCheckPrint := "UkonΦit bez vytiÜt∞nφ smlouvy";
  116.   szSection := 'Global';
  117.   szPath := szPath + 'prava.ini';
  118.  
  119.   szEntry := 'quest1';
  120.   GetPrivateProfileString(szSection, szEntry, '', s, 100, szPath);
  121.   if (s <> '') then szQuestEnd := s;
  122.  
  123.   szEntry := 'checkbox1';
  124.   GetPrivateProfileString(szSection, szEntry, '', s, 100, szPath);
  125.   if (s <> '') then szCheckPrint := s;
  126. end;
  127.  
  128.  
  129. procedure CreateDialogs;
  130. var
  131.   s : string[300];
  132.   i : short;
  133. begin
  134.   { 1 }
  135.   dlg[1] := DialogCreate(42, 27, 300, 200, DLG_CAPTION);
  136.   DlgText(dlg[1], "", 1001, 8, 8, 85, 165);
  137.   DlgText(dlg[1], "", ID_DLG_ID, 8, 185, 85);
  138.   DlgText(dlg[1], "S m l u v n φ   s t r a n y", -1, 114, 15, 128, 8);
  139.   DlgText(dlg[1], "Smluvnφ strana 1:", -2, 103, 52, 57, 8);
  140.   DlgInputLine(dlg[1], "", 101, 164, 50, 124, 12);
  141.   DlgText(dlg[1], "zastoupen²:", -3, 120, 71, 39, 8);
  142.   DlgInputLine(dlg[1], "", 102, 164, 69, 124, 12);
  143.   DlgText(dlg[1], "I╚O:", -4, 145, 90, 15, 8);
  144.   DlgInputLine(dlg[1], "", 103, 164, 88, 124, 12);
  145.   DlgText(dlg[1], "DI╚:", -5, 145, 109, 14, 8);
  146.   DlgInputLine(dlg[1], "", 104, 164, 107, 124, 12);
  147.   DlgText(dlg[1], "Bank. spojenφ:", -6, 112, 128, 49, 8);
  148.   DlgInputLine(dlg[1], "", 105, 164, 126, 124, 12);
  149.   DlgButton(dlg[1], "&DalÜφ  >>", 1003, 182, 180, 50, 14);
  150.   DlgButtonDefPush(dlg[1], 1003, true);
  151.   DlgBtnCancel(dlg[1], 242, 180, 50, 14);
  152.  
  153.   { 2 }
  154.   dlg[2] := DialogCreate(42, 27, 300, 200, DLG_CAPTION);
  155.   DlgText(dlg[2], "", 1001, 8, 8, 85, 165);
  156.   DlgText(dlg[2], "", ID_DLG_ID, 8, 185, 85);
  157.   DlgText(dlg[2], "S m l u v n φ   s t r a n y", -1, 114, 15, 128, 8);
  158.   DlgText(dlg[2], "Smluvnφ strana 2:", -2, 103, 52, 57, 8);
  159.   DlgInputLine(dlg[2], "", 106, 164, 50, 124, 12);
  160.   DlgText(dlg[2], "zastoupen²:", -3, 120, 71, 39, 8);
  161.   DlgInputLine(dlg[2], "", 107, 164, 69, 124, 12);
  162.   DlgText(dlg[2], "I╚O:", -4, 145, 90, 15, 8);
  163.   DlgInputLine(dlg[2], "", 108, 164, 88, 124, 12);
  164.   DlgText(dlg[2], "DI╚:", -5, 145, 109, 14, 8);
  165.   DlgInputLine(dlg[2], "", 109, 164, 107, 124, 12);
  166.   DlgText(dlg[2], "Bank. spojenφ:", -6, 112, 128, 49, 8);
  167.   DlgInputLine(dlg[2], "", 110, 164, 126, 124, 12);
  168.   DlgButton(dlg[2], "&DalÜφ  >>", 1003, 182, 180, 50, 14);
  169.   DlgButtonDefPush(dlg[2], 1003, true);
  170.   DlgButton(dlg[2], "<<  Z&p∞t", 1002, 132, 180, 50, 14);
  171.   DlgBtnCancel(dlg[2], 242, 180, 50, 14);
  172.  
  173.   { 3 }
  174.   dlg[3] := DialogCreate(42, 27, 300, 200, DLG_CAPTION);
  175.   DlgText(dlg[3], "", 1001, 8, 8, 85, 165);
  176.   DlgText(dlg[3], "", ID_DLG_ID, 8, 185, 85);
  177.   DlgText(dlg[3], "Z ß v a z e k   k   u z a v ° e n φ   p ° e d m ∞ t n Θ   s m l o u v y",
  178.           -1, 114, 15, 160, 16);
  179.   DlgTextSetAlign(dlg[3], -1, 1);
  180.   DlgText(dlg[3],
  181.     "Smluvnφ strany se zßvazn∞ dohodly na uzav°enφ p°edm∞tnΘ smlouvy o dφlo v termφnu",
  182.     -2, 114, 75, 159, 18);
  183.   DlgInputLine(dlg[3], "", 111, 115, 95, 157, 12);
  184.   DlgButton(dlg[3], "&DalÜφ  >>", 1003, 182, 180, 50, 14);
  185.   DlgButtonDefPush(dlg[3], 1003, true);
  186.   DlgButton(dlg[3], "<<  Z&p∞t", 1002, 132, 180, 50, 14);
  187.   DlgBtnCancel(dlg[3], 242, 180, 50, 14);
  188.  
  189.   { 4 }
  190.   dlg[4] := DialogCreate(42, 27, 300, 200, DLG_CAPTION);
  191.   DlgText(dlg[4], "", 1001, 8, 8, 85, 165);
  192.   DlgText(dlg[4], "", ID_DLG_ID, 8, 185, 85);
  193.   DlgText(dlg[4], "Z ß v ∞ r e Φ n ß   u s t a n o v e n φ", -1, 115, 15, 160, 8);
  194.   DlgText(dlg[4], "V", -2, 115, 88, 9, 9);
  195.   DlgInputLine(dlg[4], "", 112, 123, 86, 52, 12);
  196.   DlgText(dlg[4], "dne", -3, 186, 88, 15, 8);
  197.   DlgInputLine(dlg[4], "", 113, 202, 86, 79, 12);
  198.   DlgCheckBox(dlg[4], szCheckPrint, ID_CHECK_NOPRINT, 110, 160, 166);
  199.   DlgButton(dlg[4], "&Konec", 1003, 182, 180, 50, 14);
  200.   DlgButtonDefPush(dlg[4], 1003, true);
  201.   DlgButton(dlg[4], "<<  Z&p∞t", 1002, 132, 180, 50, 14);
  202.   DlgBtnCancel(dlg[4], 242, 180, 50, 14);
  203.  
  204.   for i:=1 to DLG_COUNT do begin
  205.     DlgTextSetBmp(dlg[i], ID_BMP, szBmpFile);
  206.     DlgSetCtrlText(dlg[i], ID_DLG_ID, GetDlgID(i));
  207.   end;
  208.  
  209.   d := today;
  210.   szItem[ITEM_COUNT] := int2str(Day(d)) + "." + int2str(Month(d)) + "." + int2str(Year(d));
  211.   InputLineSetVal(dlg[DLG_COUNT], id[ITEM_COUNT], szItem[ITEM_COUNT], STRLEN);
  212. end;
  213.  
  214.  
  215. procedure InsertTextToMark(
  216.   szMark : string[30];
  217.   szStr : string[STRLEN] );
  218. begin
  219.   if (GoToMark(false, szMark) = IDGOTO) then
  220.     InsertText(szStr)
  221.   else begin
  222.     szStr := 'Nenalezena zßlo₧ka ' + szMark;
  223.     info_box('Chyba', szStr);
  224.   end;
  225. end;
  226.  
  227.  
  228. function GetData : short;
  229. { vracφ poΦet prßzdn²ch polo₧ek }
  230. var
  231.   i, j, item, iResult : short;
  232. begin
  233.   iResult := 0;
  234.   item := 1;
  235.  
  236.   for i:=1 to DLG_COUNT do begin
  237.     for j:=1 to dlgItems[i] do begin
  238.       szItem[item] := InputLineGetVal(dlg[i], id[item]);
  239.       if (szItem[item] = '') then inc(iResult);
  240.       inc(item);
  241.     end;
  242.   end;
  243.  
  244.   GetData := iResult;
  245. end;
  246.  
  247.  
  248. function DoDialog(
  249.   x : short ) : short;
  250. begin
  251.   DoDialog := DialogRun(dlg[x]);
  252. end;
  253.  
  254.  
  255. begin
  256.   EraseThisMacro;
  257.   Init;
  258.  
  259.   bKonec := false;
  260.   bExit := false;
  261.   iDlg := 1;
  262.  
  263.   CreateDialogs;
  264.  
  265.   while not(bKonec) and not(bExit) do begin
  266.     iResult := DoDialog(iDlg);
  267.     case (iResult) of
  268.       IDCANCEL: bExit := (Yesno_box(DLG_CAPTION, szQuestEnd));
  269.       ID_NEXT: begin
  270.         if (iDlg = DLG_COUNT) then begin
  271.           if (GetData > 0) then begin
  272.             s := 'Nejsou vypln∞ny vÜechny polo₧ky. Chcete ukonΦit vypl≥ovßnφ smlouvy?';
  273.             bKonec := (Yesno_box(DLG_CAPTION, s));
  274.           end
  275.           else bKonec := true;
  276.         end
  277.         else
  278.           inc(iDlg);
  279.       end;
  280.       ID_BACK: begin dec(iDlg); if (iDlg < 1) then iDlg := 1; end;
  281.     end; { case }
  282.   end; { while }
  283.  
  284.   if not(bExit) then begin
  285.     for i:=1 to ITEM_COUNT do
  286.       InsertTextToMark(szMark[i], szItem[i]);
  287.     if not(CheckBoxGetVal(dlg[DLG_COUNT], ID_CHECK_NOPRINT)) then
  288.       Print(true, 2, 0, 0, 0);
  289.   end;
  290.  
  291. end.