|  |  | 
 |  |  |        | 
 |  |  |       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); | 
 |  |  | 
 |  |  |       dw_source.DwUpdateAllToEx(xsourcedoc); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |       if (xsource.xml() != L"") | 
 |  |  |       if ((xstring)xsource.xml() != L"") | 
 |  |  |       { | 
 |  |  |          KXMLDOMElement eitem1 = xitemdoc.documentElement(); | 
 |  |  |          if (eitem1) ebase.appendChild(eitem1); | 
 |  |  | 
 |  |  |     | 
 |  |  |       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); | 
 |  |  | 
 |  |  |       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); | 
 |  |  | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       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 | 
 |  |  |          { | 
 |  |  | 
 |  |  |       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) | 
 |  |  | 
 |  |  |          } | 
 |  |  |          CalcDraftAmount(); | 
 |  |  |          CalcProfit(); | 
 |  |  |          GetInsuranceAmountEx(); | 
 |  |  |  | 
 |  |  |          dw_base.Redraw(); | 
 |  |  |       } | 
 |  |  | 
 |  |  |       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); | 
 |  |  | 
 |  |  |             } | 
 |  |  |             else | 
 |  |  |             { | 
 |  |  |                xml xp = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate"); | 
 |  |  |                xml xp = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramS", L"item", L"cryrate"); | 
 |  |  |                if (xp.selectSingleNode(L"root/item/@value")) | 
 |  |  |                   exchangeRate = xp.selectSingleNode(L"root/item/@value").text(); | 
 |  |  |                dw_profit.SetItemString(1, L"ExchangeRate", exchangeRate); | 
 |  |  | 
 |  |  |             } | 
 |  |  |             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; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  | 
 |  |  |       if (x == L"userSalespersonID") | 
 |  |  |       { | 
 |  |  |          xstring sSalespersonID = dw_base.GetItemString(1, L"SalespersonID"); | 
 |  |  |          hdr->data = sSalespersonID; | 
 |  |  |          hdr->data = sSalespersonID.c_str(true); | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  | 
 |  |  |             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()); | 
 |  |  |             if (t.selectSingleNode(L"LCSignDate"))dw_base.SetItemString(1, L"LCSignDate", t.selectSingleNode(L"LCSignDate").text()); | 
 |  |  | 
 |  |  |       xstring exchRate = L""; | 
 |  |  |       xstring exchRate2 = L""; | 
 |  |  |  | 
 |  |  |       xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"prepareFeeRate"); | 
 |  |  |       xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramS", L"item", L"prepareFeeRate"); | 
 |  |  |       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"); | 
 |  |  |       xml x1 = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramS", L"item", L"cryrate"); | 
 |  |  |       if (x.selectSingleNode(L"root/item/@value")) | 
 |  |  |          exchRate2 = x1.selectSingleNode(L"root/item/@value").text(); | 
 |  |  |       double cryrate = exchRate2.toDouble(); | 
 |  |  | 
 |  |  |       xstring expRate = L""; | 
 |  |  |       xstring exchRate = L""; | 
 |  |  |  | 
 |  |  |       xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate"); | 
 |  |  |       xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramS", L"item", L"cryrate"); | 
 |  |  |       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"); | 
 |  |  |       x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramS", L"item", L"mgtFeeRate"); | 
 |  |  |       if (x.selectSingleNode(L"root/item/@value")) | 
 |  |  |          expRate = x.selectSingleNode(L"root/item/@value").text(); | 
 |  |  |       //double sale = dw_profit.GetItemDouble(1,L"ExchangeAmountEx"); | 
 |  |  | 
 |  |  |       xstring expRate = L""; | 
 |  |  |       xstring exchRate = L""; | 
 |  |  |  | 
 |  |  |       xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate"); | 
 |  |  |       xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramS", L"item", L"cryrate"); | 
 |  |  |       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"); | 
 |  |  |       x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramS", L"item", L"RiskFundAmount"); | 
 |  |  |       if (x.selectSingleNode(L"root/item/@value")) | 
 |  |  |          expRate = x.selectSingleNode(L"root/item/@value").text(); | 
 |  |  |       //alert(expRate); | 
 |  |  |       //double sale = dw_profit.GetItemDouble(1,L"ExchangeAmountEx"); | 
 |  |  |  | 
 |  |  |       xstring ETDEx = dw_base.GetItemString(1, L"ETD"); | 
 |  |  | 
 |  |  |       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"); | 
 |  |  | 
 |  |  |       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"); | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |       xstring exchangeRate = L""; | 
 |  |  |       exchangeRate = dw_profit.GetItemString(1, L"ExchangeRate"); | 
 |  |  |       if (exchangeRate == L"") { | 
 |  |  |          xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate"); | 
 |  |  |          xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramS", L"item", L"cryrate"); | 
 |  |  |          if (x.selectSingleNode(L"root/item/@value")) | 
 |  |  |             exchangeRate = x.selectSingleNode(L"root/item/@value").text(); | 
 |  |  |          dw_profit.SetItemString(1, L"ExchangeRate", exchangeRate); | 
 |  |  | 
 |  |  |  | 
 |  |  |    int CalcProfit() | 
 |  |  |    { | 
 |  |  |       GetInsuranceAmountEx(); | 
 |  |  |       evalSale(); | 
 |  |  |       evalManagementFee(); | 
 |  |  |       evalRiskFundAmount(); | 
 |  |  | 
 |  |  |  | 
 |  |  |    int onload() | 
 |  |  |    { | 
 |  |  |  | 
 |  |  |       SetArg(); | 
 |  |  |       xstring  userid = publiccode::GetUser().id; | 
 |  |  |       //trace(userid); | 
 |  |  |       haveUpdate = true; | 
 |  |  | 
 |  |  |       dw_custom.SetColumnState(L"ClassifyID", false); | 
 |  |  |       dw_custom.SetColumnState(L"AmountEx", false); | 
 |  |  |       //dw_custom.SetReadOnlyColumn(L"CustName",true); | 
 |  |  |       dw_custom.SetColumnState(L"LineNo", false); | 
 |  |  |       //dw_custom.SetColumnState(L"LineNo", false); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |       dw_customex = GetControl(L"dw_customex"); | 
 |  |  | 
 |  |  |       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"") |