GDN
LiFan
2024-06-26 b7b9d28bb091bf673b4899f50fd28fa1214ac7a3
jrj/project/business/GDN3.maint.cpp
@@ -53,18 +53,18 @@
      xml x;
      
      xaserverarg arg = new xaserverarg;
      xaserverarg& arg = *new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());
      arg.AddArg(L"scene", scene, L"xs:xstring");
      arg.AddArg(L"EntityID", EntityID, L"xs:xstring");
      arg.AddArg(L"EntityName", EntityName, L"xs:xstring");
      url::get(L"/workflow/query/datarole/" + EntityName, arg.GetString(), x);
      xurl::get(L"/workflow/query/datarole/" + EntityName, arg.GetString(), x);
      xstring sNodes;
      sNodes = L"datarole/actions/action[contains(@scene,'" + scene + L"')]";
      KXMLDOMNodeList nlist = x.GetXmlDoc().SelectNodes(sNodes);
      KXMLDOMNodeList nlist = x.selectNodes(sNodes);
      int  index;
      int  nlen = nlist.length;
      int  nlen = nlist.length();
      KXMLDOMElement ele;
      xstring tools = L"<vbox class=''>";
@@ -74,17 +74,17 @@
      for (index = 0; index < nlen; index++)
      {
         ele = nlist.item(index);
         xstring name = ele.selectSingleNode(L"@id").text;//.getAttribute(L"id");
         xstring label = ele.selectSingleNode(L"@caption").text;//ele.getAttribute(L"caption");
         xstring name = ele.selectSingleNode(L"@id").text();//.getAttribute(L"id");
         xstring label = ele.selectSingleNode(L"@caption").text();//ele.getAttribute(L"caption");
         xstring image;
         xstring src = L"";
         if (ele.selectSingleNode(L"@image"))
            image = ele.selectSingleNode(L"@image").text;
            image = ele.selectSingleNode(L"@image").text();
         else
            image = L"0 22";
         if (ele.selectSingleNode(L"@src"))
            src = ele.selectSingleNode(L"@src").text;
            src = ele.selectSingleNode(L"@src").text();
         xstring tool;
         if (name.find(L"bill.update") >= 0) haveUpdate = true;
@@ -96,12 +96,12 @@
      }
      if (agent)
      {
         nlist = agent.SelectNodes(L".//xtoolbutton");
         nlen = nlist.length;
         nlist = agent.selectNodes(L".//xtoolbutton");
         nlen = nlist.length();
         for (index = 0; index < nlen; index++)
         {
            ele = nlist.item(index);
            xstring tmp = ele.xml;
            xstring tmp = ele.xml();
            tools += tmp;
         }
      }
@@ -178,52 +178,52 @@
      return 1;
   }
   xstring  GetEntityData(int pr)
   xstring  GetEntityData(LPARAM pr)
   {
      dw_base.AcceptText();
      dw_source.AcceptText();
      dw_item.AcceptText();
      dw_custom.AcceptText();
      xml xbase = new xml;
      xbase.setNativePointer(xml::CreateInstance());
      dw_base.DwUpdateAllTo(xbase.GetXmlDoc());
      xml xbase;
      dw_base.DwUpdateAllTo(xbase);
      KXMLDOMElement ebase = xbase.GetXmlDoc().documentElement;
      KXMLDOMElement ebase = xbase.documentElement();
      xml xitem = new xml;
      xitem.setNativePointer(xml::CreateInstance());
      KXMLDOMDocument xitemdoc = xitem.GetXmlDoc();
      xml xitem ;
      KXMLDOMDocument xitemdoc = xitem;
      dw_item.DwUpdateAllToEx(xitemdoc);
      if (xitem.GetXml() != L"")
      if (xitem.xml() != L"")
      {
         KXMLDOMElement eitem = xitemdoc.documentElement;
         KXMLDOMElement eitem = xitemdoc.documentElement();
         if (eitem) ebase.appendChild(eitem);
      }
      xml xsource = new xml;
      xsource.setNativePointer(xml::CreateInstance());
      KXMLDOMDocument xsourcedoc = xsource.GetXmlDoc();
      xml xsource;
      KXMLDOMDocument xsourcedoc = xsource;
      dw_source.DwUpdateAllToEx(xsourcedoc);
      if (xsource.GetXml() != L"")
      if (xsource.xml() != L"")
      {
         KXMLDOMElement eitem1 = xitemdoc.documentElement;
         KXMLDOMElement eitem1 = xitemdoc.documentElement();
         if (eitem1) ebase.appendChild(eitem1);
      }
      xml xcustom = new xml;
      xcustom.setNativePointer(xml::CreateInstance());
      KXMLDOMDocument xcustomdoc = xcustom.GetXmlDoc();
      xml xcustom;
      KXMLDOMDocument xcustomdoc = xcustom;
      dw_source.DwUpdateAllToEx(xcustomdoc);
      if (xcustom.GetXml() != L"")
      if (xcustom.xml() != L"")
      {
         KXMLDOMElement eitem2 = xitemdoc.documentElement;
         if (eitem2) ebase.appendChild(eitem1);
         KXMLDOMElement eitem2 = xitemdoc.documentElement();
         if (eitem2) ebase.appendChild(eitem2);
      }
      return ebase.xml;
      return ebase.xml();
   }
@@ -253,7 +253,7 @@
   xstring GetEntityName(int /*param*/ pr)
   {
      return "GDN3";
      return L"GDN3";
   }
   xstring GetGuid()
@@ -266,14 +266,14 @@
      xml x = ViewObject::RetrieveData(L"/sale/data/GDN/habit/customer", L"CustomerID", CustomerID);
      if (x)
      {
         KXMLDOMNodeList nodes = x.GetXmlDoc().selectNodes(L"GDN/*");
         int len = nodes.length;
         KXMLDOMNodeList nodes = x.selectNodes(L"GDN/*");
         int len = nodes.length();
         for (int i = 0; i < len; i++)
         {
            KXMLDOMElement e = nodes.item(i);
            dw_base.SetItemString(1, e.tagName, e.text);
            dw_base.SetItemString(1, e.tagName(), e.text());
            if (e.selectSingleNode(L"@_displaystring"))
               dw_base.SetItemDisplayString(1, e.tagName, e.selectSingleNode(L"@_displaystring").text);
               dw_base.SetItemDisplayString(1, e.tagName(), e.selectSingleNode(L"@_displaystring").text());
         }
      }
      return 1;
@@ -358,7 +358,7 @@
      for (int row = 1; row <= dw_item.GetRowCount(); row++)
      {
         double Quantity = dw_item.GetItemDouble(row, L"Quantity");
         int Packages = dw_item.GetItemDouble(row, L"Packages").toInt();
         int Packages = (int)dw_item.GetItemDouble(row, L"Packages");
         double GW = dw_item.GetItemDouble(row, L"GW");
         double NW = dw_item.GetItemDouble(row, L"NW");
         double Vol = dw_item.GetItemDouble(row, L"Volume");
@@ -373,7 +373,7 @@
         GW_s += GW;
         NW_s += NW;
         Amount_s += Amount;
         Vol_s += Vol.round(2);
         Vol_s += xdouble(Vol).round(2);
         Cost_s += Cost;
         ResearchCommissionRate_s += ResearchCommissionRate;
         MiddlemanAmountRate_s += MiddlemanAmountRate;
@@ -381,9 +381,9 @@
      dw_base.SetItemDouble(1, L"Quantity", Quantity_s);
      dw_base.SetItemDouble(1, L"GW", GW_s);
      dw_base.SetItemDouble(1, L"NW", NW_s);
      dw_base.SetItemString(1, L"Packages", Packages_s.toString());
      dw_base.SetItemDouble(1, L"Volume", Vol_s.round(2));
      dw_base.ItemChangeTo(1, L"Amount", Amount_s.toString());
      dw_base.SetItemString(1, L"Packages", xstring(Packages_s));
      dw_base.SetItemDouble(1, L"Volume", xdouble(Vol_s).round(2));
      dw_base.ItemChangeTo(1, L"Amount", xstring(Amount_s));
      dw_base.SetItemDouble(1, L"PrivateCommissionAmount", ResearchCommissionRate_s + MiddlemanAmountRate_s);
@@ -426,7 +426,7 @@
         xml check_x = ViewObject::RetrieveData(L"/sale/data/GDN/source/FindByInvoiceNo", L"InvoiceNo", InvoiceNo1);
         if (check_x)
         {
            xstring cnt = check_x.GetXmlDoc().documentElement.getAttribute(L"count");
            xstring cnt = check_x.documentElement().getAttribute(L"count");
            if (cnt != L"0") {
               alert(L"外运编号已存在,请重新填写!");
               return 0;
@@ -511,32 +511,32 @@
      xstring str = L"";
      dw_base.AcceptText();
      xml xbase = new xml;
      xbase.setNativePointer(xml::CreateInstance());
      KXMLDOMDocument xbasedoc = xbase.GetXmlDoc();
      xml xbase;
      KXMLDOMDocument xbasedoc = xbase;
      dw_base.DwUpdateAllTo(xbasedoc);
      xaserverarg arg = GDNView::MakeArg();
      //if(dw_billnote.DeletedCount()+dw_billnote.ModifiedCount() > 0)
      //{
      xml xbillnote = new xml;
      xbillnote.setNativePointer(xml::CreateInstance());
      dw_billnote.DwUpdateAllToEx(xbillnote.GetXmlDoc());
      xml xbillnote ;
      dw_billnote.DwUpdateAllToEx(xbillnote);
      KXMLDOMElement docinfo = xbillnote.GetXmlDoc().selectSingleNode(L"GDN/DocInfo");
      docinfo.SetAttribute(L"update.modify", L"1");
      xbase.GetXmlDoc().documentElement.appendChild(docinfo);
      xbase.GetXmlDoc().documentElement.SetAttribute(L"update.modify", L"1");
      KXMLDOMElement docinfo = xbillnote.selectSingleNode(L"GDN/DocInfo");
      docinfo.setAttribute(L"update.modify", L"1");
      xbase.documentElement().appendChild(docinfo);
      xbase.documentElement().setAttribute(L"update.modify", L"1");
      //}
      arg.AddArg(L"content", xbase.GetXml());
      if (url::get(L"/sale/data/Gdn3/update/base", arg.GetString(), xbase) != 1)
      arg.AddArg(L"content", xbase.xml());
      if (xurl::get(L"/sale/data/Gdn3/update/base", arg.GetString(), xbase) != 1)
      {
         xstring error = xbase.GetXmlDoc().text;
         xstring error = xbase.text();
         alert(L"err:" + error);
         alert(L"基本信息保存失败!");
         return -1;
      }
      str = xbase.GetXmlDoc().documentElement.getAttribute(L"text");
      str = xbase.documentElement().getAttribute(L"text");
      if (str == L"false")
      {
         alert(L"基本信息保存失败!");
@@ -545,19 +545,19 @@
      dw_base.ResetUpdateStatus();
      dw_profit.AcceptText();
      xml xprofit = new xml;
      xprofit.setNativePointer(xml::CreateInstance());
      KXMLDOMDocument xprofitdoc = xprofit.GetXmlDoc();
      xml xprofit;
      KXMLDOMDocument xprofitdoc = xprofit;
      dw_profit.DwUpdateAllTo(xprofitdoc);
      xaserverarg arg3 = GDNView::MakeArg();
      arg3.AddArg(L"content", xprofit.GetXml());
      if (url::get(L"/sale/data/Gdn/update/profit", arg3.GetString(), xprofit) != 1)
      arg3.AddArg(L"content", xprofit.xml());
      if (xurl::get(L"/sale/data/Gdn/update/profit", arg3.GetString(), xprofit) != 1)
      {
         xstring error4 = xprofit.GetXmlDoc().text;
         xstring error4 = xprofit.text();
      }
      else
      {
         str = xprofit.GetXmlDoc().documentElement.getAttribute(L"text");
         str = xprofit.documentElement().getAttribute(L"text");
         if (str == L"false")
         {
            alert(L"盈亏信息保存失败!");
@@ -573,25 +573,25 @@
      {
         if (dw_item.GetItemString(k, L"SeqNo") == L"")
         {
            dw_item.SetItemString(k, L"SeqNo", k.toString());
            dw_item.SetItemString(k, L"SeqNo", xstring(k));
         }
      }
      xml xitem = new xml;
      xitem.setNativePointer(xml::CreateInstance());
      KXMLDOMDocument xitemdoc = xitem.GetXmlDoc();
      xml xitem ;
      KXMLDOMDocument xitemdoc = xitem;
      dw_item.DwUpdateAllToEx(xitemdoc);
      //dw_base.DwUpdateAllTo(xitemdoc);
      xaserverarg arg1 = GDNView::MakeArg();
      arg1.AddArg(L"content", xitem.GetXml());
      arg1.AddArg(L"content", xitem.xml());
      if (url::get(L"/sale/data/Gdn/update/item", arg1.GetString(), xitem) != 1)
      if (xurl::get(L"/sale/data/Gdn/update/item", arg1.GetString(), xitem) != 1)
      {
         xstring error1 = xitem.GetXmlDoc().text;
         xstring error1 = xitem.text();
      }
      else
      {
         str = xitem.GetXmlDoc().documentElement.getAttribute(L"text");
         str = xitem.documentElement().getAttribute(L"text");
         if (str == L"false")
         {
            alert(L"商品信息保存失败!");
@@ -602,18 +602,18 @@
      }
      dw_source.AcceptText();
      xml x;
      x.setNativePointer(x.CreateInstance());
      dw_source.DwUpdateAllToEx(x.GetXmlDoc());
      dw_source.DwUpdateAllToEx(x);
      xaserverarg arg2 = GDNView::MakeArg();
      arg2.AddArg(L"content", x.GetXml());
      arg2.AddArg(L"content", x.xml());
      if (url::get(L"/sale/data/Gdn/update/sourceex", arg2.GetString(), x) != 1)
      if (xurl::get(L"/sale/data/Gdn/update/sourceex", arg2.GetString(), x) != 1)
      {
         xstring error3 = x.GetXmlDoc().text;
         xstring error3 = x.text();
      }
      else
      {
         str = x.GetXmlDoc().documentElement.getAttribute(L"text");
         str = x.documentElement().getAttribute(L"text");
         if (str == L"false")
         {
            alert(L"货源信息保存失败!");
@@ -630,19 +630,19 @@
            dw_custom.SetItemString(k, L"LineNo", k.toString());
         }
      }
      xml xcustom = new xml;
      xcustom.setNativePointer(xcustom.CreateInstance());
      dw_custom.DwUpdateAllToEx(xcustom.GetXmlDoc());
      if (xcustom.GetXml() != L"")
      xml xcustom;
      dw_custom.DwUpdateAllToEx(xcustom);
      if (xcustom.xml() != L"")
      {
         xcustom = CustomView::UpdateCustomItem(dw_base.GetItemString(1, L"InvoiceNo"), xcustom.GetXml());
         xcustom = CustomView::UpdateCustomItem(dw_base.GetItemString(1, L"InvoiceNo"), xcustom.xml());
         if (!xcustom)
         {
            xstring error5 = xcustom.GetXmlDoc().text;
            xstring error5 = xcustom.text();
         }
         else
         {
            str = xcustom.GetXmlDoc().documentElement.getAttribute(L"text");
            str = xcustom.documentElement().getAttribute(L"text");
            if (str == L"false")
            {
               alert(L"报关信息保存失败!");
@@ -654,18 +654,18 @@
      if (dw_invoiceItem.GetRowCount() > 0)
      {
         dw_invoiceItem.AcceptText();
         xml x1 = new xml;
         x1.setNativePointer(x1.CreateInstance());
         dw_invoiceItem.DwUpdateAllToEx(x1.GetXmlDoc());
         xml x1 ;
         dw_invoiceItem.DwUpdateAllToEx(x1);
         xaserverarg arg4 = GDNView::MakeArg();
         arg4.AddArg(L"content", x1.GetXml());
         if (url::get(L"/sale/data/Gdn/update/itemex", arg4.GetString(), x1) != 1)
         arg4.AddArg(L"content", x1.xml());
         if (xurl::get(L"/sale/data/Gdn/update/itemex", arg4.GetString(), x1) != 1)
            if (!x1)
            {
               alert(L"议付信息保存失败!");
               return -1;
            }
         str = x1.GetXmlDoc().documentElement.getAttribute(L"text");
         str = x1.documentElement().getAttribute(L"text");
         if (str == L"false")
         {
            alert(L"议付信息保存失败!");
@@ -674,19 +674,19 @@
         dw_invoiceItem.ResetUpdateStatus();
      }
      dw_fcl.AcceptText();
      xml xfcl = new xml;
      xfcl.setNativePointer(xfcl.CreateInstance());
      dw_fcl.DwUpdateAllToEx(xfcl.GetXmlDoc());
      xml xfcl ;
      dw_fcl.DwUpdateAllToEx(xfcl);
      xaserverarg arg8 = GDNView::MakeArg();
      arg8.AddArg(L"content", xfcl.GetXml());
      arg8.AddArg(L"content", xfcl.xml());
      if (url::get(L"/sale/data/Gdn/update/container", arg8.GetString(), xfcl) != 1)
      if (xurl::get(L"/sale/data/Gdn/update/container", arg8.GetString(), xfcl) != 1)
      {
         xstring error8 = xfcl.GetXmlDoc().text;
         xstring error8 = xfcl.text();
      }
      else
      {
         str = xfcl.GetXmlDoc().documentElement.getAttribute(L"text");
         str = xfcl.documentElement().getAttribute(L"text");
         if (str == L"false")
         {
            alert(L"分箱信息保存失败!");
@@ -695,22 +695,22 @@
         dw_fcl.ResetUpdateStatus();
      }
      dw_cdelement.AcceptText();
      xml xcdelement = new xml;
      xcdelement.setNativePointer(xcdelement.CreateInstance());
      dw_cdelement.DwUpdateAllToEx(xcdelement.GetXmlDoc());
      if (xcdelement.GetXml() != L"")
      xml xcdelement ;
      dw_cdelement.DwUpdateAllToEx(xcdelement);
      if (xcdelement.xml() != L"")
      {
         xcdelement = CustomView::UpdateCustomElement(dw_base.GetItemString(1, L"InvoiceNo"), xcdelement.GetXml());
         if (!xcdelement)
         {
            xstring error6 = xcdelement.GetXmlDoc().text;
            xstring error6 = xcdelement.text();
            alert(L"err:" + error6);
            alert(L"申报要素信息保存失败!");
            //return -1;
         }
         else
         {
            str = xcdelement.GetXmlDoc().documentElement.getAttribute(L"text");
            str = xcdelement.documentElement().getAttribute(L"text");
            if (str == L"false")
            {
               alert(L"申报要素信息保存失败!");
@@ -744,7 +744,7 @@
         classfyid = dw_item.GetItemString(i, L"ClassifyID");
         if (dw_custom.LookUpRow(L"ClassifyID", classfyid) == 0)
         {
            alert(L"出货商品第" + i.toString() + L"行海关代码[" +
            alert(L"出货商品第" + xstring(i) + L"行海关代码[" +
               dw_item.GetItemDisplayString(i, L"ClassifyID") + L"]与报关商品不一致");
            return false;
         }
@@ -756,14 +756,14 @@
         classfyid = dw_custom.GetItemString(i, L"ClassifyID");
         if (dw_item.LookUpRow(L"ClassifyID", classfyid) == 0)
         {
            alert(L"报关商品第" + i.toString() + L"行海关代码[" +
            alert(L"报关商品第" + xstring(i) + L"行海关代码[" +
               dw_item.GetItemDisplayString(i, L"ClassifyID") + L"]与出货商品不一致");
            return false;
         }
         xml xx3 = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNClassifyID", L"InvoiceNo", classfyid);
         trace(classfyid);
         xstring Results3 = xx3.GetXmlDoc().text;
         xstring Results3 = xx3.text();
         if (Results3 != L"")
         {
            alert(Results3);
@@ -790,12 +790,12 @@
      if(No != L"")
      {
         xml x = ViewObject::RetrieveData(L"/sale/data/GDN/GDNClassifyID",L"InvoiceNo", No);
         if(x.GetXmlDoc().selectSingleNode(L"data/item/ClassifyID"))
         if(x.GetXmlDoc().selectSingleNode(L"data/item/CDquantity"))
         if(x.selectSingleNode(L"data/item/ClassifyID"))
         if(x.selectSingleNode(L"data/item/CDquantity"))
         xstring ClassifyIDOne=L"";
         xstring CDquantityOne=L"";
         ClassifyIDOne = x.GetXmlDoc().selectSingleNode(L"data/item/ClassifyID").text;
         CDquantityOne= x.GetXmlDoc().selectSingleNode(L"data/item/CDquantity").text;
         ClassifyIDOne = x.selectSingleNode(L"data/item/ClassifyID").text();
         CDquantityOne= x.selectSingleNode(L"data/item/CDquantity").text();
         double CDquantityTwo=CDquantityOne.toInt();
      }
      double ttl=0.0;
@@ -835,13 +835,13 @@
      {
         double GW = dw_custom.GetItemDouble(k, L"GW");
         double NW = dw_custom.GetItemDouble(k, L"NW");
         GWS += (GW).round(2);
         NWS += (NW).round(2);
         GWS += xdouble(GW).round(2);
         NWS += xdouble(NW).round(2);
   }
      double GW1 = dw_base.GetItemDouble(1, L"GW");
      double NW1 = dw_base.GetItemDouble(1, L"NW");
      if ((NWS).round(2) != (NW1).round(2) || (GWS).round(2) != (GW1).round(2))
      if (xdouble(NWS).round(2) != xdouble(NW1).round(2) || xdouble(GWS).round(2) != xdouble(GW1).round(2))
      {
         alert(L"毛重总量或净总重量不一致,需要核对!");
         return 0;
@@ -882,7 +882,7 @@
                  NWS += NW;
               }
               trace(L"*****" + NWS.toString() + L"*****" + LegalQty.toString() + L"*****");
               trace(L"*****" + xstring(NWS) + L"*****" + xstring(LegalQty) + L"*****");
               NWS = NWS - LegalQty;
               if (NWS < 0.0) NWS = 0.0 - NWS;
@@ -999,62 +999,62 @@
      if (clear) ClearSourcingItem(nRow);
      double ExchangeCostEx = dw_profit.GetItemDouble(1, L"ExchangeCostEx");
      xml x = xml::Make();
      x.LoadXml(L"<data/>");
      x.loadXML(L"<data/>");
      KXMLDOMElement e = dw_item.GetRowElement(nRow);
      KXMLDOMNode n = e.cloneNode(-1);
      x.GetXmlDoc().documentElement.appendChild(n);
      x.documentElement().appendChild(n);
      n.Release();
      xstring val = x.GetXml();
      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)
      {
         KXMLDOMNodeList items = source.GetXmlDoc().selectNodes(L"data/Item");
         KXMLDOMNodeList items = source.selectNodes(L"data/Item");
         //trace(L"=======L"+source.GetXml()+L"=======L"); 
         int len = items.length;
         int len = items.length();
         int row = 0;
         for (int i = 0; i < len; i++)
         {
            row = dw_source.InsertRow(0);
            KXMLDOMNode t = items.item(i);
            //dw_source.SetItemDouble(row,L"Swapthecost",ExchangeCostEx);
            if (t.selectSingleNode(L"PONo"))dw_source.SetItemString(row, L"PONo", t.selectSingleNode(L"PONo").text);
            if (t.selectSingleNode(L"POItemID"))dw_source.SetItemString(row, L"POItemID", t.selectSingleNode(L"POItemID").text);
            if (t.selectSingleNode(L"SOLineID"))dw_source.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text);
            if (t.selectSingleNode(L"GDNLineID"))dw_source.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text);
            if (t.selectSingleNode(L"PONo"))dw_source.SetItemString(row, L"PONo", t.selectSingleNode(L"PONo").text());
            if (t.selectSingleNode(L"POItemID"))dw_source.SetItemString(row, L"POItemID", t.selectSingleNode(L"POItemID").text());
            if (t.selectSingleNode(L"SOLineID"))dw_source.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text());
            if (t.selectSingleNode(L"GDNLineID"))dw_source.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text());
            if (t.selectSingleNode(L"GDNID"))dw_source.SetItemString(row, L"GDNID", t.selectSingleNode(L"GDNID").text);
            if (t.selectSingleNode(L"GDNID"))dw_source.SetItemString(row, L"GDNID", t.selectSingleNode(L"GDNID").text());
            if (t.selectSingleNode(L"GoodsNo"))dw_source.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text);
            if (t.selectSingleNode(L"GDNQuantity"))dw_source.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"GDNQuantity").text);
            if (t.selectSingleNode(L"BuyQuantity"))dw_source.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"BuyQuantity").text);
            if (t.selectSingleNode(L"CName"))dw_source.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text);
            if (t.selectSingleNode(L"CustomerItemNo"))dw_source.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text);
            if (t.selectSingleNode(L"BOMPart"))dw_source.SetItemString(row, L"BOMPart", t.selectSingleNode(L"BOMPart").text);
            if (t.selectSingleNode(L"ItemID"))dw_source.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text);
            if (t.selectSingleNode(L"BuyUnitPrice"))dw_source.SetItemString(row, L"BuyUnitPrice", t.selectSingleNode(L"BuyUnitPrice").text);
            if (t.selectSingleNode(L"BuyAmount"))dw_source.SetItemString(row, L"BuyAmount", t.selectSingleNode(L"BuyAmount").text);
            if (t.selectSingleNode(L"SupplierID"))dw_source.SetItemString(row, L"SupplierID", t.selectSingleNode(L"SupplierID").text);
            if (t.selectSingleNode(L"SupplierID/@_displaystring"))dw_source.SetItemDisplayString(row, L"SupplierID", t.selectSingleNode(L"SupplierID/@_displaystring").text);
            if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text);
            if (t.selectSingleNode(L"GoodsNo"))dw_source.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text());
            if (t.selectSingleNode(L"GDNQuantity"))dw_source.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"GDNQuantity").text());
            if (t.selectSingleNode(L"BuyQuantity"))dw_source.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"BuyQuantity").text());
            if (t.selectSingleNode(L"CName"))dw_source.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text());
            if (t.selectSingleNode(L"CustomerItemNo"))dw_source.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text());
            if (t.selectSingleNode(L"BOMPart"))dw_source.SetItemString(row, L"BOMPart", t.selectSingleNode(L"BOMPart").text());
            if (t.selectSingleNode(L"ItemID"))dw_source.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text());
            if (t.selectSingleNode(L"BuyUnitPrice"))dw_source.SetItemString(row, L"BuyUnitPrice", t.selectSingleNode(L"BuyUnitPrice").text());
            if (t.selectSingleNode(L"BuyAmount"))dw_source.SetItemString(row, L"BuyAmount", t.selectSingleNode(L"BuyAmount").text());
            if (t.selectSingleNode(L"SupplierID"))dw_source.SetItemString(row, L"SupplierID", t.selectSingleNode(L"SupplierID").text());
            if (t.selectSingleNode(L"SupplierID/@_displaystring"))dw_source.SetItemDisplayString(row, L"SupplierID", t.selectSingleNode(L"SupplierID/@_displaystring").text());
            if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text());
            //trace(L"\r\nHasVATInvoice:"+dw_source.GetItemDisplayString(row,L"HasVATInvoice"));
            if (dw_source.GetItemString(row, L"HasVATInvoice") == L"Y")
            {
               if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text);
               if (t.selectSingleNode(L"VATRefundRate"))dw_source.SetItemString(row, L"VATRefundRate", t.selectSingleNode(L"VATRefundRate").text);
               if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text());
               if (t.selectSingleNode(L"VATRefundRate"))dw_source.SetItemString(row, L"VATRefundRate", t.selectSingleNode(L"VATRefundRate").text());
            }
            if (t.selectSingleNode(L"Amount"))dw_source.SetItemString(row, L"Amount", t.selectSingleNode(L"Amount").text);
            if (t.selectSingleNode(L"POCreatorID"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID").text);
            if (t.selectSingleNode(L"POCreatorID/@_displaystring"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID/@_displaystring").text);
            if (t.selectSingleNode(L"Swapthecost"))dw_source.SetItemString(row, L"Swapthecost", t.selectSingleNode(L"Swapthecost").text);
            if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text);
            if (t.selectSingleNode(L"PurcharName"))dw_source.SetItemString(row, L"PurcharID", t.selectSingleNode(L"PurcharName").text);
            if (t.selectSingleNode(L"PurcharID"))dw_source.SetItemString(row, L"PurcharID", t.selectSingleNode(L"PurcharID").text);
            if (t.selectSingleNode(L"Amount"))dw_source.SetItemString(row, L"Amount", t.selectSingleNode(L"Amount").text());
            if (t.selectSingleNode(L"POCreatorID"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID").text());
            if (t.selectSingleNode(L"POCreatorID/@_displaystring"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID/@_displaystring").text());
            if (t.selectSingleNode(L"Swapthecost"))dw_source.SetItemString(row, L"Swapthecost", t.selectSingleNode(L"Swapthecost").text());
            if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text());
            if (t.selectSingleNode(L"PurcharName"))dw_source.SetItemString(row, L"PurcharID", t.selectSingleNode(L"PurcharName").text());
            if (t.selectSingleNode(L"PurcharID"))dw_source.SetItemString(row, L"PurcharID", t.selectSingleNode(L"PurcharID").text());
            if (t.selectSingleNode(L"PackUnitPrice"))dw_source.SetItemString(row, L"PackUnitPrice", t.selectSingleNode(L"PackUnitPrice").text);
            if (t.selectSingleNode(L"PackUnitPrice"))dw_source.SetItemString(row, L"PackUnitPrice", t.selectSingleNode(L"PackUnitPrice").text());
         }
@@ -1078,63 +1078,63 @@
      if (clear) ClearSourcingItem(nRow);
      double ExchangeCostEx = dw_profit.GetItemDouble(1, L"ExchangeCostEx");
      xml x = xml::Make();
      x.LoadXml(L"<data/>");
      x.loadXML(L"<data/>");
      KXMLDOMElement e = dw_item.GetRowElement(nRow);
      KXMLDOMNode n = e.cloneNode(-1);
      x.GetXmlDoc().documentElement.appendChild(n);
      x.documentElement().appendChild(n);
      n.Release();
      xstring val = x.GetXml();
      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)
      {
         KXMLDOMNodeList items = source.GetXmlDoc().selectNodes(L"data/Item");
         int len = items.length;
         KXMLDOMNodeList items = source.selectNodes(L"data/Item");
         int len = items.length();
         int row = 0;
         for (int i = 0; i < len; i++)
         {
            row = dw_source.InsertRow(0);
            KXMLDOMNode t = items.item(i);
            //dw_source.SetItemDouble(row,L"Swapthecost",ExchangeCostEx);
            if (t.selectSingleNode(L"PONo"))dw_source.SetItemString(row, L"PONo", t.selectSingleNode(L"PONo").text);
            if (t.selectSingleNode(L"POItemID"))dw_source.SetItemString(row, L"POItemID", t.selectSingleNode(L"POItemID").text);
            if (t.selectSingleNode(L"SOLineID"))dw_source.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text);
            if (t.selectSingleNode(L"GDNLineID"))dw_source.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text);
            if (t.selectSingleNode(L"PONo"))dw_source.SetItemString(row, L"PONo", t.selectSingleNode(L"PONo").text());
            if (t.selectSingleNode(L"POItemID"))dw_source.SetItemString(row, L"POItemID", t.selectSingleNode(L"POItemID").text());
            if (t.selectSingleNode(L"SOLineID"))dw_source.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text());
            if (t.selectSingleNode(L"GDNLineID"))dw_source.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text());
            if (t.selectSingleNode(L"GDNID"))dw_source.SetItemString(row, L"GDNID", t.selectSingleNode(L"GDNID").text);
            if (t.selectSingleNode(L"GDNID"))dw_source.SetItemString(row, L"GDNID", t.selectSingleNode(L"GDNID").text());
            if (t.selectSingleNode(L"GoodsNo"))dw_source.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text);
            if (t.selectSingleNode(L"GDNQuantity"))dw_source.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"GDNQuantity").text);
            if (t.selectSingleNode(L"BuyQuantity"))dw_source.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"BuyQuantity").text);
            if (t.selectSingleNode(L"CName"))dw_source.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text);
            if (t.selectSingleNode(L"CustomerItemNo"))dw_source.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text);
            if (t.selectSingleNode(L"BOMPart"))dw_source.SetItemString(row, L"BOMPart", t.selectSingleNode(L"BOMPart").text);
            if (t.selectSingleNode(L"ItemID"))dw_source.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text);
            if (t.selectSingleNode(L"BuyUnitPrice"))dw_source.SetItemString(row, L"BuyUnitPrice", t.selectSingleNode(L"BuyUnitPrice").text);
            if (t.selectSingleNode(L"BuyAmount"))dw_source.SetItemString(row, L"BuyAmount", t.selectSingleNode(L"BuyAmount").text);
            if (t.selectSingleNode(L"SupplierID"))dw_source.SetItemString(row, L"SupplierID", t.selectSingleNode(L"SupplierID").text);
            if (t.selectSingleNode(L"SupplierID/@_displaystring"))dw_source.SetItemDisplayString(row, L"SupplierID", t.selectSingleNode(L"SupplierID/@_displaystring").text);
            if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemDisplayString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text);
            if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text);
            //   if(t.selectSingleNode(L"HSCode"))dw_source.SetItemString(row,L"HSCode",t.selectSingleNode(L"HSCode").text);
            if (t.selectSingleNode(L"GoodsNo"))dw_source.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text());
            if (t.selectSingleNode(L"GDNQuantity"))dw_source.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"GDNQuantity").text());
            if (t.selectSingleNode(L"BuyQuantity"))dw_source.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"BuyQuantity").text());
            if (t.selectSingleNode(L"CName"))dw_source.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text());
            if (t.selectSingleNode(L"CustomerItemNo"))dw_source.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text());
            if (t.selectSingleNode(L"BOMPart"))dw_source.SetItemString(row, L"BOMPart", t.selectSingleNode(L"BOMPart").text());
            if (t.selectSingleNode(L"ItemID"))dw_source.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text());
            if (t.selectSingleNode(L"BuyUnitPrice"))dw_source.SetItemString(row, L"BuyUnitPrice", t.selectSingleNode(L"BuyUnitPrice").text());
            if (t.selectSingleNode(L"BuyAmount"))dw_source.SetItemString(row, L"BuyAmount", t.selectSingleNode(L"BuyAmount").text());
            if (t.selectSingleNode(L"SupplierID"))dw_source.SetItemString(row, L"SupplierID", t.selectSingleNode(L"SupplierID").text());
            if (t.selectSingleNode(L"SupplierID/@_displaystring"))dw_source.SetItemDisplayString(row, L"SupplierID", t.selectSingleNode(L"SupplierID/@_displaystring").text());
            if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemDisplayString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text());
            if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text());
            //   if(t.selectSingleNode(L"HSCode"))dw_source.SetItemString(row,L"HSCode",t.selectSingleNode(L"HSCode").text());
            if (dw_source.GetItemString(row, L"HasVATInvoice") == L"Y")
            {
               if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text);
               if (t.selectSingleNode(L"VATRefundRate"))dw_source.SetItemString(row, L"VATRefundRate", t.selectSingleNode(L"VATRefundRate").text);
               if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text());
               if (t.selectSingleNode(L"VATRefundRate"))dw_source.SetItemString(row, L"VATRefundRate", t.selectSingleNode(L"VATRefundRate").text());
            }
            if (t.selectSingleNode(L"Amount"))dw_source.SetItemString(row, L"Amount", t.selectSingleNode(L"Amount").text);
            if (t.selectSingleNode(L"POCreatorID"))dw_source.SetItemString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID").text);
            if (t.selectSingleNode(L"POCreatorID/@_displaystring"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID/@_displaystring").text);
            if (t.selectSingleNode(L"Swapthecost"))dw_source.SetItemString(row, L"Swapthecost", t.selectSingleNode(L"Swapthecost").text);
            if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text);
            if (t.selectSingleNode(L"PurcharName"))dw_source.SetItemDisplayString(row, L"PurcharID", t.selectSingleNode(L"PurcharName").text);
            if (t.selectSingleNode(L"PurcharID"))dw_source.SetItemString(row, L"PurcharID", t.selectSingleNode(L"PurcharID").text);
            if (t.selectSingleNode(L"Amount"))dw_source.SetItemString(row, L"Amount", t.selectSingleNode(L"Amount").text());
            if (t.selectSingleNode(L"POCreatorID"))dw_source.SetItemString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID").text());
            if (t.selectSingleNode(L"POCreatorID/@_displaystring"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID/@_displaystring").text());
            if (t.selectSingleNode(L"Swapthecost"))dw_source.SetItemString(row, L"Swapthecost", t.selectSingleNode(L"Swapthecost").text());
            if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text());
            if (t.selectSingleNode(L"PurcharName"))dw_source.SetItemDisplayString(row, L"PurcharID", t.selectSingleNode(L"PurcharName").text());
            if (t.selectSingleNode(L"PurcharID"))dw_source.SetItemString(row, L"PurcharID", t.selectSingleNode(L"PurcharID").text());
            if (t.selectSingleNode(L"PackUnitPrice"))dw_source.SetItemString(row, L"PackUnitPrice", t.selectSingleNode(L"PackUnitPrice").text);
            if (t.selectSingleNode(L"PackUnitPrice"))dw_source.SetItemString(row, L"PackUnitPrice", t.selectSingleNode(L"PackUnitPrice").text());
         }
         PoTotal(nRow);
@@ -1156,57 +1156,57 @@
      while (dw_source.GetRowCount() > 0) dw_source.DeleteRow(1);
      dw_item.AcceptText();
      xml xitem = new xml;
      xitem.setNativePointer(xml::CreateInstance());
      KXMLDOMDocument xitemdoc = xitem.GetXmlDoc();
      xml xitem ;
      KXMLDOMDocument xitemdoc = xitem;
      dw_item.DwUpdateAllToEx(xitemdoc);
      trace(L"****" + xitem.GetXml() + L"****");
      xml x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/gdn/sourcing/refreshitemexOne", L"content", xitem.GetXml());
      trace(x.GetXml());
      trace(x.xml());
      if (x)
      {
         KXMLDOMNodeList items = x.GetXmlDoc().selectNodes(L"data/Item");
         int len = items.length;
         KXMLDOMNodeList items = x.selectNodes(L"data/Item");
         int len = items.length();
         int row = 0;
         for (int i = 0; i < len; i++)
         {
            row = dw_source.InsertRow(0);
            KXMLDOMNode t = items.item(i);
            if (t.selectSingleNode(L"PONo"))dw_source.SetItemString(row, L"PONo", t.selectSingleNode(L"PONo").text);
            if (t.selectSingleNode(L"POItemID"))dw_source.SetItemString(row, L"POItemID", t.selectSingleNode(L"POItemID").text);
            if (t.selectSingleNode(L"SOLineID"))dw_source.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text);
            if (t.selectSingleNode(L"GDNLineID"))dw_source.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text);
            if (t.selectSingleNode(L"PONo"))dw_source.SetItemString(row, L"PONo", t.selectSingleNode(L"PONo").text());
            if (t.selectSingleNode(L"POItemID"))dw_source.SetItemString(row, L"POItemID", t.selectSingleNode(L"POItemID").text());
            if (t.selectSingleNode(L"SOLineID"))dw_source.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text());
            if (t.selectSingleNode(L"GDNLineID"))dw_source.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text());
            if (t.selectSingleNode(L"GDNID"))dw_source.SetItemString(row, L"GDNID", t.selectSingleNode(L"GDNID").text);
            if (t.selectSingleNode(L"GDNID"))dw_source.SetItemString(row, L"GDNID", t.selectSingleNode(L"GDNID").text());
            if (t.selectSingleNode(L"GoodsNo"))dw_source.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text);
            if (t.selectSingleNode(L"GDNQuantity"))dw_source.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"GDNQuantity").text);
            if (t.selectSingleNode(L"BuyQuantity"))dw_source.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"BuyQuantity").text);
            if (t.selectSingleNode(L"CName"))dw_source.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text);
            if (t.selectSingleNode(L"CustomerItemNo"))dw_source.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text);
            if (t.selectSingleNode(L"BOMPart"))dw_source.SetItemString(row, L"BOMPart", t.selectSingleNode(L"BOMPart").text);
            if (t.selectSingleNode(L"ItemID"))dw_source.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text);
            if (t.selectSingleNode(L"BuyUnitPrice"))dw_source.SetItemString(row, L"BuyUnitPrice", t.selectSingleNode(L"BuyUnitPrice").text);
            if (t.selectSingleNode(L"GoodsNo"))dw_source.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text());
            if (t.selectSingleNode(L"GDNQuantity"))dw_source.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"GDNQuantity").text());
            if (t.selectSingleNode(L"BuyQuantity"))dw_source.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"BuyQuantity").text());
            if (t.selectSingleNode(L"CName"))dw_source.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text());
            if (t.selectSingleNode(L"CustomerItemNo"))dw_source.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text());
            if (t.selectSingleNode(L"BOMPart"))dw_source.SetItemString(row, L"BOMPart", t.selectSingleNode(L"BOMPart").text());
            if (t.selectSingleNode(L"ItemID"))dw_source.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text());
            if (t.selectSingleNode(L"BuyUnitPrice"))dw_source.SetItemString(row, L"BuyUnitPrice", t.selectSingleNode(L"BuyUnitPrice").text());
            if (t.selectSingleNode(L"BuyAmount"))dw_source.SetItemString(row, L"BuyAmount", t.selectSingleNode(L"BuyAmount").text);
            if (t.selectSingleNode(L"BuyAmount"))dw_source.SetItemString(row, L"BuyAmount", t.selectSingleNode(L"BuyAmount").text());
            if (t.selectSingleNode(L"SupplierID"))dw_source.SetItemString(row, L"SupplierID", t.selectSingleNode(L"SupplierID").text);
            if (t.selectSingleNode(L"SupplierID/@_displaystring"))dw_source.SetItemDisplayString(row, L"SupplierID", t.selectSingleNode(L"SupplierID/@_displaystring").text);
            if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemDisplayString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text);
            if (t.selectSingleNode(L"Amount"))dw_source.SetItemDisplayString(row, L"Amount", t.selectSingleNode(L"Amount").text);
            if (t.selectSingleNode(L"POCreatorID"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID").text);
            if (t.selectSingleNode(L"POCreatorID/@_displaystring"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID/@_displaystring").text);
            if (t.selectSingleNode(L"Swapthecost"))dw_source.SetItemDisplayString(row, L"Swapthecost", t.selectSingleNode(L"Swapthecost").text);
            if (t.selectSingleNode(L"PurcharName"))dw_source.SetItemDisplayString(row, L"PurcharID", t.selectSingleNode(L"PurcharName").text);
            if (t.selectSingleNode(L"PurcharID"))dw_source.SetItemString(row, L"PurcharID", t.selectSingleNode(L"PurcharID").text);
            if (t.selectSingleNode(L"PackUnitPrice"))dw_source.SetItemString(row, L"PackUnitPrice", t.selectSingleNode(L"PackUnitPrice").text);
            //   if(t.selectSingleNode(L"HSCode"))dw_source.SetItemString(row,L"HSCode",t.selectSingleNode(L"HSCode").text);
            if (t.selectSingleNode(L"SupplierID"))dw_source.SetItemString(row, L"SupplierID", t.selectSingleNode(L"SupplierID").text());
            if (t.selectSingleNode(L"SupplierID/@_displaystring"))dw_source.SetItemDisplayString(row, L"SupplierID", t.selectSingleNode(L"SupplierID/@_displaystring").text());
            if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemDisplayString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text());
            if (t.selectSingleNode(L"Amount"))dw_source.SetItemDisplayString(row, L"Amount", t.selectSingleNode(L"Amount").text());
            if (t.selectSingleNode(L"POCreatorID"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID").text());
            if (t.selectSingleNode(L"POCreatorID/@_displaystring"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID/@_displaystring").text());
            if (t.selectSingleNode(L"Swapthecost"))dw_source.SetItemDisplayString(row, L"Swapthecost", t.selectSingleNode(L"Swapthecost").text());
            if (t.selectSingleNode(L"PurcharName"))dw_source.SetItemDisplayString(row, L"PurcharID", t.selectSingleNode(L"PurcharName").text());
            if (t.selectSingleNode(L"PurcharID"))dw_source.SetItemString(row, L"PurcharID", t.selectSingleNode(L"PurcharID").text());
            if (t.selectSingleNode(L"PackUnitPrice"))dw_source.SetItemString(row, L"PackUnitPrice", t.selectSingleNode(L"PackUnitPrice").text());
            //   if(t.selectSingleNode(L"HSCode"))dw_source.SetItemString(row,L"HSCode",t.selectSingleNode(L"HSCode").text());
            if (dw_source.GetItemDisplayString(row, L"HasVATInvoice") == L"Y")
            {
               if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text);
               if (t.selectSingleNode(L"VATRefundRate"))dw_source.SetItemString(row, L"VATRefundRate", t.selectSingleNode(L"VATRefundRate").text);
               if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text());
               if (t.selectSingleNode(L"VATRefundRate"))dw_source.SetItemString(row, L"VATRefundRate", t.selectSingleNode(L"VATRefundRate").text());
            }
         }
         evalPurcharCost();
@@ -1235,42 +1235,42 @@
         xml x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/gdn/sourcing/refreshitem", L"InvoiceNo", No, L"GDNLineID", gdnLineID);
         if (x)
         {
            KXMLDOMNodeList items = x.GetXmlDoc().selectNodes(L"data/Item");
            int len = items.length;
            KXMLDOMNodeList items = x.selectNodes(L"data/Item");
            int len = items.length();
            int row = 0;
            for (int i = 0; i < len; i++)
            {
               row = dw_source.InsertRow(0);
               KXMLDOMNode t = items.item(i);
               if (t.selectSingleNode(L"PONo"))dw_source.SetItemString(row, L"PONo", t.selectSingleNode(L"PONo").text);
               if (t.selectSingleNode(L"POItemID"))dw_source.SetItemString(row, L"POItemID", t.selectSingleNode(L"POItemID").text);
               if (t.selectSingleNode(L"SOLineID"))dw_source.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text);
               if (t.selectSingleNode(L"GDNLineID"))dw_source.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text);
               if (t.selectSingleNode(L"PONo"))dw_source.SetItemString(row, L"PONo", t.selectSingleNode(L"PONo").text());
               if (t.selectSingleNode(L"POItemID"))dw_source.SetItemString(row, L"POItemID", t.selectSingleNode(L"POItemID").text());
               if (t.selectSingleNode(L"SOLineID"))dw_source.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text());
               if (t.selectSingleNode(L"GDNLineID"))dw_source.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text());
               if (t.selectSingleNode(L"GDNID"))dw_source.SetItemString(row, L"GDNID", t.selectSingleNode(L"GDNID").text);
               if (t.selectSingleNode(L"GDNID"))dw_source.SetItemString(row, L"GDNID", t.selectSingleNode(L"GDNID").text());
               if (t.selectSingleNode(L"GoodsNo"))dw_source.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text);
               if (t.selectSingleNode(L"GDNQuantity"))dw_source.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"GDNQuantity").text);
               if (t.selectSingleNode(L"BuyQuantity"))dw_source.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"BuyQuantity").text);
               if (t.selectSingleNode(L"CName"))dw_source.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text);
               if (t.selectSingleNode(L"CustomerItemNo"))dw_source.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text);
               if (t.selectSingleNode(L"BOMPart"))dw_source.SetItemString(row, L"BOMPart", t.selectSingleNode(L"BOMPart").text);
               if (t.selectSingleNode(L"ItemID"))dw_source.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text);
               if (t.selectSingleNode(L"BuyUnitPrice"))dw_source.SetItemString(row, L"BuyUnitPrice", t.selectSingleNode(L"BuyUnitPrice").text);
               if (t.selectSingleNode(L"BuyAmount"))dw_source.SetItemString(row, L"BuyAmount", t.selectSingleNode(L"BuyAmount").text);
               if (t.selectSingleNode(L"SupplierID"))dw_source.SetItemString(row, L"SupplierID", t.selectSingleNode(L"SupplierID").text);
               if (t.selectSingleNode(L"SupplierID/@_displaystring"))dw_source.SetItemDisplayString(row, L"SupplierID", t.selectSingleNode(L"SupplierID/@_displaystring").text);
               if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemDisplayString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text);
               if (t.selectSingleNode(L"GoodsNo"))dw_source.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text());
               if (t.selectSingleNode(L"GDNQuantity"))dw_source.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"GDNQuantity").text());
               if (t.selectSingleNode(L"BuyQuantity"))dw_source.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"BuyQuantity").text());
               if (t.selectSingleNode(L"CName"))dw_source.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text());
               if (t.selectSingleNode(L"CustomerItemNo"))dw_source.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text());
               if (t.selectSingleNode(L"BOMPart"))dw_source.SetItemString(row, L"BOMPart", t.selectSingleNode(L"BOMPart").text());
               if (t.selectSingleNode(L"ItemID"))dw_source.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text());
               if (t.selectSingleNode(L"BuyUnitPrice"))dw_source.SetItemString(row, L"BuyUnitPrice", t.selectSingleNode(L"BuyUnitPrice").text());
               if (t.selectSingleNode(L"BuyAmount"))dw_source.SetItemString(row, L"BuyAmount", t.selectSingleNode(L"BuyAmount").text());
               if (t.selectSingleNode(L"SupplierID"))dw_source.SetItemString(row, L"SupplierID", t.selectSingleNode(L"SupplierID").text());
               if (t.selectSingleNode(L"SupplierID/@_displaystring"))dw_source.SetItemDisplayString(row, L"SupplierID", t.selectSingleNode(L"SupplierID/@_displaystring").text());
               if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemDisplayString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text());
               if (dw_source.GetItemDisplayString(row, L"HasVATInvoice") == L"Y")
               {
                  if (t.selectSingleNode(L"VATRefundRate"))dw_source.SetItemString(row, L"VATRefundRate", t.selectSingleNode(L"VATRefundRate").text);
                  if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text);
                  if (t.selectSingleNode(L"VATRefundRate"))dw_source.SetItemString(row, L"VATRefundRate", t.selectSingleNode(L"VATRefundRate").text());
                  if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text());
               }
               if (t.selectSingleNode(L"Amount"))dw_source.SetItemDisplayString(row, L"Amount", t.selectSingleNode(L"Amount").text);
               if (t.selectSingleNode(L"POCreatorID"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID").text);
               if (t.selectSingleNode(L"POCreatorID/@_displaystring"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID/@_displaystring").text);
               if (t.selectSingleNode(L"Swapthecost"))dw_source.SetItemDisplayString(row, L"Swapthecost", t.selectSingleNode(L"Swapthecost").text);
               if (t.selectSingleNode(L"Amount"))dw_source.SetItemDisplayString(row, L"Amount", t.selectSingleNode(L"Amount").text());
               if (t.selectSingleNode(L"POCreatorID"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID").text());
               if (t.selectSingleNode(L"POCreatorID/@_displaystring"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID/@_displaystring").text());
               if (t.selectSingleNode(L"Swapthecost"))dw_source.SetItemDisplayString(row, L"Swapthecost", t.selectSingleNode(L"Swapthecost").text());
            }
         }
         evalTotalCost();
@@ -1282,22 +1282,22 @@
   }
   //event
   int OnDWClick(ref TNotifyEvent evt, int p)
   int OnDWClick(TEvent* evt, int p)
   {
      ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR);
      xstring value = hdr.data;
      xstring colname = hdr.colname;
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      xstring value = hdr->data;
      xstring colname = hdr->colname;
      return 1;
   }
   int OnProfitItemChanged(ref TNotifyEvent evt, int p)
   int OnProfitItemChanged(TEvent* evt, int p)
   {
      int HCursor = xutil::SetCursorWait();
      ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
      int row = hdr.row;
      xstring col = hdr.colname;
      xstring data = hdr.data;
      HCURSOR HCursor = xutil::SetCursorWait();
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      int row = hdr->row;
      xstring col = hdr->colname;
      xstring data = hdr->data;
      if (col == L"DrawbackIntrest" ||
         col == L"DrawbackIntrest" ||
@@ -1327,13 +1327,13 @@
      return 1;
   }
   int OnCustomItemChanged(ref TNotifyEvent evt, int p)
   int OnCustomItemChanged(TEvent* evt, int p)
   {
      int HCursor = xutil::SetCursorWait();
      ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
      int row = hdr.row;
      xstring col = hdr.colname;
      xstring data = hdr.data;
      HCURSOR HCursor = xutil::SetCursorWait();
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      int row = hdr->row;
      xstring col = hdr->colname;
      xstring data = hdr->data;
      if (col == L"AdjustParam")
      {
         double rate = 1.0;
@@ -1377,14 +1377,13 @@
      return 1;
   }
   int OnBaseItemChanged(ref TNotifyEvent evt, int p)
   int OnBaseItemChanged(TEvent* evt, int p)
   {
      int HCursor = xutil::SetCursorWait();
      ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
      int row = hdr.row;
      xstring col = hdr.colname;
      xstring data = hdr.data;
      HCURSOR HCursor = xutil::SetCursorWait();
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      int row = hdr->row;
      xstring col = hdr->colname;
      xstring data = hdr->data;
      if (col == L"CustomerID")
      {
@@ -1441,11 +1440,11 @@
         xml supplier_x = ViewObject::RetrieveData(L"/sale/data/expense3/view/FindByOriginName", L"OriginName", s);
         if (supplier_x)
         {
            KXMLDOMNode o = supplier_x.GetXmlDoc().selectSingleNode(L"Item");
            xstring GoodsSource = o.selectSingleNode(L"OriginName").text;
            xstring OriginID = o.selectSingleNode(L"OriginID").text;
            KXMLDOMNode o = supplier_x.selectSingleNode(L"Item");
            xstring GoodsSource = o.selectSingleNode(L"OriginName").text();
            xstring OriginID = o.selectSingleNode(L"OriginID").text();
            xstring sname = OriginID + L" " + s;
            xstring name = o.selectSingleNode(L"name").text;
            xstring name = o.selectSingleNode(L"name").text();
            if (sname == name) {
               dw_base.SetItemDisplayString(1, L"GoodsSource", name);
               dw_base.SetItemString(1, L"GoodsSource", name);
@@ -1534,8 +1533,8 @@
         {
            trace(ETD);
            xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramEx", L"ETD", ETD);
            if (x.GetXmlDoc().selectSingleNode(L"root/item/@value"))
               exchangeRate = x.GetXmlDoc().selectSingleNode(L"root/item/@value").text;
            if (x.selectSingleNode(L"root/item/@value"))
               exchangeRate = x.selectSingleNode(L"root/item/@value").text();
            if (exchangeRate != L"")
            {
               dw_profit.SetItemString(1, L"ExchangeRate", exchangeRate);
@@ -1543,8 +1542,8 @@
            else
            {
               xml xp = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate");
               if (xp.GetXmlDoc().selectSingleNode(L"root/item/@value"))
                  exchangeRate = xp.GetXmlDoc().selectSingleNode(L"root/item/@value").text;
               if (xp.selectSingleNode(L"root/item/@value"))
                  exchangeRate = xp.selectSingleNode(L"root/item/@value").text();
               dw_profit.SetItemString(1, L"ExchangeRate", exchangeRate);
            }
@@ -1586,10 +1585,10 @@
      xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyinfo", L"ClassifyID", ClassifyID);
      if (x)
      {
         KXMLDOMNode o = x.GetXmlDoc().selectSingleNode(L"data/Item");
         KXMLDOMNode o = x.selectSingleNode(L"data/Item");
         if (o)
         {
            refundRate = o.selectSingleNode(L"VATRefundRate").text;
            refundRate = o.selectSingleNode(L"VATRefundRate").text();
         }
      }
      if (refundRate != L"*")
@@ -1627,7 +1626,7 @@
         if (d4 != 0.0)
         {
            double d5 = d3 / d4;
            d5 = d5.round(4);
            d5 = xdouble(d5).round(4);
            if (d3 <= 0.0 && d4 <= 0.0)
            {
               //trace(L"--------1111-----------");
@@ -1643,14 +1642,13 @@
      return 1;
   }
   int OnItemChanged(ref TNotifyEvent evt, int p)
   int OnItemChanged(TEvent* evt, int p)
   {
      //if(datareading) return 0;
      int HCursor = xutil::SetCursorWait();
      ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
      int row = hdr.row;
      xstring col = hdr.colname;
      xstring data = hdr.data;
      HCURSOR HCursor = xutil::SetCursorWait();
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      int row = hdr->row;
      xstring col = hdr->colname;
      xstring data = hdr->data;
      if (col == L"ClassifyID")
      {
@@ -1664,7 +1662,7 @@
         double dqty = dw_item.GetItemDouble(row, L"Quantity");
         xstring spackingrate = dw_item.GetItemString(row, L"PackingRate");
         int ipack = caclPacking(dqty, spackingrate);
         dw_item.ItemChangeTo(row, L"Packages", ipack.toString());
         dw_item.ItemChangeTo(row, L"Packages", xstring(ipack));
         if (col == L"Quantity")
         {
            if (!datareading)
@@ -1695,7 +1693,7 @@
         dw_item.SetItemDouble(row, L"VolumePerPkg", pv2);
         double ctns2 = dw_item.GetItemDouble(row, L"Packages");
         double svol2 = pv2 * ctns2;
         dw_item.SetItemDouble(row, L"Volume", svol2.round(2));
         dw_item.SetItemDouble(row, L"Volume", xdouble(svol2).round(2));
         dw_item.SetItemDouble(row, L"NW", nw);
         dw_item.SetItemDouble(row, L"GW", gw);
@@ -1753,14 +1751,14 @@
         double svol = pv * ctns;
         //trace(svol.toString() +L"******"+svol.round(2));
         dw_item.SetItemDouble(row, L"Volume", svol.round(2));
         dw_item.SetItemDouble(row, L"Volume", xdouble(svol).round(2));
         double Volumes = 0.0;
         for (int roww = 1; roww <= dw_item.GetRowCount(); ++roww)
         {
            double Volume = dw_item.GetItemDouble(roww, L"Volume");
            Volumes += Volume.round(2);
            Volumes += xdouble(Volume).round(2);
         }
         dw_base.SetItemDouble(1, L"Volume", Volumes.round(2));
         dw_base.SetItemDouble(1, L"Volume", xdouble(Volumes).round(2));
         dw_item.Redraw();
      }
      if (col == L"VolumePerPkg")
@@ -1778,7 +1776,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);
            calcTotal();
@@ -1801,6 +1799,7 @@
      double Amount_s = 0.0;
      double  Vol_s = 0.0;
      double  Vol_A = 2.0;
      double GDNItemAmount = 0.0;
      for (int row = 1; row <= dw_source.GetRowCount(); ++row)
      {
         for (int k = 1; k <= dw_item.GetRowCount(); ++k) {
@@ -1808,7 +1807,7 @@
            KXMLDOMElement  e = dw_item.GetRowElement(k);
            xstring GDNLineID = e.getAttribute(L"guid");
            double GDNSourceAmount = dw_source.GetItemDouble(row, L"BuyAmount");
            double GDNItemAmount = dw_item.GetItemDouble(k, L"Amount");
            GDNItemAmount = dw_item.GetItemDouble(k, L"Amount");
            xstring POGDNLineID = dw_source.GetItemString(row, L"GDNLineID");
            if (GDNLineID == POGDNLineID) {
               Amount_s += GDNSourceAmount;
@@ -1821,20 +1820,20 @@
      return 1;
   }
   int OnItemChangedEx(ref TNotifyEvent evt, int p)
   int OnItemChangedEx(TEvent* evt, int p)
   {
      ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR);
      xstring colname = hdr.colname;
      xstring value = hdr.data;
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      xstring colname = hdr->colname;
      xstring value = hdr->data;
      if (colname == L"VATRefundRate")
      {
         //double price1      = dw_source.GetItemDouble(hdr.row,L"BuyUnitPrice");
         //double quantity1 = dw_source.GetItemDouble(hdr.row,L"BuyQuantity");
         double amount1 = dw_source.GetItemDouble(hdr.row, L"BuyAmount");
         double VATRefundRate = dw_source.GetItemDouble(hdr.row, L"VATRefundRate");
         //dw_source.SetItemDouble(hdr.row,L"RefundAmount", price1 * quantity1 / 1.13 * VATRefundRate/100);
         dw_source.SetItemDouble(hdr.row, L"RefundAmount", amount1 / 1.13 * VATRefundRate / 100);
         //double price1      = dw_source.GetItemDouble(hdr->row,L"BuyUnitPrice");
         //double quantity1 = dw_source.GetItemDouble(hdr->row,L"BuyQuantity");
         double amount1 = dw_source.GetItemDouble(hdr->row, L"BuyAmount");
         double VATRefundRate = dw_source.GetItemDouble(hdr->row, L"VATRefundRate");
         //dw_source.SetItemDouble(hdr->row,L"RefundAmount", price1 * quantity1 / 1.13 * VATRefundRate/100);
         dw_source.SetItemDouble(hdr->row, L"RefundAmount", amount1 / 1.13 * VATRefundRate / 100);
         evalDrawbackEx();
         evalTotalCost();
         evalProfitAmountEx();
@@ -1842,19 +1841,19 @@
      if (colname == L"BuyUnitPrice" || colname == L"BuyQuantity" || colname == L"PackUnitPrice") //读取最近订单信息
      {
         double price = dw_source.GetItemDouble(hdr.row, L"BuyUnitPrice");
         double quantity = dw_source.GetItemDouble(hdr.row, L"BuyQuantity");
         double Amount = dw_source.GetItemDouble(hdr.row, L"Amount");
         double PackUnitPrice = dw_source.GetItemDouble(hdr.row, L"PackUnitPrice");
         dw_source.SetItemDouble(hdr.row, L"BuyAmount", price * quantity + PackUnitPrice);
         double price = dw_source.GetItemDouble(hdr->row, L"BuyUnitPrice");
         double quantity = dw_source.GetItemDouble(hdr->row, L"BuyQuantity");
         double Amount = dw_source.GetItemDouble(hdr->row, L"Amount");
         double PackUnitPrice = dw_source.GetItemDouble(hdr->row, L"PackUnitPrice");
         dw_source.SetItemDouble(hdr->row, L"BuyAmount", price * quantity + PackUnitPrice);
      }
      if (colname == L"BuyUnitPrice" || colname == L"BuyQuantity" || colname == L"PackUnitPrice" || colname == L"BuyAmount")
      {
         if (dw_source.GetItemString(hdr.row, L"VATRefundRate") != L"")
         if (dw_source.GetItemString(hdr->row, L"VATRefundRate") != L"")
         {
            double amount2 = dw_source.GetItemDouble(hdr.row, L"BuyAmount");
            double VATRefundRate2 = dw_source.GetItemDouble(hdr.row, L"VATRefundRate");
            dw_source.SetItemDouble(hdr.row, L"RefundAmount", amount2 / 1.13 * VATRefundRate2 / 100);
            double amount2 = dw_source.GetItemDouble(hdr->row, L"BuyAmount");
            double VATRefundRate2 = dw_source.GetItemDouble(hdr->row, L"VATRefundRate");
            dw_source.SetItemDouble(hdr->row, L"RefundAmount", amount2 / 1.13 * VATRefundRate2 / 100);
         }
         CalcProfit();
      }
@@ -1862,31 +1861,32 @@
   }
   int OnAskDataBase(ref TNotifyEvent evt, int p)
   int OnAskDataBase(TEvent* evt, int p)
   {
      ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR);
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      xstring x = hdr.colname;
      xstring x = hdr->colname;
      if (x == L"userSalespersonID")
      {
         xstring sSalespersonID = dw_base.GetItemString(1, L"SalespersonID");
         hdr.data = sSalespersonID;
         hdr->data = sSalespersonID;
      }
      return 1;
   }
   int OnBillNoteDoubleClicked(ref TNotifyEvent evt, int p)
   int OnBillNoteDoubleClicked(TEvent* evt, int p)
   {
      ref DWNMHDR  hdr = evt.pnmh;
      xstring colname = hdr.colname;
      int row = hdr.row;
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      xstring colname = hdr->colname;
      int row = hdr->row;
      if (colname == L"Content")
      {
         xaserverarg arg = new xaserverarg;
         arg.setNativePointer(arg.CreateInstance());
         xaserverarg arg ;
         xstring str = dw_billnote.GetItemString(row, colname);
         arg.AddArg(L"value", str);
         openUrl(L"/sale/view/view.dlg/xpage/memo/edit/new", arg.getNativePointer());
         openUrl(L"/sale/view/view.dlg/xpage/memo/edit/new", &arg);
         xstring comdid = arg.GetArgString(L"comdid");
         if (comdid == L"xmOK")
         {
@@ -1902,13 +1902,13 @@
   {
      CheckCDLine();
      CheckGW();
      xaserverarg arg = new xaserverarg;
      xaserverarg arg ;
      arg.setNativePointer(arg.CreateInstance());
      arg.AddArg(L"EntityName", L"GDN3", L"");
      arg.AddArg(L"EntityID", InvoiceID, L"");
      arg.AddArg(L"EntityNo", dw_base.GetItemString(1, L"InvoiceNo"), L"");
      int p = arg.ptr_native_;
      openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", p);
      openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", &arg);
      return 1;
   }
@@ -1924,7 +1924,7 @@
      for (int row = 1; row <= dw_item.GetRowCount(); ++row)
      {
         double Quantity = dw_item.GetItemDouble(row, L"Quantity");
         int Packages = dw_item.GetItemDouble(row, L"Packages").toInt();
         int Packages = (int)dw_item.GetItemDouble(row, L"Packages");
         double GW = dw_item.GetItemDouble(row, L"GW");
         double NW = dw_item.GetItemDouble(row, L"NW");
         double Amount = dw_item.GetItemDouble(row, L"Amount");
@@ -2098,17 +2098,17 @@
         val = dw_custom.GetItemDouble(i, L"Quantity");
         val += Quantity.round(3);
         val += xdouble(Quantity).round(3);
         double sqty = 0;
         sqty = val;
         dw_custom.SetItemDouble(i, L"Quantity", val);
         val = dw_custom.GetItemDouble(i, L"GW");
         val += GW.round(3);
         val += xdouble(GW).round(3);
         dw_custom.SetItemDouble(i, L"GW", val);
         val = dw_custom.GetItemDouble(i, L"NW");
         val += NW.round(3);
         val += xdouble(NW).round(3);
         dw_custom.SetItemDouble(i, L"NW", val);
         int nval = dw_custom.GetItemDouble(i, L"Packages");
@@ -2127,30 +2127,30 @@
         if (x)
         {
            KXMLDOMNode o = x.GetXmlDoc().selectSingleNode(L"data/Item");
            KXMLDOMNode o = x.selectSingleNode(L"data/Item");
            if (o)
            {
               if (o.selectSingleNode(L"VATRates"))
               {
                  xstring str1 = o.selectSingleNode(L"VATRates").text;
                  xstring str1 = o.selectSingleNode(L"VATRates").text();
                  if (str1.find(L",L") >= 0) str1 = str1.left(str1.find(L",L"));
                  dw_custom.SetItemString(i, L"VATRates", str1);
               }
               if (o.selectSingleNode(L"CustEName"))
               {
                  dw_custom.SetItemString(i, L"CustEName", o.selectSingleNode(L"CustEName").text);
                  dw_custom.SetItemString(i, L"CustEName", o.selectSingleNode(L"CustEName").text());
               }
               if (o.selectSingleNode(L"SupervisionRuler"))
               {
                  dw_custom.SetItemString(i, L"SupervisionRuler", o.selectSingleNode(L"SupervisionRuler").text);
                  dw_custom.SetItemString(i, L"SupervisionRuler", o.selectSingleNode(L"SupervisionRuler").text());
               }
               if (o.selectSingleNode(L"VATRefundRate"))
               {
                  dw_custom.SetItemString(i, L"VATRefundRate", o.selectSingleNode(L"VATRefundRate").text);
                  dw_custom.SetItemString(i, L"VATRefundRate", o.selectSingleNode(L"VATRefundRate").text());
               }
               if (o.selectSingleNode(L"HSCode"))
               {
                  xstring hscode = o.selectSingleNode(L"HSCode").text;
                  xstring hscode = o.selectSingleNode(L"HSCode").text();
                  if (dw_custom.GetItemString(i, L"CustName").find(L"[") >= 0)
                  {
                     xstring str = dw_custom.GetItemString(i, L"CustName");
@@ -2162,9 +2162,9 @@
               }
               if (o.selectSingleNode(L"UOM"))
               {
                  dw_custom.SetItemString(i, L"LegalUOMCode", o.selectSingleNode(L"UOM").text);
                  dw_customex.SetItemString(i, L"LegalUOMCode", o.selectSingleNode(L"UOM").text);
                  xstring uom = o.selectSingleNode(L"UOM").text;
                  dw_custom.SetItemString(i, L"LegalUOMCode", o.selectSingleNode(L"UOM").text());
                  dw_customex.SetItemString(i, L"LegalUOMCode", o.selectSingleNode(L"UOM").text());
                  xstring uom = o.selectSingleNode(L"UOM").text();
                  if (uom == L"千克")
                  {
                     dw_custom.SetItemString(i, L"LegalQty", dw_custom.GetItemString(i, L"NW"));
@@ -2180,30 +2180,30 @@
         xml x= ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyinfo",L"ClassifyID",ClassifyID);
         if(x)
         {
            KXMLDOMNode o = x.GetXmlDoc().selectSingleNode(L"data/Item");
            KXMLDOMNode o = x.selectSingleNode(L"data/Item");
            if(o)
            {
               if(o.selectSingleNode(L"VATRates"))
               {
                  xstring str1 = o.selectSingleNode(L"VATRates").text;
                  xstring str1 = o.selectSingleNode(L"VATRates").text();
                  if(str1.find(L",L")) str1 = str1.left(str1.find(L",L"));
                  dw_custom.SetItemString(i,L"VATRates",str1);
               }
               if(o.selectSingleNode(L"CustEName"))
               {
                  dw_custom.SetItemString(i,L"CustEName",o.selectSingleNode(L"CustEName").text);
                  dw_custom.SetItemString(i,L"CustEName",o.selectSingleNode(L"CustEName").text());
               }dw_base.SetItemString(1,L"Amount")
               if(o.selectSingleNode(L"VATRefundRate"))
               {
                  dw_custom.SetItemString(i,L"VATRefundRate",o.selectSingleNode(L"VATRefundRate").text);
                  dw_custom.SetItemString(i,L"VATRefundRate",o.selectSingleNode(L"VATRefundRate").text());
               }
               if(o.selectSingleNode(L"SupervisionRuler"))
               {
                  dw_custom.SetItemString(i,L"SupervisionRuler",o.selectSingleNode(L"SupervisionRuler").text);
                  dw_custom.SetItemString(i,L"SupervisionRuler",o.selectSingleNode(L"SupervisionRuler").text());
               }
               if(o.selectSingleNode(L"HSCode"))
               {
                  xstring hscode = o.selectSingleNode(L"HSCode").text;
                  xstring hscode = o.selectSingleNode(L"HSCode").text();
                  if(dw_custom.GetItemString(i,L"CustName").find(L"["+hscode)>=0)
                  {
                     xstring str = dw_custom.GetItemString(i,L"CustName");
@@ -2214,9 +2214,9 @@
               }
               if(o.selectSingleNode(L"UOM"))
               {
                  dw_custom.SetItemString(i,L"LegalUOMCode",o.selectSingleNode(L"UOM").text);
                  dw_customex.SetItemString(i,L"LegalUOMCode",o.selectSingleNode(L"UOM").text);
                  xstring uom = o.selectSingleNode(L"UOM").text;
                  dw_custom.SetItemString(i,L"LegalUOMCode",o.selectSingleNode(L"UOM").text());
                  dw_customex.SetItemString(i,L"LegalUOMCode",o.selectSingleNode(L"UOM").text());
                  xstring uom = o.selectSingleNode(L"UOM").text();
                  if(uom==L"千克")
                  {
                     dw_custom.SetItemString(i,L"LegalQty",dw_custom.GetItemString(i,L"NW"));
@@ -2256,8 +2256,8 @@
      xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyelement", L"ClassifyID", ClassifyID);
      if (x)
      {
         KXMLDOMNodeList items = x.GetXmlDoc().selectNodes(L"/GDN/CDElement");
         int lens = items.length;
         KXMLDOMNodeList items = x.selectNodes(L"/GDN/CDElement");
         int lens = items.length();
         for (int k = 0; k < lens; k++)
         {
            int row = dw_cdelement.InsertRow(0);
@@ -2267,17 +2267,17 @@
            xstring CDLineID = e1.getAttribute(L"guid");
            if (CDLineID == L"")
            {
               e1.SetAttribute(L"guid", ViewObject::GetGuid());
               e1.setAttribute(L"guid", ViewObject::GetGuid());
               CDLineID = e1.getAttribute(L"guid");
            }
            dw_cdelement.SetItemString(row, L"CDLineID", CDLineID);
            dw_cdelement.SetItemString(row, L"GDNID", dw_base.GetGuid(1));
            if (e.selectSingleNode(L"HSCode")) dw_cdelement.SetItemString(row, L"HSCode", e.selectSingleNode(L"HSCode").text);
            if (e.selectSingleNode(L"SeqNo")) dw_cdelement.SetItemString(row, L"SeqNo", e.selectSingleNode(L"SeqNo").text);
            if (e.selectSingleNode(L"EleName")) dw_cdelement.SetItemString(row, L"EleName", e.selectSingleNode(L"EleName").text);
            if (e.selectSingleNode(L"EleContent")) dw_cdelement.SetItemString(row, L"EleContent", e.selectSingleNode(L"EleContent").text);
            if (e.selectSingleNode(L"CustomName")) dw_cdelement.SetItemString(row, L"CustomName", e.selectSingleNode(L"CustomName").text);
            if (e.selectSingleNode(L"ClassifyID")) dw_cdelement.SetItemString(row, L"ClassifyID", e.selectSingleNode(L"ClassifyID").text);
            if (e.selectSingleNode(L"HSCode")) dw_cdelement.SetItemString(row, L"HSCode", e.selectSingleNode(L"HSCode").text());
            if (e.selectSingleNode(L"SeqNo")) dw_cdelement.SetItemString(row, L"SeqNo", e.selectSingleNode(L"SeqNo").text());
            if (e.selectSingleNode(L"EleName")) dw_cdelement.SetItemString(row, L"EleName", e.selectSingleNode(L"EleName").text());
            if (e.selectSingleNode(L"EleContent")) dw_cdelement.SetItemString(row, L"EleContent", e.selectSingleNode(L"EleContent").text());
            if (e.selectSingleNode(L"CustomName")) dw_cdelement.SetItemString(row, L"CustomName", e.selectSingleNode(L"CustomName").text());
            if (e.selectSingleNode(L"ClassifyID")) dw_cdelement.SetItemString(row, L"ClassifyID", e.selectSingleNode(L"ClassifyID").text());
            /*if(e.selectSingleNode(L"EleName"))
            {
               if(e.selectSingleNode(L"EleName").text==L"品牌类型")
@@ -2325,7 +2325,7 @@
   {
      if (dw_cdelement.GetRowCount() > 0)
      {
         if (win32::MessageBox(GetHWND(), L"更新报关信息会使报关要素无效,是否继续?", L"提示", 1) == 2)
         if (MessageBoxW(GetHWND(), L"更新报关信息会使报关要素无效,是否继续?", L"提示", 1) == 2)
            return 1;
      }
      int cnt = dw_custom.GetRowCount();
@@ -2435,33 +2435,33 @@
         xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyinfoex", L"ClassifyID", ClassifyID);
         if (x)
         {
            KXMLDOMNode o = x.GetXmlDoc().selectSingleNode(L"data/Item");
            KXMLDOMNode o = x.selectSingleNode(L"data/Item");
            if (o)
            {
               if (o.selectSingleNode(L"VATRates"))
               {
                  xstring str1 = o.selectSingleNode(L"VATRates").text;
                  xstring str1 = o.selectSingleNode(L"VATRates").text();
                  if (str1.find(L",L")) str1 = str1.left(str1.find(L",L"));
                  dw_custom.SetItemString(i, L"VATRates", str1);
                  dw_customex.SetItemString(i, L"VATRates", str1);
               }
               if (o.selectSingleNode(L"CustEName"))
               {
                  dw_custom.SetItemString(i, L"CustEName", o.selectSingleNode(L"CustEName").text);
                  dw_customex.SetItemString(i, L"CustEName", o.selectSingleNode(L"CustEName").text);
                  dw_custom.SetItemString(i, L"CustEName", o.selectSingleNode(L"CustEName").text());
                  dw_customex.SetItemString(i, L"CustEName", o.selectSingleNode(L"CustEName").text());
               }
               if (o.selectSingleNode(L"SupervisionRuler"))
               {
                  dw_custom.SetItemString(i, L"SupervisionRuler", o.selectSingleNode(L"SupervisionRuler").text);
                  dw_custom.SetItemString(i, L"SupervisionRuler", o.selectSingleNode(L"SupervisionRuler").text());
               }
               if (o.selectSingleNode(L"VATRefundRate"))
               {
                  dw_custom.SetItemString(i, L"VATRefundRate", o.selectSingleNode(L"VATRefundRate").text);
                  dw_customex.SetItemString(i, L"VATRefundRate", o.selectSingleNode(L"VATRefundRate").text);
                  dw_custom.SetItemString(i, L"VATRefundRate", o.selectSingleNode(L"VATRefundRate").text());
                  dw_customex.SetItemString(i, L"VATRefundRate", o.selectSingleNode(L"VATRefundRate").text());
               }
               if (o.selectSingleNode(L"HSCode"))
               {
                  xstring hscode = o.selectSingleNode(L"HSCode").text;
                  xstring hscode = o.selectSingleNode(L"HSCode").text();
                  if (dw_custom.GetItemString(i, L"CustName").find(L"[" + hscode) >= 0)
                  {
                     xstring str = dw_custom.GetItemString(i, L"CustName");
@@ -2475,9 +2475,9 @@
               }
               if (o.selectSingleNode(L"UOM"))
               {
                  dw_custom.SetItemString(i, L"LegalUOMCode", o.selectSingleNode(L"UOM").text);
                  dw_customex.SetItemString(i, L"LegalUOMCode", o.selectSingleNode(L"UOM").text);
                  xstring uom = o.selectSingleNode(L"UOM").text;
                  dw_custom.SetItemString(i, L"LegalUOMCode", o.selectSingleNode(L"UOM").text());
                  dw_customex.SetItemString(i, L"LegalUOMCode", o.selectSingleNode(L"UOM").text());
                  xstring uom = o.selectSingleNode(L"UOM").text();
                  if (uom == L"千克")
                  {
                     dw_custom.SetItemString(i, L"LegalQty", dw_custom.GetItemString(i, L"NW"));
@@ -2511,9 +2511,9 @@
      {
         xml x;
         
         x.LoadXml(str);
         KXMLDOMNodeList items = x.GetXmlDoc().selectNodes(L"data/Item");
         int len = items.length;
         x.loadXML(str);
         KXMLDOMNodeList items = x.selectNodes(L"data/Item");
         int len = items.length();
         int row = 0;
         for (int i = 0; i < len; i++)
         {
@@ -2527,32 +2527,32 @@
            }
            KXMLDOMNode t = items.item(i);
            if (t.selectSingleNode(L"PONo"))dw_source.SetItemString(row, L"PONo", t.selectSingleNode(L"PONo").text);
            if (t.selectSingleNode(L"POItemID"))dw_source.SetItemString(row, L"POItemID", t.selectSingleNode(L"POItemID").text);
            if (t.selectSingleNode(L"SOLineID"))dw_source.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text);
            if (t.selectSingleNode(L"GDNLineID"))dw_source.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text);
            if (t.selectSingleNode(L"PONo"))dw_source.SetItemString(row, L"PONo", t.selectSingleNode(L"PONo").text());
            if (t.selectSingleNode(L"POItemID"))dw_source.SetItemString(row, L"POItemID", t.selectSingleNode(L"POItemID").text());
            if (t.selectSingleNode(L"SOLineID"))dw_source.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text());
            if (t.selectSingleNode(L"GDNLineID"))dw_source.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text());
            if (t.selectSingleNode(L"GDNID"))dw_source.SetItemString(row, L"GDNID", t.selectSingleNode(L"GDNID").text);
            if (t.selectSingleNode(L"GDNID"))dw_source.SetItemString(row, L"GDNID", t.selectSingleNode(L"GDNID").text());
            if (t.selectSingleNode(L"GoodsNo"))dw_source.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text);
            if (t.selectSingleNode(L"GDNQuantity"))dw_source.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"GDNQuantity").text);
            if (t.selectSingleNode(L"BuyQuantity"))dw_source.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"BuyQuantity").text);
            if (t.selectSingleNode(L"CName"))dw_source.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text);
            if (t.selectSingleNode(L"CustomerItemNo"))dw_source.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text);
            if (t.selectSingleNode(L"BOMPart"))dw_source.SetItemString(row, L"BOMPart", t.selectSingleNode(L"BOMPart").text);
            if (t.selectSingleNode(L"ItemID"))dw_source.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text);
            if (t.selectSingleNode(L"BuyUnitPrice"))dw_source.SetItemString(row, L"BuyUnitPrice", t.selectSingleNode(L"BuyUnitPrice").text);
            if (t.selectSingleNode(L"BuyAmount"))dw_source.SetItemString(row, L"BuyAmount", t.selectSingleNode(L"BuyAmount").text);
            if (t.selectSingleNode(L"SupplierID"))dw_source.SetItemString(row, L"SupplierID", t.selectSingleNode(L"POSupplierID").text);
            if (t.selectSingleNode(L"SupplierID/@_displaystring"))dw_source.SetItemDisplayString(row, L"SupplierID", t.selectSingleNode(L"SupplierID/@_displaystring").text);
            if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemDisplayString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text);
            if (t.selectSingleNode(L"VATRefundRate"))dw_source.SetItemDisplayString(row, L"VATRefundRate", t.selectSingleNode(L"VATRefundRate").text);
            if (t.selectSingleNode(L"Amount"))dw_source.SetItemDisplayString(row, L"Amount", t.selectSingleNode(L"Amount").text);
            if (t.selectSingleNode(L"POCreatorID"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID").text);
            if (t.selectSingleNode(L"POCreatorID/@_displaystring"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID/@_displaystring").text);
            if (t.selectSingleNode(L"Swapthecost"))dw_source.SetItemDisplayString(row, L"Swapthecost", t.selectSingleNode(L"Swapthecost").text);
            if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemDisplayString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text);
            //if(t.selectSingleNode(L"HSCode"))dw_source.SetItemDisplayString(row,L"HSCode",t.selectSingleNode(L"HSCode").text);
            if (t.selectSingleNode(L"GoodsNo"))dw_source.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text());
            if (t.selectSingleNode(L"GDNQuantity"))dw_source.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"GDNQuantity").text());
            if (t.selectSingleNode(L"BuyQuantity"))dw_source.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"BuyQuantity").text());
            if (t.selectSingleNode(L"CName"))dw_source.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text());
            if (t.selectSingleNode(L"CustomerItemNo"))dw_source.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text());
            if (t.selectSingleNode(L"BOMPart"))dw_source.SetItemString(row, L"BOMPart", t.selectSingleNode(L"BOMPart").text());
            if (t.selectSingleNode(L"ItemID"))dw_source.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text());
            if (t.selectSingleNode(L"BuyUnitPrice"))dw_source.SetItemString(row, L"BuyUnitPrice", t.selectSingleNode(L"BuyUnitPrice").text());
            if (t.selectSingleNode(L"BuyAmount"))dw_source.SetItemString(row, L"BuyAmount", t.selectSingleNode(L"BuyAmount").text());
            if (t.selectSingleNode(L"SupplierID"))dw_source.SetItemString(row, L"SupplierID", t.selectSingleNode(L"POSupplierID").text());
            if (t.selectSingleNode(L"SupplierID/@_displaystring"))dw_source.SetItemDisplayString(row, L"SupplierID", t.selectSingleNode(L"SupplierID/@_displaystring").text());
            if (t.selectSingleNode(L"HasVATInvoice"))dw_source.SetItemDisplayString(row, L"HasVATInvoice", t.selectSingleNode(L"HasVATInvoice").text());
            if (t.selectSingleNode(L"VATRefundRate"))dw_source.SetItemDisplayString(row, L"VATRefundRate", t.selectSingleNode(L"VATRefundRate").text());
            if (t.selectSingleNode(L"Amount"))dw_source.SetItemDisplayString(row, L"Amount", t.selectSingleNode(L"Amount").text());
            if (t.selectSingleNode(L"POCreatorID"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID").text());
            if (t.selectSingleNode(L"POCreatorID/@_displaystring"))dw_source.SetItemDisplayString(row, L"POCreatorID", t.selectSingleNode(L"POCreatorID/@_displaystring").text());
            if (t.selectSingleNode(L"Swapthecost"))dw_source.SetItemDisplayString(row, L"Swapthecost", t.selectSingleNode(L"Swapthecost").text());
            if (t.selectSingleNode(L"RefundAmount"))dw_source.SetItemDisplayString(row, L"RefundAmount", t.selectSingleNode(L"RefundAmount").text());
            //if(t.selectSingleNode(L"HSCode"))dw_source.SetItemDisplayString(row,L"HSCode",t.selectSingleNode(L"HSCode").text());
         }
         CalcProfit();
      }
@@ -2576,9 +2576,9 @@
         trace(str);
         xml x;
         
         x.LoadXml(str);
         KXMLDOMNodeList items = x.GetXmlDoc().selectNodes(L"data/Item");
         int len = items.length;
         x.loadXML(str);
         KXMLDOMNodeList items = x.selectNodes(L"data/Item");
         int len = items.length();
         int row = 0;
         xstring SONos = dw_base.GetItemString(1, L"SONos");
         xstring OrderNos = dw_base.GetItemString(1, L"OrderNos");
@@ -2600,13 +2600,14 @@
               row = dw_item.InsertRow(0);
            }
            KXMLDOMNode t = items.item(i);
            dw_item.SetItemString(row, L"SeqNo", (row * 10).toString());
            dw_item.SetItemString(row, L"SeqNo", xstring((row * 10)));
            dw_item.SetItemString(row, L"GDNID", dw_base.GetGuid(1));
            double cost = t.selectSingleNode(L"Cost").text.toDouble();
            double cost = (double) t.selectSingleNode(L"Cost").text().todouble();
            if (t.selectSingleNode(L"SONo"))
            {
               xstring SONo = t.selectSingleNode(L"SONo").text;
               xstring SONo = t.selectSingleNode(L"SONo").text();
               if (SONos == L"")
               {
                  SONos = SONo;
@@ -2621,7 +2622,7 @@
            if (t.selectSingleNode(L"CustomerPONo"))
            {
               xstring CustomerPONo = t.selectSingleNode(L"CustomerPONo").text;
               xstring CustomerPONo = t.selectSingleNode(L"CustomerPONo").text();
               if (OrderNos == L"")
                  OrderNos = CustomerPONo;
               else if (OrderNos.find(CustomerPONo) < 0) OrderNos += L",L" + CustomerPONo;
@@ -2629,7 +2630,7 @@
            if (t.selectSingleNode(L"OperationTips"))
            {
               xstring OperationTips = t.selectSingleNode(L"OperationTips").text;
               xstring OperationTips = t.selectSingleNode(L"OperationTips").text();
               if (OperationTipss == L"")
                  OperationTipss = OperationTips;
               else if (OperationTipss.find(OperationTips) < 0) OperationTipss += L"\r\n" + OperationTips;
@@ -2637,81 +2638,81 @@
            if (t.selectSingleNode(L"FrontMarks"))
            {
               xstring FrontMarks = t.selectSingleNode(L"FrontMarks").text;
               xstring FrontMarks = t.selectSingleNode(L"FrontMarks").text();
               if (FrontMarkss == L"")
                  FrontMarkss = FrontMarks;
               else if (FrontMarkss.find(FrontMarks) < 0) FrontMarkss += L"\r\n" + FrontMarks;
            }
            //int cost = t.selectSingleNode(L"Cost").text.toDouble();
            //dw_base.SetItemString(1,L"Cost",t.selectSingleNode(L"Cost").text);
            if (t.selectSingleNode(L"SalespersonID/@_displaystring"))dw_base.SetItemDisplayString(1, L"SalespersonID", t.selectSingleNode(L"SalespersonID/@_displaystring").text);
            if (t.selectSingleNode(L"SalespersonID"))dw_base.SetItemString(1, L"SalespersonID", t.selectSingleNode(L"SalespersonID").text);
            if (t.selectSingleNode(L"CustomerID"))dw_base.SetItemString(1, L"CustomerID", t.selectSingleNode(L"CustomerID").text);
            if (t.selectSingleNode(L"CustomerID/@_displaystring"))dw_base.SetItemDisplayString(1, L"CustomerID", t.selectSingleNode(L"CustomerID/@_displaystring").text);
            //dw_base.SetItemString(1,L"Cost",t.selectSingleNode(L"Cost").text());
            if (t.selectSingleNode(L"SalespersonID/@_displaystring"))dw_base.SetItemDisplayString(1, L"SalespersonID", t.selectSingleNode(L"SalespersonID/@_displaystring").text());
            if (t.selectSingleNode(L"SalespersonID"))dw_base.SetItemString(1, L"SalespersonID", t.selectSingleNode(L"SalespersonID").text());
            if (t.selectSingleNode(L"CustomerID"))dw_base.SetItemString(1, L"CustomerID", t.selectSingleNode(L"CustomerID").text());
            if (t.selectSingleNode(L"CustomerID/@_displaystring"))dw_base.SetItemDisplayString(1, L"CustomerID", t.selectSingleNode(L"CustomerID/@_displaystring").text());
            //trace(L"*****************");
            if (t.selectSingleNode(L"LCNo"))dw_base.SetItemString(1, L"LCNo", t.selectSingleNode(L"LCNo").text);
            if (t.selectSingleNode(L"LCSignDate"))dw_base.SetItemString(1, L"LCSignDate", t.selectSingleNode(L"LCSignDate").text);
            if (t.selectSingleNode(L"LCReceiveDate"))dw_base.SetItemString(1, L"LCReceiveDate", t.selectSingleNode(L"LCReceiveDate").text);
            if (t.selectSingleNode(L"DraftPayer"))dw_base.SetItemString(1, L"DraftPayer", t.selectSingleNode(L"DraftPayer").text);
            if (t.selectSingleNode(L"NegotiatingBank"))dw_base.SetItemString(1, L"NegotiatingBank", t.selectSingleNode(L"NegotiatingBank").text);
            if (t.selectSingleNode(L"DraftTerm"))dw_base.SetItemString(1, L"DraftTerm", t.selectSingleNode(L"DraftTerm").text);
            if (t.selectSingleNode(L"CustomerDesc"))dw_base.SetItemString(1, L"CustomerDesc", t.selectSingleNode(L"CustomerDesc").text);
            if (t.selectSingleNode(L"LCSigner"))dw_base.SetItemString(1, L"LCSigner", t.selectSingleNode(L"LCSigner").text);
            if (t.selectSingleNode(L"Consignee"))dw_base.SetItemString(1, L"Consignee", t.selectSingleNode(L"Consignee").text);
            if (t.selectSingleNode(L"NotifyParty"))dw_base.SetItemString(1, L"NotifyParty", t.selectSingleNode(L"NotifyParty").text);
            if (t.selectSingleNode(L"Country"))dw_base.SetItemString(1, L"Country", t.selectSingleNode(L"Country").text);
            if (t.selectSingleNode(L"CountryName"))dw_base.SetItemDisplayString(1, L"Country", t.selectSingleNode(L"CountryName").text);
            if (t.selectSingleNode(L"TradeType"))dw_base.SetItemString(1, L"TradeType", t.selectSingleNode(L"TradeType").text);
            if (t.selectSingleNode(L"TradeTypeName"))dw_base.SetItemDisplayString(1, L"TradeType", t.selectSingleNode(L"TradeTypeName").text);
            if (t.selectSingleNode(L"TransportMode"))dw_base.SetItemString(1, L"TransportMode", t.selectSingleNode(L"TransportMode").text);
            if (t.selectSingleNode(L"TransportModeName"))dw_base.SetItemDisplayString(1, L"TransportMode", t.selectSingleNode(L"TransportModeName").text);
            if (t.selectSingleNode(L"POL"))dw_base.SetItemString(1, L"POL", t.selectSingleNode(L"POL").text);
            if (t.selectSingleNode(L"PriceTerm"))dw_base.SetItemString(1, L"PriceTerm", t.selectSingleNode(L"PriceTerm").text);
            if (t.selectSingleNode(L"PaymentTerm"))dw_base.SetItemString(1, L"PaymentTerm", t.selectSingleNode(L"PaymentTerm").text);
            if (t.selectSingleNode(L"PaymentTermMore"))dw_base.SetItemString(1, L"PaymentTermMore", t.selectSingleNode(L"PaymentTermMore").text);
            if (t.selectSingleNode(L"LCNo"))dw_base.SetItemString(1, L"LCNo", t.selectSingleNode(L"LCNo").text());
            if (t.selectSingleNode(L"LCSignDate"))dw_base.SetItemString(1, L"LCSignDate", t.selectSingleNode(L"LCSignDate").text());
            if (t.selectSingleNode(L"LCReceiveDate"))dw_base.SetItemString(1, L"LCReceiveDate", t.selectSingleNode(L"LCReceiveDate").text());
            if (t.selectSingleNode(L"DraftPayer"))dw_base.SetItemString(1, L"DraftPayer", t.selectSingleNode(L"DraftPayer").text());
            if (t.selectSingleNode(L"NegotiatingBank"))dw_base.SetItemString(1, L"NegotiatingBank", t.selectSingleNode(L"NegotiatingBank").text());
            if (t.selectSingleNode(L"DraftTerm"))dw_base.SetItemString(1, L"DraftTerm", t.selectSingleNode(L"DraftTerm").text());
            if (t.selectSingleNode(L"CustomerDesc"))dw_base.SetItemString(1, L"CustomerDesc", t.selectSingleNode(L"CustomerDesc").text());
            if (t.selectSingleNode(L"LCSigner"))dw_base.SetItemString(1, L"LCSigner", t.selectSingleNode(L"LCSigner").text());
            if (t.selectSingleNode(L"Consignee"))dw_base.SetItemString(1, L"Consignee", t.selectSingleNode(L"Consignee").text());
            if (t.selectSingleNode(L"NotifyParty"))dw_base.SetItemString(1, L"NotifyParty", t.selectSingleNode(L"NotifyParty").text());
            if (t.selectSingleNode(L"Country"))dw_base.SetItemString(1, L"Country", t.selectSingleNode(L"Country").text());
            if (t.selectSingleNode(L"CountryName"))dw_base.SetItemDisplayString(1, L"Country", t.selectSingleNode(L"CountryName").text());
            if (t.selectSingleNode(L"TradeType"))dw_base.SetItemString(1, L"TradeType", t.selectSingleNode(L"TradeType").text());
            if (t.selectSingleNode(L"TradeTypeName"))dw_base.SetItemDisplayString(1, L"TradeType", t.selectSingleNode(L"TradeTypeName").text());
            if (t.selectSingleNode(L"TransportMode"))dw_base.SetItemString(1, L"TransportMode", t.selectSingleNode(L"TransportMode").text());
            if (t.selectSingleNode(L"TransportModeName"))dw_base.SetItemDisplayString(1, L"TransportMode", t.selectSingleNode(L"TransportModeName").text());
            if (t.selectSingleNode(L"POL"))dw_base.SetItemString(1, L"POL", t.selectSingleNode(L"POL").text());
            if (t.selectSingleNode(L"PriceTerm"))dw_base.SetItemString(1, L"PriceTerm", t.selectSingleNode(L"PriceTerm").text());
            if (t.selectSingleNode(L"PaymentTerm"))dw_base.SetItemString(1, L"PaymentTerm", t.selectSingleNode(L"PaymentTerm").text());
            if (t.selectSingleNode(L"PaymentTermMore"))dw_base.SetItemString(1, L"PaymentTermMore", t.selectSingleNode(L"PaymentTermMore").text());
            if (t.selectSingleNode(L"SOLineID"))dw_item.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text);
            if (t.selectSingleNode(L"GoodsNo"))dw_item.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text);
            if (t.selectSingleNode(L"EName"))dw_item.SetItemString(row, L"EName", t.selectSingleNode(L"EName").text);
            if (t.selectSingleNode(L"CustomerItemNo"))dw_item.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text);
            if (t.selectSingleNode(L"ItemID"))dw_item.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text);
            if (t.selectSingleNode(L"UnitPrice"))dw_item.SetItemString(row, L"UnitPrice", t.selectSingleNode(L"UnitPrice").text);
            if (t.selectSingleNode(L"GDNLineID"))dw_item.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text);
            if (t.selectSingleNode(L"SOLineID"))dw_item.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text());
            if (t.selectSingleNode(L"GoodsNo"))dw_item.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text());
            if (t.selectSingleNode(L"EName"))dw_item.SetItemString(row, L"EName", t.selectSingleNode(L"EName").text());
            if (t.selectSingleNode(L"CustomerItemNo"))dw_item.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text());
            if (t.selectSingleNode(L"ItemID"))dw_item.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text());
            if (t.selectSingleNode(L"UnitPrice"))dw_item.SetItemString(row, L"UnitPrice", t.selectSingleNode(L"UnitPrice").text());
            if (t.selectSingleNode(L"GDNLineID"))dw_item.SetItemString(row, L"GDNLineID", t.selectSingleNode(L"GDNLineID").text());
            if (t.selectSingleNode(L"SONo"))dw_item.SetItemString(row, L"SONo", t.selectSingleNode(L"SONo").text);
            if (t.selectSingleNode(L"SONo"))dw_item.SetItemString(row, L"SONo", t.selectSingleNode(L"SONo").text());
            if (t.selectSingleNode(L"SOLineNo"))dw_item.SetItemString(row, L"SOLineNo", t.selectSingleNode(L"SOLineNo").text);
            if (t.selectSingleNode(L"CustomerPONo"))dw_item.SetItemString(row, L"PONo", t.selectSingleNode(L"CustomerPONo").text);
            if (t.selectSingleNode(L"GroupNo"))dw_item.SetItemString(row, L"PONo", t.selectSingleNode(L"GroupNo").text);
            if (t.selectSingleNode(L"SOLineNo"))dw_item.SetItemString(row, L"SOLineNo", t.selectSingleNode(L"SOLineNo").text());
            if (t.selectSingleNode(L"CustomerPONo"))dw_item.SetItemString(row, L"PONo", t.selectSingleNode(L"CustomerPONo").text());
            if (t.selectSingleNode(L"GroupNo"))dw_item.SetItemString(row, L"PONo", t.selectSingleNode(L"GroupNo").text());
            if (t.selectSingleNode(L"SKUNo"))dw_item.SetItemString(row, L"SKUNo", t.selectSingleNode(L"SKUNo").text);
            if (t.selectSingleNode(L"Packing"))dw_item.SetItemString(row, L"Packing", t.selectSingleNode(L"Packing").text);
            if (t.selectSingleNode(L"InnerQty"))dw_item.SetItemString(row, L"InnerQty", t.selectSingleNode(L"InnerQty").text);
            if (t.selectSingleNode(L"PackingRate"))dw_item.SetItemString(row, L"PackingRate", t.selectSingleNode(L"PackingRate").text);
            if (t.selectSingleNode(L"Brand"))dw_item.SetItemString(row, L"Brand", t.selectSingleNode(L"Brand").text);
            if (t.selectSingleNode(L"UOMCode"))dw_item.SetItemString(row, L"UOMCode", t.selectSingleNode(L"UOMCode").text);
            if (t.selectSingleNode(L"UOMCode/@_displaystring"))dw_item.SetItemDisplayString(row, L"UOMCode", t.selectSingleNode(L"UOMCode/@_displaystring").text);
            if (t.selectSingleNode(L"SKUNo"))dw_item.SetItemString(row, L"SKUNo", t.selectSingleNode(L"SKUNo").text());
            if (t.selectSingleNode(L"Packing"))dw_item.SetItemString(row, L"Packing", t.selectSingleNode(L"Packing").text());
            if (t.selectSingleNode(L"InnerQty"))dw_item.SetItemString(row, L"InnerQty", t.selectSingleNode(L"InnerQty").text());
            if (t.selectSingleNode(L"PackingRate"))dw_item.SetItemString(row, L"PackingRate", t.selectSingleNode(L"PackingRate").text());
            if (t.selectSingleNode(L"Brand"))dw_item.SetItemString(row, L"Brand", t.selectSingleNode(L"Brand").text());
            if (t.selectSingleNode(L"UOMCode"))dw_item.SetItemString(row, L"UOMCode", t.selectSingleNode(L"UOMCode").text());
            if (t.selectSingleNode(L"UOMCode/@_displaystring"))dw_item.SetItemDisplayString(row, L"UOMCode", t.selectSingleNode(L"UOMCode/@_displaystring").text());
            if (t.selectSingleNode(L"KOPCode"))dw_item.SetItemString(row, L"KOPCode", t.selectSingleNode(L"KOPCode").text);
            if (t.selectSingleNode(L"KOPCode/@_displaystring"))dw_item.SetItemDisplayString(row, L"KOPCode", t.selectSingleNode(L"KOPCode/@_displaystring").text);
            if (t.selectSingleNode(L"PackageL"))dw_item.SetItemString(row, L"PackageL", t.selectSingleNode(L"PackageL").text);
            if (t.selectSingleNode(L"PackageW"))dw_item.SetItemString(row, L"PackageW", t.selectSingleNode(L"PackageW").text);
            if (t.selectSingleNode(L"PackageH"))dw_item.SetItemString(row, L"PackageH", t.selectSingleNode(L"PackageH").text);
            if (t.selectSingleNode(L"GWPerPkg"))dw_item.SetItemString(row, L"GWPerPkg", t.selectSingleNode(L"GWPerPkg").text);
            if (t.selectSingleNode(L"NWPerPkg"))dw_item.SetItemString(row, L"NWPerPkg", t.selectSingleNode(L"NWPerPkg").text);
            if (t.selectSingleNode(L"ClassifyID"))dw_item.SetItemString(row, L"ClassifyID", t.selectSingleNode(L"ClassifyID").text);
            if (t.selectSingleNode(L"ClassifyID/@_displaystring"))dw_item.SetItemDisplayString(row, L"ClassifyID", t.selectSingleNode(L"ClassifyID/@_displaystring").text);
            if (t.selectSingleNode(L"Remarks"))dw_item.SetItemString(row, L"Remarks", t.selectSingleNode(L"Remarks").text);
            if (t.selectSingleNode(L"KOPCode"))dw_item.SetItemString(row, L"KOPCode", t.selectSingleNode(L"KOPCode").text());
            if (t.selectSingleNode(L"KOPCode/@_displaystring"))dw_item.SetItemDisplayString(row, L"KOPCode", t.selectSingleNode(L"KOPCode/@_displaystring").text());
            if (t.selectSingleNode(L"PackageL"))dw_item.SetItemString(row, L"PackageL", t.selectSingleNode(L"PackageL").text());
            if (t.selectSingleNode(L"PackageW"))dw_item.SetItemString(row, L"PackageW", t.selectSingleNode(L"PackageW").text());
            if (t.selectSingleNode(L"PackageH"))dw_item.SetItemString(row, L"PackageH", t.selectSingleNode(L"PackageH").text());
            if (t.selectSingleNode(L"GWPerPkg"))dw_item.SetItemString(row, L"GWPerPkg", t.selectSingleNode(L"GWPerPkg").text());
            if (t.selectSingleNode(L"NWPerPkg"))dw_item.SetItemString(row, L"NWPerPkg", t.selectSingleNode(L"NWPerPkg").text());
            if (t.selectSingleNode(L"ClassifyID"))dw_item.SetItemString(row, L"ClassifyID", t.selectSingleNode(L"ClassifyID").text());
            if (t.selectSingleNode(L"ClassifyID/@_displaystring"))dw_item.SetItemDisplayString(row, L"ClassifyID", t.selectSingleNode(L"ClassifyID/@_displaystring").text());
            if (t.selectSingleNode(L"Remarks"))dw_item.SetItemString(row, L"Remarks", t.selectSingleNode(L"Remarks").text());
            if (t.selectSingleNode(L"UnitCommPrice"))dw_item.SetItemString(row, L"UnitCommPrice", t.selectSingleNode(L"UnitCommPrice").text);
            if (t.selectSingleNode(L"MiddlemanAmount"))dw_item.SetItemString(row, L"MiddlemanAmount", t.selectSingleNode(L"MiddlemanAmount").text);
            if (t.selectSingleNode(L"UnitCommPrice"))dw_item.SetItemString(row, L"UnitCommPrice", t.selectSingleNode(L"UnitCommPrice").text());
            if (t.selectSingleNode(L"MiddlemanAmount"))dw_item.SetItemString(row, L"MiddlemanAmount", t.selectSingleNode(L"MiddlemanAmount").text());
            if (t.selectSingleNode(L"ShipQuantity"))
               dw_item.ItemChangeTo(row, L"Quantity", t.selectSingleNode(L"ShipQuantity").text);
               dw_item.ItemChangeTo(row, L"Quantity", t.selectSingleNode(L"ShipQuantity").text());
            else
               if (t.selectSingleNode(L"Quantity"))dw_item.ItemChangeTo(row, L"Quantity", t.selectSingleNode(L"Quantity").text);
               if (t.selectSingleNode(L"Quantity"))dw_item.ItemChangeTo(row, L"Quantity", t.selectSingleNode(L"Quantity").text());
            double d1 = dw_item.GetItemDouble(row, L"Quantity");
            double d2 = dw_item.GetItemDouble(row, L"UnitPrice");
@@ -2726,7 +2727,7 @@
            double MiddlemanAmountRate = MiddlemanAmount * Quantity;
            PrivateCommissionAmount += ResearchCommission;
            PrivateCommissionAmountEx += MiddlemanAmountRate;
            //if(t.selectSingleNode(L"Amount"))dw_item.SetItemString(row,L"Amount",t.selectSingleNode(L"Amount").text);
            //if(t.selectSingleNode(L"Amount"))dw_item.SetItemString(row,L"Amount",t.selectSingleNode(L"Amount").text());
            RefreshSourcingItem(row, false);
@@ -2800,7 +2801,7 @@
         xstring CDLineID = e1.getAttribute(L"guid");
         if (CDLineID == L"")
         {
            e1.SetAttribute(L"guid", ViewObject::GetGuid());
            e1.setAttribute(L"guid", ViewObject::GetGuid());
            CDLineID = e1.getAttribute(L"guid");
         }
@@ -2831,8 +2832,8 @@
         xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyelement", L"ClassifyID", ClassifyID);
         if (x)
         {
            KXMLDOMNodeList items = x.GetXmlDoc().selectNodes(L"/GDN/CDElement");
            int lens = items.length;
            KXMLDOMNodeList items = x.selectNodes(L"/GDN/CDElement");
            int lens = items.length();
            for (int k = 0; k < lens; k++)
            {
               int row = dw_cdelement.InsertRow(0);
@@ -2842,15 +2843,15 @@
               xstring CDLineID = e1.getAttribute(L"guid");
               if (CDLineID == L"")
               {
                  e1.SetAttribute(L"guid", ViewObject::GetGuid());
                  e1.setAttribute(L"guid", ViewObject::GetGuid());
                  CDLineID = e1.getAttribute(L"guid");
               }
               dw_cdelement.SetItemString(row, L"CDLineID", CDLineID);
               dw_cdelement.SetItemString(row, L"GDNID", dw_base.GetGuid(1));
               if (e.selectSingleNode(L"HSCode")) dw_cdelement.SetItemString(row, L"HSCode", e.selectSingleNode(L"HSCode").text);
               if (e.selectSingleNode(L"SeqNo")) dw_cdelement.SetItemString(row, L"SeqNo", e.selectSingleNode(L"SeqNo").text);
               if (e.selectSingleNode(L"EleName")) dw_cdelement.SetItemString(row, L"EleName", e.selectSingleNode(L"EleName").text);
               if (e.selectSingleNode(L"EleContent")) dw_cdelement.SetItemString(row, L"EleContent", e.selectSingleNode(L"EleContent").text);
               if (e.selectSingleNode(L"HSCode")) dw_cdelement.SetItemString(row, L"HSCode", e.selectSingleNode(L"HSCode").text());
               if (e.selectSingleNode(L"SeqNo")) dw_cdelement.SetItemString(row, L"SeqNo", e.selectSingleNode(L"SeqNo").text());
               if (e.selectSingleNode(L"EleName")) dw_cdelement.SetItemString(row, L"EleName", e.selectSingleNode(L"EleName").text());
               if (e.selectSingleNode(L"EleContent")) dw_cdelement.SetItemString(row, L"EleContent", e.selectSingleNode(L"EleContent").text());
               /*if(e.selectSingleNode(L"EleName"))
               {
                  if(e.selectSingleNode(L"EleName").text==L"品牌类型")
@@ -2879,8 +2880,8 @@
                     }
                  }
               }*/
               if (e.selectSingleNode(L"CustomName")) dw_cdelement.SetItemString(row, L"CustomName", e.selectSingleNode(L"CustomName").text);
               if (e.selectSingleNode(L"ClassifyID")) dw_cdelement.SetItemString(row, L"ClassifyID", e.selectSingleNode(L"ClassifyID").text);
               if (e.selectSingleNode(L"CustomName")) dw_cdelement.SetItemString(row, L"CustomName", e.selectSingleNode(L"CustomName").text());
               if (e.selectSingleNode(L"ClassifyID")) dw_cdelement.SetItemString(row, L"ClassifyID", e.selectSingleNode(L"ClassifyID").text());
            }
         }
      }
@@ -2945,13 +2946,14 @@
      }
      if (comdid == L"xmSearch")
      {
         xaserverarg arg1 = new xaserverarg;
         arg1.setNativePointer(arg1.CreateInstance());
         xaserverarg& arg1 = *new xaserverarg;
         arg1.AddArg(L"text", searchStr);
         if (tabname == L"sourcing")
         {
            OpenWindow(L"dev:xpage[search.dialog.vx]", cast(arg1 as int));
            OpenWindow(L"dev:xpage[search.dialog.vx]", (LPARAM)&arg1);
            xstring str = arg1.GetArgString(L"text");
            searchStr = str;
            dw_source.Filter(L"*", searchStr);
@@ -2959,8 +2961,8 @@
         }
         else if (tabname == L"goods")
         {
            OpenWindow(L"dev:xpage[search.dialog.vx]", cast(arg1 as int));
            str = arg1.GetArgString(L"text");
            OpenWindow(L"dev:xpage[search.dialog.vx]", (LPARAM)&arg1);
            xstring str = arg1.GetArgString(L"text");
            searchStr = str;
            dw_item.Filter(L"*", searchStr);
            return 1;
@@ -2971,11 +2973,11 @@
      if (comdid == L"action:bill.GDNDelay")
      {
         xstring EntityIDEx = dw_base.GetGuid(1);
         xaserverarg argEx = new xaserverarg;
         argEx.setNativePointer(argEx.CreateInstance());
         xaserverarg& argEx = *new xaserverarg;
         trace(EntityIDEx);
         argEx.AddArg(L"GDNID", EntityIDEx);
         OpenWindow(L"dev:xpage[GDNDelay.vx]", cast(argEx as int));
         OpenWindow(L"dev:xpage[GDNDelay.vx]", (LPARAM)&argEx);
         return 1;
      }
      if (comdid == L"action:bill.Volume")
@@ -2987,7 +2989,7 @@
      {
         xstring EntityID1 = dw_base.GetGuid(1);
         xml x1 = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNJudge", L"GDNID", EntityID1);
         xstring Results1 = x1.GetXmlDoc().text;
         xstring Results1 = x1.text();
         if (Results1 != L"")
         {
            alert(Results1);
@@ -3019,7 +3021,7 @@
         xstring EntityID = dw_base.GetGuid(1);
         xml xx = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNJudge", L"GDNID", EntityID);
         xstring Results = xx.GetXmlDoc().text;
         xstring Results = xx.text();
         if (Results != L"")
         {
            alert(Results);
@@ -3027,7 +3029,7 @@
         }
         xml xx1 = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNJudgeEx", L"GDNID", EntityID);
         xstring Results2 = xx1.GetXmlDoc().text;
         xstring Results2 = xx1.text();
         if (Results2 != L"")
         {
            alert(Results2);
@@ -3035,7 +3037,7 @@
         }
         xml xx3 = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNJudgeExS", L"GDNID", EntityID);
         xstring Results3 = xx3.GetXmlDoc().text;
         xstring Results3 = xx3.text();
         if (Results3 != L"")
         {
            alert(Results3);
@@ -3043,7 +3045,7 @@
         }
         xml xx4 = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNJudgeAmount", L"GDNID", EntityID);
         xstring Results4 = xx4.GetXmlDoc().text;
         xstring Results4 = xx4.text();
         if (Results4 != L"")
         {
            alert(Results4);
@@ -3051,18 +3053,18 @@
         }
         /*   xml xx5= ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNCost",L"GDNID",EntityID);
            xstring Results5=xx5.GetXmlDoc().text;
            xstring Results5=xx5.text();
            if(Results5 !=L"")
            {
               alert(Results5);
               return 0;
            }*/
         xaserverarg arg7 = new xaserverarg;
         arg7.setNativePointer(arg7.CreateInstance());
         xaserverarg& arg7 = *new xaserverarg;
         trace(EntityID);
         arg7.AddArg(L"GDNID", EntityID);
         OpenWindow(L"dev:xpage[GDNDelay.vx]", cast(arg7 as int));
         OpenWindow(L"dev:xpage[GDNDelay.vx]", (LPARAM)arg7);
      }
      if (comdid.find(L"action:", 0) >= 0)
@@ -3183,11 +3185,12 @@
      {
         if (dw_base.GetItemString(1, L"InvoiceNo") != L"")
         {
            xaserverarg arg2 = new xaserverarg;
            arg2.setNativePointer(arg2.CreateInstance());
            xaserverarg& arg2 = *new xaserverarg;
            arg2.AddArg(L"InvoiceNo", dw_base.GetItemString(1, L"InvoiceNo"));
            arg2.AddArg(L"HWND", GetHWND().toString());
            OpenWindow(L"dev:xpage[GDNSourcePaperCard.vx]", cast(arg2 as int));
            //arg2.AddArg(L"HWND", GetHWND().toString());
            arg2.SetParam(L"HWND", (LPARAM)GetHWND());
            OpenWindow(L"dev:xpage[GDNSourcePaperCard.vx]",(LPARAM)&arg2);
         }
         else
         {
@@ -3229,17 +3232,17 @@
   {
      xstring name = L"出运明细单";
      xml x = ViewObject::RetrieveData(L"/sale/data/TradeFinance3/GetSetUpRemarks", L"Type", name);
      KXMLDOMNodeList items = x.GetXmlDoc().selectNodes(L"data/Item");
      KXMLDOMNodeList items = x.selectNodes(L"data/Item");
      KXMLDOMNode t = items.item(0);
      xstring Content = L"";
      if (t.selectSingleNode(L"Content"))
      {
         Content = t.selectSingleNode(L"Content").text;
         Content = t.selectSingleNode(L"Content").text();
      }
      xaserverarg arg1 = new xaserverarg;
      arg1.setNativePointer(arg1.CreateInstance());
      xaserverarg arg1 ;
      arg1.AddArg(L"value", Content);
      OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg1.getNativePointer());
      OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg1);
      return 1;
   }
@@ -3248,7 +3251,7 @@
   {
      xstring GDNID = dw_base.GetGuid(1);
      xml x = ViewObject::RetrieveData(L"/sale/data/GDN/CheckGW", L"GDNID", GDNID);
      xstring  r = x.GetXmlDoc().text;
      xstring  r = x.text();
      int r1 = r.toInt();
      if (x)
      {
@@ -3260,7 +3263,7 @@
      xml xs = ViewObject::RetrieveData(L"/sale/data/GDN/CheckCDLine", L"GDNID", GDNID);
      xstring  rs = xs.GetXmlDoc().text;
      xstring  rs = xs.text();
      int rs1 = rs.toInt();
      if (xs)
      {
@@ -3274,9 +3277,9 @@
      return 1;
   }
   //命令处理事件
   int OnXCommand(ref TXCommandEvent evt, int param)
   int OnXCommand(TEvent* evt, int param)
   {
      return OnCmdDispatch(evt.pStrID);
      return OnCmdDispatch(evt->xcommand.pStrID);
   }
   //风险计提
@@ -3288,13 +3291,13 @@
      xstring exchRate2 = L"";
      xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"prepareFeeRate");
      if (x.GetXmlDoc().selectSingleNode(L"root/item/@value"))
         exchRate = x.GetXmlDoc().selectSingleNode(L"root/item/@value").text;
      if (x.selectSingleNode(L"root/item/@value"))
         exchRate = x.selectSingleNode(L"root/item/@value").text();
      double rate = exchRate.toDouble();
      xml x1 = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate");
      if (x.GetXmlDoc().selectSingleNode(L"root/item/@value"))
         exchRate2 = x1.GetXmlDoc().selectSingleNode(L"root/item/@value").text;
      if (x.selectSingleNode(L"root/item/@value"))
         exchRate2 = x1.selectSingleNode(L"root/item/@value").text();
      double cryrate = exchRate2.toDouble();
      if (CurrencyCode == L"RMB" || CurrencyCode == L"CNY")
@@ -3343,7 +3346,7 @@
            if (x)
            {
               //   trace(L"\r\n" + x.GetXml());
               KXMLDOMNode o = x.GetXmlDoc().selectSingleNode(L"data/Item");
               KXMLDOMNode o = x.selectSingleNode(L"data/Item");
               if (o)
               {
                  KXMLDOMNode n = o.selectSingleNode(L"VATRates");
@@ -3360,7 +3363,7 @@
                  }
                  o.Release();
               }
               x.GetXmlDoc().Release();
               x.Release();
            }
         }
@@ -3395,12 +3398,12 @@
      xstring exchRate = L"";
      xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate");
      if (x.GetXmlDoc().selectSingleNode(L"root/item/@value"))
         exchRate = x.GetXmlDoc().selectSingleNode(L"root/item/@value").text;
      if (x.selectSingleNode(L"root/item/@value"))
         exchRate = x.selectSingleNode(L"root/item/@value").text();
      x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"mgtFeeRate");
      if (x.GetXmlDoc().selectSingleNode(L"root/item/@value"))
         expRate = x.GetXmlDoc().selectSingleNode(L"root/item/@value").text;
      if (x.selectSingleNode(L"root/item/@value"))
         expRate = x.selectSingleNode(L"root/item/@value").text();
      //double sale = dw_profit.GetItemDouble(1,L"ExchangeAmountEx");
      xstring ETDEx = dw_base.GetItemString(1, L"ETD");
@@ -3440,16 +3443,16 @@
      xstring exchRate = L"";
      xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate");
      if (x.GetXmlDoc().selectSingleNode(L"root/item/@value"))
         exchRate = x.GetXmlDoc().selectSingleNode(L"root/item/@value").text;
      if (x.selectSingleNode(L"root/item/@value"))
         exchRate = x.selectSingleNode(L"root/item/@value").text();
      x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"RiskFundAmount");
      if (x.GetXmlDoc().selectSingleNode(L"root/item/@value"))
         expRate = x.GetXmlDoc().selectSingleNode(L"root/item/@value").text;
      if (x.selectSingleNode(L"root/item/@value"))
         expRate = x.selectSingleNode(L"root/item/@value").text();
      //double sale = dw_profit.GetItemDouble(1,L"ExchangeAmountEx");
      xstring ETDEx = dw_base.GetItemString(1, L"ETD");
      if (ETDEx < "2023-01-01")
      if (ETDEx < L"2023-01-01")
      {
         //alert(L"1");
         expRate = L"0.0";
@@ -3548,8 +3551,8 @@
      exchangeRate = dw_profit.GetItemString(1, L"ExchangeRate");
      if (exchangeRate == L"") {
         xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate");
         if (x.GetXmlDoc().selectSingleNode(L"root/item/@value"))
            exchangeRate = x.GetXmlDoc().selectSingleNode(L"root/item/@value").text;
         if (x.selectSingleNode(L"root/item/@value"))
            exchangeRate = x.selectSingleNode(L"root/item/@value").text();
         dw_profit.SetItemString(1, L"ExchangeRate", exchangeRate);
      }
      if (exchangeRate != L"" || CurrencyCode == L"USD") {
@@ -3643,10 +3646,10 @@
      evalProfitAmountEx();
   }
   int OnItemAskStyle(ref TNotifyEvent evt, int p)
   int OnItemAskStyle(TEvent* evt, LPARAM p)
   {
      int DMS_CSSSTYLE = 0x8;
      ref DWASKSTYLENMHDR hdr = trust(evt.pnmh as ref DWASKSTYLENMHDR);
      DWASKSTYLENMHDR& hdr = *(DWASKSTYLENMHDR*)evt->notify.pnmh;
      int row = hdr.row;
      int col = hdr.col;
      xstring colname = hdr.colname;
@@ -3666,7 +3669,7 @@
            if ((Quantity / PackingRate) * PackingRate != Quantity)
            {
               hdr.mask = DMS_CSSSTYLE;
               hdr.cssstyle = L"color:#ff0000";
               hdr.pCssStyle = (wchar_t*)L"color:#ff0000";
            }
         }
      }
@@ -3676,20 +3679,20 @@
   int OnAttachEvent()
   {
      //绑定工具条点击事件
      AttachEvent(L"WM_XCOMMAND", OnXCommand);
      AttachEvent(L"WM_XCOMMAND", L"DWV_CLICKED", (FEvent)&GDN3MaintWin::OnXCommand);
      //获取焦点事件,用于重置工具条
      AttachEvent(L"WM_SETFOCUS", OnSetFocus);
      AttachEvent(L"WM_SETFOCUS", (FEvent)&GDN3MaintWin::OnSetFocus);
      AttachEvent(L"dw_item", L"DWV_ITEMCHANGED", OnItemChanged);
      AttachEvent(L"dw_source", L"DWV_ITEMCHANGED", OnItemChangedEx);
      AttachEvent(L"dw_base", L"DWV_ASKDATA", OnAskDataBase);
      AttachEvent(L"dw_item", L"DWV_ITEMCHANGED", (FEvent)&GDN3MaintWin::OnItemChanged);
      AttachEvent(L"dw_source", L"DWV_ITEMCHANGED", (FEvent)&GDN3MaintWin::OnItemChangedEx);
      AttachEvent(L"dw_base", L"DWV_ASKDATA", (FEvent)&GDN3MaintWin::OnAskDataBase);
      AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", OnBaseItemChanged);
      AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", (FEvent)&GDN3MaintWin::OnBaseItemChanged);
      AttachEvent(L"dw_profit", L"DWV_ITEMCHANGED", OnProfitItemChanged);
      AttachEvent(L"dw_custom", L"DWV_ITEMCHANGED", OnCustomItemChanged);
      AttachEvent(L"dw_billnote", L"DWV_DOUBLECLICKED", OnBillNoteDoubleClicked);//行双击
      AttachEvent(L"dw_item", L"DWV_ASKSTYLE", OnItemAskStyle);
      AttachEvent(L"dw_profit", L"DWV_ITEMCHANGED", (FEvent)&GDN3MaintWin::OnProfitItemChanged);
      AttachEvent(L"dw_custom", L"DWV_ITEMCHANGED", (FEvent)&GDN3MaintWin::OnCustomItemChanged);
      AttachEvent(L"dw_billnote", L"DWV_DOUBLECLICKED", (FEvent)&GDN3MaintWin::OnBillNoteDoubleClicked);//行双击
      AttachEvent(L"dw_item", L"DWV_ASKSTYLE", (FEvent)&GDN3MaintWin::OnItemAskStyle);
      AttachCloseWindow();
@@ -3701,16 +3704,16 @@
      xml x;
      x = new xml;
      
      xaserverarg arg = new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());
      xaserverarg arg;
      arg.AddArg(L"EntityID", GetEntityID(1));
      arg.AddArg(L"invno", invno);
      //int t0 = win32::GetTickCount();
      //if(url::get(L"/sale/data/Gdn/data/buffer", arg.GetString(),x)!=1)
      if (url::get(L"/sale/data/Gdn/data", arg.GetString(), x) != 1)
      //if(xurl::get(L"/sale/data/Gdn/data/buffer", arg.GetString(),x)!=1)
      if (xurl::get(L"/sale/data/Gdn/data", arg.GetString(), x) != 1)
      {
         alert(x.GetXmlDoc().text);
         alert(x.text());
         return -1;
      }
@@ -3719,7 +3722,7 @@
      KXMLDOMElement ele;
      KXMLDOMNode node;
      KXMLDOMDocument xdoc = x.GetXmlDoc();
      KXMLDOMDocument xdoc =x;
      node = xdoc.selectSingleNode(L"data/Item[@subject='Base' or @subject='base']/*");
      dw_base.DwRetrieve(GetServerUrl(), L"[gdnbase.gdn.sql.xq]", L"EntityID", InvoiceID);
@@ -3744,7 +3747,7 @@
               "<Item Name='装船通知' Field='Remark'></Item>" +
               "<Item Name='加拿大海关发票' Field='Remark'></Item>" +
               "<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>";
            x0.LoadXml(billnote);
            x0.loadXML(billnote);
            dw_billnote.Retrieve(x0);
         }
      }
@@ -3762,7 +3765,7 @@
      if (dw_item.GetRowCount() < 1)
      {
         xml x2 = xml::Make();
         x2.LoadXml(L"<GDN/>");
         x2.loadXML(L"<GDN/>");
         dw_item.Retrieve(x2);
         x2.Free();
      }
@@ -3836,13 +3839,12 @@
      xml x;
      x = new xml;
      
      xaserverarg arg = new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());
      xaserverarg arg ;
      arg.AddArg(L"invno", invno);
      if (url::get(L"/sale/data/Gdn/source/maintex", arg.GetString(), x) != 1)
      if (xurl::get(L"/sale/data/Gdn/source/maintex", arg.GetString(), x) != 1)
      {
         alert(x.GetXmlDoc().text);
         alert(x.text());
         return -1;
      }
@@ -3858,21 +3860,20 @@
      xml x;
      x = new xml;
      
      xaserverarg arg = new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());
      xaserverarg arg ;
      arg.AddArg(L"invno", invno);
      if (url::get(L"/sale/data/Gdn/source/maintex", arg.GetString(), x) != 1)
      if (xurl::get(L"/sale/data/Gdn/source/maintex", arg.GetString(), x) != 1)
      {
         alert(x.GetXmlDoc().text);
         alert(x.text());
         return -1;
      }
      dw_source.Retrieve(x);
      dw_source.SetSelectionMode(1);
      if (url::get(L"/sale/data/Gdn/source/base", arg.GetString(), x) != 1)
      if (xurl::get(L"/sale/data/Gdn/source/base", arg.GetString(), x) != 1)
      {
         alert(x.GetXmlDoc().text);
         alert(x.text());
         return -1;
      }
@@ -3886,55 +3887,55 @@
            "<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);
            "<Item Name='加拿大海关发票' Field='Remark'></Item>") +
            "<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>");
         x.loadXML(billnote);
         dw_billnote.Retrieve(x);
      }
      if (url::get(L"/sale/data/Gdn/source/gdnline", arg.GetString(), x) != 1)
      if (xurl::get(L"/sale/data/Gdn/source/gdnline", arg.GetString(), x) != 1)
      {
         alert(x.GetXml);
         alert(x.xml());
         return -1;
      }
      dw_item.Retrieve(x);
      dw_item.SetSelectionMode(1);
      if (url::get(L"/sale/data/Gdn/source/gdnlineex", arg.GetString(), x) != 1)
      if (xurl::get(L"/sale/data/Gdn/source/gdnlineex", arg.GetString(), x) != 1)
      {
         alert(x.GetXmlDoc().text);
         alert(x.text());
         return -1;
      }
      dw_invoiceItem.Retrieve(x);
      if (url::get(L"/sale/data/Gdn/source/profit", arg.GetString(), x) != 1)
      if (xurl::get(L"/sale/data/Gdn/source/profit", arg.GetString(), x) != 1)
      {
         alert(x.GetXmlDoc().text);
         alert(x.text());
         return -1;
      }
      dw_profit.Retrieve(x);
      if (url::get(L"/sale/data/Custom3/maint/custom/data", arg.GetString(), x) != 1)
      if (xurl::get(L"/sale/data/Custom3/maint/custom/data", arg.GetString(), x) != 1)
      {
         alert(x.GetXmlDoc().text);
         alert(x.text());
         return -1;
      }
      dw_custom.Retrieve(x);
      dw_customex.Retrieve(x);
      dw_custom.SetSelectionMode(1);
      if (url::get(L"/sale/data/Gdn/source/cdelement", arg.GetString(), x) != 1)
      if (xurl::get(L"/sale/data/Gdn/source/cdelement", arg.GetString(), x) != 1)
      {
         alert(x.GetXmlDoc().text);
         alert(x.text());
         return -1;
      }
      dw_cdelement.Retrieve(x);
      dw_cdelement.SetSelectionMode(1);
      //dw_cdelement.Retrieve(x);
      if (url::get(L"/sale/data/Gdn/source/container", arg.GetString(), x) != 1)
      if (xurl::get(L"/sale/data/Gdn/source/container", arg.GetString(), x) != 1)
      {
         alert(x.GetXmlDoc().text);
         alert(x.text());
         return -1;
      }
      dw_fcl.Retrieve(x);
@@ -3963,10 +3964,10 @@
         dPackages = dQty / sPRate.toDouble();
      }
      if ((dPackages * 1000).toInt() > dPackages.toInt() * 1000)
      if (((int)dPackages * 1000) > (int)dPackages * 1000)
         dPackages = dPackages + 1;
      return dPackages.toInt();
      return (int)dPackages;
   }
   xstring GetInvoiceID(xstring InvoiceNo)
@@ -3976,9 +3977,9 @@
      arg.AddArg(L"InvoiceNo", InvoiceNo);
      xaserver::ExecXQuery(GetServerUrl(), L"[gdnid.gdn.xq]", arg.GetString(), x);
      xstring InvoiceID1 = L"";
      if (x.GetXmlDoc())
      if (x)
      {
         InvoiceID1 = x.GetXmlDoc().text;
         InvoiceID1 = x.text();
      }
      arg.Free();
      x.Free();
@@ -4020,7 +4021,7 @@
         "<Item Name='装船通知' Field='Remark'></Item>" +
         "<Item Name='加拿大海关发票' Field='Remark'></Item>" +
         "<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>";
      x.LoadXml(billnote);
      x.loadXML(billnote);
      dw_billnote.Retrieve(x);
   }