home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a063 / 6.img / SAMPLE / APTFORMS / INVAL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-24  |  1.2 KB  |  61 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. /*
  10. **    INVAL - Insert the sale values in the database.
  11. **    
  12. **    This procedure is triggered by the user picking the "Insert" option.
  13. */
  14.  
  15. inval(context, argarray)
  16. FRSCONTEXT       *context;
  17. POINTER          argarray[];
  18. {
  19.  
  20.     FORM           *salesform;
  21.     DBPROCESS      *dbproc;
  22.     int            rows;
  23.     OBJDSC         objdsc;
  24.     OBJDSC         *storefld = &objdsc;
  25.  
  26.     /* Get the form */
  27.     salesform = fscurform(context);
  28.  
  29.     dbproc = (DBPROCESS *)argarray[0];
  30.  
  31.     /* Compute the total cost and display it on the form */
  32.     if (clcst(salesform, "quantity", "discount", "price", "total")
  33.         == FAIL)
  34.     {
  35.         return;
  36.     }
  37.  
  38.     /* Insert the new sale. */
  39.     rows = fssql(dbproc, 
  40.         "insert sales values ('{storeid}', '{ordernum}', '{orderdate}', \
  41.         convert(smallint ,'{quantity}'), '{terms}','{titleid}')");
  42.  
  43.     if (rows == -1)
  44.     {
  45.         fsmessage("Insert failed.");
  46.     }
  47.     else
  48.     {
  49.         fsmessage("Values successfully inserted.");
  50.     }
  51.  
  52.     /* Return the cursor to store name field, defined as the 
  53.     ** initial field in the form's tab order.
  54.     */
  55.     fsfsetcurfld(context,
  56.         fsfgetfld(salesform, "storename", -1, NULL, storefld) );
  57.  
  58.     /* All done! */
  59.     return;
  60. }
  61.