home *** CD-ROM | disk | FTP | other *** search
- #include <sybfront.h>
- #include <sybdb.h>
- #include <sybfrs.h>
-
- #if MSDOS
- # include "aforms.h"
- #endif /* MSDOS */
-
- #define BUFSIZE 100
-
- /*
- ** RGDSC - Regular Discount
- **
- ** One of the "regular" discounts has been chosen or dropped.
- ** Adjust the total discount accordingly.
- ** This procedure is triggered by the regular discount "pick" field
- ** pick processing.
- */
-
- rgdsc(context, argarray)
- FRSCONTEXT *context;
- POINTER argarray[];
- {
-
- FORM *form;
- OBJINDEX objindex;
- OBJINDEX *rowindex = &objindex;
- DBFLT8 delta;
- DBFLT8 discount;
- char buf[BUFSIZE];
- char *sign;
-
- /* Get the form. */
- form = fscurform(context);
-
- /* This routine was called because the user toggled a discount pick
- ** field. First step is to get the discount for this pick.
- */
- fsggetindex(fsfcurfld(context), rowindex),
- fsfreadval(form, "percent", -1, rowindex, &delta, NULL);
-
- /* Find out whether the discount was turned on or off. */
- sign = fsfreadval(form, NULL, -1, NULL, NULL, NULL);
- if (strcmp(sign, "no") == 0)
- {
- delta *= -1;
- }
-
- /* Get the current total discount .*/
- fsfreadval(form, "totpercent", -1, NULL, &discount, NULL);
- discount += delta;
-
- /* Update the form with the new total discount. */
- fsfwriteval(form, "totpercent", -1, NULL, -1, SSOFF,
- &discount, buf, -1, FALSE);
-
- /* Call a routine to compute and display the new total cost. */
- clcst(form, "quantity", "totpercent", "price", "totalcost");
-
- /* All done! */
-
- return;
- }
-