þÿ#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) ExportCreditSwitchTo : public xframe { public: xdwgrid dw_list; xnode m_agentNode; //Agent Condition int hObject = 0; xstring CustomerID; public: ExportCreditSwitchTo(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static ExportCreditSwitchTo* CreateInstance(void* implPtr, void* hWnd) { ExportCreditSwitchTo* pWin = new ExportCreditSwitchTo(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 OnRowChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; int row = hdr.row; SetAgent(); return 1; } //q&p¹oÀm;YtQýep int OnSetFocus(TEvent* evt, LPARAM param) { //‘Ín]åQwga SetAgent(); //trace(GetEntityID(1)); return 1; } //T}NäSÑ^Qýep int OnCmdDispatch(xstring comdid) { if (comdid == L"xmImport") { xaserverarg arg=GetArg(); arg.AddArg(L"items", L""); xstring str = L""; xstring InvoiceNoS = L""; int row = dw_list.GetNextSelectRow(1); trace(L"-----------1111---------------"); while (row > 0 && row <= dw_list.GetRowCount()) { KXMLDOMElement ele = dw_list.GetRowElement(row); xstring InvoiceNo = dw_list.GetItemString(row, L"InvoiceNo"); if (InvoiceNoS == L"") InvoiceNoS = InvoiceNo; else if (InvoiceNoS.find(InvoiceNo) < 0) InvoiceNoS += L"," + InvoiceNo; str += ele.xml(); row = dw_list.GetNextSelectRow(row + 1); } if (str != L"") arg.AddArg(L"items", L"<data>" + str + L"</data>"); trace(L"------------2222--------------"); CloseWindow(); return 1; } if (comdid == L"xmClose") { CloseWindow(); return 1; } if (comdid == L"xmSearch") { OnRetrieve(CustomerID); return 1; } return 0; } //T}NäYtN‹Nö int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnAttachEvent() { //~Ñ[š]åQwgap¹QûN‹Nö AttachEvent(L"WM_XCOMMAND", (FEvent)&ExportCreditSwitchTo::OnXCommand); //ƒ·SÖq&p¹N‹Nöÿ u(NŽ‘Ín]åQwga AttachEvent(L"WM_SETFOCUS", (FEvent)&ExportCreditSwitchTo::OnSetFocus); AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&ExportCreditSwitchTo::OnRowChanged); return 1; } int OnRetrieve(xstring CustomerID) { xml x ; xaserverarg arg; arg.AddArg(L"CustomerID", CustomerID); arg.AddArg(L"InvoiceNo", xcontrol(GetControl(L"search")).GetText()); if (getUrl(L"/sale/data/Expense3/ExportCreditSwitchToList", arg.GetString(), x) != 1) { trace(x.text()); return -1; } else { dw_list.Retrieve(x); dw_list.Redraw(); } dw_list.SetSelectionMode(3); dw_list.SetReadOnly(true); return 1; } int onload() { SetArg(); dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/expense3/ExportCreditSwitchToList"); dw_list.SetColumnState(L"SalespersonID", false); dw_list.SetColumnState(L"CreatorID", false); if (GetWinParam()) { xaserverarg arg = GetArg(); CustomerID = arg.GetArgString(L"CustomerID"); OnRetrieve(arg.GetArgString(L"CustomerID")); } OnRetrieve(CustomerID); OnAttachEvent(); return 1; } int onloaded() { SetAgent(); return 1; } };