I am enclosing herewith a function, through which I am trying to add data in a database. The main Problems is:
a) The Get fields are not activated and jumping directly to “Sure to save …….” Msg.
Other problems :
a) How Can I set font name and size?
b) Some Procedure/Function Return shows Warning… during compilation. The msg in “Procedure return value” ……… What is this actually?
c) If I want to move a child mdi window within a specific area of main MDI window, then how can I set the same?
- Code: Select all Expand view RUN
Function getCustomer(aDataFld, helpIDX, OperateArea, nShortId,
lShortPressed, ButnStatus)
Static nVal := 0
Static getList := {}
Local cColor := "W/N,R/W,,,N/W"
Local userlevel := "P"
Local today := Date()
Local chCust := 0
Local Success, savDelete, lReadit, i
Local cCNo := Space(8), cRank := Space(8), nPin := Space(6)
Local cName := Space(35), cAdd1 := Space(35), cAdd2 := Space(35)
Local cLoc := Space(35)
lReadit := .T.
// Hide mouse cursor
mSetCursor(.F.)
// Set Color Attribute
Set Color to(cColor)
// Hide cursor
Set Cursor Off
If Len(aDataFld) == 0
MessageBox(, "Get Fields are empty. Try again later...", "WARNING", "OK")
Clear Gets
ReadKill(.T.)
Chcust := 0
ButnStatus := .T.
lShortPressed := .T.
nShortId := "S_NOCHOICE"
Return(ButnStatus, nShortId, lShortPressed)
Endif
If lReadit == .F.
@ 3, 11 Get aDataFld[01] ;
Picture "@!" ;
Color "12/7, 12/7" ;
Valid nodupl(aDataFld[01], Customer->CustNo, helpIDX, ,1, ;
" Invalid Customer Code. ;" + ;
"A Customer with the current Customer No.;" + ;
"found.;") .And. !LastKey() == K_ESC
Else
@ 3, 11 Get aDataFld[01] ;
Picture "@!" ;
Color "W/N,R/W,,,N/W" ;
Valid Lreqdata() .And. nodupl(aDataFld[01], Customer->CustNo, helpIDX, ,1, ;
" Invalid Customer Code. ;" + ;
"A Customer with the current Customer No.;" + ;
"found.;") .And. !LastKey() == K_ESC .And. ;
lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)
Endif
@ 5, 11 Get aDataFld[02] ;
Picture "@!" ;
Color "W/N,R/W,,,N/W" ;
Valid lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)
@ 6, 11 Get aDataFld[03] ;
Picture "@!" ;
Color "W/N,R/W,,,N/W" ;
When If(userlevel == "P", .T., .F.) ;
Valid Lreqdata() .And. lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)
@ 7, 11 Get aDataFld[04] ;
Picture "@!" ;
Color "W/N,R/W,,,N/W" ;
When !Empty(aDataFld[03]) ;
Valid Lreqdata() .And. lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)
@ 8, 11 Get aDataFld[05] ;
Picture "@!" ;
Color "W/N,R/W,,,N/W" ;
When If(!Empty(aDataFld[03]), .T., .F.) ;
Valid lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)
@ 9, 11 Get aDataFld[06] ;
Picture "@!" ;
Color "W/N,R/W,,,N/W" ;
When If(!Empty(aDataFld[03]), .T., .F.) ;
Valid lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)
@ 10, 11 Get aDataFld[07] ;
Picture "@Z 999999" ;
Color "W/N,R/W,,,N/W" ;
When If(!Empty(aDataFld[03]), .T., .F.) ;
Valid lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)
// Show mouse cursor
mSetCursor(.T.)
If lReadit
// Turn on the cursor
Set Cursor On
ReadModal(GetList, 1,, 4, 50, 70, "9/14")
// Hide cursor
Set Cursor Off
Else
While .T.
i := Inkey()
Do Case
Case i = K_PGDN
If Eof()
dbSkip()
Endif
Exit
Case i = K_PGUP
If Eof()
dbSkip(-1)
Endif
Exit
Otherwise
Loop
EndCase
Enddo
Return(ButnStatus, nShortId, lShortPressed)
Endif
// User terminated, read unchanged or fails data integrity
If LastKey() == K_ESC
If helpIDX == "ADD"
Return(ButnStatus, nShortId, lShortPressed)
Endif
Endif
If ValueChanged .Or. Updated()
If !integrity(aDataFld)
Return(ButnStatus, nShortId, lShortPressed)
Endif
Endif
// Save the record after operator's confirmation
If MessageBox(, "Sure to save current record ?" ,;
"CONFIRM", "MB_OKCANCEL") <> 1
Return(ButnStatus, nShortId, lShortPressed)
Endif
// Update system databases and establish all locks in the databases
updvars(aDataFld, helpIDX, @Success)
// All okay, save now
If Success
For i := 1 To FCount()
FieldPut(i, aDataFld[i])
Next
// Force pending updates to disk
dbCommitAll()
Else
MessageBox(, "Unable to save data" , "WARNING", "OK")
Endif
Chcust := 0
CustAppnd := .F.
ValueChanged := .F.
Success := .F.
Customer->(dbRUnLock())
cAdnlCust->(dbrUnLock())
Return(ButnStatus, nShortId, lShortPressed)
I have very much doubt that whether the above code will be readable or not. I did not found any other option to attach the same. I hope such option should be there. Waiting for early reply.
Thanks everybody.
Arindam