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
-
- /*
- ** TITIN - Get the book title information.
- **
- ** Retrieve the book information from the SQL Server.
- ** If there is no such book, display a message and reposition
- ** the cursor on the book field.
- ** This procedure is triggered by title field post-processing.
- */
-
- titin (context, argarray)
- FRSCONTEXT *context;
- POINTER argarray[];
- {
-
-
- DBPROCESS *dbproc;
- FORM *salesform;
- OBJDSC objdsc;
- OBJDSC *titlefld = &objdsc;
- char buf[BUFSIZE];
- char *title;
- int rows;
-
- salesform = fscurform(context);
- dbproc = (DBPROCESS *)argarray[0];
-
- /* Get the book title field */
- fsfgetfld(salesform, "title", -1, NULL, titlefld);
-
- /* Check whether the field has been modified: if not, there's no
- ** need to do anything. If it has been modified, reset the modified
- ** flag, so that it will reflect only new changes on later events.
- */
- if ( fsfisfldmod(titlefld) == FALSE)
- {
- return;
- }
- else
- {
- fsfclrfldflags(salesform, titlefld, FRS_MODIFIED);
- }
- title = fsfreadval(salesform, "title", -1, NULL, NULL, NULL);
-
- if (title == NULL)
- return; /* Nothing to process... */
-
- /* Run the query. */
- rows = fssql(dbproc,
- "select titleid = title_id, price from titles where title = '{title}'");
-
- switch(rows)
- {
- case 0:
- /* If no rows were retrieved, then complain. */
-
- fsmessage("Sorry, no such title.");
- fsfsetfldflags(salesform, titlefld, FRS_MODIFIED);
- fsfsetcurfld(context, titlefld);
- break;
-
- case 1:
- /* All is well. */
- break;
-
- default:
- fsabort("Attempt to read titles failed(fssql)");
- break;
- }
- return;
- }
-