þÿ#include <wobject/xstring.hpp> #include <xcontrol/xtreeview.hpp> #include <xcontrol/xdwgrid.hpp> #include <wobject/xdouble.hpp> #include <xcontrol/xlayersheet.hpp> #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) CommissionExpenseBase : public xframe { public: HWND hObject = 0; xdwtable dw_base; xnode m_agentNode; //Agent Condition bool updated; public: CommissionExpenseBase(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static CommissionExpenseBase* CreateInstance(void* implPtr, void* hWnd) { CommissionExpenseBase* pWin = new CommissionExpenseBase(implPtr, (HWND)hWnd); return pWin; } int SetAgent() { return 1; xstring xfNodeAgentArea = L"agentarea"; xnode anode = GetAgentNode(xfNodeAgentArea); if (m_agentNode) { SetAgentNode(anode, m_agentNode); } else { KXMLDOMElement xframeElement = GetElement(); KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[1]/*"); if (agent) { xstring s = agent.xml(); m_agentNode = SetAgentNode(anode, s); } } return 1; } //q&p¹oÀm;YtQýep int OnSetFocus(TEvent* evt, LPARAM param) { //‘Ín]åQwga //SetAgent(); return 1; } int OnSave() { xml x ; xaserverarg arg; dw_base.AcceptText(); dw_base.DwUpdateAllTo(x); xstring error = L""; arg.AddArg(L"content", x.xml()); if (xurl::get(L"/sale/data/expense3/update/Commission", arg.GetString(), x) != 1) { error = x.text(); //alert(error); } else { xstring str = x.documentElement().getAttribute(L"text"); if (str == L"true") { dw_base.ResetUpdateStatus(); alert(L"OÝ[XbRŸ!"); SendMessage(hObject, 0x401, (LPARAM)L"xmRefresh", 0); CloseWindow(); } else { alert(L"OÝ[XY1%!"); } //alert(str); } return 1; } //T}NäSÑ^Qýep int OnCmdDispatch(xstring comdid) { if (comdid == L"xmSave") { OnSave(); return 1; } else if (comdid == L"xmClose") { if (updated) SendMessage(hObject, 0x401, (LPARAM)L"xmRefresh", 0); CloseWindow(); return 1; } return 0; } //T}NäYtN‹Nö int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnItemChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname = hdr.colname; xstring value = hdr.data; xstring dwname = L"dw_base"; if (value != L"") { KXMLDOMNodeList nlist = GetElement().selectNodes(L"//*[@name='" + dwname + L"']/trans[@for='" + colname + L"']"); ViewObject::TransData(nlist, dw_base, hdr.row, colname, value); } if (colname == L"CommAmount" || colname == L"Exchage") { double CommAmount = dw_base.GetItemDouble(hdr.row, L"CommAmount"); double Exchage = dw_base.GetItemDouble(hdr.row, L"Exchage"); dw_base.SetItemDouble(hdr.row, L"CommAmountRMB", xdouble((CommAmount * Exchage)).round(2)); } return 1; } int OnAttachEvent() { //~Ñ[š]åQwgap¹QûN‹Nö AttachEvent(L"WM_XCOMMAND", (FEvent)&CommissionExpenseBase::OnXCommand); //ƒ·SÖq&p¹N‹Nöÿ u(NŽ‘Ín]åQwga AttachEvent(L"WM_SETFOCUS", (FEvent)&CommissionExpenseBase::OnSetFocus); AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", (FEvent)&CommissionExpenseBase::OnItemChanged); return 1; } int OnRetrieve(xstring CommissionExpenseID) { xml x ; xaserverarg arg; arg.AddArg(L"CommissionExpenseID", CommissionExpenseID); if (getUrl(L"/sale/data/Expense3/GetCommissionByID", arg.GetString(), x) != 1) { trace(x.text()); return -1; } else { dw_base.Retrieve(x); dw_base.Redraw(); } return 1; } int onload() { SetArg(); dw_base = GetControl(L"dw_base"); dw_base.openUrl(L"/sale/view/Expense3/commission/Base"); dw_base.SetColHeaderHeight(0); dw_base.SetRowSelectorWidth(0); dw_base.SetHScrollState(false); dw_base.SetVScrollState(false); xstring CommissionExpenseID = L""; hObject = 0; if (GetWinParam()) { xaserverarg arg=GetArg(); CommissionExpenseID = arg.GetArgString(L"CommissionExpenseID"); hObject = (HWND)arg.GetParam(L"HWND"); } if (CommissionExpenseID != L"") { OnRetrieve(CommissionExpenseID); } else { xstring suserid = publiccode::GetUser().id; xstring susername = publiccode::GetUser().name; dw_base.SetItemString(1, L"CreateID", suserid); dw_base.SetItemDisplayString(1, L"CreateID", susername); xstring sdate = publiccode::GetCurrentDate(); dw_base.SetItemString(1, L"CreateDate", sdate); } OnAttachEvent(); updated = false; return 1; } int onloaded() { //SetAgent(); return 1; } };