home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / samples.z / excel70.wxf < prev    next >
Encoding:
Text File  |  1996-05-06  |  8.1 KB  |  363 lines

  1. Save Format v1.3
  2. @begin Form "WinExcel70"
  3.  Exported 0;
  4.  
  5.  @begin Object "WDialog"
  6.   WSCaption 1;
  7.   WSSizeable 1;
  8.   WSDlgBorder 1;
  9.   WSSysMenu 1;
  10.   WSSystemMenu 1;
  11.   WSMinimizeBox 1;
  12.   WSMaximizeBox 1;
  13.   WSGroup 1;
  14.   WSTabStop 1;
  15.   WSResizeBorder 1;
  16.   WSVisible 1;
  17.   FormPositionType "Centered";
  18.   FormAbsTop "219";
  19.   FormAbsLeft "265";
  20.   FDXStructName "WinExcel70FDXStruct";
  21.   Font "8.MS Sans Serif";
  22.   Text "Microsoft Excel 7.0 Example";
  23.   @begin Event "Create"
  24.    GencodeSrcLine 222;
  25.    FunctionName "WinExcel70::WinExcel70_Create";
  26.   @end;
  27.   @begin UserFunction "WinExcel70()"
  28.    Compiler 1;
  29.    GencodeSrcLine 236;
  30.    FunctionName "WinExcel70::WinExcel70()";
  31.   @end;
  32.   @begin UserFunction "~WinExcel70()"
  33.    Compiler 1;
  34.    GencodeSrcLine 240;
  35.    FunctionName "WinExcel70::~WinExcel70()";
  36.   @end;
  37.   @begin UserFunction "Process( WWindow *parent )"
  38.    GencodeSrcLine 244;
  39.    FunctionName "WinExcel70::Process( WWindow *parent )";
  40.   @end;
  41.   @begin UserFunction "Prototype for Process( WWindow *parent )"
  42.    Private 1;
  43.    GencodeSrcLine 66;
  44.    FunctionName "WinExcel70::Prototype for Process( WWindow *parent )";
  45.   @end;
  46.   ResID 105;
  47.   DesignName WinExcel70;
  48.   TabIndex 0;
  49.   DesignRect 262,218,222,94;
  50.  @end;
  51.  
  52.  @begin Object "WQuery"
  53.   BindLimit "0";
  54.   ConcurrencyLevel "WQCLLock";
  55.   CursorType "WQCTDynamic";
  56.   SQL "select * from `Company`\r\norder by Employee";
  57.   Transaction "WinExcel70::transaction_excel70";
  58.   AutoOpen "0";
  59.   ResID 101;
  60.   DesignName query_excel70;
  61.   TabIndex 0;
  62.   DesignRect 10,55,19,17;
  63.  @end;
  64.  
  65.  @begin Object "WLabel"
  66.   WSSLeftNoWordWrap 1;
  67.   WSSNotify 1;
  68.   WCCSNoResize 1;
  69.   WCCSNoParentAlign 1;
  70.   WSChild 1;
  71.   WSMinimizeBox 1;
  72.   WSGroup 1;
  73.   WSVisible 1;
  74.   AutoSize "1";
  75.   Text "Employee:";
  76.   ResID 102;
  77.   DesignName label_1;
  78.   TabIndex 0;
  79.   DesignRect 10,10,33,8;
  80.  @end;
  81.  
  82.  @begin Object "WTransaction"
  83.   DataSource "Excel 7.0 Optima Example";
  84.   AutoConnect "0";
  85.   ResID 103;
  86.   DesignName transaction_excel70;
  87.   TabIndex 1;
  88.   DesignRect 30,55,19,17;
  89.  @end;
  90.  
  91.  @begin Object "WTextBox"
  92.   WTextBoxAutoHScroll 1;
  93.   WSBorder 1;
  94.   WSChild 1;
  95.   WSMaximizeBox 1;
  96.   WSTabStop 1;
  97.   WSExClientEdge 1;
  98.   WSVisible 1;
  99.   DataColumns "Employee";
  100.   DataSource "WinExcel70::query_excel70";
  101.   FDXFieldName "textb_1_data";
  102.   FDXFieldType "WString";
  103.   ResizePercentages "[ 0 0 100 0 ]";
  104.   ResID 104;
  105.   DesignName textb_1;
  106.   TabIndex 1;
  107.   DesignRect 60,10,145,12;
  108.  @end;
  109.  
  110.  @begin Object "WLabel"
  111.   WSSLeftNoWordWrap 1;
  112.   WSSNotify 1;
  113.   WCCSNoResize 1;
  114.   WCCSNoParentAlign 1;
  115.   WSChild 1;
  116.   WSVisible 1;
  117.   AutoSize "1";
  118.   Text "Start date:";
  119.   ResID 105;
  120.   DesignName label_2;
  121.   TabIndex 2;
  122.   DesignRect 10,25,30,8;
  123.  @end;
  124.  
  125.  @begin Object "WTextBox"
  126.   WTextBoxAutoHScroll 1;
  127.   WSBorder 1;
  128.   WSChild 1;
  129.   WSMaximizeBox 1;
  130.   WSTabStop 1;
  131.   WSExClientEdge 1;
  132.   WSVisible 1;
  133.   DataColumns "StartDate";
  134.   DataSource "WinExcel70::query_excel70";
  135.   FDXFieldName "textb_2_data";
  136.   FDXFieldType "WString";
  137.   ResizePercentages "[ 0 0 100 0 ]";
  138.   ResID 106;
  139.   DesignName textb_2;
  140.   TabIndex 3;
  141.   DesignRect 60,25,145,12;
  142.  @end;
  143.  
  144.  @begin Object "WLabel"
  145.   WSSLeftNoWordWrap 1;
  146.   WSSNotify 1;
  147.   WCCSNoResize 1;
  148.   WCCSNoParentAlign 1;
  149.   WSChild 1;
  150.   WSVisible 1;
  151.   AutoSize "1";
  152.   Text "Salary:";
  153.   ResID 107;
  154.   DesignName label_3;
  155.   TabIndex 4;
  156.   DesignRect 10,40,21,8;
  157.  @end;
  158.  
  159.  @begin Object "WTextBox"
  160.   WTextBoxAutoHScroll 1;
  161.   WSBorder 1;
  162.   WSChild 1;
  163.   WSMaximizeBox 1;
  164.   WSTabStop 1;
  165.   WSExClientEdge 1;
  166.   WSVisible 1;
  167.   DataColumns "Salary";
  168.   DataSource "WinExcel70::query_excel70";
  169.   FDXFieldName "textb_3_data";
  170.   FDXFieldType "WString";
  171.   ResizePercentages "[ 0 0 100 0 ]";
  172.   ResID 108;
  173.   DesignName textb_3;
  174.   TabIndex 5;
  175.   DesignRect 60,40,145,12;
  176.  @end;
  177.  
  178.  @begin Object "WDataNavigator"
  179.   WSChild 1;
  180.   WSMaximizeBox 1;
  181.   WSTabStop 1;
  182.   WSVisible 1;
  183.   BOFAction "WDNActionMoveFirst";
  184.   DataSource "WinExcel70::query_excel70";
  185.   EOFAction "WDNActionMoveLast";
  186.   ShowAdd "1";
  187.   ShowCancel "1";
  188.   ShowDelete "1";
  189.   ShowEdit "1";
  190.   ShowMoveFirst "1";
  191.   ShowMoveLast "1";
  192.   ShowMoveNext "1";
  193.   ShowMovePrevious "1";
  194.   ShowRefresh "1";
  195.   ShowUpdate "1";
  196.   ResID 109;
  197.   DesignName datanavigator_1;
  198.   TabIndex 6;
  199.   DesignRect 60,60,147,13;
  200.  @end;
  201.  
  202.  @begin HPPPrefixBlock
  203. @begin-code HPPPrefix
  204.  
  205. // Declarations added here will be included at the top of the .HPP file
  206.  
  207. @end-code;
  208.   GencodeSrcLine 13;
  209.  @end;
  210.  
  211.  @begin CPPPrefixBlock
  212. @begin-code CPPPrefix
  213.  
  214. // Code added here will be included at the top of the .CPP file
  215.  
  216. static WChar *Driver_keys[]={
  217.     WTEXT( "Description" ), WTEXT( "" ),
  218.     WTEXT( "ScanRows" ), WTEXT( "25" ),
  219.     WTEXT( "FileOpenCache" ), WTEXT( "0" ),
  220.     WTEXT( "CacheSize" ), WTEXT( "256" ),
  221.     WTEXT( "IntlSort" ), WTEXT( "0" ),
  222.     WTEXT( "CharacterLengthGuessing" ), WTEXT( "0" ),
  223.     NULL
  224. };
  225.  
  226. static WChar Driver[]=
  227.     WTEXT( "INTERSOLV OEM 2.12 32-BIT Excel5Workbook" );
  228.     
  229. static WChar Datasource[]= WTEXT( "Excel 7.0 Optima Example" );
  230.  
  231. static WChar DBFile[]= WTEXT( "excel70.xls" );
  232.  
  233. //  Include definitions for resources.
  234. #include "WRes.h"
  235. #include "odbcadm.hpp"
  236. #include "applic.hpp"
  237.  
  238. @end-code;
  239.   GencodeSrcLine 10;
  240.  @end;
  241.  
  242.  @begin ClassContentsBlock
  243. @begin-code ClassContents
  244.  
  245.     public:
  246.         // add your public instance data here
  247.     private:
  248.         // add your private instance data here
  249.         WString                     _dbfile;
  250.         
  251.     protected:
  252.         // add your protected instance data here
  253.  
  254. @end-code;
  255.   GencodeSrcLine 58;
  256.  @end;
  257.  
  258. @begin-code GeneratedClassContents
  259.  
  260.         WinExcel70();
  261.         ~WinExcel70();
  262.  
  263. @end-code;
  264.  
  265. @begin-code Code "WinExcel70::WinExcel70()"
  266.  
  267. WinExcel70::WinExcel70()
  268. {
  269.     
  270. }
  271.  
  272. @end-code;
  273.  
  274. @begin-code Code "WinExcel70::~WinExcel70()"
  275.  
  276. WinExcel70::~WinExcel70()
  277. {
  278.     
  279. }
  280.  
  281. @end-code;
  282.  
  283. @begin-code Code "WinExcel70::Process( WWindow *parent )"
  284.  
  285. WBool WinExcel70::Process( WWindow *parent )
  286. {
  287.     WString             driver_dll;
  288.     WStringArray        keys;
  289.     int                 i;
  290.     WString             db_file;
  291.     WFilePath           path;
  292.     WString             dir;
  293.     
  294.     if( !ODBCAdmin::DriverExists( Driver, driver_dll ) ) {
  295.         WMessageBox::Messagef( parent, WMBLevelError, WMBButtonOk, "Driver Error",
  296.                 "The ODBC Driver '%s' is not installed. Data source cannot "
  297.                 "be created.", Driver );
  298.         return( FALSE );
  299.     }
  300.     
  301.     for( i = 0; Driver_keys[i] != NULL; ++i );
  302.     keys.SetCount( i + 4 );
  303.     for( i = 0; Driver_keys[i] != NULL; ++i ) {
  304.         keys[i] = Driver_keys[i];
  305.     }
  306.     keys[i] = WTEXT( "Driver" );
  307.     keys[i + 1] = driver_dll;
  308.     keys[i + 2] = WTEXT( "Database" );
  309.     db_file = Application->GetProgramPath();
  310.     path = db_file;
  311.     dir = path.GetDirectory();
  312.     dir.Concat( "\\.." );
  313.     path.SetFileName( DBFile );
  314.     path.SetDirectory( dir );
  315.     path.CleanDirectory();
  316.     if( !path.Exists() ) {
  317.         WMessageBox::Messagef( parent, WMBLevelError, WMBButtonOk, "Data source Error",
  318.                 "The data file '%s' could not be found", path.GetText() );
  319.         return( FALSE );
  320.     }
  321.     keys[i + 3] = path;
  322.     _dbfile = path;
  323.  
  324.     if( !ODBCAdmin::AddDataSource( Datasource, Driver, keys ) ) {
  325.         WMessageBox::Messagef( parent, WMBLevelError, WMBButtonOk, "Data source Error",
  326.                 "The ODBC Datasource '%s' could not be installed", Datasource );
  327.         return( FALSE );
  328.     }
  329.  
  330.     Create( parent );
  331.     
  332.     return( FALSE );
  333. }
  334.  
  335. @end-code;
  336.  
  337. @begin-code Code "WinExcel70::Prototype for Process( WWindow *parent )"
  338.  
  339.     public:
  340.         WBool Process( WWindow *parent );
  341.  
  342. @end-code;
  343.  
  344. @begin-code Code "WinExcel70::WinExcel70_Create"
  345.  
  346. WBool WinExcel70::WinExcel70_Create(
  347.     WObject *               source,
  348.     WCreateEventData *      event )
  349. {
  350.     WString                 connect_parms;
  351.     
  352.     connect_parms.Sprintf( "database=%s", _dbfile.GetText() );
  353.     transaction_excel70->SetConnectParams( connect_parms );
  354.     transaction_excel70->Connect();
  355.     query_excel70->Open();
  356.     query_excel70->MoveFirst();
  357.     
  358.     return FALSE;
  359. }
  360.  
  361. @end-code;
  362. @end;
  363.