From 06b2164e72a30ada44d933b008f701904acdb982 Mon Sep 17 00:00:00 2001
From: xj qian <qianxj15@sina.com>
Date: 星期二, 09 七月 2024 15:54:10 +0800
Subject: [PATCH] update document  datetimepick

---
 jrj/project/tradedocument/DocFileSaveDlg.cpp |  235 +++++++++++
 jrj/xframe/xcontrol/xlistview.hpp            |    5 
 jrj/xframe/xcontrol/xdatetimepick.hpp        |   58 ++
 jrj/project/tradedocument/DocSelectDlg.cpp   |  134 ++++++
 jrj/ext-jrj/ext-jrj.vcxproj                  |    5 
 jrj/project/tradedocument/TDocumentWin.cpp   |  494 ++++++++++++++++++++++++
 jrj/xframe/kobject/kxml.hpp                  |    4 
 jrj/ext-jrj/ext-jrj.vcxproj.filters          |   18 
 jrj/project/tradedocument/HelpDocWin.cpp     |  235 +++++++++++
 9 files changed, 1,187 insertions(+), 1 deletions(-)

diff --git a/jrj/ext-jrj/ext-jrj.vcxproj b/jrj/ext-jrj/ext-jrj.vcxproj
index 61bf544..29a0f16 100644
--- a/jrj/ext-jrj/ext-jrj.vcxproj
+++ b/jrj/ext-jrj/ext-jrj.vcxproj
@@ -226,6 +226,7 @@
     <ClInclude Include="..\xframe\xcontrol\xcell.hpp" />
     <ClInclude Include="..\xframe\xcontrol\xcheckbox.hpp" />
     <ClInclude Include="..\xframe\xcontrol\xcombobox.hpp" />
+    <ClInclude Include="..\xframe\xcontrol\xdatetimepick.hpp" />
     <ClInclude Include="..\xframe\xcontrol\xdwgrid.hpp" />
     <ClInclude Include="..\xframe\xcontrol\xdwpages.hpp" />
     <ClInclude Include="..\xframe\xcontrol\xdwtable.hpp" />
@@ -541,6 +542,10 @@
     </ClCompile>
     <ClCompile Include="..\project\start.vframe.vbusiness.cpp" />
     <ClCompile Include="..\project\total3\ViewTotalWin.cpp" />
+    <ClCompile Include="..\project\tradedocument\DocFileSaveDlg.cpp" />
+    <ClCompile Include="..\project\tradedocument\DocSelectDlg.cpp" />
+    <ClCompile Include="..\project\tradedocument\HelpDocWin.cpp" />
+    <ClCompile Include="..\project\tradedocument\TDocumentWin.cpp" />
     <ClCompile Include="..\project\viewobject\view.base.hpp" />
     <ClCompile Include="..\project\vindexform.cpp" />
     <ClCompile Include="..\project\vindexformex.cpp" />
diff --git a/jrj/ext-jrj/ext-jrj.vcxproj.filters b/jrj/ext-jrj/ext-jrj.vcxproj.filters
index e72e70b..e057028 100644
--- a/jrj/ext-jrj/ext-jrj.vcxproj.filters
+++ b/jrj/ext-jrj/ext-jrj.vcxproj.filters
@@ -100,6 +100,9 @@
     <Filter Include="vbusiness\analysis">
       <UniqueIdentifier>{27c3e1cb-c8de-4a10-8a61-bacae62112e3}</UniqueIdentifier>
     </Filter>
+    <Filter Include="vbusiness\tradedoucment">
+      <UniqueIdentifier>{6a683d68-f569-41c4-a72d-4acb7b71ab4e}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="framework.h">
@@ -343,6 +346,9 @@
       <Filter>xframe\kobject</Filter>
     </ClInclude>
     <ClInclude Include="..\xframe\xcontrol\xcheckbox.hpp">
+      <Filter>xframe\xcontrol</Filter>
+    </ClInclude>
+    <ClInclude Include="..\xframe\xcontrol\xdatetimepick.hpp">
       <Filter>xframe\xcontrol</Filter>
     </ClInclude>
   </ItemGroup>
@@ -659,5 +665,17 @@
     <ClCompile Include="..\project\total3\ViewTotalWin.cpp">
       <Filter>vbusiness\total</Filter>
     </ClCompile>
+    <ClCompile Include="..\project\tradedocument\TDocumentWin.cpp">
+      <Filter>vbusiness\tradedoucment</Filter>
+    </ClCompile>
+    <ClCompile Include="..\project\tradedocument\HelpDocWin.cpp">
+      <Filter>vbusiness\tradedoucment</Filter>
+    </ClCompile>
+    <ClCompile Include="..\project\tradedocument\DocFileSaveDlg.cpp">
+      <Filter>vbusiness\tradedoucment</Filter>
+    </ClCompile>
+    <ClCompile Include="..\project\tradedocument\DocSelectDlg.cpp">
+      <Filter>vbusiness\tradedoucment</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>
\ No newline at end of file
diff --git a/jrj/project/tradedocument/DocFileSaveDlg.cpp b/jrj/project/tradedocument/DocFileSaveDlg.cpp
new file mode 100644
index 0000000..5e13743
--- /dev/null
+++ b/jrj/project/tradedocument/DocFileSaveDlg.cpp
@@ -0,0 +1,235 @@
+#include <wobject/xstring.hpp>
+#include <xcontrol/xtreeview.hpp>
+#include <xcontrol/xdwgrid.hpp>
+#include <xcontrol/xlayersheet.hpp>
+#include <xcontrol/xcell.hpp>
+#include <xcontrol/xlistview.hpp>
+
+#include "vbusiness/vframe/maint.vframe.vbusiness.hpp"
+#include "viewobject/view.base.hpp"
+
+using xml = KXMLDOMDocument;
+class __declspec(dllexport) HelpDocWin : public xframe
+{
+public:
+	HelpDocWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
+public:
+	static HelpDocWin* CreateInstance(void* implPtr, void* hWnd)
+	{
+		return  new HelpDocWin(implPtr, (HWND)hWnd);
+	}
+
+public:
+	//xdwgrid	dw_list;
+	xlistview  lv_view;
+	xnode	m_agentNode;	//Agent Condition
+	int columnCount;
+
+	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;
+	}
+
+	//焦点激活处理函数
+	int OnSetFocus(TEvent* evt,LPARAM param)
+	{
+		//重置工具条
+		SetAgent();
+		return 1;
+	}
+
+	int OnListViewDoubleClicked(TEvent* evt,LPARAM param)
+	{
+		//重置工具条
+		//SetAgent();
+		OnDocumentOpen();
+		CloseWindow();
+		return 1;
+	}
+
+	int OnDocumentOpen()
+	{
+		int  LVNI_ALL = 0x0000;
+		int  LVNI_FOCUSED = 0x0001;
+		int  LVNI_SELECTED = 0x0002;
+		int  LVNI_CUT = 0x0004;
+		int  LVNI_DROPHILITED = 0x0008;
+
+		int nItem = lv_view.GetNextItem( -1, LVNI_FOCUSED);
+		if (nItem < 0) return 1;
+
+		int LVIF_PARAM = 0x0004;
+
+		lvitem lvItem;
+		lvItem.iItem = nItem;
+		lvItem.iSubItem = 0;
+		lvItem.mask = LVIF_PARAM;
+
+		lv_view.GetItem( lvItem);
+		KXMLDOMElement ele = lvItem.lParam;
+
+		xstring src = ele.getAttribute(L"url");
+		xstring file = L"";
+		if (src.find(L"/file/") > 0) file = src.mid(src.find(L"/file/") + 6, 9999);
+		if (file.find(L"/file/") >= 0) file = file.mid(file.find(L"/file/") + 6, 9999);
+		if (file.find(L"file/") >= 0) file = file.mid(file.find(L"file/") + 5, 9999);
+		if (file == L"") return 1;
+		//alert(file);
+		xstring name = ele.getAttribute(L"caption");
+		/*
+		const xstring d = m_Html.GetData(p.object);
+		if(d == L"") return -1;
+		xstring file = d.mid(0, d.find(L"|##@@|",0));
+		xstring name = d.mid(d.find(L"|##@@|",0)+6, d.length());
+		*/
+
+		xaserver::CreateDirectory(L"C:/Temp");
+		xstring str = file.left(2);
+		xstring ext = L"";
+		if (name.find(L".") >= 0) ext = name.mid(name.find(L"."), name.length());
+		xstring sfile = file;// file.left(file.length() - 4);
+		//trace(L"--"+ext +L" " + L"/business/attachment/"+str+L"/"+ file);
+		//int openRet = xaserver::DownLoadFile(GetServerUrl(),L"/business/attachment/"+str+L"/"+ file,name,L"C:/Temp/"+name);
+		int openRet = xaserver::DownLoadFile(GetServerUrl(), L"/business/attachment/" + str + L"/" + file + L".jpg", L"", L"C:/Temp/" + sfile + ext);
+
+		//alert(L"/business/attachment/"+str+L"/"+ file+L".jpg");
+		if (openRet < 0)
+		{
+			alert(L"文件打开失败1!");
+			return -1;
+		}
+		//openRet = win32::ShellExecute(0,L"open",L"C:/Temp/"+name,L"",L"",5);	
+		openRet = ShellExecuteW(0, L"open", L"C:/Temp/" + sfile + ext, L"", L"", 5);
+		if (openRet < 32)
+		{
+			alert(L"文件打开失败2!");
+			return -1;
+		}
+
+		return -1;
+	}
+
+
+	//命令发布函数
+	int OnCmdDispatch(xstring comdid)
+	{
+		return 0;
+	}
+
+	//命令处理事件
+	int OnXCommand(TEvent* evt, int param)
+	{
+		return OnCmdDispatch(evt->xcommand.pStrID);
+	}
+
+	int OnAttachEvent()
+	{
+		//绑定工具条点击事件
+		AttachEvent(L"WM_XCOMMAND", (FEvent)&HelpDocWin::OnXCommand);
+		//获取焦点事件,用于重置工具条
+		AttachEvent(L"WM_SETFOCUS", (FEvent)&HelpDocWin::OnSetFocus);
+		return 1;
+	}
+
+	/*
+	int  OnRetrieve()
+	{
+		xml x = new xml;
+		x.setNativePointer(xml::CreateInstance());
+		xaserverarg arg = new xaserverarg;
+		arg.setNativePointer(arg.CreateInstance());
+		arg.AddArg(L"xxx",L"xxx");
+		if (getUrl(L"",arg.GetString(),x)!=1)
+		{
+			trace(x.GetXmlDoc().text);
+			return -1;
+		}else
+		{
+			//dw_list.Retrieve(x);
+			//dw_list.Redraw();
+		}
+		return 1;
+	}
+	*/
+
+	int SetListViewHeaderColumn(xstring Url)
+	{
+		const int LVCFMT_LEFT = 0;
+		for (int i = 0; i < 3; i++)  lv_view.DeleteColumn( 1);
+		//if(Url==L"")
+		//{
+		lv_view.InsertColumn( 0, L"创建日期", LVCFMT_LEFT, 80, 0);
+		lv_view.InsertColumn( 0, L"创建人员", LVCFMT_LEFT, 80, 0);
+		lv_view.InsertColumn( 0, L"名称", 0, 180, 0);
+		columnCount = 3;
+		//}
+		return 1;
+	}
+
+	int Retrieve()
+	{
+		xstring src = L"object/knowledge";
+		//xstring src=L"data/SettleExchange";
+		xml x = ViewObject::RetrieveData(L"/sale/data/TDocument3/FolderListHelp");
+		if (x)
+		{
+			//alert(x.GetXml());
+			KXMLDOMElement ele = x.documentElement();
+			KXMLDOMNodeList nlist = ele.selectNodes(L"*");
+			int s = nlist.length();
+			if (s > 0)
+			{
+				for (int i = 0; i < s; i++)
+				{
+					KXMLDOMElement e = nlist.item(i);
+					xstring name = e.getAttribute(L"caption");
+					int nItem = lv_view.InsertItemEx( 0, name, 14, e);
+
+					lv_view.SetItemText( nItem, 1, e.getAttribute(L"Creator"));
+					lv_view.SetItemText( nItem, 2, e.getAttribute(L"CreateDate"));
+
+				}
+			}
+		}
+		return 1;
+	}
+
+	int onload()
+	{
+		//dw_list = GetControl(L"xxx");
+		//dw_list.openUrl(L"xxx");
+		lv_view = GetControl(L"lv_view");
+
+		columnCount = 0;
+		SetListViewHeaderColumn(L"");
+
+		AttachEvent(L"lv_view", L"NM_DBLCLK", (FEvent)&HelpDocWin::OnListViewDoubleClicked);
+
+		Retrieve();
+
+		return 1;
+	}
+
+	int onloaded()
+	{
+		SetAgent();
+
+		return 1;
+	}
+};
\ No newline at end of file
diff --git a/jrj/project/tradedocument/DocSelectDlg.cpp b/jrj/project/tradedocument/DocSelectDlg.cpp
new file mode 100644
index 0000000..e656d33
--- /dev/null
+++ b/jrj/project/tradedocument/DocSelectDlg.cpp
@@ -0,0 +1,134 @@
+#include <wobject/xstring.hpp>
+#include <xcontrol/xtreeview.hpp>
+#include <xcontrol/xdwgrid.hpp>
+#include <xcontrol/xlayersheet.hpp>
+#include <xcontrol/xcell.hpp>
+#include <xcontrol/xlistview.hpp>
+
+#include "vbusiness/vframe/maint.vframe.vbusiness.hpp"
+#include "viewobject/view.base.hpp"
+
+using xml = KXMLDOMDocument;
+class __declspec(dllexport) DocFileSaveDlg : public xframe
+{
+public:
+	DocFileSaveDlg(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
+public:
+	static DocFileSaveDlg* CreateInstance(void* implPtr, void* hWnd)
+	{
+		return  new DocFileSaveDlg(implPtr, (HWND)hWnd);
+	}
+
+
+	xlistview  lv_view;
+	xnode	m_agentNode;	//Agent Condition
+	int columnCount;
+
+	//焦点激活处理函数
+	int OnSetFocus(TEvent* evt, LPARAM param)
+	{
+		//重置工具条
+		return 1;
+	}
+
+
+	//命令发布函数
+	int OnCmdDispatch(string comdid)
+	{
+		if (comdid == L"xmOk")
+		{
+			string filename = xcontrol(GetControl(L"filename")).GetText();
+			if (filename == L"") return 1;
+			xaserverarg arg = GetArg();
+			if (!arg) return 1;
+			arg.AddArg(L"result", L"ok");
+			arg.AddArg(L"filename", filename);
+			CloseWindow();
+			return 1;
+		}
+		else if (comdid == L"xmCancel")
+		{
+			CloseWindow();
+			return 1;
+		}
+		return 0;
+	}
+
+	//命令处理事件
+	int OnXCommand(TEvent* evt, int param)
+	{
+		return OnCmdDispatch(evt->xcommand.pStrID);
+	}
+
+	int OnAttachEvent()
+	{
+		//绑定工具条点击事件
+		AttachEvent(L"WM_XCOMMAND", (FEvent)& DocFileSaveDlg::OnXCommand);
+		//获取焦点事件,用于重置工具条
+		AttachEvent(L"WM_SETFOCUS", (FEvent)&DocFileSaveDlg::OnSetFocus);
+
+		return 1;
+	}
+
+
+	int SetListViewHeaderColumn(string Url)
+	{
+		const int LVCFMT_LEFT = 0;
+		for (int i = 0; i < 3; i++)  lv_view.DeleteColumn( 1);
+		lv_view.InsertColumn( 0, L"创建人员", LVCFMT_LEFT, 80, 0);
+		lv_view.InsertColumn( 0, L"创建日期", LVCFMT_LEFT, 80, 0);
+		lv_view.InsertColumn( 0, L"名称", 0, 120, 0);
+		columnCount = 3;
+		return 1;
+	}
+
+	int Retrieve(string src)
+	{
+		xml x = ViewObject::RetrieveData(L"/sale/data/TDocument3/folder/list", L"src", src);
+		if (x)
+		{
+			KXMLDOMNodeList nlist = x.documentElement().selectNodes(L"*");
+			int s = nlist.length();
+			if (s > 0)
+			{
+				for (int i = 0; i < s; i++)
+				{
+					KXMLDOMElement e = nlist.item(i);
+					string name = e.getAttribute(L"caption");
+					int nItem = lv_view.InsertItemEx(0, name, 23, e);
+
+					lv_view.SetItemText(nItem, 1, e.getAttribute(L"Creator"));
+					lv_view.SetItemText(nItem, 2, e.getAttribute(L"CreateDate"));
+				}
+			}
+		}
+		return 1;
+	}
+
+	int onload()
+	{
+		SetArg();
+		lv_view = GetControl(L"lv_view");
+		//lv_list.SetdwStyle0);
+
+		columnCount = 0;
+		SetListViewHeaderColumn(L"");
+		OnAttachEvent();
+
+		if (GetWinParam())
+		{
+			xaserverarg arg = GetArg();
+			string src = arg.GetArgString(L"src");
+			Retrieve(src);
+		}
+
+		return 1;
+	}
+
+	int onloaded()
+	{
+		//SetAgent();			
+
+		return 1;
+	}
+};
\ No newline at end of file
diff --git a/jrj/project/tradedocument/HelpDocWin.cpp b/jrj/project/tradedocument/HelpDocWin.cpp
new file mode 100644
index 0000000..5e13743
--- /dev/null
+++ b/jrj/project/tradedocument/HelpDocWin.cpp
@@ -0,0 +1,235 @@
+#include <wobject/xstring.hpp>
+#include <xcontrol/xtreeview.hpp>
+#include <xcontrol/xdwgrid.hpp>
+#include <xcontrol/xlayersheet.hpp>
+#include <xcontrol/xcell.hpp>
+#include <xcontrol/xlistview.hpp>
+
+#include "vbusiness/vframe/maint.vframe.vbusiness.hpp"
+#include "viewobject/view.base.hpp"
+
+using xml = KXMLDOMDocument;
+class __declspec(dllexport) HelpDocWin : public xframe
+{
+public:
+	HelpDocWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
+public:
+	static HelpDocWin* CreateInstance(void* implPtr, void* hWnd)
+	{
+		return  new HelpDocWin(implPtr, (HWND)hWnd);
+	}
+
+public:
+	//xdwgrid	dw_list;
+	xlistview  lv_view;
+	xnode	m_agentNode;	//Agent Condition
+	int columnCount;
+
+	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;
+	}
+
+	//焦点激活处理函数
+	int OnSetFocus(TEvent* evt,LPARAM param)
+	{
+		//重置工具条
+		SetAgent();
+		return 1;
+	}
+
+	int OnListViewDoubleClicked(TEvent* evt,LPARAM param)
+	{
+		//重置工具条
+		//SetAgent();
+		OnDocumentOpen();
+		CloseWindow();
+		return 1;
+	}
+
+	int OnDocumentOpen()
+	{
+		int  LVNI_ALL = 0x0000;
+		int  LVNI_FOCUSED = 0x0001;
+		int  LVNI_SELECTED = 0x0002;
+		int  LVNI_CUT = 0x0004;
+		int  LVNI_DROPHILITED = 0x0008;
+
+		int nItem = lv_view.GetNextItem( -1, LVNI_FOCUSED);
+		if (nItem < 0) return 1;
+
+		int LVIF_PARAM = 0x0004;
+
+		lvitem lvItem;
+		lvItem.iItem = nItem;
+		lvItem.iSubItem = 0;
+		lvItem.mask = LVIF_PARAM;
+
+		lv_view.GetItem( lvItem);
+		KXMLDOMElement ele = lvItem.lParam;
+
+		xstring src = ele.getAttribute(L"url");
+		xstring file = L"";
+		if (src.find(L"/file/") > 0) file = src.mid(src.find(L"/file/") + 6, 9999);
+		if (file.find(L"/file/") >= 0) file = file.mid(file.find(L"/file/") + 6, 9999);
+		if (file.find(L"file/") >= 0) file = file.mid(file.find(L"file/") + 5, 9999);
+		if (file == L"") return 1;
+		//alert(file);
+		xstring name = ele.getAttribute(L"caption");
+		/*
+		const xstring d = m_Html.GetData(p.object);
+		if(d == L"") return -1;
+		xstring file = d.mid(0, d.find(L"|##@@|",0));
+		xstring name = d.mid(d.find(L"|##@@|",0)+6, d.length());
+		*/
+
+		xaserver::CreateDirectory(L"C:/Temp");
+		xstring str = file.left(2);
+		xstring ext = L"";
+		if (name.find(L".") >= 0) ext = name.mid(name.find(L"."), name.length());
+		xstring sfile = file;// file.left(file.length() - 4);
+		//trace(L"--"+ext +L" " + L"/business/attachment/"+str+L"/"+ file);
+		//int openRet = xaserver::DownLoadFile(GetServerUrl(),L"/business/attachment/"+str+L"/"+ file,name,L"C:/Temp/"+name);
+		int openRet = xaserver::DownLoadFile(GetServerUrl(), L"/business/attachment/" + str + L"/" + file + L".jpg", L"", L"C:/Temp/" + sfile + ext);
+
+		//alert(L"/business/attachment/"+str+L"/"+ file+L".jpg");
+		if (openRet < 0)
+		{
+			alert(L"文件打开失败1!");
+			return -1;
+		}
+		//openRet = win32::ShellExecute(0,L"open",L"C:/Temp/"+name,L"",L"",5);	
+		openRet = ShellExecuteW(0, L"open", L"C:/Temp/" + sfile + ext, L"", L"", 5);
+		if (openRet < 32)
+		{
+			alert(L"文件打开失败2!");
+			return -1;
+		}
+
+		return -1;
+	}
+
+
+	//命令发布函数
+	int OnCmdDispatch(xstring comdid)
+	{
+		return 0;
+	}
+
+	//命令处理事件
+	int OnXCommand(TEvent* evt, int param)
+	{
+		return OnCmdDispatch(evt->xcommand.pStrID);
+	}
+
+	int OnAttachEvent()
+	{
+		//绑定工具条点击事件
+		AttachEvent(L"WM_XCOMMAND", (FEvent)&HelpDocWin::OnXCommand);
+		//获取焦点事件,用于重置工具条
+		AttachEvent(L"WM_SETFOCUS", (FEvent)&HelpDocWin::OnSetFocus);
+		return 1;
+	}
+
+	/*
+	int  OnRetrieve()
+	{
+		xml x = new xml;
+		x.setNativePointer(xml::CreateInstance());
+		xaserverarg arg = new xaserverarg;
+		arg.setNativePointer(arg.CreateInstance());
+		arg.AddArg(L"xxx",L"xxx");
+		if (getUrl(L"",arg.GetString(),x)!=1)
+		{
+			trace(x.GetXmlDoc().text);
+			return -1;
+		}else
+		{
+			//dw_list.Retrieve(x);
+			//dw_list.Redraw();
+		}
+		return 1;
+	}
+	*/
+
+	int SetListViewHeaderColumn(xstring Url)
+	{
+		const int LVCFMT_LEFT = 0;
+		for (int i = 0; i < 3; i++)  lv_view.DeleteColumn( 1);
+		//if(Url==L"")
+		//{
+		lv_view.InsertColumn( 0, L"创建日期", LVCFMT_LEFT, 80, 0);
+		lv_view.InsertColumn( 0, L"创建人员", LVCFMT_LEFT, 80, 0);
+		lv_view.InsertColumn( 0, L"名称", 0, 180, 0);
+		columnCount = 3;
+		//}
+		return 1;
+	}
+
+	int Retrieve()
+	{
+		xstring src = L"object/knowledge";
+		//xstring src=L"data/SettleExchange";
+		xml x = ViewObject::RetrieveData(L"/sale/data/TDocument3/FolderListHelp");
+		if (x)
+		{
+			//alert(x.GetXml());
+			KXMLDOMElement ele = x.documentElement();
+			KXMLDOMNodeList nlist = ele.selectNodes(L"*");
+			int s = nlist.length();
+			if (s > 0)
+			{
+				for (int i = 0; i < s; i++)
+				{
+					KXMLDOMElement e = nlist.item(i);
+					xstring name = e.getAttribute(L"caption");
+					int nItem = lv_view.InsertItemEx( 0, name, 14, e);
+
+					lv_view.SetItemText( nItem, 1, e.getAttribute(L"Creator"));
+					lv_view.SetItemText( nItem, 2, e.getAttribute(L"CreateDate"));
+
+				}
+			}
+		}
+		return 1;
+	}
+
+	int onload()
+	{
+		//dw_list = GetControl(L"xxx");
+		//dw_list.openUrl(L"xxx");
+		lv_view = GetControl(L"lv_view");
+
+		columnCount = 0;
+		SetListViewHeaderColumn(L"");
+
+		AttachEvent(L"lv_view", L"NM_DBLCLK", (FEvent)&HelpDocWin::OnListViewDoubleClicked);
+
+		Retrieve();
+
+		return 1;
+	}
+
+	int onloaded()
+	{
+		SetAgent();
+
+		return 1;
+	}
+};
\ No newline at end of file
diff --git a/jrj/project/tradedocument/TDocumentWin.cpp b/jrj/project/tradedocument/TDocumentWin.cpp
new file mode 100644
index 0000000..df1a1c6
--- /dev/null
+++ b/jrj/project/tradedocument/TDocumentWin.cpp
@@ -0,0 +1,494 @@
+#include <wobject/xstring.hpp>
+#include <xcontrol/xtreeview.hpp>
+#include <xcontrol/xdwgrid.hpp>
+#include <xcontrol/xlayersheet.hpp>
+#include <xcontrol/xcell.hpp>
+#include <xcontrol/xlistview.hpp>
+
+#include "vbusiness/vframe/maint.vframe.vbusiness.hpp"
+#include "viewobject/view.base.hpp"
+
+using xml = KXMLDOMDocument;
+class __declspec(dllexport) TDocumentWin : public xframe
+{
+public:
+	TDocumentWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
+public:
+	static TDocumentWin* CreateInstance(void* implPtr, void* hWnd)
+	{
+		return  new TDocumentWin(implPtr, (HWND)hWnd);
+	}
+
+public:
+	//xdwgrid	dw_list;
+	xtreeview tv_folder;
+	xlistview  lv_view;
+	xnode	m_agentNode;	//Agent Condition
+	int columnCount;
+
+	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;
+	}
+
+	//焦点激活处理函数
+	int OnSetFocus(TEvent* evt, LPARAM param)
+	{
+		//重置工具条
+		SetAgent();
+		return 1;
+	}
+
+	int OnListViewDoubleClicked(TEvent* evt,LPARAM param)
+	{
+		//重置工具条
+		//SetAgent();
+		return OnDocumentOpen();
+	}
+
+	int OnDocumentOpen()
+	{
+		int  LVNI_ALL = 0x0000;
+		int  LVNI_FOCUSED = 0x0001;
+		int  LVNI_SELECTED = 0x0002;
+		int  LVNI_CUT = 0x0004;
+		int  LVNI_DROPHILITED = 0x0008;
+
+		int nItem = lv_view.GetNextItem(-1, LVNI_FOCUSED);
+		if (nItem < 0) return 1;
+
+		int LVIF_PARAM = 0x0004;
+
+		lvitem lvItem;
+		lvItem.iItem = nItem;
+		lvItem.iSubItem = 0;
+		lvItem.mask = LVIF_PARAM;
+
+		lv_view.GetItem( lvItem);
+		KXMLDOMElement ele =lvItem.lParam;
+
+		xstring src = ele.getAttribute(L"url");
+		xstring file = L"";
+		if (src.find(L"/file/") > 0) file = src.mid(src.find(L"/file/") + 6, 9999);
+		if (file.find(L"/file/") >= 0) file = file.mid(file.find(L"/file/") + 6, 9999);
+		if (file.find(L"file/") >= 0) file = file.mid(file.find(L"file/") + 5, 9999);
+		if (file == L"") return 1;
+		//alert(file);
+		xstring name = ele.getAttribute(L"caption");
+		/*
+		const xstring d = m_Html.GetData(p.object);
+		if(d == L"") return -1;
+		xstring file = d.mid(0, d.find(L"|##@@|",0));
+		xstring name = d.mid(d.find(L"|##@@|",0)+6, d.length());
+		*/
+
+		xaserver::CreateDirectory(L"C:/Temp");
+		xstring str = file.left(2);
+		xstring ext = L"";
+		if (name.find(L".") >= 0) ext = name.mid(name.find(L"."), name.length());
+		xstring sfile = file;// file.left(file.length() - 4);
+		//trace(L"--"+ext +L" " + L"/business/attachment/"+str+L"/"+ file);
+		//int openRet = xaserver::DownLoadFile(GetServerUrl(),L"/business/attachment/"+str+L"/"+ file,name,L"C:/Temp/"+name);
+		int openRet = xaserver::DownLoadFile(GetServerUrl(), L"/business/attachment/" + str + L"/" + file + L".jpg", L"", L"C:/Temp/" + sfile + ext);
+
+		//alert(L"/business/attachment/"+str+L"/"+ file+L".jpg");
+		if (openRet < 0)
+		{
+			alert(L"文件打开失败1!");
+			return -1;
+		}
+		//openRet =ShellExecute(0,L"open",L"C:/Temp/"+name,L"",L"",5);	
+		openRet =ShellExecuteW(0, L"open", L"C:/Temp/" + sfile + ext, L"", L"", 5);
+		if (openRet < 32)
+		{
+			alert(L"文件打开失败2!");
+			return -1;
+		}
+
+		return -1;
+	}
+
+	int OnAddAttachment()
+	{
+		xstring sguid = publiccode::GetGuid();
+		xstring sname = sguid;
+		xstring str = sname.mid(0, 2);
+		str = str.toUpper();
+		xstring suri = L"attachment" + str;
+		xstring ret = xaserver::UploadFile(suri, sname + L".jpg", GetHWND(), L"", false);
+		if (ret == L"-1")
+		{
+			alert(L"上传的文件没选择!");
+			return 0;
+		}
+		else
+		{
+			while (ret.find(L"\\", 0) >= 0)
+				ret = ret.mid(ret.find(L"\\", 0) + 1, 9999);
+
+			HTREEITEM h = tv_folder.GetSelectedItem();
+			KXMLDOMElement ele = tv_folder.GetItemData(h);
+			xstring myurl = ele.getAttribute(L"url");
+			//alert(myurl);
+
+			xml x ;
+			xaserverarg args;
+			args.setNativePointer(args.CreateInstance());
+			args.AddArg(L"myurl", myurl);
+			args.AddArg(L"name", ret);
+			args.AddArg(L"filepath", sname);
+			args.AddArg(L"fileext", L"");
+			args.AddArg(L"filesource", ret);
+
+			xml x1 = ViewObject::RetrieveData(L"/sale/data/TDocument3/attachment/GetFileFormat", L"Name", ret);
+			KXMLDOMNodeList items = x1.selectNodes(L"data/Item");
+			KXMLDOMNode t = items.item(0);
+			xstring FileFormat = L"";
+			if (t.selectSingleNode(L"FileFormat"))FileFormat = t.selectSingleNode(L"FileFormat").text();
+			if (FileFormat != L"pdf" && FileFormat != L"PDF" && FileFormat != L"mp4" && FileFormat != L"avi" && FileFormat != L"wmv" && FileFormat != L"mpg"
+				&& FileFormat != L"mpeg" && FileFormat != L"mov" && FileFormat != L"rm" && FileFormat != L"ram" && FileFormat != L"swf" && FileFormat != L"flv")
+			{
+				alert(L"文件格式错误,请上传PDF文档或者视频!");
+				return 0;
+			}
+
+			if (xurl::get(L"/sale/data/TDocument3/attachment/add", args.GetString(), x) != 1)
+			{
+				alert(L"保存出错了!");
+				return 0;
+			}
+			else
+			{
+				alert(x.text());
+				//OnRetrieve();
+			}
+		}
+		return 0;
+	}
+
+	int OnDeleteFile()
+	{
+		int  LVNI_ALL = 0x0000;
+		int  LVNI_FOCUSED = 0x0001;
+		int  LVNI_SELECTED = 0x0002;
+		int  LVNI_CUT = 0x0004;
+		int  LVNI_DROPHILITED = 0x0008;
+
+		int nItem = lv_view.GetNextItem( -1, LVNI_FOCUSED);
+		if (nItem < 0) return 1;
+
+		int LVIF_PARAM = 0x0004;
+
+		lvitem lvItem;
+		lvItem.iItem = nItem;
+		lvItem.iSubItem = 0;
+		lvItem.mask = LVIF_PARAM;
+
+		lv_view.GetItem( lvItem);
+		KXMLDOMElement ele =lvItem.lParam;
+
+		xstring src = ele.getAttribute(L"url");
+		xstring file = L"";
+		if (src.find(L"/file/") > 0) file = src.mid(src.find(L"/file/") + 6, 9999);
+		if (file.find(L"/file/") >= 0) file = file.mid(file.find(L"/file/") + 6, 9999);
+		if (file.find(L"file/") >= 0) file = file.mid(file.find(L"file/") + 5, 9999);
+		if (file == L"") return 1;
+
+		xstring name = ele.getAttribute(L"caption");
+		if (MessageBox(GetHWND(), L"确定要删除文件" + name + L"?", L"提示", 1) == 2)
+			return 0;
+
+		xaserverarg arg;
+		arg.AddArg(L"filepath", file);
+		xml x;
+		if (xurl::get(L"/sale/data/TDocument3/file/delete", arg.GetString(), x) != 1)
+		{
+			alert(L"删除出错了!");
+			return 1;
+		}
+		else
+		{
+			//alert(x.text);
+			lv_view.DeleteItem(nItem);
+		}
+
+		return 1;
+	}
+
+	//命令发布函数
+	int OnCmdDispatch(xstring comdid)
+	{
+		xstring  userno = publiccode::GetUser().no;
+		HTREEITEM h = tv_folder.GetSelectedItem();
+		KXMLDOMElement ele = tv_folder.GetItemData(h);
+		xstring caption = ele.getAttribute(L"caption");
+
+		if (comdid == L"xmUpload")
+		{
+
+			/*	if(caption ==L"采购部" || caption ==L"跟单部" || caption ==L"业务部" ||caption ==L"公司共享" )
+				{
+
+					if(userno ==L"admin" || userno ==L"00301" || userno ==L"00601" || userno ==L"00701" )
+					{
+						OnAddAttachment();
+					}
+				}*/
+				/*	if(caption ==L"业务部优秀案例" || caption ==L"采购部优秀案例" )
+					{*/
+
+			if (userno == L"admin" || userno == L"00301" || userno == L"00601" || userno == L"00701" || userno == L"00102" || userno == L"00201")
+			{
+				OnAddAttachment();
+			}
+			//}
+			return 1;
+		}
+		if (comdid == L"xmOpen")
+		{
+			return OnDocumentOpen();
+		}
+		if (comdid == L"xmDelete")
+		{
+			/*if(caption ==L"采购部" || caption ==L"跟单部" || caption ==L"外销部" ||caption ==L"公司共享" )
+			{
+
+				if(userno ==L"admin" || userno ==L"00301" || userno ==L"00601" || userno ==L"00701" )
+				{
+					OnDeleteFile();
+				}
+			}
+			if(caption ==L"业务部优秀案例" || caption ==L"采购部优秀案例" )
+			{*/
+
+
+			if (userno == L"admin" || userno == L"00301" || userno == L"00601" || userno == L"00701" || userno == L"00102" || userno == L"00201")
+			{
+				OnDeleteFile();
+			}
+			//}
+			return 1;
+		}
+		if (comdid == L"xmSearch")
+		{
+			OnRetrieve();
+			return 1;
+		}
+
+		return 0;
+	}
+
+	int OnRetrieve()
+	{
+		xstring urlEx = L"";
+		xcontrol xc = GetControl(L"frame:sle_search");
+		xstring Search = xc.GetText();
+		HTREEITEM h = tv_folder.GetSelectedItem();
+		KXMLDOMElement ele = tv_folder.GetItemData(h);
+		urlEx = ele.getAttribute(L"url");
+
+		trace(Search + L"******" + urlEx);
+		if (urlEx == L"")
+		{
+			alert(L"选择文件目录!");
+			return 1;
+		}
+		else
+		{
+			xaserverarg arg ;
+			arg.AddArg(L"url", urlEx);
+			arg.AddArg(L"Search", Search);
+			OpenWindow(L"dev:xpage[trade.helpEx.vx]", arg);
+			return 1;
+		}
+
+		return 1;
+	}
+
+	//命令处理事件
+	int OnXCommand(TEvent* evt, LPARAM param)
+	{
+		return OnCmdDispatch(evt->xcommand.pStrID);
+	}
+
+	int OnAttachEvent()
+	{
+		//绑定工具条点击事件
+		AttachEvent(L"WM_XCOMMAND", (FEvent)&TDocumentWin::OnXCommand);
+		//获取焦点事件,用于重置工具条
+		AttachEvent(L"WM_SETFOCUS", (FEvent) & TDocumentWin::OnSetFocus);
+
+		return 1;
+	}
+
+	int createSubTree(HTREEITEM h, KXMLDOMElement ele)
+	{
+		KXMLDOMNodeList nlist = ele.selectNodes(L"folder");
+		int i;
+		int s = nlist.length();
+		if (s > 0)
+		{
+			for (i = 0; i < s; i++)
+			{
+				KXMLDOMElement e = nlist.item(i);
+				xstring name = e.getAttribute(L"caption");
+				HTREEITEM hw = tv_folder.InsertChildItem(h, name, e, 15);
+				createSubTree(hw, e);
+			}
+		}
+		return 1;
+	}
+
+	int OnCreateTree()
+	{
+		xml x;
+		if (xurl::get(L"/sale/data/TDocument3/folder/root", L"", x) != 1)
+		{
+			return -1;
+		}
+		else
+		{
+			KXMLDOMNodeList nlist = x.selectNodes(L"folders/folder");
+			int len = nlist.length();
+
+			if (len > 0)
+			{
+				int i;
+				for (i = 0; i < len; i++)
+				{
+					KXMLDOMElement e = nlist.item(i);
+					xstring name = e.getAttribute(L"caption");
+					HTREEITEM h =tv_folder.InsertChildItem( 0, name, e, 17);
+					createSubTree(h, e);
+					if (len == 1) tv_folder.ExpandItem(h);
+				}
+				tv_folder.ExpandItem(0);
+			}
+		}
+		return 1;
+	}
+
+	//树选择
+	int OnTreeSelChanged(TEvent* evt, int p)
+	{
+		xstring name;
+		lv_view.DeleteItemAll();
+
+		HTREEITEM h = tv_folder.GetSelectedItem();
+		KXMLDOMElement ele = tv_folder.GetItemData(h);
+		KXMLDOMNodeList nlist = ele.selectNodes(L"folder");
+
+		int i;
+		int s = nlist.length();
+		if (s > 0)
+		{
+			for (i = 0; i < s; i++)
+			{
+				KXMLDOMElement e = nlist.item(i);
+				name = e.getAttribute(L"caption");
+				lv_view.InsertItemEx(0, name, 0, e);
+			}
+		}
+
+		xstring src = ele.getAttribute(L"url");
+		trace(L"\r\n" + src);
+		xml x = ViewObject::RetrieveData(L"/sale/data/TDocument3/folder/list", L"src", src);
+		if (x)
+		{
+			//alert(x.GetXml());
+			nlist = x.documentElement().selectNodes(L"*");
+			s = nlist.length();
+			if (s > 0)
+			{
+				for (i = 0; i < s; i++)
+				{
+					KXMLDOMElement e = nlist.item(i);
+					name = e.getAttribute(L"caption");
+					int nItem = lv_view.InsertItemEx( 0, name, 23, e);
+
+					lv_view.SetItemText( nItem, 1, e.getAttribute(L"Creator"));
+					lv_view.SetItemText( nItem, 2, e.getAttribute(L"CreateDate"));
+				}
+			}
+		}
+		lv_view.Redraw();
+
+		return 1;
+	}
+
+	int SetListViewHeaderColumn(xstring Url)
+	{
+		const int LVCFMT_LEFT = 0;
+		for (int i = 0; i < 3; i++)  lv_view.DeleteColumn( 1);
+		//if(Url==L"")
+		//{
+		lv_view.InsertColumn(0, L"创建日期", LVCFMT_LEFT, 80, 0);
+		lv_view.InsertColumn(0, L"创建人员", LVCFMT_LEFT, 80, 0);
+		lv_view.InsertColumn(0, L"名称", 0, 180, 0);
+		columnCount = 3;
+		//}
+		return 1;
+	}
+
+	/*
+	int  OnRetrieve()
+	{
+		xml x = new xml;
+		x.setNativePointer(xml::CreateInstance());
+		xaserverarg arg = new xaserverarg;
+		arg.setNativePointer(arg.CreateInstance());
+		arg.AddArg(L"xxx",L"xxx");
+		if (getUrl(L"",arg.GetString(),x)!=1)
+		{
+			trace(x.text);
+			return -1;
+		}else
+		{
+			//dw_list.Retrieve(x);
+			//dw_list.Redraw();
+		}
+		return 1;
+	}
+	*/
+
+	int onload()
+	{
+		tv_folder = GetControl(L"tv_folder");
+		lv_view = GetControl(L"lv_view");
+
+		columnCount = 0;
+		SetListViewHeaderColumn(L"");
+
+		AttachEvent(L"tv_folder", L"TVN_SELCHANGED", (FEvent)&TDocumentWin::OnTreeSelChanged);
+		AttachEvent(L"lv_view", L"NM_DBLCLK", (FEvent)&TDocumentWin::OnListViewDoubleClicked);
+
+		OnCreateTree();
+		OnAttachEvent();
+
+		tv_folder.ExpandItem(tv_folder.GetRootItem());
+		return 1;
+	}
+
+	int onloaded()
+	{
+		SetAgent();
+
+		return 1;
+	}
+};
\ No newline at end of file
diff --git a/jrj/xframe/kobject/kxml.hpp b/jrj/xframe/kobject/kxml.hpp
index ebcdfbe..dcf125c 100644
--- a/jrj/xframe/kobject/kxml.hpp
+++ b/jrj/xframe/kobject/kxml.hpp
@@ -156,7 +156,9 @@
 		KXMLDOMElement(void* impl) :KXMLDOMNode(impl) {}
 		KXMLDOMElement() :KXMLDOMNode() {}
 	public:
-		KXMLDOMElement(LPARAM p) :KXMLDOMNode((void*)p) {}
+		KXMLDOMElement(LPARAM p) :KXMLDOMNode((void*)p) {
+			AddRef();
+		}
 	};
 
 	class KXMLDOMDocument : public KXMLDOMNode
diff --git a/jrj/xframe/xcontrol/xdatetimepick.hpp b/jrj/xframe/xcontrol/xdatetimepick.hpp
new file mode 100644
index 0000000..e4c8c76
--- /dev/null
+++ b/jrj/xframe/xcontrol/xdatetimepick.hpp
@@ -0,0 +1,58 @@
+#pragma once
+
+#include "wobject/xcontrol.hpp"
+#include "win32/win.hpp"
+
+struct SYSTEMTIME
+{
+	short wYear;
+	short wMonth;
+	short wDayOfWeek; //星期,0=星期日,1=星期一
+	short wDay;
+	short wHour;
+	short wMinute;
+	short wSecond;
+	short wMilliseconds; //毫秒
+};
+
+class xdatetimepick:  public xcontrol
+{
+public:
+    xdatetimepick() :xcontrol(nullptr) {}
+    xdatetimepick(void* implptr) :xcontrol(implptr) {}
+
+	int SetDatetime(int wYear, int wMonth, int wDay)
+	{
+		SYSTEMTIME fdate;
+		fdate.wYear = wYear;
+		fdate.wMonth = wMonth;
+		fdate.wDay = wDay;
+		//fdate.wDayOfWeek=0;
+		//fdate.wHour=0;
+		//fdate.wMinute=0;
+		//fdate.wSecond=0;
+		//fdate.wMilliseconds=0;
+
+		int GDT_VALID = 0x0;
+		int DTM_FIRST = 0x1000;
+		int DTM_SETSYSTEMTIME = DTM_FIRST + 2;
+		int WM_KILLFOCUS = 0x0008;
+		int WM_SETFOCUS = 0x0007;
+		SendMessage(GetHWND(), DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM) & fdate);
+		return 1;
+	}
+
+	int IsChecked()
+	{
+		int GDT_VALID = 0x0;
+		int GDT_NONE = 0x1;
+
+		int DTM_FIRST = 0x1000;
+		int DTM_GETSYSTEMTIME = DTM_FIRST + 1;
+
+		SYSTEMTIME fdate;
+		int ret = SendMessage(GetHWND(), 0x1001, 0, (LPARAM)&fdate);
+		if (ret == GDT_NONE) return 0;
+		return 1;
+	}
+};
\ No newline at end of file
diff --git a/jrj/xframe/xcontrol/xlistview.hpp b/jrj/xframe/xcontrol/xlistview.hpp
index bd01730..78e6cd8 100644
--- a/jrj/xframe/xcontrol/xlistview.hpp
+++ b/jrj/xframe/xcontrol/xlistview.hpp
@@ -562,6 +562,11 @@
 		return InsertItem(GetHWND(),xIndex, label, pictureindex);
 	}
 
+	int InsertItemEx(int xIndex, string label, int pictureindex , KXMLDOMElement data )//only the label and picture index need to be specified	
+	{
+		return InsertItemEx(GetHWND(), xIndex, label, pictureindex, data.ptr());
+	}
+
 	int InsertItemEx(int xIndex, string label, int pictureindex = 0,LPARAM data=0)//only the label and picture index need to be specified	
 	{
 		return InsertItemEx(GetHWND(), xIndex, label,  pictureindex , data);

--
Gitblit v1.9.3