#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 "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
|
#include "viewobject/view.base.hpp"
|
|
using xml = KXMLDOMDocument;
|
|
class __declspec(dllexport) CustomerItemNoList : public xframe
|
{
|
public:
|
xdwgrid dw_list;
|
|
xnode m_agentNode; //Agent Condition
|
int hObject = 0;
|
|
xstring GoodsNo;
|
|
public:
|
CustomerItemNoList(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
|
public:
|
static CustomerItemNoList* CreateInstance(void* implPtr, void* hWnd)
|
{
|
CustomerItemNoList* pWin = new CustomerItemNoList(implPtr, (HWND)hWnd);
|
return pWin;
|
}
|
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;
|
}
|
|
int OnRowChanged(TEvent* evt, int p)
|
{
|
DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
|
int row = hdr.row;
|
SetAgent();
|
return 1;
|
}
|
|
|
//½¹µã¼¤»î´¦Àíº¯Êý
|
int OnSetFocus(TEvent* evt, LPARAM param)
|
{
|
//ÖØÖù¤¾ßÌõ
|
SetAgent();
|
//trace(GetEntityID(1));
|
return 1;
|
}
|
|
|
|
//ÃüÁî·¢²¼º¯Êý
|
int OnCmdDispatch(xstring comdid)
|
{
|
if(comdid==L"xmImport")
|
{
|
|
Doubleclick();
|
return 1;
|
}
|
if(comdid==L"xmClose")
|
{
|
|
CloseWindow();
|
return 1;
|
}
|
if(comdid==L"xmSearch")
|
{
|
|
OnRetrieve(GoodsNo);
|
return 1;
|
}
|
return 0;
|
}
|
|
int Doubleclick()
|
{
|
xaserverarg arg = GetArg();
|
arg.AddArg(L"items",L"");
|
xstring str = L"";
|
int row = dw_list.GetNextSelectRow(1);
|
while(row > 0 && row <= dw_list.GetRowCount())
|
{
|
KXMLDOMElement ele = dw_list.GetRowElement(row);
|
|
str += ele.xml();
|
row = dw_list.GetNextSelectRow(row + 1);
|
}
|
if(str != L"")
|
arg.AddArg(L"items",L"<data>"+str+L"</data>");
|
trace(str);
|
arg.AddArg(L"action",L"ok");
|
CloseWindow();
|
return 1;
|
}
|
|
//ÃüÁî´¦Àíʼþ
|
int OnXCommand(TEvent* evt, LPARAM param)
|
{
|
return OnCmdDispatch(evt->xcommand.pStrID);
|
}
|
|
int OnAttachEvent()
|
{
|
//°ó¶¨¹¤¾ßÌõµã»÷ʼþ
|
AttachEvent(L"WM_XCOMMAND", (FEvent)&CustomerItemNoList::OnXCommand);
|
//»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
|
AttachEvent(L"WM_SETFOCUS", (FEvent)&CustomerItemNoList::OnSetFocus);
|
AttachEvent(L"dw_list",L"DWV_DOUBLECLICKED", (FEvent)&CustomerItemNoList::Doubleclick);
|
return 1;
|
|
}
|
|
|
int OnRetrieve(xstring GoodsNo)
|
{
|
xml x ;
|
|
xaserverarg arg ;
|
|
arg.AddArg(L"GoodsNo",GoodsNo);
|
|
if (getUrl(L"/sale/data/ProductLibrary3/GetCustomerItemNoList",arg.GetString(),x)!=1)
|
{
|
trace(x.text());
|
return -1;
|
}else
|
{
|
dw_list.Retrieve(x);
|
dw_list.Redraw();
|
}
|
dw_list.SetSelectionMode(1);
|
dw_list.SetReadOnly(true);
|
return 1;
|
}
|
|
int onload()
|
{
|
SetArg();
|
dw_list = GetControl(L"dw_list");
|
dw_list.openUrl(L"/sale/view/Quote3/template/Quote/CustomerItemNoList");
|
|
|
if(GetWinParam())
|
{
|
xaserverarg arg = GetArg();
|
GoodsNo=arg.GetArgString(L"GoodsNo");
|
OnRetrieve(arg.GetArgString(L"GoodsNo"));
|
}
|
OnRetrieve(GoodsNo);
|
OnAttachEvent();
|
return 1;
|
}
|
|
int onloaded()
|
{
|
SetAgent();
|
|
return 1;
|
}
|
};
|