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

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