// add a new record
oLbxB:bPastEof = {|| _AddNewRow( oRsDetail,nRepairNumber,nAssignedTo,cLoc,oLbxB,"Y",oRsRepair,"" ) }
//----------------
Static Func _AddNewRow( oRsDetail,nRN,nTech,cLocation,oBrw,cAsk,oRsRepair,cReturn )
Local Saying,nEid,nLine,nUpdated
If empty( cAsk )
cAsk := "Y"
Endif
If Empty(cReturn)
cReturn := "ADD"
ENdif
If cAsk = "Y"
Saying := "Do you wish to Add a New Record ?"
If MsgYesNo( Saying )
Else
oBrw:SetFocus()
Return(.f.)
Endif
Endif
nEid := _GenEid(1)
If nEid = -1
Saying := "Error in Creating Unique EID for Repair Detail"
Msginfo( Saying )
oBrw:SetFocus()
Return(.f.)
Endif
nLine := _GenLine()
If nLine = -1
Saying := "Error in Creating Unique LINE for Repair Detail"
Msginfo( Saying )
oBrw:SetFocus()
Return(.f.)
Endif
// update the concurrent counter in repair header
nUpdated := oRsRepair:Fields("Updated"):Value
If Empty(nUpdated)
nUpdated := 1
Else
nUpdated++
Endif
oRsRepair:Fields("Updated"):Value := nUpdated
oRsRepair:Update()
oRsDetail:AddNew()
oRsDetail:Fields("RepDetailEid"):Value := nEid
oRsDetail:Fields("Unique Line"):Value := nLine
oRsDetail:Fields("Repair Number"):Value := nRn
If cReturn = "RETURN"
oRsDetail:Fields("Qty"):Value := -1
Else
oRsDetail:Fields("Qty"):Value := 1
Endif
oRsDetail:Fields("Item Description"):Value := space(100)
oRsDetail:Fields("Price"):Value := 0.00
oRsDetail:Fields("Tech Number"):Value := nTech
oRsDetail:Fields("Inventory Id"):Value := space(50)
oRsDetail:Fields("Inventory Type"):Value := space(50) //"Labor"+space(45)
oRsDetail:Fields("Cost"):Value := 0.00
oRsDetail:Fields("Covered By Warranty"):Value := .f.
oRsDetail:Fields("Location"):Value := cLocation
oRsDetail:Fields("Code"):Value := space(25)
*oRsDetail:Fields("Shipping Ref"):Value := space(64)
oRsDetail:Fields("Serial Number"):Value := space(50)
oRsDetail:Fields("NoTax"):Value := 0
oRsDetail:Fields("Warranty Provider"):Value := space(50)
*oRsDetail:Fields("Quote Price"):Value := 0
oRsDetail:Fields("LockedDown"):Value := .f.
oRsDetail:Fields("IsSerial"):Value := .f.
oRsDetail:Fields("IsLabor"):Value := .f.
oRsDetail:Update()
oBrw:ReFresh()
oBrw:nColSel(3) // move to part number on add
*__Keyboard( Chr( VK_RETURN ))
oBrw:SetFocus()
Return(.t.)
//-------------------
Static Func _GenEid(nNum)
LOCAL nRAND
LOCAL oRs, cSQL, oERR
oRs:= TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType := 1 // opendkeyset
oRs:CursorLocation := 3 // local cache
oRs:LockType := 3 // lockoportunistic
Do Case
Case nNum = 1
cSQL := "SELECT RepDetailEid from [Repair Detail]"
Case nNum = 2
cSQL := "SELECT InvoiceEid from [Invoice]"
Case nNum = 3
cSql := "SELECT InvDetailEid from [Invoice Detail]"
Case nNum = 4
cSql := "SELECT SerialEid from [SerialNumber]"
Case nNum = 5
cSql := "SELECT LaborEid from [RoLabor]"
Case nNum = 6
cSql := "SELECT PaymentEid from [Payments]"
Case nNum = 7
cSql := "SELECT ScrapId from [UtilScrapHeap]"
EndCase
TRY
oRs:Open( cSQL,xConnect )
CATCH oErr
Do Case
Case nNum = 1
MsgInfo( "Error in Opening Repair Detail to Create Unique EID" )
Case nNum = 2
MsgInfo( "Error in Opening Invoice to Create Unique EID" )
Case nNum = 3
MsgInfo( "Error in Opening Invoice Detail to Create Unique EID" )
Case nNum = 4
MsgInfo( "Error in Opening SerialNumber to Create Unique EID" )
Case nNum = 5
MsgInfo( "Error in Opening RoLabor to Create Unique EID" )
Case nNum = 6
MsgInfo( "Error in Opening Payments to Create Unique EID" )
Case nNum = 7
MsgInfo( "Error in Opening UtilScrapHeap to Create Unique EID" )
EndCase
Return(-1)
END TRY
DO WHILE .T.
nRAND := nRANDOM(100000000)
// 1 is reserved and 0 is a null key //
IF nRAND = 1 .or. nRAND = 0 .or. nRAND = NIL
LOOP
ENDIF
IF oRs:eof
ELSE
oRs:MoveFirst()
Do Case
Case nNum = 1
oRs:Find("RepDetailEid = "+ltrim(str(nRand)) )
Case nNum = 2
oRs:Find("InvoiceEid = "+ltrim(str(nRand)) )
Case nNum = 3
* oRs:Find("InvDetailEid = "+ltrim(str(nRand)) )
Case nNum = 4
oRs:Find("SerialEid = "+ltrim(str(nRand)) )
Case nNum = 5
oRs:Find("LaborEid = "+ltrim(str(nRand)) )
Case nNum = 6
oRs:Find("PaymentEid = "+ltrim(str(nRand)) )
Case nNum = 7
oRs:Find("ScrapId = "+ltrim(str(nRand)) )
EndCase
ENDIF
IF oRs:eof
EXIT
ELSE
LOOP
ENDIF
EXIT
ENDDO
oRs:Close()
oRs := nil
RETURN( nRAND )
//-------------------
Static Func _GenLine()
LOCAL nRAND
LOCAL oRs, cSQL, oERR
oRs:= TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType := 1 // opendkeyset
oRs:CursorLocation := 3 // local cache
oRs:LockType := 3 // lockoportunistic
cSQL := "SELECT [Unique Line] from [Repair Detail] order by [Unique Line]"
TRY
oRs:Open( cSQL,xConnect )
CATCH oErr
MsgInfo( "Error in Opening Repair Detail to Create Unique LINE" )
Return(-1)
END TRY
If oRs:Eof()
nRand := 1
Else
oRs:MoveLast()
nRand := oRs:Fields("Unique Line"):Value+1
Endif
oRs:CLose()
oRs := NIL
Return(nRand)
REDEFINE XBROWSE ::oBrw ID 131 OF ::oDlg ;
HEADER "LeaseID", "PropertyID", "LandLordID", "ManagerID", "StartDate", "EndDate", "TenantName", ;
"Rent", "PMagmntFee" ;//, "Balance", "Expenses", "Net", "Payments" ;
COLUMNS "LeaseID", "PropertyID", "LandLordID", "ManagerID", "StartDate", "EndDate", "TenantName", ;
"Rent", "PmFee" ;
;//FIELDS { || ::LoadBalances(), ::oDbf:Balance }, { || ::oDbf:Expenses }, {|| ::oDbf:Net }, { || ::oDbf:Payments } ;
SIZES 100, 170, 140, 140, 70, 70, 100, 100, 90, 100, 100, 100, 100 ;
PICTURES ,,,,"@d","@d",,"9,999,999.99", "9,999.99", "9,999,999.99", "9,999,999.99", "9,999,999.99", "9,999,999.99" ;
ALIAS ::oDbf:cAlias ;
ON CHANGE Eval( ::bChange ) ;
ON DBLCLICK Eval( ::bEdit ) ;
FOOTERS ;
WHEN ! ::lEdit
#include "FiveWin.ch"
function Main()
local oBrw, oDlg, aData := {{1,2,3},{4,5,6},{7,8,9},{1,1,1}}
define dialog oDlg from 10,10 to 400,400 pixel
@ 5,5 Xbrowse oBrw ;
OF oDlg ;
columns 1,2,3 ;
header "A","B","C" ;
sizes 90,90,90;
ARRAY aData ;
size 170,170 ;
pixel
oBrw:createFromCode()
oBrw:bPastEof := {|| if( newRecord( aData, oBrw, oDlg ), ( oBrw:setArray( aData ), ;
oBrw:goBottom(),;
oBrw:refresh() ), NIL ), .T. }
activate dialog oDlg center
return nil
FUNCTION newRecord( aData, oBrw, oD )
LOCAL oDlg, v1 := 0, v2 := 0, v3 := 0, lRet := .F.
LOCAL aRect := GetCoors(oD:hWnd)
LOCAL nCol := oBrw:aCols[1]:nDisplayCol + aRect[2], ;
nRow := ( ( oBrw:nRowSel - 1 ) * oBrw:nRowHeight ) + oBrw:HeaderHeight() + aRect[1]
DEFINE DIALOG oDlg FROM 400,400 to 440,780 PIXEL STYLE nOR( WS_CHILD, WS_POPUP, WS_VISIBLE )
@ 5,5 GET v1 OF oDlg SIZE 45,12 pixel
@ 5,50 GET v2 OF oDlg SIZE 45,12 pixel
@ 5,95 GET v3 OF oDlg SIZE 45,12 pixel
@ 5,140 BUTTON "ADD" OF oDlg SIZE 45,12 PIXEL ACTION ( AADD( aData, { v1, v2, v3 } ), lRet := .T. , oDlg:end() )
ACTIVATE DIALOG oDlg ON INIT oDlg:move( nRow + 60, nCol )
RETURN lRet
$sql2 = "CALL GET_ALL_P0001() ";
$res = $mysqli->query($sql2);
while($row = $res->fetch_assoc()):
$FIL_NR = $row["FIL_NR"] ;
$DATUM = $row["DATUM"] ;
$table .= '<tr><td>' . $FIL_NR . '</td><td>'. $DATUM . '</td></tr>' ;
endwhile;
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 50 guests