#include #include #include #include #include #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) brand_regtype : public xframe { public: xdwtable dw_list; xnode m_agentNode; public: brand_regtype(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static brand_regtype* CreateInstance(void* implPtr, void* hWnd) { brand_regtype* pWin = new brand_regtype(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; } xdwtable getDw() { xdwtable dw1 = dw_list.FindDwTable(L"item"); return dw1; } int addRow() { xdwtable dw = getDw(); int row = dw.InsertRow(0); xstring no = L"2"; if (row > 1) no = dw.GetItemString(row - 1, L"RegTypeID"); int n = no.toInt(); int h = n + 1; dw.SetItemString(row, L"RegTypeID", xstring(h)); return 1; } int deleteRow() { xdwtable dw = getDw(); int row = dw.GetRow(); if (row < 1 || row > dw.GetRowCount()) return -1; if (MessageBox(GetHWND(), L"ÊÇ·ñɾ³ýÑ¡ÔñµÄ¼Ç¼ÐУ¿", L"Ìáʾ", 4) == 7) return 1; dw.DeleteRow(row); return 1; } int save() { xml x; xaserverarg arg; dw_list.AcceptText(); dw_list.DwUpdateAllTo(x); KXMLDOMElement e = x.documentElement(); //trace(e.xml); arg.AddArg(L"content", e.xml()); if (getUrl(L"/workflow/action/BrandRegType.dbmap/bill.update", arg.GetString(), x) != 1) { alert(L"±£´æÊ§°Ü!"); return -1; } //trace(x.xml()); xstring str = x.xml(); if (str.find(L"±£´æ³É¹¦", 0) > 0) { alert(L"±£´æ³É¹¦"); dw_list.ResetUpdateStatus(); dw_list.Redraw(); } else alert(L"±£´æÊ§°Ü0!"); return 1; } //ÃüÁî·¢²¼º¯Êý int OnCmdDispatch(xstring comdid) { HCURSOR hCursor = xutil::SetCursorWait(); if (comdid == L"xmNew") addRow(); else if (comdid == L"xmDelete") deleteRow(); else if (comdid == L"xmSave") save(); xutil::RestoreCursor(hCursor); return 0; } //ÃüÁî´¦Àíʼþ int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnSetFocus(TEvent* evt, LPARAM p) { SetAgent(); return 1; } int OnAttachEvent() { AttachEvent(L"WM_XCOMMAND", (FEvent)&brand_regtype::OnXCommand); AttachEvent(L"WM_SETFOCUS", (FEvent)&brand_regtype::OnSetFocus); return 1; } int Initail() { xaserverarg arg; xml x; if (getUrl(L"/sale/data/brand/entity/regtype", arg.GetString(), x) != 1) { alert(L"³õʼ»¯²éѯʧ°Ü!"); return -1; } //trace(x.xml()); dw_list.Retrieve(x); dw_list.Redraw(); return 1; } int onload() { dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/brand/template/regtype"); //dw_list.SetColHeaderHeight(0); dw_list.SetRowSelectorWidth(0); OnAttachEvent(); SetAgent(); Initail(); return -1; } };