LiFan
2025-05-12 63eebabbfee1bc84850b36967ecac5116a28b73f
jrj/project/business/BasicCode/QuickCode.cpp
@@ -3,12 +3,13 @@
#include <xcontrol/xdwgrid.hpp>
#include <wobject/xdouble.hpp>
#include <xcontrol/xlayersheet.hpp>
#include <wobject/xpage.hpp>
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
using xml = KXMLDOMDocument;
class __declspec(dllexport) QuickCode : public xwin
class __declspec(dllexport) QuickCode : public xframe
{
public:
   xdwgrid   dw_list;
@@ -22,19 +23,14 @@
   KXMLDOMDocument m_configDoc;
   xnode   m_agentNode;
public:
   QuickCode(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {}
   QuickCode(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
public:
   static QuickCode* CreateInstance(void* implPtr, void* hWnd)
   {
      QuickCode* pWin = new QuickCode(implPtr, (HWND)hWnd);
      return pWin;
   }
   int alert(xstring str)
   {
      //win::MessageBox(GetHWND(),str,L"提示:",0);
      TApp::alert(this, str);
      return 0;
   }
   int SetAgent()
   {
      xstring xfNodeAgentArea = L"agentarea";
@@ -46,7 +42,8 @@
      else
      {
         KXMLDOMElement xframeElement = GetElement();
         KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[1]/*");
         //alert(m_configDoc.xml());
         KXMLDOMElement agent = m_configDoc.selectSingleNode(L"Config/" + xfNodeAgentArea + L"[1]/*");
         if (agent)
         {
            xstring s = agent.xml();
@@ -143,7 +140,7 @@
            xml xi;
            xaserverarg argi;
            argi.setNativePointer(argi.CreateInstance());
            if (xurl::get(L"QuickCode/ExchangeRate/import", argi.GetString(), xi) != 1)
            {
               trace(xi.text());
@@ -183,8 +180,8 @@
         {
            xstring CategoryID = arg.GetArgString(L"CategoryID");
            xstring CName = arg.GetArgString(L"CName");
            dw_list.SetItemDisplayString(row, colname, CName);
            dw_list.SetItemString(row, colname, CategoryID);
            dw_list.SetItemDisplayString(row, colname.c_str(), CName);
            dw_list.SetItemString(row, colname.c_str(), CategoryID);
            dw_list.Redraw();
         }
      }
@@ -196,8 +193,8 @@
         {
            xstring OrgName = arg.GetArgString(L"OrgName");
            xstring OrgId = arg.GetArgString(L"OrgId");
            dw_list.SetItemDisplayString(row, colname, OrgName);
            dw_list.SetItemString(row, colname, OrgId);
            dw_list.SetItemDisplayString(row, colname.c_str(), OrgName);
            dw_list.SetItemString(row, colname.c_str(), OrgId);
            dw_list.Redraw();
         }
      }
@@ -210,8 +207,8 @@
            xstring sPersonID = arg.GetArgString(L"sPersonID");
            trace(sPersonID);
            xstring sPersonName = arg.GetArgString(L"sPersonName");
            dw_list.SetItemDisplayString(row, colname, sPersonName);
            dw_list.SetItemString(row, colname, sPersonID);
            dw_list.SetItemDisplayString(row, colname.c_str(), sPersonName);
            dw_list.SetItemString(row, colname.c_str(), sPersonID);
            dw_list.Redraw();
         }
      }
@@ -227,14 +224,14 @@
      //xstring str = hdr.data;
      xstring colname = hdr.colname;
      xstring str = dw_list.GetItemString(row, 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, value);
         dw_list.SetItemString(row, colname.c_str(), value);
         dw_list.Redraw();
      }
@@ -242,7 +239,7 @@
   }
   int ItemOutput()
   {
      xstring d = xaserver::GetCurrentDate();
      xstring d = publiccode::GetCurrentDate();
      d = d.left(10) + L"";
      dw_list.SaveAs(d);
      return 1;
@@ -292,10 +289,10 @@
      while (row > 0)
      {
         xstring tmp;
         if (dw_list.GetItemDisplayString(row, col))
            tmp = dw_list.GetItemDisplayString(row, col);
         if (dw_list.GetItemDisplayString(row, col.c_str()))
            tmp = dw_list.GetItemDisplayString(row, col.c_str());
         else
            tmp = dw_list.GetItemString(row, col);
            tmp = dw_list.GetItemString(row, col.c_str());
         str += tmp + L"\r\n";
         row = dw_list.GetNextSelectRow(row + 1);
      }
@@ -308,25 +305,25 @@
      DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
      int row = hdr.row;
      int m = win::CreatePopupMenu();
      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;
      win::AppendMenu(m, MF_STRING, 1, L"复制行");
      win::AppendMenu(m, MF_STRING, 101, L"复制列");
      win::AppendMenu(m, MF_SEPARATOR, -1, L"");
      win::AppendMenu(m, MF_STRING, 2, L"ȫѡ");
      win::AppendMenu(m, MF_SEPARATOR, -1, L"");
      win::AppendMenu(m, MF_STRING, 4, L"导出到Excel");
      win::AppendMenu(m, MF_SEPARATOR, -1, L"");
      win::AppendMenu(m, MF_STRING, 6, L"显示列设置");
      xrect xr;
      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;
      win::GetCursorPos(pt);
      int ret = win::TrackPopupMenu(m, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, GetHWND(), xr);
      GetCursorPos(pt);
      int ret = TrackPopupMenu(m, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, GetHWND(), &xr);
      //trace(ret);
      HCURSOR hCursor = xutil::SetCursorWait();
@@ -405,35 +402,24 @@
      {
         p += L"&";
         int i = 1;
         while (p.find(L"=L", 0) > 0)
         while (p.find(L"=", 0) > 0)
         {
            xstring name = p.mid(0, p.find(L"=L", 0));
            xstring value = p.mid(p.find(L"=L", 0) + 1, p.find(L"&", 0) - p.find(L"=L", 0) - 1);
            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 "";
      return L"";
   }
   int getURLParam()
   {
      if (GetWinParam())
      {
         xpage xp = new xpage;
         xp.setNativePointer(GetXPage());
         xpage xp = GetXPage();
         xstring aurl = xp.GetWkUrl();
         xaserverarg arg;
         if (aurl && aurl.find(L"native=true", 0) > 0)
         {
            int p = GetParam();
            arg;
            arg.setNativePointer(p);
         }
         else
         {
            arg = GetParam();
         }
         xaserverarg arg = GetArg();
         xstring config = arg.GetArgString(L"config");
         xml x;
@@ -454,10 +440,11 @@
   }
   int loaded()
   {
      getURLParam();
      KXMLDOMDocument    ee = m_configDoc;
      xstring id = m_id;
      var n = ee.selectSingleNode(L"//list/dwview[@type='dwgrid'][@id='" + id + L"']");
      auto n = ee.selectSingleNode(L"//list/dwview[@type='dwgrid'][@id='" + id + L"']");
      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();
@@ -474,7 +461,7 @@
      }
      else
      {
         var m = ee.selectSingleNode(L"//list");
         auto m = ee.selectSingleNode(L"//list");
         KXMLDOMElement e1 = m;
         //trace(e.xml());
         if (e1.selectSingleNode(L"@name")) dwname = e1.selectSingleNode(L"@name").text();
@@ -483,11 +470,10 @@
      }
      m_dbmap = dbmap;
      dw_list = new xdwgrid;
      dw_list.setNativePointer(GetControl(dwname));
      dw_list = GetControl(dwname);
      dw_list.openUrl(vface + L"/" + tpl);
      //dw_list.SetSelectionMode(4);                     
      return 1;
   }
   int Onital()
   {
@@ -495,7 +481,7 @@
      xml x1;
      xaserverarg arg1;
      arg1.setNativePointer(arg1.CreateInstance());
      arg1.AddArg(L"id", L"地区");
      if (xurl::get(L"/sale/data/QuickCode/entity/list", arg1.GetString(), x1) != 1)
      {
@@ -503,9 +489,9 @@
         return -1;
      }
      var list = x1.selectNodes(L"root/item");
      auto list = x1.selectNodes(L"root/item");
      int i;
      int s = list.length;
      int s = list.length();
      if (s > 0)
      {
         xstring str = L"<cellprop celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='保护' cellvisibleex='' cellvisible='' cellvalid='' cellinitial=''><edit edittype='ddlb' ddlbxml='&lt;data>";
@@ -530,7 +516,7 @@
      xml x2;
      xaserverarg arg2;
      arg2.setNativePointer(arg2.CreateInstance());
      arg2.AddArg(L"id", L"FND_Currency");
      if (xurl::get(L"/sale/data/QuickCode/entity/list", arg2.GetString(), x2) != 1)
      {
@@ -538,9 +524,9 @@
         return -1;
      }
      var list1 = x2.selectNodes(L"root/item");
      auto list1 = x2.selectNodes(L"root/item");
      int j;
      int s1 = list1.length;
      int s1 = list1.length();
      if (s1 > 0)
      {
         xstring str1 = L"<cellprop celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='保护' cellvisibleex='' cellvisible='' cellvalid='' cellinitial=''><edit edittype='ddlb' ddlbxml='&lt;data>";
@@ -565,7 +551,7 @@
      xml x3;
      xaserverarg arg3;
      arg3.setNativePointer(arg3.CreateInstance());
      arg3.AddArg(L"id", L"FND_Country");
      if (xurl::get(L"/sale/data/QuickCode/entity/list", arg3.GetString(), x3) != 1)
      {
@@ -573,9 +559,9 @@
         return -1;
      }
      var list2 = x3.selectNodes(L"root/item");
      auto list2 = x3.selectNodes(L"root/item");
      int k;
      int s2 = list2.length;
      int s2 = list2.length();
      if (s2 > 0)
      {
         xstring str2 = L"<cellprop celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='保护' cellvisibleex='' cellvisible='' cellvalid='' cellinitial=''><edit edittype='ddlb' ddlbxml='&lt;data>";
@@ -600,6 +586,7 @@
   }
   int onload()
   {
      SetArg();
      m_config = L"QuickCode.config";
      m_agent = L"";