lib
proc Form_Start(FORM
)
f = FORM
pe = PByName
(f
,"AU_EVENT_PURCH"
)
{te: handler of in-memory table}
te = TByName
(pe
,"AU_EVENT_PURCH"
)
task = FormTask
(f
)
mode = __params[6]
if (task = ptApp
end) then
call TEdit
(te
)
call TSetFld
(te
,"SCHEDULED_FLAG"
,"0"
)
call TSetFld
(te
,"DONE_FLAG"
,"0"
)
call TSetFld
(te
,"CANCELED_FLAG"
,"0"
)
call TSetFld
(te
,"STAT"
,"Non Scheduled"
)
call TSetFld
(te
,"SDATE1"
,crDate
)
if (mode = "SUPPLIER_MODE"
) then
bus_id = __params[7]
btitle = __params[8]
call TSetFld
(te
,"AU_BUSINESS"
,bus_id
)
call TSetFld
(te
,"F_AU_BUSINESS_TITLE"
,btitle
)
endif
if (mode = "PRODUCT_MODE"
) then
start_sql "*" "KOSMOS"
SELECT AU_GOOD_CODE.AU_GOOD_CODE
, AU_BUSINESS.AU_BUSINESS
, AU_GOOD.TITLE
AS GTITLE
,
AU_GOOD.CODE
AS GCODE
, AU_GOOD_CODE.CODE
, AU_GOOD_CODE.DESCR
, AU_BUSINESS.TITLE
, AU_GOOD_CODE.AU_GOOD_CODE
FROM (AU_GOOD
LEFT JOIN AU_GOOD_CODE
ON AU_GOOD.AU_GOOD = AU_GOOD_CODE.AU_GOOD
)
LEFT
JOIN AU_BUSINESS
ON AU_GOOD_CODE.AU_BUSINESS = AU_BUSINESS.AU_BUSINESS
WHERE (AU_GOOD.AU_GOOD=:G
)
ORDER BY AU_GOOD_CODE.AU_GOOD_CODE
end_sql
q = QueryByName
()
good_id = __params[7]
call TSetParam
(q
,"G"
,good_id
)
call TExecute
(q
)
call TLast
(q
)
gcode = TGetFld
(q
,"GCODE"
)
gtitle = TGetFld
(q
,"GTITLE"
)
code = TGetFld
(q
,"CODE"
)
descr = TGetFld
(q
,"DESCR"
)
bus_id = TGetFld
(q
,"AU_BUSINESS"
)
bus_t = TGetFld
(q
,"TITLE"
)
code_id = TGetFld
(q
,"AU_GOOD_CODE"
)
call FreeEmbSQL
(q
)
call TSetFld
(te
,"AU_BUSINESS"
,bus_id
)
call TSetFld
(te
,"F_AU_BUSINESS_TITLE"
,bus_t
)
call TSetFld
(te
,"AU_GOOD"
,good_id
)
call TSetFld
(te
,"F_AU_GOOD_CODE"
,gcode
)
call TSetFld
(te
,"F_AU_GOOD_TITLE"
,gtitle
)
call TSetFld
(te
,"AU_GOOD_CODE"
,code_id
)
call TSetFld
(te
,"F_AU_GOOD_CODE_CODE"
,code
)
call TSetFld
(te
,"F_AU_GOOD_CODE_DESCR"
,descr
)
endif
if (mode = "DEMAND_DEPART_MODE"
) then
demand_id = __params[7]
depart_id = __params[8]
call TSetFld
(te
,"AU_PURCH_DEMAND"
,demand_id
)
text = LookUpId
("AU_PURCH_DEMAND"
,demand_id
,"AU_PURCH_DEMAND_D"
)
call TSetFld
(te
,"F_AU_PURCH_DEMAND_AU_PURCH_DEMAND_D"
,text
)
call TSetFld
(te
,"AU_POS"
,depart_id
)
text = LookUpId
("AU_POS"
,depart_id
,"POS_D"
)
call TSetFld
(te
,"F_AU_POS_POS_D"
,text
)
endif
call TPost
(te
)
call ReLoadEditFields
(f
)
endif
if (mode = "DEMAND_DEPART_MODE"
) then
call OnOpenForm_DisableField
("F_AU_PURCH_DEMAND_AU_PURCH_DEMAND_D"
)
call OnOpenForm_DisableField
("F_AU_POS_POS_D"
)
endif
end
proc new_good
()
call OpenFormTop
("ptApp
end"
,"
AU_GOOD_FAST_E.FM"
,"WORK.AU_GOOD"
,1
,"?=AU_GOOD"
)
end
proc calculations
()
AMOUNT_EST = AU_EVENT_PURCH!QUANT * AU_EVENT_PURCH!PRICE_EST
AMOUNT_FIN = AU_EVENT_PURCH!QUANT * AU_EVENT_PURCH!PRICE_FIN
call TEdit
(te
)
call TSetFld
(te
,"AMOUNT_EST"
,AMOUNT_EST
)
call TSetFld
(te
,"AMOUNT_FIN"
,AMOUNT_FIN
)
call TPost
(te
)
call ReLoadEditFields
(f
)
end