#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) QuoteSupplierItem : public xframe
|
{
|
public:
|
xdwgrid dw_list;
|
xnode m_agentNode; //Agent Condition
|
public:
|
QuoteSupplierItem(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
|
public:
|
static QuoteSupplierItem* CreateInstance(void* implPtr, void* hWnd)
|
{
|
QuoteSupplierItem* pWin = new QuoteSupplierItem(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 OnSetFocus(TEvent* evt, LPARAM param)
|
{
|
//ÖØÖù¤¾ßÌõ
|
//SetAgent();
|
return 1;
|
}
|
|
int OnOk()
|
{
|
DoUpdate();
|
return 1;
|
}
|
|
int OnCancel()
|
{
|
CloseWindow();
|
return 1;
|
}
|
|
//ÃüÁî·¢²¼º¯Êý
|
int OnCmdDispatch(xstring comdid)
|
{
|
if(comdid==L"xmCancel") return OnCancel();
|
else if(comdid==L"xmOK") return OnOk();
|
else if(comdid==L"xmDelete") return OnDelete();
|
|
return 0;
|
}
|
|
//ÃüÁî´¦Àíʼþ
|
int OnXCommand(TEvent* evt, LPARAM param)
|
{
|
return OnCmdDispatch(evt->xcommand.pStrID);
|
}
|
|
int OnDelete()
|
{
|
dw_list.DeleteRow(dw_list.GetRow());
|
return 0;
|
}
|
|
int DoUpdate()
|
{
|
dw_list.AcceptText();
|
|
xml xitem ;
|
KXMLDOMDocument xitemdoc = xitem;
|
dw_list.DwUpdateAllToEx(xitemdoc);
|
xaserverarg arg ;
|
|
arg.AddArg(L"content",xitem.xml());
|
|
//alert(xitem.xml());
|
//return 1;
|
|
if(xurl::get(L"/sale/data/SupplierV3/entity/update/quotemysupplier", arg.GetString(),xitem)!=1)
|
{
|
xstring error1 = xitem.text();
|
return 1;
|
}else
|
{
|
xstring str = xitem.documentElement().getAttribute(L"text");
|
if(str == L"false")
|
{
|
alert(L"±£´æÊ§°Ü!");
|
return -1;
|
}
|
alert(L"±£´æ³É¹¦!");
|
dw_list.ResetUpdateStatus();
|
}
|
|
return 1;
|
}
|
|
int OnAttachEvent()
|
{
|
//°ó¶¨¹¤¾ßÌõµã»÷ʼþ
|
AttachEvent(L"WM_XCOMMAND", (FEvent)&QuoteSupplierItem::OnXCommand);
|
//»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
|
AttachEvent(L"WM_SETFOCUS", (FEvent)&QuoteSupplierItem::OnSetFocus);
|
return 1;
|
}
|
|
int OnRetrieve()
|
{
|
if(GetWinParam())
|
{
|
xaserverarg arg = GetArg();
|
xstring val = arg.GetArgString(L"value");
|
xml x ;
|
|
x.loadXML(val);
|
dw_list.Retrieve(x);
|
dw_list.Redraw();
|
|
xstring sPartyNo = publiccode::GetIdentityNo(L"Party2");
|
xstring No =L"";
|
xstring Name =L"";
|
xstring NameEx =L"";
|
/*for(int i=0; i <=dw_list.GetRowCount() ;i++)
|
{
|
Name=dw_list.GetItemString(i,L"Name");
|
if(Name !=L"")
|
{
|
if(NameEx ==L"")
|
{
|
NameEx = Name;
|
}
|
else if(NameEx.find(Name) < 0)
|
{
|
|
//dw_list.DeleteRow(i);
|
}
|
}
|
}*/
|
|
|
for(int row = 1;row <= dw_list.GetRowCount(); row++)
|
{
|
if(row==1)
|
No = sPartyNo;
|
else
|
No = (L"0000"+xstring((No.toInt()+1))).right(4);
|
dw_list.SetItemString(row,L"PartyNo",No+L"N");
|
dw_list.SetItemString(row,L"Type",L"12");
|
dw_list.SetItemString(row,L"IdentifyAddressFlag",L"Y");
|
dw_list.SetItemString(row,L"PrimaryFlag",L"Y");
|
|
xstring id = ViewObject::GetGuid();
|
KXMLDOMElement ele = dw_list.GetRowElement(row);
|
ele.setAttribute(L"guid",id);
|
//dw_list.SetGuid(row,id);
|
}
|
}
|
return 1;
|
}
|
|
int onload()
|
{
|
SetArg();
|
dw_list = GetControl(L"dw_list");
|
dw_list.openUrl(L"/sale/view/Quote3/template/Quote/QuoteSupplierItem");
|
|
OnAttachEvent();
|
OnRetrieve();
|
|
return 1;
|
}
|
|
int onloaded()
|
{
|
//SetAgent();
|
|
return 1;
|
}
|
};
|