#include <wobject/xstring.hpp>
|
#include <xcontrol/xtreeview.hpp>
|
#include <xcontrol/xdwgrid.hpp>
|
|
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
|
#include "viewobject/view.base.hpp"
|
|
using xml = KXMLDOMDocument;
|
class __declspec(dllexport) listvatnotifyWin : public xframe
|
{
|
public:
|
xdwgrid dw_list;
|
xdwpages dw_pages;
|
xdwtable dw_arg;
|
|
xnode m_agentNode; //Agent Condition
|
|
int m_pageindex;
|
int m_pagenumber;
|
xstring m_QueryTxt;
|
xstring DatePicker;
|
|
public:
|
listvatnotifyWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
|
public:
|
static listvatnotifyWin* CreateInstance(void* implPtr, void* hWnd)
|
{
|
listvatnotifyWin* pWin = new listvatnotifyWin(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 OnDWClick(TEvent* evt, LPARAM p)
|
{
|
DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
|
xstring value = hdr.data;
|
xstring colname = hdr.colname;
|
int row = hdr.row;
|
|
if (row < 1) return 1;
|
|
xaserverarg arg;
|
if (colname == L"SONo")
|
{
|
xstring SONo = dw_list.GetItemString(row, colname.c_str());
|
|
arg.AddArg(L"EntityNo", SONo);
|
arg.AddArg(L"ReadOnly", L"true");
|
OpenWindow(L"dev:xpage[base.maint.so.vx]", arg);
|
}
|
if (colname == L"InvoiceNo")
|
{
|
xstring InvoiceNo = dw_list.GetItemString(row, colname.c_str());
|
|
arg.AddArg(L"EntityNo", InvoiceNo);
|
arg.AddArg(L"ReadOnly", L"true");
|
OpenWindow(L"dev:xpage[maintex.GDN3.vx]", arg);
|
}
|
return 1;
|
}
|
|
int OnPrint()
|
{
|
xaserverarg arg ;
|
|
arg.AddArg(L"EntityName", L"VATNotify");
|
arg.AddArg(L"EntityID", L"", L"");
|
xstring InvoiceNo = dw_list.GetItemString(dw_list.GetRow(), L"NInvoiceNo");
|
if (InvoiceNo == L"") InvoiceNo = dw_list.GetItemString(dw_list.GetRow(), L"InvoiceNo");
|
|
xstring NInvoiceNoEx = dw_list.GetItemString(dw_list.GetRow(), L"NInvoiceNo");
|
xstring InvoiceNoEx = dw_list.GetItemString(dw_list.GetRow(), L"InvoiceNo");
|
xstring SupplierName = dw_list.GetItemString(dw_list.GetRow(), L"ShortName");
|
if (NInvoiceNoEx != InvoiceNoEx)
|
{
|
NInvoiceNoEx = InvoiceNoEx;
|
}
|
xstring SupplierID = dw_list.GetItemString(dw_list.GetRow(), L"SupplierID");
|
arg.AddArg(L"EntityNo", InvoiceNo, L"");
|
arg.AddArg(L"EntityNoEx", NInvoiceNoEx, L"");
|
arg.AddArg(L"SupplierID", SupplierID);
|
arg.AddArg(L"VATNotifyID", L"");
|
arg.AddArg(L"SupplierName", SupplierName);
|
trace(InvoiceNo + L"==1" + NInvoiceNoEx + L"==2" + SupplierID + L"==3" + dw_list.GetGuid(dw_list.GetRow()));
|
|
openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", arg);
|
return 1;
|
}
|
|
int OnPrintItem()
|
{
|
xaserverarg arg;
|
|
arg.AddArg(L"EntityName", L"VATNotify");
|
arg.AddArg(L"EntityID", L"", L"");
|
xstring InvoiceNo = dw_list.GetItemString(dw_list.GetRow(), L"NInvoiceNo");
|
if (InvoiceNo == L"") InvoiceNo = dw_list.GetItemString(dw_list.GetRow(), L"InvoiceNo");
|
|
xstring NInvoiceNoEx = dw_list.GetItemString(dw_list.GetRow(), L"NInvoiceNo");
|
xstring InvoiceNoEx = dw_list.GetItemString(dw_list.GetRow(), L"InvoiceNo");
|
if (NInvoiceNoEx != InvoiceNoEx)
|
{
|
NInvoiceNoEx = InvoiceNoEx;
|
}
|
xstring SupplierID = dw_list.GetItemString(dw_list.GetRow(), L"SupplierID");
|
xstring SupplierName = dw_list.GetItemString(dw_list.GetRow(), L"ShortName");
|
arg.AddArg(L"EntityNo", InvoiceNo, L"");
|
arg.AddArg(L"EntityNoEx", NInvoiceNoEx, L"");
|
arg.AddArg(L"SupplierID", SupplierID);
|
arg.AddArg(L"VATNotifyID", dw_list.GetGuid(dw_list.GetRow()));
|
arg.AddArg(L"SupplierName", SupplierName);
|
trace(L"=====L" + InvoiceNo + L"=====L" + SupplierID + L"=====L" + dw_list.GetGuid(dw_list.GetRow()));
|
|
openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", arg);
|
return 1;
|
}
|
|
int OnOpen() {
|
int row = dw_list.GetRow();
|
if (row < 1) return 0;
|
KXMLDOMElement ele = dw_list.GetRowElement(row);
|
xstring entityid = ele.selectSingleNode(L"InvoiceNo").text();
|
xaserverarg arg;
|
|
arg.AddArg(L"invoiceno", entityid);
|
|
OpenWindow(L"dev:xpage[simple.maint.vatnotify.vx]", arg);
|
return 1;
|
}
|
|
int OnPapercardOpen() {
|
int row = dw_list.GetRow();
|
if (row < 1) return 0;
|
KXMLDOMElement ele = dw_list.GetRowElement(row);
|
xstring entityid = ele.selectSingleNode(L"InvoiceNo").text();
|
xstring classifyID = ele.selectSingleNode(L"ClassifyID").text();
|
xstring supplierID = ele.selectSingleNode(L"SupplierID").text();
|
xstring cname = ele.selectSingleNode(L"CName").text();
|
|
xaserverarg arg;
|
|
arg.AddArg(L"invoiceno", entityid);
|
arg.AddArg(L"ClassifyID", classifyID);
|
arg.AddArg(L"SupplierID", supplierID);
|
arg.AddArg(L"CName", cname);
|
|
OpenWindow(L"dev:xpage[maint.papercard.vatnotify.vx]", arg);
|
return 1;
|
}
|
|
int OnModify() {
|
int row = dw_list.GetRow();
|
if (row < 1) return 0;
|
KXMLDOMElement ele = dw_list.GetRowElement(row);
|
xstring entityid = ele.selectSingleNode(L"InvoiceNo").text();
|
xaserverarg arg;
|
|
arg.AddArg(L"invoiceno", entityid);
|
|
OpenWindow(L"dev:xpage[update.vatnotify.vx]", arg);
|
return 1;
|
}
|
|
int Onfinish() {
|
|
return 1;
|
}
|
|
int OnDeleteRow()
|
{
|
if (dw_list.GetRow() < 1) return 1;
|
int row = dw_list.GetRow();
|
xstring InvoiceNo = dw_list.GetItemString(row, L"InvoiceNo");
|
int res = MessageBox(GetHWND(), L"ÊÇ·ñÈ·ÈÏɾ³ý" + InvoiceNo + L"µÄ¿ªÆ±Í¨Öª?", L"Ìáʾ", 4);
|
if (res == 6)
|
{
|
xml x = ViewObject::RetrieveData(L"/sale/data/VATNotify/entity/delete", L"invoiceno", InvoiceNo);
|
if (!x)
|
{
|
alert(L"ɾ³ý´íÎó");
|
return 1;
|
}
|
//dw_list.DeleteRow(row);
|
alert(x.text());
|
OnRetrieve(DatePicker);
|
}
|
|
return 1;
|
}
|
|
//ÃüÁî·¢²¼º¯Êý
|
int OnCmdDispatch(xstring comdid)
|
{
|
if (comdid == L"xm:import") {
|
OpenWindow(L"dev:xpage[import.vatnotify.vx]", 0);
|
}
|
if (comdid == L"action:bill.open") {
|
OnOpen();
|
}
|
else if (comdid == L"xm:notify") {
|
OnOpen();
|
}
|
else if (comdid == L"xm:papercardnotify") {
|
OnPapercardOpen();
|
}
|
else if (comdid == L"xm:modify") {
|
OnModify();
|
}
|
else if (comdid == L"xm:finish") {
|
Onfinish();
|
}
|
else if (comdid == L"xm:ratecalc") {
|
|
}
|
else if (comdid == L"find")
|
{
|
m_QueryTxt = xcontrol(GetControl(L"txt")).GetText();
|
return OnRetrieve(DatePicker);
|
}
|
else if (comdid == L"xmRefresh")
|
{
|
return OnRetrieve(DatePicker);
|
}
|
else if (comdid == L"xmDeleteRow")
|
{
|
return OnDeleteRow();
|
}
|
else if (comdid == L"xmPrint") {
|
return OnPrint();
|
}
|
else if (comdid == L"xmPrintItem") {
|
return OnPrintItem();
|
}
|
else if (comdid == L"xmSaveAs")
|
{
|
dw_list.SaveAs(L"");
|
return 1;
|
}
|
return 0;
|
}
|
|
//ÃüÁî´¦Àíʼþ
|
int OnXCommand(TEvent* evt, LPARAM param)
|
{
|
return OnCmdDispatch(evt->xcommand.pStrID);
|
}
|
|
int OnAttachEvent()
|
{
|
//°ó¶¨¹¤¾ßÌõµã»÷ʼþ
|
AttachEvent(L"WM_XCOMMAND", (FEvent)&listvatnotifyWin::OnXCommand);
|
//»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
|
AttachEvent(L"WM_SETFOCUS", (FEvent)&listvatnotifyWin::OnSetFocus);
|
AttachEvent(L"dw_list", L"DWV_CLICKED", (FEvent)&listvatnotifyWin::OnDWClick);
|
AttachEvent(L"cbx_state", L"CBN_SELCHANGE", (FEvent)&listvatnotifyWin::OnDatePicker);
|
return 1;
|
}
|
|
int OnDatePicker(TEvent* evt, int lParam)
|
{
|
|
DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
|
|
int h = xcombobox::GetCurSel(evt->command.hCtrl);
|
if (h > -1)
|
{
|
xstring txt = (string)xcombobox::GetLBText(evt->command.hCtrl, h);
|
if (txt == L"֪ͨÈÕÆÚ")
|
{
|
|
DatePicker = L"NotifyDate";
|
OnRetrieve(DatePicker);
|
}
|
else if (txt == L"³öÔËÈÕÆÚ")
|
{
|
|
DatePicker = L"ETD";
|
OnRetrieve(DatePicker);
|
}
|
}
|
return 1;
|
}
|
|
|
xstring GetQueryArg()
|
{
|
dw_arg.AcceptText();
|
xml x ;
|
|
dw_arg.DwUpdateAllTo(x);
|
return x.xml();
|
}
|
|
int OnRetrieve(xstring DatePicker)
|
{
|
HCURSOR hCursor = xutil::SetCursorWait();
|
xml x ;
|
|
xaserverarg arg;
|
|
arg.AddArg(L"pageindex", xstring(m_pageindex));
|
arg.AddArg(L"pagenumber", xstring(m_pagenumber));
|
arg.AddArg(L"QueryTxt", m_QueryTxt);
|
arg.AddArg(L"QueryArg", GetQueryArg());
|
arg.AddArg(L"DatePicker", DatePicker);
|
if (getUrl(L"/sale/data/VATNotify/entity/listOne", arg.GetString(), x) != 1)
|
{
|
trace(x.text());
|
xutil::RestoreCursor(hCursor);
|
return -1;
|
}
|
else
|
{
|
//trace(x.xml);
|
KXMLDOMElement ele = x.documentElement();
|
if (dw_pages.getNativePointer())
|
{
|
if (ele.selectSingleNode(L"@TotalPage"))
|
{
|
xstring s = ele.selectSingleNode(L"@TotalPage").text(); //×ÜÊýÁ¿
|
dw_pages.SetMaxPage(s.toInt());
|
}
|
}
|
dw_list.Retrieve(x);
|
dw_list.Redraw();
|
dw_list.SetReadOnly(true);
|
}
|
xutil::RestoreCursor(hCursor);
|
return 1;
|
}
|
|
int OnChangePages(TEvent* evt, LPARAM p)
|
{
|
PAGENMHDR& h = *(PAGENMHDR*)evt->notify.pnmh;
|
int c = h.cur;
|
HCURSOR hCursor = xutil::SetCursorWait();
|
m_pageindex = c;
|
OnRetrieve(DatePicker);
|
xutil::RestoreCursor(hCursor);
|
return 1;
|
}
|
|
int OnDoubleClicked(TEvent* evt, LPARAM p)
|
{
|
HCURSOR hCursor = xutil::SetCursorWait();
|
OnCmdDispatch(L"action:bill.open");
|
xutil::RestoreCursor(hCursor);
|
return 1;
|
}
|
|
int onload()
|
{
|
dw_list = GetControl(L"dw_list");
|
dw_list.openUrl(L"/sale/view/VATNotify/template/VATNotify/list");
|
dw_list.SetColumnState(L"ShortName", false);
|
|
dw_arg = GetControl(L"dw_arg");
|
dw_arg.openUrl(L"/sale/view/AR/template/queryarg");
|
dw_arg.SetColHeaderHeight(0);
|
dw_arg.SetRowSelectorWidth(0);
|
dw_arg.SetHScrollState(false);
|
dw_arg.SetVScrollState(false);
|
dw_arg.SetItemString(1, L"DateType", L"±¾ÔÂ");
|
//dw_arg.SetItemString(1,L"DateType",L"");
|
AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&listvatnotifyWin::OnDoubleClicked);//ÐÐË«»÷
|
dw_pages = GetControl(L"pages");
|
AttachEvent(L"pages", L"PAGE_CLICK", (FEvent)&listvatnotifyWin::OnChangePages);
|
|
|
OnAttachEvent();
|
|
return 1;
|
}
|
|
int onloaded()
|
{
|
SetAgent();
|
|
m_pageindex = 1;
|
m_pagenumber = 10000;
|
m_QueryTxt = L"";
|
|
//OnRetrieve();
|
|
return 1;
|
}
|
};
|