ÿþ#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) CommodityInspectionExpenseWin : public xframe { public: CommodityInspectionExpenseWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static CommodityInspectionExpenseWin* CreateInstance(void* implPtr, void* hWnd) { CommodityInspectionExpenseWin* pWin = new CommodityInspectionExpenseWin(implPtr, (HWND)hWnd); return pWin; } public: xdwgrid dw_list; xnode m_agentNode; //Agent Condition 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; } //&q¹pÀo;mYtýQpe int OnSetFocus(TEvent* evt, LPARAM param) { //͑nå]wQag SetAgent(); return 1; } int OnItemChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname=hdr.colname; xstring value = hdr.data; xstring dwname = L"dw_list"; if(value != L"") { //alert(dwname); KXMLDOMNodeList nlist = GetElement().selectNodes(L"//*[@name='"+dwname+L"']/trans[@for='"+colname+L"']"); ViewObject::TransData(nlist, dw_list, hdr.row, colname, value); } return 1; } int OnSave() { xml x ; KXMLDOMDocument xdoc = x; dw_list.DwUpdateAllToEx(xdoc); xaserverarg arg ; arg.AddArg(L"content",x.xml()); //alert(x); //return 1; if(xurl::get(L"/sale/data/expense3/update/CommodityInspection", arg.GetString(),x)!=1) { xstring error = x.text(); alert(L"err:"+error); return 1; } //alert(x); alert(L"ÝOX[bŸRÿ"); dw_list.ResetUpdateStatus(); return 1; } //}TäNÑS^ýQpe int OnCmdDispatch(xstring comdid) { if(comdid==L"xmAddRow") { int row =dw_list.GetRowCount(); dw_list.InsertRow(0); xstring suserid = publiccode::GetUser().id; xstring susername = publiccode::GetUser().name; dw_list.SetItemString(row+1,L"CreateID",suserid); dw_list.SetItemDisplayString(row+1,L"CreateID",susername); xstring sdate = publiccode::GetCurrentDate(); dw_list.SetItemString(row+1,L"CreateDate",sdate); return 1; } else if(comdid==L"xmDeleteRow") { dw_list.DeleteRow(0); return 1; } else if (comdid == L"xmSave") { OnSave(); } 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)&CommodityInspectionExpenseWin::OnXCommand); //·ƒÖS&q¹p‹NöN ÿ(uŽN͑nå]wQag AttachEvent(L"WM_SETFOCUS", (FEvent)&CommodityInspectionExpenseWin::OnSetFocus); AttachEvent(L"dw_list",L"DWV_ITEMCHANGED", (FEvent)&CommodityInspectionExpenseWin::OnItemChanged); return 1; } int OnRetrieve() { xml x ; xaserverarg arg ; //arg.AddArg(L"Status",L"1"); if (getUrl(L"/sale/data/Expense3/view/CommodityInspection",arg.GetString(),x)!=1) { trace(x.text()); return -1; }else { dw_list.Retrieve(x); dw_list.Redraw(); } return 1; } int onload() { dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/Expense3/inspection/list"); OnAttachEvent(); return 1; } int onloaded() { SetAgent(); OnRetrieve(); return 1; } };