-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit1.pas
More file actions
99 lines (87 loc) · 2 KB
/
Copy pathUnit1.pas
File metadata and controls
99 lines (87 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Panel2: TPanel;
pnLogin: TPanel;
Label1: TLabel;
Label2: TLabel;
btnLogin: TButton;
edUN: TEdit;
edPS: TEdit;
pnMain: TPanel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
edCode: TEdit;
edAfm: TEdit;
edName: TEdit;
btnPost: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure btnLoginClick(Sender: TObject);
procedure btnPostClick(Sender: TObject);
private
{ Private declarations }
FSoftOne : OleVariant;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
ComObj;
procedure TForm1.FormCreate(Sender: TObject);
begin
FSoftOne := CreateOleObject('SoXplorer.SoConnection');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FSoftOne:= Null;
FSoftOne:= Unassigned;
end;
procedure TForm1.btnLoginClick(Sender: TObject);
begin
FSoftOne.Login(edUN.Text, edPS.Text, 1, 1, SysUtils.Date);
PnLogin.Enabled:= False;
btnLogin.Enabled:= False;
pnMain.Enabled:= True;
end;
procedure TForm1.btnPostClick(Sender: TObject);
var
ACustObj : OleVariant;
ACustTable: OleVariant;
AError: string;
AId: integer;
begin
try
ACustObj := FSoftOne.CreateObj('CUSTOMER');
try
ACustTable:= ACustObj.FindTable('CUSTOMER');
ACustObj.DBInsert;
ACustTable.Code := edCode.Text;
ACustTable.Name := edName.Text;
ACustTable.Afm := edafm.Text;
AId:=ACustObj.DBPost;
ShowMessage(format('Ï ðåëÜôçò : %s êáôá÷ùñÞèçêå ìå ID %d',[edName.Text, AID]));
edCode.Text:='';
edAfm.Text:='';
edName.Text:='';
finally
ACustObj:= Null;
ACustObj:= Unassigned;
end;
except
AError:=FSoftOne.GetLastError;
if AError<>'' then
raise Exception.Create(AError)
else raise;
end;
end;
end.