#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) xmQuoteBillList : public xframe
|
{
|
public:
|
xdwgrid dw_list;
|
|
xnode m_agentNode; //Agent Condition
|
int hObject = 0;
|
|
xstring QuoteNo;
|
xstring printStr;
|
public:
|
xmQuoteBillList(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
|
public:
|
static xmQuoteBillList* CreateInstance(void* implPtr, void* hWnd)
|
{
|
xmQuoteBillList* pWin = new xmQuoteBillList(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")
|
{
|
if(GetWinParam())
|
{
|
xaserverarg arg = GetArg();
|
arg.AddArg(L"items",printStr);
|
|
arg.AddArg(L"action",L"ok");
|
}
|
CloseWindow();
|
return 1;
|
}
|
if(comdid==L"xmClose")
|
{
|
|
CloseWindow();
|
return 1;
|
}
|
if(comdid==L"xmSearch")
|
{
|
|
OnRetrieve(QuoteNo);
|
return 1;
|
}
|
if(comdid==L"xmSelectAll") return SelectAll();
|
if(comdid==L"xmUnSelectAll") return UnSelectAll();
|
|
return 0;
|
}
|
|
int OnDwClicked(TEvent* evt, int p)
|
{
|
DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
|
char ch;
|
int row = hdr.row;
|
xstring col = hdr.colname;
|
|
xstring str = L"";
|
if(dw_list.GetGuid(row) !=L"")
|
{
|
str = dw_list.GetItemString(row,L"QuoteLineID");
|
}
|
|
if(dw_list.IsRowSelected(row) & 0xff)
|
{
|
printStr = printStr.replace(L" "+str,L"");
|
}else
|
{
|
printStr += L" " + str;
|
}
|
return 1;
|
}
|
//ÃüÁî´¦Àíʼþ
|
int OnXCommand(TEvent* evt, LPARAM param)
|
{
|
return OnCmdDispatch(evt->xcommand.pStrID);
|
}
|
|
int SelectAll()
|
{
|
printStr=L"";
|
for(int row = 1; row <= dw_list.GetRowCount(); row++)
|
{
|
dw_list.SetItemString(row,L"IsSend",L"1");
|
dw_list.SelectRow(row,true);
|
xstring str = L"";
|
if(dw_list.GetGuid(row) !=L"")
|
{
|
str = dw_list.GetItemString(row,L"QuoteLineID");
|
printStr += L" " + str;
|
}
|
}
|
dw_list.Redraw();
|
return 1;
|
}
|
|
int UnSelectAll()
|
{
|
printStr=L"";
|
for(int row = 1; row <= dw_list.GetRowCount(); row++)
|
{
|
dw_list.SetItemString(row,L"IsSend",L"0");
|
dw_list.SelectRow(row,false);
|
}
|
dw_list.Redraw();
|
return 1;
|
}
|
|
int OnAttachEvent()
|
{
|
//°ó¶¨¹¤¾ßÌõµã»÷ʼþ
|
AttachEvent(L"WM_XCOMMAND", (FEvent)&xmQuoteBillList::OnXCommand);
|
//»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
|
AttachEvent(L"WM_SETFOCUS", (FEvent)&xmQuoteBillList::OnSetFocus);
|
AttachEvent(L"dw_list",L"DWV_ROWFOCUSCHANGED", (FEvent)&xmQuoteBillList::OnRowChanged);
|
AttachEvent(L"dw_list",L"DWV_CLICKED", (FEvent)&xmQuoteBillList::OnDwClicked);
|
return 1;
|
|
}
|
|
|
int OnRetrieve(xstring QuoteNo)
|
{
|
xml x ;
|
|
xaserverarg arg ;
|
|
arg.AddArg(L"QuoteNo",QuoteNo);
|
|
if (getUrl(L"/sale/data/ProductLibrary3/QuoteBillList",arg.GetString(),x)!=1)
|
{
|
trace(x.text());
|
return -1;
|
}else
|
{
|
dw_list.Retrieve(x);
|
dw_list.Redraw();
|
}
|
dw_list.SetSelectionMode(3);
|
dw_list.SetReadOnly(true);
|
return 1;
|
}
|
|
int onload()
|
{
|
dw_list = GetControl(L"dw_list");
|
dw_list.openUrl(L"/sale/view/Quote3/template/Quote/QuoteBillList");
|
|
|
if(GetWinParam())
|
{
|
xaserverarg arg = GetArg();
|
QuoteNo=arg.GetArgString(L"QuoteNo");
|
OnRetrieve(arg.GetArgString(L"QuoteNo"));
|
}
|
OnRetrieve(QuoteNo);
|
SelectAll();
|
OnAttachEvent();
|
return 1;
|
}
|
|
int onloaded()
|
{
|
SetAgent();
|
|
return 1;
|
}
|
};
|