Ver Mensaje Individual
  #2  
Antiguo 15-06-2018
Avatar de gmontes
gmontes gmontes is offline
Miembro
 
Registrado: jul 2004
Ubicación: Culiacán, Sinaloa, México
Posts: 668
Reputación: 20
gmontes Va por buen camino
yo lo hago con componentes zeos asi



este es un codigo que no he revisado en años, pero es de una aplicacion que funciona





Código Delphi [-]
 //inicia transaccion
   DMSIU.zcDBase.StartTransaction;
   try
   
     with DMSIU.zqryModifica do
      begin
        Close;
        SQL.Clear;
        SQL.Add('SELECT * FROM ocxc WHERE clavef = '''+inttostr(iClavef)+'''');
        Open;
        if not (Eof) then
         Begin
          //Application.MessageBox('El documento ya existe en cobranza.', 'Error', MB_OK);
          bAcepta:=False;
         end;
        Close;
      end;
      if bAcepta then
       begin
        with DMSIU.zqryModifica do
         begin
          Close;
          SQL.Clear;
          SQL.Add('SELECT * FROM oconcxc WHERE codigo = ''FAC''');
          Open;
          iClaveConCxC :=0;
          if not (Eof) then
           iClaveConCxC:=FieldByname('claveccxc').asinteger;
          Close;
         end;

        sFechacxc:=copy(datetostr(date),7,4)+'/'+copy(datetostr(date),4,2)+'/'+copy(datetostr(date),1,2);
        sFechaven:=copy(datetostr(date+30),7,4)+'/'+copy(datetostr(date+30),4,2)+'/'+copy(datetostr(date+30),1,2);
        sFechae:=copy(sFechae,7,4)+'/'+copy(sFechae,4,2)+'/'+copy(sFechae,1,2);
        with DMSIU.zqryModifica do
         begin
          Close;
          SQL.Clear;
          SQL.Add('INSERT INTO ocxc (clavec, claveccxc, clavef, documento, docto, referencia, importe, pagado, fechaaplic, fechavenc, fechaelab, estado, condicion,serie,folio) VALUES('''+IntToStr(iClavec)+''','''+IntToStr(iClaveConCxC)+''',');
          SQL.Add(''''+IntToStr(iClavef)+''','''+sDocumento+''','''+sDocumento+''','''+sDocumento+''','''+floa  ttostr(nImportet)+''',''0.0'','''+sFechacxc+''',');
          SQL.Add(''''+sFechaven+''','''+sFechae+''','''+sEstatus+''','''+'Credito'+''','''+LeftStr(sDocumento  ,1)+''','''+Trim(Copy(sDocumento,2,Length(sDocumento)))+''')');
          ExecSQL;
          Close;
          SQL.Clear;
         end;
       end; //bAcepta

    //transaccion
    //Application.MessageBox('Datos capturados', 'Aceptar', MB_OK);
    DMSIU.zcDBase.Commit;
   except
    Application.MessageBox('Error en datos', 'Aceptar', MB_OK);
    DMSIU.zcDBase.Rollback;
   end;
   //transaccion
__________________
Todos llevamos nuestros demonios a cuestas..
Responder Con Cita