|  |  | 
 |  |  | use"lang.vl" | 
 |  |  | use "win.vl" | 
 |  |  | use "dev:vm[xml.vm]" | 
 |  |  | use "treeview.vm" | 
 |  |  | use "dev:vm[xaserverarg.vm]" | 
 |  |  | use "dev:vm[xaserver.vm]" | 
 |  |  | use "dev:vm[xdwgrid.vm]" | 
 |  |  | use "dev:vm[xdwtable.vm]" | 
 |  |  | use "dev:vm[xutil.vm]" | 
 |  |  | use "file.vl" | 
 |  |  | use "list.vl" | 
 |  |  | unit vbusiness.vpage | 
 |  |  | [ | 
 |  |  |    QuickCode_Tree is extend list; | 
 |  |  |    about QuickCode_Tree | 
 |  |  |    [ | 
 |  |  |       field: | 
 |  |  | 			 | 
 |  |  |       method: | 
 |  |  |       [ | 
 |  |  |          xdwgrid__   dw_list; | 
 |  |  |          treeview__      tv_1;			 | 
 |  |  |          string m_config; | 
 |  |  |          string m_agent; | 
 |  |  |          string m_id; | 
 |  |  |          string m_dbmap; | 
 |  |  |          string treexquery; | 
 |  |  |          string      c_type;	 | 
 |  |  |          msxml::IXMLDOMDocument m_configDoc; | 
 |  |  |          string kpstr; | 
 |  |  |          string strtpl; | 
 |  |  |          string m_QueryTxt; | 
 |  |  |          int alert(string str) | 
 |  |  | #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) QuickCode_Tree : public listwin | 
 |  |  | { | 
 |  |  | public: | 
 |  |  |    xdwgrid   dw_list; | 
 |  |  |    xtreeview   tv_1; | 
 |  |  |    xstring m_config; | 
 |  |  |    xstring m_agent; | 
 |  |  |    xstring m_id; | 
 |  |  |    xstring m_dbmap; | 
 |  |  |    xstring treexquery; | 
 |  |  |    xstring      c_type; | 
 |  |  |    KXMLDOMDocument m_configDoc; | 
 |  |  |    xstring kpstr; | 
 |  |  |    xstring strtpl; | 
 |  |  |    xstring m_QueryTxt; | 
 |  |  |    xnode   m_agentNode; | 
 |  |  | public: | 
 |  |  |    QuickCode_Tree(void* implPtr, HWND hWnd) :listwin(implPtr, hWnd) {} | 
 |  |  | public: | 
 |  |  |    static QuickCode_Tree* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |    { | 
 |  |  |       QuickCode_Tree* pWin = new QuickCode_Tree(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]/*"); | 
 |  |  |          KXMLDOMElement agent = m_configDoc.selectSingleNode(L"Config/" + xfNodeAgentArea + L"[1]/*"); | 
 |  |  |          if (agent) | 
 |  |  |          { | 
 |  |  |             TApp::alert(this,str); | 
 |  |  |             //win__::MessageBox(this.GetHWND(),str,"提示:",0); | 
 |  |  |             xstring s = agent.xml(); | 
 |  |  |             m_agentNode = SetAgentNode(anode, s); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnRetrieve() | 
 |  |  |    { | 
 |  |  |       dw_list.AcceptText(); | 
 |  |  |       xml x; | 
 |  |  |  | 
 |  |  |       xaserverarg arg; | 
 |  |  |  | 
 |  |  |       arg.AddArg(L"id", m_id); | 
 |  |  |       arg.AddArg(L"sType", c_type); | 
 |  |  |       arg.AddArg(L"QueryTxt", m_QueryTxt); | 
 |  |  |       //trace(arg.GetString()); | 
 |  |  |       /*if (TDataSet::exec(m_config, L"query1", arg.GetString(),x) != 1) | 
 |  |  |       { | 
 |  |  |          trace(x.text()); | 
 |  |  |          return -1; | 
 |  |  |       }*/ | 
 |  |  |       if (xurl::get(L"QuickCode/entity/listaddtree", arg.GetString(), x) != 1) | 
 |  |  |       { | 
 |  |  |          trace(x.text()); | 
 |  |  |          return -1; | 
 |  |  |       } | 
 |  |  |       //trace(x.xml()); | 
 |  |  |       if ((xstring)x.xml() == L"") | 
 |  |  |       { | 
 |  |  |          xml xx; | 
 |  |  |          xx.loadXML(L"<root/>"); | 
 |  |  |          dw_list.Retrieve(xx); | 
 |  |  |          dw_list.Redraw(); | 
 |  |  |       } | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  |          dw_list.Retrieve(x); | 
 |  |  |          dw_list.Redraw(); | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnTreeSelChanged(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       NMTREEVIEW& nmtv = *(NMTREEVIEW*)evt->notify.pnmh; | 
 |  |  |       HTREEITEM hItem = nmtv.itemNew.hItem; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |       HTREEITEM hitem = tv_1.GetSelectedItem(); | 
 |  |  |       //c_type=dw_type.GetItemLabel(hitem); | 
 |  |  |       //如果是跟节点 | 
 |  |  |       HTREEITEM roothitem = tv_1.GetRootItem(); | 
 |  |  |       if (hitem == roothitem) { | 
 |  |  |          c_type = L""; | 
 |  |  |       } | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  |          c_type = tv_1.GetItemLabel(hitem); | 
 |  |  |  | 
 |  |  |       } | 
 |  |  |       OnRetrieve(); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int adduomfolder() | 
 |  |  |    { | 
 |  |  |       xaserverarg arg; | 
 |  |  |  | 
 |  |  |       arg.AddArg(L"note", L"新增"); | 
 |  |  |       arg.AddArg(L"m_id", m_id); | 
 |  |  |       //win::OpenWindow(L"dev:xpage[AddUomGroup.vx]",arg); | 
 |  |  |       openUrl(L"公共设置.vface/xpage/quickcode/AddGroup", arg); | 
 |  |  |       xstring ok = arg.GetArgString(L"return"); | 
 |  |  |       if (ok == L"ok") { | 
 |  |  |          xstring GroupName = arg.GetArgString(L"GroupName"); | 
 |  |  |          xml xx; | 
 |  |  |  | 
 |  |  |          xaserverarg args; | 
 |  |  |  | 
 |  |  |          args.AddArg(L"GroupName", GroupName); | 
 |  |  |          args.AddArg(L"OldGroupName", L""); | 
 |  |  |          args.AddArg(L"m_id", m_id); | 
 |  |  |          /*if(TFile::exec(m_config,L"updateuomtype",args,xx)!=1) | 
 |  |  |          { | 
 |  |  |             trace(L"error:"+xx.xml()); | 
 |  |  |             alert(L"保存出错!"); | 
 |  |  |             return 0; | 
 |  |  |          }*/ | 
 |  |  |          if (xurl::get(L"QuickCode/pref/quickcode_tree.updateGroup", args.GetString(), xx) != 1) | 
 |  |  |          { | 
 |  |  |             trace(L"error:" + (xstring)xx.xml()); | 
 |  |  |             alert(L"保存出错!"); | 
 |  |  |             return 0; | 
 |  |  |          } | 
 |  |  |          int SetAgent() | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             string xfNodeAgentArea  = "agentarea"; | 
 |  |  |             xnode__ anode = new xnode__; | 
 |  |  |             anode.setNativePointer(GetAgentNode(xfNodeAgentArea)); | 
 |  |  |             var xframeElement =  win__::GetElement(); | 
 |  |  |             var agent = xframeElement.selectSingleNode("agent/"+xfNodeAgentArea+"[1]"); | 
 |  |  |             if(agent) | 
 |  |  |             xstring vv = xx.documentElement().text(); | 
 |  |  |             xml x; | 
 |  |  |  | 
 |  |  |             x.loadXML(L"<row GroupName='" + GroupName + L"'/>"); | 
 |  |  |             HTREEITEM root = tv_1.GetRootItem(); | 
 |  |  |             if (vv == L"OK") | 
 |  |  |             { | 
 |  |  |                string s = agent.xml+""; | 
 |  |  |                SetAgentNodeContent (anode,s); | 
 |  |  |                tv_1.InsertChildItem(root, GroupName, x.documentElement(), 15); | 
 |  |  |             } | 
 |  |  |             return 1; | 
 |  |  |  | 
 |  |  |          } | 
 |  |  |          int OnRetrieve() | 
 |  |  |          { | 
 |  |  |             dw_list.AcceptText();				 | 
 |  |  |             xml__ x=new xml__; | 
 |  |  |             x.setNativePointer(xml__::CreateInstance()); | 
 |  |  |             xaserverarg__ arg=new xaserverarg__; | 
 |  |  |             arg.setNativePointer(arg.CreateInstance());	 | 
 |  |  |             arg.AddArg("id",m_id); | 
 |  |  |             arg.AddArg("sType",c_type); | 
 |  |  |             arg.AddArg("QueryTxt", m_QueryTxt ); 				 | 
 |  |  |             //trace(arg.GetString()); | 
 |  |  |             /*if (TDataSet::exec(m_config, "query1", arg.GetString(),x) != 1) | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int modifyuomfolder() | 
 |  |  |    { | 
 |  |  |  | 
 |  |  |       HTREEITEM h = tv_1.GetSelectedItem(); | 
 |  |  |       if (!h) | 
 |  |  |       { | 
 |  |  |          alert(L"请选择需要修改的组名"); | 
 |  |  |          return 0; | 
 |  |  |       } | 
 |  |  |       HTREEITEM roothitem = tv_1.GetRootItem(); | 
 |  |  |       if (h == roothitem) | 
 |  |  |       { | 
 |  |  |          alert(L"不能修改根节点名称!"); | 
 |  |  |       } | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  |          KXMLDOMElement e = tv_1.GetItemData(h); | 
 |  |  |          trace(e.xml()); | 
 |  |  |          //xstring  OldGroupName= e.SelectSingleNode(L"@GroupName").text(); | 
 |  |  |          xstring  OldGroupName = tv_1.GetItemLabel(h); | 
 |  |  |          xaserverarg arg; | 
 |  |  |  | 
 |  |  |          arg.AddArg(L"note", L"修改"); | 
 |  |  |          arg.AddArg(L"m_id", m_id); | 
 |  |  |          arg.AddArg(L"GroupName", OldGroupName); | 
 |  |  |          OpenWindow(L"dev:xpage[AddUomGroup.vx]", arg); | 
 |  |  |          xstring ok = arg.GetArgString(L"return"); | 
 |  |  |          if (ok == L"ok") { | 
 |  |  |             xstring NewGroupName = arg.GetArgString(L"GroupName"); | 
 |  |  |             xml xx; | 
 |  |  |  | 
 |  |  |             xaserverarg args; | 
 |  |  |  | 
 |  |  |             args.AddArg(L"GroupName", NewGroupName); | 
 |  |  |             args.AddArg(L"OldGroupName", OldGroupName); | 
 |  |  |             args.AddArg(L"m_id", m_id); | 
 |  |  |             /*if(TFile::exec(m_config,L"updateuomtype",args,xx)!=1) | 
 |  |  |             { | 
 |  |  |                trace(x.GetXmlDoc().text); | 
 |  |  |                return -1; | 
 |  |  |                trace(L"error:"+xx.xml()); | 
 |  |  |                alert(L"保存出错!"); | 
 |  |  |                return 0; | 
 |  |  |             }*/ | 
 |  |  |             if (url::get("QuickCode/entity/listaddtree",arg.GetString(),x) != 1) | 
 |  |  |             if (xurl::get(L"QuickCode/pref/quickcode_tree.updateGroup", args.GetString(), xx) != 1) | 
 |  |  |             { | 
 |  |  |                trace(x.GetXmlDoc().text); | 
 |  |  |                return -1; | 
 |  |  |             }		 | 
 |  |  |             //trace(x.GetXml()); | 
 |  |  |             if(x.GetXml()=="") | 
 |  |  |             {	 | 
 |  |  |                xml__ xx=new xml__; | 
 |  |  |                xx.setNativePointer(xml__::CreateInstance()); | 
 |  |  |                xx.LoadXml("<root/>"); | 
 |  |  |                dw_list.Retrieve(xx); | 
 |  |  |                dw_list.Redraw();				 | 
 |  |  |                trace(L"error:" + (xstring)xx.xml()); | 
 |  |  |                alert(L"保存出错!"); | 
 |  |  |                return 0; | 
 |  |  |             } | 
 |  |  |             else | 
 |  |  |             {	 | 
 |  |  |                dw_list.Retrieve(x); | 
 |  |  |                dw_list.Redraw();				 | 
 |  |  |             }	 | 
 |  |  |             { | 
 |  |  |                trace(xx.xml()); | 
 |  |  |                xstring vv = xx.documentElement().text(); | 
 |  |  |                if (vv == L"OK") | 
 |  |  |                { | 
 |  |  |                   tv_1.SetItemLabel(h, NewGroupName); | 
 |  |  |                } | 
 |  |  |  | 
 |  |  |             return 1; | 
 |  |  |          }				 | 
 |  |  |          int OnTreeSelChanged(ref TNotifyEvent evt,int p) | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int deluomfolder() | 
 |  |  |    { | 
 |  |  |  | 
 |  |  |       HTREEITEM hitem = tv_1.GetSelectedItem(); | 
 |  |  |       if (!hitem) | 
 |  |  |       { | 
 |  |  |          alert(L"请选择需要删除的组名"); | 
 |  |  |          return 0; | 
 |  |  |       } | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  |  | 
 |  |  |          int s = dw_list.GetRowCount(); | 
 |  |  |          if (s > 0) | 
 |  |  |          { | 
 |  |  |             ref NMTREEVIEW nmtv = evt.pnmh; | 
 |  |  |             int hItem = nmtv.itemNew.hItem;	 | 
 |  |  |  | 
 |  |  |             int wid = tv_1.GetId(); | 
 |  |  |             int hitem=treeview__::GetSelectedItem(wid); | 
 |  |  |             //c_type=dw_type.GetItemLabel(hitem); | 
 |  |  |             //如果是跟节点 | 
 |  |  |             int roothitem=treeview__::GetRootItem(wid); | 
 |  |  |             if(hitem == roothitem){ | 
 |  |  |                c_type=""; | 
 |  |  |             } | 
 |  |  |             else | 
 |  |  |             alert(L"该分组下面存在数据,不能删除!"); | 
 |  |  |             return 0; | 
 |  |  |          } | 
 |  |  |          HTREEITEM roothitem = tv_1.GetRootItem(); | 
 |  |  |          if (hitem == roothitem) | 
 |  |  |          { | 
 |  |  |             alert(L"不能删除根节点!"); | 
 |  |  |          } | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             //缺少判断删除的条件 | 
 |  |  |             xstring GroupName = tv_1.GetItemLabel(hitem); | 
 |  |  |             if (MessageBox(GetHWND(), L"确定删除组名:" + GroupName + L" 吗?", L"提示", 1) == 1) | 
 |  |  |             { | 
 |  |  |                c_type = treeview__::GetItemLabel(wid,hitem); | 
 |  |  |                xml xx; | 
 |  |  |  | 
 |  |  |                xaserverarg arg; | 
 |  |  |  | 
 |  |  |                arg.AddArg(L"GroupName", GroupName); | 
 |  |  |                arg.AddArg(L"m_id", m_id); | 
 |  |  |                trace(GroupName); | 
 |  |  |                trace(m_id); | 
 |  |  |                /*if (xaserver::ExecXAction(GetServerUrl(),L"[delete.type.FND_UOM.xa]",arg.GetString()) == 1) | 
 |  |  |                { | 
 |  |  |                   tv_1.DeleteItem(wid,hitem); | 
 |  |  |                   //OnTreeSelChanged(); | 
 |  |  |                }*/ | 
 |  |  |                if (xurl::get(L"QuickCode/pref/quickcode_tree.deleteGroup", arg.GetString(), xx) == 1) | 
 |  |  |                { | 
 |  |  |                   tv_1.DeleteItem(hitem); | 
 |  |  |                } | 
 |  |  |                else | 
 |  |  |                   alert(L"删除失败!"); | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    xdwgrid getDW() | 
 |  |  |    { | 
 |  |  |       return dw_list; | 
 |  |  |    } | 
 |  |  |    int GridSearch() | 
 |  |  |    { | 
 |  |  |       xml x; | 
 |  |  |  | 
 |  |  |       xaserver::LoadUrl(L"", L"dev:vface[公共设置.vface]", L"", x); | 
 |  |  |       //trace(x.xml()); | 
 |  |  |       //trace(strtpl); | 
 |  |  |       xstring aa = strtpl; | 
 |  |  |       auto doc = x; | 
 |  |  |       auto n = doc.selectSingleNode(L"//resource[@url='" + aa + L"']/@src"); | 
 |  |  |       //trace(n.text());			 | 
 |  |  |  | 
 |  |  |       xaserverarg arg; | 
 |  |  |  | 
 |  |  |       arg.AddArg(L"sheet", n.text()); | 
 |  |  |       arg.AddArg(L"search", listwin::m_QueryTxt); | 
 |  |  |       openUrl(L"view.dlg.vface/xpage/grid/column/search", arg); | 
 |  |  |       xstring ok = arg.GetArgString(L"return"); | 
 |  |  |       if (ok == L"ok") { | 
 |  |  |          xstring txt = arg.GetArgString(L"search"); | 
 |  |  |          if (txt != L"") { | 
 |  |  |             m_QueryTxt = txt; | 
 |  |  |             //trace(txt); | 
 |  |  |             OnRetrieve(); | 
 |  |  |             return 1;	 | 
 |  |  |          } | 
 |  |  |          int adduomfolder() | 
 |  |  |          { | 
 |  |  |             xaserverarg__ arg = new xaserverarg__; | 
 |  |  |             arg.setNativePointer(arg.CreateInstance());		 | 
 |  |  |             arg.AddArg("note","新增"); | 
 |  |  |             arg.AddArg("m_id",m_id);				 | 
 |  |  |             //win__::OpenWindow("dev:xpage[AddUomGroup.vx]",arg); | 
 |  |  |             openUrl("公共设置.vface/xpage/quickcode/AddGroup", arg);					 | 
 |  |  |             string ok = arg.GetArgString("return"); | 
 |  |  |             if(ok == "ok"){ | 
 |  |  |                string GroupName = arg.GetArgString("GroupName");	 | 
 |  |  |                xml__ xx=new xml__; | 
 |  |  |                xx.setNativePointer(xml__::CreateInstance());				 | 
 |  |  |                xaserverarg__ args = new xaserverarg__; | 
 |  |  |                args.setNativePointer(args.CreateInstance());		 | 
 |  |  |                args.AddArg("GroupName",GroupName); | 
 |  |  |                args.AddArg("OldGroupName",""); | 
 |  |  |                args.AddArg("m_id",m_id);					 | 
 |  |  |                /*if(TFile::exec(m_config,"updateuomtype",args,xx)!=1) | 
 |  |  |                { | 
 |  |  |                   trace("error:"+xx.GetXml()); | 
 |  |  |                   alert("保存出错!"); | 
 |  |  |                   return 0; | 
 |  |  |                }*/ | 
 |  |  |                if (url::get("QuickCode/pref/quickcode_tree.updateGroup",args.GetString(),xx) != 1) | 
 |  |  |                { | 
 |  |  |                   trace("error:"+xx.GetXml()); | 
 |  |  |                   alert("保存出错!"); | 
 |  |  |                   return 0; | 
 |  |  |                }						 | 
 |  |  |                else | 
 |  |  |                {	 | 
 |  |  |                   string vv=xx.GetXmlDoc().documentElement.text; | 
 |  |  |                   xml__ x=new xml__; | 
 |  |  |                   x.setNativePointer(xml__::CreateInstance()); | 
 |  |  |                   x.LoadXml("<row GroupName='"+GroupName+"'/>"); | 
 |  |  |                   int root = treeview__::GetRootItem(tv_1.GetId()); | 
 |  |  |                   if(vv=="OK") | 
 |  |  |                   {	 | 
 |  |  |                      treeview__::InsertChildItem(tv_1.GetId(), root, GroupName,x.GetXmlDoc().documentElement, 15);								 | 
 |  |  |                   } | 
 |  |  | 		 | 
 |  |  |                }	 | 
 |  |  |             }					 | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          int modifyuomfolder() | 
 |  |  |          { | 
 |  |  |             int wid = tv_1.GetId(); | 
 |  |  |             int h = treeview__::GetSelectedItem(wid); | 
 |  |  |             if (h<1) | 
 |  |  |             { | 
 |  |  |                alert("请选择需要修改的组名"); | 
 |  |  |                return 0; | 
 |  |  |             } | 
 |  |  |             int roothitem=treeview__::GetRootItem(wid); | 
 |  |  |             if(h==roothitem) | 
 |  |  |             {	 | 
 |  |  |                alert("不能修改根节点名称!");					 | 
 |  |  |             } | 
 |  |  |             else | 
 |  |  |             {	 | 
 |  |  |                msxml::IXMLDOMElement e = treeview__::GetItemData(wid,h); | 
 |  |  |                trace(e.xml); | 
 |  |  |                //string  OldGroupName= e.SelectSingleNode("@GroupName").text; | 
 |  |  |                string  OldGroupName= treeview__::GetItemLabel(wid,h); | 
 |  |  |                xaserverarg__ arg = new xaserverarg__; | 
 |  |  |                arg.setNativePointer(arg.CreateInstance());		 | 
 |  |  |                arg.AddArg("note","修改"); | 
 |  |  |                arg.AddArg("m_id",m_id);					 | 
 |  |  |                arg.AddArg("GroupName",OldGroupName);				 | 
 |  |  |                win__::OpenWindow("dev:xpage[AddUomGroup.vx]",arg); | 
 |  |  |                string ok = arg.GetArgString("return"); | 
 |  |  |                if(ok == "ok"){ | 
 |  |  |                   string NewGroupName = arg.GetArgString("GroupName");	 | 
 |  |  |                   xml__ xx=new xml__; | 
 |  |  |                   xx.setNativePointer(xml__::CreateInstance());				 | 
 |  |  |                   xaserverarg__ args = new xaserverarg__; | 
 |  |  |                   args.setNativePointer(args.CreateInstance());		 | 
 |  |  |                   args.AddArg("GroupName",NewGroupName); | 
 |  |  |                   args.AddArg("OldGroupName",OldGroupName); | 
 |  |  |                   args.AddArg("m_id",m_id);			 | 
 |  |  |                   /*if(TFile::exec(m_config,"updateuomtype",args,xx)!=1) | 
 |  |  |                   { | 
 |  |  |                      trace("error:"+xx.GetXml()); | 
 |  |  |                      alert("保存出错!"); | 
 |  |  |                      return 0; | 
 |  |  |                   }*/ | 
 |  |  |                   if (url::get("QuickCode/pref/quickcode_tree.updateGroup",args.GetString(),xx)!=1) | 
 |  |  |                   { | 
 |  |  |                      trace("error:"+xx.GetXml()); | 
 |  |  |                      alert("保存出错!"); | 
 |  |  |                      return 0; | 
 |  |  |                   }					 | 
 |  |  |                   else | 
 |  |  |                   {	 | 
 |  |  |                   trace(xx.GetXml()); | 
 |  |  |                      string vv=xx.GetXmlDoc().documentElement.text;	 | 
 |  |  |                      if(vv=="OK") | 
 |  |  |                      {							 | 
 |  |  |                         treeview__::SetItemLabel(tv_1.GetId(), h,NewGroupName); | 
 |  |  |                      } | 
 |  |  |       } | 
 |  |  |       return 0; | 
 |  |  |    } | 
 |  |  |    int OnCmdDispatch(xstring comdid) | 
 |  |  |    { | 
 |  |  |       HCURSOR hCursor = xutil::SetCursorWait(); | 
 |  |  |       xdwgrid dw = getDW(); | 
 |  |  |       if (comdid == L"save") { | 
 |  |  |          dw_list.AcceptText(); | 
 |  |  |          xml x; | 
 |  |  |  | 
 |  |  |                   }	 | 
 |  |  |                } | 
 |  |  |             }					 | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          int deluomfolder() | 
 |  |  |          {	 | 
 |  |  | 				 | 
 |  |  |             int wid = tv_1.GetId(); | 
 |  |  |             int hitem=treeview__::GetSelectedItem(wid); | 
 |  |  |             if (hitem<1) | 
 |  |  |             { | 
 |  |  |                alert("请选择需要删除的组名"); | 
 |  |  |                return 0; | 
 |  |  |             }					 | 
 |  |  |             else | 
 |  |  |             { | 
 |  |  |          xaserverarg arg; | 
 |  |  |  | 
 |  |  |                int s=dw_list.GetRowCount(); | 
 |  |  |                if (s>0) | 
 |  |  |                { | 
 |  |  |                   alert("该分组下面存在数据,不能删除!"); | 
 |  |  |                   return 0; | 
 |  |  |                } | 
 |  |  |                int roothitem=treeview__::GetRootItem(wid); | 
 |  |  |                if(hitem==roothitem) | 
 |  |  |                {	 | 
 |  |  |                   alert("不能删除根节点!");					 | 
 |  |  |                } | 
 |  |  |                else | 
 |  |  |                {	 | 
 |  |  |                   //缺少判断删除的条件 | 
 |  |  |                   string GroupName =treeview__::GetItemLabel(wid,hitem); | 
 |  |  |                   if(win__::MessageBox(GetHWND(),"确定删除组名:"+GroupName+" 吗?","提示",1)==1) | 
 |  |  |                   { | 
 |  |  |                      xml__ xx=new xml__; | 
 |  |  |                      xx.setNativePointer(xml__::CreateInstance());		 | 
 |  |  |                      xaserverarg__ arg = new xaserverarg__; | 
 |  |  |                      arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |                      arg.AddArg("GroupName",GroupName); | 
 |  |  |                      arg.AddArg("m_id",m_id); | 
 |  |  |                      trace(GroupName); | 
 |  |  |                      trace(m_id);					 | 
 |  |  |                      /*if (xaserver__::ExecXAction(GetServerUrl(),"[delete.type.FND_UOM.xa]",arg.GetString()) == 1) | 
 |  |  |                      { | 
 |  |  |                         treeview__::DeleteItem(wid,hitem); | 
 |  |  |                         //OnTreeSelChanged(); | 
 |  |  |                      }*/ | 
 |  |  |                      if (url::get("QuickCode/pref/quickcode_tree.deleteGroup",arg.GetString(),xx)== 1) | 
 |  |  |                      { | 
 |  |  |                         treeview__::DeleteItem(wid,hitem); | 
 |  |  |                      }								 | 
 |  |  |                      else | 
 |  |  |                         alert("删除失败!"); | 
 |  |  |                   } | 
 |  |  |                }						 | 
 |  |  |             } | 
 |  |  |             return 1; | 
 |  |  |          }					 | 
 |  |  |          xdwgrid__ getDW() | 
 |  |  |          dw_list.DwUpdateAllToEx(x); | 
 |  |  |          KXMLDOMElement e = x.documentElement(); | 
 |  |  |          e.setAttribute(L"id", m_id); | 
 |  |  |          //arg.AddArg(L"id",m_id); | 
 |  |  |          //trace(m_id); | 
 |  |  |          //trace(m_dbmap); | 
 |  |  |          if (m_id == L"开票银行") | 
 |  |  |          { | 
 |  |  |             return dw_list;					 | 
 |  |  |             xml kp; | 
 |  |  |  | 
 |  |  |             kp.loadXML(L"<root></root>"); | 
 |  |  |             KXMLDOMElement ele = kp.documentElement(); | 
 |  |  |             auto list = e.selectNodes(L"item[@update.modify='1' or @update.delete='1' ]"); | 
 |  |  |             int j; | 
 |  |  |             int k = list.length(); | 
 |  |  |             for (j = 0; j < k; j++) | 
 |  |  |             { | 
 |  |  |                KXMLDOMElement ele1 = list.item(j); | 
 |  |  |                ele.appendChild(ele1); | 
 |  |  |             } | 
 |  |  |             kpstr = ele.xml(); | 
 |  |  |             trace(ele.xml()); | 
 |  |  |          } | 
 |  |  |          int GridSearch() | 
 |  |  |          if (m_id == L"开票银行") | 
 |  |  |          { | 
 |  |  |             xml__ x = new xml__; | 
 |  |  |             x.setNativePointer(xml__ ::CreateInstance()); | 
 |  |  |             xaserver__::LoadUrl("","dev:vface[公共设置.vface]","",x); | 
 |  |  |             //trace(x.GetXml()); | 
 |  |  |             //trace(strtpl); | 
 |  |  |             string aa=strtpl; | 
 |  |  |             var doc = x.GetXmlDoc(); | 
 |  |  |             var n = doc.selectSingleNode("//resource[@url='"+aa+"']/@src"); | 
 |  |  |             //trace(n.text);			 | 
 |  |  | 							 | 
 |  |  |             xaserverarg__ arg=new xaserverarg__; | 
 |  |  |             arg.setNativePointer(arg.CreateInstance());	 | 
 |  |  |             arg.AddArg("sheet",n.text); | 
 |  |  |             arg.AddArg("search",list::m_QueryTxt); | 
 |  |  |             openUrl("view.dlg.vface/xpage/grid/column/search", arg);						 | 
 |  |  |             string ok = arg.GetArgString("return"); | 
 |  |  |             if(ok == "ok"){ | 
 |  |  |                string txt = arg.GetArgString("search"); | 
 |  |  |                if(txt != ""){		 | 
 |  |  |                   m_QueryTxt = txt; | 
 |  |  |                   //trace(txt); | 
 |  |  |                   OnRetrieve(); | 
 |  |  |                } | 
 |  |  |             } | 
 |  |  |             arg.AddArg(L"content", kpstr); | 
 |  |  |          } | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             arg.AddArg(L"content", e.xml()); | 
 |  |  |          } | 
 |  |  |          arg.AddArg(L"dbmap", m_dbmap); | 
 |  |  |          /*if(TFile::exec(m_config,L"save",arg,x)!=1) | 
 |  |  |          { | 
 |  |  |             trace(L"error:"+x.xml()); | 
 |  |  |             alert(L"保存出错!"); | 
 |  |  |             return 0; | 
 |  |  |          }							 | 
 |  |  |          int OnCmdDispatch(string comdid) | 
 |  |  |          }*/ | 
 |  |  |          trace(m_dbmap + L"\r\n" + e.xml()); | 
 |  |  |          if (xurl::get(L"QuickCode/pref/quickcode.save", arg.GetString(), x) != 1) | 
 |  |  |          { | 
 |  |  |             int hCursor = xutil__::SetCursorWait(); | 
 |  |  |             xdwgrid__ dw=getDW();				 | 
 |  |  |             if(comdid == "save"){ | 
 |  |  |                dw_list.AcceptText(); | 
 |  |  |                xml__ x=new xml__; | 
 |  |  |                x.setNativePointer(xml__::CreateInstance()); | 
 |  |  |                xaserverarg__ arg=new xaserverarg__; | 
 |  |  |                arg.setNativePointer(arg.CreateInstance());	 | 
 |  |  |                dw_list.DwUpdateAllToEx(x.GetXmlDoc());  | 
 |  |  |                msxml::IXMLDOMElement e= x.GetXmlDoc().documentElement; | 
 |  |  |                e.SetAttribute("id", m_id); | 
 |  |  |                //arg.AddArg("id",m_id); | 
 |  |  |                //trace(m_id); | 
 |  |  |                //trace(m_dbmap); | 
 |  |  |                if(m_id=="开票银行") | 
 |  |  |                {	 | 
 |  |  |                   xml__ kp = new xml__; | 
 |  |  |                   kp.setNativePointer(xml__::CreateInstance());			 | 
 |  |  |                   kp.LoadXml("<root></root>"); | 
 |  |  |                   msxml::IXMLDOMElement ele= kp.GetXmlDoc().documentElement; | 
 |  |  |                   var list = e.SelectNodes("item[@update.modify='1' or @update.delete='1' ]"); | 
 |  |  |                   int j; | 
 |  |  |                   int k = list.length; | 
 |  |  |                   for (j=0; j<k; j++) | 
 |  |  |                   { | 
 |  |  |                      msxml::IXMLDOMElement ele1 = list.item(j); | 
 |  |  |                      ele.appendChild(ele1);			 | 
 |  |  |                   } | 
 |  |  |                   kpstr=ele.xml; | 
 |  |  |                   trace(ele.xml);					 | 
 |  |  |                }	 | 
 |  |  |                if(m_id=="开票银行") | 
 |  |  |                {	 | 
 |  |  |                   arg.AddArg("content",kpstr);					 | 
 |  |  |                } | 
 |  |  |                else  | 
 |  |  |                {	 | 
 |  |  |                   arg.AddArg("content",e.xml);					 | 
 |  |  |                }						 | 
 |  |  |                arg.AddArg("dbmap", m_dbmap); | 
 |  |  |                /*if(TFile::exec(m_config,"save",arg,x)!=1) | 
 |  |  |                { | 
 |  |  |                   trace("error:"+x.GetXml()); | 
 |  |  |                   alert("保存出错!"); | 
 |  |  |                   return 0; | 
 |  |  |                }*/ | 
 |  |  |                trace(m_dbmap+"\r\n"+e.xml);					 | 
 |  |  |                if (url::get("QuickCode/pref/quickcode.save",arg.GetString(),x) != 1) | 
 |  |  |                { | 
 |  |  |                   string error = x.GetXmlDoc().text; | 
 |  |  |                   trace(error); | 
 |  |  |                }					 | 
 |  |  |                //trace(arg.GetString()); | 
 |  |  |                if(x.GetXmlDoc().selectSingleNode("error")) | 
 |  |  |                { | 
 |  |  |                   alert("保存出错2!"); | 
 |  |  |                   return 0;				 | 
 |  |  |                } | 
 |  |  |                dw_list.ResetUpdateStatus(); | 
 |  |  |                alert("保存成功!"); | 
 |  |  |             } | 
 |  |  |             else if(comdid=="add"){ | 
 |  |  |                dw.InsertRow(0);  | 
 |  |  |                int rows = dw.GetRowCount(); | 
 |  |  |                dw.SetItemString(rows,"GroupName",c_type);			 | 
 |  |  |                dw.SetItemString(rows,"BankName",c_type);	 | 
 |  |  |             } | 
 |  |  |             else if(comdid=="insert"){ | 
 |  |  |                int row = dw.GetRow(); | 
 |  |  |                if(row<1 || row>dw.GetRowCount()) return 0; | 
 |  |  |                dw.InsertRow(row);  | 
 |  |  | 				 | 
 |  |  |                dw.SetItemString(row,"GroupName",c_type);				 | 
 |  |  |             } | 
 |  |  |             else if(comdid == "delet"){ | 
 |  |  |                dw_list.AcceptText(); | 
 |  |  |                int row2 = dw.GetRow(); | 
 |  |  |                if(row2<1 || row2>dw.GetRowCount()) return 0; | 
 |  |  |                dw.DeleteRow(row2); | 
 |  |  |             } | 
 |  |  |             else if (comdid=="adduomfolder") | 
 |  |  |                adduomfolder(); | 
 |  |  |             else if (comdid=="modifyuomfolder") | 
 |  |  |                modifyuomfolder(); | 
 |  |  |             else if (comdid=="deluomfolder") | 
 |  |  |                deluomfolder(); | 
 |  |  |             else if (comdid=="search") | 
 |  |  |                GridSearch();				 | 
 |  |  |             xutil__::RestoreCursor(hCursor); | 
 |  |  |             xstring error = x.text(); | 
 |  |  |             trace(error); | 
 |  |  |          } | 
 |  |  |          //trace(arg.GetString()); | 
 |  |  |          if (x.selectSingleNode(L"error")) | 
 |  |  |          { | 
 |  |  |             alert(L"保存出错2!"); | 
 |  |  |             return 0; | 
 |  |  |          } | 
 |  |  |          int OnXCommand(ref TXCommandEvent evt,int p) | 
 |  |  |          { | 
 |  |  |             return OnCmdDispatch(""+evt.pStrID); | 
 |  |  |          } | 
 |  |  |          int OnSetFocus(ref TNotifyEvent evt,int p){ | 
 |  |  |             SetAgent(); | 
 |  |  |             tv_1 =  new treeview__; | 
 |  |  |             tv_1.setNativePointer(this.GetControl("tv_1")); | 
 |  |  |             int wid = tv_1.GetId(); | 
 |  |  |             int root = treeview__::GetRootItem(wid);		 | 
 |  |  |             treeview__::ExpandItem(wid,root);					 | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          int OnDoubleClicked(ref TNotifyEvent evt,int p) | 
 |  |  |          { | 
 |  |  |             ref DWNMHDR  hdr = evt.pnmh; | 
 |  |  |             int row = hdr.row; | 
 |  |  |             if(row<1 || row > dw_list.GetRowCount() ) return 0; | 
 |  |  | 				 | 
 |  |  |             xaserverarg__ arg = new xaserverarg__; | 
 |  |  |             arg.setNativePointer(arg.CreateInstance());	 | 
 |  |  |             //string str = hdr.data; | 
 |  |  |             string colname=hdr.colname; | 
 |  |  |             string str = dw_list.GetItemString(row, colname); | 
 |  |  |             arg.AddArg("value",str); | 
 |  |  |             openUrl("/sale/view/view.dlg/xpage/memo/edit", arg);									 | 
 |  |  |             string comdid = arg.GetArgString("comdid"); | 
 |  |  |             if(comdid=="xmOK") | 
 |  |  |             { | 
 |  |  |                string value = arg.GetArgString("value"); | 
 |  |  |                dw_list.SetItemString(row,colname,value);  | 
 |  |  |                dw_list.Redraw(); | 
 |  |  |             }								 | 
 |  |  | 				 | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          int ItemOutput() | 
 |  |  |          { | 
 |  |  |             string d = xaserver__::GetCurrentDate(); | 
 |  |  |             d = d.left(10) +""; | 
 |  |  |             dw_list.SaveAs(d);		 | 
 |  |  |             return 1; | 
 |  |  |          }				 | 
 |  |  |          int OnSelectAllRow() | 
 |  |  |          { | 
 |  |  |             int rows =  this.dw_list.GetRowCount(); | 
 |  |  |             if(rows < 1) return -1; | 
 |  |  |              this.dw_list.SelectRow(1, rows, true); | 
 |  |  |              this.dw_list.Redraw(); | 
 |  |  |             return 1; | 
 |  |  |          }				 | 
 |  |  |          int OnRowCopy() | 
 |  |  |          { | 
 |  |  |             int rows = this.dw_list.GetRowCount(); | 
 |  |  |             if(rows < 1) return -1; | 
 |  |  |             int cols = this.dw_list.GetColumnCount();  | 
 |  |  |             string str = ""; | 
 |  |  |             int row = this.dw_list.GetNextSelectRow(1); | 
 |  |  |             int i; | 
 |  |  |             while(row > 0) | 
 |  |  |             { | 
 |  |  |                string tmp1 = ""; | 
 |  |  |                for(i=1; i<cols; i++) | 
 |  |  |                { | 
 |  |  |                   int w = this.dw_list.GetColumnWidth(i); | 
 |  |  |                   if(w < 5) continue; | 
 |  |  |                   string tmp; | 
 |  |  |                   if(this.dw_list.GetItemDisplayString(row, i + 1)) | 
 |  |  |                      tmp = this.dw_list.GetItemDisplayString(row, i + 1); | 
 |  |  |                   else | 
 |  |  |                      tmp = this.dw_list.GetItemString(row, i + 1);							 | 
 |  |  |                   tmp1 += tmp + "\t"; | 
 |  |  |                } | 
 |  |  |                str += tmp1 + "\r\n"; | 
 |  |  |                row = this.dw_list.GetNextSelectRow(row + 1); | 
 |  |  |             } | 
 |  |  |             this.dw_list.SetDataToClip(str); | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          int OnColCopy(string col) | 
 |  |  |          { | 
 |  |  |             int rows = this.dw_list.GetRowCount(); | 
 |  |  |             if(rows < 1) return -1; | 
 |  |  |             string str = ""; | 
 |  |  |             int row = this.dw_list.GetNextSelectRow(1); | 
 |  |  |             while(row > 0) | 
 |  |  |             { | 
 |  |  |                string tmp; | 
 |  |  |                if(this.dw_list.GetItemDisplayString(row, col)) | 
 |  |  |                   tmp = this.dw_list.GetItemDisplayString(row,col); | 
 |  |  |                else | 
 |  |  |                   tmp = this.dw_list.GetItemString(row, col);						 | 
 |  |  |                str += tmp + "\r\n"; | 
 |  |  |                row = this.dw_list.GetNextSelectRow(row + 1); | 
 |  |  |             } | 
 |  |  |             this.dw_list.SetDataToClip(str); | 
 |  |  | 				 | 
 |  |  |             return 1; | 
 |  |  |          }					 | 
 |  |  |          int OnRClick(ref TNotifyEvent evt,int p) | 
 |  |  |          { | 
 |  |  |             ref DWNMHDR  hdr = evt.pnmh; | 
 |  |  |             int row = hdr.row; | 
 |  |  | 				 | 
 |  |  |             int m = win__::CreatePopupMenu(); | 
 |  |  |             int MF_STRING = 0x00000000; | 
 |  |  |             int MF_DISABLED  = 0x00000002; | 
 |  |  |             int TPM_RIGHTBUTTON = 0x0002; | 
 |  |  |             int TPM_RETURNCMD = 0x0100; | 
 |  |  |             int MF_CHECKED = 0x8; | 
 |  |  |             int MF_SEPARATOR = 0x0800; | 
 |  |  |             win__::AppendMenu(m,MF_STRING, 1, "复制行");		 | 
 |  |  |             win__::AppendMenu(m,MF_STRING, 101, "复制列");		 | 
 |  |  |             win__::AppendMenu(m,MF_SEPARATOR, -1, "");		 | 
 |  |  |             win__::AppendMenu(m,MF_STRING, 2, "ȫѡ");		 | 
 |  |  |             win__::AppendMenu(m,MF_SEPARATOR, -1, "");		 | 
 |  |  |             win__::AppendMenu(m,MF_STRING, 4, "导出到Excel"); | 
 |  |  |             win__::AppendMenu(m,MF_SEPARATOR, -1, "");		 | 
 |  |  |             win__::AppendMenu(m,MF_STRING, 6, "显示列设置"); | 
 |  |  |             xrect xr; | 
 |  |  |             xpoint pt; | 
 |  |  |             win__::GetCursorPos(pt);				 | 
 |  |  |             int ret=win__::TrackPopupMenu(m, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, this.GetHWND(), xr); | 
 |  |  | 				 | 
 |  |  |             //trace(ret); | 
 |  |  |             int hCursor = xutil__::SetCursorWait();					 | 
 |  |  |             if(ret == 1) {OnRowCopy();} | 
 |  |  |             else if(ret == 101) { | 
 |  |  |                string colname=hdr.colname; | 
 |  |  |                if(colname != "") | 
 |  |  |                   OnColCopy(colname); | 
 |  |  |             } | 
 |  |  |             else if(ret == 2) {OnSelectAllRow();} | 
 |  |  |             else if(ret == 4) {ItemOutput();} | 
 |  |  |             else if(ret == 6) {} | 
 |  |  |             xutil__::RestoreCursor(hCursor);				 | 
 |  |  | 					 | 
 |  |  |             return 1; | 
 |  |  |          }				 | 
 |  |  |          int OnAttachEvent() | 
 |  |  |          { | 
 |  |  |             //获取焦点事件,用于重置工具条 | 
 |  |  |             AttachEvent("WM_SETFOCUS",OnSetFocus); | 
 |  |  |             //绑定工具条点击事件 | 
 |  |  |             AttachEvent("WM_XCOMMAND",OnXCommand); | 
 |  |  |             //获得树的选择事件 | 
 |  |  |             AttachEvent("tv_1", "TVN_SELCHANGED",OnTreeSelChanged);	 | 
 |  |  |             AttachEvent("dw_list","DWV_DOUBLECLICKED",OnDoubleClicked);//行双击 | 
 |  |  |             AttachEvent("dw_list","DWV_RCLICKED",OnRClick);//鼠标右键								 | 
 |  |  |          } | 
 |  |  |          dw_list.ResetUpdateStatus(); | 
 |  |  |          alert(L"保存成功!"); | 
 |  |  |       } | 
 |  |  |       else if (comdid == L"add") { | 
 |  |  |          dw.InsertRow(0); | 
 |  |  |          int rows = dw.GetRowCount(); | 
 |  |  |          dw.SetItemString(rows, L"GroupName", c_type); | 
 |  |  |          dw.SetItemString(rows, L"BankName", c_type); | 
 |  |  |       } | 
 |  |  |       else if (comdid == L"insert") { | 
 |  |  |          int row = dw.GetRow(); | 
 |  |  |          if (row<1 || row>dw.GetRowCount()) return 0; | 
 |  |  |          dw.InsertRow(row); | 
 |  |  |  | 
 |  |  | 				 | 
 |  |  |          string jxParam(string p, string n) | 
 |  |  |          dw.SetItemString(row, L"GroupName", c_type); | 
 |  |  |       } | 
 |  |  |       else if (comdid == L"delet") { | 
 |  |  |          dw_list.AcceptText(); | 
 |  |  |          int row2 = dw.GetRow(); | 
 |  |  |          if (row2<1 || row2>dw.GetRowCount()) return 0; | 
 |  |  |          dw.DeleteRow(row2); | 
 |  |  |       } | 
 |  |  |       else if (comdid == L"adduomfolder") | 
 |  |  |          adduomfolder(); | 
 |  |  |       else if (comdid == L"modifyuomfolder") | 
 |  |  |          modifyuomfolder(); | 
 |  |  |       else if (comdid == L"deluomfolder") | 
 |  |  |          deluomfolder(); | 
 |  |  |       else if (comdid == L"search") | 
 |  |  |          GridSearch(); | 
 |  |  |       xutil::RestoreCursor(hCursor); | 
 |  |  |       return 0; | 
 |  |  |    } | 
 |  |  |    int OnXCommand(TEvent* evt, LPARAM param) | 
 |  |  |    { | 
 |  |  |       return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |    } | 
 |  |  |    int OnSetFocus(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       SetAgent(); | 
 |  |  |       tv_1 = GetControl(L"tv_1"); | 
 |  |  |  | 
 |  |  |       HTREEITEM root = tv_1.GetRootItem(); | 
 |  |  |       tv_1.ExpandItem(root); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnDoubleClicked(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |       int row = hdr.row; | 
 |  |  |       if (row<1 || row > dw_list.GetRowCount()) return 0; | 
 |  |  |  | 
 |  |  |       xaserverarg arg; | 
 |  |  |  | 
 |  |  |       //xstring str = hdr.data; | 
 |  |  |       xstring colname = hdr.colname; | 
 |  |  |       xstring str = dw_list.GetItemString(row, colname.c_str()); | 
 |  |  |       arg.AddArg(L"value", str); | 
 |  |  |       openUrl(L"/sale/view/view.dlg/xpage/memo/edit", arg); | 
 |  |  |       xstring comdid = arg.GetArgString(L"comdid"); | 
 |  |  |       if (comdid == L"xmOK") | 
 |  |  |       { | 
 |  |  |          xstring value = arg.GetArgString(L"value"); | 
 |  |  |          dw_list.SetItemString(row, colname.c_str(), value); | 
 |  |  |          dw_list.Redraw(); | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int ItemOutput() | 
 |  |  |    { | 
 |  |  |       xstring d = publiccode::GetCurrentDate(); | 
 |  |  |       d = d.left(10) + L""; | 
 |  |  |       dw_list.SaveAs(d); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnSelectAllRow() | 
 |  |  |    { | 
 |  |  |       int rows = dw_list.GetRowCount(); | 
 |  |  |       if (rows < 1) return -1; | 
 |  |  |       dw_list.SelectRow(1, rows, true); | 
 |  |  |       dw_list.Redraw(); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnRowCopy() | 
 |  |  |    { | 
 |  |  |       int rows = dw_list.GetRowCount(); | 
 |  |  |       if (rows < 1) return -1; | 
 |  |  |       int cols = dw_list.GetColumnCount(); | 
 |  |  |       xstring str = L""; | 
 |  |  |       int row = dw_list.GetNextSelectRow(1); | 
 |  |  |       int i; | 
 |  |  |       while (row > 0) | 
 |  |  |       { | 
 |  |  |          xstring tmp1 = L""; | 
 |  |  |          for (i = 1; i < cols; i++) | 
 |  |  |          { | 
 |  |  |             if(p != "") | 
 |  |  |             { | 
 |  |  |                p +="&"; | 
 |  |  |                int i = 1; | 
 |  |  |                while (p.find("=",0)>0) | 
 |  |  |                { | 
 |  |  |                   string name = p.mid(0, p.find("=",0)); | 
 |  |  |                   string value = p.mid(p.find("=",0) + 1, p.find("&",0) - p.find("=",0) - 1); | 
 |  |  |                   if(name==n) return ""+value; | 
 |  |  |                   i += 1; | 
 |  |  |                   p = p.mid(p.find("&",0) + 1, p.length()); | 
 |  |  |                } | 
 |  |  |             }		 | 
 |  |  |             return ""; | 
 |  |  |             int w = dw_list.GetColumnWidth(i); | 
 |  |  |             if (w < 5) continue; | 
 |  |  |             xstring tmp; | 
 |  |  |             if (dw_list.GetItemDisplayString(row, i + 1)) | 
 |  |  |                tmp = dw_list.GetItemDisplayString(row, i + 1); | 
 |  |  |             else | 
 |  |  |                tmp = dw_list.GetItemString(row, i + 1); | 
 |  |  |             tmp1 += tmp + L"\t"; | 
 |  |  |          } | 
 |  |  |          int getURLParam() | 
 |  |  |          str += tmp1 + L"\r\n"; | 
 |  |  |          row = dw_list.GetNextSelectRow(row + 1); | 
 |  |  |       } | 
 |  |  |       dw_list.SetDataToClip(str); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnColCopy(xstring col) | 
 |  |  |    { | 
 |  |  |       int rows = dw_list.GetRowCount(); | 
 |  |  |       if (rows < 1) return -1; | 
 |  |  |       xstring str = L""; | 
 |  |  |       int row = dw_list.GetNextSelectRow(1); | 
 |  |  |       while (row > 0) | 
 |  |  |       { | 
 |  |  |          xstring tmp; | 
 |  |  |          if (dw_list.GetItemDisplayString(row, col.c_str())) | 
 |  |  |             tmp = dw_list.GetItemDisplayString(row, col.c_str()); | 
 |  |  |          else | 
 |  |  |             tmp = dw_list.GetItemString(row, col.c_str()); | 
 |  |  |          str += tmp + L"\r\n"; | 
 |  |  |          row = dw_list.GetNextSelectRow(row + 1); | 
 |  |  |       } | 
 |  |  |       dw_list.SetDataToClip(str); | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnRClick(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |       int row = hdr.row; | 
 |  |  |  | 
 |  |  |       HMENU m = CreatePopupMenu(); | 
 |  |  |       int MF_STRING = 0x00000000; | 
 |  |  |       int MF_DISABLED = 0x00000002; | 
 |  |  |       int TPM_RIGHTBUTTON = 0x0002; | 
 |  |  |       int TPM_RETURNCMD = 0x0100; | 
 |  |  |       int MF_CHECKED = 0x8; | 
 |  |  |       int MF_SEPARATOR = 0x0800; | 
 |  |  |       AppendMenu(m, MF_STRING, 1, L"复制行"); | 
 |  |  |       AppendMenu(m, MF_STRING, 101, L"复制列"); | 
 |  |  |       AppendMenu(m, MF_SEPARATOR, -1, L""); | 
 |  |  |       AppendMenu(m, MF_STRING, 2, L"ȫѡ"); | 
 |  |  |       AppendMenu(m, MF_SEPARATOR, -1, L""); | 
 |  |  |       AppendMenu(m, MF_STRING, 4, L"导出到Excel"); | 
 |  |  |       AppendMenu(m, MF_SEPARATOR, -1, L""); | 
 |  |  |       AppendMenu(m, MF_STRING, 6, L"显示列设置"); | 
 |  |  |       RECT xr; | 
 |  |  |       xpoint pt; | 
 |  |  |       GetCursorPos(pt); | 
 |  |  |       int ret = TrackPopupMenu(m, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, GetHWND(), &xr); | 
 |  |  |  | 
 |  |  |       //trace(ret); | 
 |  |  |       HCURSOR hCursor = xutil::SetCursorWait(); | 
 |  |  |       if (ret == 1) { OnRowCopy(); } | 
 |  |  |       else if (ret == 101) { | 
 |  |  |          xstring colname = hdr.colname; | 
 |  |  |          if (colname != L"") | 
 |  |  |             OnColCopy(colname); | 
 |  |  |       } | 
 |  |  |       else if (ret == 2) { OnSelectAllRow(); } | 
 |  |  |       else if (ret == 4) { ItemOutput(); } | 
 |  |  |       else if (ret == 6) {} | 
 |  |  |       xutil::RestoreCursor(hCursor); | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnAttachEvent() | 
 |  |  |    { | 
 |  |  |       //获取焦点事件,用于重置工具条 | 
 |  |  |       AttachEvent(L"WM_SETFOCUS", (FEvent)&QuickCode_Tree::OnSetFocus); | 
 |  |  |       //绑定工具条点击事件 | 
 |  |  |       AttachEvent(L"WM_XCOMMAND", (FEvent)&QuickCode_Tree::OnXCommand); | 
 |  |  |       //获得树的选择事件 | 
 |  |  |       AttachEvent(L"tv_1", L"TVN_SELCHANGED", (FEvent)&QuickCode_Tree::OnTreeSelChanged); | 
 |  |  |       AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&QuickCode_Tree::OnDoubleClicked);//行双击 | 
 |  |  |       AttachEvent(L"dw_list", L"DWV_RCLICKED", (FEvent)&QuickCode_Tree::OnRClick);//鼠标右键		 | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |    xstring jxParam(xstring p, xstring n) | 
 |  |  |    { | 
 |  |  |       if (p != L"") | 
 |  |  |       { | 
 |  |  |          p += L"&"; | 
 |  |  |          int i = 1; | 
 |  |  |          while (p.find(L"=", 0) > 0) | 
 |  |  |          { | 
 |  |  |             if(GetParam()) | 
 |  |  |             { | 
 |  |  |                xpage__ xp=new xpage__; | 
 |  |  |                xp.setNativePointer(this.GetXPage()); | 
 |  |  |                string aurl = xp.GetWkUrl(); | 
 |  |  |                xaserverarg__ arg; | 
 |  |  |                if(aurl && aurl.find("native=true",0)>0) | 
 |  |  |                { | 
 |  |  |                   int p = this.GetParam(); | 
 |  |  |                   arg = new xaserverarg__; | 
 |  |  |                   arg.setNativePointer(p); | 
 |  |  |                } | 
 |  |  |                else | 
 |  |  |                { | 
 |  |  |                   arg = GetParam(); | 
 |  |  |                } | 
 |  |  |                string config = arg.GetArgString("config"); | 
 |  |  |                xml__ x = new xml__; | 
 |  |  |                x.setNativePointer(xml__::CreateInstance()); | 
 |  |  |                if(config == "") | 
 |  |  |                { | 
 |  |  |                   string configXml = arg.GetArgString("configxml"); | 
 |  |  |                   x.LoadXml(configXml); | 
 |  |  |                } | 
 |  |  |                else | 
 |  |  |                { | 
 |  |  |                   getUrl(config, "", x);						 | 
 |  |  |                }	 | 
 |  |  |                m_configDoc = x.GetXmlDoc();			 | 
 |  |  |             xstring name = p.mid(0, p.find(L"=", 0)); | 
 |  |  |             xstring value = p.mid(p.find(L"=", 0) + 1, p.find(L"&", 0) - p.find(L"=", 0) - 1); | 
 |  |  |             if (name == n) return L"" + value; | 
 |  |  |             i += 1; | 
 |  |  |             p = p.mid(p.find(L"&", 0) + 1, p.length()); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return L""; | 
 |  |  |    } | 
 |  |  |    int getURLParam() | 
 |  |  |    { | 
 |  |  |       if (GetWinParam()) | 
 |  |  |       { | 
 |  |  |          xaserverarg arg = GetArg(); | 
 |  |  |          xstring config = arg.GetArgString(L"config"); | 
 |  |  |          xml x; | 
 |  |  |  | 
 |  |  |             } | 
 |  |  | 				 | 
 |  |  |             return 1; | 
 |  |  |          }						 | 
 |  |  |          int loaded() | 
 |  |  |          {	 | 
 |  |  |             getURLParam(); | 
 |  |  |             msxml::IXMLDOMDocument    ee=m_configDoc; | 
 |  |  |             string id=m_id; | 
 |  |  |             var n = ee.selectSingleNode("//list/dwview[@type='dwgrid'][@id='"+id+"']"); | 
 |  |  |             if(n) | 
 |  |  |             { | 
 |  |  |                msxml::IXMLDOMElement e = n; | 
 |  |  |                //trace(e.xml); | 
 |  |  |                string vface = m_configDoc.selectSingleNode("//vface[1]").text; | 
 |  |  |                string dwname = "";//e.selectsingleNode("@name").text; | 
 |  |  |                string tpl = "";//e.selectsingleNode("@url").text; | 
 |  |  |                string dbmap = ""; | 
 |  |  |                string strtreexquery=""; | 
 |  |  |                if(e.selectSingleNode("@name")) dwname = e.selectSingleNode("@name").text; | 
 |  |  |                if(e.selectSingleNode("@url")) tpl = e.selectSingleNode("@url").text; | 
 |  |  |                if(e.selectSingleNode("@dbmap")) dbmap = e.selectSingleNode("@dbmap").text; | 
 |  |  |                if(e.selectSingleNode("@treexquery")) strtreexquery = e.selectSingleNode("@treexquery").text;				 | 
 |  |  |                m_dbmap = dbmap; | 
 |  |  |                treexquery = strtreexquery; | 
 |  |  |                //trace(vface +"/"+ tpl); | 
 |  |  |                //trace(selectmode); | 
 |  |  |                dw_list = new xdwgrid__; | 
 |  |  |                dw_list.setNativePointer(GetControl(dwname)); | 
 |  |  |                dw_list.openUrl(vface +"/"+ tpl); | 
 |  |  |                strtpl=tpl; | 
 |  |  |                trace(tpl); | 
 |  |  |  | 
 |  |  |             }	 | 
 |  |  |          }					 | 
 |  |  |          int onload() | 
 |  |  |          if (config == L"") | 
 |  |  |          { | 
 |  |  |             xstring configXml = arg.GetArgString(L"configxml"); | 
 |  |  |             x.loadXML(configXml); | 
 |  |  |          } | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             getUrl(config, L"", x); | 
 |  |  |          } | 
 |  |  |          m_configDoc = x; | 
 |  |  |  | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int loaded() | 
 |  |  |    { | 
 |  |  |       getURLParam(); | 
 |  |  |       KXMLDOMDocument    ee = m_configDoc; | 
 |  |  |       xstring id = m_id; | 
 |  |  |       auto n = ee.selectSingleNode(L"//list/dwview[@type='dwgrid'][@id='" + id + L"']"); | 
 |  |  |       if (n) | 
 |  |  |       { | 
 |  |  |          KXMLDOMElement e = n; | 
 |  |  |          //trace(e.xml); | 
 |  |  |          xstring vface = m_configDoc.selectSingleNode(L"//vface[1]").text(); | 
 |  |  |          xstring dwname = L"";//e.selectsingleNode(L"@name").text(); | 
 |  |  |          xstring tpl = L"";//e.selectsingleNode(L"@url").text(); | 
 |  |  |          xstring dbmap = L""; | 
 |  |  |          xstring strtreexquery = L""; | 
 |  |  |          if (e.selectSingleNode(L"@name")) dwname = e.selectSingleNode(L"@name").text(); | 
 |  |  |          if (e.selectSingleNode(L"@url")) tpl = e.selectSingleNode(L"@url").text(); | 
 |  |  |          if (e.selectSingleNode(L"@dbmap")) dbmap = e.selectSingleNode(L"@dbmap").text(); | 
 |  |  |          if (e.selectSingleNode(L"@treexquery")) strtreexquery = e.selectSingleNode(L"@treexquery").text(); | 
 |  |  |          m_dbmap = dbmap; | 
 |  |  |          treexquery = strtreexquery; | 
 |  |  |          //trace(vface +L"/"+ tpl); | 
 |  |  |          //trace(selectmode); | 
 |  |  |          dw_list = new xdwgrid; | 
 |  |  |          dw_list.setNativePointer(GetControl(dwname)); | 
 |  |  |          dw_list.openUrl(vface + L"/" + tpl); | 
 |  |  |          strtpl = tpl; | 
 |  |  |          trace(tpl); | 
 |  |  |  | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int onload() | 
 |  |  |    { | 
 |  |  |  | 
 |  |  |       SetArg(); | 
 |  |  |       m_config = L"QuickCode.config"; | 
 |  |  |       m_agent = L""; | 
 |  |  |       dw_list = new xdwtable; | 
 |  |  |       dw_list.setNativePointer(GetControl(L"dw_list")); | 
 |  |  |       if (GetWinParam()) | 
 |  |  |       { | 
 |  |  |          xaserverarg arg = GetArg(); | 
 |  |  |          //trace(arg.GetString()); | 
 |  |  |          xstring id = arg.GetArgString(L"id"); | 
 |  |  |          if (id == L"") return 0; | 
 |  |  |          m_id = id; | 
 |  |  |          loaded(); | 
 |  |  |  | 
 |  |  |          /*xstring tpl = arg.GetArgString(L"tpl"); | 
 |  |  |          if(tpl == L"") | 
 |  |  |             tpl = L"QuickCode.tpl/QuickCode"; | 
 |  |  |          dw_list.SetDataObject(GetServerUrl(),L"dev:sheet["+tpl+L"]"); | 
 |  |  |          //dw_list.SetColHeaderHeight(0); | 
 |  |  |          //dw_list.SetRowSelectorWidth(0); | 
 |  |  |          xstring dbmap = arg.GetArgString(L"dbmap"); | 
 |  |  |          if(dbmap == L"") | 
 |  |  |             dbmap = L"QuickCode.dbmap"; | 
 |  |  |          m_dbmap = dbmap; | 
 |  |  |          xstring txquery=arg.GetArgString(L"treexquery"); | 
 |  |  |          treexquery=txquery; | 
 |  |  |          xstring title = arg.GetArgString(L"title"); | 
 |  |  |          if(title != L"") | 
 |  |  |             win::SetWindowText(GetHWND(),title);*/ | 
 |  |  |          OnRetrieve(); | 
 |  |  |       } | 
 |  |  |       SetAgent(); | 
 |  |  |       xstring aa = treexquery; | 
 |  |  |       xstring xfNodeAgentArea2 = L"treeagent"; | 
 |  |  |       xnode tnode = new xnode; | 
 |  |  |       tnode.setNativePointer(GetAgentNode(xfNodeAgentArea2)); | 
 |  |  |       xstring stree = L"<vbox><xtree name='tv_1' imagelist='0'>"; | 
 |  |  |       stree += L"<treeitem src='xquery:[" + aa + L"]'  xcaption='@GroupName' xroot='/root' xpath='row' xchildpath='row' image='15' loop='yes' xdata='.'/>"; | 
 |  |  |       stree += L"</xtree></vbox>"; | 
 |  |  |       SetAgentNode(tnode, stree); | 
 |  |  |  | 
 |  |  |       tv_1 = GetControl(L"tv_1"); | 
 |  |  |        | 
 |  |  |             m_config = "QuickCode.config"; | 
 |  |  |             m_agent = ""; | 
 |  |  |             dw_list = new xdwtable__; | 
 |  |  |             dw_list.setNativePointer(GetControl("dw_list"));				 | 
 |  |  |             if(this.GetParam()) | 
 |  |  |             { | 
 |  |  |                xaserverarg__ arg = this.GetParam(); | 
 |  |  |             //trace(arg.GetString()); | 
 |  |  |                string id = arg.GetArgString("id"); | 
 |  |  |                if(id == "") return 0; | 
 |  |  |                m_id = id;					 | 
 |  |  |                loaded(); | 
 |  |  | 	 | 
 |  |  |                /*string tpl = arg.GetArgString("tpl"); | 
 |  |  |                if(tpl == "") | 
 |  |  |                   tpl = "QuickCode.tpl/QuickCode"; | 
 |  |  |                dw_list.SetDataObject(GetServerUrl(),"dev:sheet["+tpl+"]"); | 
 |  |  |                //dw_list.SetColHeaderHeight(0); | 
 |  |  |                //dw_list.SetRowSelectorWidth(0);	 | 
 |  |  |                string dbmap = arg.GetArgString("dbmap"); | 
 |  |  |                if(dbmap == "") | 
 |  |  |                   dbmap = "QuickCode.dbmap"; | 
 |  |  |                m_dbmap = dbmap; | 
 |  |  |                string txquery=arg.GetArgString("treexquery"); | 
 |  |  |                treexquery=txquery; | 
 |  |  |                string title = arg.GetArgString("title"); | 
 |  |  |                if(title != "") | 
 |  |  |                   win__::SetWindowText(this.GetHWND(),title);*/ | 
 |  |  |                OnRetrieve(); | 
 |  |  |             } | 
 |  |  |             SetAgent();					 | 
 |  |  |             string aa=treexquery; | 
 |  |  |             string xfNodeAgentArea2  = "treeagent"; | 
 |  |  |             xnode__ tnode = new xnode__; | 
 |  |  |             tnode.setNativePointer(GetAgentNode(xfNodeAgentArea2)); | 
 |  |  |             string stree="<vbox><xtree name='tv_1' imagelist='0'>"; | 
 |  |  |             stree +="<treeitem src='xquery:["+aa+"]'  xcaption='@GroupName' xroot='/root' xpath='row' xchildpath='row' image='15' loop='yes' xdata='.'/>"; | 
 |  |  |             stree +="</xtree></vbox>"; | 
 |  |  |             SetAgentNodeContent (tnode,stree);				 | 
 |  |  |       HTREEITEM root = tv_1.GetRootItem(); | 
 |  |  |       tv_1.ExpandItem( root); | 
 |  |  |       OnAttachEvent(); | 
 |  |  |  | 
 |  |  |             tv_1 =  new treeview__; | 
 |  |  |             tv_1.setNativePointer(this.GetControl("tv_1")); | 
 |  |  |             int wid = tv_1.GetId(); | 
 |  |  |             int root = treeview__::GetRootItem(wid);		 | 
 |  |  |             treeview__::ExpandItem(wid,root);							 | 
 |  |  |             OnAttachEvent(); | 
 |  |  |  | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |       ] | 
 |  |  |    ] | 
 |  |  | ] | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  | }; |