microbiano
01-05-2012, 03:39:55
bien resulta que quiero comparar la fecha que tengo registrada en el sistema conla fecha del servidor, y si es menor entonces modifique una columna de pago tardio, pero no logro ahcer que funcione. lo hago de la isguiente manera.
obtengo la fecha del Servidor asi.
WFechaServidor:TDate;
procedure TFmodulo.FechaServidor;
var I:Integer;
begin
with Fmodulo.QryTemp do
begin
close;
sql.Clear;
SQL.Add('SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [Fecha]');
try
Open;
if (not Eof) then
begin
wfechaservidor:=StrToDate(FieldByname('Fecha').AsString);//aqui pongo la fecha del servidor
DecodeDate(Wfechaservidor,anio,Mes,Dia);
if Anio<>0 then
begin
wanioString:=IntToStr(Anio);
end;
end;
except
on E:EOleException do
begin
MessageDlg(Format('Error: %s Codigo: %d', [E.Message, E.ErrorCode]), mtError, [mbOK], 0);
end;
end;
end;
end;
y entonces despues genero 12 recibos en un modulo de cuentas por cobrar y para poder modificar la situacion de cada recibo lo hago de la siguiente manera.
function tfrmrecibos.CargaMeses(IdContrato:string):string;
var wStatus:string;
WfechaRegistro:TDate;
begin
with fmodulo.QryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from sap_prerecibos');
sql.Add('where nocontrato=:Pnocontrato and fechaPago is null');
Parameters.ParamByName('Pnocontrato').Value:=Idcontrato;
try
Open;
while (not Eof) do
begin
cbb_1.Items.Add(FieldByname('concepto').AsString);
WfechaRegistro:=(FieldByName('fechafinpago').AsDateTime);
if Trunc(WfechaRegistro) < trunc(Fmodulo.WFechaServidor) then //aqui es donde hago la validacion pero no funciona me cambia la columna de todos los registros aqui valida la fecha de fin de pago que son 12 recibos de enero a diciembre y fechafin de pago es el 30 de cada mes
wStatus:='S';
begin
with Fmodulo. QryTemporal do
begin
SQL.Clear;
SQL.Add('update sap_prerecibos set interes=:pstatus');
SQL.Add('where nocontrato=:pcontrato and FechaPago is null');
Parameters.ParamByName('Pcontrato').Value:=Idcontrato;
Parameters.ParamByName('Pstatus').Value:=Trim(wStatus);
ExecSQL;
end;
end;
Next;
end;
except
on e:eoleException do
begin
end;
end;
end;
end;
alguna sugerencia? de antemano muchas gracias
obtengo la fecha del Servidor asi.
WFechaServidor:TDate;
procedure TFmodulo.FechaServidor;
var I:Integer;
begin
with Fmodulo.QryTemp do
begin
close;
sql.Clear;
SQL.Add('SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [Fecha]');
try
Open;
if (not Eof) then
begin
wfechaservidor:=StrToDate(FieldByname('Fecha').AsString);//aqui pongo la fecha del servidor
DecodeDate(Wfechaservidor,anio,Mes,Dia);
if Anio<>0 then
begin
wanioString:=IntToStr(Anio);
end;
end;
except
on E:EOleException do
begin
MessageDlg(Format('Error: %s Codigo: %d', [E.Message, E.ErrorCode]), mtError, [mbOK], 0);
end;
end;
end;
end;
y entonces despues genero 12 recibos en un modulo de cuentas por cobrar y para poder modificar la situacion de cada recibo lo hago de la siguiente manera.
function tfrmrecibos.CargaMeses(IdContrato:string):string;
var wStatus:string;
WfechaRegistro:TDate;
begin
with fmodulo.QryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from sap_prerecibos');
sql.Add('where nocontrato=:Pnocontrato and fechaPago is null');
Parameters.ParamByName('Pnocontrato').Value:=Idcontrato;
try
Open;
while (not Eof) do
begin
cbb_1.Items.Add(FieldByname('concepto').AsString);
WfechaRegistro:=(FieldByName('fechafinpago').AsDateTime);
if Trunc(WfechaRegistro) < trunc(Fmodulo.WFechaServidor) then //aqui es donde hago la validacion pero no funciona me cambia la columna de todos los registros aqui valida la fecha de fin de pago que son 12 recibos de enero a diciembre y fechafin de pago es el 30 de cada mes
wStatus:='S';
begin
with Fmodulo. QryTemporal do
begin
SQL.Clear;
SQL.Add('update sap_prerecibos set interes=:pstatus');
SQL.Add('where nocontrato=:pcontrato and FechaPago is null');
Parameters.ParamByName('Pcontrato').Value:=Idcontrato;
Parameters.ParamByName('Pstatus').Value:=Trim(wStatus);
ExecSQL;
end;
end;
Next;
end;
except
on e:eoleException do
begin
end;
end;
end;
end;
alguna sugerencia? de antemano muchas gracias