ÿþ#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" #include "viewobject/gdn3.view.hpp" #include "viewobject/custom.view.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) GDN3MaintExWin : public xframe { public: GDN3MaintExWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static GDN3MaintExWin* CreateInstance(void* implPtr, void* hWnd) { GDN3MaintExWin* pWin = new GDN3MaintExWin(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; xnode m_agentNode; //Agent Condition xstring tabname; //xdwgrid dw_element; int SetAgentEx() { /* xstring xfNodeAgentArea = L"agentarea"; xnode anode = GetAgentNode(xfNodeAgentArea); if(m_agentNode) { SetAgentNodeContent (anode,m_agentNode); } else { KXMLDOMElement xframeElement = GetElement(); KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*"); if(agent) { xstring s = agent.xml; m_agentNode = SetAgentNodeContent (anode,s); } }*/ SwitchLayer(L"agent_"+xstring(tabname),L"agentareaframe"); return 1; } //&q¹pÀo;mYtýQpe int OnSetFocus(TEvent* evt, int param) { //͑nå]wQag SetAgentEx(); return 1; } xstring GetGuid() { return publiccode::GetGuid(); } int OnSave() { 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; } 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",Vol_s); xstring str = L""; dw_base.AcceptText(); xml xbase ; KXMLDOMDocument xbasedoc = xbase; dw_base.DwUpdateAllTo(xbasedoc); xaserverarg arg ; //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()); //trace(xbase.xml()); //alert(xbase.xml()); if(xurl::get(L"/sale/data/Gdn/update/base", arg.GetString(),xbase)!=1) { xstring error = xbase.text(); alert(L"err:"+(xstring)error); alert(L"úW,gáOo`ÝOX[1Y%!"); return -1; } str = xbase.documentElement().getAttribute(L"text"); if(str == L"false") { alert(L"úW,gáOo`ÝOX[1Y%!"); return -1; } dw_base.ResetUpdateStatus(); dw_item.AcceptText(); xml xitem ; KXMLDOMDocument xitemdoc = xitem; dw_item.DwUpdateAllToEx(xitemdoc); xaserverarg arg1; arg1.AddArg(L"content",xitem.xml()); if(xurl::get(L"/sale/data/Gdn/update/item", arg1.GetString(),xitem)!=1) { xstring error1 = xitem.text(); alert(L"err:"+(xstring)error1); alert(L"FUÁTáOo`ÝOX[1Y%!"); return -1; } str = xitem.documentElement().getAttribute(L"text"); if(str == L"false") { alert(L"úW,gáOo`ÝOX[1Y%!"); return -1; } dw_item.ResetUpdateStatus(); /* dw_source.AcceptText(); xml x ; x.setNativePointer(x.CreateInstance()); dw_source.DwUpdateAllToEx(x); xaserverarg arg2 = GDNView::MakeArg(); arg2.AddArg(L"content",x.xml()); if(url::get(L"/sale/data/Gdn/update/sourceex", arg2.GetString(),x)!=1) { xstring error3 = x.text(); alert(L"err:"+error3); alert(L"'náOo`ÝOX[1Y%!"); return -1; } str = x.documentElement().getAttribute(L"text"); if(str == L"false") { alert(L"'náOo`ÝOX[1Y%!"); return -1; } dw_source.ResetUpdateStatus(); */ dw_custom.AcceptText(); xml xcustom ; dw_custom.DwUpdateAllToEx(xcustom); //trace(xcustom.xml()); xcustom = CustomView::UpdateCustomItem(dw_base.GetItemString(1,L"InvoiceNo"), xcustom.xml()); if(!xcustom) { //xstring error5= xcustom.text(); //alert(L"err:"+error5); alert(L"¥bsQáOo`ÝOX[1Y%!"); return -1; } str =xcustom.documentElement().getAttribute(L"text"); if(str == L"false") { alert(L"¥bsQáOo`ÝOX[1Y%!"); return -1; } dw_custom.ResetUpdateStatus(); dw_invoiceItem.AcceptText(); xml x1 ; dw_invoiceItem.DwUpdateAllToEx(x1); arg1.AddArg(L"content",x1.xml()); if(xurl::get(L"/sale/data/Gdn/update/itemex", arg1.GetString(),x1)!=1) if(!xcustom) { alert(L"®‹ØNáOo`ÝOX[1Y%1!"); return -1; } str =x1.documentElement().getAttribute(L"text"); if(str == L"false") { alert(L"®‹ØNáOo`ÝOX[1Y%!"); return -1; } dw_invoiceItem.ResetUpdateStatus(); dw_fcl.AcceptText(); xml xfcl ; dw_fcl.DwUpdateAllToEx(xfcl); xaserverarg arg8; arg8.AddArg(L"content",xfcl.xml()); if(xurl::get(L"/sale/data/Gdn/update/container", arg8.GetString(),xfcl)!=1) { xstring error8 = xfcl.text(); /*alert(L"err:"+error3); alert(L"R±{áOo`ÝOX[1Y%!"); return -1;*/ }else { str = xfcl.documentElement().getAttribute(L"text"); if(str == L"false") { alert(L"R±{áOo`ÝOX[1Y%!"); return -1; } dw_fcl.ResetUpdateStatus(); } dw_customex.AcceptText(); xml xcustomex ; dw_customex.DwUpdateAllToEx(xcustomex); trace(xcustomex.xml()); xcustomex = CustomView::UpdateCustomElement(dw_base.GetItemString(1,L"InvoiceNo"),xcustomex.xml()); if(!xcustomex) { alert(L"R±{¥bsQáOo`ÝOX[1Y%!"); return -1; } str =xcustomex.documentElement().getAttribute(L"text"); if(str == L"false") { alert(L"R±{¥bsQáOo`ÝOX[1Y%!"); return -1; } dw_customex.ResetUpdateStatus(); dw_cdelement.AcceptText(); xml xcdelement ; dw_cdelement.DwUpdateAllToEx(xcdelement); //trace(xcdelement.xml()); if(xcdelement.xml()!=L"") { xcdelement = CustomView::UpdateCustomElement(dw_base.GetItemString(1,L"InvoiceNo"), xcdelement.xml()); if(!xcdelement) { xstring error6= xcdelement.text(); alert(L"err:"+(xstring)error6); alert(L"3u¥b‰ }áOo`ÝOX[1Y%!"); //return -1; }else { str =xcdelement.documentElement().getAttribute(L"text"); if(str == L"false") { alert(L"3u¥b‰ }áOo`ÝOX[1Y%!"); return -1; } dw_cdelement.ResetUpdateStatus(); } } /* dw_profit.AcceptText(); xml xprofit ; xprofit.setNativePointer(xml::CreateInstance()); KXMLDOMDocument xprofitdoc = xprofit; dw_profit.DwUpdateAllTo(xprofitdoc); xaserverarg arg3 = GDNView::MakeArg(); arg3.AddArg(L"content",xprofit.xml()); if(url::get(L"/sale/data/Gdn/update/profit", arg3.GetString(),xprofit)!=1) { xstring error4 = xprofit.text(); alert(L"err:"+error1); alert(L"ÈvNáOo`ÝOX[1Y%!"); return -1; } str =xprofit.documentElement().getAttribute(L"text"); if(str == L"false") { alert(L"ÈvNáOo`ÝOX[1Y%!"); return -1; } dw_profit.ResetUpdateStatus(); */ alert(L"ÝOX[bŸRÿ"); 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"FundsIntrestFee"|| col==L"AgentAmount"|| col==L"AgentTax"|| col==L"OtherFee") { evalTotalCost(); evalProfitAmount(); 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"); double amt1 = amt*rate; dw_custom.SetItemDouble(row,L"Amount", amt1); double quantity = dw_custom.GetItemDouble(row,L"Quantity"); double price = amt1 /quantity; dw_custom.SetItemDouble(row,L"UnitPrice", price); dw_custom.Redraw(); } 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"CommissionRate") { double commrate = data.toDouble(); dw_base.SetItemDouble(1,L"CommissionAmount", dw_base.GetItemDouble(1,L"Amount") * commrate/100.0); } else if(col ==L"PrivateCommissionRate") { double fcommrate = data.toDouble(); dw_base.SetItemDouble(1,L"PrivateCommissionAmount", dw_base.GetItemDouble(1,L"Amount") * fcommrate/100.0); } 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(); } } 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; xutil::RestoreCursor(HCursor); 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"BuyUnitPrice" || colname == L"BuyQuantity") //û‹ÖSgя¢‹USáOo` { double price = dw_source.GetItemDouble(hdr.row,L"BuyUnitPrice"); double quantity = dw_source.GetItemDouble(hdr.row,L"BuyQuantity"); dw_source.SetItemDouble(hdr.row,L"BuyAmount", price * quantity); } 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.c_str(true); } 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.c_str()); 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"); //alert(value); dw_billnote.SetItemString(row,colname.c_str(), value); dw_billnote.Redraw(); } } return 1; } int OnPrint() { xaserverarg arg; arg.AddArg(L"EntityName",L"GDN3",L""); arg.AddArg(L"EntityID",dw_base.GetItemString(1,L"GDNID"),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"); if(ContainerNo==L"")ContainerNo=L"1"; 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 OnMakeCustomeContainer() { //dw_custom.Reset(); int 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 ContainerNo = dw_item.GetItemString(row,L"ContainerNo"); if(ContainerNo==L"")ContainerNo=L"1"; xstring ClassifyID = dw_item.GetItemString(row,L"ClassifyID"); 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_customex.GetRowCount(); i++) { if(dw_customex.GetItemString(i,L"ClassifyID")==ClassifyID) { if(dw_customex.GetItemString(i,L"ContainerNo")==ContainerNo)break; } } int k=1; for(k=1;k<=dw_custom.GetRowCount(); k++) { if(dw_custom.GetItemString(k,L"ClassifyID")==ClassifyID)break; } if(i>dw_customex.GetRowCount()) { dw_customex.InsertRow(0); i = dw_customex.GetRowCount(); dw_customex.SetItemString(i,L"ContainerNo",ContainerNo); dw_customex.SetItemString(i,L"GDNID",dw_base.GetGuid(1)); dw_customex.SetItemString(i,L"ClassifyID",ClassifyID); } dw_customex.SetItemString(i,L"ClassifyID",ClassifyID); dw_customex.SetItemString(i,L"CustName",name); double val = 0; double samt = 0; val = dw_customex.GetItemDouble(i, L"Amount"); val += Amount; samt = val; 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_customex.GetItemDouble(i,L"Quantity"); val += Quantity; double sqty = 0; sqty = val; dw_customex.SetItemDouble(i,L"Quantity",val); val = dw_customex.GetItemDouble(i,L"GW"); val += GW; dw_customex.SetItemDouble(i,L"GW",val); val = dw_customex.GetItemDouble(i,L"NW"); val += NW; dw_customex.SetItemDouble(i,L"NW",val); int nval = dw_customex.GetItemDouble(i,L"Packages"); nval += Packages; dw_customex.SetItemInt(i,L"Packages",nval); val = dw_customex.GetItemDouble(i,L"Volume"); val += Vol; dw_customex.SetItemDouble(i,L"Volume",val); double price = samt/sqty; dw_customex.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",")) str1 = str1.left(str1.find(L",")); dw_customex.SetItemString(i,L"VATRates",str1); } if(k<=dw_custom.GetRowCount()) { //ÁT TïSý€ò]îO9e dw_customex.SetItemString(i,L"CustEName",dw_custom.GetItemString(k,L"CustEName")); }else if(o.selectSingleNode(L"CustEName")) { dw_customex.SetItemString(i,L"CustEName",o.selectSingleNode(L"CustEName").text()); } if(o.selectSingleNode(L"VATRefundRate")) { dw_customex.SetItemString(i,L"VATRefundRate",o.selectSingleNode(L"VATRefundRate").text()); } if(o.selectSingleNode(L"HSCode")) { xstring hscode = o.selectSingleNode(L"HSCode").text(); if(k<=dw_custom.GetRowCount()) { //ÁT TïSý€ò]îO9e dw_customex.SetItemString(i,L"CustName",dw_custom.GetItemString(k,L"CustName")); } else if(dw_customex.GetItemString(i,L"CustName").find(L"["+hscode)>=0) { xstring str = dw_customex.GetItemString(i,L"CustName"); str = str.left(str.find(L"[" + hscode)); dw_customex.SetItemString(i,L"CustName",str); } dw_customex.SetItemString(i,L"HSCode",hscode); } if(o.selectSingleNode(L"UOM")) { dw_customex.SetItemString(i,L"LegalUOMCode",o.selectSingleNode(L"UOM").text()); xstring uom = o.selectSingleNode(L"UOM").text(); if(uom==L"CSKQ") { dw_customex.SetItemString(i,L"LegalQty",dw_customex.GetItemString(i,L"NW")); } else { dw_customex.SetItemString(i,L"LegalQty",dw_customex.GetItemString(i,L"Quantity")); } } } } } 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"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; } int OnMakeCustom() { HCURSOR HCursor = xutil::SetCursorWait(); dw_custom.AcceptText(); int cnt = dw_custom.GetRowCount(); int i = 1; 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""); } 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"); 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"); bool bAdd = false; for(i=1; i<=dw_custom.GetRowCount(); i++) { if(dw_custom.GetItemString(i,L"ClassifyID")==ClassifyID)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); 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); val = dw_custom.GetItemDouble(i,L"Quantity"); val += Quantity; double sqty = 0; sqty = val; dw_custom.SetItemDouble(i,L"Quantity",val); val = dw_custom.GetItemDouble(i,L"GW"); val += GW; dw_custom.SetItemDouble(i,L"GW",val); val = dw_custom.GetItemDouble(i,L"NW"); val += NW; 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",")) str1 = str1.left(str1.find(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"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"CSKQ") { 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); } 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); return 1; } int OnAddSourcingItem() { xaserverarg arg; 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"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()); } } return 1; } int OnDeleteSourceingItem() { dw_source.DeleteRow(0); return 1; } int OnAddGDNItem() { xaserverarg arg ; arg.AddArg(L"CustomerID",dw_base.GetItemString(1,L"CustomerID")); arg.AddArg(L"InvoiceNo",dw_base.GetItemString(1,L"InvoiceNo")); arg.AddArg(L"SONo",dw_base.GetItemString(1,L"")); OpenWindow(L"dev:xpage[select.gdnitem.so.vx]",arg); 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_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); if(t.selectSingleNode(L"SOLineID"))dw_item.SetItemString(row,L"SOLineID",t.selectSingleNode(L"SOLineID").text()); //if(t.selectSingleNode(L"GDNLineID"))dw_item.SetItemString(row,L"GDNLineID",t.selectSingleNode(L"GDNLineID").text()); if(t.selectSingleNode(L"GoodsNo"))dw_item.SetItemString(row,L"GoodsNo",t.selectSingleNode(L"GoodsNo").text()); if(t.selectSingleNode(L"Quantity"))dw_item.SetItemString(row,L"Quantity",t.selectSingleNode(L"Quantity").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"Amount"))dw_item.SetItemString(row,L"Amount",t.selectSingleNode(L"Amount").text()); if(t.selectSingleNode(L"SOLineNo"))dw_item.SetItemString(row,L"SOLineNo",t.selectSingleNode(L"SOLineNo").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"Packingt").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"PackingRatet",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"Packages"))dw_item.SetItemString(row,L"Packages",t.selectSingleNode(L"Packages").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.SetItemString(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"Volume"))dw_item.SetItemString(row,L"Volume",t.selectSingleNode(L"Volume").text()); if(t.selectSingleNode(L"GWPerPkg"))dw_item.SetItemString(row,L"GWPerPkg",t.selectSingleNode(L"GWPerPkg").text()); if(t.selectSingleNode(L"GW"))dw_item.SetItemString(row,L"GW",t.selectSingleNode(L"GW").text()); if(t.selectSingleNode(L"NWPerPkg"))dw_item.SetItemString(row,L"NWPerPkg",t.selectSingleNode(L"NWPerPkg").text()); if(t.selectSingleNode(L"NW"))dw_item.SetItemString(row,L"NW",t.selectSingleNode(L"NW").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.SetItemString(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()); } } 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()); } } 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 OnCDElement() { while(dw_cdelement.GetRowCount()>0) dw_cdelement.DeleteRow(dw_cdelement.GetRowCount()); for(int i=1;i<=dw_custom.GetRowCount();i++) AddCDElement(i); return 1; } 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(); } } } //for(int row==dw_cdelement.GetRowCount();row>=1; row++) //{ //} return 1; } int OnDeleteGDNItem() { dw_item.DeleteRow(0); return 1; } //}TäNÑS^ýQpe int OnCmdDispatch(xstring comdid) { if(comdid==L"xmCDElement") { return OnCDElement(); } if(comdid==L"xmCDElementMatch") { return OnCDElementMatch(); } 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"xmMakeContainer") { OnMakeContainer(); OnMakeCustomeContainer(); 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"xmMakeGdnLineEx") { return OnMakeGdnLineEx(); } else if(comdid==L"xmDeleteRow") { dw_item.DeleteRow(0); return 1; } else if(comdid==L"xmAddItem") { //dw_item.InsertRow(0); 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; } return 0; } //}TäNYt‹NöN int OnXCommand(TEvent* evt, int param) { return OnCmdDispatch(evt->xcommand.pStrID); } //Θi–¡‹Ðc int evalRisk() { xstring CurrencyCode = dw_base.GetItemDisplayString(1,L"CurrencyCode"); double rate =0.2; if(CurrencyCode==L"RMB" || CurrencyCode==L"CNY") rate = 1.0/30.0; double amt = dw_profit.GetItemDouble(1,L"Amount"); dw_profit.SetItemDouble(1,L"RiskPrepareFee", amt * rate); return 1; } //Ǒ-b,g int evalPurcharCost() { double cost= dw_source.GetItemSumDouble(L"BuyAmount"); dw_profit.SetItemDouble(1,L"Cost",cost); return 1; } //z 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 = 13; tax = 17; if(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) { if(o.selectSingleNode(L"VATRates")) tax = xstring(o.selectSingleNode(L"VATRates").text()).toDouble(); if(o.selectSingleNode(L"VATRefundRate")) retax = xstring(o.selectSingleNode(L"VATRefundRate").text()).toDouble(); } } } 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 evalManagementFee() { xstring CurrencyCode = dw_base.GetItemDisplayString(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"dcomp_amt"); if(x.selectSingleNode(L"root/item/@value")) expRate = x.selectSingleNode(L"root/item/@value").text(); double sale = dw_profit.GetItemDouble(1,L"ExchangeAmountEx"); 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; } dw_profit.SetItemDouble(1,L"ManagementFee",ManagementFee); return 1; } //;`b,g 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"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; } //•.U 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 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"); dw_profit.SetItemDouble(1,L"ExchangeAmountEx",ttl); xstring CurrencyCode = dw_base.GetItemDisplayString(1,L"CurrencyCode"); xstring exchangeRate = L""; if(CurrencyCode==L"RMB"||CurrencyCode==L"CNY") { exchangeRate=L"1.0"; }else { 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); 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); }else { dw_profit.SetItemString(1,L"ProfitAmountEx",L""); } if(sale != 0.0) { double amt1 = ttl; amt1 += 2.0* drawback; amt1= amt1 /sale; dw_profit.SetItemDouble(1,L"ExchangeCostEx", amt1); } else dw_profit.SetItemString(1,L"ExchangeCostEx",L""); return 1; } int CalcProfit() { evalSale(); evalManagementFee(); evalRisk(); evalPurcharCost(); evalDrawback(); evalTotalCost(); evalProfitAmount(); // /* idw_maint[9].setitem(1,'cnt_no',idw_maint[1].getitemString(1,'cnt_no')) idw_maint[9].setitem(1,'dept_no',idw_maint[1].getitemString(1,'dept_no')) idw_maint[9].setitem(1,'emp_no',idw_maint[1].getitemString(1,'emp_no')) idw_maint[9].setitem(1,'costpro_date',idw_maint[1].getitemdatetime(1,'dtl_date')) idw_maint[9].setitem(1,'custom_date',idw_maint[1].getitemdatetime(1,'exportdate')) idw_maint[9].setitem(1,'client_id',idw_maint[1].getitemnumber(1,'client_id')) idw_maint[9].setitem(1,'country_no',idw_maint[1].getitemString(1,'cty_no')) idw_maint[9].setitem(1,'price_item',idw_maint[1].getitemString(1,'priceterm')) idw_maint[9].setitem(1,'payment_item',idw_maint[1].getitemString(1,'payterm')) idw_maint[9].setitem(1,'lc_no',idw_maint[1].getitemString(1,'lcno')) idw_maint[9].setitem(1,'cry_no1',idw_maint[1].getitemString(1,'cry_no')) if idw_maint[3].rowCount() >= 1 then idw_maint[9].setitem(1,'cntg_qty',idw_maint[3].getitemDecimal(1,'zsl')) idw_maint[9].setitem(1,'intg_qty',idw_maint[3].getitemDecimal(1,'zsl')) idw_maint[9].setitem(1,'cnt_amount',idw_maint[3].getitemDecimal(1,'zje')) idw_maint[9].setitem(1,'cntg_price',idw_maint[3].getitemDecimal(1,'zje')/idw_maint[3].getitemDecimal(1,'zsl')) end if idw_maint[9].setitem(1,'ffreight_amt',idw_maint[1].getitemDecimal(1,'freight')) idw_maint[9].setitem(1,'finsurance_amt',idw_maint[1].getitemDecimal(1,'insuamt')) if idw_maint[7].rowCount() >= 1 then idw_maint[9].setitem(1,'cost_amt',idw_maint[7].getitemDecimal(1,'ttlamt')) xstring ls_custids long ll_i2 long ll_id1 decimal ldec_r1,ldec_r2,ldec_retaxex,ldec_amtex datastore lds_retax lds_retax = create datastore lds_retax.create(idw_maint[7].describe('datawindow.syntax')) idw_maint[7].rowscopy(1,idw_maint[7].rowCount(),primary!,lds_retax,9999,primary!) for ll_i2 = 1 to idw_maint[3].rowCount() ls_custid = idw_maint[3].getItemString(ll_i2,'custid') if isnull(ls_custid) or trim(ls_custid)='' then ldec_retax = 13 ldec_tax = 17 else select retax,tax_rate into :ldec_retax,:ldec_tax from code_t_custom where code_s = :ls_custid; end if // if long(ldec_retax) <> 13 or long(ldec_tax)<>17 then ll_id1 = idw_maint[3].getItemNumber(ll_i2,'pd_id') ldec_r1 = ldec_retax ldec_r2 = ldec_tax if isnull(ldec_r2) and long(ldec_r1)=6 then ldec_r2 = 6 lds_retax.setfilter('pd_id='+xstring(ll_id1)+L" and kpflag='Y'") lds_retax.filter() if lds_retax.rowCount() > 0 then ldec_retaxex += lds_retax.getitemDecimal(1,'ttlamt')/(100+ldec_tax)*ldec_retax ldec_amtex += lds_retax.getitemDecimal(1,'ttlamt') end if // end if next // idw_maint[9].setitem(1,'ddrawback_amt',(idw_maint[7].getitemDecimal(1,'ttlamt') - ldec_amtex)/1.17*0.13 + ldec_retaxex) idw_maint[9].setitem(1,'ddrawback_amt',ldec_retaxex) if isvalid(lds_retax) then destroy lds_retax ELSE idw_maint[9].setitem(1,'ddrawback_amt',0) idw_maint[9].setitem(1,'cost_amt',0) END IF decimal ldec_comm,ldec_dcomm,ldec_expense,ldec_discamt decimal ldec_other,ldec_commex xstring ls_isincexpens ldec_comm = idw_maint[1].getitemDecimal(1,'commamt') ldec_dcomm = idw_maint[1].getitemDecimal(1,'dcommamt') ldec_expense = idw_maint[1].getitemDecimal(1,'expenseamt') ldec_discamt = idw_maint[1].getitemDecimal(1,'discamt') ls_isincexpens = idw_maint[1].getitemString(1,'isincexpens') if isnull(ls_isincexpens) then ls_isincexpens = '1' if isnull(ldec_expense) then ldec_expense = 0 if ldec_expense <> 0 then ldec_expense = -1 * ldec_expense * long(ls_isincexpens) ldec_other = ldec_expense end if if isnull(ldec_discamt) then ldec_discamt = 0 if isnull(ldec_comm) then ldec_comm = 0 if isnull(ldec_dcomm) then ldec_dcomm = 0 ldec_commex = ldec_discamt + ldec_comm + ldec_dcomm ldec_other = ldec_expense idw_maint[9].setitem(1,'fcommision_amt',ldec_commex) idw_maint[9].setitem(1,'fother_amt',ldec_other) decimal ldec_rate,ldec_exprate SELECT code_t_addition_cp.ratevalue INTO :ldec_rate FROM code_t_addition_cp WHERE code_t_addition_cp.code_no = 'cryrate'; SELECT code_t_addition_cp.ratevalue INTO :ldec_exprate FROM code_t_addition_cp WHERE code_t_addition_cp.code_no = 'dcomp_amt'; //exprate idw_maint[9].setitem(1,'rate_amt',ldec_rate) decimal ldec_rated xstring ls_cno ls_cno = idw_maint[1].getitemString(1,'cry_no') if isnull(ls_cno) then ls_cno = '' if (ls_cno <> 'CNY') then ldec_rated = 0.2 elseif (ls_cno = 'CNY') then ldec_rated = 1/30 else ldec_rated = 0.2 end if if idw_maint[3].rowcount() > 0 then idw_maint[9].setitem(1,'dventure_amt',idw_maint[3].getitemDecimal(1,'zje') * ldec_rated) else idw_maint[9].object.dventure_amt[1] = 0 end if //cwd //lQøS¡{t9 decimal ldec_cnt_amount,ldec_ffreight_amt,ldec_finsurance_amt,ldec_fcommision_amt,ldec_fother_amt ldec_cnt_amount = idw_maint[9].getitemdecimal(1,'cnt_amount') //•.U6eeQ ldec_ffreight_amt = idw_maint[9].getitemdecimal(1,'ffreight_amt') //ýVYЏ9 ldec_finsurance_amt = idw_maint[9].getitemdecimal(1,'finsurance_amt') //ýVYÝOi–9 ldec_fcommision_amt = idw_maint[9].getitemdecimal(1,'fcommision_amt') //cOё ldec_fother_amt = idw_maint[9].getitemdecimal(1,'fother_amt') //ýVYvQÖN9(u if isnull(ldec_cnt_amount) then ldec_cnt_amount = 0 if isnull(ldec_ffreight_amt) then ldec_ffreight_amt = 0 if isnull(ldec_finsurance_amt) then ldec_finsurance_amt = 0 if isnull(ldec_fcommision_amt) then ldec_fcommision_amt = 0 if isnull(ldec_fother_amt) then ldec_fother_amt = 0 xstring ls_cryno ls_cryno = idw_maint[1].getitemString(1,'cry_no') if ls_cryno = 'USD' then //lQøS¡{t9*ÿ•.U6eeQ - ýVYЏ9 - ýVYÝOi–9 - cOё - ýVYvQÖN9(u ÿ idw_maint[9].setitem(1,'dcomp_amt',ldec_exprate*(ldec_cnt_amount - ldec_ffreight_amt - ldec_finsurance_amt - ldec_fcommision_amt - ldec_fother_amt)) //lQøS¡{t9 ELSEIF ls_cryno = 'CNY' THEN dec ldec_tmp ldec_tmp = (ldec_cnt_amount - ldec_ffreight_amt - ldec_finsurance_amt - ldec_fcommision_amt - ldec_fother_amt) //lQøS¡{t9*ÿ•.U6eeQ - ýVYЏ9 - ýVYÝOi–9 - cOё - ýVYvQÖN9(u ÿ/ ŽCQù[ºNl^Gl‡s idw_maint[9].setitem(1,'dcomp_amt',ldec_tmp/ldec_rate * ldec_exprate) end if //Sň9 decimal ldec_dpackage_amt xstring ls_dtl_no ls_dtl_no = idw_maint[9].getitemstring(1,'dtl_no') select sum(bcpamt) into :ldec_dpackage_amt from exp_t_buy_cwgoods where dtl_no = :ls_dtl_no and supplier_id <> 1033840; idw_maint[9].setitem(1,'dpackage_amt',ldec_dpackage_amt) end if*/ return 1; } int OnAttachEvent() { //Ñ~š[å]wQag¹pûQ‹NöN AttachEvent(L"WM_XCOMMAND", (FEvent)&GDN3MaintExWin::OnXCommand); //·ƒÖS&q¹p‹NöN ÿ(uŽN͑nå]wQag AttachEvent(L"WM_SETFOCUS", (FEvent)&GDN3MaintExWin::OnSetFocus); AttachEvent(L"dw_item",L"DWV_ITEMCHANGED", (FEvent)&GDN3MaintExWin::OnItemChanged); AttachEvent(L"dw_source",L"DWV_ITEMCHANGED", (FEvent)&GDN3MaintExWin::OnItemChangedEx); AttachEvent(L"dw_base",L"DWV_ASKDATA", (FEvent)&GDN3MaintExWin::OnAskDataBase); AttachEvent(L"dw_base",L"DWV_ITEMCHANGED", (FEvent)&GDN3MaintExWin::OnBaseItemChanged); AttachEvent(L"dw_profit",L"DWV_ITEMCHANGED", (FEvent)&GDN3MaintExWin::OnProfitItemChanged); AttachEvent(L"dw_custom",L"DWV_ITEMCHANGED", (FEvent)&GDN3MaintExWin::OnCustomItemChanged); AttachEvent(L"dw_billnote",L"DWV_DOUBLECLICKED", (FEvent)&GDN3MaintExWin::OnBillNoteDoubleClicked);//LˆÌSûQ return 1; } int Retrieve(xstring invno) { xml x; x ; 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); if(xurl::get(L"/sale/data/Gdn/source/base", arg.GetString(),x)!=1) { alert(x.text()); return -1; } //alert(x.xml()); dw_base.Retrieve(x); trace(x.xml()); dw_billnote.Retrieve(x); if(dw_billnote.GetRowCount() < 1 ) { xstring billnote=L"<GDN><DocInfo><data><Item Name='¥bsQÑShy' Field='Remark'></Item>" L"<Item Name='¥bsQ±{US' Field='Remark'></Item>" L"<Item Name='®‹ØNÑShy' Field='Remark'></Item>" L"<Item Name='®‹ØN±{US' Field='Remark'></Item>" L"<Item Name='ň9‚åw' Field='Remark'></Item>" L"<Item Name=' Rÿb'YwmsQÑShy' Field='Remark'></Item>" L"<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.text()); return -1; } dw_item.Retrieve(x); dw_item.SetReadOnly(true); //dw_invoiceItem.Retrieve(x); 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); if(xurl::get(L"/sale/data/Custom3/maint/customcontainer", arg.GetString(),x)!=1) { alert(x.text()); return -1; } dw_customex.Retrieve(x); if(xurl::get(L"/sale/data/Gdn/source/cdelement", arg.GetString(),x)!=1) { alert(x.text()); return -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); return 1; } int onload() { SetArg(); 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_item = GetControl(L"dw_item"); dw_item.openUrl(L"/sale/view/GDN/template/GDNItem1"); 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"ClassifyID",false); dw_item.SetColumnState(L"GDNID",false); dw_item.SetColumnState(L"SOLineID",false); dw_item.SetColumnState(L"UnitPrice",false); dw_item.SetColumnState(L"Amount",false); dw_item.SetColumnState(L"UnitCommPrice",false); dw_item.SetColumnState(L"ResearchCommissionRate",false); dw_item.SetColumnState(L"BuyUnitPrice",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_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_custom = GetControl(L"dw_custom"); dw_custom.openUrl(L"/sale/view/Custom3/template/maint"); dw_custom.SetColumnState(L"ClassifyID",false); dw_custom.SetReadOnlyColumn(L"CustName",true); dw_custom.SetColumnState(L"AmountEx",false); dw_customex = GetControl(L"dw_customex"); dw_customex.openUrl(L"/sale/view/GDN/template/item3"); dw_customex.SetColumnState(L"ClassifyID",false); dw_customex.SetColumnState(L"AmountEx",false); 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.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 (GetWinParam()) { xaserverarg arg_param =GetArg(); 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"); InvoiceNo = GDNView::GetInvoiceNoByID(EntityID); } } SetWindowText(GetHWND(),L"úQ'US:"+InvoiceNo); return 1; } int onloaded() { //alert(L"xxxx"); if(InvoiceNo !=L"") { Retrieve(InvoiceNo); //OnMakeCustom(); } dw_base.SetColumnProp(L"InvoiceNo",L"cellprotect",L"1"); //dw_base.SetColumnProp(L"InvoiceDate",L"cellprotect",L"1"); dw_base.SetColumnProp(L"SONos",L"cellprotect",L"1"); //dw_base.SetColumnProp(L"OrderNos",L"cellprotect",L"1"); dw_base.SetColumnProp(L"CustomerID",L"cellprotect",L"1"); dw_base.SetColumnProp(L"CommissionRate",L"cellprotect",L"1"); dw_base.SetColumnProp(L"CommissionAmount",L"cellprotect",L"1"); dw_base.SetColumnProp(L"PrivateCommissionRate",L"cellprotect",L"1"); dw_base.SetColumnProp(L"PrivateCommissionAmount",L"cellprotect",L"1"); dw_base.SetColumnProp(L"CostMoreLess",L"cellprotect",L"1"); dw_base.SetColumnProp(L"CostDesc",L"cellprotect",L"1"); dw_base.SetColumnProp(L"Cost",L"cellprotect",L"1"); xstring PaymentTerm = dw_base.GetItemString(1,L"PaymentTerm"); if(PaymentTerm==L"") dw_base.GetItemString(1,L"PaymentTermEx"); if(PaymentTerm.find(L"L/C'") <0) { 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.SetColumnProp(L"Amount",L"cellprotect",L"1"); dw_base.SetColumnProp(L"NW",L"cellprotect",L"1"); dw_base.SetColumnProp(L"GW",L"cellprotect",L"1"); dw_base.SetColumnProp(L"Packages",L"cellprotect",L"1"); dw_base.SetColumnProp(L"Volume",L"cellprotect",L"1"); dw_base.SetColumnProp(L"Quantity",L"cellprotect",L"1"); dw_base.SetColumnProp(L"DiscountRate",L"cellprotect",L"1"); dw_base.SetColumnProp(L"DiscountAmount",L"cellprotect",L"1"); //xaserverarg arg_param ; //arg_param.setNativePointer(GetParam()); //xstring EntityID = arg_param.GetArgString(L"EntityID"); //SetAgent(L"maint", EntityID); SetAgentEx(); return 1; } };