Fórum não pode confirmar se tiver campo vazio #185119
29/09/2003
0
Tem algum forma mais prátoca para q tipo em um formulario quando vamos confirmar inclusões por exemplo, todos os dbetis não pode estar vazios, sem ter q fazer aquele monte de ifs, ou fazer referencial integridade pela estrutura da tabela, existe alguma coisa mais fácil?
Janete
Curtir tópico
+ 0
Responder
Posts
29/09/2003
Mmtoor
determine em sua tabela que o campo é requerido, ou seja, não será aceito campo null.
Pode aplicar esta regra para qualquer tipo de BD.
MMTOOR2003
Pode aplicar esta regra para qualquer tipo de BD.
MMTOOR2003
Responder
Gostei + 0
29/09/2003
Luizfernando777
Funciona o q nosso colega disse,
mas acho que a menssagem vai ficar em ingles,
nosso cliente vai gostar disso,
experimente isso
function PreencherCampos( DataSet: TDataSet);
var
Texto : String;
OK : Boolean;
begin
Texto := ´´;
OK := False;
for I := 0 to DataSet.Fields.Count-1 do
begin
{
os números o case que eu coloquei são os que
eu preciso, caso você precise de todos
então no lugar do case faz o seguinte:
for I := 0 to DataSet.Fields.Count-1 do
if DataSet.Fields[i].IsNull then
OK := True;
}
case I of
5 : OK := DataSet.Fields[i].IsNull;
6 : OK := DataSet.Fields[i].IsNull;
7 : OK := DataSet.Fields[i].IsNull;
8 : OK := DataSet.Fields[i].IsNull;
9 : OK := DataSet.Fields[i].IsNull;
10 : OK := DataSet.Fields[i].IsNull;
11 : OK := DataSet.Fields[i].IsNull;
end; // case
if OK then
if DataSet.Fields[i].IsNull then
Texto := DataSet.Fields[i].DisplayLabel;
if Texto <> ´´ then
begin
Application.MessageBox(PChar(Format( ´Favor preencher o campo ´ ¬s ´´, [ Texto ] )),
´Atenção´, MB_ICONWARNING+MB_OK);
Texto := ´´;
Abort;
end;// if
end; // for
end;
mas acho que a menssagem vai ficar em ingles,
nosso cliente vai gostar disso,
experimente isso
function PreencherCampos( DataSet: TDataSet);
var
Texto : String;
OK : Boolean;
begin
Texto := ´´;
OK := False;
for I := 0 to DataSet.Fields.Count-1 do
begin
{
os números o case que eu coloquei são os que
eu preciso, caso você precise de todos
então no lugar do case faz o seguinte:
for I := 0 to DataSet.Fields.Count-1 do
if DataSet.Fields[i].IsNull then
OK := True;
}
case I of
5 : OK := DataSet.Fields[i].IsNull;
6 : OK := DataSet.Fields[i].IsNull;
7 : OK := DataSet.Fields[i].IsNull;
8 : OK := DataSet.Fields[i].IsNull;
9 : OK := DataSet.Fields[i].IsNull;
10 : OK := DataSet.Fields[i].IsNull;
11 : OK := DataSet.Fields[i].IsNull;
end; // case
if OK then
if DataSet.Fields[i].IsNull then
Texto := DataSet.Fields[i].DisplayLabel;
if Texto <> ´´ then
begin
Application.MessageBox(PChar(Format( ´Favor preencher o campo ´ ¬s ´´, [ Texto ] )),
´Atenção´, MB_ICONWARNING+MB_OK);
Texto := ´´;
Abort;
end;// if
end; // for
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)