ÿþ#include <wobject/xstring.hpp> #include <xcontrol/xtreeview.hpp> #include <xcontrol/xdwgrid.hpp> #include <wobject/xdouble.hpp> #include <xcontrol/xlayersheet.hpp> #include <xcontrol/xdatetimepick.hpp> #include <xcontrol/ximageview.hpp> #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) ProductNewItemWin : public xwin { public: ProductNewItemWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} public: static ProductNewItemWin* CreateInstance(void* implPtr, void* hWnd) { return new ProductNewItemWin(implPtr, (HWND)hWnd); } public: xdwtable dw_props; xdwtable dw_makeitem; xnode m_agentNode; //Agent Condition xstring m_EntityID; xdwgrid dw_obj; bool m_toold; KXMLDOMElement imageElement; xstring originSKUID; HWND hObject = 0; int SetAgent() { xstring xfNodeAgentArea = L"agentarea"; xnode anode = GetAgentNode(xfNodeAgentArea); if(m_agentNode) { SetAgentNode (anode,m_agentNode); } else { KXMLDOMElement xframeElement = GetElement(); KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*"); if(agent) { xstring s = agent.xml(); m_agentNode = SetAgentNode (anode,s); } } return 1; } //&q¹pÀo;mYtýQpe int OnSetFocus(TEvent* evt, LPARAM param) { //͑nå]wQag SetAgent(); return 1; } xstring GetGuid() { return publiccode::GetGuid(); } xstring GetNo() { xstring typ=L"C"; xml x; xaserverarg arg ; arg.AddArg(L"count", L"1" ); arg.AddArg(L"type", typ ); if(xurl::get(L"/sale/data/SO/goods/usegoods/goodslib/asknos", arg.GetString(),x)!=1)return L""; return x.text(); } int OnShowImage(xstring skuid) { ximageview im = GetControl(L"im1"); //im.RemoveImage(); im.Reset(); xml xp; xaserverarg arg_pic; arg_pic.AddArg(L"SKUID",skuid); if(xurl::get(L"/sale/data/ProductLibrary3/pref/picture/imagelistSKU",arg_pic.GetString(),xp)!=1) { trace(xstring(L"xxx",xp.xml())); }else { //trace(skuid+L" "+xp.xml()); imageElement = xp.documentElement(); KXMLDOMNodeList nlistp= xp.selectNodes(L"ImageList/image"); int lenp = nlistp.length(); for(int ip=0;ip<lenp;ip++) { KXMLDOMElement xitem = nlistp.item(ip); xstring picname = xitem.selectSingleNode(L"PicPath").text(); xstring goodno = xitem.selectSingleNode(L"GoodsNo").text(); if(picname == L"/business/products/Thumbs//") picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg"; im.AddImages(picname, L""); } im.Redraw(); //SendMessage(im.GetId(),0x000f,0,1); //InvalidateRect(im.GetId(),cast(0 as ref xrect),true); } return 1; } int OnSave() { dw_props.AcceptText(); dw_props.SetItemString(1,L"No",GetNo()); if(dw_props.GetItemString(1,L"BarCode")==L"") { dw_props.SetItemString(1,L"BarCode",L"1000000"+dw_props.GetItemString(1,L"No").right(6)); } if(dw_props.GetItemString(1,L"GoodsNo")==L"") { alert(L"÷‹“eQlQøS'÷S"); return 1; } if(dw_props.GetItemString(1,L"CategoryID")==L"") { dw_props.SetItemString(1,L"CategoryID",L"EF37E57D-5833-4AF9-BA5E-01CCF39C1F2"); dw_props.SetItemDisplayString(1,L"CategoryID",L"notify.pnmh; xstring value = hdr.data; xstring colname = hdr.colname; xaserverarg arg; return 1; } //}TäNYt‹NöN int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnAttachEvent() { AttachEvent(L"dw_props",L"DWV_CLICKED", (FEvent)&ProductNewItemWin::OnPropClick); //Ñ~š[å]wQag¹pûQ‹NöN AttachEvent(L"WM_XCOMMAND", (FEvent)&ProductNewItemWin::OnXCommand); //·ƒÖS&q¹p‹NöN ÿ(uŽN͑nå]wQag AttachEvent(L"WM_SETFOCUS", (FEvent)&ProductNewItemWin::OnSetFocus); return 1; } int onload() { SetArg(); OnAttachEvent(); originSKUID = L""; dw_props = GetControl(L"dw_props"); dw_makeitem = GetControl(L"dw_makeitem"); dw_makeitem.openUrl(L"/sale/view/ProductLibrary/template/newiteminfo"); dw_makeitem.SetColHeaderHeight(0); dw_makeitem.SetRowSelectorWidth(0); dw_makeitem.SetHScrollState(false); dw_makeitem.SetVScrollState(false); m_EntityID = L""; xaserverarg arg; if(GetWinParam()) { arg = GetArg(); m_EntityID = arg.GetArgString(L"EntityID"); } xml x; arg.AddArg(L"guid",m_EntityID); dw_props.openUrl(L"/sale/view/ProductLibrary/template/ProductProps"); dw_props.SetDataObject(x); dw_props.SetColHeaderHeight(0); dw_props.SetRowSelectorWidth(0); dw_props.SetHScrollState(false); if(GetWinParam()) { hObject = (HWND)arg.GetParam(L"HWND"); dw_obj = (void*)arg.GetParam(L"dw"); KXMLDOMElement e = (LPARAM)arg.GetParam(L"data"); if(e.selectSingleNode(L"CName")) dw_props.SetItemString(1,L"CName",e.selectSingleNode(L"CName").text()); if(e.selectSingleNode(L"EName")) dw_props.SetItemString(1,L"EName",e.selectSingleNode(L"EName").text()); //if(e.selectSingleNode(L"GoodsNo")) dw_props.SetItemString(1,L"GoodsNo",e.selectSingleNode(L"GoodsNo").text()); if(e.selectSingleNode(L"PackingRate")) dw_props.SetItemString(1,L"PackingRate",e.selectSingleNode(L"PackingRate").text()); if(e.selectSingleNode(L"VolumeDesc")) dw_props.SetItemString(1,L"VolumeDesc",e.selectSingleNode(L"VolumeDesc").text()); if(e.selectSingleNode(L"QTYUnit")) dw_props.SetItemString(1,L"QTYUnit",e.selectSingleNode(L"QTYUnit").text()); if(e.selectSingleNode(L"InnerQty")) dw_props.SetItemString(1,L"InnerQty",e.selectSingleNode(L"InnerQty").text()); if(e.selectSingleNode(L"KOPCode")) dw_props.SetItemString(1,L"KOPCode",e.selectSingleNode(L"KOPCode").text()); if(e.selectSingleNode(L"GWPerPkg")) dw_props.SetItemString(1,L"GWPerPkg",e.selectSingleNode(L"GWPerPkg").text()); if(e.selectSingleNode(L"NWPerPkg")) dw_props.SetItemString(1,L"NWPerPkg",e.selectSingleNode(L"NWPerPkg").text()); if(e.selectSingleNode(L"SKUGW")) dw_props.SetItemString(1,L"SKUGW",e.selectSingleNode(L"SKUGW").text()); if(e.selectSingleNode(L"BuyPrice")) dw_props.SetItemString(1,L"BuyPrice",e.selectSingleNode(L"BuyPrice").text()); if(e.selectSingleNode(L"SupplierID")) dw_props.SetItemString(1,L"SupplierID",e.selectSingleNode(L"SupplierID").text()); if(e.selectSingleNode(L"Remark")) dw_props.SetItemString(1,L"Remark",e.selectSingleNode(L"Remark").text()); if(e.selectSingleNode(L"PackageL")) dw_props.SetItemString(1,L"PackageL",e.selectSingleNode(L"PackageL").text()); if(e.selectSingleNode(L"PackageW")) dw_props.SetItemString(1,L"PackageW",e.selectSingleNode(L"PackageW").text()); if(e.selectSingleNode(L"PackageH")) dw_props.SetItemString(1,L"PackageH",e.selectSingleNode(L"PackageH").text()); if(e.selectSingleNode(L"CategoryID"))dw_props.SetItemString(1,L"CategoryID",e.selectSingleNode(L"CategoryID").text()); if(e.selectSingleNode(L"CategoryID/@_displaystring"))dw_props.SetItemDisplayString(1,L"CategoryID",e.selectSingleNode(L"CategoryID/@_displaystring").text()); if(e.selectSingleNode(L"Category/@_displaystring"))dw_props.SetItemDisplayString(1,L"CategoryID",e.selectSingleNode(L"Category/@_displaystring").text()); if(e.selectSingleNode(L"Creator"))dw_props.SetItemDisplayString(1,L"DeveloperID",e.selectSingleNode(L"Creator").text()); if(e.selectSingleNode(L"CreateID"))dw_props.SetItemString(1,L"DeveloperID",e.selectSingleNode(L"CreateID").text()); if(e.selectSingleNode(L"Price")) dw_props.SetItemString(1,L"Price",e.selectSingleNode(L"Price").text()); if(e.selectSingleNode(L"Packing")) dw_props.SetItemString(1,L"Packing",e.selectSingleNode(L"Packing").text()); //if(e.selectSingleNode(L"BarCode")) dw_props.SetItemString(1,L"BarCode",e.selectSingleNode(L"BarCode").text()); dw_props.SetItemString(1,L"CreationDate",publiccode::GetCurrentDate()); //dw_props.SetItemString(1,L"No",GetNo()); if(e.selectSingleNode(L"@guid")) { originSKUID = e.selectSingleNode(L"@guid").text(); OnShowImage(originSKUID); } } dw_props.SetColumnProp(L"BarCode",L"cellprotect",L"1"); dw_props.SetColumnProp(L"No",L"cellprotect",L"1"); dw_props.SetColumnProp(L"CreationDate",L"cellprotect",L"1"); dw_props.SetColumnProp(L"InnerNo",L"cellprotect",L"1"); dw_props.SetEditUpperMode(true); m_toold = true; return 1; } int onloaded() { SetAgent(); return 1; } };