This repository has been archived by the owner on Aug 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
funcoesdedeposito.pas
81 lines (65 loc) · 2.15 KB
/
funcoesdedeposito.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
unit FuncoesDeDeposito;
{$mode objfpc}{$H+}
interface
uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ComCtrls, variants;
function validaDeposito(contaDeposito, valorDeposito, AgenciaDeposito: String):Integer;
function salvarDeposito(valor, idconta:String):Integer;
function depositoPropriaConta(valor :String):Integer;
implementation
uses conexaoDB, telaLogin, dadosUsuario, telaInicial, telaInseriNotas, FuncoesDeSaque, funcoes;
function validaDeposito(contaDeposito, valorDeposito, AgenciaDeposito :String):Integer;
var checarConta :String;
begin
if (contaDeposito ='') OR (valorDeposito ='') OR (AgenciaDeposito='') then
Result :=3//valores nao preenchidos
else
begin
try
DB.SQLQuery1.SQL.Text:='SELECT idconta FROM conta WHERE idconta = '''+contaDeposito+'''';
DB.SQLQuery1.Open;
checarConta := VarToStr(DB.SQLQuery1['idconta']);
DB.SQLQuery1.Close;
if checarConta = contaDeposito then
Result:= 1//conta exsite
else
Result:=2;//conta nao existe
except
On E:Exception do
falhaBanco();
end;
end;
end;
function salvarDeposito(valor, idconta:String):Integer;
begin
try
DB.SQLQuery1.SQL.Text:='INSERT INTO deposito (idcontaUsuario, idcontadeposito, valor, aprovado, idcaixa, datadepostio) VALUES (0, '''+idconta+''','''+valor+''',1,1, current_date)';
DB.SQLTransaction1.Active:=false;
DB.SQLTransaction1.StartTransaction;
DB.SQLQuery1.ExecSQL;
DB.SQLTransaction1.Commit;
except
On E:Exception do
falhaBanco();
end;
end;
function depositoPropriaConta(valor :String):Integer;
begin
if (valor ='') OR (Length(valor) >6) then
Result :=1
else
begin
try
DB.SQLQuery1.SQL.Text:='INSERT INTO deposito (idcontaUsuario, idcontadeposito, valor, aprovado, idcaixa, datadepostio) VALUES ('''+nConta+''', '''+nConta+''','''+valor+''',1,1, current_date)';
DB.SQLTransaction1.Active:=false;
DB.SQLTransaction1.StartTransaction;
DB.SQLQuery1.ExecSQL;
DB.SQLTransaction1.Commit;
Result :=2;
except
On E:Exception do
falhaBanco();
end;
end;
end;
end.