LiFan
2024-07-17 f7c01240b27f0ad97feb9115b238d7a44b4b56b2
jrj/project/business/SystemSettings/BindComputer.cpp
@@ -1,106 +1,115 @@
use"lang.vl"
use "win.vl"
use "dev:vm[xdwgrid.vm]"
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <wobject/xdouble.hpp>
#include <xcontrol/xlayersheet.hpp>
unit vbusiness.vpage
[
   BindComputerDlgNew is extend win__;
   about BindComputerDlgNew
   [
      field:
      method:
      [
         xdwgrid__   dw_list;
         int  OnRetrieve()
         {
            xml__ x = new xml__;
            x.setNativePointer(xml__ ::CreateInstance());
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
using xml = KXMLDOMDocument;
class __declspec(dllexport) BindComputerDlgNew : public xwin
{
            xaserverarg__ arg=new xaserverarg__;
            arg.setNativePointer(arg.CreateInstance());
            arg = this.GetParam();
            if(arg.GetArgString("BindComputer"))
            {
               string sbys= arg.GetArgString("BindComputer");
               //alert(sbys);
               x.LoadXml(sbys);
            }
            else
            {
public:
               x.LoadXml("<args></args>");
            }
   xdwgrid   dw_list;
public:
   BindComputerDlgNew(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {}
public:
   static BindComputerDlgNew* CreateInstance(void* implPtr, void* hWnd)
   {
      BindComputerDlgNew* pWin = new BindComputerDlgNew(implPtr, (HWND)hWnd);
      return pWin;
   }
   int  OnRetrieve()
   {
      xml x;
            dw_list.Retrieve(x.GetXmlDoc().selectSingleNode("args"));
            dw_list.ResetUpdateStatus();
            dw_list.Redraw();
            return 1;
         }
         int OnAddRow(xdwgrid__ dw)
         {
            dw.InsertRow(0);
            return 1;
         }
         int OnDelRow(xdwgrid__ dw)
         {
            int row = dw.GetRow();
            if(row<1 || row > dw.GetRowCount()) return -1;
            dw.DeleteRow(row);
            return 1;
         }
         //命令发布函数
         int OnCmdDispatch(string comdid)
         {
            dw_list.AcceptText();
            xaserverarg__ arg = new xaserverarg__;
            arg.setNativePointer(arg.CreateInstance());
            arg = win__::GetParam();
            arg.AddArg("comdid",comdid);
            if (comdid=="ok")
            {
               xml__ x = new xml__;
               x.setNativePointer(xml__ ::CreateInstance());
               dw_list.DwUpdateAllTo(x.GetXmlDoc());
               arg.AddArg("xml",x.GetXml());
               CloseWindow();
            }
            else if(comdid=="close")
               CloseWindow();
            else if(comdid == "add")
               OnAddRow(dw_list);
            else if(comdid == "del")
               OnDelRow(dw_list);
            return 0;
         }
         //命令处理事件
         int OnXCommand(ref TXCommandEvent evt,int p)
         {
            return OnCmdDispatch(evt.pStrID);
         }
         int OnAttachEvent()
         {
            //绑定工具条点击事件
            AttachEvent("WM_XCOMMAND",OnXCommand);
         }
         int onload()
         {
            OnAttachEvent();
            dw_list = new xdwgrid__;
            dw_list.setNativePointer(GetControl("dw_list"));
            dw_list.SetDataObject(GetServerUrl(),"dev:sheet[SysUser.tpl/BindComputer]");
            dw_list.SetReadOnly(true);
            if(this.GetParam())
            {
               OnRetrieve();
            }
            return 1;
         }
      ]
   ]
]
      xaserverarg arg;
      arg = GetArg();
      if (arg.GetArgString(L"BindComputer"))
      {
         xstring sbys = arg.GetArgString(L"BindComputer");
         //alert(sbys);
         x.loadXML(sbys);
      }
      else
      {
         x.loadXML(L"<args></args>");
      }
      dw_list.Retrieve(x.selectSingleNode(L"args"));
      dw_list.ResetUpdateStatus();
      dw_list.Redraw();
      return 1;
   }
   int OnAddRow(xdwgrid dw)
   {
      dw.InsertRow(0);
      return 1;
   }
   int OnDelRow(xdwgrid dw)
   {
      int row = dw.GetRow();
      if (row<1 || row > dw.GetRowCount()) return -1;
      dw.DeleteRow(row);
      return 1;
   }
   //命令发布函数
   int OnCmdDispatch(xstring comdid)
   {
      dw_list.AcceptText();
      xaserverarg arg;
      arg = GetArg();
      arg.AddArg(L"comdid", comdid);
      if (comdid == L"ok")
      {
         xml x;
         dw_list.DwUpdateAllTo(x);
         arg.AddArg(L"xml", x.xml());
         CloseWindow();
      }
      else if (comdid == L"close")
         CloseWindow();
      else if (comdid == L"add")
         OnAddRow(dw_list);
      else if (comdid == L"del")
         OnDelRow(dw_list);
      return 0;
   }
   //命令处理事件
   int OnXCommand(TEvent* evt, LPARAM param)
   {
      return OnCmdDispatch(evt->xcommand.pStrID);
   }
   int OnAttachEvent()
   {
      //绑定工具条点击事件
      AttachEvent(L"WM_XCOMMAND", (FEvent)&BindComputerDlgNew::OnXCommand);
      return 1;
   }
   int onload()
   {
      SetArg();
      OnAttachEvent();
      dw_list = new xdwgrid;
      dw_list.setNativePointer(GetControl(L"dw_list"));
      dw_list.SetDataObject(GetServerUrl(), L"dev:sheet[SysUser.tpl/BindComputer]");
      dw_list.SetReadOnly(true);
      if (GetWinParam())
      {
         OnRetrieve();
      }
      return 1;
   }
};