þÿ#include <wobject/xstring.hpp> #include <xcontrol/xtreeview.hpp> #include <xcontrol/xdwgrid.hpp> #include <wobject/xdouble.hpp> #include <xcontrol/xlayersheet.hpp> #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) ExportCredit : public xframe { public: xdwgrid dw_list; xnode m_agentNode; //Agent Condition xdwgrid dw_item; xdwtable dw_arg; xdwgrid dw_goods; public: ExportCredit(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static ExportCredit* CreateInstance(void* implPtr, void* hWnd) { ExportCredit* pWin = new ExportCredit(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, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; int row = hdr.row; SetAgent(); OnRetrieveEx(row); return 1; } //q&p¹oÀm;YtQýep int OnSetFocus(TEvent* evt, LPARAM param) { //‘Ín]åQwga SetAgent(); //trace(GetEntityID(1)); return 1; } int OnSave() { xml x ; dw_item.AcceptText(); dw_item.DwUpdateAllToEx(x); xml x0; x0.loadXML(L"<ExportCredit/>"); KXMLDOMNodeList t = x.selectNodes(L"ExportCredit/Item[@update.modify='1' or @update.delete ='1']"); KXMLDOMElement e1 = x0.documentElement(); int len = t.length(); for (int i = 0; i < len; i++) { e1.appendChild(t.item(i)); } xaserverarg arg; arg.AddArg(L"content", x0.xml()); trace(x0.xml()); if (xurl::get(L"/sale/data/Expense3/update/ExportCreditItem", arg.GetString(), x) != 1) { xstring error = x.text(); alert(L"err:" + error); return 1; } xstring str = x.documentElement().getAttribute(L"text"); if (str == L"true") { dw_item.ResetUpdateStatus(); alert(L"OÝ[XbRŸ!"); OnRetrieve(); } else { alert(L"OÝ[XY1%!"); } return 1; } int OnModifyRow(int row) { xaserverarg arg; arg.AddArg(L"ExportCreditID", dw_list.GetItemString(row, L"ExportCreditID")); OpenWindow(L"dev:xpage[ExportCreditMaint.vx]", arg); return 1; } int XmDelete() { xstring ExportCreditID = dw_list.GetItemString(dw_list.GetRow(), L"ExportCreditID"); int MB_OKCANCEL = 1; int IDOK = 1; int ret = MessageBox(GetHWND(), L"xn‹¤R –d?", L"cÐy:", MB_OKCANCEL); if (ret == IDOK) { xml x = ViewObject::RetrieveData(L"/sale/data/Expense3/DeleteExportCredit", L"ExportCreditID", ExportCreditID); xstring status = x.xml(); if (status.find(L"ok") == 1) { alert(L"R –dbRŸ"); OnRetrieve(); } else { alert(L"R –dY1%"); } } return 1; } //T}NäSÑ^Qýep int OnCmdDispatch(xstring comdid) { xstring NO = publiccode::GetUser().no; xstring Jobname = publiccode::GetUser().jobname; if (NO == L"admin") Jobname = L""; if (Jobname == L"NR¡TX") { if (comdid == L"OnOpen") { OnModifyRow(dw_list.GetRow()); return 1; } if (comdid == L"xmSearch") { OnRetrieve(); return 1; } return 1; } if (comdid == L"OnOpen") { OnModifyRow(dw_list.GetRow()); return 1; } if (comdid == L"xmSearch") { OnRetrieve(); return 1; } if (comdid == L"OnNew") { OpenWindow(L"dev:xpage[ExportCreditMaint.vx]", 0); return 1; } if (comdid == L"OnDelete") { XmDelete(); return 1; } if (comdid == L"XmSave") { OnSave(); return 1; }if (comdid == L"XmPremiumRate") { PremiumRate(dw_list.GetRow()); return 1; } return 0; } int PremiumRate(int row) { xstring CustomerID = dw_list.GetItemString(row, L"CustomerID"); xstring CustomerName = dw_list.GetItemDisplayString(row, L"CustomerID"); xaserverarg arg; arg.AddArg(L"CustomerID", CustomerID); arg.AddArg(L"CustomerName", CustomerName); OpenWindow(L"dev:xpage[PremiumRateList.vx]", arg); return 1; } int OnDoubleClicked(TEvent* evt, LPARAM p) { return OnCmdDispatch(L"OnOpen"); } //T}NäYtN‹Nö int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnItemChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname = hdr.colname; xstring value = hdr.data; int row = hdr.row; xstring dwname = L"dw_item"; if (colname == L"Type") { if (value == L"N") { dw_item.SetItemString(row, L"CreatorID", L""); dw_item.SetItemDisplayString(row, L"CreatorID", L""); dw_item.SetItemString(row, L"CreateDate", L""); dw_item.SetItemString(row, L"Note", L""); } else { xstring Createdate = publiccode::GetCurrentDate(); xstring userid = publiccode::GetUser().id; xstring username = publiccode::GetUser().name; dw_item.SetItemString(row, L"CreatorID", userid); dw_item.SetItemDisplayString(row, L"CreatorID", username); dw_item.SetItemString(row, L"CreateDate", Createdate); //dw_item.SetGuid(row, publiccode::GetGuid()); KXMLDOMElement e = dw_item.GetRowElement(row); xstring ID = publiccode::GetGuid(); e.setAttribute(L"guid", ID); } } return 1; } int OnAttachEvent() { //~Ñ[š]åQwgap¹QûN‹Nö AttachEvent(L"WM_XCOMMAND", (FEvent)&ExportCredit::OnXCommand); //ƒ·SÖq&p¹N‹Nöÿ u(NŽ‘Ín]åQwga AttachEvent(L"WM_SETFOCUS", (FEvent)&ExportCredit::OnSetFocus); AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&ExportCredit::OnDoubleClicked);//ˆLSÌQû AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&ExportCredit::OnRowChanged); AttachEvent(L"dw_item", L"DWV_ITEMCHANGED", (FEvent)&ExportCredit::OnItemChanged); return 1; } xstring GetQueryArg() { dw_arg.AcceptText(); xml x; dw_arg.DwUpdateAllTo(x); return x.xml(); } int OnRetrieve() { xml x ; xaserverarg arg; arg.AddArg(L"sType",xcontrol(GetControl(L"search")).GetText()); arg.AddArg(L"QueryArg", GetQueryArg()); if (getUrl(L"/sale/data/Expense3/ExportCreditList", 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); OnRetrieveGoods(); return 1; } int OnRetrieveGoods() { xml x; xaserverarg arg; arg.AddArg(L"QueryArg", GetQueryArg()); arg.AddArg(L"sType", xcontrol(GetControl(L"search")).GetText()); trace(GetQueryArg()); if (getUrl(L"/sale/data/Expense3/ExportCreditGoods", arg.GetString(), x) != 1) { trace(x.text()); return -1; } else { dw_goods.Retrieve(x); dw_goods.Redraw(); } dw_goods.SetSelectionMode(1); dw_goods.SetReadOnly(true); return 1; } int OnRetrieveEx(int row) { xstring ExportCreditID = dw_list.GetItemString(row, L"ExportCreditID"); xml x ; xaserverarg arg; arg.AddArg(L"ExportCreditID", ExportCreditID); arg.AddArg(L"QueryArg", GetQueryArg()); arg.AddArg(L"sType", xcontrol(GetControl(L"search")).GetText()); if (getUrl(L"/sale/data/Expense3/GetExportCreditItemEx", arg.GetString(), x) != 1) { trace(x.text()); return -1; } else { dw_item.Retrieve(x); dw_item.Redraw(); } dw_item.SetSelectionMode(1); //dw_item.SetReadOnly(true); return 1; } int onload() { dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/expense3/ExportCreditList"); dw_list.SetColumnState(L"ExportCreditID", false); dw_item = GetControl(L"dw_item"); dw_item.openUrl(L"/sale/view/expense3/ExportCreditItem"); dw_item.SetColumnState(L"ExportCreditItemID", false); dw_item.SetColumnState(L"ExportCreditID", false); dw_goods = GetControl(L"dw_goods"); dw_goods.openUrl(L"/sale/view/expense3/ExportCreditGoods"); dw_goods.SetColumnState(L"ExportCreditItemID", false); dw_goods.SetColumnState(L"ExportCreditID", 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"g,^t"); OnAttachEvent(); OnRetrieve(); OnRetrieveEx(1); return 1; } int onloaded() { SetAgent(); return 1; } };