ÿþ#include <wobject/xstring.hpp> #include <xcontrol/xtreeview.hpp> #include <xcontrol/xdwgrid.hpp> #include <wobject/xdouble.hpp> #include <xcontrol/xlayersheet.hpp> #include <xcontrol/xdatetimepick.hpp> #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) APSpliteLineView : public xframe { public: xdwgrid dw_list; xnode m_agentNode; //Agent Condition double APAmount; xstring APID; public: APSpliteLineView(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static APSpliteLineView* CreateInstance(void* implPtr, void* hWnd) { APSpliteLineView* pWin = new APSpliteLineView(implPtr, (HWND)hWnd); return pWin; } int SetAgent() { 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; } int OnSave() { dw_list.AcceptText(); xstring error; xstring str; xml x ; xaserverarg arg ; arg.setNativePointer(xaserverarg::CreateInstance()); dw_list.DwUpdateAllToEx(x); arg.AddArg(L"content",x.xml()); if(xurl::get(L"/sale/data/AP/update", arg.GetString(),x)!=1) { error = x.text(); alert(L"err:"+error); return 1; } str = x.documentElement().getAttribute(L"text"); if(str != L"true") { alert(L"ÝOX[1Y%1!"); return 1; }else { dw_list.ResetUpdateStatus(); alert(L"ÝOX[bŸR!"); return 1; } } //&q¹pÀo;mYtýQpe int OnSetFocus(TEvent* evt, LPARAM param) { //͑nå]wQag SetAgent(); return 1; } int OnRowAdd() { double amt = 0.0; int row = 0; for(row = 1; row <= dw_list.GetRowCount();row++) { amt += dw_list.GetItemDouble(row,L"Amount"); } if(((APAmount*100.0) - (amt*100.0))==0) { alert(L"ё˜ò]hQèRrR"); return 1; } row = dw_list.InsertRow(0); dw_list.SetItemString(row,L"APID",APID); dw_list.SetItemDouble(row,L"Amount", APAmount - amt); return 1; } int OnRowDelete() { dw_list.DeleteRow(0); return 1; } //}TäNÑS^ýQpe int OnCmdDispatch(xstring comdid) { if(comdid==L"xmRowAdd") { return OnRowAdd(); } else if(comdid==L"xmRowDelete") { return OnRowDelete(); } else if(comdid==L"xmSave") { return OnSave(); } else if(comdid==L"xmClose") { CloseWindow(); return 1; } return 0; } //}TäNYt‹NöN int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnAttachEvent() { //Ñ~š[å]wQag¹pûQ‹NöN AttachEvent(L"WM_XCOMMAND", (FEvent)&APSpliteLineView::OnXCommand); //·ƒÖS&q¹p‹NöN ÿ(uŽN͑nå]wQag AttachEvent(L"WM_SETFOCUS", (FEvent)&APSpliteLineView::OnSetFocus); return 1; } int OnRetrieve() { xml x ; xaserverarg arg ; arg.AddArg(L"APID",APID); if (getUrl(L"/sale/data/AP/APSpliteLine",arg.GetString(),x)!=1) { trace(x.text()); return -1; }else { dw_list.Retrieve(x); dw_list.Redraw(); } return 1; } int onload() { SetArg(); dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/AP/template/PrepaySplite"); if(GetWinParam()) { xaserverarg arg = GetArg(); APID = arg.GetArgString(L"APID"); APAmount = arg.GetArgString(L"Amount").toDouble(); OnRetrieve(); } OnAttachEvent(); dw_list.SetColumnState(L"APID",false); return 1; } int onloaded() { SetAgent(); return 1; } };