home *** CD-ROM | disk | FTP | other *** search
- #include <sybfront.h>
- #include <sybdb.h>
- #include <sybfrs.h>
-
- #if MSDOS
- # include "aforms.h"
- #endif /* MSDOS */
-
- /*
- ** STRIN - Get the store information.
- **
- ** Retrieve the store information from the SQL Server.
- ** If there is no such store, display a message and reposition
- ** the cursor on the store field.
- ** This procedure is triggered by storename field post-processing.
- */
-
- strin (context, argarray)
- FRSCONTEXT *context;
- POINTER argarray[];
- {
-
- DBPROCESS *dbproc;
- FORM *salesform;
- OBJDSC objdsc;
- OBJDSC *storefld = &objdsc;
- char *storename;
- int rows;
-
- dbproc = (DBPROCESS *)argarray[0];
- salesform = fscurform(context);
-
- /* Get the store name field */
- fsfgetfld(salesform, "storename", -1, NULL, storefld);
-
- /* 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(storefld) == FALSE)
- {
- return;
- }
- else
- {
- fsfclrfldflags(salesform, storefld, FRS_MODIFIED);
- }
-
- /* Get the user-entered store name. */
-
- storename = fsfreadval(salesform, "storename", -1,
- NULL, NULL, NULL);
-
- /* If the name is empty, skip the edits */
- if (storename == NULL || storename[0] == '\0')
- return;
-
- /* Run the query for the store information. */
-
- rows = fssql(dbproc,
- "select storeid = stor_id, city, state, zip from stores \
- where stor_name='{storename}'");
-
- switch(rows)
- {
- case 0:
- /* If no rows were retrieved, then complain. */
-
- fsmessage("Sorry, no such bookstore");
- fsfsetfldflags(salesform, storefld, FRS_MODIFIED);
- fsfsetcurfld(context, storefld);
- break;
-
- case 1:
- /* All is well. */
- break;
-
- default:
- fsabort("Attempt to read bookstores failed(fssql)");
- break;
- }
- return;
- }
-