#include "fivewin.ch"
#include "xbrowse.ch"
#include "tdolphin.ch"
#include "dtpicker.ch"
FUNCTION uzsak()
local oWnd, oBrw, oQry, oCol, oBar, oPopup
local aDgr, aCol, aHdr, aPct, aWnd
local cFld, cSql, cStr
local cTbl := "uzsakym"
local cWnd := "uzsakym"
local nL_g := if( cLg == "L", 2, 3 )
local cYs := padr( msgId( "cTaip", cLg ), 4 )
local cNo := padr( msgId( "cNe" , cLg ), 4 )
local lEdt := .t.
local u := 0
local aMod := {}
local aGrd := { ;
{ "uzsak" , "Užsak.ID" , "Order.ID" , 150, "@!" }, ;
{ "telkinys" , "Telkinys" , "Pool" , 80, "@!K" }, ;
{ "preke" , "Prekės ID" , "Item ID" , 150, "@!K" }, ;
{ "uzs_kiekis" , "Kiekis" , "Qty." , 75, "@999999" }, ;
{ "svarbus" , "Svarbus" , "Important" , 50, "" }, ;
{ "specai" , "Spec" , "Spec" , 50, "" }, ;
{ "mazi" , "Mazi" , "Smalls" , 50, "" }, ;
{ "uzs_spalv" , "Užsak.spalvos" , "Ord.colors" , 100, "@!K" }, ;
{ "uzs_data" , "Užs.data" , "Ord.date" , 100, "@D" }, ;
{ "uzs_sav" , "Užs.sav." , "Ord.week" , 75, "" }, ;
{ "graz_data" , "Grąž.data" , "Ret.date" , 100, "@D" }, ;
{ "graz_sav" , "Grąž.sav." , "Ret.week" , 75, "" }, ;
{ "fakt_data" , "Fakt.data" , "Fact.date" , 100, "@D" }, ;
{ "fakt_sav" , "Fakt.sav." , "Fact.week" , 75, "" }, ;
{ "pastabos_ord" , "Ord.pastaba" , "Ord.note" , 180, "@!" }, ;
{ "zymos" , "Žymos" , "Notes" , 80, "@!" }, ;
{ "kerpa" , "Kerpa" , "Cutting" , 100, "" }, ;
{ "sukirp_lap" , "Suk.lapas" , "Cut.page" , 80, "@!K" }, ;
{ "etiketes" , "Etiketės" , "Labels" , 40, "@!K" }, ;
{ "gav_data" , "Gavim.data" , "Recv.date" , 100, "@D" }, ;
{ "subrang" , "Subrangovas" , "Subcontr." , 100, "" }, ;
{ "aud_nuras" , "Aud.nur." , "Mater.off" , 60, "" }, ;
{ "frn_nuras" , "Furn.nur." , "Furnit.off" , 60, "" }, ;
{ "invc_nuras" , "Sąsk.nur." , "Invoice off" , 60, "" }, ;
{ "nav_nuras" , "NAV nur." , "NAV off" , 60, "" }, ;
{ "pasel_prad" , "Pasel.prad." , "Mak.begin" , 60, "" }, ;
{ "pokav_prad" , "Pokav.prad." , "Pack.begin" , 60, "" }, ;
{ "prilyg_mod" , "Prilyg.modelis" , "Equat.model" , 150, "@!K" }, ;
{ "prilyg_kiekis" , "Prilyg.kiekis" , "Eq.qty" , 75, "@999999" }, ;
{ "pastabos_buh" , "Pastabos buh." , "Account notes" , 180, "@!" }, ;
{ "buh_specas" , "Buh.spec" , "Buh.spec" , 60, "" }, ;
{ "pastabos_zs" , "Pastabos Zarasu" , "Notes of Zarasai" , 180, "@!" }, ;
{ "pok_lap_mod" , "Pokav.lapo modelis" , "Pack.list model" , 150, "@!K" } }
aWnd := wnd_rest( cWnd )
if len( aWnd ) == 0
aWnd := { 20, 20, 500, 800, .f. }
endif
aDgr := brw_rest( cTbl, aGrd, cLg )
cFld := aDgr[ 1 ]
aCol := aDgr[ 2 ]
aHdr := aDgr[ 3 ]
aPct := aDgr[ 7 ]
cStr := if( cLg == "L", "pav_lt", "pav_en" )
aMod := qry_arr( "SELECT preke," + cStr + " FROM prekes WHERE prek_tipas = 'Gaminys' AND db='" + cDb_id + "' ORDER BY preke", { "preke", cStr } )
cSql := "SELECT " + cFld + " FROM uzsakym WHERE db='" + cDb_id + "'"
oQry := oServ:Query( cSql )
DEFINE WINDOW oWnd MDICHILD OF wndMain() TITLE "Užsakymai" PIXEL FROM aWnd[ 1 ], aWnd[ 2 ] TO aWnd[ 3 ], aWnd[ 4 ]
if aWnd[ 5 ] == .f.
oWnd:Move( aWnd[ 1 ], aWnd[ 2 ], aWnd[ 4 ], aWnd[ 3 ], .t. )
else
oWnd:Maximize()
endif
Ikona( oWnd )
oWnd:Hide()
oWnd:Cargo := cWnd
@ 0, 0 XBROWSE oBrw OF oWnd DATASOURCE oQry COLUMNS aCol HEADERS aHdr PICTURES aPct AUTOSORT
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:lColDividerComplete := .t.
brw_col( oBrw, aCol )
oCol := oBrw:aCols[ ascan( aCol, "uzsak" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:uzsak }
:bEditValid := { | oGet, oCol | var_not_exist( "uzsakym", oCol:cExpr, oGet:Value(), "ut" ) }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,, ( oQry:uzsak := xVal, oQry:Save(), if( oQry:lAppend == .t., oQry:lAppend := .f., ) ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "telkinys" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:telkinys }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:telkinys := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "preke" ) ]
WITH OBJECT oCol
:bEditValue := { || oQry:preke }
:nEditType := if( lEdt, EDIT_GET_BUTTON, EDIT_NONE )
:bEditBlock := { | nRow, nCol, oCol | brw_arr( "Pasirinkite !", { "Modelis", "Model.pavadinimas" }, aMod, oCol:Value ) }
:bEditValid := { | oGet, oCol | mod_pas( aMod, oCol:Value ) }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:preke := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "prilyg_mod" ) ]
WITH OBJECT oCol
:bEditValue := { || oQry:prilyg_mod }
:nEditType := if( lEdt, EDIT_GET_BUTTON, EDIT_NONE )
:bEditBlock := { | nRow, nCol, oCol | brw_arr( "Pasirinkite !", { "Modelis", "Model.pavadinimas" }, aMod, oCol:Value ) }
:bEditValid := { | oGet, oCol | mod_pas( aMod, oCol:Value ) }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:prilyg_mod := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "uzs_kiekis" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:uzs_kiekis }
:bEditValid := { | oGet, oCol | oCol:Value > 0 }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:uzs_kiekis := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "prilyg_kiekis" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:prilyg_kiekis }
:bEditValid := { | oGet, oCol | oCol:Value >= 0 }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:prilyg_kiekis := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "svarbus" ) ]
WITH OBJECT oCol
:AddBitmap( cProgr_pict + "on.bmp" )
:AddBitmap( cProgr_pict + "off.bmp" )
:bEditValue := { || oQry:svarbus }
:bBmpData := { || if( oQry:svarbus == .t., 1, 2 ) }
if lEdt
:bStrData := { || if( oQry:svarbus == .t., cYs, cNo ) }
:nEditType := EDIT_LISTBOX
:aEditListTxt := { cYs, cNo }
:aEditListBound := { .t., .f. }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:svarbus := xVal, oQry:Save() ) ) }
endif
END
oCol := oBrw:aCols[ ascan( aCol, "specai" ) ]
WITH OBJECT oCol
:AddBitmap( cProgr_pict + "on.bmp" )
:AddBitmap( cProgr_pict + "off.bmp" )
:bEditValue := { || oQry:specai }
:bBmpData := { || if( oQry:specai == .t., 1, 2 ) }
if lEdt
:bStrData := { || if( oQry:specai == .t., cYs, cNo ) }
:nEditType := EDIT_LISTBOX
:aEditListTxt := { cYs, cNo }
:aEditListBound := { .t., .f. }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:specai := xVal, oQry:Save() ) ) }
endif
END
oCol := oBrw:aCols[ ascan( aCol, "mazi" ) ]
WITH OBJECT oCol
:AddBitmap( cProgr_pict + "on.bmp" )
:AddBitmap( cProgr_pict + "off.bmp" )
:bEditValue := { || oQry:mazi }
:bBmpData := { || if( oQry:mazi == .t., 1, 2 ) }
if lEdt
:bStrData := { || if( oQry:mazi == .t., cYs, cNo ) }
:nEditType := EDIT_LISTBOX
:aEditListTxt := { cYs, cNo }
:aEditListBound := { .t., .f. }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:mazi := xVal, oQry:Save() ) ) }
endif
END
oCol := oBrw:aCols[ ascan( aCol, "buh_specas" ) ]
WITH OBJECT oCol
:AddBitmap( cProgr_pict + "on.bmp" )
:AddBitmap( cProgr_pict + "off.bmp" )
:bEditValue := { || oQry:buh_specas }
:bBmpData := { || if( oQry:buh_specas == .t., 1, 2 ) }
if lEdt
:bStrData := { || if( oQry:buh_specas == .t., cYs, cNo ) }
:nEditType := EDIT_LISTBOX
:aEditListTxt := { cYs, cNo }
:aEditListBound := { .t., .f. }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:buh_specas := xVal, oQry:Save() ) ) }
endif
END
oCol := oBrw:aCols[ ascan( aCol, "uzs_spalv" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:uzs_spalv }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:uzs_spalv := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "uzs_data" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_DATE, EDIT_NONE )
:bEditValue := { || oQry:uzs_data }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:uzs_data := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "uzs_sav" ) ]
WITH OBJECT oCol
:nEditType := EDIT_NONE
:bEditValue := { || oQry:uzs_sav }
END
oCol := oBrw:aCols[ ascan( aCol, "graz_data" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_DATE, EDIT_NONE )
:bEditValue := { || oQry:graz_data }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:graz_data := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "graz_sav" ) ]
WITH OBJECT oCol
:nEditType := EDIT_NONE
:bEditValue := { || oQry:graz_sav }
END
oCol := oBrw:aCols[ ascan( aCol, "fakt_data" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_DATE, EDIT_NONE )
:bEditValue := { || oQry:fakt_data }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:fakt_data := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "fakt_sav" ) ]
WITH OBJECT oCol
:nEditType := EDIT_NONE
:bEditValue := { || oQry:fakt_sav }
END
oCol := oBrw:aCols[ ascan( aCol, "pastabos_ord" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:pastabos_ord }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:pastabos_ord := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "zymos" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:zymos }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:zymos := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "sukirp_lap" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:sukirp_lap }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:sukirp_lap := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "etiketes" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:etiketes }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:etiketes := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "gav_data" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_DATE, EDIT_NONE )
:bEditValue := { || oQry:gav_data }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:gav_data := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "kerpa" ) ]
WITH OBJECT oCol
:bEditValue := { || oQry:kerpa }
:nEditType := if( lEdt, EDIT_LISTBOX, EDIT_NONE )
:aEditListTxt := { padr( "Danija", 10 ), padr( "Zarasai", 10 ) }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:kerpa := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "subrang" ) ]
WITH OBJECT oCol
:bEditValue := { || oQry:subrang }
:nEditType := if( lEdt, EDIT_LISTBOX, EDIT_NONE )
:aEditListTxt := { padr( "UT", 10 ), padr( "BR", 10 ) }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:subrang := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "aud_nuras" ) ]
WITH OBJECT oCol
:AddBitmap( cProgr_pict + "on.bmp" )
:AddBitmap( cProgr_pict + "off.bmp" )
:bEditValue := { || oQry:aud_nuras }
:bBmpData := { || if( oQry:aud_nuras == .t., 1, 2 ) }
:bStrData := { || NIL }
:nEditType := EDIT_NONE
END
oCol := oBrw:aCols[ ascan( aCol, "frn_nuras" ) ]
WITH OBJECT oCol
:AddBitmap( cProgr_pict + "on.bmp" )
:AddBitmap( cProgr_pict + "off.bmp" )
:bEditValue := { || oQry:frn_nuras }
:bBmpData := { || if( oQry:frn_nuras == .t., 1, 2 ) }
:nEditType := EDIT_NONE
:bStrData := { || NIL }
END
oCol := oBrw:aCols[ ascan( aCol, "invc_nuras" ) ]
WITH OBJECT oCol
:AddBitmap( cProgr_pict + "on.bmp" )
:AddBitmap( cProgr_pict + "off.bmp" )
:bEditValue := { || oQry:invc_nuras }
:bBmpData := { || if( oQry:invc_nuras == .t., 1, 2 ) }
:nEditType := EDIT_NONE
:bStrData := { || NIL }
END
oCol := oBrw:aCols[ ascan( aCol, "nav_nuras" ) ]
WITH OBJECT oCol
:AddBitmap( cProgr_pict + "on.bmp" )
:AddBitmap( cProgr_pict + "off.bmp" )
:bEditValue := { || oQry:nav_nuras }
:bBmpData := { || if( oQry:nav_nuras == .t., 1, 2 ) }
:nEditType := EDIT_NONE
:bStrData := { || NIL }
END
oCol := oBrw:aCols[ ascan( aCol, "pasel_prad" ) ]
WITH OBJECT oCol
:AddBitmap( cProgr_pict + "on.bmp" )
:AddBitmap( cProgr_pict + "off.bmp" )
:bEditValue := { || oQry:pasel_prad }
:bBmpData := { || if( oQry:pasel_prad == .t., 1, 2 ) }
:nEditType := EDIT_NONE
:bStrData := { || NIL }
END
oCol := oBrw:aCols[ ascan( aCol, "pokav_prad" ) ]
WITH OBJECT oCol
:AddBitmap( cProgr_pict + "on.bmp" )
:AddBitmap( cProgr_pict + "off.bmp" )
:bEditValue := { || oQry:pokav_prad }
:bBmpData := { || if( oQry:pokav_prad == .t., 1, 2 ) }
:nEditType := EDIT_NONE
:bStrData := { || NIL }
END
oCol := oBrw:aCols[ ascan( aCol, "pastabos_buh" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:pastabos_buh }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:pastabos_buh := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "pastabos_zs" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:pastabos_zs }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:pastabos_zs := xVal, oQry:Save() ) ) }
END
oCol := oBrw:aCols[ ascan( aCol, "pok_lap_mod" ) ]
WITH OBJECT oCol
:nEditType := if( lEdt, EDIT_GET, EDIT_NONE )
:bEditValue := { || oQry:pok_lap_mod }
:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:pok_lap_mod := xVal, oQry:Save() ) ) }
END
WITH OBJECT oBrw
:bClrStd := { || If( oBrw:KeyNo() % 2 == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
:bPopUp := { |oCol| brw_menu( oCol ) }
:lRecordSelector := .t.
END
if len( aDgr ) > 0
for u := 1 to len( oBrw:aCols )
oBrw:aCols[ u ]:nWidth := aDgr[ 5, u ]
oBrw:aCols[ u ]:lHide := aDgr[ 6, u ]
next
endif
SetBalloon( .T. )
DEFINE BUTTONBAR oBar OF oWnd SIZE 60, 60 2007
MENU oPopup POPUP
MENUITEM "Naujas įrašas" ACTION newRec( oBrw, oQry, 1 )
MENUITEM "Nauji įrašai iš Excel failo" ACTION newRec( oBrw, oQry, 2 )
MENUITEM "Nauji įrašai iš Sukirpimo failo" ACTION newRec( oBrw, oQry, 3 )
ENDMENU
DEFINE BUTTON OF oBar ACTION newRec( oBrw, oQry ) FILENAME cProgr_pict + "Bar\New.bmp" MENU oPopup PROMPT if( cLg == "L", 'Naujas', 'New' ) TOOLTIP if( cLg == "L", 'Nauji įrašai', 'New records' )
DEFINE BUTTON OF oBar ACTION delRec( oBrw, oQry ) FILENAME cProgr_pict + "Bar\Delete.bmp" PROMPT if( cLg == "L", 'Šalinti', 'Delete' ) TOOLTIP if( cLg == "L", 'Šalinti įrašus', 'Delete records' )
DEFINE BUTTON OF oBar ACTION excRec( oBrw, oQry ) FILENAME cProgr_pict + "Bar\Doc-Excel.bmp" GROUP PROMPT if( cLg == "L", 'Excelis', 'Excel' ) TOOLTIP if( cLg == "L", 'Eskportas į Excelį', 'Export to Excel' )
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd ON INIT ( oBrw:GoBottom(), oBrw:SetFocus(), if( aWnd[ 5 ] == .t., oWnd:Maximize(), ) ) VALID ( brw_save( oBrw, cTbl ), wnd_save( oWnd, cWnd ), wnd_end( oBrw, oQry ), .t. )
return( NIL )
function mod_pas( aMod, cMod )
if empty( cMod )
return .f.
endif
return( if( ascan( aMod, { |x| x[ 1 ] == cMod } ) <> 0, .t., .f. ) )
function newRec( oBrw, oQry, nRez )
MsgInfo( "naujas irasas ! " + str( nRez ) )
return( NIL )
function delRec( oBrw, oQry )
MsgInfo( "delete record !" )
return( NIL )
function excRec( oBrw, oQry )
MsgInfo( "eksportas i Exceli !" )
return( NIL )