In a form in my application, the record record button is activated unconditionally. I put a confirmation message on that record button. When another button, for example printing, is clicked on this form, the save confirmation message is displayed. I have already examined the script and everything is correct.
Did MVD always record the record in this type of situation and was that evident when I put the confirmation message? Has anyone ever experienced this?
1 2020-01-26 23:59:24
Topic: please help - record button is triggered strangely (4 replies, posted in FAQ)
2 2020-01-09 16:30:56
Topic: Valor monetário por extenso (NumberToWords) (1 replies, posted in Script)
adaptei do Delphi para o MVD. (I adapted from Delphi to MVD.)
créditos:
Prof. Omero Francisco Bertol (http://www.pb.utfpr.edu.br/omero/)
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
showmessage(valorPorExtenso(Form1.tb_valor.value));
end;
function valorPorExtenso(vlr: real): string;
var
unidade: array[1..19] of string;
centena: array[1..9] of string;
dezena: array[2..9] of string;
qualificaS: array[0..4] of string;
qualificaP: array[0..4] of string;
inteiro: integer; //Int64;
resto: real;
vlrS, s, saux, vlrP, centavos: string;
n, unid, dez, cent, tam, i: integer;
umReal, tem: boolean;
begin
unidade[1] := 'um';
unidade[2] := 'dois';
unidade[3] := 'três';
unidade[4] := 'quatro';
unidade[5] := 'cinco';
unidade[6] := 'seis';
unidade[7] := 'sete';
unidade[8] := 'oito';
unidade[9] := 'nove';
unidade[10] := 'dez';
unidade[11] := 'onze';
unidade[12] := 'doze';
unidade[13] := 'treze';
unidade[14] := 'quatorze';
unidade[15] := 'quinze';
unidade[16] := 'dezesseis';
unidade[17] := 'dezessete';
unidade[18] := 'dezoito';
unidade[19] := 'dezenove';
centena[1] := 'cento';
centena[2] := 'duzentos';
centena[3] := 'trezentos';
centena[4] := 'quatrocentos';
centena[5] := 'quinhentos';
centena[6] := 'seiscentos';
centena[7] := 'setecentos';
centena[8] := 'oitocentos';
centena[9] := 'novecentos';
dezena[2] := 'vinte';
dezena[3] := 'trinta';
dezena[4] := 'quarenta';
dezena[5] := 'cinquenta';
dezena[6] := 'sessenta';
dezena[7] := 'setenta';
dezena[8] := 'oitenta';
dezena[9] := 'noventa';
qualificaS[0] := '';
qualificaS[1] := 'mil';
qualificaS[2] := 'milhão';
qualificaS[3] := 'bilhão';
qualificaS[4] := 'trilhão';
qualificaP[0] := '';
qualificaP[1] := 'mil';
qualificaP[2] := 'milhões';
qualificaP[3] := 'bilhões';
qualificaP[4] := 'trilhões';
if (vlr = 0)
then begin
Result := 'zero';
exit;
end;
inteiro := trunc(vlr); // parte inteira do valor
resto := vlr - inteiro; // parte fracionária do valor
vlrS := inttostr(inteiro);
if (length(vlrS) > 15)
then begin
Result := 'Erro: valor superior a 999 trilhões.';
exit;
end;
s := '';
centavos := inttostr(round(resto * 100));
// definindo o extenso da parte inteira do valor
i := 0;
umReal := false; tem := false;
while (vlrS <> '0') do
begin
tam := length(vlrS);
// retira do valor a 1a. parte, 2a. parte, por exemplo, para 123456789:
// 1a. parte = 789 (centena)
// 2a. parte = 456 (mil)
// 3a. parte = 123 (milhões)
if (tam > 3)
then begin
vlrP := copy(vlrS, tam-2, tam);
vlrS := copy(vlrS, 1, tam-3);
end
else begin // última parte do valor
vlrP := vlrS;
vlrS := '0';
end;
if (vlrP <> '000')
then begin
saux := '';
if (vlrP = '100')
then saux := 'cem'
else begin
n := strtoint(vlrP); // para n = 371, tem-se:
cent := n div 100; // cent = 3 (centena trezentos)
dez := (n mod 100) div 10; // dez = 7 (dezena setenta)
unid := (n mod 100) mod 10; // unid = 1 (unidade um)
if (cent <> 0)
then saux := centena[cent];
if ((dez <> 0) or (unid <> 0))
then begin
if ((n mod 100) <= 19)
then begin
if (length(saux) <> 0)
then saux := saux + ' e ' + unidade[n mod 100]
else saux := unidade[n mod 100];
end
else begin
if (length(saux) <> 0)
then saux := saux + ' e ' + dezena[dez]
else saux := dezena[dez];
if (unid <> 0)
then if (length(saux) <> 0)
then saux := saux + ' e ' + unidade[unid]
else saux := unidade[unid];
end;
end;
end;
if ((vlrP = '1') or (vlrP = '001'))
then begin
if (i = 0) // 1a. parte do valor (um real)
then umReal := true
else saux := saux + ' ' + qualificaS[i];
end
else if (i <> 0)
then saux := saux + ' ' + qualificaP[i];
if (length(s) <> 0)
then s := saux + ', ' + s
else s := saux;
end;
if (((i = 0) or (i = 1)) and (length(s) <> 0))
then tem := true; // tem centena ou mil no valor
i := i + 1; // próximo qualificador: 1- mil, 2- milhão, 3- bilhão, ...
end;
if (length(s) <> 0)
then begin
if (umReal)
then s := s + ' real'
else if (tem)
then s := s + ' reais'
else s := s + ' de reais';
end;
// definindo o extenso dos centavos do valor
if (centavos <> '0') // valor com centavos
then begin
if (length(s) <> 0) // se não é valor somente com centavos
then s := s + ' e ';
if (centavos = '1')
then s := s + 'um centavo'
else begin
n := strtoint(centavos);
if (n <= 19)
then s := s + unidade[n]
else begin // para n = 37, tem-se:
unid := n mod 10; // unid = 37 % 10 = 7 (unidade sete)
dez := n div 10; // dez = 37 / 10 = 3 (dezena trinta)
s := s + dezena[dez];
if (unid <> 0)
then s := s + ' e ' + unidade[unid];
end;
s := s + ' centavos';
end;
end;
Result := s;
end;
begin
end.
3 2020-01-08 17:02:57
Topic: Funções que validam CPF e CNPJ, utilizados no Brasil (1 replies, posted in Script)
Retirei da Internet - código foi escrito em Pascal e funciona no MVD
function ValidaCPF(num: string): boolean;
var
n1,n2,n3,n4,n5,n6,n7,n8,n9: integer;
d1,d2: integer;
digitado, calculado: string;
begin
if (Length(num)<>11) then
begin
Result:=False;
end
else
begin
n1:=StrToInt(num[1]);
n2:=StrToInt(num[2]);
n3:=StrToInt(num[3]);
n4:=StrToInt(num[4]);
n5:=StrToInt(num[5]);
n6:=StrToInt(num[6]);
n7:=StrToInt(num[7]);
n8:=StrToInt(num[8]);
n9:=StrToInt(num[9]);
d1:=n9*2+n8*3+n7*4+n6*5+n5*6+n4*7+n3*8+n2*9+n1*10;
d1:=11-(d1 mod 11);
if d1>=10 then d1:=0;
d2:=d1*2+n9*3+n8*4+n7*5+n6*6+n5*7+n4*8+n3*9+n2*10+n1*11;
d2:=11-(d2 mod 11);
if d2>=10 then d2:=0;
calculado:=inttostr(d1)+inttostr(d2);
digitado:=num[10]+num[11];
if calculado=digitado then
Result :=true
else
Result :=false;
end;
end;
function ValidaCNPJ(num: string): boolean;
var
n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12: integer;
d1,d2: integer;
digitado, calculado: string;
begin
if (Length(num)<>14) then
begin
Result:=False;
end
else
begin
n1:=StrToInt(num[1]);
n2:=StrToInt(num[2]);
n3:=StrToInt(num[3]);
n4:=StrToInt(num[4]);
n5:=StrToInt(num[5]);
n6:=StrToInt(num[6]);
n7:=StrToInt(num[7]);
n8:=StrToInt(num[8]);
n9:=StrToInt(num[9]);
n10:=StrToInt(num[10]);
n11:=StrToInt(num[11]);
n12:=StrToInt(num[12]);
d1:=n12*2+n11*3+n10*4+n9*5+n8*6+n7*7+n6*8+n5*9+n4*2+n3*3+n2*4+n1*5;
d1:=11-(d1 mod 11);
if d1>=10 then d1:=0;
d2:=d1*2+n12*3+n11*4+n10*5+n9*6+n8*7+n7*8+n6*9+n5*2+n4*3+n3*4+n2*5+n1*6;
d2:=11-(d2 mod 11);
if d2>=10 then d2:=0;
calculado:=inttostr(d1)+inttostr(d2);
digitado:=num[13]+num[14];
if calculado=digitado then
Result:=true
else
Result:=false;
end;
end;
4 2019-11-19 19:53:56
Re: color rows alternately on a tablegrid when there are many records (3 replies, posted in Script)
thank you
5 2019-11-10 23:25:46
Topic: color rows alternately on a tablegrid when there are many records (3 replies, posted in Script)
I use the procedure below to alternately color the lines of a tablegrid. This routine, I found here in this forum.
However, navigation slows down on a 22 row tablegrid because it is linked to a table with 4000 records. I noticed that using the tablegrid dblimit of 22 lines, the browsing speed is good. But,
As you scroll down the tablegrid, the colors fade. Can anyone help?
procedure ColorRowGrid (Grid:TdbStringGridEx;ColorEven,ColorOdd:TColor;ajusta:boolean);
//**** alterna cores de linhas numa tablegrid
var
iRow ,c: integer;
q, iCol: integer;
begin
c := Grid.RowCount - 1;
q := Grid.Columns.Count-1;
for iRow := 0 to c do
for iCol := 0 to q do
begin
if iRow mod 2 = 0 then Grid.Cell[iCol,iRow].Color := ColorEven
else
Grid.Cell[iCol,iRow].Color := ColorOdd;
end;
if ajusta then Grid.BestFitColumns(bfBoth); //ajusta conteúdo no tablegrid
end;
6 2019-10-27 13:26:10
Topic: to capture image (jpg) of the Internet (1 replies, posted in Script)
How can I capture automatically an image (jpg) of the Internet straightly for a DBImage1?
7 2019-06-20 01:18:38
Re: [SOLVED] it does not lose data while closing the form (5 replies, posted in General)
One more applications program developed with the MVD. It calculates profits in an application of fixed income. The calculator, besides financial calculations, to do taxes conversion.
8 2019-06-17 12:40:29
Re: How To Use Cal Power(2,3) ??? (7 replies, posted in Script)
Hello community MVD. It follows down script what I created to do financial calculations (financial mathematics).
procedure calculo_juros_composto;
var
PMT, FV, PV, i, n: real;
inicio: integer;
p1, p2: real;
calculou: boolean = false;
begin
PMT := frmCalc.edPMT.value;
FV := frmCalc.edFV.value;
PV := frmCalc.edPV.value;
i := frmCalc.edi.value/100;
n := frmCalc.edn.value;
inicio := strtoint(frmCalc.chk_begin.sqlValue);
if (frmCalc.edPMT.text = '') and (frmCalc.edFV.value = 0) then //calcula PMT com FV = 0
begin
calculou := true;
p1 := power((i + 1),n)-1;
p2 := power((1 + i),(n - inicio)) * i;
PMT := PV/(p1/p2);
frmCalc.edPMT.text := Formatfloat('###,###,#0.00',PMT);
exit;
end;
if (frmCalc.edPV.text = '') and (frmCalc.edFV.value = 0) then //calcula PV com FV = 0
begin
calculou := true;
p1 := power((i + 1),n)-1;
p2 := power((1 + i),(n - inicio)) * i;
PV := PMT/(p2/p1);
frmCalc.edPV.text := Formatfloat('###,###,#0.00',PV);
exit;
end;
if (frmCalc.edFV.text = '') and (frmCalc.edPV.value = 0) then //calcula FV com PV = 0
begin
calculou := true;
p1 := power((i + 1),n)-1;
p2 := i;
FV := PMT * (p1/p2);
frmCalc.edFV.text := Formatfloat('###,###,#0.00',FV);
exit;
end;
if (frmCalc.edPMT.text = '') and (frmCalc.edPV.value = 0) then //calcula PMT com PV = 0
begin
calculou := true;
p1 := power((i + 1),n)-1;
p2 := i;
PMT := FV / (p1/p2);
frmCalc.edPMT.text := Formatfloat('###,###,#0.00',PMT);
exit;
end;
if (frmCalc.edi.text = '') and (frmCalc.edPMT.value = 0) then //calcula i com PMT = 0
begin
calculou := true;
p1 := FV/PV;
p2 := power(p1,(1/n));
i := (p2 - 1)*100;
frmCalc.edi.text := Formatfloat('###,###,#0.00',i);
exit;
end;
if (frmCalc.edn.text = '') and (frmCalc.edPMT.value = 0) then //calcula n com PMT = 0
begin
calculou := true;
p1 := FV/PV;
p2 := i + 1;
n := ln(p1)/ln(p2);
frmCalc.edn.text := Formatfloat('##0',n);
exit;
end;
.......................................................................
if calculou = false then showmessage('o campo a ser calculado deve estar em branco e deve haver um campo com valor = 0 (zero)');
end;
9 2019-06-05 00:26:34
Re: How will it print more than a tablegrid in different reports? (3 replies, posted in General)
Solved. I used your example. Tank you.
10 2019-06-01 19:39:47
Re: How will it print more than a tablegrid in different reports? (3 replies, posted in General)
Dmitry obliged by the help, but I would like of each one prints the tablegrids in a report. Is it possible to create a function so that it can be in use in some tablegrid?
11 2019-05-30 14:53:58
Re: Using Grid Results in Report (11 replies, posted in Reports)
Dmitry, thank you, but I wanted to print each tablegrid in a different report, in other words, there are 2 reports. Is it possible? The ideal is if there was a function to call any tablegrid to criterion of a user
12 2019-05-27 01:08:53
Topic: How will it print more than a tablegrid in different reports? (3 replies, posted in General)
I used the script of the link down and it gave right, but I do not manage to print other tablegrids in other reports. The ideal is that there would be a function that could be used in any tablegrid case if it will be printed in a report. Can anybody help me?
13 2019-05-25 16:09:45
Re: Using Grid Results in Report (11 replies, posted in Reports)
Dmitry, please, how can I use the routine above if I have 2 tablegrids?
14 2019-04-30 12:20:03
Re: Using Grid Results in Report (11 replies, posted in Reports)
Dmitry, I used the script above that you published and worked, but I do not manage to use the same thing to produce another report. I want to print the tablegrid in 2 reports. How can I use the same routine?
15 2019-04-30 00:46:32
Re: [SOLVED] it does not lose data while closing the form (5 replies, posted in General)
Mais um aplicativo concluído - ver no link abaixo - que desenvolvi com MVD 3.1.
16 2019-04-13 18:07:24
Re: Вопрос по DecimalSeparator (1 replies, posted in Russian)
eu consegui resolver com um quebra-galho. O validfloat não funcionou para mim.
numa consulta SQL usei:
select (valor as real) as valor from table.
Estou usando o MVD 3.1 e estou tendo muitas dificuldades com o ponto decimal
17 2019-04-04 17:16:43
Re: POSSIBLE BUG: TableGrid, Date, Float and some questions (8 replies, posted in General)
I am not managing to carve a textbox he was seeing sql with insert. In properties it was defined that the only accepted textbox numbers, which it has 2 decimal houses and which the separation takes as a thousand. I tried already with replace, floattostr (textbox) etc. and without success. Can anybody help?
I am using the MVD 3.1
18 2019-04-02 17:07:50
Re: [SOLVED] it does not lose data while closing the form (5 replies, posted in General)
Não sou programador e nem trabalho na área, mas me considero um auto-didata e consegui desenvolver o projeto abaixo, com tudo que aprendi neste fórum. Parabéns ao Dmitry por ter desenvolvido essa excelente ferramenta de programação, que é o MVD.
19 2018-12-28 00:03:28
Re: date filter (4 replies, posted in General)
Please, I ask the one who will be able to help and to a desenvolvedor, which gives support for the forum, as I can compare a date he was seeing script. The filter used in the button SEARCH with the operator> = for the least date is lowered by me, IT DOES NOT WORK.
procedure frmComissoes_OnShow (Sender: string; Action: string);
begin
frmComissoes.dtIni.datetime := strtodate(SQLExecute('SELECT strftime("%d/%m/%Y",MIN(Data_Venda)) FROM Vendas'));
frmComissoes.dtFim.datetime := strtodate(SQLExecute('SELECT strftime("%d/%m/%Y",MAX(Data_Venda)) FROM Vendas'));
end;
20 2018-12-22 18:49:39
Re: Clearing after delete... (21 replies, posted in General)
Please, how can I use the procedure shown by Dmitry and select the fields that will not be clean?
21 2018-12-12 01:58:31
Topic: [SOLVED] it does not lose data while closing the form (5 replies, posted in General)
var
alterado: boolean = False;
procedure form4_Edit3_OnChange (Sender: string);
//*** flag que alteracao foi feita no campo
begin
alterado := true;
end;
procedure Form4_OnShow (Sender: string; Action: string);
//**** desabilita todos os icones do sistema no formulario: fechar, minimizar e maximizar
begin
Form4.BorderIcons:= 0;
end;
procedure form4_Button2_OnClick (Sender: string; var Cancel: boolean);
//*** evita sair sem gravar - botao de fechar tem que estar como "no action"
begin
if alterado = false then Form4.Close;
if alterado = true then
if 6 = MessageDlg('Cancela alterações', mtConfirmation, mbYes + mbNo + mbCancel, 0) then
Form4.Close;
end;
begn
end.
22 2018-11-27 00:16:15
Re: [Query] Check for duplicate for beginners (14 replies, posted in FAQ)
KEY DUPLICATE
Mathias, obrigado pela informação. Eu usei a função no MVD 2.8 e funciona. Entretanto, ela não funciona quando estou inserindo um novo registro num formulário que tem um tablegrid (registros filhos). Quando tento gravar o registro, após a inserção de registros no tablegrid, o MVD dá a mensagem que a chave já existe. Eu entendi que o MVD primeiro grava o registro pai antes de inserir o registro filho no tablegrid....
Você tem alguma sugestão para esse caso? Obrigado.
Eu usei o trigger abaixo, que encontrei na internet e funcionou. Achei o de insert na Internet e criei o de update:
CREATE TRIGGER [nf_duplicada_update] BEFORE UPDATE ON [Vendas] WHEN [OLD].[Nota_Fiscal] <> [NEW].[Nota_Fiscal]
BEGIN
SELECT RAISE(ABORT, "Nota Fiscal já existe")
WHERE EXISTS (SELECT *
FROM [Vendas]
WHERE [Nota_Fiscal] = [NEW].[Nota_Fiscal]);
END;
CREATE TRIGGER [nf_duplicada_insert] BEFORE INSERT ON [Vendas]
BEGIN
SELECT RAISE(ABORT, "Nota Fiscal já existe")
WHERE EXISTS (SELECT C *
FROM [Vendas]
WHERE [Nota_Fiscal] = [NEW].[Nota_Fiscal]);
END;
23 2018-11-23 16:01:30
Re: Getting Access Violation (3 replies, posted in General)
Estou tendo o mesmo problema!!!! O sistema que desenvolvi com o MVD 2.8, que roda bem sem erros no Windows 7, apresenta a mensagem de erro "access violation at address....." na versão 4.6. Dmitry, preciso da sua ajuda
Dmitry, por favor, responda....até pra dizer que não tem solução...
24 2018-11-19 00:56:07
Re: Final MVD 4.6, 4.7 (7 replies, posted in General)
Hello MVD community. I use the procedure below to generate a report. Works well. I use dtIni and dtFim to put the period in the report title. Is it possible to simplify this comparison (> =, <=) with dates?
Or is there another way to put the query date range in the report header?
procedure frmListVendas_bRelVendas_OnClick (Sender: string; var Cancel: boolean);
//****** alimenta relatório padrão lista de vendas a partir do tablegrid
var
i,c: integer;
s, YY, MM, DD: string;
Y,M,D: Word;
v_dtini, v_dtfim: string;
begin
s := '';
DecodeDate(frmListVendas.dtIni.Date, Y, M, D);
YY := vartostr(Y); MM :=vartostr(M); DD := vartostr(D);
if length(MM) = 1 then MM := '0'+MM; if length(DD) = 1 then DD := '0'+DD;
v_dtini := YY+'-'+MM+'-'+DD; showmessage(v_dtini);
DecodeDate(frmListVendas.dtFim.Date, Y, M, D);
YY := vartostr(Y); MM :=vartostr(M); DD := vartostr(D);
if length(MM) = 1 then MM := '0'+MM; if length(DD) = 1 then DD := '0'+DD;
v_dtfim := YY+'-'+MM+'-'+DD; showmessage(v_dtfim);
frmListVendas.bRelVendas.dbSQL := '';
frmListVendas.bRelVendas.dbSQL := 'SELECT "Vendas"."Nota_Fiscal", "Vendas"."Pedido", '+
' strftime("%d-%m-%Y","Vendas"."Data_Venda") as Data_Venda, '+
' (SELECT strftime("%d-%m-%Y",Min("Vendas"."Data_Venda")) from Vendas where Data_Venda >= '+v_dtini+') as DtIni,'+
' (SELECT strftime("%d-%m-%Y",Max("Vendas"."Data_Venda")) from Vendas where Data_Venda <= '+v_dtfim+') as DtFim,'+
' "Clientes"."Clie_Nome", '+
' "Vendedores"."Vend_Nome", '+
' "Vendas"."Quantidade", '+
' "Vendas"."Valor" '+
'FROM "Vendas" '+
'LEFT OUTER JOIN "Clientes" ON "Vendas"."id_Clientes" = "Clientes"."id" '+
'LEFT OUTER JOIN "Vendedores" ON "Vendas"."id_Vendedores" = "Vendedores"."id" ';
c := frmListVendas.TableGrid_Vendas.RowCount-1;
for i := 0 to c do
begin
s := s + ''+IntToStr(frmListVendas.TableGrid_Vendas.dbIndexToID(i)) + ',';
end;
if s <> '' then
begin
SetLength(s, Length(s)-1);
//showmessage(s);
frmListVendas.bRelVendas.dbSQL := frmListVendas.bRelVendas.dbSQL + ' WHERE Vendas.id IN (' + s +') ORDER BY Data_Venda';
end;
if (frmListVendas.TableGrid_Vendas.RowCount-1) = -1 then cancel := True;
end;
25 2018-11-09 11:26:44
Re: example of required fields? (8 replies, posted in General)
Thank you Derek