#include <wobject/xstring.hpp>
|
#include <wobject/xdouble.hpp>
|
#include <xcontrol/xtreeview.hpp>
|
#include <xcontrol/xdwgrid.hpp>
|
#include <xcontrol/ximageview.hpp>
|
|
#include "vbusiness/vframe/maint.vframe.vbusiness.hpp"
|
#include "viewobject/view.base.hpp"
|
#include "viewobject/saleorder.view.hpp"
|
#include "viewobject/quote.view.hpp"
|
|
class __declspec(dllexport) GDN3MaintWin : public maint
|
{
|
public:
|
GDN3MaintWin(void* implPtr, HWND hWnd) :maint(implPtr, hWnd) {}
|
public:
|
static GDN3MaintWin* CreateInstance(void* implPtr, void* hWnd)
|
{
|
GDN3MaintWin* pWin = new GDN3MaintWin(implPtr, (HWND)hWnd);
|
return pWin;
|
}
|
public:
|
xdwtable dw_base;
|
xdwgrid dw_item;
|
xdwgrid dw_custom;
|
xdwtable dw_profit;
|
xdwgrid dw_source;
|
xdwgrid dw_cdelement;
|
xdwgrid dw_invoiceItem;
|
xdwgrid dw_customex;
|
xdwgrid dw_billnote;
|
xdwgrid dw_doclist;
|
xdwgrid dw_fcl;
|
|
xstring InvoiceNo;
|
xstring InvoiceID;
|
bool readonly;
|
bool haveUpdate;
|
xnode m_agentNode; //Agent Condition
|
xstring tabname;
|
bool datareading;
|
bool readonlyEx;
|
xstring searchStr;
|
//xstring ApprovalStatus;
|
//xdwgrid dw_element;
|
|
int SetAgent(xstring scene, xstring EntityName, xstring EntityID)
|
{
|
xstring xfNodeAgentArea = L"agentarea";
|
xnode anode = GetAgentNode(xfNodeAgentArea);
|
KXMLDOMElement xframeElement = GetElement();
|
KXMLDOMNode agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[1]/*");
|
|
xml x;
|
|
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");
|
xurl::get(L"/workflow/query/datarole/" + EntityName, arg.GetString(), x);
|
|
xstring sNodes;
|
sNodes = L"datarole/actions/action[contains(@scene,'" + scene + L"')]";
|
KXMLDOMNodeList nlist = x.selectNodes(sNodes);
|
int index;
|
int nlen = nlist.length();
|
KXMLDOMElement ele;
|
|
xstring tools = L"<vbox class=''>";
|
if (scene == L"list") tools += L"<xspace height='12'/>";
|
|
haveUpdate = false;
|
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 image;
|
xstring src = L"";
|
if (ele.selectSingleNode(L"@image"))
|
image = ele.selectSingleNode(L"@image").text();
|
else
|
image = L"0 22";
|
|
if (ele.selectSingleNode(L"@src"))
|
src = ele.selectSingleNode(L"@src").text();
|
|
xstring tool;
|
if (name.find(L"bill.update") >= 0) haveUpdate = true;
|
if (src != L"")
|
tool = L"<xtoolbutton src='" + src + L"' caption='" + label + L"' name='action:" + name + L"' height='23' style='background-color:none #ceecce none #ffffff'/>";
|
else
|
tool = L"<xtoolbutton image='" + image + L"' caption='" + label + L"' name='action:" + name + L"' height='23' style='background-color:none #ceecce none #ffffff'/>";
|
tools += tool;
|
}
|
if (agent)
|
{
|
nlist = agent.selectNodes(L".//xtoolbutton");
|
nlen = nlist.length();
|
for (index = 0; index < nlen; index++)
|
{
|
ele = nlist.item(index);
|
xstring tmp = ele.xml();
|
tools += tmp;
|
}
|
}
|
tools += L"</vbox>";
|
SetAgentNodeContent(anode, tools);
|
|
return 1;
|
}
|
|
int OnMakeGdnLineEx()
|
{
|
int cnt = dw_invoiceItem.GetRowCount();
|
for (int k = 1; k <= cnt; k++) dw_invoiceItem.DeleteRow(1);
|
|
for (int row = 1; row <= dw_item.GetRowCount(); ++row)
|
{
|
dw_invoiceItem.InsertRow(0);
|
dw_invoiceItem.SetItemString(row, L"ClassifyID", dw_item.GetItemString(row, L"ClassifyID"));
|
dw_invoiceItem.SetItemDisplayString(row, L"ClassifyID", dw_item.GetItemDisplayString(row, L"ClassifyID"));
|
|
dw_invoiceItem.SetItemString(row, L"Quantity", dw_item.GetItemString(row, L"Quantity"));
|
dw_invoiceItem.SetItemString(row, L"Packages", dw_item.GetItemString(row, L"Packages"));
|
dw_invoiceItem.SetItemString(row, L"Amount", dw_item.GetItemString(row, L"Amount"));
|
dw_invoiceItem.SetItemString(row, L"UnitPrice", dw_item.GetItemString(row, L"UnitPrice"));
|
|
dw_invoiceItem.SetItemString(row, L"ContainerNo", dw_item.GetItemString(row, L"ContainerNo"));
|
dw_invoiceItem.SetItemString(row, L"GoodsNo", dw_item.GetItemString(row, L"GoodsNo"));
|
dw_invoiceItem.SetItemString(row, L"CustomerItemNo", dw_item.GetItemString(row, L"CustomerItemNo"));
|
dw_invoiceItem.SetItemString(row, L"PONo", dw_item.GetItemString(row, L"PONo"));
|
dw_invoiceItem.SetItemString(row, L"EName", dw_item.GetItemString(row, L"EName"));
|
dw_invoiceItem.SetItemString(row, L"Mark", dw_item.GetItemString(row, L"Mark"));
|
dw_invoiceItem.SetItemString(row, L"GroupNo", dw_item.GetItemString(row, L"GroupNo"));
|
|
dw_invoiceItem.SetItemString(row, L"UnitPrice", dw_item.GetItemString(row, L"UnitPrice"));
|
dw_invoiceItem.SetItemString(row, L"CurrencyCode", dw_base.GetItemString(1, L"CurrencyCode"));
|
dw_invoiceItem.SetItemString(row, L"PackingRate", dw_item.GetItemString(row, L"PackingRate"));
|
dw_invoiceItem.SetItemString(row, L"VolumeDesc", dw_item.GetItemString(row, L"VolumeDesc"));
|
dw_invoiceItem.SetItemString(row, L"VolumePerPkg", dw_item.GetItemString(row, L"VolumePerPkg"));
|
dw_invoiceItem.SetItemString(row, L"Volume", dw_item.GetItemString(row, L"Volume"));
|
dw_invoiceItem.SetItemString(row, L"NWPerPkg", dw_item.GetItemString(row, L"NWPerPkg"));
|
dw_invoiceItem.SetItemString(row, L"NW", dw_item.GetItemString(row, L"NW"));
|
dw_invoiceItem.SetItemString(row, L"GWPerPkg", dw_item.GetItemString(row, L"GWPerPkg"));
|
dw_invoiceItem.SetItemString(row, L"GW", dw_item.GetItemString(row, L"GW"));
|
dw_invoiceItem.SetItemString(row, L"PackageL", dw_item.GetItemString(row, L"PackageL"));
|
dw_invoiceItem.SetItemString(row, L"PackageW", dw_item.GetItemString(row, L"PackageW"));
|
dw_invoiceItem.SetItemString(row, L"PackageH", dw_item.GetItemString(row, L"PackageH"));
|
|
xstring voldesc = dw_item.GetItemString(row, L"PackageL") + L"*" +
|
dw_item.GetItemString(row, L"PackageW") + L"*" +
|
dw_item.GetItemString(row, L"PackageH");
|
dw_invoiceItem.SetItemString(row, L"VolumeDesc", voldesc);
|
|
dw_invoiceItem.SetItemString(row, L"InnerQty", dw_item.GetItemString(row, L"InnerQty"));
|
dw_invoiceItem.SetItemString(row, L"CommissionRate", dw_item.GetItemString(row, L"CommissionRate"));
|
dw_invoiceItem.SetItemString(row, L"DiscountRate", dw_item.GetItemString(row, L"DiscountRate"));
|
|
dw_invoiceItem.SetItemString(row, L"ItemID", dw_item.GetItemString(row, L"ItemID"));
|
dw_invoiceItem.SetItemString(row, L"LineType", dw_item.GetItemString(row, L"LineType"));
|
dw_invoiceItem.SetItemString(row, L"LineNo", dw_item.GetItemString(row, L"LineNo"));
|
dw_invoiceItem.SetItemString(row, L"Assortment", dw_item.GetItemString(row, L"Assortment"));
|
dw_invoiceItem.SetItemString(row, L"GDNID", dw_item.GetItemString(row, L"GDNID"));
|
dw_invoiceItem.SetItemString(row, L"SOLineID", dw_item.GetItemString(row, L"SOLineID"));
|
|
dw_invoiceItem.SetItemString(row, L"UOMCode", dw_item.GetItemString(row, L"UOMCode"));
|
dw_invoiceItem.SetItemDisplayString(row, L"UOMCode", dw_item.GetItemDisplayString(row, L"UOMCode"));
|
|
dw_invoiceItem.SetItemString(row, L"KOPCode", dw_item.GetItemString(row, L"KOPCode"));
|
dw_invoiceItem.SetItemDisplayString(row, L"KOPCode", dw_item.GetItemDisplayString(row, L"KOPCode"));
|
|
KXMLDOMElement e = dw_item.GetRowElement(row);
|
dw_invoiceItem.SetItemString(row, L"GDNLineID", e.getAttribute(L"guid"));
|
}
|
|
return 1;
|
}
|
|
xstring GetEntityData(LPARAM pr)
|
{
|
dw_base.AcceptText();
|
dw_source.AcceptText();
|
dw_item.AcceptText();
|
dw_custom.AcceptText();
|
|
xml xbase;
|
|
dw_base.DwUpdateAllTo(xbase);
|
|
KXMLDOMElement ebase = xbase.documentElement();
|
|
xml xitem ;
|
|
KXMLDOMDocument xitemdoc = xitem;
|
dw_item.DwUpdateAllToEx(xitemdoc);
|
if (xitem.xml() != L"")
|
{
|
KXMLDOMElement eitem = xitemdoc.documentElement();
|
if (eitem) ebase.appendChild(eitem);
|
}
|
|
xml xsource;
|
|
KXMLDOMDocument xsourcedoc = xsource;
|
dw_source.DwUpdateAllToEx(xsourcedoc);
|
|
|
if (xsource.xml() != L"")
|
{
|
KXMLDOMElement eitem1 = xitemdoc.documentElement();
|
if (eitem1) ebase.appendChild(eitem1);
|
}
|
|
xml xcustom;
|
|
KXMLDOMDocument xcustomdoc = xcustom;
|
dw_source.DwUpdateAllToEx(xcustomdoc);
|
if (xcustom.xml() != L"")
|
{
|
KXMLDOMElement eitem2 = xitemdoc.documentElement();
|
if (eitem2) ebase.appendChild(eitem2);
|
}
|
|
return ebase.xml();
|
}
|
|
|
int SetAgentEx()
|
{
|
SetAgent(L"maint", L"GDN3", InvoiceID);
|
if (readonlyEx && tabname == L"cdelement")
|
SwitchLayer(L"agent_" + tabname, L"agentareaframe");
|
else if (haveUpdate && !readonly)
|
SwitchLayer(L"agent_" + tabname, L"agentareaframe");
|
|
return 1;
|
}
|
|
//½¹µã¼¤»î´¦Àíº¯Êý
|
int OnSetFocus(TEvent* evt, int param)
|
{
|
//ÖØÖù¤¾ßÌõ
|
SetAgentEx();
|
return 1;
|
}
|
|
xstring GetEntityID(int /*param*/ pr)
|
{
|
return InvoiceID;
|
}
|
|
xstring GetEntityName(int /*param*/ pr)
|
{
|
return L"GDN3";
|
}
|
|
xstring GetGuid()
|
{
|
return publiccode::GetGuid();
|
}
|
|
int SetCustomerHabit(xstring CustomerID)
|
{
|
xml x = ViewObject::RetrieveData(L"/sale/data/GDN/habit/customer", L"CustomerID", CustomerID);
|
if (x)
|
{
|
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());
|
if (e.selectSingleNode(L"@_displaystring"))
|
dw_base.SetItemDisplayString(1, e.tagName(), e.selectSingleNode(L"@_displaystring").text());
|
}
|
}
|
return 1;
|
}
|
|
int PoTotal(int row)
|
{
|
double Quantity_s = 0.0;
|
double Amount_s = 0.0;
|
double Vol_s = 0.0;
|
double Price = 0.0;
|
if (row < 1 or row > dw_item.GetRowCount()) return 1;
|
|
KXMLDOMElement e = dw_item.GetRowElement(row);
|
xstring GDNLineID = e.getAttribute(L"guid");
|
double Quantity = dw_item.GetItemDouble(row, L"Quantity");
|
double SAmount = dw_item.GetItemDouble(row, L"Amount");
|
for (int k = 1; k <= dw_source.GetRowCount(); ++k)
|
{
|
xstring POGDNLineID = dw_source.GetItemString(k, L"GDNLineID");
|
if (GDNLineID == POGDNLineID) {
|
|
double Amount = dw_source.GetItemDouble(k, L"BuyAmount");
|
Amount_s += Amount;
|
}
|
}
|
dw_item.SetItemDouble(row, L"BuyAmount", Amount_s);
|
Price = Amount_s / Quantity;
|
Vol_s = Amount_s / SAmount;
|
dw_item.SetItemDouble(row, L"BuyUnitPrice", Price);
|
dw_item.SetItemDouble(row, L"CostRate", Vol_s);
|
|
return 1;
|
}
|
|
int PoTotal()
|
{
|
double Quantity_s = 0.0;
|
double Amount_s = 0.0;
|
double Vol_s = 0.0;
|
double Price = 0.0;
|
double PackUnitPrice_s = 0.0;
|
for (int row = 1; row <= dw_item.GetRowCount(); ++row)
|
{
|
for (int k = 1; k <= dw_source.GetRowCount(); ++k) {
|
//double UnitPrice = dw_source.GetItemDouble(row,L"UnitPrice");
|
KXMLDOMElement e = dw_item.GetRowElement(row);
|
xstring GDNLineID = e.getAttribute(L"guid");
|
double Amount = dw_source.GetItemDouble(k, L"BuyAmount");
|
double Quantity = dw_item.GetItemDouble(row, L"Quantity");
|
double SAmount = dw_item.GetItemDouble(row, L"Amount");
|
double PackUnitPrice = dw_item.GetItemDouble(row, L"PackUnitPrice");
|
//xstring = dw_item.GetItemString(row,L"GDNLineID");
|
xstring POGDNLineID = dw_source.GetItemString(k, L"GDNLineID");
|
if (GDNLineID == POGDNLineID) {
|
Amount_s += Amount;
|
dw_item.SetItemDouble(row, L"BuyAmount", Amount_s);
|
Price = Amount_s / Quantity;
|
Vol_s = Amount_s / SAmount;
|
dw_item.SetItemDouble(row, L"BuyUnitPrice", Price);
|
dw_item.SetItemDouble(row, L"CostRate", Vol_s);
|
}
|
}
|
Amount_s = 0.0;
|
}
|
return 1;
|
}
|
|
int calcTotal()
|
{
|
double Quantity_s = 0.0;
|
int Packages_s = 0.0;
|
double GW_s = 0.0;
|
double NW_s = 0.0;
|
double Amount_s = 0.0;
|
double Vol_s = 0.0;
|
double Price = 0.0;
|
double Cost_s = 0.0;
|
double ResearchCommissionRate_s = 0.0;
|
double MiddlemanAmountRate_s = 0.0;
|
|
for (int row = 1; row <= dw_item.GetRowCount(); row++)
|
{
|
double Quantity = dw_item.GetItemDouble(row, L"Quantity");
|
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");
|
double ResearchCommissionRate = dw_item.GetItemDouble(row, L"ResearchCommissionRate");
|
double MiddlemanAmountRate = dw_item.GetItemDouble(row, L"MiddlemanAmountRate");
|
|
double UnitPrice = dw_item.GetItemDouble(row, L"UnitPrice");
|
double Amount = dw_item.GetItemDouble(row, L"Amount");
|
double Cost = dw_item.GetItemDouble(row, L"Cost");
|
Quantity_s += Quantity;
|
Packages_s += Packages;
|
GW_s += GW;
|
NW_s += NW;
|
Amount_s += Amount;
|
Vol_s += xdouble(Vol).round(2);
|
Cost_s += Cost;
|
ResearchCommissionRate_s += ResearchCommissionRate;
|
MiddlemanAmountRate_s += MiddlemanAmountRate;
|
}
|
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", 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);
|
|
//dw_base.SetItemDouble(1,L"Cost",Cost_s);
|
//dw_base.SetItemDouble(1,L"DraftAmount",Amount_s);
|
return 1;
|
}
|
|
|
//overroad
|
bool NeedNotifyUpdate()
|
{
|
if (readonly && !readonlyEx) return false;
|
if (!haveUpdate) return false;
|
return true;
|
}
|
|
//overroad
|
int DoUpdate(bool showSuccess)
|
{
|
if (readonly && !readonlyEx)
|
{
|
alert(L"µ±Ç°×´Ì¬²»Äܱ£´æ!");
|
return 1;
|
}
|
|
dw_base.AcceptText();
|
dw_source.AcceptText();
|
dw_profit.AcceptText();
|
dw_invoiceItem.AcceptText();
|
dw_fcl.AcceptText();
|
dw_cdelement.AcceptText();
|
xstring InvoiceNo1 = dw_base.GetItemString(1, L"InvoiceNo");
|
if (InvoiceNo1 == L"")
|
{
|
alert(L"ÇëÊäÈëÍâÔ˱àºÅ");
|
return 0;
|
}
|
else if (InvoiceID == L"") {
|
xml check_x = ViewObject::RetrieveData(L"/sale/data/GDN/source/FindByInvoiceNo", L"InvoiceNo", InvoiceNo1);
|
if (check_x)
|
{
|
xstring cnt = check_x.documentElement().getAttribute(L"count");
|
if (cnt != L"0") {
|
alert(L"ÍâÔ˱àºÅÒÑ´æÔÚ£¬ÇëÖØÐÂÌîд£¡");
|
return 0;
|
}
|
}
|
}
|
|
if (dw_base.GetItemString(1, L"CompanyID") == L"")
|
{
|
alert(L"ÇëÊäÈë¾Óªµ¥Î»");
|
return 0;
|
}
|
|
if (dw_base.GetItemString(1, L"ETD") == L"")
|
{
|
alert(L"ÇëÊäÈëÔ¤Åä´¬ÆÚ");
|
return 0;
|
}
|
|
if (dw_base.GetItemString(1, L"OperationTips") == L"")
|
{
|
alert(L"ÇëÊäÈë²Ù×÷Ìáʾ");
|
return 0;
|
}
|
|
/*if(dw_base.GetItemString(1,L"PriceTerm")==L"")
|
{
|
alert(L"ÇëÊäÈë¼Û¸ñÌõ¿î");
|
return 0;
|
}
|
if(dw_base.GetItemString(1,L"PaymentTerm")==L"")
|
{
|
alert(L"ÇëÊäÈë»ã¿î·½Ê½");
|
return 0;
|
}
|
if(dw_base.GetItemString(1,L"Country") == L"")
|
{
|
alert(L"ÇëÑ¡ÔñóÒ×¹ú±ð");
|
return 0;
|
}
|
if(dw_base.GetItemString(1,L"TradeType") == L"")
|
{
|
alert(L"ÇëÑ¡ÔñóÒ×·½Ê½");
|
return 0;
|
}
|
if(dw_base.GetItemString(1,L"POL") == L"")
|
{
|
alert(L"ÇëÑ¡Ôñ³ö¿Ú¿Ú°¶");
|
return 0;
|
}
|
if(dw_base.GetItemString(1,L"POD") == L"")
|
{
|
alert(L"ÇëÑ¡ÔñÄ¿µÄ¸Û");
|
return 0;
|
}
|
if(dw_base.GetItemString(1,L"TransportMode") == L"")
|
{
|
alert(L"ÇëÑ¡ÔñÔËÊ䷽ʽ");
|
return 0;
|
}*/
|
/*
|
if(dw_base.GetItemString(1,L"Mark") == L"")
|
{
|
alert(L"ÇëÊäÈëßéÍ·(ÎÞßéÍ·£¬ÇëÌî¡°N/M¡±)L");
|
return 0;
|
}*/
|
|
/*
|
if(dw_base.GetItemString(1,L"FinalCountry") == L"")
|
{
|
alert(L"ÇëÑ¡ÔñÔ˵ֹú");
|
return 0;
|
}*/
|
|
//if(dw_base.GetItemString(1,L"GoodsSource") == L"")
|
//{
|
// alert(L"ÇëÑ¡Ôñ»õÎï²úµØ(»õÎï²úµØ:¿ªÆ±¹¤³§½ð¶î×î´óµÄ¹¤³§ËùÊôµØ)L");
|
// return 0;
|
// }
|
|
//calcTotal();
|
|
xstring str = L"";
|
dw_base.AcceptText();
|
xml xbase;
|
|
KXMLDOMDocument xbasedoc = xbase;
|
dw_base.DwUpdateAllTo(xbasedoc);
|
|
xaserverarg arg = GDNView::MakeArg();
|
//if(dw_billnote.DeletedCount()+dw_billnote.ModifiedCount() > 0)
|
//{
|
xml xbillnote ;
|
|
dw_billnote.DwUpdateAllToEx(xbillnote);
|
|
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.xml());
|
if (xurl::get(L"/sale/data/Gdn3/update/base", arg.GetString(), xbase) != 1)
|
{
|
xstring error = xbase.text();
|
alert(L"err:" + error);
|
alert(L"»ù±¾ÐÅÏ¢±£´æÊ§°Ü!");
|
return -1;
|
}
|
str = xbase.documentElement().getAttribute(L"text");
|
if (str == L"false")
|
{
|
alert(L"»ù±¾ÐÅÏ¢±£´æÊ§°Ü!");
|
return -1;
|
}
|
dw_base.ResetUpdateStatus();
|
|
dw_profit.AcceptText();
|
xml xprofit;
|
|
KXMLDOMDocument xprofitdoc = xprofit;
|
dw_profit.DwUpdateAllTo(xprofitdoc);
|
xaserverarg arg3 = GDNView::MakeArg();
|
arg3.AddArg(L"content", xprofit.xml());
|
if (xurl::get(L"/sale/data/Gdn/update/profit", arg3.GetString(), xprofit) != 1)
|
{
|
xstring error4 = xprofit.text();
|
}
|
else
|
{
|
str = xprofit.documentElement().getAttribute(L"text");
|
if (str == L"false")
|
{
|
alert(L"Ó¯¿÷ÐÅÏ¢±£´æÊ§°Ü!");
|
return -1;
|
}
|
dw_profit.ResetUpdateStatus();
|
}
|
|
dw_item.AcceptText();
|
|
int k;
|
for (k = 1; k <= dw_item.GetRowCount(); k++)
|
{
|
if (dw_item.GetItemString(k, L"SeqNo") == L"")
|
{
|
dw_item.SetItemString(k, L"SeqNo", xstring(k));
|
}
|
}
|
|
xml xitem ;
|
|
KXMLDOMDocument xitemdoc = xitem;
|
dw_item.DwUpdateAllToEx(xitemdoc);
|
//dw_base.DwUpdateAllTo(xitemdoc);
|
xaserverarg arg1 = GDNView::MakeArg();
|
arg1.AddArg(L"content", xitem.xml());
|
|
if (xurl::get(L"/sale/data/Gdn/update/item", arg1.GetString(), xitem) != 1)
|
{
|
xstring error1 = xitem.text();
|
}
|
else
|
{
|
str = xitem.documentElement().getAttribute(L"text");
|
if (str == L"false")
|
{
|
alert(L"ÉÌÆ·ÐÅÏ¢±£´æÊ§°Ü!");
|
return -1;
|
}
|
//alert(error1);
|
dw_item.ResetUpdateStatus();
|
}
|
dw_source.AcceptText();
|
xml x;
|
|
dw_source.DwUpdateAllToEx(x);
|
xaserverarg arg2 = GDNView::MakeArg();
|
arg2.AddArg(L"content", x.xml());
|
|
if (xurl::get(L"/sale/data/Gdn/update/sourceex", arg2.GetString(), x) != 1)
|
{
|
xstring error3 = x.text();
|
}
|
else
|
{
|
str = x.documentElement().getAttribute(L"text");
|
if (str == L"false")
|
{
|
alert(L"»õÔ´ÐÅÏ¢±£´æÊ§°Ü!");
|
return -1;
|
}
|
dw_source.ResetUpdateStatus();
|
}
|
|
dw_custom.AcceptText();
|
for (k = 1; k <= dw_custom.GetRowCount(); k++)
|
{
|
if (dw_custom.GetItemString(k, L"LineNo") == L"")
|
{
|
dw_custom.SetItemString(k, L"LineNo", k.toString());
|
}
|
}
|
xml xcustom;
|
|
dw_custom.DwUpdateAllToEx(xcustom);
|
if (xcustom.xml() != L"")
|
{
|
xcustom = CustomView::UpdateCustomItem(dw_base.GetItemString(1, L"InvoiceNo"), xcustom.xml());
|
if (!xcustom)
|
{
|
xstring error5 = xcustom.text();
|
}
|
else
|
{
|
str = xcustom.documentElement().getAttribute(L"text");
|
if (str == L"false")
|
{
|
alert(L"±¨¹ØÐÅÏ¢±£´æÊ§°Ü!");
|
return -1;
|
}
|
dw_custom.ResetUpdateStatus();
|
}
|
}
|
if (dw_invoiceItem.GetRowCount() > 0)
|
{
|
dw_invoiceItem.AcceptText();
|
xml x1 ;
|
|
dw_invoiceItem.DwUpdateAllToEx(x1);
|
xaserverarg arg4 = GDNView::MakeArg();
|
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.documentElement().getAttribute(L"text");
|
if (str == L"false")
|
{
|
alert(L"Ò鸶ÐÅÏ¢±£´æÊ§°Ü!");
|
return -1;
|
}
|
dw_invoiceItem.ResetUpdateStatus();
|
}
|
dw_fcl.AcceptText();
|
xml xfcl ;
|
|
dw_fcl.DwUpdateAllToEx(xfcl);
|
xaserverarg arg8 = GDNView::MakeArg();
|
arg8.AddArg(L"content", xfcl.xml());
|
|
if (xurl::get(L"/sale/data/Gdn/update/container", arg8.GetString(), xfcl) != 1)
|
{
|
xstring error8 = xfcl.text();
|
}
|
else
|
{
|
str = xfcl.documentElement().getAttribute(L"text");
|
if (str == L"false")
|
{
|
alert(L"·ÖÏäÐÅÏ¢±£´æÊ§°Ü!");
|
return -1;
|
}
|
dw_fcl.ResetUpdateStatus();
|
}
|
dw_cdelement.AcceptText();
|
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.text();
|
alert(L"err:" + error6);
|
alert(L"Éê±¨ÒªËØÐÅÏ¢±£´æÊ§°Ü!");
|
//return -1;
|
}
|
else
|
{
|
str = xcdelement.documentElement().getAttribute(L"text");
|
if (str == L"false")
|
{
|
alert(L"Éê±¨ÒªËØÐÅÏ¢±£´æÊ§°Ü!");
|
return -1;
|
}
|
dw_cdelement.ResetUpdateStatus();
|
}
|
}
|
|
|
|
if (showSuccess)
|
alert(L"±£´æ³É¹¦£¡");
|
if (InvoiceID == L"")
|
{
|
InvoiceID = dw_base.GetGuid(1);
|
InvoiceNo = dw_base.GetItemString(1, L"InvoiceNo");
|
}
|
return 1;
|
}
|
|
|
|
bool validClassfyID()
|
{
|
if (dw_custom.GetRow() < 1) return true;
|
int i = 0;
|
xstring classfyid;
|
for (i = 1; i <= dw_item.GetRowCount(); i++)
|
{
|
classfyid = dw_item.GetItemString(i, L"ClassifyID");
|
if (dw_custom.LookUpRow(L"ClassifyID", classfyid) == 0)
|
{
|
alert(L"³ö»õÉÌÆ·µÚ" + xstring(i) + L"Ðк£¹Ø´úÂë[" +
|
dw_item.GetItemDisplayString(i, L"ClassifyID") + L"]Ó뱨¹ØÉÌÆ·²»Ò»ÖÂ");
|
return false;
|
}
|
|
}
|
|
for (i = 1; i <= dw_custom.GetRowCount(); i++)
|
{
|
classfyid = dw_custom.GetItemString(i, L"ClassifyID");
|
if (dw_item.LookUpRow(L"ClassifyID", classfyid) == 0)
|
{
|
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.text();
|
if (Results3 != L"")
|
{
|
alert(Results3);
|
return false;
|
}
|
|
/*
|
if(dw_custom.GetItemString(i,L"ItemGoodsSource")==L"")
|
{
|
alert(L"±¨¹ØÉÌÆ·µÚ"+i.toString()+L"ÐлõÔ´µØÎª¿Õ£¬ÎÞ·¨±£´æ");
|
return false;
|
}
|
*/
|
if (dw_custom.GetItemString(i, L"UOMCode") == L"")
|
{
|
alert(L"¿ªÆ±µ¥Î»Îª¿Õ£¡");
|
return false;
|
}
|
|
}
|
|
/*
|
xstring No = dw_base.GetItemString(1,L"InvoiceNo");
|
if(No != L"")
|
{
|
xml x = ViewObject::RetrieveData(L"/sale/data/GDN/GDNClassifyID",L"InvoiceNo", No);
|
if(x.selectSingleNode(L"data/item/ClassifyID"))
|
if(x.selectSingleNode(L"data/item/CDquantity"))
|
xstring ClassifyIDOne=L"";
|
xstring CDquantityOne=L"";
|
ClassifyIDOne = x.selectSingleNode(L"data/item/ClassifyID").text();
|
CDquantityOne= x.selectSingleNode(L"data/item/CDquantity").text();
|
double CDquantityTwo=CDquantityOne.toInt();
|
}
|
double ttl=0.0;
|
for(i=1;i<=dw_item.GetRowCount();i++)
|
{
|
classfyid = dw_item.GetItemString(i,L"ClassifyID");
|
if(classfyid == ClassifyIDOne)
|
{
|
if(dw_item.GetItemString(i,L"CDQuantity")==L""||dw_item.GetItemString(i,L"CDQuantity")==L"0.00")
|
{
|
alert(L"³öÔ˲úÆ·µÚ"+i.toString()+L":±¨¹ØÊýÁ¿Îª¿Õ£¡");
|
return false;
|
}
|
if(dw_item.GetItemString(i,L"CDAmount")==L""||dw_item.GetItemString(i,L"CDAmount")==L"0.00")
|
{
|
alert(L"³öÔ˲úÆ·µÚ"+i.toString()+L":±¨¹Ø×ܼÛΪ¿Õ£¡");
|
return false;
|
}
|
double CDQuantity = dw_item.GetItemDouble(i,L"CDQuantity");
|
ttl += CDQuantity;
|
}
|
}
|
if(ttl != CDquantityTwo)
|
{
|
alert(L"±¨¹ØÊýÁ¿²»Ò»Ö£¡");
|
return false;
|
}*/
|
return true;
|
}
|
|
bool CheckGW()
|
{
|
int i = 0;
|
double GWS = 0.0;
|
double NWS = 0.0;
|
for (int k = 1; k <= dw_item.GetRowCount(); k++)
|
{
|
double GW = dw_custom.GetItemDouble(k, L"GW");
|
double NW = dw_custom.GetItemDouble(k, L"NW");
|
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 (xdouble(NWS).round(2) != xdouble(NW1).round(2) || xdouble(GWS).round(2) != xdouble(GW1).round(2))
|
{
|
alert(L"Ã«ÖØ×ÜÁ¿»ò¾»×ÜÖØÁ¿²»Ò»Ö£¬ÐèÒªºË¶Ô£¡");
|
return 0;
|
}
|
return true;
|
}
|
|
|
bool LegalQtyCDLine()
|
{
|
xstring ApprovalStatus = dw_base.GetItemString(1, L"ApprovalStatus");
|
trace(L"#######" + ApprovalStatus + L"#######");
|
double NW = 0.0;
|
double NWS = 0.0;
|
if (ApprovalStatus != L"9")
|
{
|
int i = 0;
|
for (int k = 1; k <= dw_custom.GetRowCount(); k++)
|
{
|
xstring LegalUOMCode = dw_custom.GetItemString(k, L"LegalUOMCode");
|
if (LegalUOMCode == L"ǧ¿Ë")
|
{
|
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";
|
|
double LegalQty = dw_custom.GetItemDouble(k, L"LegalQty");
|
|
for (i = 1; i <= dw_item.GetRowCount(); i++)
|
{
|
if (ClassifyID != dw_item.GetItemString(i, L"ClassifyID")) continue;
|
if (GroupNo != dw_item.GetItemString(i, L"GroupNo")) continue;
|
|
|
NW = dw_item.GetItemDouble(i, L"NW");
|
|
NWS += NW;
|
|
}
|
trace(L"*****" + xstring(NWS) + L"*****" + xstring(LegalQty) + L"*****");
|
NWS = NWS - LegalQty;
|
|
if (NWS < 0.0) NWS = 0.0 - NWS;
|
if (NWS >= 1.0)
|
{
|
alert(L"[" + ClassifyName + L"]¶ÔÓ¦µÄ±¨¹ØÊýÁ¿²»Ò»ÖÂ!");
|
return 0;
|
}
|
}
|
}
|
}
|
return true;
|
}
|
|
|
bool CheckCDLine()
|
{
|
xstring ApprovalStatus = dw_base.GetItemString(1, L"ApprovalStatus");
|
trace(L"#######" + ApprovalStatus + L"#######");
|
//alert(ApprovalStatus);
|
if (ApprovalStatus != L"9")
|
{
|
int i = 0;
|
for (int k = 1; k <= dw_custom.GetRowCount(); k++)
|
{
|
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";
|
double VQuantity = dw_custom.GetItemDouble(k, L"Quantity");
|
double VAmount = dw_custom.GetItemDouble(k, L"Amount");
|
double qty = 0.0;
|
double amt = 0.0;
|
double qttl = 0.0;
|
double attl = 0.0;
|
for (i = 1; i <= dw_item.GetRowCount(); i++)
|
{
|
if (ClassifyID != dw_item.GetItemString(i, L"ClassifyID")) continue;
|
if (GroupNo != dw_item.GetItemString(i, L"GroupNo")) continue;
|
|
if (dw_item.GetItemDouble(i, L"CDQuantity") == 0.0)
|
qty = dw_item.GetItemDouble(i, L"Quantity");
|
else
|
qty = dw_item.GetItemDouble(i, L"CDQuantity");
|
if (dw_item.GetItemDouble(i, L"CDAmount") == 0.0)
|
amt = dw_item.GetItemDouble(i, L"Amount");
|
else
|
amt = dw_item.GetItemDouble(i, L"CDAmount");
|
qttl += qty;
|
attl += amt;
|
}
|
|
qttl = qttl - VQuantity;
|
attl = attl - VAmount;
|
|
//alert(L"Quantity: "+VQuantity.toString()+L"Amount: "+VAmount.toString()+L" QTTL:"+qttl.toString()+L" ATTL:"+ attl.toString());
|
|
if (qttl < 0.0) qttl = 0.0 - qttl;
|
if (attl < 0.0) attl = 0.0 - attl;
|
if (qttl >= 1.0 || attl >= 1.0)
|
{
|
alert(L"[" + ClassifyName + L"]¶ÔÓ¦ÉÌÆ·ÇëÌîд¿ªÆ±ÊýÁ¿ºÍ±¨¹Ø½ð¶î\r\n²»Ìîд±íʾ¿ªÆ±ÊýÁ¿ºÍ±¨¹Ø½ð¶îÓë³öÔËÊýÁ¿ºÍ½ð¶îÒ»ÖÂ!");
|
return 0;
|
}
|
}
|
}
|
return true;
|
}
|
|
bool validProfit()
|
{
|
double amt = dw_profit.GetItemString(1, L"ProfitAmountEx");
|
if (amt < 0.0)
|
{
|
if (dw_profit.GetItemString(1, L"Note") == L"")
|
{
|
alert(L"ÀûÈóΪ¸º,ÇëÔÚÓ¯¿÷±¸×¢ÖÐдÃ÷ÔÒò!");
|
return false;
|
}
|
}
|
return true;
|
}
|
|
int OnSave()
|
{
|
if (!validClassfyID()) return 1;
|
if (!validProfit()) return 1;
|
if (!CheckCDLine()) return 1;
|
if (!LegalQtyCDLine()) return 1;
|
|
|
DoUpdate(true);
|
|
return 1;
|
}
|
|
int ClearSourcingItem(int nRow)
|
{
|
if (nRow < 1 or nRow > dw_item.GetRowCount()) return 1;
|
xstring GDNLineID = dw_item.GetGuid(nRow);
|
for (int i = dw_source.GetRowCount(); i >= 1; i--)
|
{
|
if (dw_source.GetItemString(i, L"GDNLineID") == GDNLineID)
|
dw_source.DeleteRow(i);
|
}
|
return 1;
|
}
|
|
int RefreshSourcingItem(int nRow, bool clear = true)
|
{
|
|
if (nRow < 1 or nRow > dw_item.GetRowCount()) return 1;
|
xstring GDNLineID = dw_item.GetGuid(nRow);
|
if (clear) ClearSourcingItem(nRow);
|
double ExchangeCostEx = dw_profit.GetItemDouble(1, L"ExchangeCostEx");
|
xml x = xml::Make();
|
x.loadXML(L"<data/>");
|
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");
|
x.Free();
|
|
xml source = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/gdn/sourcing/refreshitemex", L"content", val);
|
if (source)
|
{
|
KXMLDOMNodeList items = source.selectNodes(L"data/Item");
|
//trace(L"=======L"+source.GetXml()+L"=======L");
|
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"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());
|
//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"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());
|
|
}
|
|
PoTotal(nRow);
|
if (clear)
|
{
|
evalPurcharCost();
|
evalTotalCost();
|
evalProfitAmountEx();
|
dw_profit.Redraw();
|
}
|
}
|
|
return 1;
|
}
|
|
int RefreshSourcingItem1(int nRow, bool clear = true)
|
{
|
if (nRow < 1 or nRow > dw_item.GetRowCount()) return 1;
|
xstring GDNLineID = dw_item.GetGuid(nRow);
|
if (clear) ClearSourcingItem(nRow);
|
double ExchangeCostEx = dw_profit.GetItemDouble(1, L"ExchangeCostEx");
|
xml x = xml::Make();
|
x.loadXML(L"<data/>");
|
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");
|
x.Free();
|
|
xml source = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/gdn/sourcing/refreshitemexOne", L"content", val);
|
if (source)
|
{
|
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"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 (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"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());
|
}
|
|
PoTotal(nRow);
|
if (clear)
|
{
|
evalPurcharCost();
|
evalTotalCost();
|
evalProfitAmountEx();
|
dw_profit.Redraw();
|
}
|
}
|
|
return 1;
|
}
|
|
int RefreshSourcingAllEx()
|
{
|
|
while (dw_source.GetRowCount() > 0) dw_source.DeleteRow(1);
|
|
dw_item.AcceptText();
|
xml xitem ;
|
|
KXMLDOMDocument xitemdoc = xitem;
|
dw_item.DwUpdateAllToEx(xitemdoc);
|
|
|
xml x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/gdn/sourcing/refreshitemexOne", L"content", xitem.GetXml());
|
trace(x.xml());
|
if (x)
|
{
|
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"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"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());
|
}
|
}
|
evalPurcharCost();
|
evalTotalCost();
|
|
dw_profit.Redraw();
|
|
PoTotal();
|
|
x.Free();
|
evalProfitAmountEx();
|
}
|
|
return 1;
|
}
|
|
int RefreshSourcingAll()
|
{
|
while (dw_source.GetRowCount() > 0) dw_source.DeleteRow(dw_source.GetRowCount());
|
|
xstring No = dw_base.GetItemString(1, L"InvoiceNo");
|
for (int k = 1; k <= dw_item.GetRowCount(); k++)
|
{
|
KXMLDOMElement e = dw_item.GetRowElement(k);
|
xstring gdnLineID = e.getAttribute(L"guid");
|
xml x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/gdn/sourcing/refreshitem", L"InvoiceNo", No, L"GDNLineID", gdnLineID);
|
if (x)
|
{
|
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"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 (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"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();
|
evalProfitAmountEx();
|
dw_profit.Redraw();
|
}
|
|
return 1;
|
}
|
|
//event
|
int OnDWClick(TEvent* evt, int p)
|
{
|
DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
|
xstring value = hdr->data;
|
xstring colname = hdr->colname;
|
|
return 1;
|
}
|
|
int OnProfitItemChanged(TEvent* evt, int p)
|
{
|
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" ||
|
col == L"CustomFee" ||
|
col == L"InspectionFee" ||
|
col == L"PaperCardCopyFee" ||
|
col == L"TransportationFee" ||
|
col == L"StorageFee" ||
|
col == L"PortIncidentalFee" ||
|
col == L"BankFee" ||
|
col == L"RiskPrepareFee" ||
|
col == L"AllocatedFee" ||
|
col == L"ManagementFee" ||
|
col == L"RiskFundAmount" ||
|
col == L"FundsIntrestFee" ||
|
col == L"AgentAmount" ||
|
col == L"AgentTax" ||
|
col == L"OtherFee")
|
{
|
evalTotalCost();
|
evalProfitAmountEx();
|
dw_profit.Redraw();
|
}
|
|
xutil::RestoreCursor(HCursor);
|
|
return 1;
|
}
|
|
int OnCustomItemChanged(TEvent* evt, int p)
|
{
|
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;
|
if (data != L"") rate = data.toDouble();
|
double amt = dw_custom.GetItemDouble(row, L"AmountEx");
|
dw_custom.SetItemDouble(row, L"Amount", amt * rate);
|
double quantity = dw_custom.GetItemDouble(row, L"Quantity");
|
double price = amt * rate / quantity;
|
dw_custom.SetItemDouble(row, L"UnitPrice", price);
|
dw_custom.Redraw();
|
}
|
if (col == L"UnitPrice" || col == L"Quantity")
|
{
|
double UnitPrice = dw_custom.GetItemDouble(row, L"UnitPrice");
|
double Quantity = dw_custom.GetItemDouble(row, L"Quantity");
|
double Amount = UnitPrice * Quantity;
|
dw_custom.SetItemDouble(row, L"Amount", Amount);
|
dw_custom.Redraw();
|
}
|
return 1;
|
}
|
|
int CalcDraftAmount()
|
{
|
|
double amt = dw_base.GetItemDouble(1, L"Amount");//4646
|
double camt = dw_base.GetItemDouble(1, L"CommissionAmount");//46
|
amt = amt - camt;
|
double damt = dw_base.GetItemDouble(1, L"DiscountAmount");//46
|
amt = amt - damt;
|
double exterm = dw_base.GetItemDouble(1, L"Cost");//46
|
xstring moreless = dw_base.GetItemString(1, L"CostMoreLess");//-1
|
if (dw_base.GetItemString(1, L"Cost") != L"")
|
{
|
if (moreless == L"-1")
|
amt = amt - exterm;
|
else
|
amt = amt + exterm;
|
}
|
dw_base.SetItemDouble(1, L"DraftAmount", amt);
|
return 1;
|
}
|
|
int OnBaseItemChanged(TEvent* evt, int p)
|
{
|
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")
|
{
|
SetCustomerHabit(data);
|
return 1;
|
}
|
if (col == L"InvoiceNo")
|
{
|
dw_profit.SetItemString(1, L"InvoiceNo", data);
|
dw_base.Redraw();
|
}
|
else if (col == L"Amount")
|
{
|
double amt = dw_base.GetItemDouble(1, L"Amount");
|
if (dw_base.GetItemString(1, L"CommissionRate") != L"")
|
{
|
double commrate1 = dw_base.GetItemDouble(1, L"CommissionRate");
|
dw_base.SetItemDouble(1, L"CommissionAmount", amt * commrate1 / 100.0);
|
}
|
if (dw_base.GetItemString(1, L"PrivateCommissionRate") != L"")
|
{
|
double fcommrate1 = dw_base.GetItemDouble(1, L"PrivateCommissionRate");
|
dw_base.SetItemDouble(1, L"PrivateCommissionAmount", amt * fcommrate1 / 100.0);
|
}
|
if (dw_base.GetItemString(1, L"DiscountRate") != L"")
|
{
|
double drate1 = dw_base.GetItemDouble(1, L"DiscountRate");
|
dw_base.SetItemDouble(1, L"DiscountAmount", amt * drate1 / 100.0);
|
}
|
CalcDraftAmount();
|
CalcProfit();
|
|
dw_base.Redraw();
|
}
|
|
if (col == L"Cost" || col == L"CostMoreLess")
|
{
|
CalcDraftAmount();
|
CalcProfit();
|
dw_base.Redraw();
|
}
|
|
if (col == L"CommissionAmount" || col == L"PrivateCommissionAmount" || col == L"DiscountAmount")
|
{
|
CalcDraftAmount();
|
CalcProfit();
|
|
dw_base.Redraw();
|
}
|
if (col == L"GoodsSource")
|
{
|
|
xstring s = dw_base.GetItemString(1, L"GoodsSource");
|
xml supplier_x = ViewObject::RetrieveData(L"/sale/data/expense3/view/FindByOriginName", L"OriginName", s);
|
if (supplier_x)
|
{
|
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();
|
if (sname == name) {
|
dw_base.SetItemDisplayString(1, L"GoodsSource", name);
|
dw_base.SetItemString(1, L"GoodsSource", name);
|
}
|
}
|
else if (!supplier_x) {
|
dw_base.SetItemDisplayString(1, L"GoodsSource", L"");
|
dw_base.SetItemString(1, L"GoodsSource", L"");
|
|
}
|
dw_base.Redraw();
|
}
|
if (col == L"CommissionRate")
|
{
|
if (data == L"")
|
{
|
dw_base.SetItemString(1, L"CommissionAmount", L"");
|
}
|
else
|
{
|
double commrate = data.toDouble();
|
dw_base.SetItemDouble(1, L"CommissionAmount",
|
dw_base.GetItemDouble(1, L"Amount") * commrate / 100.0);
|
}
|
CalcDraftAmount();
|
CalcProfit();
|
dw_base.Redraw();
|
}
|
if (col == L"DiscountRate")
|
{
|
if (data == L"")
|
{
|
dw_base.SetItemString(1, L"DiscountAmount", L"");
|
}
|
else
|
{
|
double DiscountRate = data.toDouble();
|
dw_base.SetItemDouble(1, L"DiscountAmount",
|
dw_base.GetItemDouble(1, L"Amount") * DiscountRate / 100.0);
|
}
|
CalcDraftAmount();
|
CalcProfit();
|
dw_base.Redraw();
|
}
|
else if (col == L"PrivateCommissionRate")
|
{
|
if (data == L"")
|
{
|
dw_base.SetItemString(1, L"PrivateCommissionAmount", L"");
|
}
|
else
|
{
|
double fcommrate = data.toDouble();
|
dw_base.SetItemDouble(1, L"PrivateCommissionAmount",
|
dw_base.GetItemDouble(1, L"Amount") * fcommrate / 100.0);
|
}
|
CalcProfit();
|
dw_base.Redraw();
|
}
|
else if (col == L"PaymentTerm")
|
{
|
if (data.find(L"L/C") >= 0)
|
{
|
dw_base.SetColumnProp(L"LCNo", L"cellprotect", L"0");
|
dw_base.SetColumnProp(L"LCSignDate", L"cellprotect", L"0");
|
dw_base.SetColumnProp(L"LCSigner", L"cellprotect", L"0");
|
dw_base.SetColumnProp(L"LCReceiveDate", L"cellprotect", L"0");
|
dw_base.SetColumnProp(L"LCBank", L"cellprotect", L"0");
|
dw_base.Redraw();
|
}
|
else
|
{
|
dw_base.SetColumnProp(L"LCNo", L"cellprotect", L"1");
|
dw_base.SetColumnProp(L"LCSignDate", L"cellprotect", L"1");
|
dw_base.SetColumnProp(L"LCSigner", L"cellprotect", L"1");
|
dw_base.SetColumnProp(L"LCReceiveDate", L"cellprotect", L"1");
|
dw_base.SetColumnProp(L"LCBank", L"cellprotect", L"1");
|
dw_base.Redraw();
|
}
|
}
|
else if (col == L"ETD")
|
{
|
xstring ETD = dw_base.GetItemString(1, L"ETD");
|
xstring exchangeRate = L"";
|
if (ETD != L"")
|
{
|
trace(ETD);
|
xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramEx", L"ETD", ETD);
|
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);
|
}
|
else
|
{
|
xml xp = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", 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();
|
}
|
|
dw_profit.Redraw();
|
}
|
return 1;
|
}
|
|
double CalcVolumePkg(int row)
|
{
|
xstring ll = dw_item.GetItemString(row, L"PackageL");
|
xstring lw = dw_item.GetItemString(row, L"PackageW");
|
xstring lh = dw_item.GetItemString(row, L"PackageH");
|
double pl = dw_item.GetItemDouble(row, L"PackageL");
|
double pw = dw_item.GetItemDouble(row, L"PackageW");
|
double ph = dw_item.GetItemDouble(row, L"PackageH");
|
if (ll != L"" || lh != L"" || lw != L"")
|
{
|
if (lh == L"") ph = 1.0;
|
if (lw == L"") pw = 1.0;
|
if (ll == L"") pl = 1.0;
|
return pl * ph * pw / 1000000.0;
|
}
|
else
|
return 0.0;
|
}
|
|
int OnSetRetax(int row)
|
{
|
if (row < 1) return 1;
|
|
xstring ClassifyID = dw_item.GetItemString(row, L"ClassifyID");
|
xstring refundRate = L"*";
|
trace(L"\r\n--------" + ClassifyID + L"-----------");
|
xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyinfo", L"ClassifyID", ClassifyID);
|
if (x)
|
{
|
KXMLDOMNode o = x.selectSingleNode(L"data/Item");
|
if (o)
|
{
|
refundRate = o.selectSingleNode(L"VATRefundRate").text();
|
}
|
}
|
if (refundRate != L"*")
|
{
|
xstring GDNLineID = dw_item.GetGuid(row);
|
for (int i = dw_source.GetRowCount(); i >= 1; i--)
|
{
|
if (dw_source.GetItemString(i, L"GDNLineID") == GDNLineID)
|
{
|
if (dw_source.GetItemString(i, L"HasVATInvoice") == L"Y")
|
{
|
dw_source.SetItemString(i, L"VATRefundRate", refundRate);
|
dw_source.ItemChangeTo(i, L"VATRefundRate", refundRate);
|
}
|
}
|
}
|
}
|
return 1;
|
}
|
|
int SetCDUnitPrice(int row, xstring col, xstring data)
|
{
|
if (data == L"")
|
{
|
dw_item.SetItemDisplayString(row, col, L"");
|
dw_item.SetItemString(row, L"CDUnitPrice", L"");
|
dw_item.SetItemDisplayString(row, L"CDUnitPrice", L"");
|
}
|
else
|
{
|
double d3 = dw_item.GetItemDouble(row, L"CDAmount");
|
double d4 = dw_item.GetItemDouble(row, L"CDQuantity");
|
double d6 = 0.0;
|
if (d4 == 0.0) dw_item.GetItemDouble(row, L"Quantity");
|
if (d4 != 0.0)
|
{
|
double d5 = d3 / d4;
|
d5 = xdouble(d5).round(4);
|
if (d3 <= 0.0 && d4 <= 0.0)
|
{
|
//trace(L"--------1111-----------");
|
dw_item.SetItemDouble(row, L"CDUnitPrice", d6);
|
}
|
else
|
{
|
dw_item.SetItemDouble(row, L"CDUnitPrice", d5);
|
}
|
dw_item.Redraw();
|
}
|
}
|
return 1;
|
}
|
|
int OnItemChanged(TEvent* evt, int p)
|
{
|
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")
|
{
|
OnSetRetax(row);
|
CalcProfit();
|
return 1;
|
}
|
if (col == L"Quantity" || col == L"PackingRate")
|
{
|
//¼þÊý
|
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", xstring(ipack));
|
if (col == L"Quantity")
|
{
|
if (!datareading)
|
{
|
calcTotal();
|
RefreshSourcingItem1(row);
|
CalcProfit();
|
//RefreshSourcingAllEx();
|
}
|
}
|
dw_item.Redraw();
|
}
|
if (col == L"Packages")
|
{
|
double packages = dw_item.GetItemDouble(row, L"Packages");
|
double nwpkg = dw_item.GetItemDouble(row, L"NWPerPkg");
|
double gwpkg = dw_item.GetItemDouble(row, L"GWPerPkg");
|
double UnitCommPrice = dw_item.GetItemDouble(row, L"UnitCommPrice");
|
double Quantity2 = dw_item.GetItemDouble(row, L"Quantity");
|
double MiddlemanAmount = dw_item.GetItemDouble(row, L"MiddlemanAmount");
|
|
double nw = nwpkg * packages;
|
double gw = gwpkg * packages;
|
double rw = UnitCommPrice * Quantity2;
|
double MiddlemanAmountRate = MiddlemanAmount * Quantity2;
|
|
double pv2 = CalcVolumePkg(row);
|
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", xdouble(svol2).round(2));
|
|
dw_item.SetItemDouble(row, L"NW", nw);
|
dw_item.SetItemDouble(row, L"GW", gw);
|
dw_item.SetItemDouble(row, L"ResearchCommissionRate", rw);
|
dw_item.SetItemDouble(row, L"MiddlemanAmountRate", MiddlemanAmountRate);
|
dw_item.Redraw();
|
calcTotal();
|
|
}
|
if (col == L"NWPerPkg" || col == L"MiddlemanAmount" || col == L"GWPerPkg" || col == L"MiddlemanAmountRate" || col == L"ResearchCommissionRate" || col == L"Quantity" || col == L"UnitCommPrice")
|
{
|
double packages1 = dw_item.GetItemDouble(row, L"Packages");
|
double UnitCommPrice1 = dw_item.GetItemDouble(row, L"UnitCommPrice");
|
double nwpkg1 = dw_item.GetItemDouble(row, L"NWPerPkg");
|
double gwpkg1 = dw_item.GetItemDouble(row, L"GWPerPkg");
|
double Quantity1 = dw_item.GetItemDouble(row, L"Quantity");
|
double MiddlemanAmount1 = dw_item.GetItemDouble(row, L"MiddlemanAmount");
|
|
double nw1 = nwpkg1 * packages1;
|
double gw1 = gwpkg1 * packages1;
|
double rw1 = UnitCommPrice1 * Quantity1;
|
double MiddlemanAmountRate1 = MiddlemanAmount1 * Quantity1;
|
|
dw_item.SetItemDouble(row, L"NW", nw1);
|
dw_item.SetItemDouble(row, L"GW", gw1);
|
dw_item.SetItemDouble(row, L"ResearchCommissionRate", rw1);
|
dw_item.SetItemDouble(row, L"MiddlemanAmountRate", MiddlemanAmountRate1);
|
|
double NWS = 0.0;
|
double GWS = 0.0;
|
double RWS = 0.0;
|
double MAS = 0.0;
|
for (int i = 1; i <= dw_item.GetRowCount(); ++i)
|
{
|
double NW = dw_item.GetItemDouble(i, L"NW");
|
NWS += NW;
|
double GW = dw_item.GetItemDouble(i, L"GW");
|
GWS += GW;
|
double RW = dw_item.GetItemDouble(i, L"ResearchCommissionRate");
|
RWS += RW;
|
double MA = dw_item.GetItemDouble(i, L"MiddlemanAmountRate");
|
MAS += MA;
|
}
|
dw_base.SetItemDouble(1, L"NW", NWS);
|
dw_base.SetItemDouble(1, L"GW", GWS);
|
dw_base.SetItemDouble(1, L"ResearchCommissionRate", RWS);
|
|
dw_item.Redraw();
|
}
|
if (col == L"PackageL" || col == L"PackageW" || col == L"PackageH")
|
{
|
double pv = CalcVolumePkg(row);
|
dw_item.SetItemDouble(row, L"VolumePerPkg", pv);
|
double ctns = dw_item.GetItemDouble(row, L"Packages");
|
double svol = pv * ctns;
|
//trace(svol.toString() +L"******"+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 += xdouble(Volume).round(2);
|
}
|
dw_base.SetItemDouble(1, L"Volume", xdouble(Volumes).round(2));
|
dw_item.Redraw();
|
}
|
if (col == L"VolumePerPkg")
|
{
|
double pv1 = CalcVolumePkg(row);
|
double ctns1 = dw_item.GetItemDouble(row, L"Packages");
|
double svol1 = pv1 * ctns1;
|
dw_item.SetItemDouble(row, L"Volume", svol1);
|
dw_item.Redraw();
|
}
|
if (col == L"Quantity" || col == L"UnitPrice")
|
{
|
if (!datareading)
|
{
|
double d1 = dw_item.GetItemDouble(row, L"Quantity");
|
double d2 = dw_item.GetItemDouble(row, L"UnitPrice");
|
double d = d1 * d2;
|
d = xdouble(d).round(2);
|
dw_item.SetItemDouble(row, L"Amount", d);
|
|
calcTotal();
|
CalcProfit();
|
}
|
}
|
if (col == L"CDAmount" || col == L"CDQuantity")
|
{
|
SetCDUnitPrice(row, col, data);
|
}
|
|
xutil::RestoreCursor(HCursor);
|
|
return 1;
|
}
|
|
|
int GDNSourcePoTotal()
|
{
|
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) {
|
//double UnitPrice = dw_source.GetItemDouble(row,L"UnitPrice");
|
KXMLDOMElement e = dw_item.GetRowElement(k);
|
xstring GDNLineID = e.getAttribute(L"guid");
|
double GDNSourceAmount = dw_source.GetItemDouble(row, L"BuyAmount");
|
GDNItemAmount = dw_item.GetItemDouble(k, L"Amount");
|
xstring POGDNLineID = dw_source.GetItemString(row, L"GDNLineID");
|
if (GDNLineID == POGDNLineID) {
|
Amount_s += GDNSourceAmount;
|
}
|
|
}
|
Vol_s = Amount_s / GDNItemAmount;
|
dw_source.SetItemDouble(row, L"Swapthecost", Vol_s);
|
}
|
return 1;
|
}
|
|
int OnItemChangedEx(TEvent* evt, int p)
|
{
|
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);
|
evalDrawbackEx();
|
evalTotalCost();
|
evalProfitAmountEx();
|
}
|
|
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);
|
}
|
if (colname == L"BuyUnitPrice" || colname == L"BuyQuantity" || colname == L"PackUnitPrice" || colname == L"BuyAmount")
|
{
|
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);
|
}
|
CalcProfit();
|
}
|
return 1;
|
}
|
|
|
int OnAskDataBase(TEvent* evt, int p)
|
{
|
DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
|
|
xstring x = hdr->colname;
|
if (x == L"userSalespersonID")
|
{
|
xstring sSalespersonID = dw_base.GetItemString(1, L"SalespersonID");
|
hdr->data = sSalespersonID;
|
}
|
return 1;
|
}
|
|
int OnBillNoteDoubleClicked(TEvent* evt, int p)
|
{
|
DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
|
xstring colname = hdr->colname;
|
int row = hdr->row;
|
if (colname == L"Content")
|
{
|
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);
|
|
xstring comdid = arg.GetArgString(L"comdid");
|
if (comdid == L"xmOK")
|
{
|
xstring value = arg.GetArgString(L"value");
|
dw_billnote.SetItemString(row, colname, value);
|
dw_billnote.Redraw();
|
}
|
}
|
return 1;
|
}
|
|
int OnPrint()
|
{
|
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"");
|
|
openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", &arg);
|
return 1;
|
}
|
|
int OnMakeSumPack()
|
{
|
double Quantity_s = 0.0;
|
int Packages_s = 0.0;
|
double GW_s = 0.0;
|
double NW_s = 0.0;
|
double Amount_s = 0.0;
|
double Vol_s = 0.0;
|
|
for (int row = 1; row <= dw_item.GetRowCount(); ++row)
|
{
|
double Quantity = dw_item.GetItemDouble(row, L"Quantity");
|
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");
|
double Vol = dw_item.GetItemDouble(row, L"Volume");
|
|
Quantity_s += Quantity;
|
Packages_s += Packages;
|
GW_s += GW;
|
NW_s += NW;
|
Amount_s += Amount;
|
Vol_s += Vol;
|
}
|
|
return 1;
|
}
|
|
int OnMakeContainer()
|
{
|
int cnt = dw_fcl.GetRowCount();
|
for (int k = 1; k <= cnt; k++)
|
{
|
dw_fcl.SetItemDouble(k, L"Quantity", 0.0);
|
dw_fcl.SetItemDouble(k, L"GW", 0.0);
|
dw_fcl.SetItemDouble(k, L"NW", 0.0);
|
dw_fcl.SetItemString(k, L"Packages", L"0");
|
dw_fcl.SetItemDouble(k, L"Volume", 0.0);
|
dw_fcl.SetItemString(k, L"UseFlag", L"0");
|
dw_fcl.SetItemDouble(k, L"Amount", 0.0);
|
}
|
|
for (int row = 1; row <= dw_item.GetRowCount(); ++row)
|
{
|
xstring ContainerNo = dw_item.GetItemString(row, L"ContainerNo");
|
double Quantity = dw_item.GetItemDouble(row, L"Quantity");
|
int Packages = dw_item.GetItemInt(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");
|
double Vol = dw_item.GetItemDouble(row, L"Volume");
|
|
int i = 1;
|
for (i = 1; i <= dw_fcl.GetRowCount(); i++)
|
{
|
if (dw_fcl.GetItemString(i, L"ContainerNo") == ContainerNo)break;
|
}
|
if (i > dw_fcl.GetRowCount())
|
{
|
dw_fcl.InsertRow(0);
|
i = dw_fcl.GetRowCount();
|
|
dw_fcl.SetItemString(i, L"ContainerNo", ContainerNo);
|
dw_fcl.SetItemString(i, L"GDNID", dw_base.GetGuid(1));
|
}
|
|
dw_fcl.SetItemString(i, L"UseFlag", L"1");
|
|
double val;
|
val = dw_fcl.GetItemDouble(i, L"Amount");
|
val += Amount;
|
dw_fcl.SetItemDouble(i, L"Amount", val);
|
|
val = dw_fcl.GetItemDouble(i, L"Quantity");
|
val += Quantity;
|
dw_fcl.SetItemDouble(i, L"Quantity", val);
|
|
val = dw_fcl.GetItemDouble(i, L"GW");
|
val += GW;
|
dw_fcl.SetItemDouble(i, L"GW", val);
|
|
val = dw_fcl.GetItemDouble(i, L"NW");
|
val += NW;
|
dw_fcl.SetItemDouble(i, L"NW", val);
|
|
int nval = dw_fcl.GetItemDouble(i, L"Packages");
|
nval += Packages;
|
dw_fcl.SetItemInt(i, L"Packages", nval);
|
|
val = dw_fcl.GetItemDouble(i, L"Volume");
|
val += Vol;
|
dw_fcl.SetItemDouble(i, L"Volume", val);
|
|
}
|
dw_fcl.Redraw();
|
|
for (int m = cnt; m >= 1; m--)
|
{
|
if (dw_fcl.GetItemString(m, L"UseFlag") == L"0")
|
dw_fcl.DeleteRow(m);
|
}
|
|
return 1;
|
}
|
|
int OnMakeCustom()
|
{
|
int HCursor = xutil::SetCursorWait();
|
dw_custom.AcceptText();
|
int cnt = dw_custom.GetRowCount();
|
bool cdelement = false;
|
for (int k = 1; k <= cnt; k++)
|
{
|
dw_custom.SetItemString(k, L"Quantity", L"");
|
dw_custom.SetItemString(k, L"Packages", L"");
|
dw_custom.SetItemString(k, L"GW", L"");
|
dw_custom.SetItemString(k, L"NW", L"");
|
dw_custom.SetItemString(k, L"Amount", L"");
|
dw_custom.SetItemString(k, L"AmountEx", L"");
|
dw_custom.SetItemString(k, L"VATRate", L"");
|
dw_custom.SetItemString(k, L"VATRefundRate", L"");
|
dw_custom.SetItemString(k, L"Volume", L"");
|
dw_custom.SetItemString(k, L"UnitPrice", L"");
|
dw_custom.SetItemString(k, L"UOMCode", L"");
|
dw_custom.SetItemString(k, L"KOPCode", L"");
|
dw_custom.SetItemString(k, L"UseFlag", L"0");
|
dw_custom.SetItemString(k, L"AmountEx", L"");
|
dw_custom.SetItemString(k, L"CurrencyCode", L"");
|
dw_custom.SetItemString(k, L"LineNo", L"");
|
}
|
|
xstring CurrencyCode = dw_base.GetItemString(1, L"CurrencyCode");
|
for (int row = 1; row <= dw_item.GetRowCount(); ++row)
|
{
|
xstring ClassifyID = dw_item.GetItemString(row, L"ClassifyID");
|
xstring name = dw_item.GetItemDisplayString(row, L"ClassifyID");
|
double Quantity = dw_item.GetItemDouble(row, L"Quantity");
|
xstring GroupNo = dw_item.GetItemString(row, L"GroupNo");
|
int Packages = dw_item.GetItemInt(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");
|
xstring VATRate = dw_item.GetItemString(row, L"VATRate");
|
xstring VATRefundRate = dw_item.GetItemString(row, L"VATRefundRate");
|
double Vol = dw_item.GetItemDouble(row, L"Volume");
|
xstring UnitPrice = dw_item.GetItemString(row, L"UnitPrice");
|
xstring UOMCode = dw_item.GetItemString(row, L"UOMCode");
|
xstring KOPCode = dw_item.GetItemString(row, L"KOPCode");
|
|
int i = 1;
|
bool bAdd = false;
|
for (i = 1; i <= dw_custom.GetRowCount(); i++)
|
{
|
if (dw_custom.GetItemString(i, L"ClassifyID") == ClassifyID && dw_custom.GetItemString(i, L"GroupNo") == GroupNo)
|
break;
|
}
|
if (i > dw_custom.GetRowCount())
|
{
|
dw_custom.InsertRow(0);
|
i = dw_custom.GetRowCount();
|
dw_custom.SetItemString(i, L"ClassifyID", ClassifyID);
|
bAdd = true;
|
}
|
dw_custom.SetItemString(i, L"UseFlag", L"1");
|
dw_custom.SetItemString(i, L"CustName", name);
|
dw_custom.SetItemString(i, L"GroupNo", GroupNo);
|
|
double val = 0;
|
double samt = 0;
|
val = dw_custom.GetItemDouble(i, L"Amount");
|
val += Amount;
|
samt = val;
|
dw_custom.SetItemDouble(i, L"Amount", val);
|
dw_custom.SetItemDouble(i, L"AmountEx", val);
|
dw_custom.SetItemString(i, L"VATRates", VATRate);
|
dw_custom.SetItemString(i, L"VATRefundRate", VATRefundRate);
|
dw_custom.SetItemString(i, L"UOMCode", UOMCode);
|
dw_custom.SetItemString(i, L"KOPCode", KOPCode);
|
dw_custom.SetItemDisplayString(i, L"UOMCode", dw_item.GetItemDisplayString(row, L"UOMCode"));
|
dw_custom.SetItemDisplayString(i, L"KOPCode", dw_item.GetItemDisplayString(row, L"KOPCode"));
|
dw_custom.SetItemString(i, L"CurrencyCode", CurrencyCode);
|
|
|
|
val = dw_custom.GetItemDouble(i, L"Quantity");
|
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 += xdouble(GW).round(3);
|
dw_custom.SetItemDouble(i, L"GW", val);
|
|
val = dw_custom.GetItemDouble(i, L"NW");
|
val += xdouble(NW).round(3);
|
dw_custom.SetItemDouble(i, L"NW", val);
|
|
int nval = dw_custom.GetItemDouble(i, L"Packages");
|
nval += Packages;
|
dw_custom.SetItemInt(i, L"Packages", nval);
|
|
val = dw_custom.GetItemDouble(i, L"Volume");
|
val += Vol;
|
dw_custom.SetItemDouble(i, L"Volume", val);
|
|
double price = samt / sqty;
|
dw_custom.SetItemDouble(i, L"UnitPrice", price);
|
|
|
xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyinfo", L"ClassifyID", ClassifyID);
|
|
if (x)
|
{
|
KXMLDOMNode o = x.selectSingleNode(L"data/Item");
|
if (o)
|
{
|
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"));
|
dw_custom.SetItemString(i, L"VATRates", str1);
|
}
|
if (o.selectSingleNode(L"CustEName"))
|
{
|
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());
|
}
|
if (o.selectSingleNode(L"VATRefundRate"))
|
{
|
dw_custom.SetItemString(i, L"VATRefundRate", o.selectSingleNode(L"VATRefundRate").text());
|
}
|
if (o.selectSingleNode(L"HSCode"))
|
{
|
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");
|
|
str = str.left(str.find(L"["));
|
dw_custom.SetItemString(i, L"CustName", str);
|
}
|
dw_custom.SetItemString(i, L"HSCode", hscode);
|
}
|
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();
|
if (uom == L"ǧ¿Ë")
|
{
|
dw_custom.SetItemString(i, L"LegalQty", dw_custom.GetItemString(i, L"NW"));
|
}
|
else
|
{
|
dw_custom.SetItemString(i, L"LegalQty", dw_custom.GetItemString(i, L"Quantity"));
|
}
|
}
|
}
|
}
|
/*
|
xml x= ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyinfo",L"ClassifyID",ClassifyID);
|
if(x)
|
{
|
KXMLDOMNode o = x.selectSingleNode(L"data/Item");
|
if(o)
|
{
|
if(o.selectSingleNode(L"VATRates"))
|
{
|
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_base.SetItemString(1,L"Amount")
|
if(o.selectSingleNode(L"VATRefundRate"))
|
{
|
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());
|
}
|
if(o.selectSingleNode(L"HSCode"))
|
{
|
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");
|
str = str.left(str.find(L"[" + hscode));
|
dw_custom.SetItemString(i,L"CustName",str);
|
}
|
dw_custom.SetItemString(i,L"HSCode",hscode);
|
}
|
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();
|
if(uom==L"ǧ¿Ë")
|
{
|
dw_custom.SetItemString(i,L"LegalQty",dw_custom.GetItemString(i,L"NW"));
|
}
|
else
|
{
|
dw_custom.SetItemString(i,L"LegalQty",dw_custom.GetItemString(i,L"Quantity"));
|
}
|
}
|
}
|
}*/
|
if (bAdd)
|
{
|
AddCDElement(i);
|
cdelement = true;
|
}
|
}
|
for (int m = cnt; m >= 1; m--)
|
{
|
if (dw_custom.GetItemString(m, L"UseFlag") == L"0")
|
{
|
if (dw_custom.GetItemString(i, L"ClassifyID") != L"")
|
DeleteCDElement(dw_custom.GetItemString(i, L"ClassifyID"));
|
dw_custom.DeleteRow(m);
|
}
|
}
|
xutil::RestoreCursor(HCursor);
|
dw_custom.Redraw();
|
if (cdelement)alert(L"Çë¸üб¨¹ØÒªËØ!");
|
|
return 1;
|
}
|
|
int AddCDElement(int cdrow)
|
{
|
xstring ClassifyID = dw_custom.GetItemString(cdrow, L"ClassifyID");
|
xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyelement", L"ClassifyID", ClassifyID);
|
if (x)
|
{
|
KXMLDOMNodeList items = x.selectNodes(L"/GDN/CDElement");
|
int lens = items.length();
|
for (int k = 0; k < lens; k++)
|
{
|
int row = dw_cdelement.InsertRow(0);
|
KXMLDOMElement e = items.item(k);
|
|
KXMLDOMElement e1 = dw_custom.GetRowElement(cdrow);
|
xstring CDLineID = e1.getAttribute(L"guid");
|
if (CDLineID == L"")
|
{
|
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"EleName"))
|
{
|
if(e.selectSingleNode(L"EleName").text==L"Æ·ÅÆÀàÐÍ")
|
{
|
if(dw_base.GetItemString(1,L"POL")==L"NINGBO")
|
{
|
dw_cdelement.SetItemString(row,L"EleContent",L"¾³ÄÚ×ÔÖ÷Æ·ÅÆ");
|
}else
|
{
|
dw_cdelement.SetItemString(row,L"EleContent",L"ÎÞÆ·ÅÆ");
|
}
|
}
|
else if(e.selectSingleNode(L"EleName").text==L"³ö¿ÚÏí»ÝÇé¿ö")
|
{i
|
xstring country = dw_base.GetItemString(1,L"FinalCountry");
|
if(country==L"")
|
{
|
dw_cdelement.SetItemString(row,L"EleContent",L"²»ÏíÊÜ");
|
}
|
else if(L"601,127,322,129,415,337,133,107,119,122,103,434,106,331,134,136,105,132,609,111,112,141,412,143".find(country)>=0)
|
{
|
dw_cdelement.SetItemString(row,L"EleContent",L"ÏíÊÜ");
|
}else
|
{
|
dw_cdelement.SetItemString(row,L"EleContent",L"²»ÏíÊÜ");
|
}
|
}
|
}*/
|
}
|
}
|
return 1;
|
}
|
|
int DeleteCDElement(xstring ClassifyID)
|
{
|
for (int m = dw_cdelement.GetRowCount(); m >= 1; m--)
|
{
|
if (dw_cdelement.GetItemString(m, L"ClassifyID") == ClassifyID)dw_cdelement.DeleteRow(m);
|
}
|
return 1;
|
}
|
|
//Éú³É
|
int OnMakeCustom1()
|
{
|
if (dw_cdelement.GetRowCount() > 0)
|
{
|
if (MessageBoxW(GetHWND(), L"¸üб¨¹ØÐÅÏ¢»áʹ±¨¹ØÒªËØÎÞЧ,ÊÇ·ñ¼ÌÐø?", L"Ìáʾ", 1) == 2)
|
return 1;
|
}
|
int cnt = dw_custom.GetRowCount();
|
for (int k = 1; k <= cnt; k++) dw_custom.DeleteRow(1);
|
|
cnt = dw_customex.GetRowCount();
|
for (int m = 1; m <= cnt; m++) dw_customex.DeleteRow(1);
|
|
xstring CurrencyCode = dw_base.GetItemString(1, L"CurrencyCode");
|
|
for (int row = 1; row <= dw_item.GetRowCount(); ++row)
|
{
|
xstring ClassifyID = dw_item.GetItemString(row, L"ClassifyID");
|
xstring GroupNo = dw_item.GetItemString(row, L"GroupNo");
|
xstring name = dw_item.GetItemDisplayString(row, L"ClassifyID");
|
double Quantity = dw_item.GetItemDouble(row, L"Quantity");
|
int Packages = dw_item.GetItemInt(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");
|
xstring VATRate = dw_item.GetItemString(row, L"VATRate");
|
xstring VATRefundRate = dw_item.GetItemString(row, L"VATRefundRate");
|
double Vol = dw_item.GetItemDouble(row, L"Volume");
|
xstring UnitPrice = dw_item.GetItemString(row, L"UnitPrice");
|
xstring UOMCode = dw_item.GetItemString(row, L"UOMCode");
|
xstring KOPCode = dw_item.GetItemString(row, L"KOPCode");
|
|
|
int i = 1;
|
for (i = 1; i <= dw_custom.GetRowCount(); i++)
|
{
|
if (dw_custom.GetItemString(i, L"ClassifyID") == ClassifyID && dw_custom.GetItemString(i, L"GroupNo") == GroupNo)
|
break;
|
}
|
if (i > dw_custom.GetRowCount())
|
{
|
dw_custom.InsertRow(0);
|
dw_customex.InsertRow(0);
|
i = dw_custom.GetRowCount();
|
}
|
|
dw_custom.SetItemString(i, L"ClassifyID", ClassifyID);
|
dw_customex.SetItemString(i, L"ClassifyID", ClassifyID);
|
dw_custom.SetItemString(i, L"CustName", name);
|
dw_customex.SetItemString(i, L"CustName", name);
|
dw_custom.SetItemString(i, L"GroupNo", GroupNo);
|
|
double val = 0;
|
double samt = 0;
|
val = dw_custom.GetItemDouble(i, L"Amount");
|
val += Amount;
|
samt = val;
|
dw_custom.SetItemDouble(i, L"Amount", val);
|
dw_custom.SetItemDouble(i, L"AmountEx", val);
|
dw_custom.SetItemString(i, L"VATRate", VATRate);
|
dw_custom.SetItemString(i, L"VATRefundRate", VATRefundRate);
|
dw_custom.SetItemString(i, L"UOMCode", UOMCode);
|
dw_custom.SetItemString(i, L"KOPCode", KOPCode);
|
dw_custom.SetItemDisplayString(i, L"UOMCode",
|
dw_item.GetItemDisplayString(row, L"UOMCode"));
|
dw_custom.SetItemDisplayString(i, L"KOPCode",
|
dw_item.GetItemDisplayString(row, L"KOPCode"));
|
dw_custom.SetItemString(i, L"CurrencyCode", CurrencyCode);
|
|
dw_customex.SetItemDouble(i, L"Amount", val);
|
dw_customex.SetItemDouble(i, L"AmountEx", val);
|
dw_customex.SetItemString(i, L"VATRate", VATRate);
|
dw_customex.SetItemString(i, L"VATRefundRate", VATRefundRate);
|
dw_customex.SetItemString(i, L"UOMCode", UOMCode);
|
dw_customex.SetItemString(i, L"KOPCode", KOPCode);
|
dw_customex.SetItemDisplayString(i, L"UOMCode",
|
dw_item.GetItemDisplayString(row, L"UOMCode"));
|
dw_customex.SetItemDisplayString(i, L"KOPCode",
|
dw_item.GetItemDisplayString(row, L"KOPCode"));
|
dw_customex.SetItemString(i, L"CurrencyCode", CurrencyCode);
|
|
val = dw_custom.GetItemDouble(i, L"Quantity");
|
val += Quantity;
|
double sqty = 0;
|
sqty = val;
|
dw_custom.SetItemDouble(i, L"Quantity", val);
|
dw_customex.SetItemDouble(i, L"Quantity", val);
|
|
val = dw_custom.GetItemDouble(i, L"GW");
|
val += GW;
|
dw_custom.SetItemDouble(i, L"GW", val);
|
dw_customex.SetItemDouble(i, L"GW", val);
|
|
val = dw_custom.GetItemDouble(i, L"NW");
|
val += NW;
|
dw_custom.SetItemDouble(i, L"NW", val);
|
dw_customex.SetItemDouble(i, L"NW", val);
|
|
int nval = dw_custom.GetItemDouble(i, L"Packages");
|
nval += Packages;
|
dw_custom.SetItemInt(i, L"Packages", nval);
|
dw_customex.SetItemInt(i, L"Packages", nval);
|
|
val = dw_custom.GetItemDouble(i, L"Volume");
|
val += Vol;
|
dw_custom.SetItemDouble(i, L"Volume", val);
|
dw_customex.SetItemDouble(i, L"Volume", val);
|
|
double price = samt / sqty;
|
dw_custom.SetItemDouble(i, L"UnitPrice", price);
|
dw_customex.SetItemDouble(i, L"UnitPrice", price);
|
xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyinfoex", L"ClassifyID", ClassifyID);
|
if (x)
|
{
|
KXMLDOMNode o = x.selectSingleNode(L"data/Item");
|
if (o)
|
{
|
if (o.selectSingleNode(L"VATRates"))
|
{
|
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());
|
}
|
if (o.selectSingleNode(L"SupervisionRuler"))
|
{
|
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());
|
}
|
if (o.selectSingleNode(L"HSCode"))
|
{
|
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");
|
|
str = str.left(str.find(L"[" + hscode));
|
dw_custom.SetItemString(i, L"CustName", str);
|
dw_customex.SetItemString(i, L"CustName", str);
|
}
|
dw_custom.SetItemString(i, L"HSCode", hscode);
|
dw_customex.SetItemString(i, L"HSCode", hscode);
|
}
|
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();
|
if (uom == L"ǧ¿Ë")
|
{
|
dw_custom.SetItemString(i, L"LegalQty", dw_custom.GetItemString(i, L"NW"));
|
dw_customex.SetItemString(i, L"LegalQty", dw_custom.GetItemString(i, L"NW"));
|
}
|
else
|
{
|
dw_custom.SetItemString(i, L"LegalQty", dw_custom.GetItemString(i, L"Quantity"));
|
dw_customex.SetItemString(i, L"LegalQty", dw_custom.GetItemString(i, L"Quantity"));
|
}
|
}
|
}
|
}
|
}
|
|
alert(L"±¨¹ØÊý¾ÝÒÑˢУ¬Çë¸üб¨¹ØÒªËØ!");
|
|
|
|
return 1;
|
}
|
|
int OnAddSourcingItem()
|
{
|
xaserverarg arg = GDNView::MakeArg();
|
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"")
|
{
|
xml x;
|
|
x.loadXML(str);
|
KXMLDOMNodeList items = x.selectNodes(L"data/Item");
|
int len = items.length();
|
int row = 0;
|
for (int i = 0; i < len; i++)
|
{
|
if (i == 0 && dw_source.GetRowCount() > 0 && dw_source.GetItemString(dw_source.GetRowCount(), L"GoodsNo") == L"")
|
{
|
row = dw_source.GetRowCount();
|
}
|
else
|
{
|
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"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());
|
}
|
CalcProfit();
|
}
|
return 1;
|
}
|
|
int OnDeleteSourceingItem()
|
{
|
dw_source.DeleteRow(0);
|
evalPurcharCost();
|
evalTotalCost();
|
CalcProfit();
|
return 1;
|
}
|
|
int OnAddGDNItems(xstring str)
|
{
|
|
if (str != L"")
|
{
|
trace(str);
|
xml x;
|
|
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");
|
xstring OperationTipss = dw_base.GetItemString(1, L"OperationTips");
|
xstring FrontMarkss = dw_base.GetItemString(1, L"Mark");
|
|
datareading = true;
|
double costs = 0.0;
|
double PrivateCommissionAmount = 0.0;
|
double PrivateCommissionAmountEx = 0.0;
|
for (int i = 0; i < len; i++)
|
{
|
if (i == 0 && dw_item.GetRowCount() > 0 && dw_item.GetItemString(dw_item.GetRowCount(), L"GoodsNo") == L"")
|
{
|
row = dw_item.GetRowCount();
|
}
|
else
|
{
|
row = dw_item.InsertRow(0);
|
}
|
KXMLDOMNode t = items.item(i);
|
dw_item.SetItemString(row, L"SeqNo", xstring((row * 10)));
|
dw_item.SetItemString(row, L"GDNID", dw_base.GetGuid(1));
|
double cost = (double) t.selectSingleNode(L"Cost").text().todouble();
|
|
|
if (t.selectSingleNode(L"SONo"))
|
{
|
xstring SONo = t.selectSingleNode(L"SONo").text();
|
if (SONos == L"")
|
{
|
SONos = SONo;
|
costs = cost;
|
}
|
else if (SONos.find(SONo) < 0)
|
{
|
SONos += L",L" + SONo;
|
costs += cost;
|
}
|
}
|
|
if (t.selectSingleNode(L"CustomerPONo"))
|
{
|
xstring CustomerPONo = t.selectSingleNode(L"CustomerPONo").text();
|
if (OrderNos == L"")
|
OrderNos = CustomerPONo;
|
else if (OrderNos.find(CustomerPONo) < 0) OrderNos += L",L" + CustomerPONo;
|
}
|
|
if (t.selectSingleNode(L"OperationTips"))
|
{
|
xstring OperationTips = t.selectSingleNode(L"OperationTips").text();
|
if (OperationTipss == L"")
|
OperationTipss = OperationTips;
|
else if (OperationTipss.find(OperationTips) < 0) OperationTipss += L"\r\n" + OperationTips;
|
}
|
|
if (t.selectSingleNode(L"FrontMarks"))
|
{
|
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());
|
|
//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"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"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"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"ShipQuantity"))
|
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());
|
|
double d1 = dw_item.GetItemDouble(row, L"Quantity");
|
double d2 = dw_item.GetItemDouble(row, L"UnitPrice");
|
double d = d1 * d2;
|
d = d.round(2);
|
dw_item.SetItemDouble(row, L"Amount", d);
|
|
double UnitCommPrice = dw_item.GetItemDouble(row, L"UnitCommPrice");
|
double MiddlemanAmount = dw_item.GetItemDouble(row, L"MiddlemanAmount");
|
double Quantity = dw_item.GetItemDouble(row, L"Quantity");
|
double ResearchCommission = UnitCommPrice * Quantity;
|
double MiddlemanAmountRate = MiddlemanAmount * Quantity;
|
PrivateCommissionAmount += ResearchCommission;
|
PrivateCommissionAmountEx += MiddlemanAmountRate;
|
//if(t.selectSingleNode(L"Amount"))dw_item.SetItemString(row,L"Amount",t.selectSingleNode(L"Amount").text());
|
|
|
RefreshSourcingItem(row, false);
|
|
}
|
|
dw_base.SetItemString(1, L"SONos", SONos);
|
dw_base.SetItemString(1, L"OrderNos", OrderNos);
|
dw_base.SetItemString(1, L"OperationTips", OperationTipss);
|
dw_base.SetItemString(1, L"Mark", FrontMarkss);
|
|
double CostEx = dw_base.GetItemDouble(1, L"Cost");
|
if (CostEx == 0 || CostEx == L"")
|
{
|
if (costs >= 0) {
|
dw_base.SetItemString(1, L"CostMoreLess", L"1");
|
dw_base.SetItemDisplayString(1, L"CostMoreLess", L"PLUS");
|
dw_base.SetItemDouble(1, L"Cost", costs);
|
}
|
else {
|
dw_base.SetItemString(1, L"CostMoreLess", L"-1");
|
dw_base.SetItemDisplayString(1, L"CostMoreLess", L"LESS");
|
dw_base.SetItemDouble(1, L"Cost", costs * -1);
|
}
|
}
|
dw_base.SetItemDouble(1, L"PrivateCommissionAmount", PrivateCommissionAmount + PrivateCommissionAmountEx);
|
datareading = false;
|
calcTotal();
|
evalTotalCost();
|
//RefreshSourcingAllEx();
|
CalcProfit();
|
}
|
return 1;
|
}
|
|
int OnAddGDNItem()
|
{
|
//trace(L"12313");
|
xaserverarg arg = GDNView::MakeArg();
|
arg.AddArg(L"CustomerID", dw_base.GetItemString(1, L"CustomerID"));
|
arg.AddArg(L"InvoiceNo", dw_base.GetItemString(1, L"InvoiceNo"));
|
arg.AddArg(L"SONo", dw_base.GetItemString(1, L""));
|
int p = arg;
|
if (dw_base.GetItemString(1, L"CustomerID") == L"")
|
{
|
OpenWindow(L"dev:xpage[SelectItem.New.GDN.vx]", cast(arg as int));
|
if (dw_base.GetItemString(1, L"CustomerID") == L"")
|
{
|
dw_base.SetItemDisplayString(1, L"CustomerID", arg.GetArgString(L"PartyName"));
|
dw_base.ItemChangeTo(1, L"CustomerID", arg.GetArgString(L"PartyID"));
|
dw_profit.ItemChangeTo(1, L"CustomerID", arg.GetArgString(L"PartyID"));
|
dw_profit.SetItemDisplayString(1, L"CustomerID", arg.GetArgString(L"PartyName"));
|
}
|
}
|
else
|
{
|
OpenWindow(L"dev:xpage[select.gdnitem.so.vx]", p);
|
}
|
|
xstring str = arg.GetArgString(L"items");
|
trace(L"*****");
|
return OnAddGDNItems(str);
|
}
|
|
int OnCDElementMatch()
|
{
|
for (int i = 1; i <= dw_custom.GetRowCount(); i++)
|
{
|
xstring ClassifyID = dw_custom.GetItemString(i, L"ClassifyID");
|
KXMLDOMElement e1 = dw_custom.GetRowElement(i);
|
xstring CDLineID = e1.getAttribute(L"guid");
|
if (CDLineID == L"")
|
{
|
e1.setAttribute(L"guid", ViewObject::GetGuid());
|
CDLineID = e1.getAttribute(L"guid");
|
}
|
|
for (int row = 1; row <= dw_cdelement.GetRowCount(); row++)
|
{
|
if (ClassifyID == dw_cdelement.GetItemString(row, L"ClassifyID"))
|
{
|
dw_cdelement.SetItemString(row, L"CDLineID", CDLineID);
|
dw_cdelement.SetItemString(row, L"GDNID", dw_base.GetGuid(1));
|
dw_cdelement.SetItemString(row, L"HSCode", dw_custom.GetItemString(i, L"HSCode"));
|
dw_cdelement.Redraw();
|
}
|
}
|
}
|
return 1;
|
}
|
|
int OnCDElement()
|
{
|
|
while (dw_cdelement.GetRowCount() > 0) {
|
dw_cdelement.DeleteRow(dw_cdelement.GetRowCount());
|
}
|
|
for (int i = 1; i <= dw_custom.GetRowCount(); i++)
|
{
|
xstring ClassifyID = dw_custom.GetItemString(i, L"ClassifyID");
|
xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyelement", L"ClassifyID", ClassifyID);
|
if (x)
|
{
|
KXMLDOMNodeList items = x.selectNodes(L"/GDN/CDElement");
|
int lens = items.length();
|
for (int k = 0; k < lens; k++)
|
{
|
int row = dw_cdelement.InsertRow(0);
|
KXMLDOMElement e = items.item(k);
|
|
KXMLDOMElement e1 = dw_custom.GetRowElement(i);
|
xstring CDLineID = e1.getAttribute(L"guid");
|
if (CDLineID == L"")
|
{
|
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"EleName"))
|
{
|
if(e.selectSingleNode(L"EleName").text==L"Æ·ÅÆÀàÐÍ")
|
{
|
if(dw_base.GetItemString(1,L"POL")==L"NINGBO")
|
{
|
dw_cdelement.SetItemString(row,L"EleContent",L"¾³ÄÚ×ÔÖ÷Æ·ÅÆ");
|
}else
|
{
|
dw_cdelement.SetItemString(row,L"EleContent",L"ÎÞÆ·ÅÆ");
|
}
|
}
|
else if(e.selectSingleNode(L"EleName").text==L"³ö¿ÚÏí»ÝÇé¿ö")
|
{
|
xstring country = dw_base.GetItemString(1,L"FinalCountry");
|
if(country==L"")
|
{
|
dw_cdelement.SetItemString(row,L"EleContent",L"²»ÏíÊÜ");
|
}
|
else if(L"601,127,322,129,415,337,133,107,119,122,103,434,106,331,134,136,105,132,609,111,112,141,412,143".find(country)>=0)
|
{
|
dw_cdelement.SetItemString(row,L"EleContent",L"ÏíÊÜ");
|
}else
|
{
|
dw_cdelement.SetItemString(row,L"EleContent",L"²»ÏíÊÜ");
|
}
|
}
|
}*/
|
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());
|
}
|
}
|
}
|
|
return 1;
|
}
|
|
int OnDeleteGDNItem()
|
{
|
if (dw_item.GetRow() < 1) return 1;
|
ClearSourcingItem(dw_item.GetRow());
|
dw_item.DeleteRow(0);
|
calcTotal();
|
evalTotalCost();
|
CalcProfit();
|
|
xstring PONo_s = L"";
|
xstring SONo_s = L"";
|
for (int k = 1; k <= dw_item.GetRowCount(); k++)
|
{
|
xstring SONo = dw_item.GetItemString(k, L"SONo");
|
if (SONo_s == L"")
|
{
|
SONo_s = SONo;
|
}
|
else if (SONo_s.find(SONo) < 0)
|
{
|
SONo_s += L",L" + SONo;
|
}
|
xstring PONo = dw_item.GetItemString(k, L"PONo");
|
if (PONo_s == L"")
|
{
|
PONo_s = PONo;
|
}
|
else if (PONo_s.find(PONo) < 0)
|
{
|
PONo_s += L",L" + PONo;
|
}
|
}
|
dw_base.SetItemString(1, L"OrderNos", PONo_s);
|
dw_base.SetItemString(1, L"SONos", SONo_s);
|
return 1;
|
}
|
|
//ÃüÁî·¢²¼º¯Êý
|
int OnCmdDispatch(xstring comdid)
|
{
|
if (comdid.find(L"bill.update") > 0)
|
{
|
return OnSave();
|
}
|
if (comdid == L"xmCDElementMatch")
|
{
|
return OnCDElementMatch();
|
}
|
if (comdid == L"xmSaveAs")
|
{
|
int i = dw_item.SaveAs(L"");
|
if (i == 1)
|
alert(L"µ¼³ö³É¹¦");
|
return 1;
|
}
|
if (comdid == L"xmSearch")
|
{
|
|
xaserverarg& arg1 = *new xaserverarg;
|
|
arg1.AddArg(L"text", searchStr);
|
|
if (tabname == L"sourcing")
|
{
|
OpenWindow(L"dev:xpage[search.dialog.vx]", (LPARAM)&arg1);
|
xstring str = arg1.GetArgString(L"text");
|
searchStr = str;
|
dw_source.Filter(L"*", searchStr);
|
return 1;
|
}
|
else if (tabname == L"goods")
|
{
|
OpenWindow(L"dev:xpage[search.dialog.vx]", (LPARAM)&arg1);
|
xstring str = arg1.GetArgString(L"text");
|
searchStr = str;
|
dw_item.Filter(L"*", searchStr);
|
return 1;
|
}
|
return 1;
|
}
|
if (comdid == L"action:bill.SourceRemark") return OnSourceRemark();
|
if (comdid == L"action:bill.GDNDelay")
|
{
|
xstring EntityIDEx = dw_base.GetGuid(1);
|
xaserverarg& argEx = *new xaserverarg;
|
|
trace(EntityIDEx);
|
argEx.AddArg(L"GDNID", EntityIDEx);
|
OpenWindow(L"dev:xpage[GDNDelay.vx]", (LPARAM)&argEx);
|
return 1;
|
}
|
if (comdid == L"action:bill.Volume")
|
{
|
calcTotal();
|
return 1;
|
}
|
if (comdid.find(L"bill.print") > 0)
|
{
|
xstring EntityID1 = dw_base.GetGuid(1);
|
xml x1 = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNJudge", L"GDNID", EntityID1);
|
xstring Results1 = x1.text();
|
if (Results1 != L"")
|
{
|
alert(Results1);
|
return 0;
|
}
|
|
OnPrintOne();
|
OnPrint();
|
return 1;
|
}
|
if (comdid == L"action:bill.check.ask")
|
{
|
xstring ApprovalStatus = dw_base.GetItemString(1, L"ApprovalStatus");
|
if (ApprovalStatus == L"9")
|
{
|
alert(L"ºÏ²¢Æ±²»ÔÊÐíÌá½»ÉóÅú!");
|
return 0;
|
}
|
if (dw_cdelement.GetRowCount() < 1)
|
{
|
alert(L"ÇëÉú³É±¨¹ØÒªËØ!");
|
return 0;
|
}
|
if (dw_source.GetRowCount() < 1)
|
{
|
alert(L"²É¹º»õԴδÉú³É!");
|
return 0;
|
}
|
|
xstring EntityID = dw_base.GetGuid(1);
|
xml xx = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNJudge", L"GDNID", EntityID);
|
xstring Results = xx.text();
|
if (Results != L"")
|
{
|
alert(Results);
|
return 0;
|
}
|
|
xml xx1 = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNJudgeEx", L"GDNID", EntityID);
|
xstring Results2 = xx1.text();
|
if (Results2 != L"")
|
{
|
alert(Results2);
|
return 0;
|
}
|
|
xml xx3 = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNJudgeExS", L"GDNID", EntityID);
|
xstring Results3 = xx3.text();
|
if (Results3 != L"")
|
{
|
alert(Results3);
|
return 0;
|
}
|
|
xml xx4 = ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNJudgeAmount", L"GDNID", EntityID);
|
xstring Results4 = xx4.text();
|
if (Results4 != L"")
|
{
|
alert(Results4);
|
return 0;
|
}
|
|
/* xml xx5= ViewObject::RetrieveData(L"/sale/data/GDN/GetGDNCost",L"GDNID",EntityID);
|
xstring Results5=xx5.text();
|
if(Results5 !=L"")
|
{
|
alert(Results5);
|
return 0;
|
}*/
|
|
xaserverarg& arg7 = *new xaserverarg;
|
|
trace(EntityID);
|
arg7.AddArg(L"GDNID", EntityID);
|
OpenWindow(L"dev:xpage[GDNDelay.vx]", (LPARAM)arg7);
|
|
}
|
if (comdid.find(L"action:", 0) >= 0)
|
{
|
int ret = ProcessFlowAction(comdid, 1);
|
}
|
if (comdid == L"xmRefreshSourcingAll")
|
{
|
if (dw_base.GetItemString(1, L"InvoiceNo") == L"")
|
{
|
alert(L"ÇëÏȱ£´æ£¬ÔÚˢлõÔ´£¡");
|
return 1;
|
}
|
return RefreshSourcingAllEx();
|
}
|
if (comdid == L"xmMakeGdnLineEx")
|
{
|
return OnMakeGdnLineEx();
|
}
|
if (comdid == L"xmRefreshSourcingItem")
|
{
|
if (dw_base.GetItemString(1, L"InvoiceNo") == L"")
|
{
|
alert(L"ÇëÏȱ£´æ£¬ÔÚˢлõÔ´£¡");
|
return 1;
|
}
|
return RefreshSourcingItem1(dw_item.GetRow());
|
}
|
|
if (comdid == L"xmMakeContainer")
|
{
|
return OnMakeContainer();
|
}
|
else if (comdid == L"xmCDElement")
|
{
|
return OnCDElement();
|
}
|
else if (comdid == L"tab_goods")
|
{
|
tabname = L"goods";
|
SetAgentEx();
|
return 1;
|
}
|
else if (comdid == L"tab_sourcing")
|
{
|
tabname = L"sourcing";
|
SetAgentEx();
|
return 1;
|
}
|
else if (comdid == L"tab_profit")
|
{
|
tabname = L"profit";
|
SetAgentEx();
|
return 1;
|
}
|
else if (comdid == L"tab_cdelement")
|
{
|
tabname = L"cdelement";
|
SetAgentEx();
|
return 1;
|
}
|
else if (comdid == L"tab_base")
|
{
|
tabname = L"base";
|
SetAgentEx();
|
return 1;
|
}
|
else if (comdid == L"makeCustom")
|
{
|
OnMakeSumPack();
|
return OnMakeCustom();
|
}
|
else if (comdid == L"xmDeleteRow")
|
{
|
dw_item.DeleteRow(0);
|
return 1;
|
}
|
else if (comdid == L"xmAddItem")
|
{
|
//dw_item.InsertRow(0);
|
PoTotal();//ÐÂÔöʱûÓÐ×÷ÓÃ
|
return OnAddGDNItem();
|
}
|
else if (comdid == L"xmDeleteItem")
|
{
|
//dw_item.DeleteRow(0);
|
return OnDeleteGDNItem();
|
}
|
else if (comdid == L"xmAddSourcingItem")
|
{
|
return OnAddSourcingItem();
|
}
|
if (comdid == L"xmDeleteSourcingItem")
|
{
|
return OnDeleteSourceingItem();
|
}
|
else if (comdid == L"xmSave")
|
{
|
OnSave();
|
return 1;
|
}
|
else if (comdid == L"xmPrint")
|
{
|
OnPrint();
|
return 1;
|
}
|
else if (comdid == L"xmClose")
|
{
|
//CloseWindow();
|
return 1;
|
}
|
else if (comdid == L"xmCalcProfit")
|
{
|
CalcProfit();
|
return 1;
|
}
|
else if (comdid == L"xmGDNSourcePaperCard")
|
{
|
if (dw_base.GetItemString(1, L"InvoiceNo") != L"")
|
{
|
xaserverarg& arg2 = *new xaserverarg;
|
|
arg2.AddArg(L"InvoiceNo", dw_base.GetItemString(1, L"InvoiceNo"));
|
//arg2.AddArg(L"HWND", GetHWND().toString());
|
arg2.SetParam(L"HWND", (LPARAM)GetHWND());
|
OpenWindow(L"dev:xpage[GDNSourcePaperCard.vx]",(LPARAM)&arg2);
|
}
|
else
|
{
|
alert(L"ÇëÏȱ£´æ³öÔËÐÅÏ¢£¬ÔÚÐÞ¸ÄÖ½¿¨¿ªÆ±£¡");
|
}
|
return 1;
|
}
|
else if (comdid == L"xmRefreshSource")
|
{
|
xstring invno = dw_base.GetItemString(1, L"InvoiceNo");
|
OnRefreshSource(invno);
|
return 1;
|
}
|
else if (comdid == L"xmMaintBuyPrice")
|
{
|
xaserverarg arg = GDNView::MakeArg();
|
int row = dw_source.GetRow();
|
if (row < 1) return 1;
|
arg.AddArg(L"SupplierID", dw_source.GetItemString(row, L"SupplierID"));
|
arg.AddArg(L"SupplierName", dw_source.GetItemDisplayString(row, L"SupplierID"));
|
arg.AddArg(L"Price", dw_source.GetItemString(row, L"BuyUnitPrice"));
|
OpenWindow(L"dev:xpage[GDNSourcePriceMaint.vx]", cast(arg as int));
|
if (arg.GetArgString(L"result") == L"ok")
|
{
|
if (arg.GetArgString(L"SupplierID") != L"")
|
{
|
dw_source.SetItemString(row, L"SupplierID", arg.GetArgString(L"SupplierID"));
|
dw_source.SetItemDisplayString(row, L"SupplierID", arg.GetArgString(L"SupplierName"));
|
}
|
if (arg.GetArgString(L"Price") != L"" && arg.GetArgString(L"Price") != L"0.00")
|
dw_source.ItemChangeTo(row, L"BuyUnitPrice", arg.GetArgString(L"Price"));
|
dw_source.Redraw();
|
}
|
}
|
return 0;
|
}
|
|
int OnSourceRemark()
|
{
|
xstring name = L"³öÔËÃ÷ϸµ¥";
|
xml x = ViewObject::RetrieveData(L"/sale/data/TradeFinance3/GetSetUpRemarks", L"Type", name);
|
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();
|
}
|
xaserverarg arg1 ;
|
|
arg1.AddArg(L"value", Content);
|
OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg1);
|
|
return 1;
|
}
|
|
int OnPrintOne()
|
{
|
xstring GDNID = dw_base.GetGuid(1);
|
xml x = ViewObject::RetrieveData(L"/sale/data/GDN/CheckGW", L"GDNID", GDNID);
|
xstring r = x.text();
|
int r1 = r.toInt();
|
if (x)
|
{
|
if (r1 > 0)
|
{
|
alert(L"Ã«ÖØ×ÜÁ¿»ò¾»×ÜÖØÁ¿²»Ò»Ö£¬ÐèÒªºË¶Ô£¡");
|
}
|
}
|
|
|
xml xs = ViewObject::RetrieveData(L"/sale/data/GDN/CheckCDLine", L"GDNID", GDNID);
|
xstring rs = xs.text();
|
int rs1 = rs.toInt();
|
if (xs)
|
{
|
if (rs1 > 0)
|
{
|
alert(L"±¨¹ØÊýÁ¿ºÍ±¨¹Ø½ð¶îÓë³öÔËÊýÁ¿ºÍ½ð¶î²»Ò»ÖÂ\r\n²¿·Ö±¨¹ØÊýÁ¿ºÍ½ð¶îÐèÒªºË¶Ô£¡");
|
}
|
}
|
|
//alert(GDNID);
|
return 1;
|
}
|
//ÃüÁî´¦Àíʼþ
|
int OnXCommand(TEvent* evt, int param)
|
{
|
return OnCmdDispatch(evt->xcommand.pStrID);
|
}
|
|
//·çÏÕ¼ÆÌá
|
int evalRisk()
|
{
|
xstring CurrencyCode = dw_base.GetItemString(1, L"CurrencyCode");
|
double amt = dw_profit.GetItemDouble(1, L"Amount");
|
xstring exchRate = L"";
|
xstring exchRate2 = L"";
|
|
xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", 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");
|
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")
|
{
|
if (exchRate != L"")
|
{
|
amt = amt / cryrate;
|
|
}
|
}
|
|
dw_profit.SetItemDouble(1, L"RiskPrepareFee", amt * rate);
|
return 1;
|
}
|
|
//²É¹º³É±¾
|
|
|
int evalPurcharCost()
|
{
|
double cost = dw_source.GetItemSumDouble(L"BuyAmount");
|
dw_profit.SetItemDouble(1, L"Cost", cost);
|
return 1;
|
}
|
|
//ÍË˰
|
int evalDrawback()
|
{
|
//calc Drawback
|
double retax = 0;
|
double tax = 0;
|
double cost = 0;
|
double Drawback = 0;
|
for (int k = 1; k <= dw_item.GetRowCount(); k++)
|
{
|
KXMLDOMElement e = dw_item.GetRowElement(k);
|
xstring gdnLineID = e.getAttribute(L"guid");
|
xstring ClassifyID = dw_item.GetItemString(k, L"ClassifyID");
|
retax = 16;
|
tax = 16;
|
|
if (ClassifyID != L"")
|
{
|
//trace(L"\r\n" + ClassifyID);
|
xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyinfo", L"ClassifyID", ClassifyID);
|
if (x)
|
{
|
// trace(L"\r\n" + x.GetXml());
|
KXMLDOMNode o = x.selectSingleNode(L"data/Item");
|
if (o)
|
{
|
KXMLDOMNode n = o.selectSingleNode(L"VATRates");
|
if (n)
|
{
|
tax = n.text.toDouble();
|
n.Release();
|
}
|
n = o.selectSingleNode(L"VATRefundRate");
|
if (n)
|
{
|
retax = n.text.toDouble();
|
n.Release();
|
}
|
o.Release();
|
}
|
x.Release();
|
}
|
}
|
|
cost = 0;
|
for (int m = 1; m <= dw_source.GetRowCount(); m++)
|
{
|
if (dw_source.GetItemString(m, L"GDNLineID") == gdnLineID)
|
cost += dw_source.GetItemDouble(m, L"BuyAmount");
|
}
|
Drawback += cost / (100.0 + tax) * retax;
|
}
|
dw_profit.SetItemDouble(1, L"Drawback", Drawback);
|
return 1;
|
}
|
|
int evalDrawbackEx()
|
{
|
double Drawback = 0.0;
|
for (int m = 1; m <= dw_source.GetRowCount(); m++)
|
{
|
double RefundAmount = dw_source.GetItemDouble(m, L"RefundAmount");
|
Drawback += RefundAmount;
|
}
|
dw_profit.SetItemDouble(1, L"Drawback", Drawback);
|
return 1;
|
}
|
|
int evalManagementFee()
|
{
|
xstring CurrencyCode = dw_base.GetItemString(1, L"CurrencyCode");
|
xstring expRate = L"";
|
xstring exchRate = L"";
|
|
xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", 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");
|
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 >= L"2023-01-01")
|
{
|
expRate = L"0.2";
|
}
|
|
double sale = dw_profit.GetItemDouble(1, L"Amount");
|
double ManagementFee = 0;
|
if (CurrencyCode == L"RMB" || CurrencyCode == L"CNY")
|
{
|
if (exchRate != L"")
|
{
|
double r1 = exchRate.toDouble();//»ãÂÊ
|
|
double r2 = expRate.toDouble(); //¹«Ë¾¹ÜÀí
|
|
ManagementFee = (sale / r1) * r2;
|
}
|
}
|
else
|
{
|
double rate = expRate.toDouble();
|
ManagementFee = sale * rate;
|
}
|
trace(ManagementFee.toString());
|
dw_profit.SetItemDouble(1, L"ManagementFee", ManagementFee);
|
return 1;
|
}
|
|
//·çÏÕ»ù½ð
|
int evalRiskFundAmount()
|
{
|
xstring CurrencyCode = dw_base.GetItemString(1, L"CurrencyCode");
|
xstring expRate = L"";
|
xstring exchRate = L"";
|
|
xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", 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");
|
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 < L"2023-01-01")
|
{
|
//alert(L"1");
|
expRate = L"0.0";
|
}
|
|
double sale = dw_profit.GetItemDouble(1, L"Amount");
|
double RiskFundAmount = 0;
|
if (CurrencyCode == L"RMB" || CurrencyCode == L"CNY")
|
{
|
if (exchRate != L"")
|
{
|
double r1 = exchRate.toDouble();//»ãÂÊ
|
|
double r2 = expRate.toDouble();
|
|
RiskFundAmount = (sale / r1) * r2;
|
}
|
}
|
else
|
{
|
double rate = expRate.toDouble();
|
RiskFundAmount = sale * rate;
|
}
|
//alert(L"+++L"+ETDEx+L"+++L"+rate.toString()+L"+++L"+sale.toString()+L"+++L"+RiskFundAmount.toString()+L"+++L");
|
dw_profit.SetItemDouble(1, L"RiskFundAmount", RiskFundAmount);
|
return 1;
|
}
|
|
//×ܳɱ¾
|
int evalTotalCost()
|
{
|
double ttl = 0;
|
ttl = dw_profit.GetItemDouble(1, L"Cost");
|
|
ttl -= dw_profit.GetItemDouble(1, L"Drawback");
|
ttl += dw_profit.GetItemDouble(1, L"DrawbackIntrest");
|
ttl += dw_profit.GetItemDouble(1, L"CustomFee");
|
ttl += dw_profit.GetItemDouble(1, L"InspectionFee");
|
ttl += dw_profit.GetItemDouble(1, L"PaperCardCopyFee");
|
ttl += dw_profit.GetItemDouble(1, L"TransportationFee");
|
ttl += dw_profit.GetItemDouble(1, L"StorageFee");
|
ttl += dw_profit.GetItemDouble(1, L"PortIncidentalFee");
|
ttl += dw_profit.GetItemDouble(1, L"RiskPrepareFee");
|
ttl += dw_profit.GetItemDouble(1, L"AllocatedFee");
|
ttl += dw_profit.GetItemDouble(1, L"ManagementFee");
|
ttl += dw_profit.GetItemDouble(1, L"RiskFundAmount");
|
ttl += dw_profit.GetItemDouble(1, L"FundsIntrestFee");
|
ttl -= dw_profit.GetItemDouble(1, L"AgentAmount");
|
ttl += dw_profit.GetItemDouble(1, L"AgentTax");
|
ttl += dw_profit.GetItemDouble(1, L"OtherFee");
|
|
dw_profit.SetItemDouble(1, L"TotalCostEx", ttl);
|
|
return 1;
|
}
|
|
//ÏúÊÛ
|
int evalSale()
|
{
|
dw_profit.SetItemString(1, L"Quantity", dw_base.GetItemString(1, L"Quantity"));
|
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"CommissionAmount",dw_base.GetItemString(1,L"CommissionAmount"));
|
|
double comm1 = dw_base.GetItemDouble(1, L"CommissionAmount");
|
double comm2 = dw_base.GetItemDouble(1, L"PrivateCommissionAmount");
|
double comm3 = dw_base.GetItemDouble(1, L"DiscountAmount");
|
double comm = comm1 + comm2 + comm3;
|
dw_profit.SetItemDouble(1, L"CommissionAmount", comm);
|
|
xstring cost = dw_base.GetItemString(1, L"Cost");
|
if (cost != L"")
|
{
|
xstring lessa = dw_base.GetItemString(1, L"CostMoreLess");
|
double costAmt = cost.toDouble();
|
if (lessa == L"-1") costAmt = 0.0 - costAmt;
|
dw_profit.SetItemDouble(1, L"SaleExternCost", costAmt);
|
}
|
else
|
dw_profit.SetItemDouble(1, L"SaleExternCost", 0.0);
|
|
|
double ttl = 0;
|
ttl = dw_base.GetItemDouble(1, L"Amount");
|
ttl -= dw_base.GetItemDouble(1, L"Freight");
|
ttl -= dw_base.GetItemDouble(1, L"InsuranceAmount");
|
ttl -= dw_base.GetItemDouble(1, L"CommissionAmount");
|
ttl -= dw_base.GetItemDouble(1, L"PrivateCommissionAmount");
|
ttl -= dw_base.GetItemDouble(1, L"DiscountAmount");
|
ttl += dw_profit.GetItemDouble(1, L"SaleExternCost");
|
|
|
xstring CurrencyCode = dw_base.GetItemString(1, L"CurrencyCode");
|
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");
|
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") {
|
//dw_profit.SetItemString(1,L"ExchangeRate",exchangeRate);
|
dw_profit.SetItemDouble(1, L"ExchangeAmountEx", ttl);
|
}
|
|
if (CurrencyCode == L"RMB" || CurrencyCode == L"CNY")
|
{
|
//exchangeRate=L"6.6";
|
dw_profit.SetItemDouble(1, L"ExchangeAmountEx", ttl / exchangeRate.toDouble());
|
}
|
|
return 1;
|
}
|
|
int evalProfitAmount()
|
{
|
|
double sale = dw_profit.GetItemDouble(1, L"ExchangeAmountEx");
|
double exchRate = dw_profit.GetItemDouble(1, L"ExchangeRate");
|
double ttl = dw_profit.GetItemDouble(1, L"TotalCostEx");
|
double drawback = dw_profit.GetItemDouble(1, L"Drawback");
|
if (exchRate != 0)
|
{
|
dw_profit.SetItemDouble(1, L"ProfitAmountEx", sale * exchRate - ttl);
|
dw_base.SetItemDouble(1, L"ProfitAmountEx", sale * exchRate - ttl);
|
}
|
else
|
{
|
dw_profit.SetItemString(1, L"ProfitAmountEx", L"");
|
dw_base.SetItemString(1, L"ProfitAmountEx", L"");
|
}
|
if (sale != 0.0)
|
{
|
double amt1 = ttl;
|
amt1 = amt1 / sale;
|
dw_profit.SetItemDouble(1, L"ExchangeCostEx", amt1);
|
}
|
else
|
dw_profit.SetItemString(1, L"ExchangeCostEx", L"");
|
|
return 1;
|
}
|
|
int evalProfitAmountEx()
|
{
|
double amount = dw_profit.GetItemDouble(1, L"Amount");
|
double cost = dw_profit.GetItemDouble(1, L"Cost");
|
|
double sale = dw_profit.GetItemDouble(1, L"ExchangeAmountEx");
|
double exchRate = dw_profit.GetItemDouble(1, L"ExchangeRate");
|
double ttl = dw_profit.GetItemDouble(1, L"TotalCostEx");
|
double drawback = dw_profit.GetItemDouble(1, L"Drawback");
|
if (exchRate != 0)
|
{
|
dw_profit.SetItemDouble(1, L"ProfitAmountEx", sale * exchRate - ttl);
|
dw_base.SetItemDouble(1, L"ProfitAmountEx", sale * exchRate - ttl);
|
}
|
else
|
{
|
dw_profit.SetItemString(1, L"ProfitAmountEx", L"");
|
dw_base.SetItemString(1, L"ProfitAmountEx", L"");
|
}
|
if (amount != 0.0)
|
{
|
double amt1 = cost;
|
amt1 = amt1 / amount;
|
|
dw_profit.SetItemDouble(1, L"ExchangeCostEx", amt1);
|
for (int m = 1; m <= dw_source.GetRowCount(); m++)
|
{
|
//dw_source.SetItemDouble(m,L"Swapthecost",amt1);
|
}
|
}
|
else
|
dw_profit.SetItemString(1, L"ExchangeCostEx", L"");
|
dw_source.Redraw();
|
return 1;
|
}
|
|
int CalcProfit()
|
{
|
evalSale();
|
evalManagementFee();
|
evalRiskFundAmount();
|
evalRisk();
|
evalPurcharCost();
|
evalDrawbackEx();
|
evalTotalCost();
|
evalProfitAmountEx();
|
}
|
|
int OnItemAskStyle(TEvent* evt, LPARAM p)
|
{
|
int DMS_CSSSTYLE = 0x8;
|
DWASKSTYLENMHDR& hdr = *(DWASKSTYLENMHDR*)evt->notify.pnmh;
|
int row = hdr.row;
|
int col = hdr.col;
|
xstring colname = hdr.colname;
|
|
int rows = dw_item.GetRowCount();
|
if (row < 1 || row > rows)
|
{
|
return 1;
|
}
|
|
if (colname == L"Packages")
|
{
|
int PackingRate = dw_item.GetItemString(row, L"PackingRate").toInt();
|
int Quantity = dw_item.GetItemString(row, L"Quantity").toInt();
|
if (PackingRate != 0)
|
{
|
if ((Quantity / PackingRate) * PackingRate != Quantity)
|
{
|
hdr.mask = DMS_CSSSTYLE;
|
hdr.pCssStyle = (wchar_t*)L"color:#ff0000";
|
}
|
}
|
}
|
return 1;
|
}
|
|
int OnAttachEvent()
|
{
|
//°ó¶¨¹¤¾ßÌõµã»÷ʼþ
|
AttachEvent(L"WM_XCOMMAND", L"DWV_CLICKED", (FEvent)&GDN3MaintWin::OnXCommand);
|
//»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
|
AttachEvent(L"WM_SETFOCUS", (FEvent)&GDN3MaintWin::OnSetFocus);
|
|
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", (FEvent)&GDN3MaintWin::OnBaseItemChanged);
|
|
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();
|
|
}
|
|
int RetrieveUseBuffer(xstring invno)
|
{
|
|
xml x;
|
x = new xml;
|
|
xaserverarg arg;
|
|
arg.AddArg(L"EntityID", GetEntityID(1));
|
arg.AddArg(L"invno", invno);
|
|
//int t0 = win32::GetTickCount();
|
//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.text());
|
return -1;
|
}
|
|
//trace(x.GetXml());
|
//trace(L"\r\n³öÔËÊý¾Ý¶ÁÈ¡:"+(win32::GetTickCount() - t0).toString());
|
|
KXMLDOMElement ele;
|
KXMLDOMNode node;
|
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);
|
|
if (node)
|
{
|
ele = node;
|
//node.release();
|
//dw_base.Retrieve(ele);
|
//ele.release();
|
|
dw_billnote.Retrieve(ele);
|
if (dw_billnote.GetRowCount() < 1)
|
{
|
xml x0;
|
x0 = new xml;
|
x0.setNativePointer(xml::CreateInstance());
|
xstring billnote = L"<GDN><DocInfo><data><Item Name='±¨¹Ø·¢Æ±' Field='Remark'></Item>" +
|
"<Item Name='±¨¹ØÏäµ¥' Field='Remark'></Item>" +
|
"<Item Name='Ò鸶·¢Æ±' Field='Remark'></Item>" +
|
"<Item Name='Ò鸶Ïäµ¥' Field='Remark'></Item>" +
|
"<Item Name='×°´¬Í¨Öª' Field='Remark'></Item>" +
|
"<Item Name='¼ÓÄô󺣹ط¢Æ±' Field='Remark'></Item>" +
|
"<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>";
|
x0.loadXML(billnote);
|
dw_billnote.Retrieve(x0);
|
}
|
}
|
/*node = xdoc.selectSingleNode(L"data/Item[@subject='GDNProfit' or @subject='profit']/*");
|
if(node)
|
{
|
ele = node;
|
//node.release();
|
dw_profit.Retrieve(ele);
|
// ele.release();
|
}*/
|
dw_profit.DwRetrieve(GetServerUrl(), L"[profit.dgn.sql.xq]", L"EntityID", InvoiceID);
|
dw_item.DwRetrieve(GetServerUrl(), L"[gdnline.gdn.sql.xq]", L"EntityID", InvoiceID);
|
dw_item.SetSelectionMode(1);
|
if (dw_item.GetRowCount() < 1)
|
{
|
xml x2 = xml::Make();
|
x2.loadXML(L"<GDN/>");
|
dw_item.Retrieve(x2);
|
x2.Free();
|
}
|
|
/*
|
node = xdoc.selectSingleNode(L"data/Item[@subject='GDNLine' or @subject='gdnline']/*");
|
if(node)
|
{
|
ele = node;
|
//node.release();
|
dw_item.Retrieve(ele);
|
ele.release();
|
}*/
|
|
node = xdoc.selectSingleNode(L"data/Item[@subject='GDNLineEx' or @subject='gdnlineex']/*");
|
if (node)
|
{
|
ele = node;
|
//node.release();
|
dw_invoiceItem.Retrieve(ele);
|
ele.release();
|
}
|
//alert(L"123"+InvoiceID);
|
//dw_source.DwRetrieve(GetServerUrl(),L"[source.gdn.sql.xq]", L"EntityID", InvoiceID);
|
//dw_source.SetSelectionMode(1);
|
|
node = xdoc.selectSingleNode(L"data/Item[@subject='GDNSource' or @subject='source']/*");
|
if (node)
|
{
|
ele = node;
|
//node.release();
|
dw_source.Retrieve(ele);
|
ele.release();
|
}
|
dw_custom.DwRetrieve(GetServerUrl(), L"[cdline.gdn.sql.xq]", L"EntityID", InvoiceID);
|
dw_custom.SetSelectionMode(1);
|
/*
|
node = xdoc.selectSingleNode(L"data/Item[@subject='CDLine' or @subject='cdline']/*");
|
if(node)
|
{
|
ele = node;
|
//node.release();
|
dw_custom.Retrieve(ele);
|
ele.release();
|
}
|
*/
|
node = xdoc.selectSingleNode(L"data/Item[@subject='CDElement' or @subject='cdelement']/*");
|
if (node)
|
{
|
ele = node;
|
//node.release();
|
dw_cdelement.Retrieve(ele);
|
dw_cdelement.SetSelectionMode(1);
|
ele.release();
|
}
|
|
node = xdoc.selectSingleNode(L"data/Item[@subject='Container' or @subject='container']/*");
|
if (node)
|
{
|
ele = node;
|
//node.release();
|
dw_fcl.Retrieve(ele);
|
ele.release();
|
}
|
|
return 1;
|
}
|
|
int OnRefreshSource(xstring invno)
|
{
|
xml x;
|
x = new xml;
|
|
xaserverarg arg ;
|
|
arg.AddArg(L"invno", invno);
|
if (xurl::get(L"/sale/data/Gdn/source/maintex", arg.GetString(), x) != 1)
|
{
|
alert(x.text());
|
return -1;
|
}
|
|
dw_source.Retrieve(x);
|
dw_source.SetSelectionMode(1);
|
return 1;
|
}
|
int Retrieve(xstring invno)
|
{
|
|
//return RetrieveUseBuffer(invno);
|
|
xml x;
|
x = new xml;
|
|
xaserverarg arg ;
|
|
arg.AddArg(L"invno", invno);
|
if (xurl::get(L"/sale/data/Gdn/source/maintex", arg.GetString(), x) != 1)
|
{
|
alert(x.text());
|
return -1;
|
}
|
|
dw_source.Retrieve(x);
|
dw_source.SetSelectionMode(1);
|
if (xurl::get(L"/sale/data/Gdn/source/base", arg.GetString(), x) != 1)
|
{
|
alert(x.text());
|
return -1;
|
}
|
|
dw_base.Retrieve(x);
|
|
dw_billnote.Retrieve(x);
|
if (dw_billnote.GetRowCount() < 1)
|
{
|
xstring billnote = L"<GDN><DocInfo><data><Item Name='±¨¹Ø·¢Æ±' Field='Remark'></Item>" +
|
"<Item Name='±¨¹ØÏäµ¥' Field='Remark'></Item>" +
|
"<Item Name='Ò鸶·¢Æ±' Field='Remark'></Item>" +
|
"<Item Name='Ò鸶Ïäµ¥' Field='Remark'></Item>" +
|
"<Item Name='×°´¬Í¨Öª' Field='Remark'></Item>" +
|
"<Item Name='¼ÓÄô󺣹ط¢Æ±' Field='Remark'></Item>") +
|
"<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>");
|
x.loadXML(billnote);
|
dw_billnote.Retrieve(x);
|
}
|
if (xurl::get(L"/sale/data/Gdn/source/gdnline", arg.GetString(), x) != 1)
|
{
|
alert(x.xml());
|
return -1;
|
}
|
dw_item.Retrieve(x);
|
dw_item.SetSelectionMode(1);
|
|
if (xurl::get(L"/sale/data/Gdn/source/gdnlineex", arg.GetString(), x) != 1)
|
{
|
alert(x.text());
|
return -1;
|
}
|
dw_invoiceItem.Retrieve(x);
|
|
|
if (xurl::get(L"/sale/data/Gdn/source/profit", arg.GetString(), x) != 1)
|
{
|
alert(x.text());
|
return -1;
|
}
|
dw_profit.Retrieve(x);
|
|
if (xurl::get(L"/sale/data/Custom3/maint/custom/data", arg.GetString(), x) != 1)
|
{
|
alert(x.text());
|
return -1;
|
}
|
dw_custom.Retrieve(x);
|
dw_customex.Retrieve(x);
|
dw_custom.SetSelectionMode(1);
|
|
if (xurl::get(L"/sale/data/Gdn/source/cdelement", arg.GetString(), x) != 1)
|
{
|
alert(x.text());
|
return -1;
|
}
|
dw_cdelement.Retrieve(x);
|
dw_cdelement.SetSelectionMode(1);
|
//dw_cdelement.Retrieve(x);
|
|
if (xurl::get(L"/sale/data/Gdn/source/container", arg.GetString(), x) != 1)
|
{
|
alert(x.text());
|
return -1;
|
}
|
dw_fcl.Retrieve(x);
|
dw_fcl.SetSelectionMode(1);
|
return 1;
|
}
|
|
//¼þÊý
|
int caclPacking(double dQty, xstring sPRate)
|
{
|
if (sPRate == L"" || sPRate == L"0" || sPRate == L" ")
|
return 0;
|
double dPackages;
|
int iFlag;
|
iFlag = sPRate.find(L"/", 1);
|
if (iFlag >= 0)
|
{
|
xstring sBegin = sPRate.mid(0, iFlag);
|
xstring sEnd = sPRate.mid(iFlag + 1, sPRate.length() - iFlag + 2);
|
if (!sBegin || sBegin == L"" || sBegin == L"0" || !sEnd || sEnd == L"" || sEnd == L"0")
|
return 0;
|
dPackages = dQty * sEnd.toDouble() / sBegin.toDouble();
|
}
|
else
|
{
|
dPackages = dQty / sPRate.toDouble();
|
}
|
|
if (((int)dPackages * 1000) > (int)dPackages * 1000)
|
dPackages = dPackages + 1;
|
|
return (int)dPackages;
|
}
|
|
xstring GetInvoiceID(xstring InvoiceNo)
|
{
|
xml x = xml::Make();
|
xaserverarg arg = xaserverarg::Make();
|
arg.AddArg(L"InvoiceNo", InvoiceNo);
|
xaserver::ExecXQuery(GetServerUrl(), L"[gdnid.gdn.xq]", arg.GetString(), x);
|
xstring InvoiceID1 = L"";
|
if (x)
|
{
|
InvoiceID1 = x.text();
|
}
|
arg.Free();
|
x.Free();
|
return InvoiceID1;
|
}
|
|
int OnNewInital()
|
{
|
xstring sdate = publiccode::GetCurrentDate();
|
dw_base.SetItemString(1, L"InvoiceDate", sdate);
|
xstring suserid = publiccode::GetUser().id;
|
xstring susername = publiccode::GetUser().name;
|
//dw_base.SetItemString(1,L"SalespersonID",suserid);
|
//dw_base.SetItemDisplayString(1,L"SalespersonID",susername);
|
dw_base.SetItemString(1, L"CompanyID", L"E9E3C542-062C-4957-B8F4-9B92C3E351FC");
|
dw_base.SetItemDisplayString(1, L"CompanyID", L"Äþ²¨¼Ò¶û¼Ñ½ø³ö¿ÚÓÐÏÞ¹«Ë¾");
|
dw_base.SetItemString(1, L"CreatorID", suserid);
|
dw_base.SetItemDisplayString(1, L"CreatorID", susername);
|
dw_base.SetItemString(1, L"CreateDate", sdate);
|
dw_base.SetItemString(1, L"TradeMode", L"Z");
|
dw_base.SetItemDisplayString(1, L"TradeMode", L"×ÔÓª");
|
|
dw_base.SetItemString(1, L"CurrencyCode", L"USD");
|
dw_profit.SetItemString(1, L"CurrencyCode", L"USD");
|
dw_profit.SetItemString(1, L"InvoiceDate", sdate);
|
//dw_base.SetItemString(1,L"SalespersonID",suserid);
|
//dw_base.SetItemDisplayString(1,L"SalespersonID",susername);
|
//dw_profit.SetItemString(1,L"SalespersonID",suserid);
|
//dw_profit.SetItemDisplayString(1,L"SalespersonID",susername);
|
xstring id = publiccode::GetGuid();
|
dw_base.SetGuid(1, id);
|
dw_profit.SetGuid(1, id);
|
|
xml x = ViewObject::MakeXml();
|
xstring billnote = L"<GDN><DocInfo><data><Item Name='±¨¹Ø·¢Æ±' Field='Remark'></Item>" +
|
"<Item Name='±¨¹ØÏäµ¥' Field='Remark'></Item>" +
|
"<Item Name='Ò鸶·¢Æ±' Field='Remark'></Item>" +
|
"<Item Name='Ò鸶Ïäµ¥' Field='Remark'></Item>" +
|
"<Item Name='×°´¬Í¨Öª' Field='Remark'></Item>" +
|
"<Item Name='¼ÓÄô󺣹ط¢Æ±' Field='Remark'></Item>" +
|
"<Item Name='FORMA' Field='Remark'></Item></data></DocInfo></GDN>";
|
x.loadXML(billnote);
|
dw_billnote.Retrieve(x);
|
}
|
|
int onload()
|
{
|
|
xstring userid = publiccode::GetUser().id;
|
//trace(userid);
|
haveUpdate = true;
|
InvoiceID = L"";
|
tabname = L"base";
|
|
OnAttachEvent();
|
|
dw_base = GetControl(L"dw_base");
|
dw_base.openUrl(L"/sale/view/GDN/template/Base");
|
dw_base.SetColHeaderHeight(0);
|
dw_base.SetRowSelectorWidth(0);
|
dw_base.SetHScrollState(false);
|
|
//dw_base.SetVScrollState(false);
|
//dw_base.SetColumnState(L"GoodsSource",false);
|
|
dw_item = GetControl(L"dw_item");
|
//dw_item.openUrl(L"/sale/view/GDN/template/GDNItem1");
|
dw_item.SetDataObject(GetServerUrl(), L"dev:sheet[GDN.v3.Ex.tpl/GDNItem]");
|
|
xstring userno = publiccode::GetUser().no;
|
|
//alert(userno);
|
//trace(userno);
|
//trace(userid);
|
//if(userno==L"exp-442"){
|
//dw_item.SetReadOnlyColumn(L"Packages",false);
|
//}
|
dw_item.SetAskStyle(true);
|
dw_item.SetColumnState(L"GroupNo", true);
|
dw_item.SetColumnState(L"ItemID", false);
|
dw_item.SetColumnState(L"LineType", false);
|
dw_item.SetColumnState(L"LineNo", false);
|
dw_item.SetColumnState(L"Assortment", false);
|
dw_item.SetColumnState(L"GDNID", false);
|
dw_item.SetColumnState(L"SOLineID", false);
|
dw_item.SetColumnState(L"GDNLineID", false);
|
dw_item.SetColumnState(L"SOLineNo", false);
|
dw_item.SetColumnState(L"SKUNo", false);
|
dw_item.SetColumnState(L"BuyUnitPrice", false);
|
dw_item.SetColumnState(L"POCreatorID", false);
|
dw_item.SetColumnState(L"BuyAmount", false);
|
dw_item.SetColumnState(L"CostRate", false);
|
dw_item.SetColumnState(L"CommissionRate", false);
|
dw_item.SetColumnState(L"DiscountRate", false);
|
dw_item.SetColumnState(L"Remark", false);
|
//dw_item.SetColumnState(L"UOMCode",false);
|
|
|
|
dw_source = GetControl(L"dw_source");
|
dw_source.openUrl(L"/sale/view/GDN/template/item/sourcing");
|
dw_source.SetColumnState(L"POID", false);
|
dw_source.SetColumnState(L"SOLineID", false);
|
dw_source.SetColumnState(L"ItemID", false);
|
dw_source.SetColumnState(L"POItemID", false);
|
dw_source.SetColumnState(L"GDNLineID", false);
|
dw_source.SetColumnState(L"ETD", false);
|
dw_source.SetColumnState(L"InvoiceNo", false);
|
dw_source.SetColumnState(L"GDNID", false);
|
dw_source.SetColumnState(L"Amount", false);
|
dw_source.SetColumnState(L"GDNSourceAmout", false);
|
dw_source.SetColumnState(L"GDNLineAmout", false);
|
|
//dw_source.SetColumnState(L"Amount",false);
|
|
|
dw_custom = GetControl(L"dw_custom");
|
dw_custom.openUrl(L"/sale/view/Custom3/template/maint");
|
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_customex = GetControl(L"dw_customex");
|
dw_customex.openUrl(L"/sale/view/GDN/template/item3");
|
|
dw_invoiceItem = GetControl(L"dw_invoiceex");
|
dw_invoiceItem.openUrl(L"/sale/view/GDN/template/item1");
|
|
dw_fcl = GetControl(L"dw_fcl");
|
dw_fcl.openUrl(L"/sale/view/GDN/template/item2");
|
dw_fcl.SetColumnState(L"GDNID", false);
|
dw_fcl.SetColumnState(L"UseFlag", false);
|
//dw_fcl.InsertRow(0);
|
|
dw_billnote = GetControl(L"dw_billnote");
|
dw_billnote.openUrl(L"/sale/view/GDN/template/billnote");
|
|
dw_profit = GetControl(L"dw_profit");
|
dw_profit.openUrl(L"/sale/view/GDN/template/Profit");
|
dw_profit.SetColHeaderHeight(0);
|
dw_profit.SetRowSelectorWidth(0);
|
dw_profit.SetHScrollState(false);
|
|
dw_cdelement = GetControl(L"dw_cdelement");
|
dw_cdelement.openUrl(L"/sale/view/Custom3/template/element");
|
dw_cdelement.SetColumnState(L"CDLineID", false);
|
dw_cdelement.SetColumnState(L"ClassifyID", false);
|
dw_cdelement.SetColumnState(L"GDNID", false);
|
|
dw_doclist = GetControl(L"dw_doclist");
|
dw_doclist.openUrl(L"/sale/view/GDN/template/doclist");
|
|
InvoiceNo = L"";
|
if (GetParam())
|
{
|
xaserverarg arg_param = new xaserverarg;
|
arg_param.setNativePointer(GetParam());
|
|
InvoiceNo = arg_param.GetArgString(L"InvoiceNo");
|
if (InvoiceNo == L"") InvoiceNo = arg_param.GetArgString(L"EntityNo");
|
if (InvoiceNo == L"")
|
{
|
xstring EntityID = arg_param.GetArgString(L"EntityID");
|
if (EntityID != L"") InvoiceNo = GDNView::GetInvoiceNoByID(EntityID);
|
}
|
InvoiceID = arg_param.GetArgString(L"EntityID");
|
if (InvoiceID == L"" && InvoiceNo != L"")
|
{
|
InvoiceID = GetInvoiceID(InvoiceNo);
|
}
|
|
readonly = false;
|
readonlyEx = false;
|
if (arg_param.GetArgString(L"ReadOnly") == L"true") readonly = true;
|
if (arg_param.GetArgString(L"ReadOnlyEx") == L"true") readonlyEx = true;
|
}
|
|
dw_base.SetEditUpperMode(true);
|
dw_item.SetEditUpperMode(true);
|
dw_custom.SetEditUpperMode(true);
|
dw_profit.SetEditUpperMode(true);
|
dw_source.SetEditUpperMode(true);
|
dw_cdelement.SetEditUpperMode(true);
|
dw_invoiceItem.SetEditUpperMode(true);
|
dw_customex.SetEditUpperMode(true);
|
dw_billnote.SetEditUpperMode(true);
|
dw_doclist.SetEditUpperMode(true);
|
dw_fcl.SetEditUpperMode(true);
|
|
datareading = false;
|
return 1;
|
}
|
|
int onloaded()
|
{
|
if (InvoiceNo != L"")
|
{
|
Retrieve(InvoiceNo);
|
//CalcProfit();//ÖØÐ¼ÆËãÓ¯¿÷
|
}
|
else
|
{
|
OnNewInital();
|
if (GetParam())
|
{
|
xaserverarg arg = new xaserverarg;
|
arg.setNativePointer(GetParam());
|
|
if (arg.GetArgString(L"CustomerID") != L"")
|
{
|
dw_base.ItemChangeTo(1, L"CustomerID", arg.GetArgString(L"CustomerID"));
|
dw_base.SetItemDisplayString(1, L"CustomerID", arg.GetArgString(L"CustomerName"));
|
xstring dwname = L"dw_base";
|
xstring colname = L"CustomerID";
|
xstring value = arg.GetArgString(L"CustomerID");
|
KXMLDOMNodeList nlist = GetElement().selectNodes(L"//*[@name='" + dwname + L"']/trans[@for='" + colname + L"']");
|
ViewObject::TransData(nlist, dw_base, 1, colname, value);
|
trace(L"+++++L");
|
}
|
}
|
OnAddGDNItem();
|
}
|
if (readonly)
|
{
|
dw_base.SetReadOnly(true);
|
dw_item.SetReadOnly(true);
|
if (!readonlyEx)
|
{
|
dw_custom.SetReadOnly(true);
|
dw_cdelement.SetReadOnly(true);
|
}
|
dw_profit.SetReadOnly(true);
|
dw_source.SetReadOnly(true);
|
dw_invoiceItem.SetReadOnly(true);
|
dw_customex.SetReadOnly(true);
|
dw_billnote.SetReadOnly(true);
|
dw_doclist.SetReadOnly(true);
|
dw_fcl.SetReadOnly(true);
|
}
|
dw_base.SetColumnProp(L"VerificationSheet", L"cellprotect", L"1");
|
|
SetAgentEx();
|
return 1;
|
}
|
};
|