home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a002 / 6.ddi / SAMPLE / APTFORMS / ADISC.C next >
Encoding:
C/C++ Source or Header  |  1990-08-24  |  1.3 KB  |  58 lines

  1. #include <sybfront.h>
  2. #include <sybdb.h>
  3. #include <sybfrs.h>
  4.  
  5. #if MSDOS
  6. #    include    <stdlib.h>
  7. #    include    "aforms.h"
  8. #endif /* MSDOS */
  9.  
  10. #define BUFSIZE 100
  11.  
  12. /*
  13. **    ADISC - Additional Discount
  14. **    
  15. **    Adjust the total discount using the newly entered "additional 
  16. **    discount".  This procedure is triggered by additional discount 
  17. **    field post-processing.
  18. */
  19. adisc(context, argarray)
  20. FRSCONTEXT           *context;
  21. POINTER              argarray[];
  22. {
  23.  
  24. #if !MSDOS && !OS2
  25.     extern            double   atof();
  26. #endif /* !MSDOS && !OS2 */
  27.  
  28.     FORM              *form;
  29.     DATADSC           *data;
  30.     DBFLT8            delta;
  31.     DBFLT8            discount;
  32.     char              buf[BUFSIZE];
  33.  
  34.     /* Get the form  */
  35.     form = fscurform(context);
  36.  
  37.     /* Get the difference between the new additional discount
  38.     ** and the old additional discount.
  39.     */
  40.     data = fsdcurddc(context);
  41.     delta = atof(fsdgetval(data)) - atof(fsdgetprvval(data));
  42.     
  43.     /* Get the current total discount */
  44.     fsfreadval(form, "totpercent", -1, NULL, &discount, NULL);
  45.     discount += delta;
  46.  
  47.     /* Update the form with the new total discount */
  48.     fsfwriteval(form, "totpercent", -1, NULL, -1, SSOFF,
  49.         &discount, buf, -1, FALSE);
  50.  
  51.  
  52.     /* Call a routine to compute and display the total cost. */
  53.     clcst(form, "quantity", "totpercent", "price", "totalcost");
  54.  
  55.     /* All done! */
  56.     return;
  57. }
  58.