From 7a91c3a1ed37b0332d4ff0ebeae60bd6da3665c0 Mon Sep 17 00:00:00 2001 From: xj qian <qianxj15@sina.com> Date: 星期二, 16 七月 2024 18:28:58 +0800 Subject: [PATCH] Merge branch 'master' of http://116.62.18.175:6699/r/mis-prj --- jrj/project/business/BasicCode/brand.regtype.cpp | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 161 insertions(+), 0 deletions(-) diff --git a/jrj/project/business/BasicCode/brand.regtype.cpp b/jrj/project/business/BasicCode/brand.regtype.cpp new file mode 100644 index 0000000..d58a1c3 --- /dev/null +++ b/jrj/project/business/BasicCode/brand.regtype.cpp @@ -0,0 +1,161 @@ +#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) 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 = new xdwtable; + dw1.setNativePointer(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 = new xdwtable; + dw_list.setNativePointer(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; + } +}; \ No newline at end of file -- Gitblit v1.9.3