home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a063 / 6.img / SAMPLE / APTFORMS / RGDSC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-24  |  1.5 KB  |  64 lines

  1. #include <sybfront.h>
  2. #include <sybdb.h>
  3. #include <sybfrs.h>
  4.  
  5. #if MSDOS
  6. #    include    "aforms.h"
  7. #endif /* MSDOS */
  8.  
  9. #define BUFSIZE 100
  10.  
  11. /*
  12. **    RGDSC - Regular Discount
  13. **    
  14. **    One of the "regular" discounts has been chosen or dropped.
  15. **    Adjust the total discount accordingly.
  16. **    This procedure is triggered by the regular discount "pick" field
  17. **    pick processing.
  18. */
  19.  
  20. rgdsc(context, argarray)
  21. FRSCONTEXT      *context;
  22. POINTER         argarray[];
  23. {
  24.  
  25.     FORM           *form;
  26.     OBJINDEX       objindex;
  27.     OBJINDEX       *rowindex = &objindex;
  28.     DBFLT8         delta;
  29.     DBFLT8         discount;
  30.     char           buf[BUFSIZE];
  31.     char           *sign;
  32.  
  33.     /* Get the form. */
  34.     form = fscurform(context);
  35.  
  36.     /* This routine was called because the user toggled a discount pick
  37.     ** field.  First step is to get the discount for this pick.
  38.     */
  39.     fsggetindex(fsfcurfld(context), rowindex),
  40.     fsfreadval(form, "percent", -1, rowindex, &delta, NULL);
  41.  
  42.     /* Find out whether the discount was turned on or off. */
  43.     sign = fsfreadval(form, NULL, -1, NULL, NULL, NULL);
  44.     if (strcmp(sign, "no") == 0)
  45.     {
  46.         delta *= -1;
  47.     }
  48.  
  49.     /* Get the current total discount .*/
  50.     fsfreadval(form, "totpercent", -1, NULL, &discount, NULL);
  51.     discount += delta;
  52.  
  53.     /* Update the form with the new total discount. */
  54.     fsfwriteval(form, "totpercent", -1, NULL, -1, SSOFF,
  55.         &discount, buf, -1, FALSE);
  56.  
  57.     /* Call a routine to compute and display the new total cost. */
  58.     clcst(form, "quantity", "totpercent", "price", "totalcost");
  59.  
  60.     /* All done! */
  61.  
  62.     return;
  63. }
  64.