home *** CD-ROM | disk | FTP | other *** search
- #include <sybfront.h>
- #include <sybdb.h>
- #include <sybfrs.h>
-
- #if MSDOS
- # include "aforms.h"
- #endif /* MSDOS */
-
- /*
- ** INVAL - Insert the sale values in the database.
- **
- ** This procedure is triggered by the user picking the "Insert" option.
- */
-
- inval(context, argarray)
- FRSCONTEXT *context;
- POINTER argarray[];
- {
-
- FORM *salesform;
- DBPROCESS *dbproc;
- int rows;
- OBJDSC objdsc;
- OBJDSC *storefld = &objdsc;
-
- /* Get the form */
- salesform = fscurform(context);
-
- dbproc = (DBPROCESS *)argarray[0];
-
- /* Compute the total cost and display it on the form */
- if (clcst(salesform, "quantity", "discount", "price", "total")
- == FAIL)
- {
- return;
- }
-
- /* Insert the new sale. */
- rows = fssql(dbproc,
- "insert sales values ('{storeid}', '{ordernum}', '{orderdate}', \
- convert(smallint ,'{quantity}'), '{terms}','{titleid}')");
-
- if (rows == -1)
- {
- fsmessage("Insert failed.");
- }
- else
- {
- fsmessage("Values successfully inserted.");
- }
-
- /* Return the cursor to store name field, defined as the
- ** initial field in the form's tab order.
- */
- fsfsetcurfld(context,
- fsfgetfld(salesform, "storename", -1, NULL, storefld) );
-
- /* All done! */
- return;
- }
-