þÿ#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) SelectSalaryslip : public xframe { public: xdwgrid dw_list; xnode m_agentNode; //Agent Condition public: SelectSalaryslip(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static SelectSalaryslip* CreateInstance(void* implPtr, void* hWnd) { SelectSalaryslip* pWin = new SelectSalaryslip(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, LPARAM param) { //‘Ín]åQwga SetAgent(); return 1; } int OnSave() { xml x ; dw_list.AcceptText(); dw_list.DwUpdateAllToEx(x); xaserverarg arg; arg.AddArg(L"content", x.xml()); if (xurl::get(L"/sale/data/expense3/update/salaryslip", arg.GetString(), x) != 1) { xstring error = x.text(); alert(L"err:" + error); return 1; } xstring str = x.documentElement().getAttribute(L"text"); if (str == L"true") { dw_list.Redraw(); } else { alert(L"OÝ[XY1%!"); } return 1; } int xmOk() { OnSave(); xaserverarg arg = GetArg(); double amount = 0.0; for (int row = 1; row <= dw_list.GetRowCount(); row++) { if (dw_list.GetItemString(row, L"IsSelected") == L"Y") { amount += dw_list.GetItemDouble(row, L"SalaryAmount"); } } xstring amount2 = xstring(amount); arg.AddArg(L"amount", amount2); CloseWindow(); return 1; } //T}NäSÑ^Qýep int OnCmdDispatch(xstring comdid) { if (comdid == L"xmOk") { xmOk(); return 1; } else if (comdid == L"xmCancel") { CloseWindow(); 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)&SelectSalaryslip::OnXCommand); //ƒ·SÖq&p¹N‹Nöÿ u(NŽ‘Ín]åQwga AttachEvent(L"WM_SETFOCUS", (FEvent)&SelectSalaryslip::OnSetFocus); return 1; } /* int OnRetrieve() { xml x ; xaserverarg arg; 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 onload() { SetArg(); OnAttachEvent(); dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/expense3/Salaryslip/Select"); if (GetWinParam()) { xaserverarg arg = GetArg(); xstring SalaryslipDate = arg.GetArgString(L"SalaryslipDate"); xstring PersonID = arg.GetArgString(L"PersonID"); trace(SalaryslipDate + L"******" + PersonID); xml x = ViewObject::RetrieveData(L"/sale/data/expense3/view/salaryslipSelect", L"PersonID", PersonID, L"SalaryslipDate", SalaryslipDate); if (x) { dw_list.Retrieve(x); dw_list.Redraw(); } } return 1; } int onloaded() { SetAgent(); return 1; } };