// WorkView.prg
#Include "FiveWin.ch"
#Include "xBrowse.ch"
//------------------
Func _WorkView( oWnd,oWndChild )
Local lOk,lOk1,lClosed,lTransfer,xMode,cMode
Local oFontB,oFontBig,xTitle
Local xLabor,xParts,xMisc,xTax,xTotal
Local oLabor,oParts,oMisc,oTax,oTotal
Local oWndChildB,oWorkB
Local oBtn1,oBtn2,oBtn3,oBtn4,oBtn5,oBtn6,oBtn7,oBtn8,oBtn9,oBtn10,oBtn11,oBtn12,oBtn13,oBtn14
Local Saying,nRepairNumber
lOk := .f. // trap valid close local
lOk1 := .f. // used for close local
lOk3 := .f. // used for invtfind
lClosed := .f. // use for close workedit
lTransfer := .f. // used for close transfer
nRepairNumber := 100000
xLabor := 0.00
xParts := 0.00
xMisc := 0.00
xTax := 0.00
xTotal := 0.00
oFontB := TFont():New("Ms Sans Serif",,-6,.F.,.T. ,,,,.F. )
oFontBig := TFont():New("Ms Sans Serif",,-14,.F.,.T. ,,,,.F. )
**** oWndChild:Hide()
lOk := .f.
xTitle := "RO "+LTRIM( STR( nRepairNumber))
DEFINE WINDOW oWndChildB ;
FROM 0,0 to 39,120 ;
MDICHILD ;
OF oWnd ;
TITLE xTITLE
DEFINE DIALOG oWorkB RESOURCE "WORKVIEW" of oWndChildB
REDEFINE GET oParts var xParts ID 170 of oWorkB PICTURE "999,999.99" READONLY
REDEFINE GET oLabor var xLabor ID 173 of oWorkB PICTURE "999,999.99" READONLY
REDEFINE GET oMisc var xMisc ID 175 of oWorkB PICTURE "999,999.99" READONLY
REDEFINE GET oTax var xTax ID 177 of oWorkB PICTURE "999,999.99" READONLY
REDEFINE GET oTotal var xTotal ID 183 of oWorkB PICTURE "999,999.99" READONLY
REDEFINE BTNBMP oBtn1 ID 147 PROMPT "Lookup Parts" CENTER ;
of oWorkB 2007 ;
ACTION ( _InvtFind( oWnd,oWndChildB,oFontB,oFontBig,nRepairNumber,;
@xLabor,@xParts,@xMisc,@xTax,@xTotal,;
oLabor,oParts,oMisc,oTax,oTotal) )
REDEFINE BTNBMP oBtn14 ID 140 PROMPT "Close" CENTER ;
of oWorkB 2007 ;
ACTION ( IF(cMODE = "V", lOK1 := .T., lOK1 := _busrules() ), ;
IF(cMODE = "V", lOK1 := .T. ,;
if(lOK1 = .T., _doit( cMODE),)),;
IF(lOK1 = .T., oWndChildB:end(), ))
ACTIVATE DIALOG oWorkB NOMODAL ;
ON INIT _ReCalcTotals( @xLabor,@xParts,@xMisc,@xTax,@xTotal,;
oLabor,oParts,oMisc,oTax,oTotal) ;
VALID(!GETKEYSTATE( 27 ))
ACTIVATE WINDOW oWndChildB ;
ON INIT ( oWorkB:Move( 0,0, oWndchildB:nWidth, oWndchildB:nHeight, .T. ), ;
oWndChildB:bResized := {|| _ReSizeUm( oWorkB,oWndChildB) }, ;
oWorkB:refresh(.t.));
VALID ( IIF( !lOK, ExitPgm(.T.,oWndChildB,oWndChild,@lOk,oFontB,oFontBig ), .F. ))
RETURN( NIL )
//---------------
Static Func _busrules()
Return(.t.)
//------------------
Static Func _InvtLookUp( cMode, cStockno, oRsDetail,;
cItemDescription,nPrice,cInventoryId,cInventoryType)
Local oRsInvt, cSql, Saying
If cMode = "V"
Return(.t.)
Endif
If cMode = "A" .or. cMode = "E"
If empty(cStockno) .or. cStockno = " "
Saying := "Sorry .. you can not leave the Part"+chr(10)
Saying += "Number Blank"+chr(10)
MsgInfo( Saying )
* oInventoryId:SetFocus()
Return(.f.)
Endif
Endif
If cMode = "E"
If oRsDetail:Fields("Inventory Id"):Value = cStockno
Return(.t.)
Endif
Endif
oRsInvt := TOleAuto():New( "ADODB.Recordset" )
oRsInvt:CursorType := 1 // opendkeyset
oRsInvt:CursorLocation := 3 // local cache
oRsInvt:LockType := 3 // lockoportunistic
cSql := "Select [Inventory Id],Description,Price,Cost,[Inventory Type] From Inventory "
cSql += "where [Inventory Id] like '"+alltrim(cStockno)+"%'"
TRY
oRsInvt:Open( cSQL,xCONNECT )
CATCH oErr
MsgInfo( "Error in Opening INVENTORY table" )
RETURN(.F.)
END TRY
If oRsInvt:eof
Else
// added for cell edit
cInventoryId := substr(oRsInvt:Fields("Inventory Id"):Value+space(50),1,50)
cInventoryType := substr(oRsInvt:Fields("Inventory Type"):Value+space(50),1,50)
cItemDescription := substr(oRsInvt:Fields("Description"):Value+space(255),1,255)
nPrice := oRsInvt:Fields("Price"):Value
Endif
oRsInvt:CLose()
Return( .t. )
//--------------------------
Static Func _ReCalcTotals( xLabor,xParts,xMisc,xTax,xTotal,;
oLabor,oParts,oMisc,oTax,oTotal)
Local nStart,nTaxable,Saying
Saying := "In ReCalc"+chr(10)
Saying += " "+chr(10)
Saying += "xLabor before "+str(xLabor)+chr(10)
Saying += "xParts before "+str(xParts)+chr(10)
Saying += "xMisc before "+str(xMisc)+chr(10)
Saying += "xTax before "+str(xTax)+chr(10)
Saying += "xTotal before "+str(xTotal)+chr(10)
MsgInfo( saying )
/*
xLabor := 0.00
xParts := 0.00
xMisc := 0.00
xTax := 0.00
xTotal := 0.00
*/
xLabor := xLabor+10.00
xParts := xParts+5.00
xMisc := 0
xTax := round((xParts *.07),2)
xTotal := xLabor+xParts+xMisc+xTax
oParts:ReFresh()
oLabor:ReFresh()
oMisc:ReFresh()
oTax:ReFresh()
oTotal:ReFresh()
SysReFresh()
Saying += "out ReCalc check screen"+chr(10)
Saying += " "+chr(10)
Saying += "xLabor after "+str(xLabor)+chr(10)
Saying += "xParts after "+str(xParts)+chr(10)
Saying += "xMisc after "+str(xMisc)+chr(10)
Saying += "xTax after "+str(xTax)+chr(10)
Saying += "xTotal after "+str(xTotal)+chr(10)
MsgInfo( saying )
Return( .T. )
//------------------------------
Static Func _ReSizeUm( oWorkB1,oWndChildB1 )
oWorkB1:SetSize( oWndChildB1:nWidth, oWndChildB1:nHeight, .t. ) // frame and dialog link
// dialog controls
*oWorkB1:bResized = { | nSizeType, nWidth, nHeight | ResizeControls( nSizeType, nWidth, nHeight, oWorkB1 ) }
Return(nil)
//-------------------------
Static Func ResizeControls( nSizeType, nWidth, nHeight, oWorkB1 )
if nSizeType = 0 //SIZE_MAXIMIZED
oWorkB1:aControls[ 1 ]:SetSize( nWidth - 170, nHeight - 295 ) //txbrowse
endif
Return(nil)
//--------------------
Static Func _DoIt( cMODE )
Return(.t.)
//--------------------------------
Static FUNCTION ExitPgm( lOk3,oWndchildB,oWndChild,lOk,oFontB,oFontBig )
// olbx is from the repair screen
// obrw is from this repair detail screen
LOCAL lOK1
Msginfo( "ExitPgm")
IF lOk3 = .T.
lOK := .T.
lOK1 := lOK
oWndChildB:End()
oFontB:End()
oFontBig:End()
oWndChild:Show()
ENDIF
RETURN( lOK1 )
//--------------------
Static Func _InvtFind( oWnd,oWndChildB,oFontB,oFontBig,nRepairNumber,;
xLabor,xParts,xMisc,xTax,xTotal,;
oLabor,oParts,oMisc,oTax,oTotal)
Local oIco,oBtn1,oBtn2,oBtn3,oBtn4
Local Saying,xTitle
Local lok3
Local oInvt,oWndChildD
xParts := 10.00
xLabor := 10.00
xMisc := 20.00
xTax := 0
xTotal := 40.00
oParts:ReFresh()
oLabor:ReFresh()
oMisc:ReFresh()
oTax:ReFresh()
oTotal:ReFresh()
SysReFresh()
Saying := "Check page totals"+chr(10)
Saying += "xParts "+str(xParts)+chr(10)
Saying += "xLabor "+str(xLabor)+chr(10)
Saying += "xMisc "+str(xMisc)+chr(10)
Saying += "xTax "+str(xTax)+chr(10)
Saying += "xTotal "+str(xTotal)+chr(10)
MsgInfo(Saying)
********oWndChildB:Hide()
lOk3 := .f.
xTitle := "Parts Selection Find Routine"
DEFINE WINDOW oWndChildD ;
FROM 0,0 to 39,120 ;
MDICHILD ;
OF oWnd ;
TITLE xTITLE
DEFINE DIALOG oInvt RESOURCE "INVTFIND" of oWndChildD
REDEFINE BTNBMP oBtn2 ID 161 PROMPT "Transfer" CENTER ;
of oInvt 2007 ;
ACTION ( _Transfer( oWnd,oWndChildD,oFontB,oFontBig,nRepairNumber,;
@xLabor,@xParts,@xMisc,@xTax,@xTotal,;
oLabor,oParts,oMisc,oTax,oTotal))
REDEFINE BTNBMP oBtn3 ID 162 PROMPT "Close" CENTER ;
of oInvt 2007 ;
ACTION (oWndChildD:End())
ACTIVATE DIALOG oInvt NOMODAL ;
VALID(!GETKEYSTATE( 27 ))
ACTIVATE WINDOW oWndChildD ;
ON INIT ( oInvt:Move( 0,0, oWndchildD:nWidth, oWndchildD:nHeight, .T. ), ;
oWndChildD:bResized := {|| _ReSizeUm1( oInvt,oWndChildD) }, ;
oInvt:refresh(.t.));
VALID ( IIF( !lOK3, ExitPgm3(.T.,oWndChildD,oWndChildB,@lOk3 ), .F. ))
RETURN( nil )
//-----------------------------------
Static Func _ReSizeUm1( oInvt,oWndChild )
Local Saying
// for inventory find
oInvt:SetSize( oWndChild:nWidth, oWndChild:nHeight, .t. ) // frame and dialog link
Saying := "Slide this window to the right to reveal totals"+chr(10)
Saying += "then proceed to the Transfer Button"+chr(10)
MsgInfo( saying )
Return(nil)
//--------------------------------------------
Static Func _Transfer( oWnd,oWndChildD,;
oFontB,oFontBig,nRepairNumber,;
xLabor,xParts,xMisc,xTax,xTotal,;
oLabor,oParts,oMisc,oTax,oTotal,nAssignedTo,cLoc)
Local oDlgE,oButt1,oButt2,oButt3,cTitle,oWndChildE
Local lOk5,oIco
Local Saying
Local oP,oD,oQ,oR,oTran,nTran,oHand,nHand
Local lUpDt
Local oSay1,oSay2,oSay3,oSay4,oSay5,oSay6,oSay7
Local cItemDescription,nPrice,cInventoryId,cInventoryType,nExtend,nQty
Local lTransfer
Saying := "In Transfer passed values"+chr(10)
Saying += "xLabor "+str(xLabor)+chr(10)
Saying += "xParts "+str(xParts)+chr(10)
Saying += "xMisc "+str(xMisc)+chr(10)
Saying += "xTax "+str(xTax)+chr(10)
Saying += "xTotal "+str(xTotal)+chr(10)
msginfo( Saying )
xLabor := 5.00
xParts := 50.00
xMisc := 5.00
xTax := 0
xTotal := 60.00
oLabor:ReFresh()
oParts:ReFresh()
oMisc:ReFresh()
oTax:ReFresh()
oTotal:ReFresh()
SysReFresh()
Saying := "New Values Do not show up HERE"+chr(10)
Saying += "xLabor "+str(xLabor)+chr(10)
Saying += "xParts "+str(xParts)+chr(10)
Saying += "xMisc "+str(xMisc)+chr(10)
Saying += "xTax "+str(xTax)+chr(10)
Saying += "xTotal "+str(xTotal)+chr(10)
Msginfo( Saying )
nQty := 1
cItemDescription := "USB 2.0 Ethernet Mini-Adapter"
nPrice := 18.50
cInventoryId := 524766
cInventoryType := "Parts"
nExtend := Round( (nPrice * nQty ),2 )
nHand := 10
*LightGreyGrad()
lTransfer := .f.
lUpDt := .f.
cTITLE := "Inventory Transfer"
DEFINE ICON oIco RESOURCE "COMPASS"
DEFINE WINDOW oWndChildE ;
FROM 13,56 to 35,115 ;
ICON oIco ;
MDICHILD ;
NOMINIMIZE ;
NOZOOM ;
OF oWnd ;
TITLE cTITLE
DEFINE DIALOG oDlgE RESOURCE "TRANSFER" of oWndChildE
REDEFINE SAY oSay6 PROMPT "Transferring From Inventory" ID 156 OF oDlgE UPDATE
oSay6:SetFont( oFontBig )
oSay6:nClrText := nRgb( 7,7,224 ) // blue
REDEFINE SAY oSay1 PROMPT "Part Num" ID 150 OF oDlgE UPDATE
oSay1:SetFont( oFontB )
REDEFINE SAY oSay2 PROMPT "Description" ID 152 OF oDlgE UPDATE
oSay2:SetFont( oFontB )
REDEFINE SAY oSay3 PROMPT "Qty on Hand" ID 154 OF oDlgE UPDATE
oSay3:SetFont( oFontB )
REDEFINE SAY oSay4 PROMPT "To Repair Order" ID 151 OF oDlgE UPDATE
oSay4:SetFont( oFontB )
REDEFINE SAY oSay5 PROMPT "Quantity to Transfer" ID 155 OF oDlgE UPDATE
oSay5:SetFont( oFontBig )
oSay5:nClrText := nRgb( 7,7,224 ) // blue
REDEFINE SAY oSay6 ID 153 OF oDlgE UPDATE
oSay6:SetFont( oFontB )
REDEFINE GET oP VAR cInventoryId ID 160 of oDlgE ;
COLOR CLR_BLACK,14869218 READONLY
REDEFINE GET oD VAR cItemDescription ID 162 of oDlgE ;
COLOR CLR_BLACK,14869218 READONLY
REDEFINE GET oHand VAR nHand ID 163 of oDlgE PICTURE "999,999" ;
COLOR CLR_BLACK,14869218 READONLY
REDEFINE GET oR VAR nRepairNumber ID 165 of oDlgE ;
COLOR CLR_BLACK,14869218 READONLY
REDEFINE GET oQ VAR nQty ID 167 OF oDlgE UPDATE;
PICTURE "9999" SPINNER MIN 1 MAX 1000
REDEFINE BTNBMP oButt1 ID 180 of oDlgE ; // ok
PROMPT "&Ok" CENTER 2007;
ACTION ( lUpDt := .t., oWndChildE:END() )
REDEFINE BTNBMP oButt2 ID 181 of oDlgE ; // cancel
PROMPT "&Cancel" CENTER 2007;
ACTION ( lUpDt := .f., oWndChildE:END() )
ACTIVATE DIALOG oDlgE NOWAIT ;
ON INIT ( oDlgE:Move( 0, 0 )) ;
VALID (!GETKEYSTATE( 27 )) // do not allow esc key here
ACTIVATE WINDOW oWndChildE ;
ON INIT (oWndChildE:SetSize( oDlgE:nWIDTH, oDlgE:nHEIGHT, .T. ),;
oQ:SetFocus());
VALID ( IIF( !lTransfer, ExitPgm4(.T.,oWndChildE,lUpDt,;
oWndChildD,@lTransfer,@nQty,@nPrice,;
@xLabor,@xParts,@xMisc,@xTax,@xTotal,;
oLabor,oParts,oMisc,oTax,oTotal), .F.))
Return(lTransfer)
//-------------------------------------------
Static FUNCTION ExitPgm3( lOk2,oWndchildD,oWndChildB,lOk3 )
// from inventoryfind
LOCAL lOK1
msginfo("ExitPgm3")
lOk1 := .f.
IF lOk2 = .T.
lOK3 := .T.
lOK1 := lOK3
oWndChildD:End()
oWndChildB:Show()
ENDIF
RETURN( lOK1 )
//-------------------------------------------
Static FUNCTION ExitPgm4( lOk2,oWndchildE,lUpDt,oWndChildD,lTransfer,nQty,nPrice,;
xLabor,xParts,xMisc,xTax,xTotal,;
oLabor,oParts,oMisc,oTax,oTotal )
LOCAL lOK1,YesNo,nOk,cS
// lUpDt = .t. save
// lUpDt = .f. cancel
*msginfo( "e4")
msginfo("ExitPgm4")
lOk1 := .f.
IF lOk2 = .T.
lTransfer := .T.
lOK1 := lTransfer
oWndChildE:End() // transfer
oWndChildD:End() // invtfind
_ReCalcTotals( @xLabor,@xParts,@xMisc,@xTax,@xTotal,;
oLabor,oParts,oMisc,oTax,oTotal)
oLabor:ReFresh()
oParts:ReFresh()
oMisc:ReFresh()
oTax:ReFresh()
oTotal:ReFresh()
SysReFresh()
ENDIF
RETURN( lOK1 )
// END