home *** CD-ROM | disk | FTP | other *** search
- unit Unit1;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- OleCtrls, SHDocVw, StdCtrls, Db, DBTables, ExtCtrls, ShellAPI;
-
- type
- TForm1 = class(TForm)
- tblEmployee: TTable;
- tblEmployeeEmpNo: TIntegerField;
- tblEmployeeLastName: TStringField;
- tblEmployeeFirstName: TStringField;
- tblEmployeePhoneExt: TStringField;
- tblEmployeeHireDate: TDateTimeField;
- tblEmployeeSalary: TFloatField;
- dsEmployee: TDataSource;
- Button1: TButton;
- Button2: TButton;
- btnCreateXML: TButton;
- Button4: TButton;
- Button5: TButton;
- mXML: TMemo;
- Panel1: TPanel;
- wbXML: TWebBrowser;
- Button6: TButton;
- procedure btnCreateXMLClick(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button5Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- procedure Button6Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
- g_AppPath : String;
-
- implementation
-
- {$R *.DFM}
-
-
- procedure TForm1.btnCreateXMLClick(Sender: TObject);
- var f : TextFile;
- i : Integer;
-
- begin
- i := 0;
-
- AssignFile(f, g_AppPath + '\XT\employees.xml');
- Rewrite(f);
- writeln(f, '<?xml version="1.0"?>');
-
- writeln(f, '<employees>');
- writeln(f, '');
-
- with tblEmployee do begin
- Open;
- First;
- DisableControls;
- while not eof do begin
- write(f, '<employee emp_no="');
- write(f, FieldByName('EMPNO').AsString);
- writeln(f, '">');
-
- write(f, '<emp_lastname>');
- write(f, FieldByName('LASTNAME').AsString);
- write(f, '</emp_lastname>');
-
- write(f, '<emp_firstname>');
- write(f, FieldByName('FIRSTNAME').AsString);
- write(f, '</emp_firstname>');
-
- write(f, '<emp_phoneext>');
- write(f, FieldByName('PHONEEXT').AsString);
- write(f, '</emp_phoneext>');
-
- // For every other employee, alternate the currency...
- // ..for the sake of demonstration...
- if i mod 2 = 0 then
- write(f, '<emp_salary currency="UKP">')
- else
- write(f, '<emp_salary currency="USD">');
-
- write(f, FieldByName('Salary').AsString);
- writeln(f, '</emp_salary>');
-
- writeln(f, '</employee>');
- writeln(f, '');
- next;
- i:=i+1;
- end;
- EnableControls;
- Close;
- end;
-
- writeln(f, '</employees>');
- CloseFile(f);
-
- mXML.Lines.LoadFromFile(g_AppPath + 'XT\employees.xml');
- wbXML.Navigate(g_AppPath + 'XT\employees.xml');
-
- Button1.Enabled:=True;
- Button2.Enabled:=True;
- Button4.Enabled:=True;
- Button5.Enabled:=True;
- Button6.Enabled:=True;
-
- end;
-
-
-
-
- function fnWinExecAndWait32(sFileName :String; iVisible :Integer):Integer;
- {
- Parameter : sFileName : Exe Filename with FullPath
- iVisible : Either to show the execution to the user or suppress
- 0 - Visible off
- 1 - Visible on
- Comment: To Execute the File and wait till the completion of the program
- }
-
- var
- arrAppName :array[0..512] of char;
- arrCurDir :array[0..255] of char;
- sWorkDir :String;
- StartupInfo :TStartupInfo;
- ProcessInfo :TProcessInformation;
- lwResult :LONGWORD;
- begin
-
- StrPCopy(arrAppName, sFileName);
- GetDir(0, sWorkDir);
- StrPCopy(arrCurDir, sWorkDir);
-
- FillChar(StartupInfo, sizeof(StartupInfo), #0);
- StartupInfo.cb := sizeof(StartupInfo);
-
- StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
- StartupInfo.wShowWindow := iVisible;
-
- if not CreateProcess(nil, arrAppName, nil, nil,
- False, CREATE_NEW_CONSOLE OR
- NORMAL_PRIORITY_CLASS, nil, nil,
- StartupInfo, ProcessInfo) then
- Result := -1
- else
- begin
- WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
- GetExitCodeProcess(ProcessInfo.hProcess, lwResult);
- Result := 0;
- end;
- end;
-
-
-
-
- procedure TForm1.Button1Click(Sender: TObject);
- var s : string;
- sp : string;
- begin
- mXML.Clear;
-
- s:=g_AppPath + 'XT\XT.EXE employees.xml ';
- s:=s+ g_AppPath + 'XT\empuk.xsl ';
- s:=s+ g_AppPath + 'XT\result.htm';
-
- fnWinExecAndWait32(s,0); //WinExec(PChar(s), SW_SHOWMINNOACTIVE);
-
- wbXML.Refresh;
- wbXML.Navigate(g_AppPath + 'XT\result.htm');
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- var s : string;
- begin
- mXML.Clear;
-
- s:=g_AppPath + 'XT\XT.EXE employees.xml ';
- s:=s+ g_AppPath + 'XT\empus.xsl ';
- s:=s+ g_AppPath + 'XT\result.htm';
-
- fnWinExecAndWait32(s,0); //WinExec(PChar(s), SW_SHOWMINNOACTIVE);
-
- wbXML.Refresh;
- wbXML.Navigate(g_AppPath + 'XT\result.htm');
- end;
-
- procedure TForm1.Button5Click(Sender: TObject);
- var s : string;
- begin
- mXML.Clear;
-
- s:=g_AppPath + 'XT\XT.EXE employees.xml ';
- s:=s+ g_AppPath + 'XT\empussal.xsl ';
- s:=s+ g_AppPath + 'XT\result.htm';
-
- fnWinExecAndWait32(s,0); //WinExec(PChar(s), SW_SHOWMINNOACTIVE);
-
- wbXML.Refresh;
- wbXML.Navigate(g_AppPath + 'XT\result.htm');
- end;
-
- procedure TForm1.Button4Click(Sender: TObject);
- var s : string;
- begin
- mXML.Clear;
-
- s:=g_AppPath + 'XT\XT.EXE employees.xml ';
- s:=s+ g_AppPath + 'XT\empuksna.xsl ';
- s:=s+ g_AppPath + 'XT\result.htm';
-
- fnWinExecAndWait32(s,0); //WinExec(PChar(s), SW_SHOWMINNOACTIVE);
-
- wbXML.Refresh;
- wbXML.Navigate(g_AppPath + 'XT\result.htm');
- end;
-
- procedure TForm1.Button6Click(Sender: TObject);
- var s : string;
- begin
- mXML.Clear;
-
- s:=g_AppPath + 'XT\XT.EXE employees.xml ';
- s:=s+ g_AppPath + 'XT\empuksnd.xsl ';
- s:=s+ g_AppPath + 'XT\result.htm';
-
- fnWinExecAndWait32(s,0); //WinExec(PChar(s), SW_SHOWMINNOACTIVE);
-
- wbXML.Refresh;
- wbXML.Navigate(g_AppPath + 'XT\result.htm');
- end;
-
- initialization
- g_AppPath:=ExtractFilePath(Application.ExeName);
-
- end.
-