// Testing Unicode Chinese Language
#include "Fivewin.ch"
#include "Report.ch"
#include "print.ch"
#include "xbrowse.ch"
#include "Ads.ch"
REQUEST ADS, ADSKeyNo, ADSKeyCount, ADSGetRelKeyPos, ADSSetRelKeyPos
REQUEST DBFCDX
//----------------------------------------------------------------------------//
FUNCTION Main()
LOCAL oApp
oApp := TTestUnicodeDll():New()
RETURN NIL
//---------------------------------------------------------------------------//
INIT FUNCTION App_Init()
SET SERVER LOCAL
SET FILETYPE TO CDX
SET AXS LOCKING ON
AdsRightsCheck(.F.) &&'設 .T. 無法開啟 除 ADS外DBF 設 .F. 不限
SET _3DLook ON
SET RESOURCES TO 'TestUnicodeDll.DLL'
SET DELETE ON
SET SoftSeek On
SET DATE FORMAT "YYYY.MM.DD"
SET OPTIMIZE ON
FW_SetUniCode(.T.)
RETURN NIL
//---------------------------------------------------------------------------//
EXIT FUNCTION App_Exit()
SET 3DLook OFF
SET RESOURCES TO
RETURN NIL
//---------------------------------------------------------------------------//
CLASS TTestUnicodeDll
DATA oWnd
DATA oBar
METHOD New() CONSTRUCTOR
METHOD MenuBuild()
METHOD DrawMsgBar()
METHOD TPostMsf()
ENDCLASS
METHOD New() CLASS TTestUnicodeDll
DEFINE WINDOW ::oWnd TITLE "CraneErp Unicode 繁體中文(Traditional Chinese)" ;
MENU ::MenuBuild()
::DrawMsgBar()
ACTIVATE WINDOW ::oWnd MAXIMIZED
RETURN Self
//
METHOD MenuBuild() CLASS TTestUnicodeDll
LOCAL oMenu
MENU oMenu 2010
MENUITEM "&1.基本資料"
MENU
MENUITEM "郵遞區號設定作業" ;
RESOURCE "MN_POSTMSF" ;
MESSAGE "執行郵遞區號基本資料維護" ;
ACTION ::TPostMsf()
ENDMENU
MENUITEM "&2.維護工具"
MENU
MENUITEM "離開系統程式" + chr(9) + "Alt+F4" ;
MESSAGE "離開 Crane Unicode 繁體中文(Traditional Chinese)" ;
ACCELERATOR ACC_ALT, VK_F4 ;
ACTION ::oWnd:End()
SEPARATOR
MENUITEM "計算機" ;
MESSAGE "執行計算機程式"
ENDMENU
ENDMENU
RETURN oMenu
//
METHOD DrawMsgBar() CLASS TTestUnicodeDll
SET MESSAGE OF ::oWnd TO "CraneErp Unicode 繁體中文(Traditional Chinese)" CENTERED 2010 CLOCK KEYBOARD
RETURN NIL
//
METHOD TPostMsf() CLASS TTestUnicodeDll
TPostMsf():New()
RETURN NIL
//---------------------------------------------------------------------------//
CLASS TPostMsf
DATA cResName
DATA cWndName
DATA oDlg
DATA oBrw, oCol
DATA oDlgBar, oDlgBtn
DATA oMsg_CodeNo, oMsg_Rec
DATA oLabel
DATA oGrp
DATA oSubBtn
DATA oTimer
DATA oTimerDisplay
DATA lActive AS LOGICAL INIT .T.
DATA oZIPCODE, oCITYAREA
DATA cDB , oDB && 郵遞區號資料庫
METHOD New() CONSTRUCTOR
METHOD InitData()
METHOD Open()
METHOD FormCreate()
METHOD Close()
METHOD ReLabel()
METHOD ReBrowse()
METHOD ShowPopupMenu( nRow, nCol, nPos )
METHOD ChangeRecNumTxt()
METHOD StartButtonBar()
METHOD StartMsgBar()
METHOD ReGet()
METHOD LoadData( lNew )
METHOD DisableData()
METHOD EnableData()
METHOD Read (lNew)
METHOD RefreshData()
METHOD DisplayData()
METHOD DeleteData()
METHOD SortData()
METHOD SearchData( nPos )
METHOD PrnData()
METHOD IsExit()
METHOD SaveData ( lNew )
METHOD ThinkSave ( lNew )
METHOD BrwKeyDown( nKey )
METHOD DlgKeyDown( nKey )
METHOD DisplayBrw( nRecno )
METHOD CheckChange()
METHOD BrwChange()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New() CLASS TPostMsf
CursorWait()
::InitData()
::Open()
::FormCreate()
::oBrw:SetFocus()
RETURN Self
//---------------------------------------------------------------------------//
METHOD InitData() CLASS TPostMsf
::cResName := "D_DR_WIN_POSTMSF"
::cWndName := "郵遞區號設定作業"
RETURN NIL
//----------------------------------------------------------------------------//
METHOD CheckChange() CLASS TPostMsf
::oBrw:Refresh()
RETURN NIL
//----------------------------------------------------------------------------//
METHOD Open() CLASS TPostMsf
::cDB := PostMsfOpen( "Post" )
::oDB := TDataBase():New()
RETURN NIL
//----------------------------------------------------------------------------//
METHOD Close() CLASS TPostMsf
::oDB:Close()
RETURN NIL
//----------------------------------------------------------------------------//
METHOD IsExit( oFont ) CLASS TPostMsf
IF ::oCITYAREA:lActive
IF !MsgYesNo("是否要離開目前新增(修改)作業?", ::cWndName)
RETURN .F.
ENDIF
::DisableData()
::DisplayData()
::oBrw:SetFocus()
RETURN .F.
ENDIF
::lActive := .F.
::Close()
oFont:End()
RETURN .T.
//----------------------------------------------------------------------------//
METHOD FormCreate() CLASS TPostMsf
LOCAL oSelf := Self
LOCAL oFont
DEFINE FONT oFont NAME "新細明體" SIZE 0,12
DEFINE DIALOG ::oDlg RESOURCE ::cResName FONT oFont
::oDlg:lHelpIcon := .F.
::oDlg:SetColor( CLR_BLACK, nRGB( 229, 233, 237 ) )
::LoadData()
::StartButtonBar()
::ReLabel()
::ReBrowse()
::ReGet()
::oDlg:bKeyDown := {| nKey | ::DlgKeyDown ( nKey ) }
::oDlg:bStart := {|| ::oDB:SetOrder( "POSTMSF1" ),;
::StartMsgBar(oFont) ,;
::oBrw:GoTop() ,;
::oBrw:ReFresh() ,;
::oBrw:SetFocus() ,;
::DisableData() }
::Displaydata()
ACTIVATE DIALOG ::oDlg CENTER ;
ON INIT NoCloseButton( ::oDlg ) ;
VALID oSelf:IsExit( oFont )
RETURN NIL
//----------------------------------------------------------------------------//
METHOD ReLabel() CLASS TPostMsf
LOCAL nI :=1
LOCAL oLabel[2]
FOR nI := 1 TO 2
oLabel[ nI ]:= TDr3dText():Redefine ( 500 + nI, ::oDlg )
oLabel[nI]:SetGrade( 1, 100, 1 )
oLabel[nI]:nStClr := nRGB(96,96,96)
oLabel[nI]:nEndClr := nRGB(255,255,255)
oLabel[nI]:nClrText := nRGB(0,0,0)
oLabel[nI]:lText3D := .F.
oLabel[nI]:lBlackBorder := .T.
NEXT
::oLabel := oLabel
RETURN NIL
//----------------------------------------------------------------------------//
METHOD ReBrowse() CLASS TPostMsf
::oBrw := TXBrowse():New( ::oDlg )
::oBrw:cAlias := (::cDB)
::oBrw:nMarqueeStyle := 5
::oBrw:nRowDividerStyle := 4
::oBrw:nColDividerStyle := 4
::oBrw:lColDividerComplete := .T.
::oBrw:lAllowColHiding := .F.
::oBrw:bChange := { || ::BrwChange(), ::ChangeRecNumTxt() }
::oBrw:bRClicked := {| nRow, nCol | ::ShowPopupMenu( nRow, nCol ) }
::oBrw:bKeyDown := {| nKey | ::BrwKeyDown ( nKey ) }
::oBrw:bClrSelFocus := { || { CLR_BLACK, { { 1, nRGB(238,152, 21), ;
nRGB(250,227,144) } } } }
::oBrw:bClrSel := { || { 16777215, nRGB( 0, 64, 128 ) } }
::oBrw:bClrStd := { || if( (::cDB)->(AdsKeyNo())%2=0,;
({ CLR_BLACK, nRGB( 240, 240, 240 ) }), ({ CLR_BLACK, nRGB( 255, 255, 255 ) }) )}
::oCol := ::oBrw:AddCol()
::oCol:cHeader := "郵遞區號"
::oCol:nHeadStrAlign := AL_LEFT
::oCol:bStrData := { || (::cDB)->ZIPCODE }
::oCol:nWidth := 150
::oCol := ::oBrw:AddCol()
::oCol:cHeader := "縣市/鄉鎮"
::oCol:nHeadStrAlign := AL_LEFT
::oCol:bStrData := { || (::cDB)->CITYAREA }
::oCol:nWidth := 450
::oBrw:CreateFromResource( 301 )
RETURN NIL
//---------------------------------------------------------------------------//
METHOD ChangeRecNumTxt() CLASS TPostMsf
LOCAL cPos := cValToChar( (::cDB)->( AdsKeyNo() ) )
LOCAL cRec := cValToChar( (::cDB)->( AdsKeycount(,,3) ) )
LOCAL cMsgTxt := ""
cMsgTxt := "指標/筆數:" + cPos + "/" + cRec
::oMsg_Rec:SetText( cMsgTxt )
RETURN NIL
//----------------------------------------------------------------------------//
METHOD ShowPopupMenu( nRow, nCol ) CLASS TPostMsf
LOCAL oMenu, oCol
LOCAL cPrompt, nFor, nLen
MENU oMenu 2007 POPUP
MENUITEM "新增(&A)" ACTION ::Read(.T.)
MENUITEM "修改(&M)" ACTION ::Read(.F.)
MENUITEM "刪除(&D)" ACTION ::DeleteData()
MENUITEM "搜尋(&F)" ACTION ::SearchData()
MENUITEM "排序(&S)" ACTION ::SortData()
MENUITEM "報表(&P)" ACTION ::PrnData()
SEPARATOR
MENUITEM "離開(&X)" ACTION ::oDlg:End()
SEPARATOR
MENUITEM "求助(&H)"
ENDMENU
ACTIVATE POPUP oMenu AT nRow, nCol OF ::oBrw
RETURN NIL
//---------------------------------------------------------------------------//
METHOD StartButtonBar() CLASS TPostMsf
LOCAL oDlgBtn[12]
LOCAL nI := 1
LOCAL oRect := ::oDlg:GetCliRect()
REDEFINE BUTTONBAR ::oDlgBar ID 300 OF ::oDlg 2010
//-* 設定按鈕列不可使用滑鼠右鍵 -----------------
::oDlgBar:bLClicked := {||NIL}
::oDlgBar:bRClicked := {||NIL}
DEFINE BUTTON oDlgBtn[1] OF ::oDlgBar ;
RESOURCE "BS_TOPS" ;
TOOLTIP "移動至第一筆記錄" ;
MESSAGE "記錄指標到第一筆記錄" ;
ACTION ( ::oBrw:Gotop() ,;
::oBrw:Refresh() ,;
::oBrw:SetFocus() )
DEFINE BUTTON oDlgBtn[2] OF ::oDlgBar ;
RESOURCE "BS_UP" ;
TOOLTIP "移至前一筆記錄" ;
MESSAGE "記錄指標到上一筆記錄" ;
ACTION ( ::oBrw:GoUp() ,;
::oBrw:Refresh() ,;
::oBrw:SetFocus() )
DEFINE BUTTON oDlgBtn[3] OF ::oDlgBar ;
RESOURCE "BS_NEXT" ;
TOOLTIP "移至下一筆記錄" ;
MESSAGE "記錄指標到下一筆記錄" ;
ACTION ( ::oBrw:GoDown() ,;
::oBrw:Refresh() ,;
::oBrw:SetFocus() )
DEFINE BUTTON oDlgBtn[4] OF ::oDlgBar ;
RESOURCE "BS_DOWN" ;
TOOLTIP "移動到最後一筆記錄" ;
MESSAGE "記錄指標到最後一筆記錄" ;
ACTION ( ::oBrw:GoBottom() ,;
::oBrw:Refresh() ,;
::oBrw:SetFocus() )
DEFINE BUTTON oDlgBtn[5] OF ::oDlgBar ;
GROUP ;
RESOURCE "TB_New32" ;
TOOLTIP "增加一筆新的記錄" ;
MESSAGE "新增一筆空白資料" ;
ACTION ::Read(.T.)
DEFINE BUTTON oDlgBtn[6] OF ::oDlgBar ;
RESOURCE "TB_Edit32" ;
TOOLTIP "修改目前這筆記錄" ;
MESSAGE "修改目前您所選的資料" ;
ACTION ::Read(.F.)
DEFINE BUTTON oDlgBtn[7] OF ::oDlgBar ;
RESOURCE "TB_Delete32" ;
TOOLTIP "刪除目前這筆記錄" ;
MESSAGE "刪除目前您所選的資料" ;
ACTION ::DeleteData()
DEFINE BUTTON oDlgBtn[8] OF ::oDlgBar ;
RESOURCE "TB_Search32" ;
TOOLTIP "搜尋資料" ;
MESSAGE "查詢資料" ;
ACTION ::SearchData( 1 )
DEFINE BUTTON oDlgBtn[9] OF ::oDlgBar ;
RESOURCE "TB_Print32" ;
TOOLTIP "螢幕預覽"+CRLF+"或"+CRLF+"列印至報表紙" ;
MESSAGE "列印資料" ;
ACTION (::PrnData(),::oBrw:SetFocus())
DEFINE BUTTON oDlgBtn[10] OF ::oDlgBar ;
RESOURCE "TB_Sort32" ;
TOOLTIP "依條件來排序資料" ;
MESSAGE "排序資料" ;
ACTION ::SortData()
DEFINE BUTTON oDlgBtn[11] OF ::oDlgBar ;
GROUP ;
RESOURCE "TB_Exit32" ;
TOOLTIP "離開資料維護作業" ;
MESSAGE "離開資料維護作業" ;
ACTION ::oDlg:End()
DEFINE BUTTON oDlgBtn[12] OF ::oDlgBar ;
RESOURCE "TB_Help32" ;
TOOLTIP "查詢操作及使用說明" ;
MESSAGE "查詢操作及使用說明" //;
//ACTION OpenHtmlHelp()
::oDlgBtn := oDlgBtn
::oSubBtn := Array(2)
DEFINE BUTTON ::oSubBtn[1] OF ::oDlgBar ;
GROUP ;
RESOURCE "TB_Save32" ;
TOOLTIP "儲存目前編輯的"+CRLF+"這筆資料" ;
MESSAGE "儲存目前的資料" ;
ACTION ::ThinkSave()
DEFINE BUTTON ::oSubBtn[2] OF ::oDlgBar ;
RESOURCE "TB_NoSave32" ;
TOOLTIP "放棄目前輸入的資料" ;
MESSAGE "取消目前存取資料" ;
ACTION ::oDlg:End()
RETURN NIL
//------------------------------------------------------------------------//
METHOD StartMsgBar(oFont) CLASS TPostMsf
SET MESSAGE OF ::oDlg TO "F5:新增 F6:修改 F7:查詢 F8:刪除 F9:列印 ESC:離開" ;
2007 FONT oFont
DEFINE MSGITEM ::oMsg_Rec OF ::oDlg:oMsgBar ;
PROMPT "" ;
SIZE 180
DEFINE MSGITEM ::oMsg_CodeNo OF ::oDlg:oMsgBar ;
PROMPT "程式編號: TPostMsf" ;
SIZE 180 ;
BITMAPS "PRG"
RETURN NIL
//---------------------------------------------------------------------------//
METHOD DisplayBrw( nRecno ) CLASS TPostMsf
Select(::cDB)
IF ::oBrw:oVScroll <> NIL
::oBrw:oVScroll:SetRange( 1 , (::cDB)-> ( AdsKeyCount(,,3) ) )
::oBrw:oVScroll:SetPos ( (::cDB)-> ( AdsKeyNo(3) ) )
ENDIF
(::cDB)->( DbGoTop() )
::oBrw:Refresh()
IF nRecno <> NIL
(::cDB)->( DbGoto( nRecno ) )
ENDIF
::DisplayData()
RETURN NIL
//----------------------------------------------------------------------------//
METHOD ReGet() CLASS TPostMsf
REDEFINE GROUP ::oGrp ID 400 OF ::oDlg TRANSPARENT
REDEFINE GET ::oZIPCODE VAR ::oDB:ZIPCODE ID 101 OF ::oDlg
REDEFINE GET ::oCITYAREA VAR ::oDB:CITYAREA ID 102 OF ::oDlg
RETURN NIL
//----------------------------------------------------------------------------//
METHOD LoadData( lNew ) CLASS TPostMsf
DEFAULT lNew := .f.
IF lNew
::oDB:Blank()
ELSE
::oDB:Load()
ENDIF
RETURN NIL
//----------------------------------------------------------------------------//
METHOD DisableData() CLASS TPostMsf
LOCAL nI := 1
Dr_Disable( ::oDlg, { "TGET" } )
::oBrw:Enable()
FOR nI := 1 TO Len ( ::oDlgBtn )
::oDlgBtn[nI]:Show()
NEXT
FOR nI := 1 TO Len ( ::oSubBtn )
::oSubBtn[nI]:Hide()
NEXT
::oLabel[1]:ReSet()
::oLabel[1]:nStClr := nRGB(96,96,96)
::oLabel[1]:nEndClr := nRGB(255,255,255)
::oLabel[1]:nClrText := nRGB(0,0,0)
::oLabel[1]:ReFresh()
::oLabel[2]:ReSet()
::oLabel[2]:nStClr := nRGB(96,96,96)
::oLabel[2]:nEndClr := nRGB(255,255,255)
::oLabel[2]:nClrText := nRGB(0,0,0)
::oLabel[2]:ReFresh()
RETURN NIL
//----------------------------------------------------------------------------//
METHOD EnableData() CLASS TPostMsf
LOCAL nI := 1
Dr_Enable( ::oDlg, { "TGET" } )
::oBrw:Disable()
FOR nI := 1 TO Len ( ::oDlgBtn )
::oDlgBtn[nI]:Hide()
NEXT
FOR nI := 1 TO Len ( ::oSubBtn )
::oSubBtn[nI]:Show()
NEXT
::oLabel[1]:ReSet()
::oLabel[1]:SetGrade ( 1,15,1 )
::oLabel[1]:ReFresh()
::oLabel[2]:ReSet()
::oLabel[2]:SetGrade ( 1,15,1 )
::oLabel[2]:ReFresh()
RETURN NIL
//----------------------------------------------------------------------------//
METHOD RefreshData() CLASS TPostMsf
Dr_Refresh( ::oDlg, { "TGET" } )
Dr_GetRefresh( ::oDlg )
RETURN NIL
//---------------------------------------------------------------------------//
METHOD DisplayData() CLASS TPostMsf
::LoadData()
::RefreshData()
RETURN NIL
//----------------------------------------------------------------------------//
METHOD DeleteData() CLASS TPostMsf
LOCAL nPos := (::cDB)->( AdsKeyNo(,3) )
LOCAL nOldRec := (::cDB)->( Recno() )
IF (::cDB)->(AdsKeyCount(,,3)) == 0
MsgAlert("資料檔中無任何資料,無法刪除 !","警告")
RETURN NIL
ENDIF
IF !MsgYesNo( "確定刪除此筆資料嗎?", "警告" )
::DisplayBrw( nOldRec )
::oBrw:Refresh()
::oBrw:SetFocus()
RETURN NIL
ENDIF
IF (::cDB)->( DbRLock() )
(::cDB)->( DbDelete() )
(::cDB)->( DbUnLock() )
ENDIF
IF (::cDB)->( AdsKeyCount(,,3)) == 0
(::cDB)->( DbGoBottom() )
::oBrw:Refresh()
ELSE
IF nPos == 1
::oBrw:GoDown()
::oBrw:GoTop()
ELSE
(::cDB)->( OrdKeyGoto( nPos-- ) )
::oBrw:GoUp()
::oBrw:GoDown()
::oBrw:Refresh()
ENDIF
ENDIF
::oBrw:Refresh()
::RefreshData()
::oBrw:SetFocus()
RETURN NIL
//----------------------------------------------------------------------------//
METHOD SearchData( nPos ) CLASS TPostMsf
RETURN NIL
//---------------------------------------------------------------------------//
METHOD SortData() CLASS TPostMsf
RETURN NIL
//----------------------------------------------------------------------------//
METHOD Read( lNew ) CLASS TPostMsf
IF (::cDB)->(AdsKeyCount(,,3)) == 0 .AND. lNew = .F.
MsgAlert("資料檔中無任何資料,無法修改資料 !","警告")
RETURN NIL
ENDIF
::LoadData( lNew )
::oSubBtn[1]:bAction := {|| ::ThinkSave ( lNew ) }
::EnableData()
::RefreshData()
::oZIPCODE:Setfocus()
RETURN NIL
//---------------------------------------------------------------------------//
METHOD SaveData( lNew ) CLASS TPostMsf
LOCAL nRecNo
SELECT (::cDB)
// IF lNew
// IF !Dr_Append()
// MsgStop("網路忙線中,請重新執行.", ::cWndName)
// RETURN .F.
// ENDIF
// ENDIF
(::cDB)->( DbRLock() )
::oDB:Save()
(::cDB)->( DbCommit() )
(::cDB)->( DbUnLock() )
nRecNo := (::oDB:cAlias)->(RecNo())
::DisplayBrw( nRecno )
::oBrw:Refresh()
RETURN NIL
//---------------------------------------------------------------------------//
METHOD BrwKeyDown( nKey ) CLASS TPostMsf
DO CASE
CASE nKey == VK_F5 .OR. nKey == VK_INSERT && 新增
::Read(.T.)
CASE nKey == VK_F6 .OR. nKey == 13 && 修改
::Read(.F.)
CASE nKey == VK_F7 && 查詢
::SearchData(1)
CASE nKey == ASC("F")
IF GetKeyState ( VK_CONTROL )
::SearchData(1)
ENDIF
Dr_SetFocus(::oBrw)
CASE nKey == VK_F8 .OR. nKey == VK_DELETE && 刪除
::DeleteData()
CASE nKey == VK_F9 && 列印
( ::PrnData(), Dr_SetFocus(::oBrw) )
CASE nKey == 27 && 離開
::oDlg:End()
ENDCASE
RETURN NIL
//---------------------------------------------------------------------------//
METHOD DlgKeyDown( nKey ) CLASS TPostMsf
DO CASE
CASE nKey == ASC("N") && 新增
IF GetKeyState ( VK_CONTROL )
::Read(.T.)
ENDIF
CASE nKey == ASC("M") && 修改
IF GetKeyState ( VK_CONTROL )
::Read(.F.)
ENDIF
CASE nKey == ASC("F")
IF GetKeyState ( VK_CONTROL ) && 查詢
::SearchData(1)
ENDIF
Dr_SetFocus(::oBrw)
CASE nKey == ASC("D") && 刪除
IF GetKeyState ( VK_CONTROL )
::DeleteData()
ENDIF
CASE nKey == ASC("P") && 列印
IF GetKeyState ( VK_CONTROL )
::PrnData()
ENDIF
Dr_SetFocus(::oBrw)
CASE nKey == 27 && 離開
::oDlg:End()
ENDCASE
RETURN NIL
//----------------------------------------------------------------------------//
METHOD ThinkSave( lNew ) CLASS TPostMsf
IF Empty( ::oDB:ZIPCODE )
::oZIPCODE:SetFocus()
MsgStop("郵遞區號不能空白.", ::cWndName)
RETURN NIL
ENDIF
IF Empty( ::oDB:CITYAREA )
::oCITYAREA:SetFocus()
MsgStop("縣市/鄉鎮不能空白.", ::cWndName)
RETURN NIL
ENDIF
::SaveData ( lNew )
::DisableData()
// EVAL ( ::oBrw:bChange )
::oBrw:SetFocus()
RETURN NIL
//----------------------------------------------------------------------------//
METHOD BrwChange() CLASS TPostMsf
IF ::oTimerDisplay <> NIL
::oTimerDisplay:End()
ENDIF
DEFINE TIMER ::oTimerDisplay INTERVAL 200 ;
ACTION ( ::oTimerDisplay:End(),;
::DisplayData() )
ACTIVATE TIMER ::oTimerDisplay
RETURN NIL
//----------------------------------------------------------------------------//
METHOD PrnData( oTit ) CLASS TPostMsf
RETURN NIL
//---------------------------------------------------------------------------//
FUNCTION PostMsfOpen( cAlias )
LOCAL aStruct := { { "ZIPCODE ", "C", 3, 0 },; //郵遞區號
{ "CITYAREA", "C", 14, 0 },; //縣市名稱
{ "CITY ", "C", 6, 0 },; //縣市
{ "AREA ", "C", 8, 0 },; //區域
{ "ECITY ", "C", 10, 0 },; //英文縣市
{ "EAREA ", "C", 17, 0 } }
LOCAL cFile := "PostMsf.dbf"
LOCAL cCdx := "PostMsf.cdx"
DEFAULT cAlias := "PostMsf"
IF !File ( cFile )
dbCreate( cFile, aStruct, "ADS" )
IF File( cCdx )
FErase ( cCdx )
ENDIF
ENDIF
USE (cFile) NEW SHARED ALIAS (cAlias) VIA "ADS"
cAlias := Alias()
IF !File ( cCDX )
IF (cAlias)->(FLock())
INDEX ON FIELD->ZIPCODE TAG POSTMSF1 TO ( cCDX ) FOR !Deleted()
INDEX ON FIELD->CITYAREA TAG POSTMSF2 TO ( cCDX ) FOR !Deleted()
INDEX ON FIELD->CITY+FIELD->ZIPCODE TAG POSTMSF3 TO ( cCDX ) FOR !Deleted()
(cAlias)->(DbUnLock())
ENDIF
SET INDEX TO ( cCDX )
ENDIF
SET ORDER TO "POSTMSF1"
(cAlias)->( DBGoTop() )
RETURN Alias()