þÿ#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) ExportCredit : public xframe { public: xdwgrid dw_list; xnode m_agentNode; //Agent Condition xdwgrid dw_item; public: ExportCredit(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static ExportCredit* CreateInstance(void* implPtr, void* hWnd) { ExportCredit* pWin = new ExportCredit(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(ref TNotifyEvent evt, int p) { ref DWNMHDR hdr = trust(evt.pnmh as ref DWNMHDR); int row = hdr.row; SetAgent(); OnRetrieveEx(row); return 1; } //q&p¹oÀm;YtQýep int OnSetFocus(TEvent* evt, LPARAM param) { //‘Ín]åQwga SetAgent(); //trace(GetEntityID(1)); return 1; } int OnSave() { xml x1 ; x1.setNativePointer(xml::CreateInstance()); dw_item.AcceptText(); dw_item.DwUpdateAllToEx(x1); xaserverarg arg1; arg1.setNativePointer(xaserverarg::CreateInstance()); arg1.AddArg(L"content", x1.xml()); trace(x1.xml()); if (xurl::get(L"/sale/data/Gdn/update/ExportCreditItem", arg1.GetString(), x1) != 1) { xstring error = x1.text(); alert(L"err:" + error); return 1; } xstring str = x1.documentElement().getAttribute(L"text"); if (str == L"true") { dw_item.ResetUpdateStatus(); alert(L"OÝ[XbRŸ!"); OnRetrieve(); } else { alert(L"OÝ[XY1%!"); } return 1; } int OnModifyRow(int row) { xaserverarg arg; arg.AddArg(L"ExportCreditID", dw_list.GetItemString(row, L"ExportCreditID")); OpenWindow(L"dev:xpage[ExportCreditMaint.vx]", cast(arg as int)); return 1; } int XmDelete() { xstring ExportCreditID = dw_list.GetItemString(dw_list.GetRow(), L"ExportCreditID"); int MB_OKCANCEL = 1; int IDOK = 1; int ret = MessageBox(GetHWND(), L"xn‹¤R –d?", L"cÐy:", MB_OKCANCEL); if (ret == IDOK) { xml x = ViewObject::RetrieveData(L"/sale/data/Expense3/DeleteExportCredit", L"ExportCreditID", ExportCreditID); xstring status = x.xml(); if (status.find(L"ok") == 1) { alert(L"R –dbRŸ"); OnRetrieve(); } else { alert(L"R –dY1%"); } } return 1; } //T}NäSÑ^Qýep int OnCmdDispatch(xstring comdid) { xstring NO = publiccode::GetUser().no; xstring Jobname = publiccode::GetUser().jobname; if (NO == L"admin") Jobname = L""; if (Jobname == L"NR¡TX") { if (comdid == L"OnOpen") { OnModifyRow(dw_list.GetRow()); return 1; } if (comdid == L"xmSearch") { OnRetrieve(); return 1; } return 1; } if (comdid == L"OnOpen") { OnModifyRow(dw_list.GetRow()); return 1; } if (comdid == L"xmSearch") { OnRetrieve(); return 1; } if (comdid == L"OnNew") { OpenWindow(L"dev:xpage[ExportCreditMaint.vx]", 0); return 1; } if (comdid == L"OnDelete") { XmDelete(); return 1; } if (comdid == L"XmSave") { OnSave(); return 1; } return 0; } int OnDoubleClicked(ref TNotifyEvent evt, int p) { return OnCmdDispatch(L"OnOpen"); } //T}NäYtN‹Nö int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnItemChanged(ref TNotifyEvent evt, int p) { ref DWNMHDR hdr = trust(evt.pnmh as ref DWNMHDR); xstring colname = hdr.colname; xstring value = hdr.data; int row = hdr.row; xstring dwname = L"dw_item"; if (colname == L"Type") { if (value == L"N") { dw_item.SetItemString(row, L"CreatorID", L""); dw_item.SetItemDisplayString(row, L"CreatorID", L""); dw_item.SetItemString(row, L"CreateDate", L""); dw_item.SetItemString(row, L"Note", L""); } else { xstring Createdate = publiccode::GetCurrentDate(); xstring userid = publiccode::GetUser().id; xstring username = publiccode::GetUser().name; dw_item.SetItemString(row, L"CreatorID", userid); dw_item.SetItemDisplayString(row, L"CreatorID", username); dw_item.SetItemString(row, L"CreateDate", Createdate); dw_item.SetGuid(row, publiccode::GetGuid()); } } return 1; } int OnAttachEvent() { //~Ñ[š]åQwgap¹QûN‹Nö AttachEvent(L"WM_XCOMMAND", (FEvent)&MaintAP::OnXCommand); //ƒ·SÖq&p¹N‹Nöÿ u(NŽ‘Ín]åQwga AttachEvent(L"WM_SETFOCUS", (FEvent)&MaintAP::OnSetFocus); AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&MaintAP::OnDoubleClicked);//ˆLSÌQû AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&MaintAP::OnRowChanged); AttachEvent(L"dw_item", L"DWV_ITEMCHANGED", (FEvent)&MaintAP::OnItemChanged); } int OnRetrieve() { xml x ; xaserverarg arg; arg.AddArg(L"sType", GetControl(L"search").GetText()); if (getUrl(L"/sale/data/Expense3/ExportCreditList", arg.GetString(), x) != 1) { trace(x.text); return -1; } else { dw_list.Retrieve(x); dw_list.Redraw(); } dw_list.SetSelectionMode(1); dw_list.SetReadOnly(true); return 1; } int OnRetrieveEx(int row) { xstring ExportCreditID = dw_list.GetItemString(row, L"ExportCreditID"); xml x ; xaserverarg arg; arg.AddArg(L"ExportCreditID", ExportCreditID); if (getUrl(L"/sale/data/Expense3/GetExportCreditItemEx", arg.GetString(), x) != 1) { trace(x.text); return -1; } else { dw_item.Retrieve(x); dw_item.Redraw(); } dw_item.SetSelectionMode(1); dw_item.SetReadOnly(true); return 1; } int onload() { dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/expense3/ExportCreditList"); dw_list.SetColumnState(L"ExportCreditID", false); dw_item = GetControl(L"dw_item"); dw_item.openUrl(L"/sale/view/expense3/ExportCreditItem"); dw_item.SetColumnState(L"ExportCreditItemID", false); dw_item.SetColumnState(L"ExportCreditID", false); OnAttachEvent(); OnRetrieve(); OnRetrieveEx(1); return 1; } int onloaded() { SetAgent(); return 1; } }; ]