-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit5.pas
More file actions
208 lines (175 loc) · 5.41 KB
/
Unit5.pas
File metadata and controls
208 lines (175 loc) · 5.41 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
unit unit5;
interface
uses UDM, System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option,
FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.SQLite,
FireDAC.Phys.SQLiteDef, FireDAC.Stan.ExprFuncs, FireDAC.VCLUI.Wait, Data.DB,
FireDAC.Comp.Client, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,
FireDAC.DApt, FireDAC.Comp.DataSet, Vcl.StdCtrls, Vcl.Dialogs;
type
CajaClass = class
Fid_empleado: Integer;
Fnombre_empleado: String;
Fap_empleado: String;
Fam_empledo: String;
Fhora_entrada_empleado: String;
Fhora_salida_empleado: String;
Fid_venta: Integer;
Ftotal_venta: real;
Fiva_venta: real;
Fmonto_recibido_venta: real;
Fcambio_venta: real;
Fid_exc: Integer;
Ftotal_exc: real;
Fmonto_exc: real;
Fcambio_exc: real;
Fid_cliente: integer;
Fnombre_cliente: String;
Fadeudo_cliente: real;
//q: TFDQuery;
Ftotal: Integer;
private
public
constructor Create();
function getEmpleado(id: Integer): TDataSet;
procedure getProducto(id: Integer; lb: TListBox);
procedure getClientes(lb: TListBox );
procedure sumaTotal(num: Currency);
procedure getTotal(e1: TEdit);
procedure getCambio(e: TEdit);
procedure getIVA(e: TEdit);
procedure terminarVenta();
procedure pagar(monto: Currency; e: TEdit);
procedure getVentas();
procedure AddNewCliente(e1 ,e2, e3, e4: String);
published
property id_empleado: Integer read Fid_empleado;
property nombre_empleado: String read Fnombre_empleado write Fnombre_empleado;
property ap_empleado: String read Fap_empleado write Fap_empleado;
property hora_entradaemp: String read Fhora_entrada_empleado;
property hora_salidaemp: String read Fhora_salida_empleado;
property id_venta: Integer read Fid_venta write Fid_venta;
property total_venta: real read Ftotal_venta write Ftotal_venta;
property iva_venta: real read Fiva_venta write Fiva_venta;
property monto_venta: real read Fmonto_recibido_venta write Fmonto_recibido_venta;
property cambio_venta: real read Fcambio_venta write Fcambio_venta;
property id_exc: Integer read Fid_exc write Fid_exc;
property total_exc: real read Ftotal_exc write Ftotal_venta;
property monto_exc: real read Fmonto_exc write Fmonto_exc;
property cambio_exc: real read Fmonto_exc write Fmonto_exc;
property id_cliente: Integer read Fid_cliente write Fid_cliente;
property nombre_clinte: String read Fnombre_cliente write Fnombre_cliente;
property adeudo_clinet: real read Fadeudo_cliente write Fadeudo_cliente;
End;
var
caja: CajaClass;
q: TFDQuery;
total: Currency;
aux: Currency;
monto: Currency;
iva: Currency;
cambio: Currency;
implementation
{ CajaClass }
procedure CajaClass.AddNewCliente(e1, e2, e3, e4:String);
begin
q := TFDQuery.Create(nil);
try
q.Connection := dm.dbRun;
q.SQL.Text := 'INSERT INTO cliente(id_cliente, nombre_cliente, tarjeta_cliente, adeudo_cliente)'+
' VALUES(:id,:nombre,:tarjeta,:adeudo)';
//q.SQL.Add()
q.Params.ParamByName('id').Value := (e1);
q.Params.ParamByName('nombre').AsString := e2;
q.Params.ParamByName('tarjeta').AsString := e3;
q.Params.ParamByName('adeudo').AsString := e4;
q.ExecSQL;
finally
FreeAndNil(q);
end;
end;
constructor CajaClass.Create;
begin
end;
procedure CajaClass.getCambio(e: TEdit);
begin
//e.Text := CurrToStr()
end;
procedure CajaClass.getClientes(lb: TListBox);
begin
q := TFDQuery.Create(nil);
try
q.Connection := dm.dbRun;
//ShowMessage(dm.dbRun.Params.Database);
q.SQL.Add('SELECT * FROM cliente');
//Fnombre_cliente := q.FieldByName('id_cliente').AsString;
//q.Params.ParamByName('id_cliente').Value:=1;
q.Open;
while not q.Eof do
begin
//Fnombre_cliente := q.FieldByName('').AsString;
lb.Items.Add(q.FieldByName('id_cliente').AsString+'--');
q.Next;
end;
finally
FreeAndNil(q);
end;
end;
function CajaClass.getEmpleado(id: Integer): TDataSet;
begin
q := TFDQuery.Create(nil);
q.Connection := dm.db;
//q.SQL.Text :=
q.SQL.Text:= 'SELECT * FROM empleado where id_empleado ='+id.ToString;
q.ExecSQL;
q.Open;
end;
procedure CajaClass.getIVA(e: TEdit);
begin
end;
procedure CajaClass.getProducto(id: Integer; lb: TListBox);
begin
q := TFDQuery.Create(nil);
try
q.Connection := dm.db;
q.SQL.Text := 'SELECT * FROM producto where id_producto = '+id.ToString;
q.Open;
sumaTotal(StrToCurr(q.FieldByName('precio_producto').AsString));
lb.Items.Add(q.FieldByName('id_producto').AsString+'..'+q.FieldByName('nombre_producto').AsString+'..'+q.FieldByName('precio_producto').AsString+'$');
finally
FreeAndNil(q);
end;
end;
procedure CajaClass.getTotal(e1: TEdit);
begin
e1.Text := '$ '+CurrToStr(total)
end;
procedure CajaClass.getVentas;
begin
end;
procedure CajaClass.pagar(monto: Currency; e: TEdit);
begin
if monto > total then
begin
cambio := monto - total;
e.Text := CurrToStr(cambio);
end
else
begin
ShowMessage('falta Dinero :(');
end;
end;
procedure CajaClass.sumaTotal(num: Currency);
begin
total := aux + num;
aux := total;
end;
procedure CajaClass.terminarVenta;
begin
total:=0 ;
aux := 0;
monto := 0;
iva := 0;
cambio := 0;
end;
end.