⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdataenv.prg

📁 MSComm控件资料,Visual Basic 6.0(以下简称VB) 是一种功能强大、简单易学的程序设计语言。它不但保留了原先Basic语言的全部功能
💻 PRG
📖 第 1 页 / 共 5 页
字号:
	*      eMail 1: ctb@savvysolutions.com
	*      eMail 2: 76132.2575@compuserve.com
	*        Voice: (757)853-4465
	************************************************************
	FUNCTION ORIGINAL_GetLocalORRemoteDatabase( tcDefaultDatabase )

		*---------------------------------------------------
		*-- Determine if they are using local or remote data
		*---------------------------------------------------
		IF UPPER(goApp.GetSetting("Data Settings", "Use Local Data", "YES")) == "YES"
			*--------------------------------------------------------
			*-- Get the key for identifying the record in APPINCL.DBF
			*-- that stores the key for identifying which section
			*-- in the application's .INI file stores the pathname
			*-- of the LOCAL database for this business object.
			*--------------------------------------------------------
			lcKey = DBCLOCATION_LOCALKEY
			This.lUseLocalData = .T.
		ELSE
			*--------------------------------------------------------
			*-- Get the key for identifying the record in APPINCL.DBF
			*-- that stores the key for identifying which section
			*-- in the application's .INI file stores the pathname
			*-- of the REMOTE database for this business object.
			*--------------------------------------------------------
			lcKey = DBCLOCATION_REMOTEKEY
			This.lUseLocalData = .F.
		ENDIF && - UPPER(goApp.GetSetting("Data Settings" ...

		*----------------------------------------------------------------
		*-- Get the name of the default database for this application ...
		*-- The source of this information may come from one of two
		*-- places now
		*--   1.  Normal Codebook operation by going to the application
		*--       and determining where the user has placed the data
		*--   2.  Enhanced Codebook operation that examines the developer
		*--       populated properties, cDefaultLocalLocation or
		*--       cDefaultRemoteLocation.  The reason for this
		*--       modification was to enable SAVI to create multiple
		*--       database applications where the databases are each
		*--       located in separate directories.
		*----------------------------------------------------------------
		IF EMPTY( This.cDefaultLocalLocation ) AND EMPTY( This.cDefaultRemoteLocation )
			tcDefaultDatabase = ALLT(goApp.GetSetting(lcKey, This.cDefaultDatabaseName))
		ELSE
			IF This.lUseLocalData
				tcDefaultDatabase = This.cDefaultLocalLocation
			ELSE
				tcDefaultDatabase = This.cDefaultRemoteLocation
			ENDIF
		ENDIF
	ENDFUNC

	*-------------------- Location Section ---------------------
	*   Library: cDataEnv.PRG
	*   Class:   cDataEnvironment
	*   Method:  ORIGINAL_GetLocalORRemoteDatabase()
	*--------------------- Usage Section -----------------------
	*)  Description:
	*   Scope: PUBLIC
	*   Parameters: None
	*$  Usage:
	*%  Example:
	*   Returns:
	*------------------ Maintenance Section --------------------
	*@  Inputs:
	*   Outputs:
	*   Pre-condition Invariants:
	*   Post-condition Invariants:
	*?  Notes:
	*   Collaborating Methods:
	*-- Process:
	*   Change Log:
	*--------- (c) Flash Creative Management, Inc. -------------
	*---------------- Commenting Provided By -------------------
	*   Software Assets of Virginia, Inc. (SAVI)
	*   Charles T. Blankenship, President
	*   Compuserve: 76132,2575
	*     Internet: www.savvysolutions.com
	*      eMail 1: ctb@savvysolutions.com
	*      eMail 2: 76132.2575@compuserve.com
	*        Voice: (757)853-4465
	************************************************************
	FUNCTION SAVI_GetLocalORRemoteDatabase( tcDefaultDatabase )

		IF This.lUseLocalData
			tcDefaultDatabase = This.cDefaultLocalLocation
		ELSE
			tcDefaultDatabase = This.cDefaultRemoteLocation
		ENDIF

	ENDFUNC

ENDDEFINE

DEFINE CLASS CCursor AS Cursor

	*-------------------------------------------
	*-- Default values
	*-- Alias will default to This.CursorSource
	*-- Database is set in Init()
	*-------------------------------------------

	*----------------------------------------------------
	*-- Default the cursor to Optimistic Record Buffering
	*----------------------------------------------------
	BufferModeOverride = DB_BUFOPTRECORD
	Database = ""
	Filter = ""
	NoDataOnLoad = .F.
	Order = ""
	ReadOnly = .F.
	* Specifies the version number of this class.
	cVersion = "6.01.0001"

	FUNCTION Init()
		************************************************************
		*   Method:  CCursor.Init()
		*
		*)  Description:
		*)    Subclasses VFP's Cursor ... ensures an object cannot
		*)    be directly instantiated from this class ... ensures
		*)    that the cursor's parent object is associated with
		*)    a default database.
		*
		*@  Inputs: None
		*   Outputs:
		*     1.  Property - CCursor.Database
		*
		*$  Usage:
		*$    Cannot instantiate an object from this class.  See
		*$    ADATAENV.PRG for instructions on how to do This.
		*
		*   Returns:  LOGICAL
		*     .T. if the cursor could be created
		*     .F. if not
		*
		*   Assumptions: None
		*   Rules:
		*     1. Cannot instantiate an object from this class.
		*
		*   Constraints:
		*     Performance: None
		*     Enviornmental: None
		*?  Notes:
		*     1.  See ADATAENV.PRG for instructions on how to use this class
		*
		*   Local Routines:
		*     1. IsAbstract() - UTILTIY.PRG
		*     2. CCursor.GetDefaultDatabase()
		*
		*-- Process:
		*--   1.  Do not allow this class to be directly instantiated
		*--   2.  Determine the name of the default database
		*--       with which this cursor is associated
		*--   3.  IF no database could be found ...
		*--   4.     RETURN .F.
		*--       ENDIF
		*
		*   Change Log:
		*       CREATED Sunday, 11/05/95 17:16:49 - CTB:
		************************************************************
		*------------------------------------------------------
		*-- Do not allow this class to be directly instantiated
		*------------------------------------------------------
		IF IsAbstract(This.Class, "CCursor")
			RETURN .F.
		ENDIF

		*--------------------------------------------------
		*-- Determine the name of the default database
		*-- with which this cursor is associated
		*--------------------------------------------------
		This.Database = This.GetDefaultDatabase()

		*--------------------------------------------------
		*-- Don't allow the object to be created unless
		*-- a default database can be found.
		*--------------------------------------------------
		IF EMPTY(This.Database)
			RETURN .F.
		ENDIF

	ENDFUNC

	FUNCTION Release()
		RELEASE this
	ENDFUNC

	FUNCTION GetDefaultDatabase()
		************************************************************
		*   Method:  CCursor.GetDefaultDatabase() - CDATAENV.PRG
		*
		*)  Description:
		*)     Returns the name of the default database associated
		*)     with this business object's data environment.
		*
		*@  Inputs: None
		*     1. Property - CDataEnvironment.cDefaultDatabase
		*
		*   Outputs: None
		*
		*$  Usage:
		*$    <objectname>.GetDefaultDatabase()
		*
		*%  Example:
		*%    This.GetDefaultDatabase()
		*
		*   Returns:  CHARACTER - this object's parent's default database
		*
		*   Assumptions: None
		*   Rules:  None
		*   Constraints:
		*     Performance: None
		*     Enviornmental: None
		*?  Notes:
		*?    Remember that cursors are children of data environments.
		*?    This.PARENT resolves to the object name of this object's
		*?    data environment object name.
		*?
		*   Local Routines: None
		*-- Process: TBCL
		*   Change Log:
		*       CREATED Sunday, 11/05/95 17:30:16 - CTB:
		************************************************************
		
		*** EGL: 2001.12.28 8:52 -  Added support for separate view database
		***RETURN This.Parent.cDefaultDatabase
		LOCAL lcRetVal
		IF IsA(This, "CDynamicViewCursor") OR ;
				IsA(This, "CDistinctDynamicViewCursor")
			lcRetVal = This.Parent.cDefaultViewDatabase
		ELSE
			lcRetVal = This.Parent.cDefaultDatabase
		ENDIF
		
		RETURN lcRetVal
	ENDFUNC

ENDDEFINE

DEFINE CLASS CDynamicViewCursor AS iCursor
	*---------------------------------------------------------
	*-- A dynamic view is one that can either reference
	*-- local or remote data. Generic code assumes that local
	*-- views are named "lv_<name>" while remote views are
	*-- named "rv_<name>". Switching from local to remote will
	*-- cause the cursor source to change, but the alias
	*-- to remain the same: "v_<name>".
	*---------------------------------------------------------
	*-- Defaults.  Ensures that no queries are sent to the
	*-- backend at intitialization.  Faster screen loads.
	*---------------------------------------------------------
	NoDataOnLoad = .T.

	*------------------------
	*-- New custom properties
	*------------------------
	PROTECTED cCursorSource, ;
		lUseLocalData
	cCursorSource = ""
	lUseLocalData = .T.

	FUNCTION Init()
		************************************************************
		*   Method:  CDynamicViewCursor.Init() - CDATAENV.PRG
		*
		*)  Description:
		*)     This method ensures you can't directly instantiate
		*)     an object from this class.  It also creates a cursor
		*)     that can be told to access local or remote data
		*
		*@  Inputs:
		*@    1.  Property - CDataEnvironment.lUseLocalData
		*@    2.  Property - CDynamicViewCursor.Alias
		*@    3.  Property - CDynamicViewCursor.cCursorSource
		*
		*   Outputs:
		*     1.  Property - CDynamicViewCursor.lUseLocalData
		*     2.  Property - CDynamicViewCursor.CursorSource
		*     3.  Property - CDynamicViewCursor.Alias

		*   Returns:  LOGICAL
		*      .T. if the DynamicViewCursor could be created
		*      .F. if not
		*
		*   Assumptions: None
		*   Rules:
		*     1.  This class cannot be used to directly instantiate
		*         an object.
		*   Constraints:
		*     Performance: None
		*     Enviornmental: None
		*?  Notes:
		*?    1.  See ADataEnv.PRG for instructions on how to use
		*?        this class definition.
		*
		*   Local Routines:
		*     1.  IsAbstract() - in UTILTIY.PRG
		*     2.  CCursor::Init()
		*
		*-- Process:
		*--   1.  Define local variables
		*--   2.  Do not allow this class to be directly instantiated
		*--   3.  Determine if the data environment to which this cursor
		*--          belongs is using local or remote data.
		*--   4.  Save the alias name for later re-assignment.
		*--   5.  Populate CursorSource property with the
		*--          local or remote view, whichever applies.
		*--   6.  Reset the alias property to its original value.
		*--   7.  Try to create the cursor object.
		*
		*   Change Log:
		*       CREATED Sunday, 11/05/95 17:44:46 - CTB:
		************************************************************
		LOCAL lcPrefix, lcAlias
		*---------------------------------------------------------
		*           LOCAL/PRIVATE VARIABLE DESCRIPTIONS
		*---------------------------------------------------------
		* lcPrefix - stores "l" for local view or "r" for remote
		*            depending upon whether or not this DE is using
		*            local or remote data.
		* lcAlias - stores the alias name of this cursor
		*---------------------------------------------------------

		*------------------------------------------------------
		*-- Do not allow this class to be directly instantiated
		*------------------------------------------------------
		IF IsAbstract(This.Class, "CDynamicViewCursor")
			RETURN .F.
		ENDIF

		*---------------------------------------------------------
		*-- Determine if the data environment to which this cursor
		*-- belongs is using local or remote data.
		*---------------------------------------------------------
		This.lUseLocalData = This.Parent.lUseLocalData

		*-----------------------------------------------------------
		*-- Save the alias name for later re-assignment. (Currently,
		*-- the Alias property is getting set to the CursorSource
		*-- property automatically as soon as you assign a value
		*-- to CursorSource).
		*-----------------------------------------------------------
		lcAlias = ""
		IF !EMPTY(This.Alias)
			lcAlias = This.Alias
		ELSE
			lcAlias = This.cCursorSource
		ENDIF

		*--------------------------------------------------
		*-- Populate CursorSource property with the
		*-- local or remote view, whichever applies.
		*--------------------------------------------------
		lcPrefix = IIF(This.lUseLocalData, "l", "r")
		This.CursorSource = lcPrefix + This.cCursorSource

		*------------------
		*-- Reset the alias
		*------------------
		This.Alias = lcAlias

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -