xj qian
2025-04-21 a4344c9bada0722c6ef7fac5d95f29a110eea0f1
jrj/project/business/GDN3.maint.cpp
@@ -55,8 +55,8 @@
      xml x;
      
      xaserverarg& arg = *new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());
      xaserverarg arg ;
      arg.AddArg(L"scene", scene, L"xs:xstring");
      arg.AddArg(L"EntityID", EntityID, L"xs:xstring");
      arg.AddArg(L"EntityName", EntityName, L"xs:xstring");
@@ -197,7 +197,7 @@
      
      KXMLDOMDocument xitemdoc = xitem;
      dw_item.DwUpdateAllToEx(xitemdoc);
      if (xitem.xml() != L"")
      if ((xstring)xitem.xml() != L"")
      {
         KXMLDOMElement eitem = xitemdoc.documentElement();
         if (eitem) ebase.appendChild(eitem);
@@ -209,7 +209,7 @@
      dw_source.DwUpdateAllToEx(xsourcedoc);
      if (xsource.xml() != L"")
      if ((xstring)xsource.xml() != L"")
      {
         KXMLDOMElement eitem1 = xitemdoc.documentElement();
         if (eitem1) ebase.appendChild(eitem1);
@@ -219,7 +219,7 @@
   
      KXMLDOMDocument xcustomdoc = xcustom;
      dw_source.DwUpdateAllToEx(xcustomdoc);
      if (xcustom.xml() != L"")
      if ((xstring)xcustom.xml() != L"")
      {
         KXMLDOMElement eitem2 = xitemdoc.documentElement();
         if (eitem2) ebase.appendChild(eitem2);
@@ -248,12 +248,12 @@
      return 1;
   }
   xstring GetEntityID(int /*param*/ pr)
   xstring GetEntityID(LPARAM /*param*/ pr)
   {
      return InvoiceID;
   }
   xstring GetEntityName(int /*param*/ pr)
   xstring GetEntityName(LPARAM /*param*/ pr)
   {
      return L"GDN3";
   }
@@ -386,7 +386,7 @@
      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.ItemChangeTo(1, L"InsuredAmount", xstring(Amount_s));
      dw_base.SetItemDouble(1, L"PrivateCommissionAmount", ResearchCommissionRate_s + MiddlemanAmountRate_s);
      //dw_base.SetItemDouble(1,L"Cost",Cost_s);
@@ -505,7 +505,7 @@
      //if(dw_base.GetItemString(1,L"GoodsSource") == L"")
      //{
      //   alert(L"请选择货物产地(货物产地:开票工厂金额最大的工厂所属地)L");
      //   alert(L"请选择货物产地(货物产地:开票工厂金额最大的工厂所属地)");
      //   return 0;
   //   }
@@ -633,14 +633,15 @@
         }
      }
      xml xcustom;
      xstring error5;
      dw_custom.DwUpdateAllToEx(xcustom);
      if (xcustom.xml() != L"")
      if ((xstring)xcustom.xml() != L"")
      {
         xcustom = CustomView::UpdateCustomItem(dw_base.GetItemString(1, L"InvoiceNo"), xcustom.xml());
         if (!xcustom)
         {
            xstring error5 = xcustom.text();
             error5 = xcustom.text();
         }
         else
         {
@@ -700,7 +701,7 @@
      xml xcdelement ;
      
      dw_cdelement.DwUpdateAllToEx(xcdelement);
      if (xcdelement.xml() != L"")
      if ((xstring)xcdelement.xml() != L"")
      {
         xcdelement = CustomView::UpdateCustomElement(dw_base.GetItemString(1, L"InvoiceNo"), xcdelement.xml());
         if (!xcdelement)
@@ -869,7 +870,7 @@
               xstring ClassifyID = dw_custom.GetItemString(k, L"ClassifyID");
               xstring ClassifyName = dw_custom.GetItemString(k, L"CustName");
               xstring GroupNo = dw_custom.GetItemString(k, L"GroupNo");
               if (GroupNo != L"") ClassifyName += ClassifyName + L"(L" + GroupNo + L")L";
               if (GroupNo != L"") ClassifyName += ClassifyName + L"(" + GroupNo + L")";
               double LegalQty = dw_custom.GetItemDouble(k, L"LegalQty");
@@ -913,7 +914,7 @@
            xstring ClassifyID = dw_custom.GetItemString(k, L"ClassifyID");
            xstring ClassifyName = dw_custom.GetItemString(k, L"CustName");
            xstring GroupNo = dw_custom.GetItemString(k, L"GroupNo");
            if (GroupNo != L"") ClassifyName += ClassifyName + L"(L" + GroupNo + L")L";
            if (GroupNo != L"") ClassifyName += ClassifyName + L"(" + GroupNo + L")";
            double VQuantity = dw_custom.GetItemDouble(k, L"Quantity");
            double VAmount = dw_custom.GetItemDouble(k, L"Amount");
            double qty = 0.0;
@@ -956,7 +957,7 @@
   bool validProfit()
   {
      double amt = dw_profit.GetItemString(1, L"ProfitAmountEx");
      double amt = dw_profit.GetItemDouble(1, L"ProfitAmountEx");
      if (amt < 0.0)
      {
         if (dw_profit.GetItemString(1, L"Note") == L"")
@@ -1005,7 +1006,7 @@
      KXMLDOMElement e = dw_item.GetRowElement(nRow);
      KXMLDOMNode n = e.cloneNode(-1);
      x.documentElement().appendChild(n);
      n.Release();
      xstring val = x.xml();
      trace(L"=======L" + val + L"=======L");
@@ -1083,7 +1084,7 @@
      KXMLDOMElement e = dw_item.GetRowElement(nRow);
      KXMLDOMNode n = e.cloneNode(-1);
      x.documentElement().appendChild(n);
      n.Release();
      xstring val = x.xml();
      trace(L"123=======L" + val + L"=======123");
@@ -1414,6 +1415,7 @@
         }
         CalcDraftAmount();
         CalcProfit();
         GetInsuranceAmountEx();
         dw_base.Redraw();
      }
@@ -1527,7 +1529,10 @@
      else if (col == L"ETD")
      {
         xstring ETD = dw_base.GetItemString(1, L"ETD");
         xstring CustomerID = dw_base.GetItemString(1, L"CustomerID");
         xstring exchangeRate = L"";
         xstring PremiumRate = L"";
         if (ETD != L"")
         {
            trace(ETD);
@@ -1548,10 +1553,44 @@
            }
            evalManagementFee();
            evalRiskFundAmount();
         }
            xml x1 = ViewObject::RetrieveData(L"/sale/data/GDN3/GetInsuranceRateEx", L"ETD", ETD, L"CustomerID", CustomerID);
            if (x1.selectSingleNode(L"root/item/@value"))
               PremiumRate = x1.selectSingleNode(L"root/item/@value").text();
            if (PremiumRate != L"")
            {
               dw_base.SetItemString(1, L"InsuranceRateEx", PremiumRate);
               GetInsuranceAmountEx();
            }
         }
         dw_profit.Redraw();
         dw_base.Redraw();
      }
      else if (col == L"InsuredAmount" || col == L"InsuranceRateEx")
      {
         GetInsuranceAmountEx();
      }
      return 1;
   }
   int GetInsuranceAmountEx()
   {
      double InsuranceRateEx = dw_base.GetItemDouble(1, L"InsuranceRateEx");
      double InsuredAmount = dw_base.GetItemDouble(1, L"InsuredAmount");
      double ExchangeAmountEx = dw_profit.GetItemDouble(1, L"ExchangeAmountEx");
      dw_base.SetItemDouble(1, L"InsuranceAmountEx", InsuranceRateEx * InsuredAmount / 100);
      dw_profit.SetItemDouble(1, L"SinosurAmount", InsuranceRateEx * InsuredAmount / 100);
      dw_profit.SetItemDouble(1, L"ExchangeAmountEx", ExchangeAmountEx + (InsuranceRateEx * InsuredAmount / 100));
      evalProfitAmount();
      //dw_profit.ItemChangeTo(1,"SinosurAmount",(InsuranceRateEx * InsuredAmount/100).toString());
      dw_base.Redraw();
      dw_profit.Redraw();
      return 1;
   }
@@ -1868,7 +1907,7 @@
      if (x == L"userSalespersonID")
      {
         xstring sSalespersonID = dw_base.GetItemString(1, L"SalespersonID");
         hdr->data = sSalespersonID;
         hdr->data = sSalespersonID.c_str(true);
      }
      return 1;
   }
@@ -1902,7 +1941,7 @@
      CheckCDLine();
      CheckGW();
      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"");
@@ -2132,7 +2171,7 @@
               if (o.selectSingleNode(L"VATRates"))
               {
                  xstring str1 = o.selectSingleNode(L"VATRates").text();
                  if (str1.find(L",L") >= 0) str1 = str1.left(str1.find(L",L"));
                  if (str1.find(L",") >= 0) str1 = str1.left(str1.find(L","));
                  dw_custom.SetItemString(i, L"VATRates", str1);
               }
               if (o.selectSingleNode(L"CustEName"))
@@ -2185,7 +2224,7 @@
               if(o.selectSingleNode(L"VATRates"))
               {
                  xstring str1 = o.selectSingleNode(L"VATRates").text();
                  if(str1.find(L",L")) str1 = str1.left(str1.find(L",L"));
                  if(str1.find(L",")) str1 = str1.left(str1.find(L","));
                  dw_custom.SetItemString(i,L"VATRates",str1);
               }
               if(o.selectSingleNode(L"CustEName"))
@@ -2440,7 +2479,7 @@
               if (o.selectSingleNode(L"VATRates"))
               {
                  xstring str1 = o.selectSingleNode(L"VATRates").text();
                  if (str1.find(L",L")) str1 = str1.left(str1.find(L",L"));
                  if (str1.find(L",")) str1 = str1.left(str1.find(L","));
                  dw_custom.SetItemString(i, L"VATRates", str1);
                  dw_customex.SetItemString(i, L"VATRates", str1);
               }
@@ -2505,6 +2544,7 @@
      arg.AddArg(L"InvoiceNo", dw_base.GetItemString(1, L"InvoiceNo"));
      int p = arg;
      OpenWindow(L"dev:xpage[select.item.po.vx]", p);
      xstring str = arg.GetArgString(L"items");
      if (str != L"")
      {
@@ -2614,7 +2654,7 @@
               }
               else if (SONos.find(SONo) < 0)
               {
                  SONos += L",L" + SONo;
                  SONos += L"," + SONo;
                  costs += cost;
               }
            }
@@ -2624,7 +2664,7 @@
               xstring CustomerPONo = t.selectSingleNode(L"CustomerPONo").text();
               if (OrderNos == L"")
                  OrderNos = CustomerPONo;
               else if (OrderNos.find(CustomerPONo) < 0) OrderNos += L",L" + CustomerPONo;
               else if (OrderNos.find(CustomerPONo) < 0) OrderNos += L"," + CustomerPONo;
            }
            if (t.selectSingleNode(L"OperationTips"))
@@ -2649,6 +2689,11 @@
            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());
            if (t.selectSingleNode(L"UOCCode"))dw_base.SetItemString(1, L"UOCCode", t.selectSingleNode(L"UOCCode").text());
            if (t.selectSingleNode(L"ApprovalIimit"))dw_base.SetItemString(1, L"ApprovalIimit", t.selectSingleNode(L"ApprovalIimit").text());
            if (t.selectSingleNode(L"InsuranceRateEx"))dw_base.SetItemString(1, L"InsuranceRateEx", t.selectSingleNode(L"InsuranceRateEx").text());
            if (t.selectSingleNode(L"AvailableIimits"))dw_base.SetItemString(1, L"AvailableIimits", t.selectSingleNode(L"AvailableIimits").text());
            //trace(L"*****************");
            if (t.selectSingleNode(L"LCNo"))dw_base.SetItemString(1, L"LCNo", t.selectSingleNode(L"LCNo").text());
@@ -2769,7 +2814,6 @@
      arg.AddArg(L"CustomerID", dw_base.GetItemString(1, L"CustomerID"));
      arg.AddArg(L"InvoiceNo", dw_base.GetItemString(1, L"InvoiceNo"));
      arg.AddArg(L"SONo", dw_base.GetItemString(1, L""));
      int p = arg;
      if (dw_base.GetItemString(1, L"CustomerID") == L"")
      {
         OpenWindow(L"dev:xpage[SelectItem.New.GDN.vx]", arg);
@@ -2783,7 +2827,7 @@
      }
      else
      {
         OpenWindow(L"dev:xpage[select.gdnitem.so.vx]", p);
         OpenWindow(L"dev:xpage[select.gdnitem.so.vx]", arg);
      }
      xstring str = arg.GetArgString(L"items");
@@ -2908,7 +2952,7 @@
         }
         else if (SONo_s.find(SONo) < 0)
         {
            SONo_s += L",L" + SONo;
            SONo_s += L"," + SONo;
         }
         xstring PONo = dw_item.GetItemString(k, L"PONo");
         if (PONo_s == L"")
@@ -2917,7 +2961,7 @@
         }
         else if (PONo_s.find(PONo) < 0)
         {
            PONo_s += L",L" + PONo;
            PONo_s += L"," + PONo;
         }
      }
      dw_base.SetItemString(1, L"OrderNos", PONo_s);
@@ -3187,7 +3231,7 @@
            xaserverarg& arg2 = *new xaserverarg;
            
            arg2.AddArg(L"InvoiceNo", dw_base.GetItemString(1, L"InvoiceNo"));
            //arg2.AddArg(L"HWND", GetHWND().toString());
            //arg2.AddArg(L"HWND", xstring((__int64)GetHWND()));
            arg2.SetParam(L"HWND", (LPARAM)GetHWND());
            OpenWindow(L"dev:xpage[GDNSourcePaperCard.vx]",(LPARAM)&arg2);
         }
@@ -3352,13 +3396,13 @@
                  if (n)
                  {
                     tax = xstring(n.text()).toDouble();
                     n.Release();
                  }
                  n = o.selectSingleNode(L"VATRefundRate");
                  if (n)
                  {
                     retax = xstring(n.text()).toDouble();
                     n.Release();
                  }
                  o.Release();
               }
@@ -3514,6 +3558,7 @@
      dw_profit.SetItemString(1, L"Amount", dw_base.GetItemString(1, L"Amount"));
      dw_profit.SetItemString(1, L"Freight", dw_base.GetItemString(1, L"Freight"));
      dw_profit.SetItemString(1, L"InsuranceAmount", dw_base.GetItemString(1, L"InsuranceAmount"));
      dw_profit.SetItemString(1, L"SinosurAmount", dw_base.GetItemString(1, L"InsuranceAmountEx"));
      //dw_profit.SetItemString(1,L"CommissionAmount",dw_base.GetItemString(1,L"CommissionAmount"));
      double comm1 = dw_base.GetItemDouble(1, L"CommissionAmount");
@@ -3541,6 +3586,7 @@
      ttl -= dw_base.GetItemDouble(1, L"CommissionAmount");
      ttl -= dw_base.GetItemDouble(1, L"PrivateCommissionAmount");
      ttl -= dw_base.GetItemDouble(1, L"DiscountAmount");
      ttl -= dw_base.GetItemDouble(1, L"InsuranceAmountEx");
      ttl += dw_profit.GetItemDouble(1, L"SaleExternCost");
@@ -3634,6 +3680,7 @@
   int CalcProfit()
   {
      GetInsuranceAmountEx();
      evalSale();
      evalManagementFee();
      evalRiskFundAmount();
@@ -3678,7 +3725,7 @@
   int OnAttachEvent()
   {
      //绑定工具条点击事件
      AttachEvent(L"WM_XCOMMAND", L"DWV_CLICKED", (FEvent)&GDN3MaintWin::OnXCommand);
      AttachEvent(L"WM_XCOMMAND", (FEvent)&GDN3MaintWin::OnXCommand);
      //获取焦点事件,用于重置工具条
      AttachEvent(L"WM_SETFOCUS", (FEvent)&GDN3MaintWin::OnSetFocus);
@@ -4018,7 +4065,7 @@
   int onload()
   {
      SetArg();
      xstring  userid = publiccode::GetUser().id;
      //trace(userid);
      haveUpdate = true;
@@ -4129,7 +4176,7 @@
      if (GetWinParam())
      {
         xaserverarg arg_param=GetArg();
         xstring xs = arg_param.GetString();
         InvoiceNo = arg_param.GetArgString(L"InvoiceNo");
         if (InvoiceNo == L"") InvoiceNo = arg_param.GetArgString(L"EntityNo");
         if (InvoiceNo == L"")