-
Notifications
You must be signed in to change notification settings - Fork 0
/
uMain.pas
151 lines (135 loc) · 3.11 KB
/
uMain.pas
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
unit uMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
Ocuco.Model.Interfaces;
type
TFrmMain = class(TForm)
mmCoupon: TMemo;
btnSell: TButton;
btnAddClient: TButton;
btnAddItem: TButton;
btnAddPayment: TButton;
btnFinishSell: TButton;
procedure btnSellClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnAddClientClick(Sender: TObject);
procedure btnAddItemClick(Sender: TObject);
procedure btnAddPaymentClick(Sender: TObject);
procedure btnFinishSellClick(Sender: TObject);
private
{ Private declarations }
FSell: ISell;
procedure doCoupon(Value: string);
public
{ Public declarations }
end;
var
FrmMain: TFrmMain;
implementation
uses
Ocuco.Model.Sell,
Ocuco.Model.Itens,
Ocuco.View.Client,
Ocuco.View.Item,
Ocuco.View.Payment,
Ocuco.Model.Client,
Ocuco.Model.Payment;
{$R *.dfm}
procedure TFrmMain.btnAddItemClick(Sender: TObject);
var
LFrmItem: TFrmItem;
begin
LFrmItem := TFrmItem.Create(nil);
try
if LFrmItem.ShowModal = mrOk then
begin
FSell.AddItem(TItens.New.
AddValue(StrToIntDef(LFrmItem.EditValue.Text, 0)).
AddName(LFrmItem.EditName.Text));
end;
finally
FreeAndNil(LFrmItem);
end;
end;
procedure TFrmMain.btnAddPaymentClick(Sender: TObject);
var
LFrmPayment: TFrmPayment;
begin
LFrmPayment := TFrmPayment.Create(nil);
try
if LFrmPayment.ShowModal = mrOk then
begin
FSell.AddPayment(
TPayment.New.
Add.
Value(StrToIntDef(LFrmPayment.EditValue.Text, 0)).
PaymentType(LFrmPayment.EditPaymentType.Text)
);
end;
finally
FreeAndNil(LFrmPayment);
end;
end;
procedure TFrmMain.btnFinishSellClick(Sender: TObject);
begin
FSell.EndSell;
end;
procedure TFrmMain.btnSellClick(Sender: TObject);
begin
TSell.New
.AddDisplay
.Coupon(doCoupon)
.EndDisplay
.AddClient.
Name('Oliveira').
Cpf('1233445').
EndClient
.AddItem(TItens.New.AddValue(10).AddName('Andre'))
.AddItem(TItens.New.AddValue(5).AddName('Luiz'))
.AddItem(TItens.New.AddValue(2).AddName('Oliveira'))
.AddPayment
.Add
.Value(10)
.PaymentType('Cash')
.EndAddPayment
.Add
.Value(15)
.PaymentType('CreditCard')
.EndAddPayment
.Add
.Value(15)
.PaymentType('Ticket')
.EndAddPayment
.EndPayment
.EndSell;
end;
procedure TFrmMain.btnAddClientClick(Sender: TObject);
var
FClient: TFrmClient;
begin
FClient := TFrmClient.Create(nil);
try
if FClient.ShowModal = mrOk then
begin
FSell.
AddClient(TClient.
New.
Name(FClient.EditName.Text).
Cpf(FClient.EditCpf.Text)
);
end;
finally
FreeAndNil(FCLient);
end;
end;
procedure TFrmMain.doCoupon(Value: string);
begin
mmCoupon.Lines.Add(Value);
end;
procedure TFrmMain.FormCreate(Sender: TObject);
begin
FSell := TSell.New.AddDisplay.Coupon(doCoupon).EndDisplay;
end;
end.