From b8e6a7bb37d04f1e974e231a5caffc1854cf7f41 Mon Sep 17 00:00:00 2001
From: xj qian <qianxj15@sina.com>
Date: 星期四, 27 六月 2024 09:37:26 +0800
Subject: [PATCH] this update tree data item

---
 jrj/xframe/src/xstring.cpp                                |    6 
 jrj/xframe/vbusiness/vutil/publiccode.vutil.vbusiness.hpp |    4 
 jrj/xframe/kobject/kcell.hpp                              |   98 +
 jrj/project/business/GDN3.list.cpp                        |   32 
 jrj/project/viewobject/gdn3.view.hpp                      |   36 
 jrj/project/business/Quote3.maint.cpp                     |    0 
 jrj/project/vindexform.cpp                                |    3 
 jrj/project/business/quote.enquiry.cpp                    | 5058 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 jrj/project/viewobject/view.base.hpp                      |   10 
 jrj/project/business/Enquiry.list.cpp                     |   16 
 jrj/ext-jrj/ext-jrj.vcxproj.user                          |    5 
 jrj/xframe/wobject/xstring.hpp                            |    3 
 jrj/project/business/EnquiryEx3.list.cpp                  |    0 
 jrj/xframe/xcontrol/xtreeview.hpp                         |   10 
 jrj/project/business/Supplier.maint.cpp                   |    0 
 jrj/project/business/Customer3.maint.cpp                  |    2 
 jrj/project/business/SO3.list.cpp                         |    6 
 jrj/xframe/xcontrol/xdwgrid.hpp                           |    4 
 jrj/ext-jrj/ext-jrj.vcxproj                               |   25 
 jrj/project/viewobject/custom.view.hpp                    |   63 
 jrj/project/business/GDN3.maint.cpp                       |  141 
 jrj/xframe/xcontrol/xcell.hpp                             |  294 +++
 22 files changed, 5,700 insertions(+), 116 deletions(-)

diff --git a/jrj/ext-jrj/ext-jrj.vcxproj b/jrj/ext-jrj/ext-jrj.vcxproj
index 8f596a0..9535065 100644
--- a/jrj/ext-jrj/ext-jrj.vcxproj
+++ b/jrj/ext-jrj/ext-jrj.vcxproj
@@ -74,6 +74,10 @@
     <OutDir>$(SolutionDir)..\..\..\mis-prj-build\jrj\$(Platform)\$(Configuration)\</OutDir>
     <IntDir>$(SolutionDir)..\..\..\mis-prj-build\jrj-temp\$(Platform)\$(Configuration)\</IntDir>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <OutDir>$(SolutionDir)..\..\..\mis-prj-build\jrj\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(SolutionDir)..\..\..\mis-prj-build\jrj-temp\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <WarningLevel>Level3</WarningLevel>
@@ -135,10 +139,11 @@
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <SDLCheck>true</SDLCheck>
-      <PreprocessorDefinitions>NDEBUG;EXTJRJ_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>NDEBUG;EXTJRJ_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ConformanceMode>true</ConformanceMode>
-      <PrecompiledHeader>Use</PrecompiledHeader>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>..\xframe;..\xframe\system;..\project</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
@@ -146,11 +151,18 @@
       <OptimizeReferences>true</OptimizeReferences>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableUAC>false</EnableUAC>
+      <AdditionalLibraryDirectories>D:\xclient64r</AdditionalLibraryDirectories>
+      <AdditionalDependencies>xarch.shape.lib;xarch.base.lib;xarch.util.lib;xarch.network.lib;xarch.xframe.lib;xarch.xcontrol.lib;xoffice.xcell.lib;xoffice.xgrid.lib;xoffice.xreport.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
+    <PostBuildEvent>
+      <Command>copy $(OutDirFullPath)ext-jrj.dll D:\xclient64r\ext\ext-jrj.dll</Command>
+    </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="..\project\viewobject\custom.view.hpp" />
     <ClInclude Include="..\project\viewobject\customer.view.hpp" />
     <ClInclude Include="..\project\viewobject\enquiry.view.hpp" />
+    <ClInclude Include="..\project\viewobject\gdn3.view.hpp" />
     <ClInclude Include="..\project\viewobject\productlibrary.view.hpp" />
     <ClInclude Include="..\project\viewobject\purchaseorder.view.hpp" />
     <ClInclude Include="..\project\viewobject\quote.view.hpp" />
@@ -160,6 +172,7 @@
     <ClInclude Include="..\xframe\kobject\kapp.hpp" />
     <ClInclude Include="..\xframe\kobject\kbase.hpp" />
     <ClInclude Include="..\xframe\kobject\kcachemgr.hpp" />
+    <ClInclude Include="..\xframe\kobject\kcell.hpp" />
     <ClInclude Include="..\xframe\kobject\kcontrol.hpp" />
     <ClInclude Include="..\xframe\kobject\kdwgrid.hpp" />
     <ClInclude Include="..\xframe\kobject\kdwpages.hpp" />
@@ -202,6 +215,7 @@
     <ClInclude Include="..\xframe\wobject\xutil.hpp" />
     <ClInclude Include="..\xframe\wobject\xview.hpp" />
     <ClInclude Include="..\xframe\wobject\xwin.hpp" />
+    <ClInclude Include="..\xframe\xcontrol\xcell.hpp" />
     <ClInclude Include="..\xframe\xcontrol\xcombobox.hpp" />
     <ClInclude Include="..\xframe\xcontrol\xdwgrid.hpp" />
     <ClInclude Include="..\xframe\xcontrol\xdwpages.hpp" />
@@ -222,20 +236,23 @@
     </ClCompile>
     <ClCompile Include="..\project\business\Enquiry.list.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
     <ClCompile Include="..\project\business\EnquiryEx3.list.cpp" />
     <ClCompile Include="..\project\business\GDN3.list.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
     </ClCompile>
     <ClCompile Include="..\project\business\GDN3.maint.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
     </ClCompile>
     <ClCompile Include="..\project\business\Product.list.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
     </ClCompile>
     <ClCompile Include="..\project\business\Product.maint.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="..\project\business\quote.enquiry.cpp" />
     <ClCompile Include="..\project\business\Quote3.list3.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
     </ClCompile>
diff --git a/jrj/ext-jrj/ext-jrj.vcxproj.user b/jrj/ext-jrj/ext-jrj.vcxproj.user
index 1e8d464..08c2241 100644
--- a/jrj/ext-jrj/ext-jrj.vcxproj.user
+++ b/jrj/ext-jrj/ext-jrj.vcxproj.user
@@ -5,4 +5,9 @@
     <LocalDebuggerWorkingDirectory>d:\xclient64</LocalDebuggerWorkingDirectory>
     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LocalDebuggerCommand>d:\xclient64r\xexplorer.exe</LocalDebuggerCommand>
+    <LocalDebuggerWorkingDirectory>d:\xclient64r</LocalDebuggerWorkingDirectory>
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+  </PropertyGroup>
 </Project>
\ No newline at end of file
diff --git a/jrj/project/business/Customer3.maint.cpp b/jrj/project/business/Customer3.maint.cpp
index b18b5c3..e04e1d2 100644
--- a/jrj/project/business/Customer3.maint.cpp
+++ b/jrj/project/business/Customer3.maint.cpp
@@ -290,7 +290,7 @@
 		{
 			xdwtable dw_PartyContact1;
 			dw_PartyContact1 =dw_detail.FindDwTable(L"PC_OtherInfo");			
-			xml xx = new xml;
+			xml x
 			xx.setNativePointer(xml ::CreateInstance());
 			xaserverarg argnew = new xaserverarg;
 			argnew.setNativePointer(argnew.CreateInstance());	
diff --git a/jrj/project/business/Enquiry.list.cpp b/jrj/project/business/Enquiry.list.cpp
index 3754c3e..f46437b 100644
--- a/jrj/project/business/Enquiry.list.cpp
+++ b/jrj/project/business/Enquiry.list.cpp
@@ -605,7 +605,7 @@
 		if(arg.GetArgString(L"process") == L"ok")
 		{
 		
-			xml x = new xml;
+			xml 
 			x.setNativePointer(xml::CreateInstance());
 			if (getUrl(L"/sale/data/Enquiry/PriceListEx/SKU",arg.GetString(),x)!=1) return 1;
 			KXMLDOMNodeList nodes = x.selectNodes(L"data/Item");
@@ -653,7 +653,7 @@
 		dw_priceitem.Reset();
 			
 		xaserverarg arg = xaserverarg::Make();
-		xml x = new xml;
+		xml 
 		x.setNativePointer(xml::CreateInstance());
 		arg.AddArg(L"SKUID",dw_pricelist.GetItemString(row,L"SKUID"));
 		arg.AddArg(L"SchemaNo",dw_pricelist.GetItemString(row,L"BOMSchema"));
@@ -932,7 +932,7 @@
 		OpenWindow(L"dev:xpage[PriceList.PurcharItemSelectEx.vx]",cast(arg as int));
 		if(arg.GetArgString(L"process") == L"ok")
 		{
-			xml x = new xml;
+			xml 
 			x.setNativePointer(xml::CreateInstance());
 			x.LoadXml(arg.GetArgString(L"result"));
 			KXMLDOMNodeList nodes = x.selectNodes(L"data/Item");
@@ -988,7 +988,7 @@
 		OpenWindow(L"dev:xpage[PriceList.PurcharItemSelectEx.vx]",cast(arg as int));
 		if(arg.GetArgString(L"process") == L"ok")
 		{
-			xml x = new xml;
+			xml 
 			x.setNativePointer(xml::CreateInstance());
 			x.LoadXml(arg.GetArgString(L"result"));
 			KXMLDOMNodeList nodes = x.selectNodes(L"data/Item");
@@ -1475,7 +1475,7 @@
 	
 	int OnRetrieveItem(xstring EnquiryPriceListID)
 	{
-		xml x = new xml;
+		xml 
 		x.setNativePointer(xml::CreateInstance());
 		xaserverarg arg = new xaserverarg;
 		arg.setNativePointer(arg.CreateInstance());	
@@ -1499,7 +1499,7 @@
 		KXMLDOMElement e1 = cast(tv_folder_pricebill.GetItemData(hItem) as KXMLDOMElement);
 		xstring no = e1.getAttribute(L"no");
 
-		xml x = new xml;
+		xml 
 		x.setNativePointer(xml::CreateInstance());
 		xaserverarg arg = new xaserverarg;
 		arg.setNativePointer(arg.CreateInstance());	
@@ -1529,7 +1529,7 @@
 		KXMLDOMElement e1 = cast(tv_folder_pricebill.GetItemData(hItem) as KXMLDOMElement);
 		xstring no = e1.getAttribute(L"no");
 
-		xml x = new xml;
+		xml 
 		x.setNativePointer(xml::CreateInstance());
 		xaserverarg arg = new xaserverarg;
 		arg.setNativePointer(arg.CreateInstance());	
@@ -1550,7 +1550,7 @@
 	
 	int  OnProductPriceShareRetrieve()
 	{
-		xml x = new xml;
+		xml 
 		x.setNativePointer(xml::CreateInstance());
 		xaserverarg arg = new xaserverarg;
 		arg.setNativePointer(arg.CreateInstance());	
diff --git a/jrj/project/business/EnquiryEx3.list.cpp b/jrj/project/business/EnquiryEx3.list.cpp
index ae103dc..4f8c971 100644
--- a/jrj/project/business/EnquiryEx3.list.cpp
+++ b/jrj/project/business/EnquiryEx3.list.cpp
Binary files differ
diff --git a/jrj/project/business/GDN3.list.cpp b/jrj/project/business/GDN3.list.cpp
index 0ae84fd..cef6bc4 100644
--- a/jrj/project/business/GDN3.list.cpp
+++ b/jrj/project/business/GDN3.list.cpp
@@ -5,14 +5,14 @@
 #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
 #include "viewobject/view.base.hpp"
 
-class __declspec(dllexport) GDN3list : public listwin
+class __declspec(dllexport) ListGDN3Win : public listwin
 {
 public:
-	GDN3list(void* implPtr, HWND hWnd) :listwin(implPtr, hWnd) {}
+	ListGDN3Win(void* implPtr, HWND hWnd) :listwin(implPtr, hWnd) {}
 public:
-	static GDN3list* CreateInstance(void* implPtr, void* hWnd)
+	static ListGDN3Win* CreateInstance(void* implPtr, void* hWnd)
 	{
-		GDN3list* pWin = new GDN3list(implPtr, (HWND)hWnd);
+		ListGDN3Win* pWin = new ListGDN3Win(implPtr, (HWND)hWnd);
 		return pWin;
 	}
 
@@ -100,7 +100,6 @@
 			HTREEITEM h = tv_folder.InsertChildItem(hItem, name, (LPARAM)&e, 35);
 			ExpandCatChildFolder(h, e, 35);
 		}
-		x.Free();
 		return 1;
 	}
 
@@ -201,10 +200,10 @@
 
 		if (readed) return 1;
 		HTREEITEM hItem = tv_folder.GetSelectedItem();
-		if (hItem <= 0)
+		if (!hItem)
 		{
 			hItem = tv_folder.GetRootItem();
-			if (hItem <= 0)  return 1;
+			if (!hItem)  return 1;
 		}
 		HCURSOR hCursor = xutil::SetCursorWait();
 		KXMLDOMElement& e1 = *(KXMLDOMElement*)tv_folder.GetItemData(hItem);
@@ -212,7 +211,7 @@
 		//xml x = 0;
 		//x = ViewObject::RetrieveData(myDataUrl,L"no",no,L"QueryTxt", m_QueryTxt,L"rows",rows);
 		xstring DeptName = publiccode::GetUser().deptname;
-		xaserverarg arg = xaserverarg::Make();
+		xaserverarg arg ;
 		arg.AddArg(L"no", no);
 		arg.AddArg(L"QueryTxt", m_QueryTxt);
 		arg.AddArg(L"rows", rows);
@@ -224,7 +223,6 @@
 			dw_list.DwRetrieve(GetServerUrl(),L"[list.folder.gdn.sql.xq]",arg.GetString());
 		}*/
 		dw_list.DwRetrieve(GetServerUrl(), L"[list.folder.gdn.sql.xq]", arg.GetString());
-		arg.Free();
 		dw_list.SetReadOnly(true);
 		dw_list.SetRowSort(L"ETD", false);
 
@@ -238,7 +236,7 @@
 	int OnPreRetrieve()
 	{
 		HTREEITEM hItem = tv_folder.GetSelectedItem();
-		if (hItem <= 0) return 1;
+		if (!hItem) return 1;
 
 		HCURSOR hCursor = xutil::SetCursorWait();
 
@@ -254,7 +252,7 @@
 		}
 		else
 		{
-			dw_list.ResetEx();
+			dw_list.Reset();
 			dw_list.Redraw();
 		}
 		dw_list.SetReadOnly(true);
@@ -592,11 +590,11 @@
 
 	int PostOnAttachEvent()
 	{
-		AttachEvent(L"tv_folder", L"TVN_SELCHANGED", (FEvent)&GDN3list::OnTreeSelChanged); //树选择
-		//AttachEvent(L"tv_folder", L"TVN_ITEMEXPANDING",(FEvent)&GDN3list::OnTreeExpanding); //树展开
-		AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&GDN3list::OnRowChanged);
-		AttachEvent(L"cbx_1", L"CBN_SELCHANGE", (FEvent)&GDN3list::OnSelectDdlb);
-		AttachEvent(L"cbx_datashow", L"CBN_SELCHANGE", (FEvent)&GDN3list::OnSelectDataShowDdlb);
+		AttachEvent(L"tv_folder", L"TVN_SELCHANGED", (FEvent)&ListGDN3Win::OnTreeSelChanged); //树选择
+		//AttachEvent(L"tv_folder", L"TVN_ITEMEXPANDING",(FEvent)&ListGDN3Win::OnTreeExpanding); //树展开
+		AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&ListGDN3Win::OnRowChanged);
+		AttachEvent(L"cbx_1", L"CBN_SELCHANGE", (FEvent)&ListGDN3Win::OnSelectDdlb);
+		AttachEvent(L"cbx_datashow", L"CBN_SELCHANGE", (FEvent)&ListGDN3Win::OnSelectDataShowDdlb);
 		return 1;
 	}
 
@@ -707,7 +705,7 @@
 		}
 
 		HTREEITEM hItem = tv_folder.GetCaretItem();
-		if (hItem <= 0) return 1;
+		if (!hItem) return 1;
 		KXMLDOMElement e = tv_folder.GetItemData(hItem);
 		xstring  no = e.getAttribute(L"no");
 		if (no.find(L"Customer:") >= 0)
diff --git a/jrj/project/business/GDN3.maint.cpp b/jrj/project/business/GDN3.maint.cpp
index 60c633d..72aebdf 100644
--- a/jrj/project/business/GDN3.maint.cpp
+++ b/jrj/project/business/GDN3.maint.cpp
@@ -8,6 +8,8 @@
 #include "viewobject/view.base.hpp"
 #include "viewobject/saleorder.view.hpp"
 #include "viewobject/quote.view.hpp"
+#include "viewobject/gdn3.view.hpp"
+#include "viewobject/custom.view.hpp"
 
 class __declspec(dllexport) GDN3MaintWin : public maint
 {
@@ -106,7 +108,7 @@
 			}
 		}
 		tools += L"</vbox>";
-		SetAgentNodeContent(anode, tools);
+		SetAgentNode(anode, tools);
 
 		return 1;
 	}
@@ -516,7 +518,7 @@
 		KXMLDOMDocument xbasedoc = xbase;
 		dw_base.DwUpdateAllTo(xbasedoc);
 
-		xaserverarg arg = GDNView::MakeArg();
+		xaserverarg arg ;
 		//if(dw_billnote.DeletedCount()+dw_billnote.ModifiedCount() > 0)
 		//{
 		xml xbillnote ;
@@ -549,7 +551,7 @@
 	
 		KXMLDOMDocument xprofitdoc = xprofit;
 		dw_profit.DwUpdateAllTo(xprofitdoc);
-		xaserverarg arg3 = GDNView::MakeArg();
+		xaserverarg arg3 ;
 		arg3.AddArg(L"content", xprofit.xml());
 		if (xurl::get(L"/sale/data/Gdn/update/profit", arg3.GetString(), xprofit) != 1)
 		{
@@ -582,7 +584,7 @@
 		KXMLDOMDocument xitemdoc = xitem;
 		dw_item.DwUpdateAllToEx(xitemdoc);
 		//dw_base.DwUpdateAllTo(xitemdoc);
-		xaserverarg arg1 = GDNView::MakeArg();
+		xaserverarg arg1 ;
 		arg1.AddArg(L"content", xitem.xml());
 
 		if (xurl::get(L"/sale/data/Gdn/update/item", arg1.GetString(), xitem) != 1)
@@ -604,7 +606,7 @@
 		xml x;
 		
 		dw_source.DwUpdateAllToEx(x);
-		xaserverarg arg2 = GDNView::MakeArg();
+		xaserverarg arg2 ;
 		arg2.AddArg(L"content", x.xml());
 
 		if (xurl::get(L"/sale/data/Gdn/update/sourceex", arg2.GetString(), x) != 1)
@@ -627,7 +629,7 @@
 		{
 			if (dw_custom.GetItemString(k, L"LineNo") == L"")
 			{
-				dw_custom.SetItemString(k, L"LineNo", k.toString());
+				dw_custom.SetItemString(k, L"LineNo", xstring(k));
 			}
 		}
 		xml xcustom;
@@ -657,7 +659,7 @@
 			xml x1 ;
 			
 			dw_invoiceItem.DwUpdateAllToEx(x1);
-			xaserverarg arg4 = GDNView::MakeArg();
+			xaserverarg arg4;
 			arg4.AddArg(L"content", x1.xml());
 			if (xurl::get(L"/sale/data/Gdn/update/itemex", arg4.GetString(), x1) != 1)
 				if (!x1)
@@ -677,7 +679,7 @@
 		xml xfcl ;
 		
 		dw_fcl.DwUpdateAllToEx(xfcl);
-		xaserverarg arg8 = GDNView::MakeArg();
+		xaserverarg arg8 ;
 		arg8.AddArg(L"content", xfcl.xml());
 
 		if (xurl::get(L"/sale/data/Gdn/update/container", arg8.GetString(), xfcl) != 1)
@@ -700,7 +702,7 @@
 		dw_cdelement.DwUpdateAllToEx(xcdelement);
 		if (xcdelement.xml() != L"")
 		{
-			xcdelement = CustomView::UpdateCustomElement(dw_base.GetItemString(1, L"InvoiceNo"), xcdelement.GetXml());
+			xcdelement = CustomView::UpdateCustomElement(dw_base.GetItemString(1, L"InvoiceNo"), xcdelement.xml());
 			if (!xcdelement)
 			{
 				xstring error6 = xcdelement.text();
@@ -998,7 +1000,7 @@
 		xstring GDNLineID = dw_item.GetGuid(nRow);
 		if (clear) ClearSourcingItem(nRow);
 		double ExchangeCostEx = dw_profit.GetItemDouble(1, L"ExchangeCostEx");
-		xml x = xml::Make();
+		xml x ;
 		x.loadXML(L"<data/>");
 		KXMLDOMElement e = dw_item.GetRowElement(nRow);
 		KXMLDOMNode n = e.cloneNode(-1);
@@ -1006,7 +1008,6 @@
 		n.Release();
 		xstring val = x.xml();
 		trace(L"=======L" + val + L"=======L");
-		x.Free();
 
 		xml source = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/gdn/sourcing/refreshitemex", L"content", val);
 		if (source)
@@ -1077,7 +1078,7 @@
 		xstring GDNLineID = dw_item.GetGuid(nRow);
 		if (clear) ClearSourcingItem(nRow);
 		double ExchangeCostEx = dw_profit.GetItemDouble(1, L"ExchangeCostEx");
-		xml x = xml::Make();
+		xml x ;
 		x.loadXML(L"<data/>");
 		KXMLDOMElement e = dw_item.GetRowElement(nRow);
 		KXMLDOMNode n = e.cloneNode(-1);
@@ -1085,7 +1086,6 @@
 		n.Release();
 		xstring val = x.xml();
 		trace(L"123=======L" + val + L"=======123");
-		x.Free();
 
 		xml source = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/gdn/sourcing/refreshitemexOne", L"content", val);
 		if (source)
@@ -1162,7 +1162,7 @@
 		dw_item.DwUpdateAllToEx(xitemdoc);
 		
 
-		xml x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/gdn/sourcing/refreshitemexOne", L"content", xitem.GetXml());
+		xml x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/gdn/sourcing/refreshitemexOne", L"content", xitem.xml());
 		trace(x.xml());
 		if (x)
 		{
@@ -1216,7 +1216,6 @@
 
 			PoTotal();
 
-			x.Free();
 			evalProfitAmountEx();
 		}
 
@@ -1613,7 +1612,7 @@
 	{
 		if (data == L"")
 		{
-			dw_item.SetItemDisplayString(row, col, L"");
+			dw_item.SetItemDisplayString(row, col.c_str(), L"");
 			dw_item.SetItemString(row, L"CDUnitPrice", L"");
 			dw_item.SetItemDisplayString(row, L"CDUnitPrice", L"");
 		}
@@ -1883,7 +1882,7 @@
 		{
 			xaserverarg arg ;
 			
-			xstring str = dw_billnote.GetItemString(row, colname);
+			xstring str = dw_billnote.GetItemString(row, colname.c_str());
 			arg.AddArg(L"value", str);
 			openUrl(L"/sale/view/view.dlg/xpage/memo/edit/new", &arg);
 		
@@ -1891,7 +1890,7 @@
 			if (comdid == L"xmOK")
 			{
 				xstring value = arg.GetArgString(L"value");
-				dw_billnote.SetItemString(row, colname, value);
+				dw_billnote.SetItemString(row, colname.c_str(), value);
 				dw_billnote.Redraw();
 			}
 		}
@@ -2020,7 +2019,7 @@
 
 	int OnMakeCustom()
 	{
-		int HCursor = xutil::SetCursorWait();
+		HCURSOR HCursor = xutil::SetCursorWait();
 		dw_custom.AcceptText();
 		int cnt = dw_custom.GetRowCount();
 		bool cdelement = false;
@@ -2238,8 +2237,8 @@
 		{
 			if (dw_custom.GetItemString(m, L"UseFlag") == L"0")
 			{
-				if (dw_custom.GetItemString(i, L"ClassifyID") != L"")
-					DeleteCDElement(dw_custom.GetItemString(i, L"ClassifyID"));
+				if (dw_custom.GetItemString(m, L"ClassifyID") != L"")
+					DeleteCDElement(dw_custom.GetItemString(m, L"ClassifyID"));
 				dw_custom.DeleteRow(m);
 			}
 		}
@@ -2502,7 +2501,7 @@
 
 	int OnAddSourcingItem()
 	{
-		xaserverarg arg = GDNView::MakeArg();
+		xaserverarg arg ;
 		arg.AddArg(L"InvoiceNo", dw_base.GetItemString(1, L"InvoiceNo"));
 		int p = arg;
 		OpenWindow(L"dev:xpage[select.item.po.vx]", p);
@@ -2602,7 +2601,7 @@
 				KXMLDOMNode t = items.item(i);
 				dw_item.SetItemString(row, L"SeqNo", xstring((row * 10)));
 				dw_item.SetItemString(row, L"GDNID", dw_base.GetGuid(1));
-				double cost = (double) t.selectSingleNode(L"Cost").text().todouble();
+				double cost = xstring(t.selectSingleNode(L"Cost").text()).toDouble();
 				
 
 				if (t.selectSingleNode(L"SONo"))
@@ -2717,7 +2716,7 @@
 				double d1 = dw_item.GetItemDouble(row, L"Quantity");
 				double d2 = dw_item.GetItemDouble(row, L"UnitPrice");
 				double d = d1 * d2;
-				d = d.round(2);
+				d = xdouble(d).round(2);
 				dw_item.SetItemDouble(row, L"Amount", d);
 
 				double UnitCommPrice = dw_item.GetItemDouble(row, L"UnitCommPrice");
@@ -2740,7 +2739,7 @@
 			dw_base.SetItemString(1, L"Mark", FrontMarkss);
 
 			double CostEx = dw_base.GetItemDouble(1, L"Cost");
-			if (CostEx == 0 || CostEx == L"")
+			if (CostEx == 0)
 			{
 				if (costs >= 0) {
 					dw_base.SetItemString(1, L"CostMoreLess", L"1");
@@ -2766,14 +2765,14 @@
 	int OnAddGDNItem()
 	{
 		//trace(L"12313");
-		xaserverarg arg = GDNView::MakeArg();
+		xaserverarg arg ;
 		arg.AddArg(L"CustomerID", dw_base.GetItemString(1, L"CustomerID"));
 		arg.AddArg(L"InvoiceNo", dw_base.GetItemString(1, L"InvoiceNo"));
 		arg.AddArg(L"SONo", dw_base.GetItemString(1, L""));
 		int p = arg;
 		if (dw_base.GetItemString(1, L"CustomerID") == L"")
 		{
-			OpenWindow(L"dev:xpage[SelectItem.New.GDN.vx]", cast(arg as int));
+			OpenWindow(L"dev:xpage[SelectItem.New.GDN.vx]", arg);
 			if (dw_base.GetItemString(1, L"CustomerID") == L"")
 			{
 				dw_base.SetItemDisplayString(1, L"CustomerID", arg.GetArgString(L"PartyName"));
@@ -3206,13 +3205,13 @@
 		}
 		else if (comdid == L"xmMaintBuyPrice")
 		{
-			xaserverarg arg = GDNView::MakeArg();
+			xaserverarg arg ;
 			int row = dw_source.GetRow();
 			if (row < 1) return 1;
 			arg.AddArg(L"SupplierID", dw_source.GetItemString(row, L"SupplierID"));
 			arg.AddArg(L"SupplierName", dw_source.GetItemDisplayString(row, L"SupplierID"));
 			arg.AddArg(L"Price", dw_source.GetItemString(row, L"BuyUnitPrice"));
-			OpenWindow(L"dev:xpage[GDNSourcePriceMaint.vx]", cast(arg as int));
+			OpenWindow(L"dev:xpage[GDNSourcePriceMaint.vx]", arg);
 			if (arg.GetArgString(L"result") == L"ok")
 			{
 				if (arg.GetArgString(L"SupplierID") != L"")
@@ -3352,13 +3351,13 @@
 						KXMLDOMNode n = o.selectSingleNode(L"VATRates");
 						if (n)
 						{
-							tax = n.text.toDouble();
+							tax = xstring(n.text()).toDouble();
 							n.Release();
 						}
 						n = o.selectSingleNode(L"VATRefundRate");
 						if (n)
 						{
-							retax = n.text.toDouble();
+							retax = xstring(n.text()).toDouble();
 							n.Release();
 						}
 						o.Release();
@@ -3430,7 +3429,6 @@
 			double rate = expRate.toDouble();
 			ManagementFee = sale * rate;
 		}
-		trace(ManagementFee.toString());
 		dw_profit.SetItemDouble(1, L"ManagementFee", ManagementFee);
 		return 1;
 	}
@@ -3644,6 +3642,7 @@
 		evalDrawbackEx();
 		evalTotalCost();
 		evalProfitAmountEx();
+		return 1;
 	}
 
 	int OnItemAskStyle(TEvent* evt, LPARAM p)
@@ -3695,14 +3694,14 @@
 		AttachEvent(L"dw_item", L"DWV_ASKSTYLE", (FEvent)&GDN3MaintWin::OnItemAskStyle);
 
 		AttachCloseWindow();
-
+		return 1;
 	}
 
 	int RetrieveUseBuffer(xstring invno)
 	{
 
 		xml x;
-		x = new xml;
+		
 		
 		xaserverarg arg;
 		
@@ -3738,15 +3737,13 @@
 			if (dw_billnote.GetRowCount() < 1)
 			{
 				xml x0;
-				x0 = new xml;
-				x0.setNativePointer(xml::CreateInstance());
-				xstring billnote = L"<GDN><DocInfo><data><Item Name='报关发票' Field='Remark'></Item>" +
-					"<Item Name='报关箱单' Field='Remark'></Item>" +
-					"<Item Name='议付发票' Field='Remark'></Item>" +
-					"<Item Name='议付箱单' Field='Remark'></Item>" +
-					"<Item Name='装船通知' Field='Remark'></Item>" +
-					"<Item Name='加拿大海关发票' Field='Remark'></Item>" +
-					"<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>";
+				xstring billnote = L"<GDN><DocInfo><data><Item Name='报关发票' Field='Remark'></Item>" 
+					L"<Item Name='报关箱单' Field='Remark'></Item>" 
+					L"<Item Name='议付发票' Field='Remark'></Item>" 
+					L"<Item Name='议付箱单' Field='Remark'></Item>" 
+					L"<Item Name='装船通知' Field='Remark'></Item>" 
+					L"<Item Name='加拿大海关发票' Field='Remark'></Item>" 
+					L"<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>";
 				x0.loadXML(billnote);
 				dw_billnote.Retrieve(x0);
 			}
@@ -3764,10 +3761,9 @@
 		dw_item.SetSelectionMode(1);
 		if (dw_item.GetRowCount() < 1)
 		{
-			xml x2 = xml::Make();
+			xml x2 ;
 			x2.loadXML(L"<GDN/>");
 			dw_item.Retrieve(x2);
-			x2.Free();
 		}
 
 		/*
@@ -3786,7 +3782,6 @@
 			ele = node;
 			//node.release();
 			dw_invoiceItem.Retrieve(ele);
-			ele.release();
 		}
 		//alert(L"123"+InvoiceID);
 		//dw_source.DwRetrieve(GetServerUrl(),L"[source.gdn.sql.xq]", L"EntityID",  InvoiceID);
@@ -3798,7 +3793,6 @@
 			ele = node;
 			//node.release();
 			dw_source.Retrieve(ele);
-			ele.release();
 		}
 		dw_custom.DwRetrieve(GetServerUrl(), L"[cdline.gdn.sql.xq]", L"EntityID", InvoiceID);
 		dw_custom.SetSelectionMode(1);
@@ -3819,7 +3813,6 @@
 			//node.release();
 			dw_cdelement.Retrieve(ele);
 			dw_cdelement.SetSelectionMode(1);
-			ele.release();
 		}
 
 		node = xdoc.selectSingleNode(L"data/Item[@subject='Container' or @subject='container']/*");
@@ -3828,7 +3821,6 @@
 			ele = node;
 			//node.release();
 			dw_fcl.Retrieve(ele);
-			ele.release();
 		}
 
 		return 1;
@@ -3837,7 +3829,7 @@
 	int OnRefreshSource(xstring invno)
 	{
 		xml x;
-		x = new xml;
+		
 		
 		xaserverarg arg ;
 
@@ -3858,7 +3850,7 @@
 		//return RetrieveUseBuffer(invno);
 
 		xml x;
-		x = new xml;
+		
 		
 		xaserverarg arg ;
 
@@ -3882,13 +3874,13 @@
 		dw_billnote.Retrieve(x);
 		if (dw_billnote.GetRowCount() < 1)
 		{
-			xstring billnote = L"<GDN><DocInfo><data><Item Name='报关发票' Field='Remark'></Item>" +
-				"<Item Name='报关箱单' Field='Remark'></Item>" +
-				"<Item Name='议付发票' Field='Remark'></Item>" +
-				"<Item Name='议付箱单' Field='Remark'></Item>" +
-				"<Item Name='装船通知' Field='Remark'></Item>" +
-				"<Item Name='加拿大海关发票' Field='Remark'></Item>") +
-				"<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>");
+			xstring billnote = L"<GDN><DocInfo><data><Item Name='报关发票' Field='Remark'></Item>" 
+				"<Item Name='报关箱单' Field='Remark'></Item>" 
+				"<Item Name='议付发票' Field='Remark'></Item>" 
+				"<Item Name='议付箱单' Field='Remark'></Item>" 
+				"<Item Name='装船通知' Field='Remark'></Item>" 
+				"<Item Name='加拿大海关发票' Field='Remark'></Item>"
+				"<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>";
 			x.loadXML(billnote);
 			dw_billnote.Retrieve(x);
 		}
@@ -3972,8 +3964,8 @@
 
 	xstring GetInvoiceID(xstring InvoiceNo)
 	{
-		xml x = xml::Make();
-		xaserverarg arg = xaserverarg::Make();
+		xml x ;
+		xaserverarg arg ;
 		arg.AddArg(L"InvoiceNo", InvoiceNo);
 		xaserver::ExecXQuery(GetServerUrl(), L"[gdnid.gdn.xq]", arg.GetString(), x);
 		xstring InvoiceID1 = L"";
@@ -3981,8 +3973,6 @@
 		{
 			InvoiceID1 = x.text();
 		}
-		arg.Free();
-		x.Free();
 		return InvoiceID1;
 	}
 
@@ -4013,16 +4003,17 @@
 		dw_base.SetGuid(1, id);
 		dw_profit.SetGuid(1, id);
 
-		xml x = ViewObject::MakeXml();
-		xstring billnote = L"<GDN><DocInfo><data><Item Name='报关发票' Field='Remark'></Item>" +
-			"<Item Name='报关箱单' Field='Remark'></Item>" +
-			"<Item Name='议付发票' Field='Remark'></Item>" +
-			"<Item Name='议付箱单' Field='Remark'></Item>" +
-			"<Item Name='装船通知' Field='Remark'></Item>" +
-			"<Item Name='加拿大海关发票' Field='Remark'></Item>" +
+		xml x;
+		xstring billnote = L"<GDN><DocInfo><data><Item Name='报关发票' Field='Remark'></Item>" 
+			"<Item Name='报关箱单' Field='Remark'></Item>" 
+			"<Item Name='议付发票' Field='Remark'></Item>" 
+			"<Item Name='议付箱单' Field='Remark'></Item>" 
+			"<Item Name='装船通知' Field='Remark'></Item>" 
+			"<Item Name='加拿大海关发票' Field='Remark'></Item>" 
 			"<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>";
 		x.loadXML(billnote);
 		dw_billnote.Retrieve(x);
+		return 1;
 	}
 
 	int onload()
@@ -4135,10 +4126,9 @@
 		dw_doclist.openUrl(L"/sale/view/GDN/template/doclist");
 
 		InvoiceNo = L"";
-		if (GetParam())
+		if (GetWinParam())
 		{
-			xaserverarg arg_param = new xaserverarg;
-			arg_param.setNativePointer(GetParam());
+			xaserverarg arg_param=GetArg();
 
 			InvoiceNo = arg_param.GetArgString(L"InvoiceNo");
 			if (InvoiceNo == L"") InvoiceNo = arg_param.GetArgString(L"EntityNo");
@@ -4185,10 +4175,9 @@
 		else
 		{
 			OnNewInital();
-			if (GetParam())
+			if (GetWinParam())
 			{
-				xaserverarg arg = new xaserverarg;
-				arg.setNativePointer(GetParam());
+				xaserverarg arg = GetArg();
 
 				if (arg.GetArgString(L"CustomerID") != L"")
 				{
@@ -4198,7 +4187,7 @@
 					xstring colname = L"CustomerID";
 					xstring value = arg.GetArgString(L"CustomerID");
 					KXMLDOMNodeList nlist = GetElement().selectNodes(L"//*[@name='" + dwname + L"']/trans[@for='" + colname + L"']");
-					ViewObject::TransData(nlist, dw_base, 1, colname, value);
+					ViewObject::TransData(nlist, dw_base, 1, colname, value); 
 					trace(L"+++++L");
 				}
 			}
diff --git a/jrj/project/business/Quote3.maint.cpp b/jrj/project/business/Quote3.maint.cpp
index 39cd6ed..462c10d 100644
--- a/jrj/project/business/Quote3.maint.cpp
+++ b/jrj/project/business/Quote3.maint.cpp
Binary files differ
diff --git a/jrj/project/business/SO3.list.cpp b/jrj/project/business/SO3.list.cpp
index 0ce958f..2169958 100644
--- a/jrj/project/business/SO3.list.cpp
+++ b/jrj/project/business/SO3.list.cpp
@@ -48,7 +48,7 @@
 		{
 			KXMLDOMElement e = nlist.item(i);
 			string name = e.getAttribute(L"name");
-			HTREEITEM h = tv_folder.InsertChildItem(hItem, name, e.ptr(), image);
+			HTREEITEM h = tv_folder.InsertChildItem(hItem, name, e, image);
 			ExpandCatChildFolder(h, e, 35);
 		}
 		return 1;
@@ -64,7 +64,7 @@
 		{
 			KXMLDOMElement e = nlist.item(i);
 			string name = e.getAttribute(L"name");
-			HTREEITEM h = tv_folder.InsertChildItem(hItem, name, e.ptr(), 35);
+			HTREEITEM h = tv_folder.InsertChildItem(hItem, name, e, 35);
 			ExpandCatChildFolder(h, e, 35);
 		}
 		return 1;
@@ -98,7 +98,7 @@
 			xstring child = e.getAttribute(L"child");
 			int image = 15;
 			if (sImage) image = sImage.toInt();
-			HTREEITEM h = tv_folder.InsertChildItem(hItem, name, e.ptr(), image);
+			HTREEITEM h = tv_folder.InsertChildItem(hItem, name, e, image);
 			if (child != L"no") tv_folder.SetItemChild(h, 1);
 			//ExpandChildFolder(h, e);
 		}
diff --git a/jrj/project/business/Supplier.maint.cpp b/jrj/project/business/Supplier.maint.cpp
index fc9817e..cde3e61 100644
--- a/jrj/project/business/Supplier.maint.cpp
+++ b/jrj/project/business/Supplier.maint.cpp
Binary files differ
diff --git a/jrj/project/business/quote.enquiry.cpp b/jrj/project/business/quote.enquiry.cpp
new file mode 100644
index 0000000..a71d3a2
--- /dev/null
+++ b/jrj/project/business/quote.enquiry.cpp
@@ -0,0 +1,5058 @@
+#include <wobject/xstring.hpp>
+#include <xcontrol/xtreeview.hpp>
+#include <xcontrol/xdwgrid.hpp>
+#include <xcontrol/ximageview.hpp>
+#include <xcontrol/xcell.hpp>
+
+
+#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
+#include "viewobject/view.base.hpp"
+#include "viewobject/quote.view.hpp"
+
+using xml = KXMLDOMDocument;
+class __declspec(dllexport) QuoteFileView : public xframe
+{
+
+public:
+	QuoteFileView(void* implPtr, HWND hWnd):xframe(implPtr, hWnd) {}
+public:
+	static QuoteFileView* CreateInstance(void* implPtr, void* hWnd)
+	{
+		QuoteFileView* pWin = new QuoteFileView(implPtr, (HWND)hWnd);
+		return pWin;
+	}
+public:
+	xcell	dw_cell;
+	xnode	m_agentNode;	//Agent Condition
+	xstring filename;
+	xstring fileid;
+	xstring templateurl;
+	xstring taskid;
+	xml purcher;
+
+	xdwgrid	dw_goods;
+	xdwtable dw_base;
+	xstring tabsheet;
+
+	xstring templateID;
+	xstring entityID;
+	xstring entityItemID;
+	xstring action;
+	xstring processurl;
+
+	int ARow;
+	int ACol;
+	xstring orivalue;
+	bool bPurchPrice;
+
+	int SetAgent()
+	{
+		xstring xfNodeAgentArea = L"agentarea";
+		xnode anode = GetAgentNode(xfNodeAgentArea);
+		if (m_agentNode)
+		{
+			SetAgentNode(anode, m_agentNode);
+		}
+		else
+		{
+			xstring path = L"agent/" + xfNodeAgentArea + L"[1]/*";
+			if (action == L"purch") path = L"agent/" + xfNodeAgentArea + L"[2]/*";
+			KXMLDOMElement xframeElement = GetElement();
+			KXMLDOMElement agent = xframeElement.selectSingleNode(path);
+			if (agent)
+			{
+				xstring s = agent.xml();
+				m_agentNode = SetAgentNode(anode, s);
+			}
+		}
+		return 1;
+	}
+
+	xstring GetImageUrl(xstring id)
+	{
+		xml xp ;
+		xaserverarg arg_pic;
+		arg_pic.AddArg(L"id", id);
+
+		xstring res = L"/sale/data/productlibrary3/image/url";
+		if (xurl::get(res, arg_pic.GetString(), xp) != 1)
+		{
+			trace(xp.xml());
+			return 1;
+		}
+		else
+		{
+			xstring path = xp.text();
+			if (path != L"") return path;
+		}
+
+		return L"/business/products/chanpin/" + id.left(2) + L"/" + id + L".jpg";
+	}
+
+	xstring GetGuid()
+	{
+		return publiccode::GetGuid();
+	}
+
+	int getItemHeadRow(xcell dw_obj)
+	{
+		int rowHeader = -1;
+		int rowCount = dw_obj.GetValidRow();
+		for (int row = 1; row <= rowCount; row++)
+		{
+			if (dw_obj.GetItemString(row, 0) == L"鏍囬") return row;
+			if (dw_obj.GetItemString(row, 1) == L"SKUID" || dw_obj.GetItemString(row, 2) == L"SKUID") return row;
+		}
+		return -1;
+	}
+
+	double calcVol(xstring volDesc)
+	{
+		xstring sl = L"";
+		xstring sw = L"";
+		xstring sh = L"";
+
+		xstring val = volDesc;
+		val = val.replace(L"x", L"X");
+		val = val.replace(L"*", L"X");
+
+		//parse length
+		int pos = val.find(L"X");
+		if (pos >= 0)
+			sl = val.left(pos);
+		else
+			sl = val;
+
+		//parse width
+		if (pos >= 0)
+		{
+			val = val.mid(pos + 1, 9999);
+			pos = val.find(L"X");
+			if (pos >= 0)
+				sw = val.left(pos);
+			else
+				sw = val;
+		}
+
+		//parse height
+		if (pos >= 0)
+		{
+			val = val.mid(pos + 1, 9999);
+			pos = val.find(L"X");
+			if (pos >= 0)
+				sh = val.left(pos);
+			else
+				sh = val;
+		}
+
+		double ret = 0.0;
+		if (sw == L"") ret = sl.toDouble();
+		else if (sh == L"") ret = sl.toDouble() * sw.toDouble();
+		else ret = sl.toDouble() * sw.toDouble() * sh.toDouble();
+		return ret;
+	}
+
+	int ShowImageOne(ximageview im, xstring str, xstring tm)
+	{
+		int spos = str.find(tm + L":");
+		if (spos >= 0)
+		{
+			int pos = (str + L";").find(L";", spos + 1);
+			int pos0 = spos + tm.length() + 1;
+			xstring guids = str.mid(pos0, pos - pos0);
+			while (true)
+			{
+				xstring guid = guids;
+				if (guids.find(L",L") >= 0)
+				{
+					guid = guids.left(guids.find(L",L"));
+					guids = guids.mid(guids.find(L",L") + 1, 99999);
+				}
+				else
+				{
+					guid = guids;
+					guids = L"";
+				}
+				if (guid != L"")
+				{
+					xstring picname = GetImageUrl(guid);
+					im.AddImages(picname, L"");
+					return 1;
+				}
+				if (guids == L"") break;
+			}
+		}
+		return 1;
+	}
+
+	int ShowImage(xstring str, xstring tm)
+	{
+		ximageview im = GetControl(L"frame:im1");
+
+		int spos = str.find(tm + L":");
+		if (spos >= 0)
+		{
+			int pos = (str + L";").find(L";", spos + 1);
+			int pos0 = spos + tm.length() + 1;
+			xstring guids = str.mid(pos0, pos - pos0);
+			while (true)
+			{
+				xstring guid = guids;
+				if (guids.find(L",L") >= 0)
+				{
+					guid = guids.left(guids.find(L",L"));
+					guids = guids.mid(guids.find(L",L") + 1, 99999);
+				}
+				else
+				{
+					guid = guids;
+					guids = L"";
+				}
+				if (guid != L"")
+				{
+					xstring goodno = L"瀹㈡埛鍥剧墖";
+					if (tm == L"supplier-photo") goodno = L"渚涘簲鍟嗗浘鐗�";
+					xstring picname = GetImageUrl(guid);//"/business/products/chanpin/"+guid.left(2)+L"/"+guid+L".jpg";
+					im.AddImages(picname, goodno);
+				}
+				if (guids == L"") break;
+			}
+		}
+		return 1;
+	}
+
+	xstring getImageList(xstring idlist)
+	{
+		xstring strs = idlist.trim();
+		xstring str = L"";
+		xstring fstr = L"";
+		while (strs != L"")
+		{
+			int pos = strs.find(L",L");
+			if (pos < 0)
+			{
+				str = strs;
+				strs = L"";
+			}
+			else
+			{
+				str = strs.left(pos);
+				strs = strs.mid(pos + 1, 9999);
+			}
+			if (fstr == L"")
+				fstr = GetImageUrl(str);
+			else
+				fstr += L",L" + GetImageUrl(str);
+		}
+		return fstr;
+	}
+
+	xstring GetSaleFullData(xcell cell)
+	{
+		xstring content = L"";
+		xstring base = L"";
+		base += L"<QuoteNo>" + getBaseItem(cell, L"鎶ヤ环鍗曞彿:") + L"</QuoteNo>";
+		base += L"<ExpDate>" + getBaseItem(cell, L"鎶ヤ环鎴鏃ユ湡锛�") + L"</ExpDate>";
+		base += L"<PrjName>" + getBaseItem(cell, L"椤圭洰鍚嶇О:") + L"</PrjName>";
+		base += L"<QuoteDate>" + dw_base.GetItemString(1, L"QuoteDate") + L"</QuoteDate>";
+
+		int startRow = getItemHeadRow(cell);
+
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return L"";
+		startRow++;
+
+		int colItemNo = getItemCol(cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyerPrice = getItemCol(cell, startRow - 1, L"閲囪喘浠�,閲囪喘浠锋牸");
+		int colCustomerImage = getItemCol(cell, startRow - 1, L"Photo,鍥剧墖");
+		int colSKUID = getItemCol(cell, startRow - 1, L"SKUID");
+		int colSaleRemark = getItemCol(cell, startRow - 1, L"涓氬姟To閲囪喘澶囨敞");
+
+		int colBuyerRemark = getItemCol(cell, startRow - 1, L"閲囪喘To涓氬姟澶囨敞");
+		int colFactoryImage = getItemCol(cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int colGWT = getItemCol(cell, startRow - 1, L"姣涢噸,姣涢噸(KG)L");
+		int colNWT = getItemCol(cell, startRow - 1, L"鍑�閲�,鍑�閲�(KG)L");
+		int colVolDesc = getItemCol(cell, startRow - 1, L"浣撶Н鎻忚堪,闀縓瀹絏楂�,闀縓瀹絏楂�(CM)L");
+		int colVol = getItemCol(cell, startRow - 1, L"浣撶Н,浣撶Н(M3)L");
+		int col40HQ = getItemCol(cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+
+		int colSupplier1 = getItemCol(cell, startRow - 1, L"渚涘簲鍟�1");
+		int colSupplier = getItemCol(cell, startRow - 1, L"渚涘簲鍟�");
+		int colPOPrice1 = getItemCol(cell, startRow - 1, L"浠锋牸1");
+		int colPOPrice = getItemCol(cell, startRow - 1, L"浠锋牸");
+
+		int colInnerOuter = getItemCol(cell, startRow - 1, L"瑁呯鏁�(鍐�/澶�)L");
+		int colItemQty = getItemCol(cell, startRow - 1, L"鏁伴噺,Qty");
+		int colPackage = getItemCol(cell, startRow - 1, L"Package,鍖呰鏂瑰紡");
+		int colBuyer = getItemCol(cell, startRow - 1, L"閲囪喘浜哄憳");
+		int colRemark = getItemCol(cell, startRow - 1, L"Remarks");
+		int colFOBPrice = getItemCol(cell, startRow - 1, L"FOB Price,FOB Price(USD),Fob Price");
+
+
+		int LastRow = cell.GetValidRow();
+		xstring sdate = publiccode::GetCurrentDate();
+
+		xstring rowid = L"";
+		for (int row = startRow; row <= LastRow; row++)
+		{
+			bool bextern = false;
+			if (cell.GetItemString(row, colItemName) == L"" &&
+				cell.GetItemString(row, colItemSpec) == L"")
+			{
+
+			}
+
+			xstring itemStr = L"";
+			rowid = getRowID(cell, row);
+			itemStr += L"<RowID>" + getRowID(cell, row) + L"</RowID>";
+			itemStr += L"<SKUID>" + cell.GetItemString(row, colSKUID) + L"</SKUID>";
+			itemStr += L"<customer-photo>" + getRowTerm(cell, row, L"customer-photo") + L"</customer-photo>";
+			itemStr += L"<supplier-photo>" + getRowTerm(cell, row, L"supplier-photo") + L"</supplier-photo>";
+			itemStr += L"<customer-photo-url>" + getImageList(getRowTerm(cell, row, L"customer-photo")) + L"</customer-photo-url>";
+			itemStr += L"<supplier-photo-url>" + getImageList(getRowTerm(cell, row, L"supplier-photo")) + L"</supplier-photo-url>";
+			itemStr += L"<ItemNo>" + cell.GetItemString(row, colItemNo) + L"</ItemNo>";
+			itemStr += L"<CustomItemNo>" + cell.GetItemString(row, colCustomerItemNo) + L"</CustomItemNo>";
+			itemStr += L"<ItemName>" + cell.GetItemString(row, colItemName) + L"</ItemName>";
+			itemStr += L"<ItemCName>" + cell.GetItemString(row, colItemCName) + L"</ItemCName>";
+			itemStr += L"<ItemSpec>" + cell.GetItemString(row, colItemSpec) + L"</ItemSpec>";
+			itemStr += L"<CustomerImage>" + cell.GetItemString(row, colCustomerImage) + L"</CustomerImage>";
+			itemStr += L"<BuyerPrice>" + cell.GetItemString(row, colBuyerPrice) + L"</BuyerPrice>";
+			itemStr += L"<SaleRemark>" + cell.GetItemString(row, colSaleRemark) + L"</SaleRemark>";
+
+			itemStr += L"<BuyerRemark>" + cell.GetItemString(row, colBuyerRemark) + L"</BuyerRemark>";
+			itemStr += L"<FactoryImage>" + cell.GetItemString(row, colFactoryImage) + L"</FactoryImage>";
+			itemStr += L"<GWT>" + cell.GetItemString(row, colGWT) + L"</GWT>";
+			itemStr += L"<NWT>" + cell.GetItemString(row, colNWT) + L"</NWT>";
+			itemStr += L"<VolDesc>" + cell.GetItemString(row, colVolDesc) + L"</VolDesc>";
+			itemStr += L"<Vol>" + cell.GetItemString(row, colVol) + L"</Vol>";
+			itemStr += L"<F40HQ>" + cell.GetItemString(row, col40HQ) + L"</F40HQ>";
+			itemStr += L"<Packing>" + cell.GetItemString(row, colInnerOuter) + L"</Packing>";
+			itemStr += L"<Quantity>" + cell.GetItemString(row, colItemQty) + L"</Quantity>";
+			itemStr += L"<Package>" + cell.GetItemString(row, colPackage) + L"</Package>";
+			itemStr += L"<Buyer>" + cell.GetItemString(row, colBuyer) + L"</Buyer>";
+			itemStr += L"<RemarkS>" + cell.GetItemString(row, colRemark) + L"</RemarkS>";
+			itemStr += L"<FOBPrice>" + cell.GetItemString(row, colFOBPrice) + L"</FOBPrice>";
+
+
+			itemStr += L"<PurchedDate>" + sdate + L"</PurchedDate>";
+			itemStr += L"<EnquiryLineID>" + getRowTerm(dw_cell, row, L"EnquiryLineID") + L"</EnquiryLineID>";
+			content += L"<Item>" + itemStr + L"</Item>";
+		}
+		content = L"<data>" + base + content + L"</data>";
+
+		return content;
+	}
+
+	xstring GetSaleFullData(xcell cell, KXMLDOMNodeList ts)
+	{
+		xstring content = L"";
+		xstring base = L"";
+		base += L"<QuoteNo>" + getBaseItem(cell, L"鎶ヤ环鍗曞彿:") + L"</QuoteNo>";
+		base += L"<ExpDate>" + getBaseItem(cell, L"鎶ヤ环鎴鏃ユ湡锛�") + L"</ExpDate>";
+		base += L"<PrjName>" + getBaseItem(cell, L"椤圭洰鍚嶇О:") + L"</PrjName>";
+		base += L"<QuoteDate>" + dw_base.GetItemString(1, L"QuoteDate") + L"</QuoteDate>";
+
+		int startRow = getItemHeadRow(cell);
+
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return L"";
+		startRow++;
+
+		int colItemNo = getItemCol(cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyerPrice = getItemCol(cell, startRow - 1, L"閲囪喘浠�,閲囪喘浠锋牸");
+		int colCustomerImage = getItemCol(cell, startRow - 1, L"Photo,鍥剧墖");
+		int colSKUID = getItemCol(cell, startRow - 1, L"SKUID");
+		int colSaleRemark = getItemCol(cell, startRow - 1, L"涓氬姟To閲囪喘澶囨敞");
+
+		int colBuyerRemark = getItemCol(cell, startRow - 1, L"閲囪喘To涓氬姟澶囨敞");
+		int colFactoryImage = getItemCol(cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int colGWT = getItemCol(cell, startRow - 1, L"姣涢噸,姣涢噸(KG)L");
+		int colNWT = getItemCol(cell, startRow - 1, L"鍑�閲�,鍑�閲�(KG)L");
+		int colVolDesc = getItemCol(cell, startRow - 1, L"浣撶Н鎻忚堪,闀縓瀹絏楂�,闀縓瀹絏楂�(CM)L");
+		int colVol = getItemCol(cell, startRow - 1, L"浣撶Н,浣撶Н(M3)L");
+		int col40HQ = getItemCol(cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+
+		int colPOPrice = getItemCol(cell, startRow - 1, L"浠锋牸");
+		int colSupplier = getItemCol(cell, startRow - 1, L"渚涘簲鍟�");
+		int colPOPrice1 = getItemCol(cell, startRow - 1, L"浠锋牸1");
+		int colSupplier1 = getItemCol(cell, startRow - 1, L"渚涘簲鍟�1");
+		int colPOPrice2 = getItemCol(cell, startRow - 1, L"浠锋牸2");
+		int colSupplier2 = getItemCol(cell, startRow - 1, L"渚涘簲鍟�2");
+		int colPOPrice3 = getItemCol(cell, startRow - 1, L"浠锋牸3");
+		int colSupplier3 = getItemCol(cell, startRow - 1, L"渚涘簲鍟�3");
+		int colBOMType = getItemCol(cell, startRow - 1, L"绫诲瀷");
+		int colBOMType1 = getItemCol(cell, startRow - 1, L"绫诲瀷1");
+		int colBOMType2 = getItemCol(cell, startRow - 1, L"绫诲瀷2");
+		int colBOMType3 = getItemCol(cell, startRow - 1, L"绫诲瀷3");
+
+		int colInnerOuter = getItemCol(cell, startRow - 1, L"瑁呯鏁�(鍐�/澶�)L");
+		int colItemQty = getItemCol(cell, startRow - 1, L"鏁伴噺,Qty");
+		int colPackage = getItemCol(cell, startRow - 1, L"Package,鍖呰鏂瑰紡");
+		int colBuyer = getItemCol(cell, startRow - 1, L"閲囪喘浜哄憳");
+		int colRemark = getItemCol(cell, startRow - 1, L"Remarks");
+		int colFOBPrice = getItemCol(cell, startRow - 1, L"FOB Price,FOB Price(USD),Fob Price");
+
+
+		int LastRow = cell.GetValidRow();
+		xstring sdate = publiccode::GetCurrentDate();
+
+		int len = ts.length();
+
+		//xstring content = L"";
+		//xstring sdate = publiccode::GetCurrentDate();
+		for (int k = 0; k < len; k++)
+		{
+			KXMLDOMNode node = ts.item(k);
+			xstring id = node.selectSingleNode(L"RowID").text();
+			int row = LookupCellRow(id);
+			if (row < 1) continue;
+
+			xstring itemStr = L"";
+			itemStr += L"<RowID>" + getRowID(cell, row) + L"</RowID>";
+			itemStr += L"<SKUID>" + cell.GetItemString(row, colSKUID) + L"</SKUID>";
+			itemStr += L"<customer-photo>" + getRowTerm(cell, row, L"customer-photo") + L"</customer-photo>";
+			itemStr += L"<supplier-photo>" + getRowTerm(cell, row, L"supplier-photo") + L"</supplier-photo>";
+			itemStr += L"<ItemNo>" + cell.GetItemString(row, colItemNo) + L"</ItemNo>";
+			itemStr += L"<CustomItemNo>" + cell.GetItemString(row, colCustomerItemNo) + L"</CustomItemNo>";
+			itemStr += L"<ItemName>" + cell.GetItemString(row, colItemName) + L"</ItemName>";
+			itemStr += L"<ItemCName>" + cell.GetItemString(row, colItemCName) + L"</ItemCName>";
+			itemStr += L"<ItemSpec>" + cell.GetItemString(row, colItemSpec) + L"</ItemSpec>";
+			itemStr += L"<CustomerImage>" + cell.GetItemString(row, colCustomerImage) + L"</CustomerImage>";
+			itemStr += L"<BuyerPrice>" + cell.GetItemString(row, colBuyerPrice) + L"</BuyerPrice>";
+			itemStr += L"<SaleRemark>" + cell.GetItemString(row, colSaleRemark) + L"</SaleRemark>";
+
+			itemStr += L"<BuyerRemark>" + cell.GetItemString(row, colBuyerRemark) + L"</BuyerRemark>";
+			itemStr += L"<FactoryImage>" + cell.GetItemString(row, colFactoryImage) + L"</FactoryImage>";
+			itemStr += L"<GWT>" + cell.GetItemString(row, colGWT) + L"</GWT>";
+			itemStr += L"<NWT>" + cell.GetItemString(row, colNWT) + L"</NWT>";
+			itemStr += L"<VolDesc>" + cell.GetItemString(row, colVolDesc) + L"</VolDesc>";
+			itemStr += L"<Vol>" + cell.GetItemString(row, colVol) + L"</Vol>";
+			itemStr += L"<F40HQ>" + cell.GetItemString(row, col40HQ) + L"</F40HQ>";
+			itemStr += L"<Packing>" + cell.GetItemString(row, colInnerOuter) + L"</Packing>";
+			itemStr += L"<Quantity>" + cell.GetItemString(row, colItemQty) + L"</Quantity>";
+			itemStr += L"<Package>" + cell.GetItemString(row, colPackage) + L"</Package>";
+			itemStr += L"<Buyer>" + cell.GetItemString(row, colBuyer) + L"</Buyer>";
+			itemStr += L"<RemarkS>" + cell.GetItemString(row, colRemark) + L"</RemarkS>";
+			itemStr += L"<FOBPrice>" + cell.GetItemString(row, colFOBPrice) + L"</FOBPrice>";
+
+			itemStr += L"<Supplier>" + cell.GetItemString(row, colSupplier) + L"</Supplier>";
+			itemStr += L"<Supplier1>" + cell.GetItemString(row, colSupplier1) + L"</Supplier1>";
+			itemStr += L"<Supplier2>" + cell.GetItemString(row, colSupplier2) + L"</Supplier2>";
+			itemStr += L"<Supplier3>" + cell.GetItemString(row, colSupplier3) + L"</Supplier3>";
+			itemStr += L"<POPrice>" + cell.GetItemString(row, colPOPrice) + L"</POPrice>";
+			itemStr += L"<POPrice1>" + cell.GetItemString(row, colPOPrice1) + L"</POPrice1>";
+			itemStr += L"<POPrice2>" + cell.GetItemString(row, colPOPrice2) + L"</POPrice2>";
+			itemStr += L"<POPrice3>" + cell.GetItemString(row, colPOPrice3) + L"</POPrice3>";
+
+			itemStr += L"<BOMType>" + cell.GetItemString(row, colBOMType) + L"</BOMType>";
+			itemStr += L"<BOMType1>" + cell.GetItemString(row, colBOMType1) + L"</BOMType1>";
+			itemStr += L"<BOMType2>" + cell.GetItemString(row, colBOMType2) + L"</BOMType2>";
+			itemStr += L"<BOMType3>" + cell.GetItemString(row, colBOMType2) + L"</BOMType3>";
+			itemStr += L"<PurchedDate>" + sdate + L"</PurchedDate>";
+			itemStr += L"<EnquiryLineID>" + getRowTerm(cell, row, L"EnquiryLineID") + L"</EnquiryLineID>";
+
+			int lastrow = row;
+
+			while (true)
+			{
+				row++;
+				if (cell.GetItemString(row, colItemName) != L"" || cell.GetItemString(row, colItemSpec) != L"") break;
+				if (cell.GetItemString(row, colSupplier) == L"")break;
+				xstring extStr = L"";
+				extStr += L"<Supplier>" + cell.GetItemString(row, colSupplier) + L"</Supplier>";
+				extStr += L"<Supplier1>" + cell.GetItemString(row, colSupplier1) + L"</Supplier1>";
+				extStr += L"<Supplier2>" + cell.GetItemString(row, colSupplier2) + L"</Supplier2>";
+				extStr += L"<Supplier3>" + cell.GetItemString(row, colSupplier3) + L"</Supplier3>";
+				extStr += L"<POPrice>" + cell.GetItemString(row, colPOPrice) + L"</POPrice>";
+				extStr += L"<POPrice1>" + cell.GetItemString(row, colPOPrice1) + L"</POPrice1>";
+				extStr += L"<POPrice2>" + cell.GetItemString(row, colPOPrice2) + L"</POPrice2>";
+				extStr += L"<POPrice3>" + cell.GetItemString(row, colPOPrice3) + L"</POPrice3>";
+
+				extStr += L"<BOMType>" + cell.GetItemString(row, colBOMType) + L"</BOMType>";
+				extStr += L"<BOMType1>" + cell.GetItemString(row, colBOMType1) + L"</BOMType1>";
+				extStr += L"<BOMType2>" + cell.GetItemString(row, colBOMType2) + L"</BOMType2>";
+				extStr += L"<BOMType3>" + cell.GetItemString(row, colBOMType2) + L"</BOMType3>";
+
+				itemStr += L"<ExtItem>" + extStr + L"</ExtItem>"; //澶囩敤閲囪喘淇℃伅
+				xstring eid = GetGuid();
+				setRowTerm(cell, row, L"EnquiryLineID", eid);
+				itemStr += L"<EnquiryLineID>" + getRowTerm(cell, row, L"EnquiryLineID") + L"</EnquiryLineID>";
+			}
+			content += L"<Item>" + itemStr + L"</Item>";
+		}
+		content = L"<data>" + base + content + L"</data>";
+
+		return content;
+	}
+
+	int OnPrint()
+	{
+
+		if (dw_base.GetItemString(1, L"QuoteNo") == L"")
+		{
+			alert(L"璇峰厛淇濆瓨鏁版嵁!");
+			return 1;
+		}
+
+		xaserverarg argx;
+		argx.AddArg(L"QuoteNo", dw_base.GetItemString(1, L"QuoteNo"));
+		int p1 = argx;
+		if (dw_base.GetItemString(1, L"QuoteNo") != L"")
+		{
+			OpenWindow(L"dev:xpage[xmQuoteBillList.vx]", p1);
+		}
+		if (argx.GetArgString(L"action") != L"ok") return 1;
+
+		xstring printStr = argx.GetArgString(L"items");
+
+		xaserverarg arg ;
+		
+		arg.AddArg(L"DataUrl", L"/sale/data/Quote3/print/mydata");
+		arg.AddArg(L"EntityName", L"Quote");
+		arg.AddArg(L"EntityID", entityID + printStr);
+		arg.AddArg(L"EntityNo", dw_base.GetItemString(1, L"QuoteNo"));
+		trace(L"*******" + entityID + printStr + L"*******");
+		openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", &arg);
+
+		/*	xaserverarg arg=new xaserverarg;
+			
+			arg.AddArg(L"EntityName",L"Quote",L"");
+			arg.AddArg(L"EntityID",dw_base.GetItemString(1,L"QuoteID"),L"");
+			arg.AddArg(L"EntityNo",dw_base.GetItemString(1,L"QuoteNo"),L"");
+			trace(dw_base.GetItemString(1,L"QuoteID")+L"***"+dw_base.GetItemString(1,L"QuoteNo"));
+			int p = arg.ptr_native_;
+			openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", p);*/
+
+		return 1;
+	}
+
+	int RowChanged(int row)
+	{
+		ximageview im = GetControl(L"frame:im1");
+		im.Reset();
+
+		int startRow = getItemHeadRow(dw_cell);
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return 1;
+		if (row <= startRow) return 1;
+
+		int colCustomerPhoto = getItemCol(dw_cell, startRow, L"Photo,Customer Photo");
+		xstring ls_photo = dw_cell.GetItemString(row, colCustomerPhoto);
+		while (ls_photo == L"-")
+		{
+			if (row - 1 < startRow) break;
+			row = row - 1;
+			ls_photo = dw_cell.GetItemString(row, colCustomerPhoto);
+		}
+		if (row <= startRow) return 1;
+
+		xstring str = dw_cell.GetItemString(row, 0);
+		ShowImage(str, L"customer-photo");
+		ShowImage(str, L"supplier-photo");
+
+		im.Redraw();
+
+		return 1;
+	}
+
+	xstring getBaseItem(xcell dw_cell, xstring colname)
+	{
+		int row = 0;
+		int col = 0;
+		int vcol = 0;
+		int vrow = dw_cell.GetValidRow();
+		int scol = dw_cell.GetValidCol();
+		for (row = 1; row <= vrow; row++)
+		{
+			vcol = dw_cell.GetValidCol(row);
+			if (vcol < scol) vcol++;
+			for (col = 1; col <= vcol; col++)
+			{
+				if (dw_cell.GetItemString(row, col) == colname)
+				{
+					return dw_cell.GetItemString(row, col + 1);
+				}
+			}
+		}
+		return L"";
+	}
+
+	void setBaseItem(xcell dw_cell, xstring colname, xstring val)
+	{
+		int row = 0;
+		int col = 0;
+		int vcol = 0;
+		int vrow = dw_cell.GetValidRow();
+		int scol = dw_cell.GetValidCol();
+		for (row = 1; row <= vrow; row++)
+		{
+			vcol = dw_cell.GetValidCol(row);
+			if (vcol < scol) vcol++;
+			for (col = 1; col <= vcol; col++)
+			{
+				if (dw_cell.GetItemString(row, col) == colname)
+				{
+					dw_cell.SetItemString(row, col + 1, val);
+					dw_cell.Redraw();
+				}
+			}
+		}
+	}
+
+	int getItemCol(xcell dw_obj, int row, xstring head)
+	{
+		xstring fullhead = L",L" + head + L",L";
+		int headRow = row;
+		int colCount = dw_obj.GetValidCol(headRow);
+		for (int col = 1; col <= colCount; col++)
+		{
+			if (fullhead.find(L",L" + dw_obj.GetItemString(headRow, col) + L",L") >= 0) return col;
+		}
+		return -1;
+	}
+
+
+	int setRowProp(xcell dw_obj, int row, xstring prop, xstring val)
+	{
+		prop = prop.trim();
+		if (prop.left(1) != L"[") prop = L"[" + prop + L"]";
+		xstring str = dw_obj.GetItemString(row, 0);
+		if (str.find(prop + L":" + val + L";") >= 0) return 1;
+
+		if (str.find(prop + L":") < 0)
+		{
+			if (str == L"")
+				str = prop + L":" + val + L";";
+			else
+				str += prop + L":" + val + L";";
+			dw_obj.SetItemString(row, 0, str);
+		}
+		else
+		{
+			str = str.mid(str.find(prop + L":") + prop.length() + 1, 9999);
+			xstring right = L"";
+			xstring left = str.left(str.find(prop + L":") + prop.length() + 1);
+			if (str.find(L";") >= 0)
+				right = str.mid(str.find(L";") + 1, 9999);
+			else 	if (str.find(L",L") >= 0)
+				right = str.mid(str.find(L",L") + 1, 9999);
+			str = left + val + L";" + right;
+			//alert(str);
+			dw_obj.SetItemString(row, 0, str);
+		}
+		return 1;
+	}
+
+	xstring getRowProp(xcell dw_obj, int row, xstring prop)
+	{
+		prop = prop.trim();
+		if (prop.left(1) != L"[") prop = L"[" + prop + L"]";
+		xstring str = dw_obj.GetItemString(row, 0);
+		if (str.find(prop + L":") >= 0)
+		{
+			str = str.mid(str.find(prop + L":") + prop.length() + 1, 9999);
+			if (str.find(L";") >= 0)
+				str = str.left(str.find(L";"));
+			else if (str.find(L",L") >= 0)
+				str = str.left(str.find(L",L"));
+			return str;
+		}
+		return L"";
+	}
+
+	int ensureRowID()
+	{
+		int startRow = getItemHeadRow(dw_cell);
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return 0;
+		startRow++;
+
+		int colItemNo = getItemCol(dw_cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyerPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�,閲囪喘浠锋牸");
+
+		int LastRow = dw_cell.GetValidRow();
+		for (int row = startRow; row <= LastRow; row++)
+		{
+			if (dw_cell.GetItemString(row, colItemName) == L"" &&
+				dw_cell.GetItemString(row, colItemCName) == L"") break;
+			ensureRowID(dw_cell, row);
+		}
+		return 1;
+	}
+
+	int LookupRow(xstring rowid)
+	{
+		int rowcount = dw_goods.GetRowCount();
+		for (int row = 1; row <= rowcount; row++)
+		{
+			if (dw_goods.GetGuid(row) == rowid) return row;
+		}
+		return 0;
+	}
+
+	int LookupCellRow(xcell cell, xstring rowid)
+	{
+		int startRow = getItemHeadRow(cell);
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return 0;
+		startRow++;
+
+		int LastRow = cell.GetValidRow();
+		for (int row = startRow; row <= LastRow; row++)
+		{
+			if (getRowID(cell, row) == rowid) return row;
+		}
+		return 0;
+	}
+
+	int LookupCellRow(xstring rowid)
+	{
+		return LookupCellRow(dw_cell, rowid);
+	}
+
+	int ensureRowID(xcell dw_obj, int row)
+	{
+		xstring str = dw_obj.GetItemString(row, 0);
+		if (str.find(L"rowid:") < 0)
+		{
+			xstring rowid = ViewObject::GetGuid();
+			if (str == L"")
+				str = L"rowid:" + rowid + L";";
+			else
+				str += L";rowid:" + rowid + L";";
+			//alert(str);
+			dw_obj.SetItemString(row, 0, str);
+		}
+		return 1;
+	}
+
+	xstring getRowID(xcell dw_obj, int row)
+	{
+		xstring str = dw_obj.GetItemString(row, 0);
+		if (str.find(L"rowid:") >= 0)
+		{
+			str = str.mid(str.find(L"rowid:") + 6, 99999);
+			if (str.find(L";") >= 0)
+				str = str.left(str.find(L";"));
+			else if (str.find(L",L") >= 0)
+				str = str.left(str.find(L",L"));
+			return str;
+		}
+		return L"";
+	}
+
+	xstring getRowTerm(xcell dw_obj, int row, xstring tm)
+	{
+		xstring str = dw_obj.GetItemString(row, 0);
+		if (str.find(tm + L":") >= 0)
+		{
+			str = str.mid(str.find(tm + L":") + tm.length() + 1, 99999);
+			if (str.find(L";") >= 0) 	str = str.left(str.find(L";"));
+			return str;
+		}
+		return L"";
+	}
+
+	int setRowTerm(xcell dw_obj, int row, xstring tm, xstring val)
+	{
+		xstring str = dw_obj.GetItemString(row, 0);
+		if (str.find(tm + L":") >= 0)
+		{
+			int pos0 = str.find(tm + L":");
+			xstring left = str.left(pos0);
+			if (left != L"" && left.right(1) != L";") left += L";";
+
+			xstring right = L"";
+			int pos1 = str.find(L";", pos0 + 1);
+			if (pos1 >= 0)right = str.mid(pos1, 99999);
+			str = left + tm + L":" + val + right;
+		}
+		else
+		{
+			if (str.right(1) == L";")
+				str += tm + L":" + val;
+			else
+				str += L";" + tm + L":" + val;
+		}
+		trace(L"\r\nterm:" + str + L"\r\n");
+		dw_obj.SetItemString(row, 0, str);
+		return 1;
+	}
+
+	int resetRowTerm(xcell dw_obj, int row, xstring tm)
+	{
+		xstring str = dw_obj.GetItemString(row, 0);
+		if (str.find(tm + L":") >= 0)
+		{
+			int pos0 = str.find(tm + L":");
+			xstring left = str.left(pos0);
+			if (left != L"" && left.right(1) != L";") left += L";";
+
+			xstring right = L"";
+			int pos1 = str.find(L";", pos0 + 1);
+			if (pos1 >= 0)right = str.mid(pos1, 99999);
+			str = left + right;
+		}
+		dw_obj.SetItemString(row, 0, str);
+		return 1;
+	}
+
+	//鐢熸垚杩斿洖閿�鍞汉鍛樼殑閲囪喘浜у搧淇℃伅
+	xstring makeMessageBacktoSaler(xstring myurl)
+	{
+		int startRow = getItemHeadRow(dw_cell);
+
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return L"";
+		startRow++;
+
+		int colItemNo = getItemCol(dw_cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyerPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�,閲囪喘浠锋牸");
+
+		int colBuyerRemark = getItemCol(dw_cell, startRow - 1, L"閲囪喘To涓氬姟澶囨敞");
+		int colFactoryImage = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int colGWT = getItemCol(dw_cell, startRow - 1, L"姣涢噸,姣涢噸(KG)L");
+		int colNWT = getItemCol(dw_cell, startRow - 1, L"鍑�閲�,鍑�閲�(KG)L");
+		int colVolDesc = getItemCol(dw_cell, startRow - 1, L"浣撶Н鎻忚堪,闀縓瀹絏楂�,闀縓瀹絏楂�(CM)L");
+		int colVol = getItemCol(dw_cell, startRow - 1, L"浣撶Н,浣撶Н(M3)L");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+
+		int colSupplier = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�");
+		int colSupplier1 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�1");
+		int colPOPrice = getItemCol(dw_cell, startRow - 1, L"浠锋牸");
+		int colPOPrice1 = getItemCol(dw_cell, startRow - 1, L"浠锋牸1");
+		int colProductInfo = getItemCol(dw_cell, startRow - 1, L"涓氬姟閮ㄤ骇鍝佷俊鎭�");
+		int colProductInfo1 = getItemCol(dw_cell, startRow - 1, L"閲囪喘閮ㄤ骇鍝佷俊鎭�");
+
+		int LastRow = dw_cell.GetValidRow();
+		xstring content = L"";
+
+		xstring sdate = publiccode::GetCurrentDate();
+		for (int row = startRow; row <= LastRow; row++)
+		{
+			if (dw_cell.GetItemString(row, colItemName) == L"" &&
+				dw_cell.GetItemString(row, colItemSpec) == L"") break;
+
+			xstring itemStr = L"";
+			itemStr += L"<RowID>" + getRowID(dw_cell, row) + L"</RowID>";
+			itemStr += L"<ItemNo>" + dw_cell.GetItemString(row, colItemNo) + L"</ItemNo>";
+			itemStr += L"<CustomerItemNo>" + dw_cell.GetItemString(row, colCustomerItemNo) + L"</CustomerItemNo>";
+			itemStr += L"<ItemName>" + dw_cell.GetItemString(row, colItemName) + L"</ItemName>";
+			itemStr += L"<ItemCName>" + dw_cell.GetItemString(row, colItemCName) + L"</ItemCName>";
+			itemStr += L"<ItemSpec>" + dw_cell.GetItemString(row, colItemSpec) + L"</ItemSpec>";
+			itemStr += L"<BuyerPrice>" + dw_cell.GetItemString(row, colBuyerPrice) + L"</BuyerPrice>";
+			itemStr += L"<ProductInfo>" + dw_cell.GetItemString(row, colProductInfo) + L"</ProductInfo>";
+			itemStr += L"<ProductInfo1>" + dw_cell.GetItemString(row, colProductInfo1) + L"</ProductInfo1>";
+
+			if (dw_cell.GetItemString(row, colBuyerPrice) == L"") return L"閲囪喘浠锋牸娌℃湁褰曞叆";
+			if (dw_cell.GetItemString(row, colGWT) == L"") return L"姣涢噸娌℃湁褰曞叆";
+			if (dw_cell.GetItemString(row, colNWT) == L"") return L"鍑�閲嶆病鏈夊綍鍏�";
+			if (dw_cell.GetItemString(row, colVolDesc) == L"") return L"闀縓瀹絏楂樻病鏈夊綍鍏�";
+			if (dw_cell.GetItemString(row, colFactoryImage) == L"") return L"鍥剧墖娌℃湁褰曞叆";
+
+			if (dw_cell.GetItemString(row, colSupplier) == L"")return L"渚涘簲鍟嗘病鏈夊綍鍏�";
+			if (dw_cell.GetItemString(row, colPOPrice) == L"")return L"閲囪喘浠锋牸娌℃湁褰曞叆";
+
+			if (dw_cell.GetItemString(row, colPOPrice1) != L"")
+			{
+				if (dw_cell.GetItemString(row, colSupplier1) == L"") return L"渚涘簲鍟�1娌℃湁褰曞叆";
+			}
+			if (dw_cell.GetItemString(row, colSupplier1) != L"")
+			{
+				if (dw_cell.GetItemString(row, colPOPrice1) == L"") return L"閲囪喘浠锋牸1娌℃湁褰曞叆";
+			}
+			itemStr += L"<BuyerRemark>" + dw_cell.GetItemString(row, colBuyerRemark) + L"</BuyerRemark>";
+			itemStr += L"<FactoryImage>" + dw_cell.GetItemString(row, colFactoryImage) + L"</FactoryImage>";
+			itemStr += L"<GWT>" + dw_cell.GetItemString(row, colGWT) + L"</GWT>";
+			itemStr += L"<NWT>" + dw_cell.GetItemString(row, colNWT) + L"</NWT>";
+			itemStr += L"<VolDesc>" + dw_cell.GetItemString(row, colVolDesc) + L"</VolDesc>";
+			itemStr += L"<Vol>" + dw_cell.GetItemString(row, colVol) + L"</Vol>";
+			itemStr += L"<F40HQ>" + dw_cell.GetItemString(row, col40HQ) + L"</F40HQ>";
+
+			itemStr += L"<PurchedDate>" + sdate + L"</PurchedDate>";
+			itemStr += L"<EnquiryLineID>" + getRowTerm(dw_cell, row, L"EnquiryLineID") + L"</EnquiryLineID>";
+			content += L"<Item>" + itemStr + L"</Item>";
+		}
+		xstring newEntityItemID = ViewObject::GetGuid();
+		content = L"<data id='" + entityID + L"' itemid='" + newEntityItemID + L"' action='purched'>" + content + L"</data>";
+
+		return content;
+	}
+
+	int ProcessSendMessage(xstring myurl, xstring param, xstring content, xstring datacontent, bool balert = false)
+	{
+		xaserverarg	 arg ;
+		arg.setNativePointer(xaserverarg::CreateInstance());
+		arg.AddArg(L"myurl", myurl);
+		arg.AddArg(L"param", param);
+		arg.AddArg(L"content", content);
+		arg.AddArg(L"datacontent", datacontent);
+
+		//trace(content);
+
+		xml x ;
+		
+		if (xurl::get(L"/sale/data/Thing/business/message/add", arg.GetString(), x) != 1)
+		{
+			xstring error = x.text();
+			if (balert)alert((xstring)L"error:" + x.xml());
+			trace(error);
+			return -1;
+		}
+		else
+		{
+			//trace(x.xml());
+			if (balert)
+				alert(x.text());
+		}
+		return 1;
+	}
+
+	int makeMessage(xstring myurl)
+	{
+		if (myurl == L"/task/quote/purchar/backtosaler")
+		{
+			xstring content = makeMessageBacktoSaler(myurl);
+			xstring datacontent = GetSaleFullData(dw_cell);
+			if (content.left(1) != L"<")
+			{
+				alert(content);
+				return 1;
+			}
+			if (content != L"") return  ProcessSendMessage(myurl, L"", content, datacontent, true);
+			return 1;
+		}
+		return 1;
+	}
+
+	int SendToPurcher(xstring purchor, xstring content)
+	{
+		xstring empno;
+		KXMLDOMNode n = purcher.selectSingleNode(L"//HrEmployee[Name='" + purchor + L"']/UserNo");
+		if (n)empno = n.text();
+		if (empno == L"") return 1;
+		//trace(L"\r\npurchor:"+empno);
+
+		xstring newItemID = ViewObject::GetGuid();
+		xstring business = L"";
+		content = content.mid(content.find(L"<xsheet"), 9999999);
+		business = L"<business action='purch' id='" + entityID + L"' itemid='" + newItemID + L"' processurl='" + processurl + L"' purchor.name='" + purchor + L"' purchor.no='" + empno + L"' termid='" + templateID + L"'>";
+		business += L"<content>" + content + L"</content></business>";
+
+		xcell dw_cell1 = GetControl(L"dw_cell1");
+		xstring datacontent = GetSaleFullData(dw_cell1);
+
+		//trace(datacontent);
+		int ret = ProcessSendMessage(L"/task/quote/purch", L"", business, datacontent, true);
+		return ret;
+
+		/*
+		//ThingImpl:AddTask1($FlowID,$EntityID,$EntityNo,$Subject, $Content,$Status, $Category,$Reciever)
+		xml x ;
+		
+		xaserverarg arg ;
+		arg.setNativePointer(xaserverarg::CreateInstance());
+
+		xstring empno;
+		KXMLDOMNode n = purcher.selectSingleNode(L"//HrEmployee[Name='"+purchor+L"']/UserNo");
+		if(n)empno=n.text();
+		if(empno==L"") return 1;
+		trace(L"\r\npurchor:"+empno);
+
+		arg.AddArg(L"FlowID",L"DCC32D5B-9FCD-4F53-B7CF-630441DE2B47");
+		arg.AddArg(L"EntityID",fileid);
+		//arg.AddArg(L"EntityID",L"DCC32D5B-9FCD-4F53-B7CF-630441DE2B47");
+		arg.AddArg(L"EntityNo",L"娴嬭瘯");
+		arg.AddArg(L"Subject",L"---娴嬭瘯鏁版嵁----:璇互涓嬩骇鍝佷环鏍�");
+		arg.AddArg(L"Content",content);
+		arg.AddArg(L"Status",L"閲囪喘璇环");
+		arg.AddArg(L"Category",L"QuoteEnquiry");
+		arg.AddArg(L"Reciever",empno+L"|admin|00601");
+
+		xstring path=L"/sale/data/Thing/task/add/content1";
+		if (xurl::get(path,arg.GetString(),x) != 1)
+		{
+			alert(L"鍙戦�佸嚭閿欎簡!");
+			return -1;
+		}else
+		{
+			if(x.xml().find(L"error")>=0)
+			{
+				alert(L"鍙戦�佸嚭閿欎簡!"+x.xml());
+				return -1;
+			}
+			trace(x.xml());
+		}
+		trace(L"\r\n"+L"璇环鍗曞凡鍙戦�佺粰"+purchor);
+
+		return 1;
+		*/
+	}
+
+	xstring GetPurchedItems()
+	{
+		int row = 1;
+		int startRow = getItemHeadRow(dw_cell);
+		if (startRow < 1) return L"<data/>";
+		startRow++;
+
+		int colItemNo = getItemCol(dw_cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyer = getItemCol(dw_cell, startRow - 1, L"閲囪喘浜哄憳");
+		int colPackage = getItemCol(dw_cell, startRow - 1, L"Package,鍖呰鏂瑰紡");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+
+		int colGW = getItemCol(dw_cell, startRow - 1, L"姣涢噸(KG)L");
+		int colNW = getItemCol(dw_cell, startRow - 1, L"鍑�閲�(KG)L");
+		int colVolDesc = getItemCol(dw_cell, startRow - 1, L"闀縓瀹絏楂�(CM)L");
+
+		int colPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�");
+
+		int colSupplier = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�");
+		int colSupplier1 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�1");
+		int colPOPrice = getItemCol(dw_cell, startRow - 1, L"浠锋牸");
+		int colPOPrice1 = getItemCol(dw_cell, startRow - 1, L"浠锋牸1");
+		int colBOMType = getItemCol(dw_cell, startRow - 1, L"绫诲瀷");
+		int colBOMType1 = getItemCol(dw_cell, startRow - 1, L"绫诲瀷1");
+		int colProductInfo = getItemCol(dw_cell, startRow - 1, L"涓氬姟閮ㄤ骇鍝佷俊鎭�");
+		int colProductInfo1 = getItemCol(dw_cell, startRow - 1, L"閲囪喘閮ㄤ骇鍝佷俊鎭�");
+
+		xstring items = L"<data>";
+		int LastRow = dw_cell.GetValidRow();
+		xstring content = L"";
+
+		for (row = startRow; row <= LastRow; row++)
+		{
+			if (dw_cell.GetItemString(row, colItemName) == L"" &&
+				dw_cell.GetItemString(row, colItemSpec) == L"") break;
+			ensureRowID(dw_cell, row);
+
+			xstring itemStr = L"";
+			xstring issend = L"1";
+			itemStr += L"<RowID>" + getRowID(dw_cell, row) + L"</RowID>";
+			itemStr += L"<ItemNo>" + dw_cell.GetItemString(row, colItemNo) + L"</ItemNo>";
+			itemStr += L"<ItemName>" + dw_cell.GetItemString(row, colItemName) + L"</ItemName>";
+			itemStr += L"<ItemCName>" + dw_cell.GetItemString(row, colItemCName) + L"</ItemCName>";
+			itemStr += L"<ItemSpec>" + dw_cell.GetItemString(row, colItemSpec) + L"</ItemSpec>";
+			itemStr += L"<RowNo>" + (row - startRow + 1).toString() + L"</RowNo>";
+			itemStr += L"<Purchor>" + dw_cell.GetItemString(row, colBuyer) + L"</Purchor>";
+			itemStr += L"<Package>" + dw_cell.GetItemString(row, colPackage) + L"</Package>";
+			itemStr += L"<NWT>" + dw_cell.GetItemString(row, colNW) + L"</NWT>";
+			itemStr += L"<GWT>" + dw_cell.GetItemString(row, colGW) + L"</GWT>";
+			itemStr += L"<VolDesc>" + dw_cell.GetItemString(row, colVolDesc) + L"</VolDesc>";
+			itemStr += L"<Supplier>" + dw_cell.GetItemString(row, colSupplier) + L"</Supplier>";
+			itemStr += L"<BuyPrice>" + dw_cell.GetItemString(row, colPOPrice) + L"</BuyPrice>";
+			itemStr += L"<Supplier1>" + dw_cell.GetItemString(row, colSupplier1) + L"</Supplier1>";
+			itemStr += L"<BuyPrice1>" + dw_cell.GetItemString(row, colPOPrice1) + L"</BuyPrice1>";
+			itemStr += L"<BOMType1>" + dw_cell.GetItemString(row, colBOMType1) + L"</BOMType1>";
+			itemStr += L"<BOMType>" + dw_cell.GetItemString(row, colBOMType) + L"</BOMType>";
+			itemStr += L"<POPrice>" + dw_cell.GetItemString(row, colPrice) + L"</POPrice>";
+			itemStr += L"<ProductInfo>" + dw_cell.GetItemString(row, colProductInfo) + L"</ProductInfo>";
+			itemStr += L"<ProductInfo1>" + dw_cell.GetItemString(row, colProductInfo1) + L"</ProductInfo1>";
+
+			if (dw_cell.GetItemString(row, colBuyer) == L"")issend = L"0";
+			itemStr += L"<IsSend>" + issend + L"</IsSend>";
+
+			items += L"<Item>" + itemStr + L"</Item>";
+		}
+		items += L"</data>";
+
+		return items;
+	}
+
+	xstring GetPurchItems()
+	{
+		int row = 1;
+		int startRow = getItemHeadRow(dw_cell);
+		if (startRow < 1) return L"<data/>";
+		startRow++;
+
+		int colItemNo = getItemCol(dw_cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyer = getItemCol(dw_cell, startRow - 1, L"閲囪喘浜哄憳");
+		int colPackage = getItemCol(dw_cell, startRow - 1, L"Package,鍖呰鏂瑰紡");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+
+		int colGW = getItemCol(dw_cell, startRow - 1, L"姣涢噸(KG)L");
+		int colNW = getItemCol(dw_cell, startRow - 1, L"鍑�閲�(KG)L");
+		int colVolDesc = getItemCol(dw_cell, startRow - 1, L"闀縓瀹絏楂�(CM)L");
+
+		int colProductInfo = getItemCol(dw_cell, startRow - 1, L"涓氬姟閮ㄤ骇鍝佷俊鎭�");
+		int colProductInfo1 = getItemCol(dw_cell, startRow - 1, L"閲囪喘閮ㄤ骇鍝佷俊鎭�");
+
+		xstring items = L"<data>";
+		int LastRow = dw_cell.GetValidRow();
+		xstring content = L"";
+
+		for (row = startRow; row <= LastRow; row++)
+		{
+			if (dw_cell.GetItemString(row, colItemName) == L"" &&
+				dw_cell.GetItemString(row, colItemSpec) == L"") break;
+			ensureRowID(dw_cell, row);
+
+			xstring itemStr = L"";
+			xstring issend = L"1";
+			itemStr += L"<RowID>" + getRowID(dw_cell, row) + L"</RowID>";
+			itemStr += L"<ItemNo>" + dw_cell.GetItemString(row, colItemNo) + L"</ItemNo>";
+			itemStr += L"<CustomerItemNo>" + dw_cell.GetItemString(row, colCustomerItemNo) + L"</CustomerItemNo>";
+			itemStr += L"<ItemName>" + dw_cell.GetItemString(row, colItemName) + L"</ItemName>";
+			itemStr += L"<ItemCName>" + dw_cell.GetItemString(row, colItemCName) + L"</ItemCName>";
+			itemStr += L"<ItemSpec>" + dw_cell.GetItemString(row, colItemSpec) + L"</ItemSpec>";
+			itemStr += L"<RowNo>" + xstring(row - startRow + 1) + L"</RowNo>";
+			itemStr += L"<Purchor>" + dw_cell.GetItemString(row, colBuyer) + L"</Purchor>";
+			itemStr += L"<Package>" + dw_cell.GetItemString(row, colPackage) + L"</Package>";
+			itemStr += L"<NWT>" + dw_cell.GetItemString(row, colNW) + L"</NWT>";
+			itemStr += L"<GWT>" + dw_cell.GetItemString(row, colGW) + L"</GWT>";
+			itemStr += L"<VolDesc>" + dw_cell.GetItemString(row, colVolDesc) + L"</VolDesc>";
+			itemStr += L"<ProductInfo>" + dw_cell.GetItemString(row, colProductInfo) + L"</ProductInfo>";
+			itemStr += L"<ProductInfo1>" + dw_cell.GetItemString(row, colProductInfo1) + L"</ProductInfo1>";
+			if (dw_cell.GetItemString(row, colBuyer) == L"")issend = L"0";
+			itemStr += L"<IsSend>" + issend + L"</IsSend>";
+
+			items += L"<Item>" + itemStr + L"</Item>";
+		}
+		items += L"</data>";
+
+		return items;
+	}
+
+	/*
+	xstring GetPurchedItems()
+	{
+		int row = 1;
+		int startRow = getItemHeadRow(dw_cell);
+		if(startRow < 1) return L"<data/>";
+		startRow++;
+
+		int colItemNo = getItemCol(dw_cell,startRow - 1,L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell,startRow - 1,L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell,startRow - 1,L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell,startRow - 1,L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell,startRow - 1,L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyer = getItemCol(dw_cell,startRow - 1,L"閲囪喘浜哄憳");
+		int colPackage = getItemCol(dw_cell,startRow - 1,L"Package,鍖呰鏂瑰紡");
+		int col40HQ= getItemCol(dw_cell,startRow - 1,L"40HQ,QTY(40HQ)L");
+		int colBuyer = getItemCol(dw_cell,startRow - 1,L"閲囪喘浜哄憳");
+
+		xstring items=L"<data>";
+		int LastRow = dw_cell.GetValidRow();
+		xstring content = L"";
+
+		for(row = startRow; row <=LastRow; row++)
+		{
+			if(dw_cell.GetItemString(row,colItemName)==L"" &&
+				dw_cell.GetItemString(row,colItemSpec)==L"") break;
+			ensureRowID(dw_cell,row);
+
+			xstring itemStr = L"";
+			xstring issend=L"1";
+			itemStr += L"<RowID>"+getRowID(dw_cell,row)+L"</RowID>";
+			itemStr += L"<ItemNo>"+dw_cell.GetItemString(row, colItemNo)+L"</ItemNo>";
+			itemStr += L"<ItemName>"+dw_cell.GetItemString(row, colItemName)+L"</ItemName>";
+			itemStr += L"<ItemCName>"+dw_cell.GetItemString(row, colItemCName)+L"</ItemCName>";
+			itemStr += L"<ItemSpec>"+dw_cell.GetItemString(row, colItemSpec)+L"</ItemSpec>";
+			itemStr += L"<RowNo>"+(row - startRow +1).toString()+L"</RowNo>";
+			itemStr += L"<Purchor>"+dw_cell.GetItemString(row, colBuyer)+L"</Purchor>";
+			itemStr += L"<Package>"+dw_cell.GetItemString(row, colPackage)+L"</Package>";
+			if(dw_cell.GetItemString(row, colBuyer) ==L"")issend=L"0";
+			itemStr += L"<IsSend>"+issend+L"</IsSend>";
+
+			items += L"<Item>"+itemStr+L"</Item>";
+		}
+		items += L"</data>";
+
+		return items;
+	}
+	*/
+
+	int OnSaleBack()
+	{
+		xstring str;
+		xstring head;
+		int rowCount = dw_cell.GetRowCount();
+		int row = 1;
+		int headrow = 0;
+		for (row = 1; row <= rowCount; row++)
+		{
+			head = dw_cell.GetItemString(row, 1);
+			if (head == L"SKUID") break;
+		}
+
+		if (row >= rowCount)
+		{
+			alert(L"鎵句笉鍒板晢鍝佽!");
+			return 1;
+		}
+
+		headrow = row;
+		int startRow = headrow + 1;
+		int colItemNo = getItemCol(dw_cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyerPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�,閲囪喘浠锋牸");
+		int colPurchor = getItemCol(dw_cell, startRow - 1, L"閲囪喘鍛�,閲囪喘浜哄憳");
+
+		int colBuyerRemark = getItemCol(dw_cell, startRow - 1, L"閲囪喘To涓氬姟澶囨敞");
+		int colFactoryImage = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int colGWT = getItemCol(dw_cell, startRow - 1, L"姣涢噸,姣涢噸(KG)L");
+		int colNWT = getItemCol(dw_cell, startRow - 1, L"鍑�閲�,鍑�閲�(KG)L");
+		int colVolDesc = getItemCol(dw_cell, startRow - 1, L"浣撶Н鎻忚堪,闀縓瀹絏楂�,闀縓瀹絏楂�(CM)L");
+		int colVol = getItemCol(dw_cell, startRow - 1, L"浣撶Н,浣撶Н(M3)L");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+
+		int colSupplier1 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�1");
+		int colPOPrice1 = getItemCol(dw_cell, startRow - 1, L"浠锋牸1");
+		int colSupplier = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�");
+		int colPOPrice = getItemCol(dw_cell, startRow - 1, L"浠锋牸");
+		int colSupplier2 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�2");
+		int colPOPrice2 = getItemCol(dw_cell, startRow - 1, L"浠锋牸2");
+		int colSupplier3 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�3");
+		int colPOPrice3 = getItemCol(dw_cell, startRow - 1, L"浠锋牸3");
+
+		int colSalebackDate = getItemCol(dw_cell, startRow - 1, L"閲囪喘鎻愪氦涓氬姟鏃堕棿");
+		int colProductInfo = getItemCol(dw_cell, startRow - 1, L"涓氬姟閮ㄤ骇鍝佷俊鎭�");
+		int colProductInfo1 = getItemCol(dw_cell, startRow - 1, L"閲囪喘閮ㄤ骇鍝佷俊鎭�");
+
+		int LastRow = dw_cell.GetValidRow();
+		int count = 0;
+
+		int backedcount = 0;
+		for (row = startRow; row <= LastRow; row++)
+		{
+			if (getRowID(dw_cell, row) == L"") continue;
+			if (dw_cell.GetItemString(row, colItemName) == L"")continue;
+
+			if (dw_cell.GetItemString(row, colSupplier) == L"" && dw_cell.GetItemString(row, colBuyerPrice) == L"") continue;
+			count++;
+
+			/*
+			if(dw_cell.GetItemString(row, colBuyerPrice)==L"")
+			{
+				alert(L"閲囪喘浠锋牸娌℃湁褰曞叆");
+				return 1;
+			}
+			if(dw_cell.GetItemString(row, colGWT)==L"")
+			{
+				alert(L"姣涢噸娌℃湁褰曞叆");
+				return 1;
+			}
+			if(dw_cell.GetItemString(row, colNWT)==L"")
+			{
+				alert(L"鍑�閲嶆病鏈夊綍鍏�");
+				return 1;
+			}
+			if(dw_cell.GetItemString(row, colVolDesc)==L"")
+			{
+				alert(L"闀縓瀹絏楂樻病鏈夊綍鍏�");
+				return 1;
+			}
+			if(dw_cell.GetItemString(row, colFactoryImage)==L"")
+			{
+				alert(L"宸ュ巶鍥剧墖娌℃湁褰曞叆");
+				return 1;
+			}
+			if(dw_cell.GetItemString(row, colSupplier)==L"")
+			{
+				alert(L"渚涘簲鍟嗘病鏈夊綍鍏�");
+				return 1;
+			}
+			if(dw_cell.GetItemString(row, colPOPrice)==L"")
+			{
+				alert(L"閲囪喘浠锋牸娌℃湁褰曞叆");
+				return 1;
+			}*/
+
+			/*
+			if(dw_cell.GetItemString(row, colPOPrice1)!=L"")
+			{
+				if(dw_cell.GetItemString(row, colSupplier1)==L"")
+				{
+					alert(L"渚涘簲鍟�1娌℃湁褰曞叆");
+					return 1;
+				}
+			}
+			if(dw_cell.GetItemString(row, colSupplier1)!=L"")
+			{
+				if(dw_cell.GetItemString(row, colPOPrice1)==L"")
+				{
+					alert(L"閲囪喘浠锋牸1娌℃湁褰曞叆");
+					return 1;
+				}
+			}*/
+		}
+		if (count < 1) return 1;
+
+		int col = 0;
+		int namecol = 0;
+		int pricecol = 0;
+		int purchremarkcol = 0;
+		int purchercol = 0;
+
+		int colCount = dw_cell.GetValidCol(row);
+		for (col = 1; col <= colCount; col++)
+		{
+			head = dw_cell.GetItemString(row, col);
+			if (head == L"Product Name" || head == L"Product Description") namecol = col;
+			if (head == L"FOB Price" || head == L"Fob Price" || head == L"FOB Price(USD)L") pricecol = col;
+			if (head == L"閲囪喘To涓氬姟澶囨敞") purchremarkcol = col;
+			if (head == L"閲囪喘浜哄憳") purchercol = col;
+		}
+
+		xstring items = GetPurchedItems();
+		xaserverarg arg4 ;
+		arg4.setNativePointer(xaserverarg::CreateInstance());
+		trace(items);
+		arg4.AddArg(L"value", items);
+		OpenWindow(L"dev:xpage[QuoteFilePurched.vx]", cast(arg4 as int));
+
+		if (arg4.GetArgString(L"process") != L"ok") return 1;
+		items = arg4.GetArgString(L"value");
+
+		xml x0 ;
+		x0.setNativePointer(xml::CreateInstance());
+		x0.loadXML(items);
+
+		KXMLDOMNodeList ts = x0.selectNodes(L"data/Item[IsSend='1']");
+		int len = ts.length();
+		if (len < 1) return L"";
+
+		xstring content = L"";
+		xstring sdate = publiccode::GetCurrentDate();
+		for (int k = 0; k < len; k++)
+		{
+			KXMLDOMNode node = ts.item(k);
+			xstring id = node.selectSingleNode(L"RowID").text();
+			row = LookupCellRow(id);
+			if (row < 1) continue;
+
+			if (dw_cell.GetItemString(row, colBuyerPrice) == L"")
+			{
+				alert(L"閲囪喘浠锋牸娌℃湁褰曞叆");
+				return 1;
+			}
+			if (dw_cell.GetItemString(row, colGWT) == L"")
+			{
+				alert(L"姣涢噸娌℃湁褰曞叆");
+				return 1;
+			}
+			if (dw_cell.GetItemString(row, colNWT) == L"")
+			{
+				alert(L"鍑�閲嶆病鏈夊綍鍏�");
+				return 1;
+			}
+			if (dw_cell.GetItemString(row, colVolDesc) == L"")
+			{
+				alert(L"闀縓瀹絏楂樻病鏈夊綍鍏�");
+				return 1;
+			}
+			if (dw_cell.GetItemString(row, colFactoryImage) == L"")
+			{
+				alert(L"宸ュ巶鍥剧墖娌℃湁褰曞叆");
+				return 1;
+			}
+			if (dw_cell.GetItemString(row, colSupplier) == L"")
+			{
+				alert(L"渚涘簲鍟嗘病鏈夊綍鍏�");
+				return 1;
+			}
+			if (dw_cell.GetItemString(row, colPOPrice) == L"")
+			{
+				alert(L"閲囪喘浠锋牸娌℃湁褰曞叆");
+				return 1;
+			}
+
+			//if(getRowID(dw_cell,row)==L"") continue;
+			//if(dw_cell.GetItemString(row, colItemName)==L"")continue;
+			xstring itemStr = L"";
+			itemStr += L"<RowID>" + getRowID(dw_cell, row) + L"</RowID>";
+			itemStr += L"<ItemNo>" + dw_cell.GetItemString(row, colItemNo) + L"</ItemNo>";
+			itemStr += L"<ItemName>" + dw_cell.GetItemString(row, colItemName) + L"</ItemName>";
+			itemStr += L"<ItemCName>" + dw_cell.GetItemString(row, colItemCName) + L"</ItemCName>";
+			itemStr += L"<ItemSpec>" + dw_cell.GetItemString(row, colItemSpec) + L"</ItemSpec>";
+			itemStr += L"<BuyerPrice>" + dw_cell.GetItemString(row, colBuyerPrice) + L"</BuyerPrice>";
+			itemStr += L"<ProductInfo>" + dw_cell.GetItemString(row, colProductInfo) + L"</ProductInfo>";
+			itemStr += L"<ProductInfo1>" + dw_cell.GetItemString(row, colProductInfo1) + L"</ProductInfo1>";
+			itemStr += L"<Buyer>" + dw_cell.GetItemString(row, colPurchor) + L"</Buyer>";
+
+			/*
+			if(dw_cell.GetItemString(row, colBuyerPrice)==L"") return L"閲囪喘浠锋牸娌℃湁褰曞叆";
+			if(dw_cell.GetItemString(row, colGWT)==L"") return L"姣涢噸娌℃湁褰曞叆";
+			if(dw_cell.GetItemString(row, colNWT)==L"") return L"鍑�閲嶆病鏈夊綍鍏�";
+			if(dw_cell.GetItemString(row, colVolDesc)==L"") return L"闀縓瀹絏楂樻病鏈夊綍鍏�";
+			if(dw_cell.GetItemString(row, colFactoryImage)==L"") return L"鍥剧墖娌℃湁褰曞叆";
+
+			if(dw_cell.GetItemString(row, colSupplier)==L"") return L"渚涘簲鍟嗘病鏈夊綍鍏�";
+			if(dw_cell.GetItemString(row, colPOPrice)==L"") return L"閲囪喘浠锋牸娌℃湁褰曞叆";
+
+			if(dw_cell.GetItemString(row, colPOPrice1)!=L"")
+			{
+				if(dw_cell.GetItemString(row, colSupplier1)==L"") return L"渚涘簲鍟�1娌℃湁褰曞叆";
+			}
+			if(dw_cell.GetItemString(row, colSupplier1)!=L"")
+			{
+				if(dw_cell.GetItemString(row, colPOPrice1)==L"") return L"閲囪喘浠锋牸1娌℃湁褰曞叆";
+			}
+			if(dw_cell.GetItemString(row, colGWT)!=L"")
+			{
+				if(dw_cell.GetItemString(row, colGWT)==L"") return L"姣涢噸娌℃湁褰曞叆";
+			}
+			if(dw_cell.GetItemString(row, colNWT)!=L"")
+			{
+				if(dw_cell.GetItemString(row, colNWT)==L"") return L"鍑�閲嶆病鏈夊綍鍏�";
+			}
+			if(dw_cell.GetItemString(row, colVolDesc)!=L"")
+			{
+				if(dw_cell.GetItemString(row, colVolDesc)==L"") return L"浣撶Н淇℃伅娌℃湁褰曞叆";
+			}
+			*/
+			itemStr += L"<BuyerRemark>" + dw_cell.GetItemString(row, colBuyerRemark) + L"</BuyerRemark>";
+			itemStr += L"<FactoryImage>" + dw_cell.GetItemString(row, colFactoryImage) + L"</FactoryImage>";
+			itemStr += L"<GWT>" + dw_cell.GetItemString(row, colGWT) + L"</GWT>";
+			itemStr += L"<NWT>" + dw_cell.GetItemString(row, colNWT) + L"</NWT>";
+			itemStr += L"<VolDesc>" + dw_cell.GetItemString(row, colVolDesc) + L"</VolDesc>";
+			itemStr += L"<Vol>" + dw_cell.GetItemString(row, colVol) + L"</Vol>";
+			itemStr += L"<F40HQ>" + dw_cell.GetItemString(row, col40HQ) + L"</F40HQ>";
+
+			itemStr += L"<PurchedDate>" + sdate + L"</PurchedDate>";
+			itemStr += L"<supplier-photo>" + getRowTerm(dw_cell, row, L"supplier-photo") + L"</supplier-photo>";
+
+			xstring eid = GetGuid();
+			setRowTerm(dw_cell, row, L"EnquiryLineID", eid);
+			//alert(eid +L" "+ getRowTerm(dw_cell,row,L"EnquiryLineID"));
+			itemStr += L"<EnquiryLineID>" + eid + L"</EnquiryLineID>";
+			content += L"<Item>" + itemStr + L"</Item>";
+
+			dw_cell.SetItemString(row, colSalebackDate, sdate);
+		}
+
+		xstring finished = L"1";
+		for (row = startRow; row <= LastRow; row++)
+		{
+			if (getRowID(dw_cell, row) == L"") continue;
+			if (dw_cell.GetItemString(row, colItemName) == L"")continue;
+			if (dw_cell.GetItemString(row, colSalebackDate) == L"")
+			{
+				finished = L"0";
+				break;
+			}
+		}
+
+		//trace(L"\r\n******11"+sdate);
+		xstring newEntityItemID = ViewObject::GetGuid();
+		xstring datacontent = GetSaleFullData(dw_cell, ts);
+
+		content = L"<data id='" + entityID + L"' itemid='" + newEntityItemID + L"' itemid.piror='" + entityItemID + L"' action='purched' taskid='" + taskid + L"' finished='" + finished + L"'>" + content + L"</data>";
+		xstring myurl = L"/task/quote/purchar/backtosaler";
+		if (content != L"")
+		{
+			trace(L"\r\ntaskid:" + taskid + L" finished:" + finished);
+			ProcessSendMessage(myurl, L"", content, datacontent, true);
+			win32::PostMessage(GetFrameWindow().GetHWND(), 0x401, L"xmRefreshTask", 0);
+		}
+
+		return 1;
+	}
+
+	int OnPurchEx()
+	{
+		xstring str;
+		xstring head;
+		int rowCount = dw_cell.GetRowCount();
+		int row = 1;
+		int headrow = 0;
+		for (row = 1; row <= rowCount; row++)
+		{
+			head = dw_cell.GetItemString(row, 1);
+			if (head == L"SKUID") break;
+		}
+
+		if (row >= rowCount)
+		{
+			alert(L"鎵句笉鍒板晢鍝佽!");
+			return 1;
+		}
+
+		headrow = row;
+		int startRow = headrow + 1;
+		int colCustomerItemNo = getItemCol(dw_cell, headrow, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, headrow, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, headrow, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, headrow, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colItemQty = getItemCol(dw_cell, headrow, L"鏁伴噺,Qty");
+		//int colItemSpec = getItemCol(dw_cell,headrow,L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colItemPurchDate = getItemCol(dw_cell, headrow, L"涓氬姟鍙戦�侀噰璐椂闂�");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+		int colInnerOuter = getItemCol(dw_cell, startRow - 1, L"瑁呯鏁�(鍐�/澶�)L");
+		int col = 0;
+		int namecol = 0;
+		int pricecol = 0;
+		int purchremarkcol = 0;
+		int purchercol = 0;
+
+		int colCount = dw_cell.GetValidCol(row);
+		for (col = 1; col <= colCount; col++)
+		{
+			head = dw_cell.GetItemString(row, col);
+			if (head == L"Product Name" || head == L"Product Description") namecol = col;
+			if (head == L"FOB Price" || head == L"Fob Price" || head == L"FOB Price(USD)L") pricecol = col;
+			if (head == L"閲囪喘To涓氬姟澶囨敞") purchremarkcol = col;
+			if (head == L"閲囪喘浜哄憳") purchercol = col;
+		}
+
+		if (purchercol == 0)
+		{
+			alert(L"鎵句笉鍒伴噰璐汉鍛樻暟鎹�!");
+			return 1;
+		}
+
+		xstring items = GetPurchItems();
+		xaserverarg arg4 ;
+		arg4.setNativePointer(xaserverarg::CreateInstance());
+		trace(items);
+		arg4.AddArg(L"value", items);
+		OpenWindow(L"dev:xpage[QuoteFilePurch.vx]", cast(arg4 as int));
+		if (arg4.GetArgString(L"process") != L"ok") return 1;
+		items = arg4.GetArgString(L"value");
+
+		return 1;
+	}
+
+	int OnNextPurch()
+	{
+		//dw_cell.AcceptText();
+
+		xstring str;
+		xstring head;
+		int rowCount = dw_cell.GetValidRow();
+		int row = 1;
+		int headrow = 0;
+		for (row = 1; row <= rowCount; row++)
+		{
+			head = dw_cell.GetItemString(row, 1);
+			if (head == L"SKUID") break;
+		}
+
+		if (row >= rowCount)
+		{
+			alert(L"鎵句笉鍒板晢鍝佽!");
+			return 1;
+		}
+
+		headrow = row;
+		int startRow = headrow + 1;
+		int colCustomerItemNo = getItemCol(dw_cell, headrow, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, headrow, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, headrow, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, headrow, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colItemQty = getItemCol(dw_cell, headrow, L"鏁伴噺,Qty");
+		//int colItemSpec = getItemCol(dw_cell,headrow,L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colItemPurchDate = getItemCol(dw_cell, headrow, L"涓氬姟鍙戦�侀噰璐椂闂�");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+		int colInnerOuter = getItemCol(dw_cell, startRow - 1, L"瑁呯鏁�(鍐�/澶�)L");
+		int colSalebackDate = getItemCol(dw_cell, startRow - 1, L"閲囪喘鎻愪氦涓氬姟鏃堕棿");
+
+		int col = 0;
+		int namecol = 0;
+		int pricecol = 0;
+		int purchremarkcol = 0;
+		int purchercol = 0;
+
+		int colCount = dw_cell.GetValidCol(row);
+		for (col = 1; col <= colCount; col++)
+		{
+			head = dw_cell.GetItemString(row, col);
+			if (head == L"Product Name" || head == L"Product Description") namecol = col;
+			if (head == L"FOB Price" || head == L"Fob Price" || head == L"FOB Price(USD)L") pricecol = col;
+			if (head == L"閲囪喘To涓氬姟澶囨敞") purchremarkcol = col;
+			if (head == L"閲囪喘浜哄憳") purchercol = col;
+		}
+		if (purchercol == 0)
+		{
+			alert(L"鎵句笉鍒伴噰璐汉鍛樻暟鎹�!");
+			return 1;
+		}
+
+		xstring strs = L",L";
+		row++;
+
+		int colCustomerPhoto = getItemCol(dw_cell, startRow - 1, L"Photo,Customer Photo");
+		int colPackage = getItemCol(dw_cell, startRow - 1, L"Package,鍖呰鏂瑰紡");
+
+		while (row <= rowCount)
+		{
+			str = dw_cell.GetItemString(row, purchercol);
+			if (str == L"")break;
+
+			//ensureRowID(dw_cell,row);
+			if (strs.find(L",L" + str + L",L") < 0)
+			{
+				if (purcher.selectSingleNode(L"//Name[.='" + str + L"']"))
+				{
+					strs += str + L",L";
+				}
+				else
+				{
+					alert(L"娌℃湁閲囪喘鍛橈細" + str);
+					return 1;
+				}
+			}
+			row++;
+		}
+		if (strs == L",L")
+		{
+			alert(L"璇锋寚瀹氶噰璐汉鍛�!");
+			return 1;
+		}
+
+		xstring items = GetPurchItems();
+		xaserverarg arg4 ;
+		arg4.setNativePointer(xaserverarg::CreateInstance());
+		arg4.AddArg(L"value", items);
+		OpenWindow(L"dev:xpage[QuoteFilePurch.vx]", cast(arg4 as int));
+		if (arg4.GetArgString(L"process") != L"ok") return 1;
+		items = arg4.GetArgString(L"value");
+
+		xml x0 ;
+		x0.setNativePointer(xml::CreateInstance());
+		x0.loadXML(items);
+		KXMLDOMNodeList ts1 = x0.selectNodes(L"data/Item");
+		int len1 = ts1.length();
+		for (int m = 0; m < len1; m++)
+		{
+			KXMLDOMNode node = ts1.item(m);
+			xstring rowno = L"";
+			xstring purchar = L"";
+			if (node.selectSingleNode(L"RowNo")) rowno = node.selectSingleNode(L"RowNo").text();
+			if (node.selectSingleNode(L"Purchor")) purchar = node.selectSingleNode(L"Purchor").text();
+			//alert( rowno+L" "+ node.xml);
+			if (rowno != L"")
+			{
+				int row1 = headrow + rowno.toInt();
+				if (dw_cell.GetItemString(row1, purchercol) != purchar)
+				{
+					dw_cell.SetItemString(row1, purchercol, purchar);
+				}
+			}
+		}
+
+		row = headrow + 1;
+		strs = L"";
+		while (row <= rowCount)
+		{
+			str = dw_cell.GetItemString(row, purchercol);
+			if (str == L"")break;
+
+			if (strs.find(L",L" + str + L",L") < 0)
+			{
+				if (purcher.selectSingleNode(L"//Name[.='" + str + L"']"))
+				{
+					strs += str + L",L";
+				}
+				else
+				{
+					alert(L"娌℃湁閲囪喘鍛橈細" + str);
+					return 1;
+				}
+			}
+			row++;
+		}
+		//return 1;
+
+		xstring cellstr = dw_cell.GetData();
+		xcell cell1 = GetControl(L"dw_cell1");
+		xml x ;
+		
+
+		if (strs.left(1) == L",L") strs = strs.mid(1, 9999);
+		if (strs.right(1) == L",L") strs = strs.left(strs.length() - 1);
+
+		xstring purchors = strs;
+
+		xstring supplier;
+		if (strs.find(L",L", 0) > 0)
+		{
+			supplier = strs.left(strs.find(L",L", 0));
+			strs = strs.mid(strs.find(L",L", 0) + 1, 9999);
+		}
+		else
+		{
+			supplier = strs;
+			strs = L"";
+		}
+
+		xstring username = publiccode::GetUser().name;
+
+		while (supplier != L"")
+		{
+			KXMLDOMNodeList ts = x0.selectNodes(L"data/Item[IsSend='1' and Purchor='" + supplier + L"']");
+			int len = ts.length();
+			if (supplier == username)  len = 0;
+			if (len < 1)
+			{
+				if (strs.find(L",L", 0) > 0)
+				{
+					supplier = strs.left(strs.find(L",L", 0));
+					strs = strs.mid(strs.find(L",L", 0) + 1, 9999);
+				}
+				else
+				{
+					supplier = strs;
+					strs = L"";
+				}
+				continue;
+			}
+			x.loadXML(cellstr);
+			cell1.LoadTemplate(x);
+			cell1.Redraw();
+
+			row = headrow + 1;
+			int cnt = 1;
+			while (true)
+			{
+				str = L"";
+				str = cell1.GetItemString(row, purchercol);
+				if (str == L"")break;
+				if (str != supplier)
+				{
+					cell1.SetRowColumn(row, 1);
+					cell1.SetAnchorRowColumn(row, 1);
+					SendCtrlCmd(cell1, L"xmFormatCellDeleteRow");
+				}
+				else
+				{
+					KXMLDOMNode n = x0.selectSingleNode(L"data/Item[IsSend='1' and Purchor='" + supplier + L"' and RowNo='" + xstring(cnt) + L"']");
+					if (!n)
+					{
+						cell1.SetRowColumn(row, 1);
+						cell1.SetAnchorRowColumn(row, 1);
+						SendCtrlCmd(cell1, L"xmFormatCellDeleteRow");
+					}
+					else
+					{
+						row = row + 1;
+					}
+				}
+				cnt++;
+				if (cnt > 512)break;
+			}
+
+			cell1.SetRowColumn(1, 1);
+			cell1.SetAnchorRowColumn(1, 1);
+
+			row = headrow + 1;
+			rowCount = cell1.GetValidRow();
+
+
+			if (SendToPurcher(supplier, cell1.GetData()) == -1) return 1;
+			if (strs.find(L",L", 0) > 0)
+			{
+				supplier = strs.left(strs.find(L",L", 0));
+				strs = strs.mid(strs.find(L",L", 0) + 1, 9999);
+			}
+			else
+			{
+				supplier = strs;
+				strs = L"";
+			}
+		}
+
+		//update purch
+		if (1 == 0)
+		{
+			//trace(L"\r\nentityID:"+entityID);
+			xml x2 = ViewObject::RetrieveData(L"/sale/data/TO/business/documententity", L"BusinessID", entityID);
+			if (x2)
+			{
+				//trace(x2.GetXml());
+				cell1.LoadTemplate(x2);
+				cell1.Redraw();
+			}
+			else
+			{
+				alert(L"鍑虹幇閿欒");
+				return 1;
+			}
+
+			xstring head1;
+			int rowCount1 = cell1.GetValidRow();
+			int row2 = 1;
+			int headrow1 = 0;
+			int startrow1 = 0;
+			for (row2 = 1; row2 <= rowCount1; row2++)
+			{
+				head1 = cell1.GetItemString(row2, 1);
+				if (head1 == L"SKUID") break;
+			}
+
+			headrow1 = row2;
+			startrow1 = headrow1 + 1;
+			int purchercol1 = getItemCol(cell1, headrow1, L"閲囪喘浜哄憳");
+		}
+
+		//Clear
+		if (1 == 1)
+		{
+			row = headrow + 1;
+			strs = L"";
+			while (row <= rowCount)
+			{
+				str = dw_cell.GetItemString(row, purchercol);
+				if (str == L"")break;
+				row++;
+			}
+			int lastrow = row - 1;
+			row = headrow + 1;
+			int drow = 0;
+			while (lastrow >= row)
+			{
+				supplier = L"";
+				supplier = dw_cell.GetItemString(lastrow, purchercol);
+				if (supplier != username)
+				{
+					KXMLDOMNode n1 = x0.selectSingleNode(L"data/Item[IsSend='1' and Purchor='" + supplier + L"' and RowNo='" + (lastrow - row + 1).toString() + L"']");
+					if (n1)
+					{
+						xstring rowid = getRowID(dw_cell, lastrow);
+						int frow = LookupCellRow(rowid);
+						if (0 == 1)
+						{
+							if (drow > 0)cell1.SetItemString(frow, purchercol1, supplier);
+						}
+						dw_cell.SetRowColumn(lastrow, 1);
+						dw_cell.SetAnchorRowColumn(lastrow, 1);
+						SendCtrlCmd(dw_cell, L"xmFormatCellDeleteRow");
+						drow++;
+					}
+				}
+				lastrow--;
+			}
+		}
+
+		xstring finished = L"1";
+		for (row = startRow; row <= rowCount; row++)
+		{
+			if (getRowID(dw_cell, row) == L"") continue;
+			if (dw_cell.GetItemString(row, colItemName) == L"")continue;
+			if (dw_cell.GetItemString(row, colSalebackDate) == L"")
+			{
+				finished = L"0";
+				break;
+			}
+		}
+
+		if (0 == 1)OnUpdateEntityFile();
+		OnUpdate();
+
+		if (finished == L"1")
+		{
+			OnUpdateProcessed();
+			alert(L"xxxxx");
+		}
+
+		//OnSaveEx(true);
+		//alert(L"璇环淇℃伅宸插彂閫佺粰:"+purchors);
+		return 1;
+	}
+
+	int OnPurch()
+	{
+		xstring str;
+		xstring head;
+		int rowCount = dw_cell.GetRowCount();
+		int row = 1;
+		int headrow = 0;
+		for (row = 1; row <= rowCount; row++)
+		{
+			head = dw_cell.GetItemString(row, 1);
+			if (head == L"SKUID") break;
+		}
+
+		if (dw_base.GetItemString(1, L"CustomerID") == L"")
+		{
+			alert(L"璇疯緭鍏ユ姤浠风殑瀹㈡埛!");
+			return 1;
+		}
+
+		if (row >= rowCount)
+		{
+			alert(L"鎵句笉鍒板晢鍝佽!");
+			return 1;
+		}
+
+		if (getBaseItem(dw_cell, L"鎶ヤ环鎴鏃ユ湡锛�") == L"")
+		{
+			if (getBaseItem(dw_cell, L"鎶ヤ环鎴鏃ユ湡:") == L"")
+			{
+				alert(L"鎶ヤ环鎴鏃ユ湡鏈緭鍏�!");
+				return 1;
+			}
+		}
+
+		if (getBaseItem(dw_cell, L"椤圭洰鍚嶇О:") == L"")
+		{
+			if (getBaseItem(dw_cell, L"椤圭洰鍚嶇О锛�") == L"")
+			{
+				alert(L"椤圭洰鍚嶇О鏈緭鍏�!");
+				return 1;
+			}
+		}
+
+		headrow = row;
+		int startRow = headrow + 1;
+		int colCustomerItemNo = getItemCol(dw_cell, headrow, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, headrow, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, headrow, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, headrow, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colItemQty = getItemCol(dw_cell, headrow, L"鏁伴噺,Qty");
+		//int colItemSpec = getItemCol(dw_cell,headrow,L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colItemPurchDate = getItemCol(dw_cell, headrow, L"涓氬姟鍙戦�侀噰璐椂闂�");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+		int colInnerOuter = getItemCol(dw_cell, startRow - 1, L"瑁呯鏁�(鍐�/澶�)L");
+
+		int col = 0;
+		int namecol = 0;
+		int pricecol = 0;
+		int purchremarkcol = 0;
+		int purchercol = 0;
+
+		int colCount = dw_cell.GetValidCol(row);
+		for (col = 1; col <= colCount; col++)
+		{
+			head = dw_cell.GetItemString(row, col);
+			if (head == L"Product Name" || head == L"Product Description") namecol = col;
+			if (head == L"FOB Price" || head == L"Fob Price" || head == L"FOB Price(USD)L") pricecol = col;
+			if (head == L"閲囪喘To涓氬姟澶囨敞") purchremarkcol = col;
+			if (head == L"閲囪喘浜哄憳") purchercol = col;
+		}
+		if (purchercol == 0)
+		{
+			alert(L"鎵句笉鍒伴噰璐汉鍛樻暟鎹�!");
+			return 1;
+		}
+
+		xstring strs = L",L";
+		row++;
+
+		int colCustomerPhoto = getItemCol(dw_cell, startRow - 1, L"Photo,Customer Photo");
+		int colPackage = getItemCol(dw_cell, startRow - 1, L"Package,鍖呰鏂瑰紡");
+
+		while (row <= rowCount)
+		{
+			str = dw_cell.GetItemString(row, purchercol);
+			if (str == L"")break;
+
+			/*if(dw_cell.GetItemString(row,colCustomerItemNo)==L"")
+			{
+				alert(L"绗�"+xstring(row)+L"琛岃杈撳叆瀹㈡埛鍨嬪彿!");
+				return 1;
+			}*/
+			if (dw_cell.GetItemString(row, colItemName) == L"" || dw_cell.GetItemString(row, colItemCName) == L"")
+			{
+				alert(L"绗�" + xstring(row) + L"琛岃杈撳叆浜у搧鍚嶇О!");
+				return 1;
+			}
+			if (dw_cell.GetItemString(row, colPackage) == L"")
+			{
+				alert(L"绗�" + xstring(row) + L"琛岃杈撳叆浜у搧鍖呰鏂瑰紡!");
+				return 1;
+			}
+			if (dw_cell.GetItemString(row, colCustomerPhoto) == L"")
+			{
+				alert(L"绗�" + xstring(row) + L"琛岃閫夋嫨瀹㈡埛鍥剧墖!");
+				return 1;
+			}
+			if (dw_cell.GetItemString(row, colInnerOuter) == L"")
+			{
+				alert(L"绗�" + xstring(row) + L"琛岃褰曞叆鍐呭绠辫鏁�!");
+				return 1;
+			}
+			/*if(dw_cell.GetItemString(row,col40HQ)==L"")
+			{
+				alert(L"绗�"+xstring(row)+L"琛�40HQ鐨勬暟鎹槸绌虹殑!");
+				return 1;
+			}*/
+
+			/*if(dw_cell.GetItemString(row,colItemQty)==L"")
+			{
+				alert(L"绗�"+xstring(row)+L"琛屾暟閲忔槸绌虹殑!");
+				return 1;
+			}*/
+
+			ensureRowID(dw_cell, row);
+			if (strs.find(L",L" + str + L",L") < 0)
+			{
+				if (purcher.selectSingleNode(L"//Name[.='" + str + L"']"))
+				{
+					strs += str + L",L";
+				}
+				else
+				{
+					alert(L"娌℃湁閲囪喘鍛橈細" + str);
+					return 1;
+				}
+			}
+			row++;
+		}
+		if (strs == L",L")
+		{
+			alert(L"鎵句笉鍒伴噰璐汉鍛樻暟鎹�!");
+			return 1;
+		}
+
+		xstring items = GetPurchItems();
+		xaserverarg arg4 ;
+		arg4.setNativePointer(xaserverarg::CreateInstance());
+		trace(items);
+		arg4.AddArg(L"value", items);
+		OpenWindow(L"dev:xpage[QuoteFilePurch.vx]", cast(arg4 as int));
+		if (arg4.GetArgString(L"process") != L"ok") return 1;
+		items = arg4.GetArgString(L"value");
+
+		xstring cellstr = dw_cell.GetData();
+		xcell cell1 = GetControl(L"dw_cell1");
+		xml x ;
+		
+
+		if (strs.left(1) == L",L") strs = strs.mid(1, 9999);
+		if (strs.right(1) == L",L") strs = strs.left(strs.length() - 1);
+
+		xstring purchors = strs;
+
+		xstring supplier;
+		if (strs.find(L",L", 0) > 0)
+		{
+			supplier = strs.left(strs.find(L",L", 0));
+			strs = strs.mid(strs.find(L",L", 0) + 1, 9999);
+		}
+		else
+		{
+			supplier = strs;
+			strs = L"";
+		}
+
+		xml x0 ;
+		x0.setNativePointer(xml::CreateInstance());
+		x0.loadXML(items);
+
+		while (supplier != L"")
+		{
+			KXMLDOMNodeList ts = x0.selectNodes(L"data/Item[IsSend='1' and Purchor='" + supplier + L"']");
+			int len = ts.length();
+			if (len < 1)
+			{
+				if (strs.find(L",L", 0) > 0)
+				{
+					supplier = strs.left(strs.find(L",L", 0));
+					strs = strs.mid(strs.find(L",L", 0) + 1, 9999);
+				}
+				else
+				{
+					supplier = strs;
+					strs = L"";
+				}
+				continue;
+			}
+			x.loadXML(cellstr);
+			cell1.LoadTemplate(x);
+			cell1.Redraw();
+
+			row = headrow + 1;
+			int cnt = 1;
+			while (true)
+			{
+				str = L"";
+				str = cell1.GetItemString(row, purchercol);
+				if (str == L"")break;
+				if (str != supplier)
+				{
+					cell1.SetRowColumn(row, 1);
+					cell1.SetAnchorRowColumn(row, 1);
+					SendCtrlCmd(cell1, L"xmFormatCellDeleteRow");
+				}
+				else
+				{
+					trace(L"\r\ndata/Item[IsSend='1' and Purchor='" + supplier + L"' and RowNo='" + xstring(cnt) + L"']");
+					KXMLDOMNode n = x0.selectSingleNode(L"data/Item[IsSend='1' and Purchor='" + supplier + L"' and RowNo='" + xstring(cnt) + L"']");
+					if (!n)
+					{
+						cell1.SetRowColumn(row, 1);
+						cell1.SetAnchorRowColumn(row, 1);
+						SendCtrlCmd(cell1, L"xmFormatCellDeleteRow");
+					}
+					else
+					{
+						if (colItemPurchDate > 0)
+						{
+							xstring sdate = publiccode::GetCurrentDate();
+							dw_cell.SetItemString(headrow + cnt, colItemPurchDate, sdate);
+							cell1.SetItemString(row, colItemPurchDate, sdate);
+							dw_cell.Redraw();
+						}
+						row = row + 1;
+					}
+				}
+				cnt++;
+				if (cnt > 512)break;
+			}
+
+			if (pricecol > 0)
+			{
+
+				cell1.SetRowColumn(1, purchercol);
+				cell1.SetAnchorRowColumn(1, purchercol);
+				SendCtrlCmd(cell1, L"xmFormatCellInsertCol");
+				cell1.SetItemString(headrow, purchercol, L"涓氬姟鍛�");
+
+				cell1.SetRowColumn(1, pricecol);
+				cell1.SetAnchorRowColumn(1, pricecol);
+				SendCtrlCmd(cell1, L"xmFormatCellDeleteCol");
+
+
+				cell1.SetRowColumn(1, purchremarkcol + 1);
+				cell1.SetAnchorRowColumn(1, purchremarkcol + 1);
+				SendCtrlCmd(cell1, L"xmFormatCellInsertCol");
+				SendCtrlCmd(cell1, L"xmFormatCellInsertCol");
+				SendCtrlCmd(cell1, L"xmFormatCellInsertCol");
+				SendCtrlCmd(cell1, L"xmFormatCellInsertCol");
+				SendCtrlCmd(cell1, L"xmFormatCellInsertCol");
+				SendCtrlCmd(cell1, L"xmFormatCellInsertCol");
+
+				cell1.SetItemString(headrow, purchremarkcol + 1, L"渚涘簲鍟�");
+				cell1.SetItemString(headrow, purchremarkcol + 2, L"绫诲瀷");
+				cell1.SetItemString(headrow, purchremarkcol + 3, L"浠锋牸");
+				cell1.SetItemString(headrow, purchremarkcol + 4, L"渚涘簲鍟�1");
+				cell1.SetItemString(headrow, purchremarkcol + 5, L"绫诲瀷1");
+				cell1.SetItemString(headrow, purchremarkcol + 6, L"浠锋牸1");
+
+				int colRemark = getItemCol(cell1, headrow, L"Remarks");
+				cell1.SetRowColumn(1, colRemark);
+				cell1.SetAnchorRowColumn(1, colRemark);
+				SendCtrlCmd(cell1, L"xmFormatCellDeleteCol");
+			}
+			cell1.SetRowColumn(1, 1);
+			cell1.SetAnchorRowColumn(1, 1);
+
+			row = headrow + 1;
+			rowCount = cell1.GetValidRow();
+			while (row <= rowCount)
+			{
+				str = cell1.GetItemString(row, purchercol);
+				if (str == L"")break;
+				xstring susername = publiccode::GetUser().name;
+				cell1.SetItemString(row, purchercol - 1, susername);
+				row++;
+			}
+
+			if (SendToPurcher(supplier, cell1.GetData()) == -1) return 1;
+			if (strs.find(L",L", 0) > 0)
+			{
+				supplier = strs.left(strs.find(L",L", 0));
+				strs = strs.mid(strs.find(L",L", 0) + 1, 9999);
+			}
+			else
+			{
+				supplier = strs;
+				strs = L"";
+			}
+
+		}
+		OnUpdate();
+		//OnSaveEx(true);
+		//alert(L"璇环淇℃伅宸插彂閫佺粰:"+purchors);
+
+		return 1;
+	}
+
+	//鐒︾偣婵�娲诲鐞嗗嚱鏁�
+	int OnSetFocus(ref TEvent evt, int param)
+	{
+		//閲嶇疆宸ュ叿鏉�
+		SetAgent();
+		return 1;
+	}
+
+	int OpenTemplate(xstring id)
+	{
+		xml x = ViewObject::RetrieveData(L"/sale/data/TO/template/param", L"TemplateID", id);
+
+		xml sheet ;
+		sheet.setNativePointer(x.CreateInstance());
+		sheet.loadXML(x.selectSingleNode(L"data/*").xml);
+
+		dw_cell.LoadTemplate(sheet);
+		dw_cell.Redraw();
+
+		return 1;
+	}
+
+	int OpenDocument(xstring id)
+	{
+		trace(L"BusinessItemID:" + id);
+		xml x = ViewObject::RetrieveData(L"/sale/data/TO/business/document", L"BusinessItemID", id);
+
+		/*
+		xml sheet ;
+		sheet.setNativePointer(x.CreateInstance());
+		sheet.loadXML(x.selectSingleNode(L"data/*").xml);
+		*/
+
+		//trace(x.xml());
+		dw_cell.LoadTemplate(x);
+		dw_cell.Redraw();
+
+		return 1;
+	}
+
+	xml GetProduct(xstring GoodsNo)
+	{
+		return  ViewObject::RetrieveData(L"/sale/data/ProductLibrary3/ProductByGoodsNoWithShip", L"GoodsNo", GoodsNo);
+	}
+
+	int OpenDocumentEntity(xstring id)
+	{
+		xml x = ViewObject::RetrieveData(L"/sale/data/TO/business/documententity", L"BusinessID", id);
+
+		/*
+		xml sheet ;
+		sheet.setNativePointer(x.CreateInstance());
+		sheet.loadXML(x.selectSingleNode(L"data/*").xml);
+		*/
+
+		dw_cell.LoadTemplate(x);
+		dw_cell.Redraw();
+
+		return 1;
+	}
+
+	int Reset()
+	{
+		action = L"new";
+		entityID = L"";
+		entityItemID = L"";
+		templateID = L"";
+		return 1;
+	}
+
+
+	static stdcall int GetModuleFileName(int hModule, xstring lpFileName, int nSize) native from "kernel32.dll" alias "GetModuleFileNameW";
+	static stdcall int PathRemoveFileSpec(xstring lpFileName) native from "shlwapi.dll" alias "PathRemoveFileSpecW";
+
+	xstring GetModulePath()
+	{
+		xstring str = L"";
+		str = str.space(255);
+		GetModuleFileName(0, str, 250);
+		PathRemoveFileSpec(str);
+		return str;
+	}
+
+	xstring GetModuleTmpPath()
+	{
+		xstring str = L"";
+		str = str.space(255);
+		GetModuleFileName(0, str, 250);
+		PathRemoveFileSpec(str);
+		xstring tmp = str + L"\\Temp";
+		xaserver::CreateDirectory(tmp);
+		return tmp;
+	}
+
+	xstring UploadImage(xstring guid)
+	{
+		return UploadImage(guid, L"");
+	}
+
+	xstring UploadImage(xstring guid, xstring filename)
+	{
+		xstring name = guid + L".jpg";
+		xstring str = name.mid(0, 2);
+		str = str.upper();
+		int ret = 1;
+		if (filename != L"")
+			ret = xaserver::Upload(L"product" + str, name, filename, this.GetHWND(), L"", false);
+		else
+			ret = xaserver::Upload(L"product" + str, name, this.GetHWND(), L"", false);
+		if (ret == -1) return L"";
+		if (ret == 0)
+		{
+			alert(L"鍥剧墖涓婁紶澶辫触锛�");
+			return L"";
+		}
+		return GetImageUrl(guid);
+
+		/*
+		xstring appPath = GetModuleTmpPath();
+		xaserver::CreateDirectory(appPath);
+		ret = xaserver::DownLoadFile(GetServerUrl(),L"/business/products/chanpin/"+str+L"/"+name,name,appPath+L"/"+name);
+		if(ret < 0)
+		{
+			alert(L"鍥剧墖涓嬭浇澶辫触1锛�");
+			return L"";
+		}
+
+		xutil::SmallImage(appPath+L"\\"+name,appPath+L"\\"+L"x_"+name,120,120);
+		int ret_1 = xaserver::Upload(L"product"+str, L"x_"+name,appPath+L"\\x_"+name, this.GetHWND(),L"",false);
+		//xaserver::DeleteFile(appPath+L"x_"+name);
+		//xaserver::DeleteFile(appPath+name);
+		if(ret_1 != 1)
+		{
+			alert(L"涓婁紶缂╃暐鍥惧け璐�!");
+			return L"";
+		}
+		return appPath+L"/"+name;
+		*/
+	}
+
+	xstring UploadImage1(xstring guid, xstring filename)
+	{
+		xstring name = guid + L".jpg";
+		xstring str = name.mid(0, 2);
+		str = str.upper();
+		int ret = 1;
+		if (filename != L"")
+			ret = xaserver::Upload(L"product" + str, name, filename, this.GetHWND(), L"", false);
+		else
+			ret = xaserver::Upload(L"product" + str, name, this.GetHWND(), L"", false);
+		if (ret == -1) return L"";
+		if (ret == 0)
+		{
+			alert(L"鍥剧墖涓婁紶澶辫触锛�");
+			return L"";
+		}
+
+		xstring appPath = GetModuleTmpPath();
+		xaserver::CreateDirectory(appPath);
+		ret = xaserver::DownLoadFile(GetServerUrl(), L"/business/products/chanpin/" + str + L"/" + name, name, appPath + L"/" + name);
+		if (ret < 0)
+		{
+			alert(L"鍥剧墖涓嬭浇澶辫触1锛�");
+			return L"";
+		}
+
+		xutil::SmallImage(appPath + L"\\" + name, appPath + L"\\" + L"x_" + name, 120, 120);
+		int ret_1 = xaserver::Upload(L"product" + str, L"x_" + name, appPath + L"\\x_" + name, this.GetHWND(), L"", false);
+		//xaserver::DeleteFile(appPath+L"x_"+name);
+		//xaserver::DeleteFile(appPath+name);
+		if (ret_1 != 1)
+		{
+			alert(L"涓婁紶缂╃暐鍥惧け璐�!");
+			return L"";
+		}
+		return appPath + L"/" + name;
+	}
+
+	int ClearImageTerm(int row, xstring tm)
+	{
+		xstring str = dw_cell.GetItemString(row, 0);
+		if (str.right(1) != L";") str += L";";
+		if (str.find(tm + L":") >= 0)
+		{
+			int pos = str.find(L";", str.find(tm + L":") + 1);
+			if (pos < 0) return 1;
+			str = str.left(str.find(tm + L":")) + str.mid(pos, 99999);
+		}
+		return 1;
+	}
+
+	int AddImageTermEx(int row, xstring tm, xstring guid, xstring path = L"")
+	{
+		ximageview im = GetControl(L"frame:im1");
+		xstring str = dw_cell.GetItemString(row, 0);
+		if (str.right(1) != L";") str += L";";
+		if (str.find(tm + L":") >= 0)
+		{
+			int pos = str.find(L";", str.find(tm + L":") + 1);
+			if (pos < 0) return 1;
+			str = str.left(pos) + L",L" + guid + str.mid(pos, 99999);
+		}
+		else
+		{
+			str += tm + L":" + guid + L";";
+		}
+		dw_cell.SetItemString(row, 0, str);
+		return 1;
+	}
+
+	int AddImageTerm(int row, xstring tm, xstring guid, xstring path = L"")
+	{
+		ximageview im = GetControl(L"frame:im1");
+		xstring str = dw_cell.GetItemString(row, 0);
+		if (str.right(1) != L";") str += L";";
+		if (str.find(tm + L":") >= 0)
+		{
+			int pos = str.find(L";", str.find(tm + L":") + 1);
+			if (pos < 0) return 1;
+			if (pos > 0 && str.mid(pos - 1, 1) == L":")
+				str = str.left(pos) + guid + str.mid(pos, 99999);
+			else
+				str = str.left(pos) + L",L" + guid + str.mid(pos, 99999);
+		}
+		else
+		{
+			str += tm + L":" + guid + L";";
+		}
+
+		xstring goodno = L"瀹㈡埛鍥剧墖";
+		if (tm == L"supplier-photo") goodno = L"渚涘簲鍟嗗浘鐗�";
+		xstring picname = path;
+		if (picname == L"") picname = L"/business/products/chanpin/" + guid.left(2) + L"/" + guid + L".jpg";
+		im.AddImages(picname, goodno);
+		im.Redraw();
+		dw_cell.SetItemString(row, 0, str);
+		//trace(L"\r\n"+str);
+		return 1;
+	}
+
+	int getItemCount(xstring str, xstring tm)
+	{
+		if (str.find(tm + L":") < 0) return 0;
+		int pos = str.find(L";", str.find(tm + L":") + 1);
+		if (pos < 0) pos = str.length() + 1;
+
+		xstring images = str.mid(str.find(tm + L":") + (tm + L":").length(), 99999);
+		images = images.left(pos);
+
+		int spos = 0;
+		int count = 0;
+		while (true)
+		{
+			count++;
+			spos = images.find(L",L", spos + 1);
+			if (spos < 0) break;
+		}
+		trace(L" count:" + xstring(count));
+		return count;
+	}
+
+	int OnImageDel()
+	{
+		int row = dw_cell.GetRow();
+		int startRow = getItemHeadRow(dw_cell);
+
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return 0;
+		startRow++;
+		int colPhoto = getItemCol(dw_cell, startRow - 1, L"Photo,Customer Photo");
+		int colPhoto1 = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		if (row < startRow) return  0;
+
+		xstring str = dw_cell.GetItemString(row, 0);
+		xstring tm = L"customer-photo";
+		int colimage = colPhoto;
+
+		int sindex = 0;
+		int cindex = 0;
+
+		ximageview im = GetControl(L"frame:im1");
+		int index = im.GetSelectIndex();
+		if (index < 0 || index > im.GetImageCount()) return 1;
+
+		if (action == L"purch")
+		{
+			tm = L"supplier-photo";
+			colimage = colPhoto1;
+			sindex = getItemCount(str, L"customer-photo");
+		}
+		else
+		{
+			trace(L"index:" + xstring(index) + L"--" + L"cnt:" + xstring(getItemCount(str, L"customer-photo")));
+			if (index >= getItemCount(str, L"customer-photo"))
+				return 1;
+		}
+
+		if (str.find(tm + L":"))
+		{
+			//trace(xstring(index)+L"-"+xstring(sindex));
+
+			index -= sindex;
+			if (index < 0) return 1;
+
+			int pos = str.find(L";", str.find(tm + L":") + 1);
+			if (pos < 0) pos = str.length() + 1;
+
+			xstring imageurl = im.GetImageUrl(index + sindex);
+			xstring images = str.mid(str.find(tm + L":") + (tm + L":").length(), 99999);
+			images = images.left(pos);
+			int spos = 0;
+			int i = 0;
+
+			if (action != L"purch" && index == 0 && getItemCount(str, L"customer-photo") == 1)
+			{
+				images = L";";
+			}
+			else
+			{
+				while (true)
+				{
+					if (i == index) break;
+					spos = images.find(L",L", spos + 1);
+					if (spos < 0) break;
+					i++;
+				}
+				int epos = images.find(L",L", spos + 1);
+				if (spos >= 0)
+				{
+					if (epos < 0)
+						images = images.left(spos);
+					else
+						images = images.left(spos) + images.mid(epos, 99999);
+				}
+				if (images.right(1) != L";") images += L";";
+			}
+
+			str = str.left(str.find(tm + L":") + (tm + L":").length()) + images + str.mid(pos + 1, 99999);
+			dw_cell.SetItemString(row, 0, str);
+
+
+			if (index >= 0) im.RemoveImage(index + sindex);
+			//im.ResetEx();
+			im.Redraw();
+			if (index == 0)dw_cell.SetItemString(row, colimage, L"");
+
+			if (im.GetImageCount() - sindex >= 1)
+			{
+				if (images.find(L",L") == 0) images = images.mid(1, 9999);
+				int pos1 = images.find(L",L");
+				if (pos1 < 0) pos1 = images.find(L";");
+				xstring id = images;
+				if (pos1 >= 0) id = images.left(pos1);
+
+				if (id != L"")
+				{
+					xstring name = id + L".jpg";
+
+					//xstring appPath = GetModuleTmpPath();
+					//xaserver::CreateDirectory(appPath);
+					//xaserver::DownLoadFile(GetServerUrl(),L"/business/products/chanpin/"+id.left(2)+L"/"+name,name,appPath+L"/"+name);
+
+					if (startRow > 1)
+					{
+						xstring props = dw_cell.GetCellProps(row, colimage);
+						props = L"<cellprop><edit edittype='image'/></cellprop>";
+						dw_cell.SetCellProps(row, colPhoto, props);
+						dw_cell.SetItemString(row, colimage, GetImageUrl(id));
+					}
+				}
+			}
+		}
+		else
+			dw_cell.SetItemString(row, colimage, L"");
+		dw_cell.Redraw();
+
+		return 1;
+	}
+
+	int OnImageAdd1()
+	{
+		int row = dw_cell.GetRow();
+		int startRow = getItemHeadRow(dw_cell);
+
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return 0;
+		startRow++;
+		int colPhoto = getItemCol(dw_cell, startRow - 1, L"Photo,Customer Photo");
+		int colPhoto1 = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int LastRow = dw_cell.GetValidRow();
+		if (row < startRow) return  0;
+
+		xstring props = dw_cell.GetCellProps(row, colPhoto);
+		props = L"<cellprop><edit edittype='image'/></cellprop>";
+		dw_cell.SetCellProps(row, colPhoto, props);
+		dw_cell.SetCellProps(row, colPhoto1, props);
+
+		xstring appPath = GetModuleTmpPath();
+		xstring guid = ViewObject::GetGuid();
+		xstring filename1 = UploadImage(guid);
+		if (filename1 != L"")
+		{
+			if (action == L"purch")
+			{
+				//dw_cell.SetItemString(row,colPhoto1,file);
+				AddImageTerm(row, L"supplier-photo", guid);
+				if (dw_cell.GetItemString(row, colPhoto1) == L"")
+					dw_cell.SetItemString(row, colPhoto1, appPath + L"\\" + L"x_" + guid + L".jpg");
+			}
+			else
+			{
+				//dw_cell.SetItemString(row,colPhoto,file);
+				AddImageTerm(row, L"customer-photo", guid);
+				if (dw_cell.GetItemString(row, colPhoto) == L"")
+					dw_cell.SetItemString(row, colPhoto, appPath + L"\\" + L"x_" + guid + L".jpg");
+			}
+			dw_cell.SetRowHeight(row, dw_cell.GetRowHeight(row));
+			dw_cell.Redraw();
+			Redraw();
+		}
+
+		return 1;
+	}
+
+	int GetOpenFileNames(StringArray items, xstring initFileName, xstring filter, xstring ext)
+	{
+		//xstring path = GetOpenFileName(L"",
+		//		"JPEG 鏂囦欢(*.jpg)\0*.jpg;*.jpeg;*.png;*.gif;*.bmp\0鍏ㄩ儴鏂囦欢(*.*)\0*.*\0",
+		//		"jpg");		
+
+		char[]  szFileName = new char[4096];
+		char[]  szPath = new char[4096];
+		szFileName[0] = 0;
+		szPath[0] = 0;
+
+		if (initFileName != L"")
+		{
+			int len = initFileName.length();
+			char[] tmp = initFileName;
+			for (int i = 0; i < len + 1; i++)
+			{
+				//szFileName[i] = tmp[i];
+				szPath[i] = tmp[i];
+			}
+		}
+
+		int	 nFilterIndex = 1;
+		ref OPENFILENAMEW ofn = new OPENFILENAMEW;
+
+		ofn.lStructSize = 88;//sizeof(ofn);
+		ofn.hwndOwner = 0;
+		ofn.hInstance = 0;
+		ofn.lpstrFilter = filter;
+		//"JPEG 鏂囦欢(*.jpg)\0*.jpg;*.jpeg;*.png;*.gif;*.bmp\0鍏ㄩ儴鏂囦欢(*.*)\0*.*\0";
+		ofn.lpstrCustomFilter = 0;
+		ofn.nMaxCustFilter = 0;
+		ofn.nFilterIndex = nFilterIndex;
+		ofn.lpstrFile = szPath;
+		ofn.nMaxFile = 4096;
+		ofn.lpstrFileTitle = szFileName;
+		ofn.nMaxFileTitle = 4096;
+		ofn.lpstrTitle = L"璇锋寚瀹氭枃浠跺悕";
+		ofn.lpstrDefExt = ext;
+		//"jpg";
+		ofn.lpstrInitialDir = 0;
+		ofn.Flags = 0x00000010/*OFN_SHOWHELP*/ | 0x00001000/*OFN_FILEMUSTEXIST*/
+			| 0x00000200 /*OFN_ALLOWMULTISELECT*/ | 0x00080000 /*OFN_EXPLORER*/;
+		ofn.lCustData = 0;
+		ofn.lpfnHook = 0;
+		ofn.lpTemplateName = 0;
+
+		ofn.nFileOffset = 0;
+		ofn.nFileExtension = 0;
+
+		//debugbreak();
+		if (file::GetOpenFileName(ofn))
+		{
+			int pos = ofn.nFileOffset & 0xffff;
+			xstring path = szPath;
+			if (pos < path.length()) //select one
+			{
+				items.push_back(path + L"");
+			}
+			else
+			{
+				int start = cast(szPath as int);
+				start += pos * 2;
+				xstring str = cast(start  as xstring);
+				while (true)
+				{
+					if (str == L"")break;
+					items.push_back(path + L"/" + str);
+					start += (str.length() + 1) * 2;
+					str = cast(start  as xstring);
+				}
+			}
+		}
+		delete szFileName;
+		delete szPath;
+		delete ofn;
+
+		return items.length();
+	}
+
+	int OnImageAddEx()
+	{
+		int row = dw_cell.GetRow();
+		int startRow = getItemHeadRow(dw_cell);
+
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return 0;
+		startRow++;
+		int colPhoto = getItemCol(dw_cell, startRow - 1, L"Photo,Customer Photo");
+		int colPhoto1 = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int LastRow = dw_cell.GetValidRow();
+		if (row < startRow) return  0;
+
+		xstring appPath = GetModuleTmpPath();
+		StringArray items;
+		items = StringArray::make();
+		GetOpenFileNames(items, L"",
+			"JPEG 鏂囦欢(*.jpg)\0*.jpg;*.jpeg;*.png;*.gif;*.bmp\0鍏ㄩ儴鏂囦欢(*.*)\0*.*\0",
+			"jpg");
+		if (items.length() < 1) return 1;
+
+		int sRow = row;
+		for (int i = 0; i < items.length(); i++)
+		{
+			row = sRow + i;
+			xstring props = dw_cell.GetCellProps(row, colPhoto);
+			props = L"<cellprop><edit edittype='image'/></cellprop>";
+			dw_cell.SetCellProps(row, colPhoto, props);
+			dw_cell.SetCellProps(row, colPhoto1, props);
+
+			xstring guid = ViewObject::GetGuid();
+			xstring filename1 = UploadImage(guid, items.item(i));
+			int rowheight = dw_cell.GetRowHeight(row);
+			if (rowheight < 50) rowheight = 50;
+			if (filename1 != L"")
+			{
+				if (action == L"purch")
+				{
+					//dw_cell.SetItemString(row,colPhoto1,file);
+					if (i == 0)
+						AddImageTerm(row, L"supplier-photo", guid);
+					else
+						AddImageTermEx(row, L"supplier-photo", guid);
+					if (dw_cell.GetItemString(row, colPhoto1) == L"")
+					{
+						//dw_cell.SetItemString(row,colPhoto1,appPath+L"\\"+L"x_"+guid+L".jpg");
+						dw_cell.SetItemString(row, colPhoto1, GetImageUrl(guid));
+						dw_cell.SetRowHeight(row, rowheight);
+					}
+				}
+				else
+				{
+					//dw_cell.SetItemString(row,colPhoto,file);
+					if (i == 0)
+						AddImageTerm(row, L"customer-photo", guid);
+					else
+						AddImageTermEx(row, L"customer-photo", guid);
+					if (dw_cell.GetItemString(row, colPhoto) == L"")
+					{
+						//dw_cell.SetItemString(row,colPhoto,appPath+L"\\"+L"x_"+guid+L".jpg");
+						dw_cell.SetItemString(row, colPhoto, GetImageUrl(guid));
+						dw_cell.SetRowHeight(row, rowheight);
+					}
+				}
+			}
+			//dw_cell.SetRowHeight(row,dw_cell.GetRowHeight(row));
+			dw_cell.Redraw();
+			Redraw();
+		}
+
+		return 1;
+	}
+
+	int OnImageAdd()
+	{
+		int row = dw_cell.GetRow();
+		int startRow = getItemHeadRow(dw_cell);
+
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return 0;
+		startRow++;
+		int colPhoto = getItemCol(dw_cell, startRow - 1, L"Photo,Customer Photo");
+		int colPhoto1 = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int LastRow = dw_cell.GetValidRow();
+		if (row < startRow) return  0;
+
+		xstring props = dw_cell.GetCellProps(row, colPhoto);
+		props = L"<cellprop><edit edittype='image'/></cellprop>";
+		dw_cell.SetCellProps(row, colPhoto, props);
+		dw_cell.SetCellProps(row, colPhoto1, props);
+
+		xstring appPath = GetModuleTmpPath();
+		StringArray items;
+		items = StringArray::make();
+		GetOpenFileNames(items, L"",
+			L"JPEG 鏂囦欢(*.jpg)\0*.jpg;*.jpeg;*.png;*.gif;*.bmp\0鍏ㄩ儴鏂囦欢(*.*)\0*.*\0",
+			"jpg");
+		if (items.length() < 1) return 1;
+
+		for (int i = 0; i < items.length(); i++)
+		{
+			xstring guid = ViewObject::GetGuid();
+			xstring filename1 = UploadImage(guid, items.item(i));
+			int rowheight = dw_cell.GetRowHeight(row);
+			if (rowheight < 50) rowheight = 50;
+			if (action == L"purch")
+			{
+				//dw_cell.SetItemString(row,colPhoto1,file);
+				AddImageTerm(row, L"supplier-photo", guid);
+				if (dw_cell.GetItemString(row, colPhoto1) == L"")
+				{
+					//dw_cell.SetItemString(row,colPhoto1,appPath+L"\\"+L"x_"+guid+L".jpg");
+					dw_cell.SetItemString(row, colPhoto1, GetImageUrl(guid));
+					dw_cell.SetRowHeight(row, rowheight);
+				}
+			}
+			else
+			{
+				//dw_cell.SetItemString(row,colPhoto,file);
+				AddImageTerm(row, L"customer-photo", guid);
+				if (dw_cell.GetItemString(row, colPhoto) == L"")
+				{
+					//dw_cell.SetItemString(row,colPhoto,appPath+L"\\"+L"x_"+guid+L".jpg");
+					dw_cell.SetItemString(row, colPhoto, GetImageUrl(guid));
+					dw_cell.SetRowHeight(row, rowheight);
+				}
+			}
+			//dw_cell.SetRowHeight(row,dw_cell.GetRowHeight(row));
+			dw_cell.Redraw();
+			Redraw();
+		}
+
+		return 1;
+	}
+
+	int OnCellItemChanged(TEvent* evt, int p)
+	{
+		CELLNMHDR&  hdr = *(CELLNMHDR*)evt->notify.pnmh;
+		xstring value = hdr.data;
+		int row = hdr.currentrow;
+		int col = hdr.currentcol;
+
+		trace(L"\r\n----row:" + xstring(row) + L"--col:" + xstring(col));
+		trace(L"\r\n----row:" + xstring(row) + L"--col:" + xstring(col));
+		trace(L"\r\n--value:" + dw_cell.GetItemString(row, col) + L"--orig:" + orivalue);
+		if (row == ARow && col == ACol && dw_cell.GetItemString(row, col) == orivalue) return 1;
+		trace(L"\r\n--enter:");
+
+		ARow = row;
+		ACol = col;
+		orivalue = dw_cell.GetItemString(ARow, ACol) + L"";
+
+		int startRow = getItemHeadRow(dw_cell);
+		if (startRow < 1) return 1;
+		if (row < startRow + 1) return 1;
+		startRow++;
+
+		int colItemNo = getItemCol(dw_cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyerPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�,閲囪喘浠锋牸");
+		int colBuyer = getItemCol(dw_cell, startRow - 1, L"閲囪喘浜哄憳");
+		int colCustomerPhoto = getItemCol(dw_cell, startRow - 1, L"Photo,Customer Photo");
+		int colPackage = getItemCol(dw_cell, startRow - 1, L"Package,鍖呰鏂瑰紡");
+		int colFOBPrice = getItemCol(dw_cell, startRow - 1, L"FOB Price,FOB Price(USD),Fob Price");
+		int colQty = getItemCol(dw_cell, startRow - 1, L"Qty,鏁伴噺");
+		//int colToPODate = getItemCol(dw_cell,startRow - 1,L"涓氬姟鍙戦�侀噰璐椂闂�");
+
+
+		int colVolDesc = getItemCol(dw_cell, startRow - 1, L"浣撶Н鎻忚堪,闀縓瀹絏楂�,闀縓瀹絏楂�(CM)L");
+		int colVol = getItemCol(dw_cell, startRow - 1, L"浣撶Н,浣撶Н(M3)L");
+		int colQtyPerPack = getItemCol(dw_cell, startRow - 1, L"瑁呯鏁�(鍐�/澶�),瑁呯鏁�(澶�/鍐�)L");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+		int colSKUID = getItemCol(dw_cell, startRow - 1, L"SKUID");
+
+		int colPONote = getItemCol(dw_cell, startRow - 1, L"閲囪喘To涓氬姟澶囨敞");
+		int colPOPhoto = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int colPOPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�");
+		int colNW = getItemCol(dw_cell, startRow - 1, L"姣涢噸(KG)L");
+		int colGW = getItemCol(dw_cell, startRow - 1, L"鍑�閲�(KG)L");
+		int colSKUNo = getItemCol(dw_cell, startRow - 1, L"SKUID,SKUNo");
+
+		if (col == colFOBPrice)
+		{
+			xstring fobprice = dw_cell.GetItemString(row, col);
+			if (fobprice.find(L"$") >= 0)fobprice = fobprice.mid(1, 999);
+			trace(L"+++++L" + fobprice + L"+++++L");
+			double colFOBPriceEx = fobprice.toDouble();
+
+			double colFOBPriceS;
+			colFOBPriceS = colFOBPriceEx.round(2);
+			xstring colFOBPriceS1 = xstring(colFOBPriceS);
+			xstring colFOBPriceS2 = colFOBPriceS1.left(colFOBPriceS1.find(L"."));
+			xstring colFOBPriceS3 = colFOBPriceS1.mid(colFOBPriceS1.find(L"."), colFOBPriceS1.length());
+			xstring colFOBPriceS4 = colFOBPriceS3.mid(1, 2);
+			trace(L"******" + colFOBPriceS1 + L"****" + colFOBPriceS2 + L"****" + colFOBPriceS3 + L"****" + colFOBPriceS4 + L"****");
+
+			if (fobprice != L"")dw_cell.SetItemString(row, col, L"$" + colFOBPriceS2 + L"." + colFOBPriceS4);
+			return 1;
+		}
+
+		if (col == colItemNo)
+		{
+			if (dw_cell.GetItemString(row, colItemNo) != L"")
+			{
+				xaserverarg argx ;
+				argx.setNativePointer(argx.CreateInstance());
+				argx.AddArg(L"GoodsNo", dw_cell.GetItemString(row, colItemNo));
+				OpenWindow(L"dev:xpage[CustomerItemNoList.vx]", cast(argx as int));
+				if (argx.GetArgString(L"action") != L"ok") return 1;
+
+				xml x1 ;
+				x1.loadXML(argx.GetArgString(L"items"));
+				if (x1.selectSingleNode(L"//CustomerItemNo"))
+				{
+					xstring CustomerItemNo = x1.selectSingleNode(L"//CustomerItemNo").text();
+					dw_cell.SetItemString(row, colCustomerItemNo, CustomerItemNo);
+				}
+
+				xml goods = GetProduct(dw_cell.GetItemString(row, colItemNo));
+
+				if (goods)
+				{
+					dw_cell.SetItemString(row, colCustomerPhoto, L"");
+					resetRowTerm(dw_cell, row, L"customer-photo");
+					if (goods.selectSingleNode(L"//SKUID[1]"))
+					{
+						setRowProp(dw_cell, row, L"SKUID", goods.selectSingleNode(L"//SKUID[1]").text());
+					}
+					if (goods.selectSingleNode(L"//SKUNo[1]"))
+					{
+						dw_cell.SetItemString(row, colSKUNo, goods.selectSingleNode(L"//SKUNo[1]").text());
+					}
+					if (goods.selectSingleNode(L"//EName[1]"))
+						dw_cell.SetItemString(row, colItemName, goods.selectSingleNode(L"//EName[1]").text());
+					if (goods.selectSingleNode(L"//CName[1]"))
+						dw_cell.SetItemString(row, colItemCName, goods.selectSingleNode(L"//CName[1]").text());
+					if (goods.selectSingleNode(L"//Packing[1]"))
+						dw_cell.SetItemString(row, colPackage, goods.selectSingleNode(L"//Packing[1]").text());
+					if (goods.selectSingleNode(L"//POCreatorID[1]"))
+					{
+						dw_cell.SetItemString(row, colBuyer, goods.selectSingleNode(L"//POCreatorID[1]").text());
+					}
+					if (goods.selectSingleNode(L"//PackingRate[1]"))
+					{
+						if (goods.selectSingleNode(L"//InnerQty[1]"))
+						{
+							xstring str1 = goods.selectSingleNode(L"//PackingRate[1]").text();
+							xstring str2 = goods.selectSingleNode(L"//InnerQty[1]").text();
+							dw_cell.SetItemString(row, colQtyPerPack, str2 + L"/" + str1);
+						}
+						else
+							dw_cell.SetItemString(row, colQtyPerPack, str1);
+					}
+					ProcessItemImage(dw_cell.GetItemString(row, colSKUNo), row);
+					//ProcessItemImage1(dw_cell.GetItemString(row,colItemNo),row);
+					dw_cell.SetRowColumn(row, col);
+					dw_cell.SetAnchorRowColumn(row, col);
+
+					dw_cell.Redraw();
+				}
+			}
+		}
+
+		if (col == colVolDesc || col == colQtyPerPack)
+		{
+			/*璁$畻浣撶Н*/
+			double v = 0.0;
+			xstring desc = dw_cell.GetItemString(row, colVolDesc);
+			if (desc.find(L"cm") >= 0)
+			{
+				desc = desc.replace(L"cm", L"");
+				dw_cell.SetItemString(row, colVolDesc, desc);
+			}
+			if (desc.find(L"CM") >= 0)
+			{
+				desc = desc.replace(L"CM", L"");
+				dw_cell.SetItemString(row, colVolDesc, desc);
+			}
+			if (desc == L"")
+				dw_cell.SetItemString(row, colVol, L"");
+			else
+			{
+				v = calcVol(desc) / 1000000.00;
+				xstring str = xstring(v);
+				if (str.find(L".") >= 0)	str = str.left(str.find(L".") + 5);
+				dw_cell.SetItemString(row, colVol, str);
+				dw_cell.Redraw();
+			}
+
+			xstring qtyperPack = dw_cell.GetItemString(row, colQtyPerPack);
+			if (qtyperPack != L"")
+			{
+				xstring qty1 = qtyperPack;
+				xstring qty2 = L"";
+				double qty = 0.00;
+				int pos2 = qtyperPack.find(L"/");
+				if (pos2 >= 0)
+				{
+					qty1 = qtyperPack.left(qtyperPack.find(L"/"));
+					qty2 = qtyperPack.mid(qtyperPack.find(L"/") + 1, 9999);
+				}
+				//if(qty1 !=L"") qty = qty1.toDouble();
+				//if(qty2 !=L"") qty = qty*qty2.toDouble();
+				qty = qty2.toDouble();
+				double ttl = 65.0 * qty / v;
+				dw_cell.SetItemString(row, col40HQ, ttl.toInt().toString());
+			}
+		}
+
+		if (action == L"purch")
+		{
+			int colPrice0 = getItemCol(dw_cell, startRow - 1, L"浠锋牸");
+			int colPrice1 = getItemCol(dw_cell, startRow - 1, L"浠锋牸1");
+			int colPrice2 = getItemCol(dw_cell, startRow - 1, L"浠锋牸2");
+			int colPrice3 = getItemCol(dw_cell, startRow - 1, L"浠锋牸3");
+			int colPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�");
+
+			int colTyp = getItemCol(dw_cell, startRow - 1, L"绫诲瀷");
+			int colTyp1 = getItemCol(dw_cell, startRow - 1, L"绫诲瀷1");
+			int colTyp2 = getItemCol(dw_cell, startRow - 1, L"绫诲瀷2");
+			int colTyp3 = getItemCol(dw_cell, startRow - 1, L"绫诲瀷3");
+			int colSupplier = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�,宸ュ巶");
+			int colSupplier1 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�1,宸ュ巶1");
+			int colSupplier2 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�2,宸ュ巶2");
+			int colSupplier3 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�3,宸ュ巶3");
+
+			if (colPrice0 == col || colPrice1 == col || colPrice2 == col || colPrice3 == col)
+			{
+				trace(L"\r\n---*****---hit col:" + xstring(col) + L"----");
+				xstring pricea = L"";
+				xstring priceb = L"";
+				xstring pricec = L"";
+				if (action == L"purch")
+				{
+					xstring price0 = dw_cell.GetItemString(row, colPrice0);
+					xstring price1 = dw_cell.GetItemString(row, colPrice1);
+					xstring price2 = L"";
+					if (colPrice2 > 0) price2 = dw_cell.GetItemString(row, colPrice2);
+					xstring price3 = L"";
+					if (colPrice3 > 0) price3 = dw_cell.GetItemString(row, colPrice3);
+
+					xstring price = L"";
+
+					if (price0 != L"")
+					{
+						price = price0;
+						if (price.find(L"A") < 1 && price.find(L"B") < 1 && price.find(L"C") < 1 && price.find(L"a") < 1 && price.find(L"b") < 1 && price.find(L"b") < 1)
+						{
+							alert(L"浠锋牸涓病鎸囧畾ABC");
+							if (pricea == L"") pricea = price; else pricea += L"+L" + price;
+						}
+						else if (price.find(L"A") > 0 || price.find(L"a") > 0)
+							if (pricea == L"") pricea = price; else pricea += L"+L" + price;
+						else if (price.find(L"B") > 0 || price.find(L"b") > 0)
+							if (priceb == L"") priceb = price; else priceb += L"+L" + price;
+						else if (price.find(L"C") > 0 || price.find(L"c") > 0)
+							if (pricec == L"") pricec = price; else pricec += L"+L" + price;
+					}
+					if (price1 != L"")
+					{
+						price = price1;
+						if (price.find(L"A") < 1 && price.find(L"B") < 1 && price.find(L"C") < 1 && price.find(L"a") < 1 && price.find(L"b") < 1 && price.find(L"b") < 1)
+						{
+							alert(L"浠锋牸涓病鎸囧畾ABC");
+							if (pricea == L"") pricea = price; else pricea += L"+L" + price;
+						}
+						else if (price.find(L"A") > 0 || price.find(L"a") > 0)
+							if (pricea == L"") pricea = price; else pricea += L"+L" + price;
+						else if (price.find(L"B") > 0 || price.find(L"b") > 0)
+							if (priceb == L"") priceb = price; else priceb += L"+L" + price;
+						else if (price.find(L"C") > 0 || price.find(L"c") > 0)
+							if (pricec == L"") pricec = price; else pricec += L"+L" + price;
+					}
+					if (price2 != L"")
+					{
+						price = price2;
+						if (price.find(L"A") < 1 && price.find(L"B") < 1 && price.find(L"C") < 1 && price.find(L"a") < 1 && price.find(L"b") < 1 && price.find(L"b") < 1)
+						{
+							alert(L"浠锋牸涓病鎸囧畾ABC");
+							if (pricea == L"") pricea = price; else pricea += L"+L" + price;
+						}
+						else if (price.find(L"A") > 0 || price.find(L"a") > 0)
+							if (pricea == L"") pricea = price; else pricea += L"+L" + price;
+						else if (price.find(L"B") > 0 || price.find(L"b") > 0)
+							if (priceb == L"") priceb = price; else priceb += L"+L" + price;
+						else if (price.find(L"C") > 0 || price.find(L"c") > 0)
+							if (pricec == L"") pricec = price; else pricec += L"+L" + price;
+					}
+					if (price3 != L"")
+					{
+						price = price3;
+						if (price.find(L"A") < 1 && price.find(L"B") < 1 && price.find(L"C") < 1 && price.find(L"a") < 1 && price.find(L"b") < 1 && price.find(L"b") < 1)
+						{
+							alert(L"浠锋牸涓病鎸囧畾ABC");
+							if (pricea == L"") pricea = price; else pricea += L"+L" + price;
+						}
+						else if (price.find(L"A") > 0 || price.find(L"a") > 0)
+							if (pricea == L"") pricea = price; else pricea += L"+L" + price;
+						else if (price.find(L"B") > 0 || price.find(L"b") > 0)
+							if (priceb == L"") priceb = price; else priceb += L"+L" + price;
+						else if (price.find(L"C") > 0 || price.find(L"c") > 0)
+							if (pricec == L"") pricec = price; else pricec += L"+L" + price;
+					}
+					price = pricec;
+					if (priceb != L"")
+					{
+						if (price == L"")
+							price = priceb;
+						else
+							price += L"+L" + priceb;
+					}
+					if (pricea != L"")
+					{
+						if (price == L"")
+							price = pricea;
+						else
+							price += L"+L" + pricea;
+					}
+					dw_cell.SetItemString(row, colPrice, price);
+					dw_cell.Redraw();
+				}
+			}
+		}
+
+		return 1;
+	}
+
+	int OnCellSelectChanged(ref TNotifyEvent evt, int p)
+	{
+		/*ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR);
+		xstring colname=hdr.colname;
+		xstring value = hdr.data;
+		int row = hdr.row;
+		*/
+		trace(L"========111============L");
+		return 1;
+	}
+
+	int OnItemChanged(ref TNotifyEvent evt, int p)
+	{
+		ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR);
+		xstring colname = hdr.colname;
+		xstring value = hdr.data;
+		int row = hdr.row;
+
+		if (colname == L"Project")
+		{
+
+			setBaseItem(dw_cell, L"椤圭洰鍚嶇О:", value);
+		}
+		return 1;
+	}
+
+	int OnToQuote()
+	{
+		xstring project = getBaseItem(dw_cell, L"椤圭洰鍚嶇О:");
+		if (project != L"")dw_base.SetItemString(1, L"Project", project);
+
+		int startRow = getItemHeadRow(dw_cell);
+
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return L"";
+		startRow++;
+
+		int colItemNo = getItemCol(dw_cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+
+		int colTechNote = getItemCol(dw_cell, startRow - 1, L"涓氬姟閮ㄤ骇鍝佷俊鎭�");
+		int colTechNote1 = getItemCol(dw_cell, startRow - 1, L"閲囪喘閮ㄤ骇鍝佷俊鎭�");
+
+
+
+		int colBuyerPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�,閲囪喘浠锋牸");
+		int colPackage = getItemCol(dw_cell, startRow - 1, L"Package");
+		int colPurchor = getItemCol(dw_cell, startRow - 1, L"閲囪喘鍛�,閲囪喘浜哄憳");
+		int colQtyPerPack = getItemCol(dw_cell, startRow - 1, L"瑁呯鏁�(鍐�/澶�)L");
+		int colFOBPrice = getItemCol(dw_cell, startRow - 1, L"FOB Price,FOB Price(USD),Fob Price");
+		int colQuantity = getItemCol(dw_cell, startRow - 1, L"鏁伴噺,Qty");
+
+		int colBuyerRemark = getItemCol(dw_cell, startRow - 1, L"閲囪喘To涓氬姟澶囨敞");
+		int colFactoryImage = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int colGWT = getItemCol(dw_cell, startRow - 1, L"姣涢噸,姣涢噸(KG)L");
+		int colNWT = getItemCol(dw_cell, startRow - 1, L"鍑�閲�,鍑�閲�(KG)L");
+		int colVolDesc = getItemCol(dw_cell, startRow - 1, L"浣撶Н鎻忚堪,闀縓瀹絏楂�,闀縓瀹絏楂�(CM)L");
+		int colVol = getItemCol(dw_cell, startRow - 1, L"浣撶Н,浣撶Н(M3)L");
+		int colHQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+		int colSKUNo = getItemCol(dw_cell, startRow - 1, L"SKUID,SKUNo");
+
+
+
+		ensureRowID();
+		int LastRow = dw_cell.GetValidRow();
+		xstring content = L"";
+		for (int row = startRow; row <= LastRow; row++)
+		{
+			xstring rowid = getRowID(dw_cell, row);
+			if (rowid == L"")continue;
+			if (dw_cell.GetItemString(row, colItemName) == L"")
+			{
+				if (dw_cell.GetItemString(row, colItemCName) == L"") break;
+			}
+			int i = 1;
+			for (i = 1; i <= dw_goods.GetRowCount(); i++)
+			{
+				if (dw_goods.GetGuid(i) == rowid) break;
+			}
+			if (i > dw_goods.GetRowCount())
+			{
+				dw_goods.InsertRow(0);
+				KXMLDOMElement e = dw_goods.GetRowElement(i);
+				e.setAttribute(L"guid", rowid);
+			}
+
+			xstring SKUID = getRowProp(dw_cell, row, L"SKUID");
+			if (SKUID != L"")
+			{
+				dw_goods.SetItemString(i, L"SKUID", SKUID);
+				dw_goods.SetItemString(i, L"ItemID", SKUID);
+			}
+			dw_goods.SetItemString(i, L"SKUNo", dw_cell.GetItemString(row, colSKUNo));
+			//dw_goods.SetItemString(i,L"ItemID",dw_cell.GetItemNoteString(row,colSKUNo));
+
+			dw_goods.SetItemString(i, L"CustomerItemNo", dw_cell.GetItemString(row, colCustomerItemNo));
+			dw_goods.SetItemString(i, L"GoodsNo", dw_cell.GetItemString(row, colItemNo));
+			dw_goods.SetItemString(i, L"ItemName", dw_cell.GetItemString(row, colItemName));
+			dw_goods.SetItemString(i, L"CItemName", dw_cell.GetItemString(row, colItemCName));
+			dw_goods.SetItemString(i, L"CName", dw_cell.GetItemString(row, colItemCName));
+
+			dw_goods.SetItemString(i, L"TechNote", dw_cell.GetItemString(row, colTechNote));
+			dw_goods.SetItemString(i, L"TechNote1", dw_cell.GetItemString(row, colTechNote1));
+			dw_goods.SetItemString(i, L"ProductDesc", dw_cell.GetItemString(row, colItemName));
+
+			dw_goods.SetItemString(i, L"Packing", dw_cell.GetItemString(row, colPackage));
+			dw_goods.SetItemString(i, L"VolumeDesc", dw_cell.GetItemString(row, colVolDesc));
+			dw_goods.SetItemString(i, L"Packages45H", dw_cell.GetItemString(row, colHQ));
+			dw_goods.SetItemString(i, L"ItemMiniQty", dw_cell.GetItemString(row, colQuantity));
+
+			if (getRowTerm(dw_cell, row, L"EnquiryLineID") != L"")
+			{
+				dw_goods.SetItemString(i, L"EnquiryPriceListID", getRowTerm(dw_cell, row, L"EnquiryLineID"));
+				dw_goods.SetItemString(i, L"EnquiryLineID", getRowTerm(dw_cell, row, L"EnquiryLineID"));
+			}
+
+			//dw_goods.SetItemString(i,L"Packages45H",dw_cell.GetItemString(row,colHQ));
+			//dw_goods.SetItemString(i,L"POPrice",dw_cell.GetItemString(row,colBuyerPrice));
+
+
+			xstring FobUnitPriceEx = dw_cell.GetItemString(row, colFOBPrice);
+			if (FobUnitPriceEx == L"$") FobUnitPriceEx = L"";
+			if (FobUnitPriceEx.find(L"$") >= 0) FobUnitPriceEx = FobUnitPriceEx.right(FobUnitPriceEx.length() - 1);
+			trace(FobUnitPriceEx);
+			//dw_goods.SetItemString(i,L"FobUnitPrice",dw_cell.GetItemString(row,colFOBPrice));
+			dw_goods.SetItemString(i, L"FobUnitPrice", FobUnitPriceEx);
+
+
+			dw_goods.SetItemDisplayString(i, L"POCreatorID", dw_cell.GetItemString(row, colPurchor));
+			dw_goods.SetItemString(i, L"POCreatorID", GetPurchorByName(dw_cell.GetItemString(row, colPurchor)));
+
+
+			xstring QtyPerPack = dw_cell.GetItemString(row, colQtyPerPack);
+			xstring outer = QtyPerPack;
+			if (QtyPerPack.find(L"/") >= 0) outer = QtyPerPack.left(QtyPerPack.find(L"/"));
+			xstring inner = L"";
+			if (QtyPerPack.find(L"/") >= 0) inner = QtyPerPack.mid(QtyPerPack.find(L"/") + 1, 9999);
+			dw_goods.SetItemString(i, L"InnerQty", outer);
+			dw_goods.SetItemString(i, L"Packages", inner);
+
+			dw_goods.Redraw();
+		}
+		int crow = dw_goods.GetRow();
+		if (crow > 0)
+		{
+			OnQuoteLineChanged(crow);
+			//OnShowImage(dw_goods.GetItemString(crow,L"SKUNo"),crow);
+		}
+
+		return 1;
+	}
+
+	int ProcessItemImage(xstring goodsno, int row)
+	{
+		xml xp ;
+		xp.setNativePointer(xml::CreateInstance());
+		xaserverarg arg_pic ;
+		arg_pic.setNativePointer(arg_pic.CreateInstance());
+		arg_pic.AddArg(L"SKUNo", goodsno);
+
+		ximageview im = GetControl(L"frame:im1");
+		im.ResetEx();
+		xstring res = L"/sale/data/productlibrary3/pref/picture/imagelistskuno";
+		if (xurl::get(res, arg_pic.GetString(), xp) != 1)
+		{
+			trace(xp.GetXml());
+			return 1;
+		}
+		else
+		{
+			//alert(xp.GetXml());
+			ClearImageTerm(row, L"customer-photo");
+			//alert(xp.GetXml());
+			KXMLDOMNodeList nlistp = xp.selectNodes(L"ImageList/image");
+			int lenp = nlistp.length();
+			int ip = 0;
+			if (lenp > 0) lenp = 1;
+			for (ip = 0; ip < lenp; ip++)
+			{
+				KXMLDOMNode xitem = nlistp.item(ip);
+				xstring id = xitem.selectSingleNode(L"@guid").text();
+				xstring path = L"";
+				if (xitem.selectSingleNode(L"PicPath")) path = xitem.selectSingleNode(L"PicPath").text();
+				xstring name = id + L".jpg";
+				if (path == L"") path = L"/business/products/chanpin/" + id.left(2) + L"/" + name;
+				AddImageTerm(row, L"customer-photo", id, path);
+				/*xstring picname = xitem.selectSingleNode(L"PicPath").text();
+				if(picname == L"/business/products/Thumbs//")
+					picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg";
+				im.AddImages(picname,goodsno);*/
+				if (ip == 0)
+				{
+					//xstring appPath = GetModuleTmpPath();
+					//xaserver::CreateDirectory(appPath);
+					//xaserver::DownLoadFile(GetServerUrl(),path,name,appPath+L"/"+name);
+
+					int startRow = getItemHeadRow(dw_cell);
+					if (startRow > 1)
+					{
+						int colPhoto = getItemCol(dw_cell, startRow, L"Photo,Customer Photo");
+						xstring props = dw_cell.GetCellProps(row, colPhoto);
+						props = L"<cellprop><edit edittype='image'/></cellprop>";
+						dw_cell.SetCellProps(row, colPhoto, props);
+						//dw_cell.SetItemString(row,colPhoto,appPath+L"\\"+name);
+						dw_cell.SetItemString(row, colPhoto, path);
+					}
+				}
+			}
+		}
+		return 1;
+	}
+
+	int ProcessItemImage1(xstring goodsno, int row)
+	{
+		xml xp ;
+		xp.setNativePointer(xml::CreateInstance());
+		xaserverarg arg_pic ;
+		arg_pic.setNativePointer(arg_pic.CreateInstance());
+		arg_pic.AddArg(L"GoodsNo", goodsno);
+
+		ximageview im = GetControl(L"frame:im1");
+		im.ResetEx();
+		xstring res = L"/sale/data/ProductLibrary3/pref/picture/imagelistItemNo";
+		if (xurl::get(res, arg_pic.GetString(), xp) != 1)
+		{
+			trace(xp.GetXml());
+			return 1;
+		}
+		else
+		{
+			ClearImageTerm(row, L"customer-photo");
+			//alert(xp.GetXml());
+			KXMLDOMNodeList nlistp = xp.selectNodes(L"ImageList/image");
+			int lenp = nlistp.length();
+			int ip = 0;
+			for (ip = 0; ip < lenp; ip++)
+			{
+				KXMLDOMNode xitem = nlistp.item(ip);
+				xstring id = xitem.selectSingleNode(L"@guid").text();
+				xstring name = id + L".jpg";
+				AddImageTerm(row, L"customer-photo", id);
+				/*xstring picname = xitem.selectSingleNode(L"PicPath").text();
+				if(picname == L"/business/products/Thumbs//")
+					picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg";
+				im.AddImages(picname,goodsno);*/
+				if (ip == 0)
+				{
+					xstring appPath = GetModuleTmpPath();
+					xaserver::CreateDirectory(appPath);
+					xaserver::DownLoadFile(GetServerUrl(), L"/business/products/chanpin/" + id.left(2) + L"/" + name, name, appPath + L"/" + name);
+
+					int startRow = getItemHeadRow(dw_cell);
+					if (startRow > 1)
+					{
+						int colPhoto = getItemCol(dw_cell, startRow, L"Photo,Customer Photo");
+						xstring props = dw_cell.GetCellProps(row, colPhoto);
+						props = L"<cellprop><edit edittype='image'/></cellprop>";
+						dw_cell.SetCellProps(row, colPhoto, props);
+						dw_cell.SetItemString(row, colPhoto, appPath + L"\\" + name);
+					}
+				}
+			}
+		}
+		return 1;
+	}
+
+	int OnAddBOMItem()
+	{
+		int startRow = getItemHeadRow(dw_cell);
+		int headrow = startRow;
+		if (startRow < 1) return 1;
+		startRow++;
+		int row = dw_cell.GetRow();
+
+		int colPurchPrice1 = getItemCol(dw_cell, headrow, L"浠锋牸1");
+		int colPurchPrice2 = getItemCol(dw_cell, headrow, L"浠锋牸2");
+		int colPurchPrice3 = getItemCol(dw_cell, headrow, L"浠锋牸3");
+		if (colPurchPrice3 > 0) return  1;
+
+		if (colPurchPrice2 < 1)
+		{
+			//dw_cell.SetColumnCount(dw_cell.GetColumnCount()+3);
+			//dw_cell.SetColumnCount(dw_cell.GetValidCol()+3);
+			dw_cell.SetRowColumn(row, colPurchPrice1 + 1);
+			dw_cell.SetAnchorRowColumn(row, colPurchPrice1 + 1);
+
+			SendCtrlCmd(dw_cell, L"xmFormatCellInsertCol");
+			SendCtrlCmd(dw_cell, L"xmFormatCellInsertCol");
+			SendCtrlCmd(dw_cell, L"xmFormatCellInsertCol");
+
+			dw_cell.SetItemString(headrow, colPurchPrice1 + 1, L"渚涘簲鍟�2");
+			dw_cell.SetItemString(headrow, colPurchPrice1 + 2, L"绫诲瀷2");
+			dw_cell.SetItemString(headrow, colPurchPrice1 + 3, L"浠锋牸2");
+		}
+		else
+		{
+			//dw_cell.SetColumnCount(dw_cell.GetColumnCount()+3);
+			//dw_cell.SetColumnCount(dw_cell.GetValidCol()+3);
+			dw_cell.SetRowColumn(row, colPurchPrice2 + 1);
+			dw_cell.SetAnchorRowColumn(row, colPurchPrice2 + 1);
+
+			SendCtrlCmd(dw_cell, L"xmFormatCellInsertCol");
+			SendCtrlCmd(dw_cell, L"xmFormatCellInsertCol");
+			SendCtrlCmd(dw_cell, L"xmFormatCellInsertCol");
+
+			dw_cell.SetItemString(headrow, colPurchPrice2 + 1, L"渚涘簲鍟�3");
+			dw_cell.SetItemString(headrow, colPurchPrice2 + 2, L"绫诲瀷3");
+			dw_cell.SetItemString(headrow, colPurchPrice2 + 3, L"浠锋牸3");
+		}
+		return 1;
+	}
+
+	//鍛戒护鍙戝竷鍑芥暟
+	int OnCmdDispatch(xstring comdid)
+	{
+		if (comdid == L"xmAddBOMItem") return OnAddBOMItem();
+		if (comdid == L"xmQuoteBill")
+		{
+			if (dw_base.GetItemString(1, L"CustomerID") == L"")
+			{
+				alert(L"瀵煎嚭鍓嶈杈撳叆瀹㈡埛");
+				return 1;
+			}
+			return OnPrint();
+		}
+		if (comdid == L"tab_quote")
+		{
+			tabsheet = L"tab_quote";
+			return OnToQuote();
+		}
+		if (comdid == L"xmMySupplier")
+			return OnMySupplier();
+		if (comdid == L"xmImageAdd")
+		{
+			OnImageAdd();
+			return 1;
+		}
+		if (comdid == L"xmImageAddEx")
+		{
+			OnImageAddEx();
+			return 1;
+		}
+		if (comdid == L"xmImageDel")
+		{
+			OnImageDel();
+			return 1;
+		}
+		else if (comdid == L"xmPurched")
+		{
+			//if(makeMessage(L"/task/quote/purchar/backtosaler")==-1) return 1;
+			return OnSaleBack();
+		}
+		else if (comdid == L"xmPurch")
+		{
+			return OnPurch();
+		}
+		else if (comdid == L"xmSetPurchor")
+		{
+			return OnNextPurch();
+		}
+		else if (comdid == L"xmSetPurchor")
+		{
+			return OnPurchEx();
+		}
+		else if (comdid == L"xmRefreshTask1")
+		{
+			win32::PostMessage(GetFrameWindow().GetHWND(), 0x401, L"xmRefreshTask", 0);
+			return 1;
+		}
+		else if (comdid == L"xmFileOpen" || comdid == L"xmOpen" || comdid == L"xmNew")
+		{
+			xstring suserid = publiccode::GetUser().id;
+			xaserverarg args ;
+			args.setNativePointer(args.CreateInstance());
+
+			if (comdid == L"xmNew")
+				OpenWindow(L"dev:xpage[TONewSelectDlg.vx]", cast(args as int));
+			else
+				OpenWindow(L"dev:xpage[TOSelectDlg.vx]", cast(args as int));
+			fileid = args.GetArgString(L"id");
+			templateID = args.GetArgString(L"templateID");
+			xstring myaction = args.GetArgString(L"action");
+			if (myaction == L"new" && action == L"new") Reset();
+			if (myaction == L"new")
+			{
+				action = L"new";
+				trace(args.GetArgString(L"id"));
+				return OpenTemplate(args.GetArgString(L"id"));
+			}
+			else if (myaction == L"open")
+			{
+				action = L"open";
+				entityID = args.GetArgString(L"ID");
+				entityItemID = args.GetArgString(L"ItemID");
+
+				OnRetrieve(entityID);
+				return OpenDocument(entityItemID);
+			}
+
+			return 1;
+
+			args.AddArg(L"src", L"data/QuoteFile/" + suserid);
+			args.AddArg(L"process", L"path");
+			OpenWindow(L"dev:xpage[trade.document.selectdlg.vx]", cast(args as int));
+			if (args.GetArgString(L"result") == L"ok")
+			{
+				xstring u = args.GetArgString(L"src");
+				xml x ;
+				
+				xaserver::LoadUrl(GetServerUrl(), u, L"", x);
+				trace(x.xml());
+				dw_cell.LoadTemplateEx(x.documentElement);
+				dw_cell.Redraw();
+				filename = args.GetArgString(L"filename");
+				fileid = args.GetArgString(L"ID");
+				win32::SetWindowText(GetHWND(), L"鎶ヤ环鏂囦欢:" + filename);
+			}
+			return 1;
+		}
+		else if (comdid == L"xmFileNew" || comdid == L"xmNew")
+		{
+			dw_cell.openUrl(templateurl);
+			dw_cell.Redraw();
+			filename = L"";
+			fileid = L"";
+			win32::SetWindowText(GetHWND(), L"鎶ヤ环鏂囦欢:[new]");
+			return 1;
+		}
+		else if (comdid == L"xmFileSave" || comdid == L"xmSave")
+		{
+
+			return OnSave();
+		}
+		else if (comdid == L"xmSaveEx")
+		{
+			return OnSaveEx();
+		}
+		else if (comdid == L"xmFileSaveAs" || comdid == L"xmSaveAs")
+		{
+			return OnSave(/*saveas*/true);
+		}
+		else if (comdid.left(3) == L"IK_")
+		{
+			int row = dw_cell.GetRow();
+			xstring cmd = comdid.mid(3, comdid.length());
+			if (comdid == L"IK_xmFormatCellDeleteRow" && row > 0)
+			{
+				xstring rowid = getRowID(dw_cell, row);
+				if (rowid != L"")
+				{
+					int frow = LookupRow(rowid);
+					if (frow > 0) dw_goods.DeleteRow(frow);
+				}
+			}
+			SendCtrlCmd(dw_cell, cmd);
+			return 1;
+		}
+		else if (comdid == L"xmFormatCellDeleteRow")
+		{
+			if (action == L"purch")
+			{
+				int crow = dw_cell.GetRow();
+				if (getRowID(dw_cell, crow) == L"") SendCtrlCmd(dw_cell, cmd);
+				return 1;
+			}
+		}
+		return 0;
+	}
+
+	xstring GetNo()
+	{
+		xstring  typ = L"C";
+
+		xml x ;
+		
+		xaserverarg arg ;
+		
+		arg.AddArg(L"count", L"1");
+		arg.AddArg(L"type", typ);
+		if (xurl::get(L"/sale/data/SO/goods/usegoods/goodslib/asknos", arg.GetString(), x) != 1)return L"";
+		return x.text();
+	}
+
+	int OnSaveNewItem(xstring content)
+	{
+		xml x ;
+		
+		xaserverarg arg ;
+		
+		arg.AddArg(L"content", content);
+		if (xurl::get(L"/sale/data/ProductLibrary3/update/newestproduct", arg.GetString(), x) != 1)
+		{
+			xstring error = x.text();
+			alert(error);
+			return -1;
+		}
+		return 1;
+	}
+
+	int OnSaveEx(bool balert = false)
+	{
+		//dw_cell.AcceptText();
+
+		OnToQuote();
+		if (dw_base.GetItemString(1, L"SalespersonID") == L"")OnInit();
+
+		dw_base.AcceptText();
+		dw_goods.AcceptText();
+
+		if (dw_base.GetItemString(1, L"QuoteNo") == L"")
+		{
+			xstring QuoteNo = QuoteView::MakeBillNo();
+			dw_base.SetItemString(1, L"QuoteNo", QuoteNo);
+			setBaseItem(dw_cell, L"鎶ヤ环鍗曞彿:", QuoteNo);
+		}
+		if (dw_base.GetGuid(1) == L"")
+			dw_base.SetGuid(1, entityID);
+
+		xml x1 ;
+		bool hasNew = false;
+
+		xstring sdate = publiccode::GetCurrentDate();
+		xstring suserid = publiccode::GetUser().id;
+		xstring categoryID = L"EF37E57D-5833-4AF9-BA5E-01CCF39C1F20";
+		xstring folderID = L"10200009-0000-0000-0001-000000000000";
+
+		for (int i = 1; i <= dw_goods.GetRowCount(); i++)
+		{
+			if (dw_goods.GetItemString(i, L"ItemID") == L"" || dw_goods.GetItemString(i, L"SKUNo") == L"")
+			{
+				//alert(L"row:"+xstring(i));
+				hasNew = true;
+				xstring ItemID = GetGuid();
+				dw_goods.SetItemString(i, L"ItemID", ItemID);
+				xstring Item = L"<Item update.new='1' update.modify='1' guid='" + ItemID + L"'>";
+				Item += L"<SKUID>" + ItemID + L"</SKUID>";
+				Item += L"<GoodsNo>" + dw_goods.GetItemString(i, L"GoodsNo") + L"</GoodsNo>";
+				xstring SKUNo = GetNo();
+				dw_goods.SetItemString(i, L"SKUNo", SKUNo);
+				dw_goods.Redraw();
+
+				int frow = LookupCellRow(dw_goods.GetGuid(i));
+				//alert(dw_goods.GetGuid(1)+L"--"+xstring(frow));
+				if (frow > 0) dw_cell.SetItemString(frow, 1, SKUNo);
+
+				Item += L"<No>" + SKUNo + L"</No>";
+				Item += L"<SKUNo>" + SKUNo + L"</SKUNo>";
+				Item += L"<CName>" + dw_goods.GetItemString(i, L"CName") + L"</CName>";
+				Item += L"<EName>" + dw_goods.GetItemString(i, L"ItemName") + L"</EName>";
+				Item += L"<Packing>" + dw_goods.GetItemString(i, L"Packing") + L"</Packing>";
+
+				Item += L"<CategoryID>" + categoryID + L"</CategoryID>";
+				Item += L"<FolderID>" + folderID + L"</FolderID>";
+
+				Item += L"<CreateID>" + suserid + L"</CreateID>";
+				Item += L"<CreateDate>" + sdate + L"</CreateDate>";
+				Item += L"<ModifierID>" + suserid + L"</ModifierID>";
+				Item += L"<ModifyDate>" + sdate + L"</ModifyDate>";
+
+				Item += L"</Item>";
+			}
+			if (hasNew)
+			{
+				xstring newItem = L"<data>" + Item + L"</data>";
+				trace(newItem);
+				if (OnSaveNewItem(newItem) == -1) return 1;
+			}
+		}
+
+		xml x ;
+		
+		xaserverarg arg ;
+		
+		dw_goods.DwUpdateAllToEx(x);
+		dw_base.DwUpdateAllTo(x);
+
+		xstring error = L"";
+		arg.AddArg(L"content", x.xml());
+
+		//trace(x.xml());
+		//return 1;
+
+		if (xurl::get(L"/sale/data/Quote/update", arg.GetString(), x) != 1)
+		{
+			error = x.text();
+			alert(error);
+		}
+		else
+		{
+			xstring str = x.documentElement.getAttribute(L"text");
+			if (str == L"true")
+			{
+				dw_goods.ResetUpdateStatus();
+				dw_base.ResetUpdateStatus();
+				if (balert)alert(L"淇濆瓨鎴愬姛!");
+
+				return -1;
+
+			}
+			else
+			{
+				alert(L"淇濆瓨澶辫触!");
+				return -1;
+			}
+		}
+		return 1;
+	}
+
+	xstring GetExchangeRate(xstring pcur, xstring pdate)
+	{
+
+		if (pcur.upper() == L"RMB") return L"1";
+		xstring exchangeRate = L"";
+		if (exchangeRate == L"") {
+			xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate");
+			if (x.selectSingleNode(L"root/item/@value"))
+				exchangeRate = x.selectSingleNode(L"root/item/@value").text();
+		}
+		return exchangeRate;
+	}
+
+	xstring GetExchangeRate(xstring pcur)
+	{
+		return GetExchangeRate(pcur, L"");
+	}
+
+	int OnInit()
+	{
+		//鍏徃鎶ご銆佹姤浠蜂汉銆佹姤浠锋棩鏈�
+		xstring sdate = publiccode::GetCurrentDate();
+		dw_base.SetItemString(1, L"QuoteDate", sdate);
+		xstring suserid = publiccode::GetUser().id;
+		xstring susername = publiccode::GetUser().name;
+		dw_base.SetItemString(1, L"SalespersonID", suserid);
+		dw_base.SetItemDisplayString(1, L"SalespersonID", susername);
+		dw_base.SetItemString(1, L"CurrencyCode", L"USD");
+		dw_base.SetItemDisplayString(1, L"CurrencyCode", L"USD");
+
+		xstring exchangeRate = L"";
+		xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramEx", L"ETD", sdate);
+		if (x.selectSingleNode(L"root/item/@value"))
+			exchangeRate = x.selectSingleNode(L"root/item/@value").text();
+		if (exchangeRate != L"")
+		{
+			dw_base.SetItemString(1, L"ExchangeRate", exchangeRate);
+		}
+		else
+		{
+			dw_base.SetItemString(1, L"ExchangeRate", L"6.49");
+		}
+
+		//dw_base.SetItemString(1,L"ExchangeRate",GetExchangeRate(L"USD"));
+
+		dw_base.SetItemString(1, L"CompanyID", L"E9E3C542-062C-4957-B8F4-9B92C3E351FC");
+		dw_base.SetItemDisplayString(1, L"CompanyID", L"瀹佹尝瀹跺皵浣宠繘鍑哄彛鏈夐檺鍏徃");
+
+		/*xstring ss = L"select (select EnglishName from Party where PartyID = CompanyID) as 'CompanyID/@_displaystring',CompanyID from HR_Org where OrgID = '{$id}' for xml PATH('root'),ELEMENTS XSINIL";
+		xstring scguid;
+		xstring sCename;
+		xml x1 = RetrieveSqlData(ss,L"id",sg);
+		KXMLDOMElement e1 = x1.documentElement;
+		scguid = sureNodeText(e1,L"CompanyID");
+		sCename = sureNodeText(e1,L"CompanyID/@_displaystring");
+		*/
+
+		return 1;
+	}
+
+	int OnRowChanged(ref TNotifyEvent evt, int p)
+	{
+		ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR);
+		int row = hdr.row;
+
+		return OnQuoteLineChanged(row);
+	}
+
+	int OnQuoteLineChanged(int row)
+	{
+		ximageview im = GetControl(L"im1");
+		im.ResetEx();
+		//xstring skuno = dw_goods.GetItemString(row,L"SKUNo");
+		//OnShowImage(skuno,row);
+		//im.Redraw();
+
+		xstring rowid = dw_goods.GetGuid(row);
+		int frow = LookupCellRow(rowid);
+		if (frow > 0)
+		{
+			xstring str = dw_cell.GetItemString(frow, 0);
+			trace(L"\r\ncustomer-photo:" + str);
+			ShowImageOne(im, str, L"customer-photo");
+			im.Redraw();
+
+			RowChanged(frow);
+		}
+		return 1;
+	}
+
+	int OnShowImage(xstring skuno, int row)
+	{
+		ximageview im = GetControl(L"im1");
+
+		xml xp ;
+		xp.setNativePointer(xml::CreateInstance());
+		xaserverarg arg_pic ;
+		arg_pic.setNativePointer(arg_pic.CreateInstance());
+		arg_pic.AddArg(L"SKUNo", skuno);
+
+		xstring res = L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo";
+		xstring customerID = dw_base.GetItemString(1, L"CustomerID");
+		xstring customerItemNo = dw_goods.GetItemString(row, L"CustomerItemNo");
+		if (customerItemNo != L"")
+		{
+			trace(customerID + L":" + customerItemNo);
+			res = L"/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKUNo";
+			arg_pic.AddArg(L"CustomerID", customerID);
+			arg_pic.AddArg(L"CustomerItemNo", customerItemNo);
+		}
+
+		bool hasIamge = false;
+		if (xurl::get(res, arg_pic.GetString(), xp) != 1)
+		{
+			trace(xp.GetXml());
+			return 1;
+		}
+		else
+		{
+			KXMLDOMNodeList  nlistp = xp.selectNodes(L"ImageList/image");
+			int lenp = nlistp.length();
+			for (int ip = 0; ip < lenp; ip++)
+			{
+				hasIamge = true;
+				KXMLDOMElement xitem = nlistp.item(ip);
+				xstring picname = xitem.selectSingleNode(L"PicPath").text();
+				xstring goodno = xitem.selectSingleNode(L"GoodsNo").text();
+				if (picname == L"/business/products/Thumbs//")
+					picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg";
+				im.AddImages(picname, goodno);
+			}
+		}
+		if (!hasIamge)
+		{
+			res = L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo";
+			if (xurl::get(res, arg_pic.GetString(), xp) != 1)
+			{
+				trace(xp.GetXml());
+				return 1;
+			}
+			else
+			{
+				nlistp = xp.selectNodes(L"ImageList/image");
+				lenp = nlistp.length();
+				for (ip = 0; ip < lenp; ip++)
+				{
+					xitem = nlistp.item(ip);
+					picname = xitem.selectSingleNode(L"PicPath").text();
+					goodno = xitem.selectSingleNode(L"GoodsNo").text();
+					if (picname == L"/business/products/Thumbs//")
+						picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg";
+					im.AddImages(picname, goodno);
+				}
+			}
+		}
+		return 1;
+	}
+
+	int OnUpdateEntityFile()
+	{
+		xcell cell1 = GetControl(L"dw_cell1");
+		xstring content = cell1.GetData();
+		content = content.mid(content.find(L"<xsheet"), 9999999);
+		while (true)
+		{
+			int pos = content.find(L"<display>");
+			int pos1 = 0;
+			xstring str = L"";
+			if (pos >= 0)
+			{
+				pos1 = content.find(L"</display>", pos);
+				str = content.mid(pos1 + L"</display>".length(), 9999999);
+				content = content.left(pos) + str;
+			}
+			else
+				break;
+		}
+		int ret = 1;
+		if (content != L"")
+		{
+			ret = ProcessSendMessage(L"/task/quote/file-update", entityID, content, L"", false);
+		}
+		return ret;
+	}
+
+	int OnUpdateProcessed()
+	{
+		int ret = ProcessSendMessage(L"/task/quote/update-processed", taskid, L"", L"", false);
+		win32::PostMessage(GetFrameWindow().GetHWND(), 0x401, L"xmRefreshTask", 0);
+		return ret;
+	}
+
+	int OnUpdate()
+	{
+		//set rowid
+		ensureRowID();
+
+		xstring content = dw_cell.GetData();
+		content = content.mid(content.find(L"<xsheet"), 9999999);
+		while (true)
+		{
+			int pos = content.find(L"<display>");
+			int pos1 = 0;
+			xstring str = L"";
+			if (pos >= 0)
+			{
+				pos1 = content.find(L"</display>", pos);
+				str = content.mid(pos1 + L"</display>".length(), 9999999);
+				content = content.left(pos) + str;
+			}
+			else
+				break;
+		}
+		//trace(content);
+		xstring business = L"";
+		//trace(content);
+
+		if (action == L"new")
+		{
+			entityID = ViewObject::GetGuid();
+			entityItemID = ViewObject::GetGuid();
+		}
+
+		//trace(L"\r\nid:"+entityID+L" termid:"+entityItemID);
+		business = L"<business action='" + action + L"' id='" + entityID + L"' itemid='" + entityItemID + L"' processurl='" + processurl + L"' termid='" + templateID + L"'>";
+		business += L"<content>" + content + L"</content></business>";
+		xstring datacontent = GetSaleFullData(dw_cell);
+		bool balter = false;
+		if (action == L"purch")
+			balter = true;
+
+		int ret = ProcessSendMessage(L"/task/quote/update", L"", business, datacontent, balter);
+		//int ret =  ProcessSendMessage(L"/task/quote/update", L"", business,false);
+
+
+
+		if (action == L"new" && ret == 1) action = L"open";
+		return ret;
+	}
+
+	int OnSave(bool saveas = false)
+	{
+		//dw_cell.AcceptText();
+		dw_cell.SetRowColumn(1, 1);
+		dw_cell.SetAnchorRowColumn(1, 1);
+
+		if (tabsheet != L"tab_quote") OnToQuote();
+
+		if (getBaseItem(dw_cell, L"鎶ヤ环鍗曞彿:") == L"")
+			setBaseItem(dw_cell, L"鎶ヤ环鍗曞彿:", dw_base.GetItemString(1, L"QuoteNo"));
+
+		OnUpdate();
+		if (action == L"purch") return 1;
+		return OnSaveEx(true);
+
+		xstring suserid = publiccode::GetUser().id;
+		xstring myurl = L"data/QuoteFile/" + suserid;
+		xstring sfilename = filename;
+		if (filename == L"" || saveas)
+		{
+			xaserverarg arg ;
+			
+			arg.AddArg(L"src", myurl);
+			OpenWindow(L"dev:xpage[trade.document.saveas.vx]", cast(arg as int));
+			if (arg.GetArgString(L"result") == L"ok")
+			{
+				sfilename = arg.GetArgString(L"filename");
+			}
+			else
+				return 1;
+		}
+
+		xstring content = dw_cell.GetData();
+
+		xstring sguid = publiccode::GetGuid();
+		xstring sname = sguid;
+		xstring str = sname.mid(0, 2);
+		str = str.upper();
+		xstring suri = L"attachment" + str;
+		int ret = xaserver::UploadData(suri, sguid + L".jpg", content);
+		if (ret < 0)
+		{
+			alert(L"涓婁紶鏂囦欢鍑洪敊!");
+			return 0;
+		}
+
+		xml x ;
+		
+		xaserverarg args ;
+		args.setNativePointer(args.CreateInstance());
+		args.AddArg(L"myurl", myurl);
+		args.AddArg(L"name", sfilename);
+		args.AddArg(L"filepath", sname);
+		args.AddArg(L"fileext", L"xdoc");
+		args.AddArg(L"filesource", sfilename);
+		args.AddArg(L"filesource", sfilename);
+		args.AddArg(L"id", fileid);
+
+		xstring path = L"/sale/data/TDocument3/attachment/update";
+		if (filename == L"" || saveas) path = L"/sale/data/TDocument3/attachment/add";
+		if (xurl::get(path, args.GetString(), x) != 1)
+		{
+			alert(L"淇濆瓨鍑洪敊浜�!");
+			return 0;
+		}
+		else
+		{
+			filename = sfilename;
+			win32::SetWindowText(GetHWND(), L"鎶ヤ环鏂囦欢:" + filename);
+			alert(x.text());
+		}
+
+		return 1;
+	}
+
+	int SendCtrlCmd(xcontrol xc, xstring cmd)
+	{
+		win32::SendMessage(xc.GetId(), 0x401, cmd, 0);
+		return 1;
+	}
+
+	int OnCellClicked(ref TNotifyEvent evt, int p)
+	{
+		ref DWNMHDR dwhdr = cast(evt.pnmh as ref DWNMHDR);
+		int row = dwhdr.row;
+		int col = dwhdr.col;
+		//xstring col = dwhdr.colname;
+		//xstring data = dwhdr.data;
+
+		//alert(xstring(col));
+		int startRow = getItemHeadRow(dw_cell);
+		if (startRow < 1) return 1;
+
+		if (row < startRow)
+		{
+			xstring val = dw_cell.GetItemString(row, col);
+			if (val == L"鎶ヤ环鍗曞彿:" || val == L"鎶ヤ环鎴鏃ユ湡锛�" || val == L"椤圭洰鍚嶇О:")
+			{
+				dwhdr.idFrom = -1;
+				return 1;
+			}
+			if (col > 1)
+			{
+				val = dw_cell.GetItemString(row, col - 1);
+				if (val == L"鎶ヤ环鍗曞彿:")
+				{
+					dwhdr.idFrom = -1;
+					return 1;
+				}
+			}
+		}
+		if (row == startRow)
+		{
+			dwhdr.idFrom = -1;
+			return 1;
+		}
+		if (row < startRow + 1) return 1;
+		startRow++;
+
+		trace(xstring(row) + L"---" + (startRow - 1).toString());
+
+		int colItemNo = getItemCol(dw_cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyerPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�,閲囪喘浠锋牸");
+		int colBuyer = getItemCol(dw_cell, startRow - 1, L"閲囪喘浜哄憳");
+		int colCustomerPhoto = getItemCol(dw_cell, startRow - 1, L"Photo,Customer Photo");
+		int colPackage = getItemCol(dw_cell, startRow - 1, L"Package,鍖呰鏂瑰紡");
+		int colFOBPrice = getItemCol(dw_cell, startRow - 1, L"FOB Price,FOB Price(USD),Fob Price");
+		int colQty = getItemCol(dw_cell, startRow - 1, L"Qty,鏁伴噺");
+		//int colToPODate = getItemCol(dw_cell,startRow - 1,L"涓氬姟鍙戦�侀噰璐椂闂�");
+
+		int colSaler = getItemCol(dw_cell, startRow - 1, L"涓氬姟鍛�");
+
+		int colVolDesc = getItemCol(dw_cell, startRow - 1, L"浣撶Н鎻忚堪,闀縓瀹絏楂�,闀縓瀹絏楂�(CM)L");
+		int colVol = getItemCol(dw_cell, startRow - 1, L"浣撶Н,浣撶Н(M3)L");
+		int colQtyPerPack = getItemCol(dw_cell, startRow - 1, L"瑁呯鏁�(鍐�/澶�),瑁呯鏁�(澶�/鍐�)L");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+		int colSKUID = getItemCol(dw_cell, startRow - 1, L"SKUID");
+
+		int colPONote = getItemCol(dw_cell, startRow - 1, L"閲囪喘To涓氬姟澶囨敞");
+		int colPONote2 = getItemCol(dw_cell, startRow - 1, L"涓氬姟To閲囪喘澶囨敞");
+
+		int colItemNote = getItemCol(dw_cell, startRow - 1, L"浜у搧澶囨敞");
+
+		int colPOPhoto = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int colPOPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�");
+		int colNW = getItemCol(dw_cell, startRow - 1, L"姣涢噸(KG)L");
+		int colGW = getItemCol(dw_cell, startRow - 1, L"鍑�閲�(KG)L");
+		int colSKUNo = getItemCol(dw_cell, startRow - 1, L"SKUID,SKUNo");
+
+		int purchremarkcol = getItemCol(dw_cell, startRow - 1, L"閲囪喘To涓氬姟澶囨敞");
+		int colRemark = getItemCol(dw_cell, startRow - 1, L"Remarks");
+
+		//int colProductInfo = getItemCol(dw_cell,startRow - 1,L"浜у搧淇℃伅");
+		int colProductInfo = getItemCol(dw_cell, startRow - 1, L"涓氬姟閮ㄤ骇鍝佷俊鎭�");
+		int colProductInfo1 = getItemCol(dw_cell, startRow - 1, L"閲囪喘閮ㄤ骇鍝佷俊鎭�");
+
+
+		int colItemPurchDate = getItemCol(dw_cell, startRow - 1, L"涓氬姟鍙戦�侀噰璐椂闂�");
+
+		dwhdr.idFrom = 0;
+		if (action != L"purch")
+		{
+			if (col == colPONote || col == colProductInfo1 || col == colItemNote || col == colPOPhoto || col == colPOPrice || col == colNW || col == colGW || col == colVol || col == colVolDesc)
+			{
+				dwhdr.idFrom = -1;
+				return 1;
+			}
+			/*if(col==colProductInfo && dw_cell.GetItemString(row,colItemPurchDate)!=L"")
+			{
+				dwhdr.idFrom = -1;
+				return 1;
+			}*/
+		}
+
+		if (action != L"purched")
+		{
+			if (col == colBuyer)
+			{
+				KXMLDOMNodeList items = purcher.selectNodes(L"//HrEmployee");
+				int count = items.length();
+				xstring pitems = L"";
+				for (int i = 0; i < count; i++)
+				{
+					pitems += L"&lt;row&gt;&lt;鏄剧ず鍒�&gt;" + items.item(i).selectSingleNode(L"Name").text + L"&lt;/鏄剧ず鍒�&gt;&lt;鏁版嵁鍒�&gt;"
+						+ items.item(i).selectSingleNode(L"Name").text + L"&lt;/鏁版嵁鍒�&gt;&lt;/row&gt;";
+
+				}
+				xstring prop = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial='' cellsource='' fontstyle='' windowurl=''>" +
+					"<edit edittype='ddlb' ddlbdataurl='' ddlbxml='&lt;data&gt;" + pitems + L"&lt;/data&gt;'/>" +
+					"</cellprop>";
+				dw_cell.SetCellProps(row, col, prop);
+			}
+		}
+
+		if (action != L"purch" && action != L"purched")
+		{
+			/*if(col ==colBuyer)
+			{
+				KXMLDOMNodeList items = purcher.selectNodes(L"//HrEmployee");
+				int count = items.length();
+				xstring pitems = L"";
+				for(int i=0;i<count;i++)
+				{
+					pitems += L"&lt;row&gt;&lt;鏄剧ず鍒�&gt;"+items.item(i).selectSingleNode(L"Name").text+L"&lt;/鏄剧ず鍒�&gt;&lt;鏁版嵁鍒�&gt;"
+							+items.item(i).selectSingleNode(L"Name").text + L"&lt;/鏁版嵁鍒�&gt;&lt;/row&gt;";
+
+				}
+				xstring prop=L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial='' cellsource='' fontstyle='' windowurl=''>" +
+					"<edit edittype='ddlb' ddlbdataurl='' ddlbxml='&lt;data&gt;" + pitems  + L"&lt;/data&gt;'/>" +
+					"</cellprop>";
+				dw_cell.SetCellProps(row,col,prop);
+			}*/
+			if (col == colPackage)
+			{
+				xstring proppack = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='淇濇姢' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial='' cellsource='' fontstyle='' windowurl=''><edit edittype='ddlb' ddlbdataurl='xquery:[Convert.quickcode.xq]?id=鍖呰鏂瑰紡1' ddlbxml=''/></cellprop>";
+				dw_cell.SetCellProps(row, col, proppack);
+			}
+		}
+
+
+		//alert(action);
+		if (action == L"purch")
+		{
+			if (col == colPONote2 || col == colProductInfo || col == colCustomerPhoto || col == colSaler || col == colSKUID || col == colQty || col == colBuyerPrice || col == col40HQ || col == colQtyPerPack || col == colPackage || col == colItemNo || col == colItemCName || col == colCustomerItemNo || col == colItemName || col == colItemSpec //|| colBuyer ==col
+				|| col == colVol)
+			{
+				dwhdr.idFrom = -1;
+				return 1;
+			}
+		}
+
+		if (action == L"purch")
+		{
+			int colPrice0 = getItemCol(dw_cell, startRow - 1, L"浠锋牸");
+			int colPrice1 = getItemCol(dw_cell, startRow - 1, L"浠锋牸1");
+			int colPrice2 = getItemCol(dw_cell, startRow - 1, L"浠锋牸2");
+			int colPrice3 = getItemCol(dw_cell, startRow - 1, L"浠锋牸3");
+			int colPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�");
+
+			int colTyp = getItemCol(dw_cell, startRow - 1, L"绫诲瀷");
+			int colTyp1 = getItemCol(dw_cell, startRow - 1, L"绫诲瀷1");
+			int colTyp2 = getItemCol(dw_cell, startRow - 1, L"绫诲瀷2");
+			int colTyp3 = getItemCol(dw_cell, startRow - 1, L"绫诲瀷3");
+			int colSupplier = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�,宸ュ巶");
+			int colSupplier1 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�1,宸ュ巶1");
+			int colSupplier2 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�2,宸ュ巶2");
+			int colSupplier3 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�3,宸ュ巶3");
+
+
+			if (col == colSupplier || col == colSupplier1 || col == colSupplier2 || col == colSupplier3)
+			{
+				if (dw_cell.GetItemString(row, col) == L"")
+					dw_cell.SetItemString(row, col, L" ");
+				xstring prop2 = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial='' cellsource='' fontstyle='' windowurl=''>" +
+					"<edit edittype='query' dddwxpageurl='' dddwdataurl='xquery:[Convert.quickcode.xq]?id=Supplier' dddwtemplateurl='dev:sheet[Supplier.v3.tpl/List]' dddwdatacolumn='Name' dddwdisplaycolumn='Name' dddwwidth='' dddwheight='' dddwautoselect='N' dddwshowbutton='鍚�' dddwcanedit='鏄�'/>" +
+					"</cellprop>";
+				dw_cell.SetCellProps(row, col, prop2);
+				dw_cell.Redraw();
+			}
+			else if (col == colTyp1 || col == colTyp || col == colTyp2 || col == colTyp3)
+			{
+				xstring pitems1 = L"";
+				pitems1 += L"&lt;row&gt;&lt;鏄剧ず鍒�&gt;鎴愬搧&lt;/鏄剧ず鍒�&gt;&lt;鏁版嵁鍒�&gt;"
+					+ L"鎴愬搧&lt;/鏁版嵁鍒�&gt;&lt;/row&gt;";
+				pitems1 += L"&lt;row&gt;&lt;鏄剧ず鍒�&gt;鏁h揣&lt;/鏄剧ず鍒�&gt;&lt;鏁版嵁鍒�&gt;"
+					+ L"鏁h揣&lt;/鏁版嵁鍒�&gt;&lt;/row&gt;";
+				pitems1 += L"&lt;row&gt;&lt;鏄剧ず鍒�&gt;鍖呰&lt;/鏄剧ず鍒�&gt;&lt;鏁版嵁鍒�&gt;"
+					+ L"鍖呰&lt;/鏁版嵁鍒�&gt;&lt;/row&gt;";
+				xstring prop1 = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial='' cellsource='' fontstyle='' windowurl=''>" +
+					"<edit edittype='ddlb' ddlbdataurl='' ddlbxml='&lt;data&gt;" + pitems1 + L"&lt;/data&gt;'/>" +
+					"</cellprop>";
+				dw_cell.SetCellProps(row, col, prop1);
+			}
+		}
+		if (ARow != row) RowChanged(row);
+		ARow = row;
+		ACol = col;
+		//orivalue = dw_cell.GetItemString(ARow,ACol);
+
+		return 1;
+	}
+
+
+	int OnCellClicked1(ref TNotifyEvent evt, int p)
+	{
+		ref DWNMHDR dwhdr = cast(evt.pnmh as ref DWNMHDR);
+		int row = dwhdr.row;
+		int col = dwhdr.col;
+		//xstring col = dwhdr.colname;
+		//xstring data = dwhdr.data;
+
+		//alert(xstring(col));
+		int startRow = getItemHeadRow(dw_cell);
+		if (startRow < 1) return 1;
+		if (row == startRow)
+		{
+			dwhdr.idFrom = -1;
+			return 1;
+		}
+		if (row < startRow + 1) return 1;
+		startRow++;
+
+		trace(xstring(row) + L"---" + (startRow - 1).toString());
+
+		int colItemNo = getItemCol(dw_cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyerPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�,閲囪喘浠锋牸");
+		int colBuyer = getItemCol(dw_cell, startRow - 1, L"閲囪喘浜哄憳");
+		int colCustomerPhoto = getItemCol(dw_cell, startRow - 1, L"Photo,Customer Photo");
+		int colPackage = getItemCol(dw_cell, startRow - 1, L"Package,鍖呰鏂瑰紡");
+		int colFOBPrice = getItemCol(dw_cell, startRow - 1, L"FOB Price,FOB Price(USD),Fob Price");
+		int colQty = getItemCol(dw_cell, startRow - 1, L"Qty,鏁伴噺");
+		//int colToPODate = getItemCol(dw_cell,startRow - 1,L"涓氬姟鍙戦�侀噰璐椂闂�");
+
+
+		int colVolDesc = getItemCol(dw_cell, startRow - 1, L"浣撶Н鎻忚堪,闀縓瀹絏楂�,闀縓瀹絏楂�(CM)L");
+		int colVol = getItemCol(dw_cell, startRow - 1, L"浣撶Н,浣撶Н(M3)L");
+		int colQtyPerPack = getItemCol(dw_cell, startRow - 1, L"瑁呯鏁�(鍐�/澶�),瑁呯鏁�(澶�/鍐�)L");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+		int colSKUID = getItemCol(dw_cell, startRow - 1, L"SKUID");
+
+		int colPONote = getItemCol(dw_cell, startRow - 1, L"閲囪喘To涓氬姟澶囨敞");
+		int colPOPhoto = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int colPOPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�");
+		int colNW = getItemCol(dw_cell, startRow - 1, L"姣涢噸(KG)L");
+		int colGW = getItemCol(dw_cell, startRow - 1, L"鍑�閲�(KG)L");
+		int colSKUNo = getItemCol(dw_cell, startRow - 1, L"SKUID,SKUNo");
+
+		dwhdr.idFrom = 0;
+		if (action != L"purch")
+		{
+			if (col == colPONote || col == colPOPhoto || col == colPOPrice || col == colNW || col == colGW || col == colVol || col == colVolDesc)
+			{
+				dwhdr.idFrom = -1;
+				return 1;
+			}
+		}
+
+		if (ACol == colFOBPrice && (col != colFOBPrice || row != ARow) && ARow >= startRow)
+		{
+			xstring fobprice = dw_cell.GetItemString(ARow, ACol);
+			if (fobprice.left(1) != L"$") dw_cell.SetItemString(ARow, ACol, L"$" + fobprice);
+		}
+
+		if (action != L"purch" && action != L"purched")
+		{
+			if (col == colBuyer)
+			{
+				KXMLDOMNodeList items = purcher.selectNodes(L"//HrEmployee");
+				int count = items.length();
+				xstring pitems = L"";
+				for (int i = 0; i < count; i++)
+				{
+					pitems += L"&lt;row&gt;&lt;鏄剧ず鍒�&gt;" + items.item(i).selectSingleNode(L"Name").text + L"&lt;/鏄剧ず鍒�&gt;&lt;鏁版嵁鍒�&gt;"
+						+ items.item(i).selectSingleNode(L"Name").text + L"&lt;/鏁版嵁鍒�&gt;&lt;/row&gt;";
+
+				}
+				xstring prop = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial='' cellsource='' fontstyle='' windowurl=''>" +
+					"<edit edittype='ddlb' ddlbdataurl='' ddlbxml='&lt;data&gt;" + pitems + L"&lt;/data&gt;'/>" +
+					"</cellprop>";
+				dw_cell.SetCellProps(row, col, prop);
+			}
+			if (col == colPackage)
+			{
+				xstring proppack = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='淇濇姢' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial='' cellsource='' fontstyle='' windowurl=''><edit edittype='ddlb' ddlbdataurl='xquery:[Convert.quickcode.xq]?id=鍖呰鏂瑰紡1' ddlbxml=''/></cellprop>";
+				dw_cell.SetCellProps(row, col, proppack);
+			}
+		}
+
+		if (ACol == colItemNo && col != colItemNo && dw_cell.GetItemString(ARow, colItemNo) != orivalue)
+		{
+			trace(L"/r/n--------------------");
+			if (dw_cell.GetItemString(ARow, colItemNo) != L"")
+			{
+				xaserverarg argx ;
+				argx.setNativePointer(argx.CreateInstance());
+				argx.AddArg(L"GoodsNo", dw_cell.GetItemString(ARow, colItemNo));
+				OpenWindow(L"dev:xpage[CustomerItemNoList.vx]", cast(argx as int));
+				if (argx.GetArgString(L"action") != L"ok")
+				{
+					ARow = row;
+					ACol = col;
+					orivalue = dw_cell.GetItemString(row, col);
+					return 1;
+				}
+
+				xml x1 ;
+				
+				x1.loadXML(argx.GetArgString(L"items"));
+				if (x1.selectSingleNode(L"//CustomerItemNo"))
+				{
+					xstring CustomerItemNo = x1.selectSingleNode(L"//CustomerItemNo").text();
+					dw_cell.SetItemString(ARow, colCustomerItemNo, CustomerItemNo);
+				}
+
+				xml goods = GetProduct(dw_cell.GetItemString(ARow, colItemNo));
+
+				if (goods)
+				{
+					dw_cell.SetItemString(ARow, colCustomerPhoto, L"");
+					resetRowTerm(dw_cell, ARow, L"customer-photo");
+					if (goods.selectSingleNode(L"//SKUID[1]"))
+					{
+						setRowProp(dw_cell, ARow, L"SKUID", goods.selectSingleNode(L"//SKUID[1]").text());
+					}
+					if (goods.selectSingleNode(L"//SKUNo[1]"))
+					{
+						dw_cell.SetItemString(ARow, colSKUNo, goods.selectSingleNode(L"//SKUNo[1]").text());
+					}
+					if (goods.selectSingleNode(L"//EName[1]"))
+						dw_cell.SetItemString(ARow, colItemName, goods.selectSingleNode(L"//EName[1]").text());
+					if (goods.selectSingleNode(L"//CName[1]"))
+						dw_cell.SetItemString(ARow, colItemCName, goods.selectSingleNode(L"//CName[1]").text());
+					if (goods.selectSingleNode(L"//Packing[1]"))
+						dw_cell.SetItemString(ARow, colPackage, goods.selectSingleNode(L"//Packing[1]").text());
+					if (goods.selectSingleNode(L"//POCreatorID[1]"))
+					{
+						dw_cell.SetItemString(ARow, colBuyer, goods.selectSingleNode(L"//POCreatorID[1]").text());
+					}
+					if (goods.selectSingleNode(L"//PackingRate[1]"))
+					{
+						if (goods.selectSingleNode(L"//InnerQty[1]"))
+						{
+							xstring str1 = goods.selectSingleNode(L"//PackingRate[1]").text();
+							xstring str2 = goods.selectSingleNode(L"//InnerQty[1]").text();
+							dw_cell.SetItemString(ARow, colQtyPerPack, str2 + L"/" + str1);
+						}
+						else
+						{
+							xstring str1 = goods.selectSingleNode(L"//PackingRate[1]").text();
+							dw_cell.SetItemString(ARow, colQtyPerPack, str1);
+						}
+					}
+					ProcessItemImage(dw_cell.GetItemString(ARow, colSKUNo), ARow);
+					//ProcessItemImage1(dw_cell.GetItemString(ARow,colItemNo),ARow);
+					dw_cell.SetRowColumn(row, col);
+					dw_cell.SetAnchorRowColumn(row, col);
+				}
+			}
+		}
+
+		if (((ACol == colVolDesc && (col != colVolDesc || row != ARow)) || (ACol == colQtyPerPack && (col != colQtyPerPack || row != ARow))) && ARow >= startRow)
+		{
+			/*璁$畻浣撶Н*/
+			xstring desc = dw_cell.GetItemString(ARow, colVolDesc);
+			if (desc == L"")
+				dw_cell.SetItemString(ARow, colVol, L"");
+			else
+			{
+				double v = calcVol(desc) / 1000000.00;
+				xstring str = xstring(v);
+				if (str.find(L".") >= 0)	str = str.left(str.find(L".") + 5);
+				dw_cell.SetItemString(ARow, colVol, str);
+				dw_cell.Redraw();
+			}
+
+			xstring qtyperPack = dw_cell.GetItemString(ARow, colQtyPerPack);
+			if (qtyperPack != L"")
+			{
+				xstring qty1 = qtyperPack;
+				xstring qty2 = L"";
+				double qty = 0.00;
+				int pos2 = qtyperPack.find(L"/");
+				if (pos2 >= 0)
+				{
+					qty1 = qtyperPack.left(qtyperPack.find(L"/"));
+					qty2 = qtyperPack.mid(qtyperPack.find(L"/") + 1, 9999);
+				}
+				if (qty1 != L"") qty = qty1.toDouble();
+				if (qty2 != L"") qty = qty * qty2.toDouble();
+				double ttl = 65.0 * qty / v;
+				dw_cell.SetItemString(ARow, col40HQ, ttl.toInt().toString());
+			}
+		}
+
+		//alert(action);
+		if (action == L"purch")
+		{
+			if (col == colSKUID || col == colQty || col == colBuyerPrice || col == col40HQ || col == colQtyPerPack || col == colPackage || col == colItemNo || col == colItemCName || col == colCustomerItemNo || col == colItemName || col == colItemSpec || colBuyer == col
+				|| col == colVol)
+			{
+				dwhdr.idFrom = -1;
+				return 1;
+			}
+		}
+
+		if (action == L"purch")
+		{
+			int colPrice0 = getItemCol(dw_cell, startRow - 1, L"浠锋牸");
+			int colPrice1 = getItemCol(dw_cell, startRow - 1, L"浠锋牸1");
+			int colPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�");
+
+			int colTyp = getItemCol(dw_cell, startRow - 1, L"绫诲瀷");
+			int colTyp1 = getItemCol(dw_cell, startRow - 1, L"绫诲瀷1");
+			int colSupplier = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�,宸ュ巶");
+			int colSupplier1 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�1,宸ュ巶1");
+			int colSupplier2 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�2,宸ュ巶2");
+
+
+			if (col == colSupplier || col == colSupplier1 || col == colSupplier2)
+			{
+				if (dw_cell.GetItemString(row, col) == L"")
+					dw_cell.SetItemString(row, col, L" ");
+				xstring prop2 = (xstring)L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial='' cellsource='' fontstyle='' windowurl=''>" +
+					L"<edit edittype='query' dddwxpageurl='' dddwdataurl='xquery:[Convert.quickcode.xq]?id=Supplier' dddwtemplateurl='dev:sheet[Supplier.v3.tpl/List]' dddwdatacolumn='Name' dddwdisplaycolumn='Name' dddwwidth='' dddwheight='' dddwautoselect='N' dddwshowbutton='鍚�' dddwcanedit='鏄�'/>" +
+					L"</cellprop>";
+				dw_cell.SetCellProps(row, col, prop2);
+				dw_cell.Redraw();
+			}
+			else if (col == colTyp1 || col == colTyp)
+			{
+				xstring pitems1 = L"";
+				pitems1 += (xstring)L"&lt;row&gt;&lt;鏄剧ず鍒�&gt;鎴愬搧&lt;/鏄剧ず鍒�&gt;&lt;鏁版嵁鍒�&gt;"
+					+ L"鎴愬搧&lt;/鏁版嵁鍒�&gt;&lt;/row&gt;";
+				pitems1 += (xstring)L"&lt;row&gt;&lt;鏄剧ず鍒�&gt;鏁h揣&lt;/鏄剧ず鍒�&gt;&lt;鏁版嵁鍒�&gt;"
+					+ L"鏁h揣&lt;/鏁版嵁鍒�&gt;&lt;/row&gt;";
+				pitems1 += (xstring)L"&lt;row&gt;&lt;鏄剧ず鍒�&gt;鍖呰&lt;/鏄剧ず鍒�&gt;&lt;鏁版嵁鍒�&gt;"
+					+ L"鍖呰&lt;/鏁版嵁鍒�&gt;&lt;/row&gt;";
+				xstring prop1 = (xstring)L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial='' cellsource='' fontstyle='' windowurl=''>" +
+					"<edit edittype='ddlb' ddlbdataurl='' ddlbxml='&lt;data&gt;" + pitems1 + L"&lt;/data&gt;'/>" +
+					"</cellprop>";
+				dw_cell.SetCellProps(row, col, prop1);
+			}
+
+
+
+			if (((colPrice != col && colPrice1 != col) || row != ARow) && bPurchPrice)
+			{
+				if (bPurchPrice && action == L"purch")
+				{
+					xstring price0 = dw_cell.GetItemString(ARow, colPrice0);
+					xstring price1 = dw_cell.GetItemString(ARow, colPrice1);
+					xstring price = price0;
+					if (price0 != L"")
+					{
+						if (price0.find(L"A") < 1 && price0.find(L"B") < 1 && price0.find(L"C") < 1 && price0.find(L"a") < 1 && price0.find(L"b") < 1 && price0.find(L"b") < 1)
+						{
+							alert(L"浠锋牸涓病鎸囧畾ABC");
+						}
+					}
+					if (price1 != L"")
+					{
+						if (price1.find(L"A") < 1 && price1.find(L"B") < 1 && price1.find(L"C") < 1 && price1.find(L"a") < 1 && price1.find(L"b") < 1 && price1.find(L"c") < 1)
+						{
+							alert(L"浠锋牸涓病鎸囧畾ABC");
+						}
+						price = price0 + L"+L" + price1;
+					}
+					dw_cell.SetItemString(ARow, colPrice, price);
+				}
+			}
+			if (colPrice0 != col && colPrice1 != col)
+				bPurchPrice = false;
+			else
+				bPurchPrice = true;
+
+		}
+		if (ARow != row) RowChanged(row);
+		ARow = row;
+		ACol = col;
+		orivalue = dw_cell.GetItemString(ARow, ACol);
+
+		return 1;
+	}
+
+	int OnImgDBClicked(TEvent* evt, LPARAM pr)
+	{
+		IMGNNMHDR& nmtv = *(IMGNNMHDR*)evt->notify.pnmh;
+		xstring src = nmtv.path;
+		/*if(src.length() > 60)
+			src = src.right(44);
+		else
+			src=src.mid(src.find(L"Thumbs", 0)+6, 50);
+		*/
+		xaserverarg arg ;
+		
+		//arg.AddArg(L"src",L"/business/products/chanpin"+src);	
+		arg.AddArg(L"src", src);
+
+		//win::OpenWindow(L"dev:xpage[BigPicture.vx]",arg);	
+
+		int h = openUrl(L"/sale/view/ProductLibrary/xpage/bigpictureview", &arg);
+		return 1;
+		/*
+		xwin x = new xwin;
+		x.setNativePointer(h);
+		m_winHwnd = x.GetHWND();
+
+		xstring sh = doc.GetXml();
+		int p = cast(sh as int);
+		win32::SendMessage(m_winHwnd, 0x401, p, 0);
+		*/
+		return 1;
+	}
+
+	//鍛戒护澶勭悊浜嬩欢
+	int OnXCommand(TEvent * evt, LPARAM param)
+	{
+		return OnCmdDispatch(evt->xcommand.pStrID);
+	}
+
+	int OnAttachListon()
+	{
+		//缁戝畾宸ュ叿鏉$偣鍑讳簨浠�
+		AttachEvent(L"WM_XCOMMAND", OnXCommand);
+		//鑾峰彇鐒︾偣浜嬩欢锛岀敤浜庨噸缃伐鍏锋潯
+		AttachEvent(L"WM_SETFOCUS", OnSetFocus);
+
+		AttachEvent(L"frame:im1", L"IMG_LDBCLICK", OnImgDBClicked);
+
+		AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", OnItemChanged);
+		AttachEvent(L"dw_goods", L"DWV_ROWFOCUSCHANGED", OnRowChanged);
+
+		AttachEvent(L"dw_cell", L"DWV_CLICKED", OnCellClicked);
+		AttachEvent(L"dw_cell", L"CELL_ITEMCHANGED", OnCellItemChanged);
+		AttachEvent(L"dw_cell", L"CELL_SELECTCHANGED", OnCellSelectChanged);
+		return 1;
+	}
+
+	/*
+	int  OnRetrieve()
+	{
+		xml x ;
+		
+		xaserverarg arg ;
+		
+		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 SyncPurch(xml x)
+	{
+		int startRow = getItemHeadRow(dw_cell);
+
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return 0;
+		startRow++;
+
+		int colItemNo = getItemCol(dw_cell, startRow - 1, L"鎴戝徃鍨嬪彿,ItemNo");
+		int colCustomerItemNo = getItemCol(dw_cell, startRow - 1, L"瀹㈡埛鍨嬪彿,Customer ItemNo,Customer Item No");
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemCName = getItemCol(dw_cell, startRow - 1, L"涓枃鍝佸悕");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+		int colBuyerPrice = getItemCol(dw_cell, startRow - 1, L"閲囪喘浠�,閲囪喘浠锋牸");
+		int colBuyer = getItemCol(dw_cell, startRow - 1, L"閲囪喘浜哄憳");
+
+		int colBuyerRemark = getItemCol(dw_cell, startRow - 1, L"閲囪喘To涓氬姟澶囨敞");
+		int colFactoryImage = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		int colGWT = getItemCol(dw_cell, startRow - 1, L"姣涢噸,姣涢噸(KG)L");
+		int colNWT = getItemCol(dw_cell, startRow - 1, L"鍑�閲�,鍑�閲�(KG)L");
+		int colVolDesc = getItemCol(dw_cell, startRow - 1, L"浣撶Н鎻忚堪,闀縓瀹絏楂�,闀縓瀹絏楂�(CM)L");
+		int colVol = getItemCol(dw_cell, startRow - 1, L"浣撶Н,浣撶Н(M3)L");
+		int col40HQ = getItemCol(dw_cell, startRow - 1, L"40HQ,QTY(40HQ)L");
+		int colPurchedDate = getItemCol(dw_cell, startRow - 1, L"閲囪喘鎻愪氦涓氬姟鏃堕棿");
+		int colPhoto1 = getItemCol(dw_cell, startRow - 1, L"宸ュ巶鍥剧墖");
+		//int colProductInfo = getItemCol(dw_cell,startRow - 1,L"浜у搧淇℃伅");
+		int colProductInfo = getItemCol(dw_cell, startRow - 1, L"涓氬姟閮ㄤ骇鍝佷俊鎭�");
+		int colProductInfo1 = getItemCol(dw_cell, startRow - 1, L"閲囪喘閮ㄤ骇鍝佷俊鎭�");
+
+		int LastRow = dw_cell.GetValidRow();
+		KXMLDOMNodeList items = x.selectNodes(L"//Item");
+		int size = items.length();
+		for (int i = 0; i < size; i++)
+		{
+			KXMLDOMElement ele = items.item(i);
+			xstring rowid = ele.selectSingleNode(L"RowID").text();
+			xstring BuyerPrice = ele.selectSingleNode(L"BuyerPrice").text();
+			xstring BuyerRemark = L"";
+			xstring FactoryImage = L"";
+			xstring GWT = L"";
+			xstring NWT = L"";
+			xstring VolDesc = L"";
+			xstring Vol = L"";
+			xstring F40HQ = L"";
+			xstring PurchedDate = L"";
+			xstring supplierphoto = L"";
+			xstring  productInfo = L"";
+			xstring  productInfo1 = L"";
+			xstring  EnquiryLineID = L"";
+			xstring  Buyer = L"";
+
+			if (ele.selectSingleNode(L"BuyerRemark")) BuyerRemark = ele.selectSingleNode(L"BuyerRemark").text();
+			if (ele.selectSingleNode(L"FactoryImage"))FactoryImage = ele.selectSingleNode(L"FactoryImage").text();
+			if (ele.selectSingleNode(L"GWT")) GWT = ele.selectSingleNode(L"GWT").text();
+			if (ele.selectSingleNode(L"NWT")) NWT = ele.selectSingleNode(L"NWT").text();
+			if (ele.selectSingleNode(L"VolDesc")) VolDesc = ele.selectSingleNode(L"VolDesc").text();
+			if (ele.selectSingleNode(L"Vol")) Vol = ele.selectSingleNode(L"Vol").text();
+			if (ele.selectSingleNode(L"F40HQ")) F40HQ = ele.selectSingleNode(L"F40HQ").text();
+			if (ele.selectSingleNode(L"PurchedDate")) PurchedDate = ele.selectSingleNode(L"PurchedDate").text();
+			trace(L"\r\n******" + PurchedDate);
+			if (ele.selectSingleNode(L"supplier-photo")) supplierphoto = ele.selectSingleNode(L"supplier-photo").text();
+			if (ele.selectSingleNode(L"ProductInfo")) productInfo = ele.selectSingleNode(L"ProductInfo").text();
+			if (ele.selectSingleNode(L"ProductInfo1")) productInfo1 = ele.selectSingleNode(L"ProductInfo1").text();
+			if (ele.selectSingleNode(L"EnquiryLineID")) EnquiryLineID = ele.selectSingleNode(L"EnquiryLineID").text();
+			if (ele.selectSingleNode(L"Buyer")) Buyer = ele.selectSingleNode(L"Buyer").text();
+
+			trace(L"\r\nsupplierphoto:" + supplierphoto);
+			for (int row = startRow; row <= LastRow; row++)
+			{
+				if (dw_cell.GetItemString(row, colItemName) == L"" &&
+					dw_cell.GetItemString(row, colItemSpec) == L"") break;
+				if (getRowID(dw_cell, row) == rowid)
+				{
+					dw_cell.SetItemString(row, colBuyerPrice, BuyerPrice);
+					dw_cell.SetItemString(row, colBuyerRemark, BuyerRemark);
+					dw_cell.SetItemString(row, colFactoryImage, FactoryImage);
+					dw_cell.SetItemString(row, colGWT, GWT);
+					dw_cell.SetItemString(row, colNWT, NWT);
+					dw_cell.SetItemString(row, colVolDesc, VolDesc);
+					dw_cell.SetItemString(row, colVol, Vol);
+					dw_cell.SetItemString(row, col40HQ, F40HQ);
+					dw_cell.SetItemString(row, colPurchedDate, PurchedDate);
+					dw_cell.SetItemString(row, colProductInfo, productInfo);
+					dw_cell.SetItemString(row, colProductInfo1, productInfo1);
+					if (Buyer != L"") dw_cell.SetItemString(row, colBuyer, Buyer);
+					if (EnquiryLineID != L"") setRowTerm(dw_cell, row, L"EnquiryLineID", EnquiryLineID);
+					if (supplierphoto != L"") setRowTerm(dw_cell, row, L"supplier-photo", supplierphoto);
+
+					xstring props = dw_cell.GetCellProps(row, colPhoto1);
+					props = L"<cellprop><edit edittype='image'/></cellprop>";
+					dw_cell.SetCellProps(row, colPhoto1, props);
+
+					break;
+				}
+			}
+		}
+		return 1;
+	}
+
+	int SyncPurch(xstring entityid)
+	{
+		xml x ;
+		
+		xaserverarg arg ;
+		
+		arg.AddArg(L"entityid", entityid);
+		//alert(id);
+		if (getUrl(L"/sale/data/TO/quote/purchared/item", arg.GetString(), x) != 1)
+		{
+			trace(x.text());
+			return -1;
+		}
+		return SyncPurch(x);
+	}
+
+	int  OnRetrieve(xstring id)
+	{
+		xml x ;
+		
+		xaserverarg arg ;
+		
+		arg.AddArg(L"id", id);
+		//alert(id);
+		if (getUrl(L"/sale/data/Quote/maint", arg.GetString(), x) != 1)
+		{
+			trace(x.text());
+			return -1;
+		}
+		else
+		{
+			dw_base.Retrieve(x);
+			dw_base.Redraw();
+			dw_goods.Retrieve(x);
+			dw_goods.Redraw();
+		}
+		return 1;
+	}
+
+	int onload()
+	{
+		Reset();
+		orivalue = L"";
+		ARow = 1;
+		ACol = 1;
+
+		tabsheet = L"tab_bill";
+		templateID = L"ECDDE57A-43EB-49DD-9287-DC5D0B29ECA1";
+		xstring templ = L"";
+		taskid = L"";
+		xaserverarg  arg;
+		if (GetParam()) {
+			arg ;
+			arg.setNativePointer(GetParam());
+			templ = arg.GetArgString(L"template");
+			entityID = arg.GetArgString(L"EntityID");
+			taskid = arg.GetArgString(L"TaskID");
+			if (entityID != L"")action = L"open";
+
+			trace(L"\r\nentity:" + entityID + L" taskid:" + taskid);
+		}
+		dw_cell = GetControl(L"dw_cell");
+
+		if (templ != L"")
+		{
+			/*xml x ;
+			x.setNativePointer(x.CreateInstance());
+			x.loadXML(templ);
+			*/
+			action = L"purch";
+
+			if (templ.find(L"action=\"") >= 0)
+			{
+				action = templ.mid(templ.find(L"action=\"") + 8, templ.find(L"\"", templ.find(L"action=\"") + 8) - (templ.find(L"action=\"") + 8));
+			}
+			if (action == L"") action = L"purch";
+			if (templ.find(L"TemplateItemID=\"") >= 0)
+			{
+				entityItemID = templ.mid(templ.find(L"TemplateItemID=\"") + 16, templ.find(L"\"", templ.find(L"TemplateItemID=\"") + 16) - (templ.find(L"TemplateItemID=\"") + 16));
+			}
+			if (entityItemID == L"")
+			{
+				if (templ.find(L" ItemID=\"") >= 0)
+				{
+					entityItemID = templ.mid(templ.find(L" ItemID=\"") + 9, templ.find(L"\"", templ.find(L" ItemID=\"") + 9) - (templ.find(L" ItemID=\"") + 9));
+				}
+			}
+
+			/*action = x.documentElement.getAttribute(L"action");
+			if(action==L"") action=L"purch";
+			entityItemID = x.documentElement.getAttribute(L"TemplateItemID");
+			if(entityItemID==L"")entityItemID = x.documentElement.getAttribute(L"ItemID");
+			*/
+			OpenDocument(entityItemID);
+			if (action == L"purched")
+			{
+				//SyncPurch(x);
+				SyncPurch(entityID);
+			}
+		}
+		else
+		{
+			/*
+			templateurl = L"/sale/view/Enquiry3/template/EnquiryQuote";
+			if(kind==L"2")
+				templateurl = L"/sale/view/Enquiry3/template/EnquiryBill";
+
+			dw_cell.openUrl(templateurl);
+			*/
+			//win32::SetWindowText(GetHWND(),L"鎶ヤ环鏂囦欢:[new]");
+		}
+
+		ARow = 0;
+		ACol = 0;
+		bPurchPrice = false;
+
+		dw_goods = GetControl(L"dw_goods");
+		//dw_goods .openUrl(L"/sale/view/Quote3/template/goods");
+		dw_goods.openUrl(L"/sale/view/Quote3/template/item/pricelist");
+		dw_goods.SetColumnState(L"ItemID", false);
+		dw_goods.SetColumnState(L"EnquiryLineID", false);
+		//dw_goods.SetColumnState(L"EnquiryPriceListID",false);
+		dw_goods.SetColumnState(L"POPrices", false);
+		dw_goods.SetColumnState(L"ClassifyID", false);
+		dw_goods.SetColumnState(L"Description", false);
+		dw_goods.SetColumnState(L"CName", false);
+		dw_goods.SetColumnState(L"QuoteLineID", false);
+		dw_goods.SetColumnState(L"SKUID", false);
+
+		dw_goods.SetAskStyle(true);
+
+		dw_base = GetControl(L"dw_base");
+		dw_base.openUrl(L"/sale/view/Quote3/template/base");
+		//dw_base.SetSelectionBorder(0);
+		dw_base.SetColHeaderHeight(0);
+		dw_base.SetRowSelectorWidth(0);
+		dw_base.SetHScrollState(false);
+		dw_base.SetVScrollState(false);
+
+		if (entityID != L"")
+		{
+			OnRetrieve(entityID);
+			if (templ == L"")OpenDocumentEntity(entityID);
+			//if(action==L"purched")SyncPurch(x);				
+		}
+		else
+		{
+			if (templ == L"")
+			{
+				OnInit();
+				OpenTemplate(templateID);
+			}
+		}
+
+		OnAttachEvent();
+		filename = L"";
+
+		/*	#define LayerFlow_None			0x00000001		//not layer space
+		#define LayerFlow_WE			0x00000002
+		#define LayerFlow_NS			0x00000004
+		#define LayerFlow_FreeForm		0x00000008
+		#define LayerFlow_Control		0x00000010
+		#define LayerFlow_HtmlFlow		0x00000020
+		#define LayerFlow_Sheets		0x00000040
+		#define LayerFlow_Hidden		0x00000080		//not show but layer space
+		#define LayerFlow_UnLayer		0x00000100		//not show and not layer space
+
+		#define	LayerFlow_NotLayerNode	(LayerFlow_None | LayerFlow_UnLayer)
+		#define LayerFlow_LayerChild	(LayerFlow_WE|LayerFlow_NS|LayerFlow_FreeForm|LayerFlow_Sheets| LayerFlow_HtmlFlow )
+		*/
+
+		if (action == L"purch")
+		{
+			xnode anode = GetAgentNode(L"tabheader");
+			anode.SetLayerFlow(0x00000100);
+			dw_cell.SetColumnCount(dw_cell.GetValidCol() + 6);
+		}
+		else
+			dw_cell.SetColumnCount(dw_cell.GetValidCol());
+
+		//OnRetrieve();
+
+		return 1;
+	}
+
+	xstring GetMySupplier()
+	{
+		int startRow = getItemHeadRow(dw_cell);
+
+		//娌℃湁鎵惧埌鍟嗗搧琛岀殑鏍囬
+		if (startRow < 1) return L"<data/>";
+		startRow++;
+
+		int colItemName = getItemCol(dw_cell, startRow - 1, L"Product Description,Product Name,Item Name");
+		int colItemSpec = getItemCol(dw_cell, startRow - 1, L"Specifications,瑙勬牸,浜у搧瑙勬牸");
+
+		int colSupplier1 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�1");
+		int colSupplier2 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�2");
+		int colSupplier3 = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�3");
+		int colSupplier = getItemCol(dw_cell, startRow - 1, L"渚涘簲鍟�");
+
+		int LastRow = dw_cell.GetValidRow();
+		xstring content = L"";
+		for (int row = startRow; row <= LastRow; row++)
+		{
+			if (dw_cell.GetItemString(row, colItemName) == L"" &&
+				dw_cell.GetItemString(row, colItemSpec) == L"") break;
+
+			xstring itemStr = L"";
+			if (colSupplier >= 1)
+			{
+				if (dw_cell.GetItemString(row, colSupplier) != L"")
+				{
+					if (hasParty(dw_cell.GetItemString(row, colSupplier)) == false)
+					{
+						itemStr += L"<Item update.new='1' update.modify='1'>";
+						itemStr += L"<Name>" + dw_cell.GetItemString(row, colSupplier) + L"</Name>";
+						itemStr += L"<ShortName>" + dw_cell.GetItemString(row, colSupplier) + L"</ShortName>";
+						itemStr += L"</Item>";
+					}
+				}
+			}
+			if (colSupplier1 >= 1)
+			{
+				if (dw_cell.GetItemString(row, colSupplier1) != L"")
+				{
+					if (hasParty(dw_cell.GetItemString(row, colSupplier1)) == false)
+					{
+						itemStr += L"<Item update.new='1' update.modify='1'>";
+						itemStr += L"<Name>" + dw_cell.GetItemString(row, colSupplier1) + L"</Name>";
+						itemStr += L"<ShortName>" + dw_cell.GetItemString(row, colSupplier1) + L"</ShortName>";
+						itemStr += L"</Item>";
+					}
+				}
+			}
+			if (colSupplier2 >= 1)
+			{
+				if (dw_cell.GetItemString(row, colSupplier2) != L"")
+				{
+					if (hasParty(dw_cell.GetItemString(row, colSupplier2)) == false)
+					{
+						itemStr += L"<Item update.new='1' update.modify='1'>";
+						itemStr += L"<Name>" + dw_cell.GetItemString(row, colSupplier2) + L"</Name>";
+						itemStr += L"<ShortName>" + dw_cell.GetItemString(row, colSupplier2) + L"</ShortName>";
+						itemStr += L"</Item>";
+					}
+				}
+			}
+			if (colSupplier3 >= 1)
+			{
+				if (dw_cell.GetItemString(row, colSupplier3) != L"")
+				{
+					if (hasParty(dw_cell.GetItemString(row, colSupplier3)) == false)
+					{
+						itemStr += L"<Item update.new='1' update.modify='1'>";
+						itemStr += L"<Name>" + dw_cell.GetItemString(row, colSupplier3) + L"</Name>";
+						itemStr += L"<ShortName>" + dw_cell.GetItemString(row, colSupplier3) + L"</ShortName>";
+						itemStr += L"</Item>";
+					}
+				}
+			}
+			if (itemStr != L"") content += itemStr;
+		}
+		xstring newEntityItemID = ViewObject::GetGuid();
+		content = L"<data>" + content + L"</data>";
+		return content;
+	}
+
+
+	int OnMySupplier()
+	{
+		if (action != L"purch") return 1;
+		xstring content = GetMySupplier();
+		xaserverarg arg ;
+		arg.setNativePointer(xaserverarg::CreateInstance());
+		arg.AddArg(L"value", content);
+		OpenWindow(L"dev:xpage[QuoteSupplierItem.vx]", cast(arg as int));
+
+		return 1;
+	}
+
+	bool hasParty(xstring name)
+	{
+		xml x ;
+		
+		xaserverarg arg ;
+		arg.setNativePointer(xaserverarg::CreateInstance());
+		arg.AddArg(L"Name", name);
+		if (getUrl(L"/sale/data/SupplierV3/HasParty", arg.GetString(), x) != 1)
+		{
+			alert(L"error:" + x.xml());
+		}
+		xstring count = x.documentElement.getAttribute(L"count");
+		if (count != L"0") return true;
+
+		return false;
+	}
+
+	int LoadPurcher()
+	{
+		purcher ;
+		purcher.setNativePointer(xml::CreateInstance());
+		xaserverarg arg ;
+		arg.setNativePointer(xaserverarg::CreateInstance());
+		arg.AddArg(L"id", L"閲囪喘鍛�");
+		if (getUrl(L"/sale/data/Quote/Purcher", arg.GetString(), purcher) != 1)
+		{
+			alert(L"error:" + purcher.GetXml());
+		}
+		return 1;
+	}
+
+	xstring GetPurchorByName(xstring name)
+	{
+		KXMLDOMNode n = purcher.selectSingleNode(L"//HrEmployee[Name='" + name + L"']/EmployeeID");
+		if (n)
+		{
+			return n.text();
+		}
+		else
+			return L"";
+
+	}
+
+	int onloaded()
+	{
+		SetAgent();
+		LoadPurcher();
+
+		xaserverarg  arg;
+		if (GetParam()) {
+			arg ;
+			arg.setNativePointer(GetParam());
+			if (arg.GetArgString(L"bill.purchor") == L"1") OnNextPurch();
+		}
+		return 1;
+	}
+};
\ No newline at end of file
diff --git a/jrj/project/viewobject/custom.view.hpp b/jrj/project/viewobject/custom.view.hpp
new file mode 100644
index 0000000..99bb272
--- /dev/null
+++ b/jrj/project/viewobject/custom.view.hpp
@@ -0,0 +1,63 @@
+#pragma once
+
+#include <wobject/xstring.hpp>
+#include <wobject/xaserverarg.hpp>
+#include <win32/win.hpp>
+#include <vbusiness/vutil/publiccode.vutil.vbusiness.hpp>
+#include <wobject/xurl.hpp>
+#include <xcontrol/xdwgrid.hpp>
+#include <xcontrol/xdwtable.hpp>
+#include "view.base.hpp"
+
+class CustomView : public ViewObject
+{
+public:
+	static KXMLDOMDocument GetSimulationView(string sono)
+	{
+		xaserverarg arg = MakeArg(L"sono", sono);
+		return FecthData(L"/sale/data/Custom3/fullview", arg.GetString());
+	}
+
+	//报关编号指定
+	static KXMLDOMDocument GetMaintFormForSourceItem()
+	{
+		return FecthData(L"/sale/data/Custom3/maint/form/sourceitem", L"");
+	}
+
+
+	static KXMLDOMDocument GetMaintSourceItem(string invno)
+	{
+		return RetrieveData(L"/sale/data/Custom3/maint/sourceitem", L"invno", invno);
+	}
+
+	static KXMLDOMDocument GetMaintFormHSGoods(string invno)
+	{
+		return RetrieveData(L"/sale/data/Custom3/maint/form/hsgoods", L"invno", invno);
+	}
+
+	static KXMLDOMDocument UpdateCustomItem(string invno, string content)
+	{
+		return RetrieveData(L"/sale/data/Custom3/maint/custom/update", L"invno", invno, L"content", content);
+	}
+
+	static KXMLDOMDocument UpdateCustomElement(string invno, string content)
+	{
+		return RetrieveData(L"/sale/data/Custom3/maint/customelement/update", L"invno", invno, L"content", content);
+	}
+
+	static KXMLDOMDocument GetCustomItem(string invno)
+	{
+		return RetrieveData(L"/sale/data/Custom3/maint/custom/data", L"invno", invno);
+	}
+
+	static KXMLDOMDocument GetCustomContainer(string invno)
+	{
+		return RetrieveData(L"/sale/data/Custom3/maint/customcontainer", L"invno", invno);
+	}
+
+
+	static KXMLDOMDocument GetCustomHabit(string invno)
+	{
+		return RetrieveData(L"/sale/data/Custom3/custom/habit", L"invno", invno);
+	}
+};
\ No newline at end of file
diff --git a/jrj/project/viewobject/gdn3.view.hpp b/jrj/project/viewobject/gdn3.view.hpp
new file mode 100644
index 0000000..3645472
--- /dev/null
+++ b/jrj/project/viewobject/gdn3.view.hpp
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <wobject/xstring.hpp>
+#include <wobject/xaserverarg.hpp>
+#include <win32/win.hpp>
+#include <vbusiness/vutil/publiccode.vutil.vbusiness.hpp>
+#include <wobject/xurl.hpp>
+#include <xcontrol/xdwgrid.hpp>
+#include <xcontrol/xdwtable.hpp>
+#include "view.base.hpp"
+
+class GDNView : public ViewObject
+{
+public:
+	//页面信息
+	static KXMLDOMDocument GetGDNSimulationView(string SONo)
+	{
+		xaserverarg arg = MakeArg(L"SONo", SONo);
+
+		return FecthData(L"/sale/data/Gdn/simulation/view", arg.GetString());
+	}
+
+	static KXMLDOMDocument GetInvoiceBySONo(string sono)
+	{
+		return RetrieveData(L"/sale/data/GDN/source/invno", L"sono", sono);
+	}
+
+	static string GetInvoiceNoByID(string id)
+	{
+		KXMLDOMDocument x = RetrieveData(L"/sale/data/GDN/info/invnobyid", L"EntityID", id);
+		string no = L"";
+		if (x) no = x.selectSingleNode(L"//item").text();
+		return no;
+	}
+
+};
\ No newline at end of file
diff --git a/jrj/project/viewobject/view.base.hpp b/jrj/project/viewobject/view.base.hpp
index 2c90dbf..4fa582c 100644
--- a/jrj/project/viewobject/view.base.hpp
+++ b/jrj/project/viewobject/view.base.hpp
@@ -195,6 +195,11 @@
 		return no;
 	}
 
+	static int TransData(KXMLDOMNodeList nlist, xdwtable dwobj, int row, string column, string data)
+	{
+		return  TransData(xapp::GetServerUrl(), nlist, dwobj, row, column, data);
+	}
+
 	static int TransData(string serverUrl,KXMLDOMNodeList nlist, xdwtable dwobj, int row, string column, string data)
 	{
 		int len = nlist.length();
@@ -236,6 +241,11 @@
 		return 1;
 	}
 
+	static int TransData(KXMLDOMNodeList nlist, xdwgrid dwobj, int row, string column, string data)
+	{
+		return  TransData(xapp::GetServerUrl(), nlist, dwobj, row, column, data);
+	}
+
 	static int TransData(string serverUrl, KXMLDOMNodeList nlist, xdwgrid dwobj, int row, string column, string data)
 	{
 		int len = nlist.length();
diff --git a/jrj/project/vindexform.cpp b/jrj/project/vindexform.cpp
index 46c6329..cb6a969 100644
--- a/jrj/project/vindexform.cpp
+++ b/jrj/project/vindexform.cpp
@@ -80,7 +80,8 @@
 		int t2 = r.top;
 		int b2 = r.bottom;
 
-		MoveWindow(m_hMenu, l - 7, b, 220, b2 - t2, false);
+		MoveWindow(m_hMenu, l - 7, b, 220, b2 - t2, true);
+		
 		return 1;
 	}
 
diff --git a/jrj/xframe/kobject/kcell.hpp b/jrj/xframe/kobject/kcell.hpp
new file mode 100644
index 0000000..4288ee4
--- /dev/null
+++ b/jrj/xframe/kobject/kcell.hpp
@@ -0,0 +1,98 @@
+#pragma once
+
+#include "kcontrol.hpp"
+namespace Hxsoft {	namespace XFrame {	namespace XOffice {	namespace XCell{
+
+class  IXCell : public IXFControl
+{
+public:
+	int GetRow();
+	int GetColumn();
+
+	int GetAnchorRow();
+	int GetAnchorCol();
+
+	int SetRowColumn(int ARow, int ACol);
+	int SetAnchorRowColumn(int ARow, int ACol);
+
+	int GetRowCount();
+	int SetRowCount(int columnCount);
+
+	int GetColumnCount();
+	int SetColumnCount(int columnCount);
+
+	LPCTSTR GetItemString(int ARow, int ACol);
+	int SetItemString(int ARow, int ACol, LPTSTR pText);
+	LPCTSTR GetItemDisplayString(int ARow, int ACol);
+	int SetItemDisplayString(int ARow, int ACol, LPTSTR pText);
+
+	int SetBorder(int nBorder);
+
+	int Copy();
+	int Cut();
+	int Paste();
+
+	int GetColumnWidth(int nCol);
+	bool SetColumnWidth(int nCol, int nWidth);
+	int GetRowHeight(int nRow);
+	bool SetRowHeight(int nRow, int nHeight);
+public:
+	int SetRowSelectorWidth(int nWidth);
+	int ResetRowSelector();
+	int GetRowSelectorWidth();
+	int GetRowSelectorDefaultWidth();
+
+	int SetColHeaderHeight(int nHeight);
+	int GetColHeaderDefaultHeight();
+	int ResetColHeaderHeight();
+	int GetColHeaderHeight();
+public:
+	LPTSTR GetCellProps(int nRow, int nCol); //得到单元整体XML属性
+	int SetCellProps(int nRow, int nCol, LPCTSTR pXmlProp); //得到单元整体XML属性
+	LPTSTR GetCellProp(int nRow, int nCol, LPCTSTR pItem); //得到单元属性
+	int SetCellProp(int nRow, int nCol, LPCTSTR pItem, LPCTSTR pProp);//得到单元属性
+public:
+	LPTSTR GetHtml();
+	LPTSTR GetData();
+public:
+	void* GetSheetSvr();
+public:
+	void		SetSchmaSource(LPCTSTR pSchema);
+	LPCTSTR		GetSchemaSource();
+	void		SetSchmaString(LPCTSTR pSchemaStr);
+	LPCTSTR		GetSchemaString();
+public:
+	int			GetSpanRight(int ARow, int ACol);
+	int			GetSpanBottom(int ARow, int ACol);
+	int			GetSpanLeft(int ARow, int ACol);
+	int			GetSpanTop(int ARow, int ACol);
+	bool		IsSpanCell(int ARow, int ACol);
+public:
+	int			GetValidRow();
+	int			GetValidCol(int ARow);
+	int			GetValidRowCol(int& ARow, int& ACol);
+	int			GetValidCol();
+public:
+	int			LoadTemplate(KXMLDOMDocument  pDoc, LPTSTR strState);
+	int			LoadTemplate(KXMLDOMElement pElement, LPTSTR strState);
+public:
+	int SaveFileAs();
+	int SaveFile();
+	int SaveFile(wchar_t* fileName);
+public:
+	int OpenFile(wchar_t* fileName);
+	int OpenFile();
+public:
+	wchar_t* m_pFileName;
+public:
+	int SetReadOnly(bool bReadOnly);
+	int SetRunState();
+	int SetRunState(int runstate);
+public:
+	void SetEditUpperMode(bool upper);
+	bool GetEditUpperMode();
+public:
+	LPCTSTR GetSortColumns();
+	void SortData(LPCTSTR sortColumn, LPTSTR strType, bool bAsc);
+};
+}}}}
diff --git a/jrj/xframe/src/xstring.cpp b/jrj/xframe/src/xstring.cpp
index 2fcb5dc..3bc27b1 100644
--- a/jrj/xframe/src/xstring.cpp
+++ b/jrj/xframe/src/xstring.cpp
@@ -595,7 +595,11 @@
     return false;
 }
 
-xstring xstring::replace(wchar_t* from, wchar_t* to, int pos)
+xstring xstring::replace(const wchar_t* from, const wchar_t* to)
+{
+    return replace(from, to, 0);
+}
+xstring xstring::replace(const wchar_t* from, const wchar_t* to, int pos)
 {
     const wchar_t* pstr = c_str();
     if (!pstr) return 0;
diff --git a/jrj/xframe/vbusiness/vutil/publiccode.vutil.vbusiness.hpp b/jrj/xframe/vbusiness/vutil/publiccode.vutil.vbusiness.hpp
index fb10202..c6294e3 100644
--- a/jrj/xframe/vbusiness/vutil/publiccode.vutil.vbusiness.hpp
+++ b/jrj/xframe/vbusiness/vutil/publiccode.vutil.vbusiness.hpp
@@ -101,7 +101,7 @@
 	{
 		/*
 		if (sOrgID == "") return "4.2";
-		xml x = new xml;
+		xml 
 		x.setNativePointer(xml::CreateInstance());
 		xaserverarg args=new xaserverarg;
 		args.setNativePointer(args.CreateInstance());
@@ -235,7 +235,7 @@
 
 	static KXMLDOMDocument getAssignment(string sguid, KXMLDOMDocument x)
 	{
-		//xml x = new xml;
+		//xml 
 		//x.setNativePointer(xml::CreateInstance());		
 		xaserverarg arg;
 		arg.setNativePointer(arg.CreateInstance());
diff --git a/jrj/xframe/wobject/xstring.hpp b/jrj/xframe/wobject/xstring.hpp
index 020ebfd..8049037 100644
--- a/jrj/xframe/wobject/xstring.hpp
+++ b/jrj/xframe/wobject/xstring.hpp
@@ -87,7 +87,8 @@
 	xstring rtrim();
 
 	bool isNumber();
-	xstring replace(wchar_t* from, wchar_t* to, int pos);
+	xstring replace(const wchar_t* from, const wchar_t* to);
+	xstring replace(const wchar_t* from, const wchar_t* to, int pos);
 };
 xstring operator +(const wchar_t* lhs, const xstring& rhs);
 
diff --git a/jrj/xframe/xcontrol/xcell.hpp b/jrj/xframe/xcontrol/xcell.hpp
new file mode 100644
index 0000000..767285f
--- /dev/null
+++ b/jrj/xframe/xcontrol/xcell.hpp
@@ -0,0 +1,294 @@
+#pragma once
+
+#include "wobject/xcontrol.hpp"
+#include "kobject/kcell.hpp"
+#include "wobject/xurl.hpp"
+
+using kcell = Hxsoft::XFrame::XOffice::XCell::IXCell;
+class xcell : public xcontrol
+{
+public:
+	xcell(void* impl=nullptr) :xcontrol(impl) {}
+public:
+	kcell* GetKCell()
+	{
+		return (kcell*)this->GetNativePtr();
+	}
+public:
+	xstring GetHtml() //alias "?GetHtml@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEPA_WXZ";
+	{
+		return GetKCell()->GetHtml();
+	}
+	xstring GetData() //alias "?GetData@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEPA_WXZ";
+	{
+		return GetKCell()->GetData();
+	}
+	int GetAnchorCol() //alias "?GetAnchorCol@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{
+		return GetKCell()->GetAnchorCol();
+
+	}
+	int GetAnchorRow() //alias "?GetAnchorRow@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{
+		return GetKCell()->GetAnchorRow();
+
+	}
+	int GetColumn() //alias "?GetColumn@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{
+		return GetKCell()->GetColumn();
+
+	}
+	int GetColumnCount() //alias "?GetColumnCount@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{
+		return GetKCell()->GetColumnCount();
+
+	}
+	xstring GetItemString(int ARow, int ACol) //alias "?GetItemString@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEPB_WHH@Z";
+	{
+		return GetKCell()->GetItemString(ARow, ACol);
+	}
+	int GetRow() //alias "?GetRow@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{
+		return GetKCell()->GetRow();
+	}
+	int GetRowCount() //alias "?GetRowCount@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{
+		return GetKCell()->GetRowCount();
+	}
+	int SetAnchorRowColumn(int ARow, int ACol) //alias "?SetAnchorRowColumn@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHHH@Z";
+	{
+		return GetKCell()->SetAnchorRowColumn(ARow,ACol);
+	}
+	int SetRowColumn(int ARow, int ACol) //alias "?SetRowColumn@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHHH@Z";
+	{
+		return GetKCell()->SetRowColumn(ARow,ACol);
+	}
+	int SetBorder(int nBorder) //alias "?SetBorder@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHH@Z";
+	{
+		return GetKCell()->SetBorder(nBorder);
+	}
+
+	int SetColumnCount(int columnCount) //alias "?SetColumnCount@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHH@Z";
+	{
+		return GetKCell()->SetColumnCount(columnCount);
+	}
+	int SetRowCount(int rowCount) //alias "?SetRowCount@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHH@Z";
+	{
+		return GetKCell()->SetRowCount(rowCount);
+	}
+
+	int SetItemString(int ARow, int ACol, xstring value) //alias "?SetItemString@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHHHPA_W@Z";
+	{
+		return GetKCell()->SetItemString(ARow,ACol,(LPTSTR)value.c_str());
+	}
+	int SetRowColumn(int ARow, int ACol) //alias "?SetRowColumn@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHHH@Z";
+	{
+		return GetKCell()->SetRowColumn(ARow,ACol);
+	}
+	int Copy() //alias "?Copy@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{
+		return GetKCell()->Copy() ;
+	}
+	int Cut() //alias "?Cut@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{
+		return GetKCell()->Cut() ;
+	}
+	int Paste() //alias "?Paste@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{
+		return GetKCell()->Paste() ;
+	}
+	xstring  GetCellProp(int nRow, int nCol, xstring Item) //alias "?GetCellProp@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEPA_WHHPB_W@Z";
+	{
+		return GetKCell()->GetCellProp(nRow,nCol,Item);
+	}
+	xstring  GetCellProps(int nRow, int nCol) //alias "?GetCellProps@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEPA_WHH@Z";
+	{
+		return GetKCell()->GetCellProps(nRow,nCol);
+	}
+	int   SetCellProp(int nRow, int nCol, xstring Item, xstring val) //alias "?SetCellProp@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHHHPB_W0@Z";
+	{
+		return GetKCell()->SetCellProp(nRow,nCol,Item,val);
+	}
+	int   SetCellProps(int nRow, int nCol, xstring val) //alias "?SetCellProps@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHHHPB_W@Z";
+	{
+		return GetKCell()->SetCellProps(nRow,nCol,val);
+	}
+	int   GetColumnWidth(int nCol) //alias "?GetColumnWidth@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHH@Z";
+	{
+		return GetKCell()->GetColumnWidth(nCol);
+	}
+	bool   SetColumnWidth(int nCol, int nWidth) //alias "?SetColumnWidth@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAE_NHH@Z";
+	{
+		return GetKCell()->SetColumnWidth(nCol,nWidth) ;
+	}
+	bool   SetRowHeight(int nRow, int nHeight) //alias "?SetRowHeight@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAE_NHH@Z";
+	{
+		return GetKCell()->SetRowHeight(nRow,nHeight);
+	}
+	int   GetRowHeight(int nRow) //alias "?GetRowHeight@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHH@Z";
+	{
+		return GetKCell()->GetRowHeight(nRow);
+	}
+	int SetRowSelectorWidth(int nWidth) //alias "?SetRowSelectorWidth@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHH@Z";
+	{
+		return GetKCell()->SetRowSelectorWidth(nWidth);
+	}
+	int ResetRowSelector() //alias "?ResetRowSelector@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->ResetRowSelector();
+
+	}
+	int GetRowSelectorWidth() //alias "?GetRowSelectorWidth@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->GetRowSelectorWidth();
+
+	}
+	int GetRowSelectorDefaultWidth() //alias "?GetRowSelectorDefaultWidth@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->GetRowSelectorDefaultWidth();
+
+	}
+	int SetColHeaderHeight(int nHeight) //alias "?SetColHeaderHeight@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHH@Z";
+	{ return GetKCell()->SetColHeaderHeight(nHeight);
+
+	}
+	int GetColHeaderDefaultHeight() //alias "?GetColHeaderDefaultHeight@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->GetColHeaderDefaultHeight();
+
+	}
+	int ResetColHeaderHeight() //alias "?ResetColHeaderHeight@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->ResetColHeaderHeight();
+
+	}
+	int GetColHeaderHeight() //alias "?GetColHeaderHeight@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->GetColHeaderHeight();
+
+	}
+	//param GetSheetSvr() //alias "?GetSheetSvr@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEPAXXZ";
+	void SetSchmaSource(xstring schemasource) //alias "?SetSchmaSource@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEXPB_W@Z";
+	{ return GetKCell()->SetSchmaSource(schemasource);
+
+	}
+	void SetSchmaString(xstring schemasstr) //alias "?SetSchmaString@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEXPB_W@Z";
+	{ return GetKCell()->SetSchmaString(schemasstr);
+
+	}
+	xstring GetSchemaSource() //alias "?GetSchemaSource@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEPB_WXZ";
+	{ return GetKCell()->GetSchemaSource();
+
+	}
+	xstring GetSchemaString() //alias "?GetSchemaString@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEPB_WXZ";
+	{ return GetKCell()->GetSchemaString();
+
+	}
+
+	int GetSpanBottom(int nRow, int nCol) //alias "?GetSpanBottom@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHHH@Z";
+	{ return GetKCell()->GetSpanBottom(nRow, nCol);
+
+	}
+	int GetSpanLeft(int nRow, int nCol) //alias "?GetSpanLeft@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHHH@Z";
+	{ return GetKCell()->GetSpanLeft(nRow,nCol);
+
+	}
+	int GetSpanRight(int ARow, int ACol) //alias "?GetSpanRight@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHHH@Z";
+	{ return GetKCell()->GetSpanRight(ARow,ACol);
+
+	}
+	int GetSpanTop(int ARow, int ACol) //alias "?GetSpanTop@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHHH@Z";
+	{ return GetKCell()->GetSpanTop(ARow,ACol);
+
+	}
+	bool IsSpanCell(int ARow, int ACol) //alias "?IsSpanCell@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAE_NHH@Z";
+	{ return GetKCell()->IsSpanCell(ARow,ACol);
+
+	}
+	int GetValidCol(int ARow) //alias "?GetValidCol@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHH@Z";
+	{ return GetKCell()->GetValidCol();
+
+	}
+	int GetValidCol() //alias "?GetValidCol@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->GetValidCol();
+
+	}
+	int GetValidRow() //alias "?GetValidRow@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->GetValidRow();
+
+	}
+	int GetValidRowCol(int &ARow, int &ACol) //alias "?GetValidRowCol@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHAAH0@Z";
+	{ return GetKCell()->GetValidRowCol(ARow,ACol) ; 
+
+	}
+	void SetEditUpperMode(bool upper) //alias "?SetEditUpperMode@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEX_N@Z";
+	{ return GetKCell()->SetEditUpperMode(upper);
+
+	}
+
+	int LoadTemplate(KXMLDOMDocument xmldoc, xstring state) //alias "?LoadTemplate@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHPAUIXMLDOMDocument@@PA_W@Z";
+	{ return GetKCell()->LoadTemplate(xmldoc,(LPTSTR)state.c_str());
+
+	}
+	int LoadTemplate(KXMLDOMElement ele, xstring state) //alias "?LoadTemplate@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHPAUIXMLDOMElement@@PA_W@Z";
+	{ return GetKCell()->LoadTemplate(ele, (LPTSTR)state.c_str());
+
+	}
+	int LoadTemplateEx(KXMLDOMElement ele)
+	{ 
+		return LoadTemplate(ele, L"design");
+	}
+
+	int LoadTemplate(KXMLDOMDocument xmldoc)
+	{ 
+		return LoadTemplate(xmldoc, L"design");
+	}
+
+	int openUrl(xstring aurl)
+	{
+		KXMLDOMDocument x;
+		xurl::get(aurl, L"", x);
+		return LoadTemplate(x);
+	}
+
+	int openUrl(xstring aurl, xstring arg)
+	{
+		KXMLDOMDocument x;
+		xurl::get(aurl, arg, x);
+		return LoadTemplate(x);
+	}
+
+	int OpenFile(xstring fileUrl) //alias "?OpenFile@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHPA_W@Z";
+	{ return GetKCell()->OpenFile((LPTSTR)fileUrl.c_str());
+
+	}
+	int OpenFile() //alias "?OpenFile@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->OpenFile();
+
+	}
+	int SaveFile(xstring fileUrl) //alias "?SaveFile@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHPA_W@Z";
+	{ return GetKCell()->SaveFile((LPTSTR)fileUrl.c_str());
+
+	}
+	int SaveFile() //alias "?SaveFile@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->SaveFile();
+
+	}
+	int SaveFileAs() //alias "?SaveFileAs@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->SaveFileAs();
+
+	}
+
+	int SetRunState(int state) // "?SetRunState@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHH@Z";
+	{ return GetKCell()->SetRunState(state);
+
+	}
+
+	int SetRunState() //alias "?SetRunState@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEHXZ";
+	{ return GetKCell()->SetRunState();
+
+	}
+
+	int SetReadOnly(bool bReadOnly) //alias "?SetReadOnly@IXCell@XCell@XOffice@XFrame@Hxsoft@@QAEH_N@Z";
+	{ return GetKCell()->SetReadOnly(bReadOnly);
+
+	}
+};
+
+
+
+
diff --git a/jrj/xframe/xcontrol/xdwgrid.hpp b/jrj/xframe/xcontrol/xdwgrid.hpp
index 254e5ff..11f7f9c 100644
--- a/jrj/xframe/xcontrol/xdwgrid.hpp
+++ b/jrj/xframe/xcontrol/xdwgrid.hpp
@@ -270,9 +270,9 @@
 		return getKReport()->GetTitleName(col);
 	}
 public:
-	int SetRowSort(LPTSTR colName, bool colOrder = true)
+	int SetRowSort(LPCTSTR colName, bool colOrder = true)
 	{
-		return getKReport()->SetRowSort(colName, colOrder);
+		return getKReport()->SetRowSort((LPTSTR)colName, colOrder);
 	}
 	int SetClickEditFlag(bool f)
 	{
diff --git a/jrj/xframe/xcontrol/xtreeview.hpp b/jrj/xframe/xcontrol/xtreeview.hpp
index 0d27f16..4fa7b47 100644
--- a/jrj/xframe/xcontrol/xtreeview.hpp
+++ b/jrj/xframe/xcontrol/xtreeview.hpp
@@ -349,6 +349,11 @@
         return 1;			
     }
 
+    HTREEITEM InsertChildItem(HTREEITEM hItem, string label, KXMLDOMElement ele, int image = 0)
+    {
+        return InsertChildItem(hItem, label, ele.ptr(), image);
+    }
+
     HTREEITEM InsertChildItem(HTREEITEM hItem,string label,LPARAM data,int image = 0)
     {
             HTREEITEM h;
@@ -377,6 +382,11 @@
             return h;
     }
 
+    HTREEITEM InsertChildItemEx(HTREEITEM hItem, string label, KXMLDOMElement ele, int image = 0, int image2 = 0)
+    {
+        return InsertChildItemEx(hItem, label, ele.ptr(), image,image2);
+    }
+
     HTREEITEM InsertChildItemEx(HTREEITEM hItem,string label,int data,int image = 0,int image2 = 0)
     {
         int TVM_INSERTITEM = TV_FIRST + 50;

--
Gitblit v1.9.3