þÿ#include <wobject/xstring.hpp> #include <xcontrol/xtreeview.hpp> #include <xcontrol/xdwgrid.hpp> #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" #include "vbusiness/vframe/frame.vframe.vbusiness.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) InsertPOWin : public xframe { public: //xdwgrid dw_list; xdwgrid dw_list; xnode m_agentNode; //Agent Condition MaintPaperCardPOWin lw_obj; public: InsertPOWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static InsertPOWin* CreateInstance(void* implPtr, void* hWnd) { InsertPOWin* pWin = new InsertPOWin(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; } //q&p¹oÀm;YtQýep int OnSetFocus(TEvent* evt, int param) { //‘Ín]åQwga SetAgent(); return 1; } int OnSave() { xml x1 ; xml x ; xml xp ; lw_obj.dw_polist.DwUpdateAllToEx(xp); lw_obj.dw_paper.DwUpdateAllTo(x); lw_obj.dw_process.DwUpdateAllTo(x1); xstring val = xp.xml(); xstring val0 = x.xml(); xstring val1 = x1.xml(); val = L"<data>" + val + val0 + val1 + L"</data>"; trace(val); xaserverarg arg; arg.setNativePointer(arg.CreateInstance()); arg.AddArg(L"content", val); if (xurl::get(L"/sale/data/PurchaseOrder/update/polistex", arg.GetString(), x) != 1) { xstring error = x.text(); alert(error); return 1; } else { xstring str = x.documentElement().getAttribute(L"text"); if (str == L"true") { lw_obj.dw_polist.ResetUpdateStatus(); //dw_list.ResetUpdateStatus(); //dw_list1.ResetUpdateStatus(); lw_obj.dw_paper.ResetUpdateStatus(); lw_obj.dw_process.ResetUpdateStatus(); alert(L"OÝ[XbRŸ!"); } else { alert(L"OÝ[XY1%!"); } //alert(x.GetXml()); } return 1; } int InsertPo() { xdwtable dw_pitem = lw_obj.dw_process.FindDwTable(L"PItem"); xdwgrid dw_polist = lw_obj.dw_polist; int row1 = dw_pitem.GetRow(); int row2 = dw_list.GetRow(); dw_pitem.SetItemString(row1, L"PONo", dw_list.GetItemString(row2, L"PONo")); dw_pitem.SetItemString(row1, L"POID", dw_list.GetRowElement(row2).getAttribute(L"guid")); for (int row = 1; row <= dw_polist.GetRowCount(); row++) { xstring POID1 = dw_polist.GetRowElement(row).getAttribute(L"guid"); xstring POID2 = dw_pitem.GetItemString(row1, L"POID"); if (POID1 == POID2) { double amount = dw_polist.GetItemDouble(row, L"Amount") + dw_pitem.GetItemDouble(row1, L"BuyAmount"); dw_polist.SetItemDouble(row, L"Amount", amount); } } OnSave(); return 1; } //T}NäSÑ^Qýep int OnCmdDispatch(xstring comdid) { if (comdid == L"xmClose") { CloseWindow(); return 1; } else if (comdid == L"xmInsert") { InsertPo(); return 1; } return 0; } //T}NäYtN‹Nö int OnXCommand(TEvent* evt, LPARAM p) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnAttachEvent() { //~Ñ[š]åQwgap¹QûN‹Nö AttachEvent(L"WM_XCOMMAND", (FEvent)&InsertPOWin::OnXCommand); //ƒ·SÖq&p¹N‹Nöÿ u(NŽ‘Ín]åQwga AttachEvent(L"WM_SETFOCUS", (FEvent)&InsertPOWin::OnSetFocus); return 1; } /* int OnRetrieve() { xml x ; xaserverarg arg; arg.setNativePointer(arg.CreateInstance()); arg.AddArg(L"xxx",L"xxx"); if (getUrl(L"",arg.GetString(),x)!=1) { trace(x.text()); return -1; }else { //dw_list.Retrieve(x); //dw_list.Redraw(); } return 1; } */ int Initial() { lw_obj = GetArg(); xdwgrid dw_polist = lw_obj.dw_polist; xdwtable dw_pitem = lw_obj.dw_process.FindDwTable(L"PItem"); for (int row = 1; row <= dw_polist.GetRowCount(); row++) { xstring posupplier = dw_polist.GetItemString(row, L"SupplierID"); xstring poitemsupplier = dw_pitem.GetItemString(row, L"SupplierID"); xstring PONo = dw_pitem.GetItemString(row, L"PONo"); KXMLDOMElement ele = dw_polist.GetRowElement(row); xstring guid = ele.getAttribute(L"guid"); if (PONo == L"") { if (posupplier == poitemsupplier) { int row1 = dw_list.InsertRow(0); KXMLDOMElement ele1 = dw_list.GetRowElement(row1); ele1.setAttribute(L"guid", guid); dw_list.SetItemDisplayString(row1, L"SupplierID", dw_polist.GetItemDisplayString(row, L"SupplierID")); if (dw_polist.GetItemString(row, L"POType"))dw_list.SetItemString(row1, L"POType", dw_polist.GetItemString(row, L"POType")); if (dw_polist.GetItemString(row, L"PONo"))dw_list.SetItemString(row1, L"PONo", dw_polist.GetItemString(row, L"PONo")); if (dw_polist.GetItemString(row, L"PODate"))dw_list.SetItemString(row1, L"PODate", dw_polist.GetItemString(row, L"PODate")); if (dw_polist.GetItemString(row, L"Amount"))dw_list.SetItemString(row1, L"Amount", dw_polist.GetItemString(row, L"Amount")); if (dw_polist.GetItemString(row, L"CurrencyCode"))dw_list.SetItemString(row1, L"CurrencyCode", dw_polist.GetItemString(row, L"CurrencyCode")); if (dw_polist.GetItemString(row, L"DeliveryDate"))dw_list.SetItemString(row1, L"DeliveryDate", dw_polist.GetItemString(row, L"DeliveryDate")); if (dw_polist.GetItemDisplayString(row, L"CreatorID"))dw_list.SetItemDisplayString(row1, L"CreatorID", dw_polist.GetItemDisplayString(row, L"CreatorID")); if (dw_polist.GetItemString(row, L"Status"))dw_list.SetItemString(row1, L"Status", dw_polist.GetItemString(row, L"Status")); if (dw_polist.GetItemString(row, L"SOID"))dw_list.SetItemString(row1, L"SOID", dw_polist.GetItemString(row, L"SOID")); } } } return 1; } int onload() { SetArg(); dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/PurchaseOrder/template/purchaseorder/polist"); dw_list.SetColumnState(L"SOID", false); OnAttachEvent(); if (GetWinParam()) Initial(); return 1; } int onloaded() { SetAgent(); return 1; } };