|  |  | 
 |  |  | use "win.vl" | 
 |  |  | use "treeview.vm" | 
 |  |  | use "dev:vm[xdwgrid.vm]" | 
 |  |  | use "dev:vm[xdwtable.vm]" | 
 |  |  | use "pref.vl" | 
 |  |  | use "dev:vm[xml.vm]" | 
 |  |  | use "dev:vm[xaserverarg.vm]" | 
 |  |  | use "dev:vm[xaserver.vm]" | 
 |  |  | use "dev:vm[xutil.vm]" | 
 |  |  | use "dev:code[pa.tpp]" | 
 |  |  | use "dev:vm[control.vm]" | 
 |  |  | #include <wobject/xstring.hpp> | 
 |  |  | #include <xcontrol/xtreeview.hpp> | 
 |  |  | #include <xcontrol/xdwgrid.hpp> | 
 |  |  | #include <wobject/xdouble.hpp> | 
 |  |  | #include <xcontrol/xlayersheet.hpp> | 
 |  |  |  | 
 |  |  | unit vbusiness.xpage tpp | 
 |  |  | [ | 
 |  |  |    class pa | 
 |  |  | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" | 
 |  |  | #include "viewobject/view.base.hpp" | 
 |  |  | using xml = KXMLDOMDocument; | 
 |  |  | class __declspec(dllexport) AddUserGroup : public xwin | 
 |  |  | { | 
 |  |  |  | 
 |  |  | public: | 
 |  |  |    xstring note; | 
 |  |  |    int hitem; | 
 |  |  |    int row; | 
 |  |  |    int wid; | 
 |  |  |    xtreeview tv; | 
 |  |  |    xdwgrid dw; | 
 |  |  |    xwin* pwin; | 
 |  |  |  | 
 |  |  | public: | 
 |  |  |    AddUserGroup(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd),pwin(nullptr) {} | 
 |  |  | public: | 
 |  |  |    static AddUserGroup* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |    { | 
 |  |  |       string note; | 
 |  |  |       int hitem; | 
 |  |  |       int row; | 
 |  |  |       int wid; | 
 |  |  |       treeview__ tv; | 
 |  |  |       xdwgrid__ dw; | 
 |  |  |       win__ pwin; | 
 |  |  |       AddUserGroup* pWin = new AddUserGroup(implPtr, (HWND)hWnd); | 
 |  |  |       return pWin; | 
 |  |  |    } | 
 |  |  | ] | 
 |  |  | 			 | 
 |  |  | unit vbusiness.xpage | 
 |  |  | [ | 
 |  |  |    int SetAgent() | 
 |  |  |    { | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    //焦点激活处理函数 | 
 |  |  |    int OnSetFocus(TEvent* evt, LPARAM param) | 
 |  |  |    { | 
 |  |  |       int SetAgent(); | 
 |  |  |  | 
 |  |  |    AddUserGroup is extend win__; | 
 |  |  |    about AddUserGroup | 
 |  |  |    [ | 
 |  |  |       control: | 
 |  |  | 		 | 
 |  |  |       method: | 
 |  |  |       [ | 
 |  |  |          pa p; | 
 |  |  | 			 | 
 |  |  |          int SetAgent() | 
 |  |  |          { | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          //焦点激活处理函数 | 
 |  |  |          int OnSetFocus(ref TEvent evt,int p) | 
 |  |  |          { | 
 |  |  |             int SetAgent(); | 
 |  |  |       //重置工具条 | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int AppendItem(xml x, KXMLDOMElement r, xstring item) { | 
 |  |  |       auto e = x.createElement(item); | 
 |  |  |       xcontrol xc = GetControl(item); | 
 |  |  |       e.settext(xc.GetText()); | 
 |  |  |       r.appendChild(e); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int AppendAttrib(xml x, KXMLDOMElement r, xstring item) { | 
 |  |  |       auto e = x.createElement(item); | 
 |  |  |       //xcontrol xc = GetControl(item); | 
 |  |  |       xcontrol xc= GetControl(item); | 
 |  |  |       e.settext(xc.GetText()); | 
 |  |  |       r.setAttribute(item, xc.GetText()); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    //命令发布函数 | 
 |  |  |    int OnCmdDispatch(xstring comdid) | 
 |  |  |    { | 
 |  |  |       if (comdid == L"cb_cancel") | 
 |  |  |          CloseWindow(); | 
 |  |  |       else if (comdid == L"cb_ok") | 
 |  |  |       { | 
 |  |  |          int wid = p.wid; | 
 |  |  |          xml x; | 
 |  |  |  | 
 |  |  |             //重置工具条 | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          int AppendItem(xml__ x,msxml::IXMLDOMElement r,string item){ | 
 |  |  |             var e = x.GetXmlDoc().createElement(item); | 
 |  |  |             control__ xc = new control__; | 
 |  |  |             xc.setNativePointer(this.GetControl(item)); | 
 |  |  |             e.text = xc.GetText(); | 
 |  |  |             r.appendChild(e);		 | 
 |  |  |             return 1; | 
 |  |  |          }	 | 
 |  |  |          int AppendAttrib(xml__ x,msxml::IXMLDOMElement r,string item){ | 
 |  |  |             var e = x.GetXmlDoc().createElement(item); | 
 |  |  |             //xcontrol xc = GetControl(item); | 
 |  |  |             control__ xc = new control__; | 
 |  |  |             xc.setNativePointer(this.GetControl(item)); | 
 |  |  |             e.text = xc.GetText(); | 
 |  |  |             r.setAttribute(item,xc.GetText()); | 
 |  |  |             return 1; | 
 |  |  |          }	 | 
 |  |  |          //命令发布函数 | 
 |  |  |          int OnCmdDispatch(string comdid) | 
 |  |  |          xaserverarg arg; | 
 |  |  |  | 
 |  |  |          x.loadXML(L"<row/>"); | 
 |  |  |          auto r = x.documentElement(); | 
 |  |  |          xstring gpguid; | 
 |  |  |          if (p.note == L"修改") | 
 |  |  |          { | 
 |  |  |             if (comdid=="cb_cancel") | 
 |  |  |                CloseWindow(); | 
 |  |  |             else if(comdid=="cb_ok") | 
 |  |  |             KXMLDOMElement ele = treeview::GetItemData(wid, p.hitem); | 
 |  |  |             gpguid = ele.selectSingleNode(L"@JobID").text(); | 
 |  |  |          } | 
 |  |  |          else | 
 |  |  |             gpguid = GetGuid(); | 
 |  |  |          r.setAttribute(L"JobID", gpguid); | 
 |  |  |          AppendAttrib(x, r, L"JobName"); | 
 |  |  |          AppendAttrib(x, r, L"JobType"); | 
 |  |  |          //AppendItem(x,r,L"JobName"); | 
 |  |  |          //AppendItem(x,r,L"JobType"); | 
 |  |  |          //trace(x.xml()); | 
 |  |  |          //return 1; | 
 |  |  |          arg.AddArg(L"content", x.xml()); | 
 |  |  |          if (xaserver::ExecXAction(GetServerUrl(), L"[update.Usergroup.xa]", arg.GetString()) == 1) | 
 |  |  |          { | 
 |  |  |             xcontrol xc = GetControl(L"JobName"); | 
 |  |  |             //p.tv.Redraw(); | 
 |  |  |             if (p.note == L"修改") | 
 |  |  |             { | 
 |  |  |                int wid = p.wid; | 
 |  |  |                xml__ x = new xml__; | 
 |  |  |                x.setNativePointer(x.CreateInstance()); | 
 |  |  |                xaserverarg__ arg = new xaserverarg__; | 
 |  |  |                arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |                x.LoadXml("<row/>"); | 
 |  |  |                var r = x.GetXmlDoc().documentElement; | 
 |  |  |                string gpguid; | 
 |  |  |                if (p.note=="修改") | 
 |  |  |                { | 
 |  |  |                   msxml::IXMLDOMElement ele = treeview__::GetItemData(wid,p.hitem); | 
 |  |  |                   gpguid=ele.selectSingleNode("@JobID").text; | 
 |  |  |                } | 
 |  |  |                else | 
 |  |  |                   gpguid=win__::GetGuid(); | 
 |  |  |                r.setAttribute("JobID",gpguid); | 
 |  |  |                AppendAttrib(x,r,"JobName"); | 
 |  |  |                AppendAttrib(x,r,"JobType"); | 
 |  |  |                //AppendItem(x,r,"JobName"); | 
 |  |  |                //AppendItem(x,r,"JobType"); | 
 |  |  |                //trace(x.GetXml()); | 
 |  |  |                //return 1; | 
 |  |  |                arg.AddArg("content",x.GetXml()); | 
 |  |  |                if (xaserver__::ExecXAction(GetServerUrl(),"[update.Usergroup.xa]",arg.GetString())==1) | 
 |  |  |                { | 
 |  |  |                   control__ xc = new control__; | 
 |  |  |                   xc.setNativePointer(this.GetControl("JobName")); | 
 |  |  |                   //p.tv.Redraw(); | 
 |  |  |                   if (p.note=="修改") | 
 |  |  |                   { | 
 |  |  |                      treeview__::SetItemData(wid,p.hitem,r); | 
 |  |  |                      treeview__::SetItemLabel(wid,p.hitem,xc.GetText()); | 
 |  |  |                   } | 
 |  |  |                   else | 
 |  |  |                   { | 
 |  |  |                      int root = treeview__::GetRootItem(wid); | 
 |  |  |                      treeview__::InsertChildItem(wid,root,xc.GetText(),r,15); | 
 |  |  |                   } | 
 |  |  |                   CloseWindow(); | 
 |  |  |                } | 
 |  |  |                else | 
 |  |  |                { | 
 |  |  |                   alert("保存出错!"); | 
 |  |  |                } | 
 |  |  |                treeview::SetItemData(wid, p.hitem, r); | 
 |  |  |                treeview::SetItemLabel(wid, p.hitem, xc.GetText()); | 
 |  |  |             } | 
 |  |  |             return 0; | 
 |  |  |          } | 
 |  |  | 			 | 
 |  |  |          //命令处理事件 | 
 |  |  |          int OnXCommand(ref TXCommandEvent evt,int p) | 
 |  |  |          { | 
 |  |  |             return OnCmdDispatch(evt.pStrID); | 
 |  |  |          } | 
 |  |  | 			 | 
 |  |  |          int OnAttachEvent() | 
 |  |  |          { | 
 |  |  |             //绑定工具条点击事件 | 
 |  |  |             AttachEvent("WM_XCOMMAND",OnXCommand); | 
 |  |  |             //获取焦点事件,用于重置工具条 | 
 |  |  |             AttachEvent("WM_SETFOCUS",OnSetFocus); | 
 |  |  |          } | 
 |  |  | 			 | 
 |  |  |          int OnInitial() | 
 |  |  |          { | 
 |  |  |             SetAgent(); | 
 |  |  |  | 
 |  |  |             OnAttachEvent(); | 
 |  |  | 				 | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  | 			 | 
 |  |  |          int SetItem(string value,string item){ | 
 |  |  |             control__ xc = new control__; | 
 |  |  |             xc.setNativePointer(GetControl(item)); | 
 |  |  |             xc.SetText(value);	 | 
 |  |  |             return 1; | 
 |  |  |          }	 | 
 |  |  | 			 | 
 |  |  |          int onload() | 
 |  |  |          { | 
 |  |  |             OnInitial(); | 
 |  |  |             p = new pa; | 
 |  |  | 				 | 
 |  |  |             if(this.GetParam()) | 
 |  |  |             else | 
 |  |  |             { | 
 |  |  |                p=GetParam(); | 
 |  |  |                win__::SetWindowText(GetHWND(),p.note+"用户组"); | 
 |  |  |                if (p.note=="修改") | 
 |  |  |                { | 
 |  |  |                   int wid = p.wid; | 
 |  |  |                   msxml::IXMLDOMElement ele=treeview__::GetItemData(wid,p.hitem); | 
 |  |  |                   //trace(ele.xml); | 
 |  |  |                   //SetItem(ele.selectSingleNode("gpno").text,"gpno"); | 
 |  |  |                   //SetItem(ele.selectSingleNode("gpname").text,"gpname"); | 
 |  |  |                   string ls_guid = ele.selectSingleNode("@JobID").text; | 
 |  |  |                   string ls_name = ele.selectSingleNode("@JobName").text; | 
 |  |  |                   string ls_type = ele.selectSingleNode("@JobType").text; | 
 |  |  |                   SetItem(ls_guid,"JobID"); | 
 |  |  |                   SetItem(ls_name,"JobName"); | 
 |  |  |                   SetItem(ls_type,"JobType"); | 
 |  |  |                } | 
 |  |  |                int root = treeview::GetRootItem(wid); | 
 |  |  |                treeview::InsertChildItem(wid, root, xc.GetText(), r, 15); | 
 |  |  |             } | 
 |  |  | 				 | 
 |  |  |             return 1; | 
 |  |  |             CloseWindow(); | 
 |  |  |          } | 
 |  |  |       ] | 
 |  |  | 		 | 
 |  |  |    ] | 
 |  |  | ] | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             alert(L"保存出错!"); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 0; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    //命令处理事件 | 
 |  |  |    int OnXCommand(TEvent* evt, LPARAM param) | 
 |  |  |    { | 
 |  |  |       return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnAttachEvent() | 
 |  |  |    { | 
 |  |  |       //绑定工具条点击事件 | 
 |  |  |       AttachEvent(L"WM_XCOMMAND", (FEvent)&AddUserGroup::OnXCommand); | 
 |  |  |       //获取焦点事件,用于重置工具条 | 
 |  |  |       AttachEvent(L"WM_SETFOCUS", (FEvent)&AddUserGroup::OnSetFocus); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnInitial() | 
 |  |  |    { | 
 |  |  |       SetAgent(); | 
 |  |  |  | 
 |  |  |       OnAttachEvent(); | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int SetItem(xstring value, xstring item) { | 
 |  |  |       xcontrol xc = GetControl(item); | 
 |  |  |       xc.SetText(value); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int onload() | 
 |  |  |    { | 
 |  |  |       OnInitial(); | 
 |  |  |       p = new pa; | 
 |  |  |  | 
 |  |  |       if (GetWinParam()) | 
 |  |  |       { | 
 |  |  |          p = GetArg(); | 
 |  |  |          SetWindowText(GetHWND(), p.note + L"用户组"); | 
 |  |  |          if (p.note == L"修改") | 
 |  |  |          { | 
 |  |  |             int wid = p.wid; | 
 |  |  |             KXMLDOMElement ele = treeview::GetItemData(wid, p.hitem); | 
 |  |  |             //trace(ele.xml); | 
 |  |  |             //SetItem(ele.selectSingleNode(L"gpno").text(),L"gpno"); | 
 |  |  |             //SetItem(ele.selectSingleNode(L"gpname").text(),L"gpname"); | 
 |  |  |             xstring ls_guid = ele.selectSingleNode(L"@JobID").text(); | 
 |  |  |             xstring ls_name = ele.selectSingleNode(L"@JobName").text(); | 
 |  |  |             xstring ls_type = ele.selectSingleNode(L"@JobType").text(); | 
 |  |  |             SetItem(ls_guid, L"JobID"); | 
 |  |  |             SetItem(ls_name, L"JobName"); | 
 |  |  |             SetItem(ls_type, L"JobType"); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  | }; |