¶Ô±ÈÐÂÎļþ |
| | |
| | | #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) MaintAP : public xframe |
| | | { |
| | | public: |
| | | xstring APID; |
| | | xstring APType; |
| | | xdwtable dw_base; |
| | | xnode m_agentNode; //Agent Condition |
| | | HWND hObject = 0; |
| | | public: |
| | | MaintAP(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static MaintAP* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | MaintAP* pWin = new MaintAP(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 updateAdvance() |
| | | { |
| | | xstring AdvanceID = dw_base.GetItemString(1, L"AdvanceID"); |
| | | xstring ChargeOffState = L"Y"; |
| | | xstring ChargeOffDate = dw_base.GetItemString(1, L"APDate"); |
| | | xstring PayedAmount = dw_base.GetItemString(1, L"PayedAmount"); |
| | | xstring val = L"<data><PO><item guid='" + AdvanceID + L"' update.modify='1'>" + |
| | | "<ChargeOffState update.modify='1'>" + ChargeOffState + L"</ChargeOffState>" + |
| | | "<ChargeOffMoney update.modify='1'>" + PayedAmount + L"</ChargeOffMoney>" + |
| | | "<ChargeOffDate update.modify='1'>" + ChargeOffDate + L"</ChargeOffDate></item></PO></data>"; |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"content", val); |
| | | xml x ; |
| | | |
| | | if (xurl::get(L"/sale/data/PurchaseOrder/update/polistex", arg.GetString(), x) != 1) |
| | | { |
| | | xstring error = x.text(); |
| | | //alert(error); |
| | | return 0; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnSave() |
| | | { |
| | | xstring APNo = dw_base.GetItemString(1, L"APNo"); |
| | | xml x ; |
| | | if (APNo == L"") |
| | | { |
| | | x = ViewObject::RetrieveData(L"/sale/data/AP/MakeAPNo"); |
| | | APNo = x.text(); |
| | | dw_base.SetItemString(1, L"APNo", APNo); |
| | | } |
| | | xstring AdvanceID = dw_base.GetItemString(1, L"AdvanceID"); |
| | | xstring OrigSysID = dw_base.GetItemString(1, L"OrigSysID"); |
| | | xstring APType1 = dw_base.GetItemString(1, L"APType"); |
| | | if (APType1 != L"000") |
| | | { |
| | | if (AdvanceID == L"" && OrigSysID != L"") { |
| | | alert(L"请转å
¥"); |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | |
| | | dw_base.AcceptText(); |
| | | dw_base.DwUpdateAllTo(x); |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"content", x.xml()); |
| | | |
| | | if (xurl::get(L"/sale/data/AP/update", 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_base.ResetUpdateStatus(); |
| | | updateAdvance(); |
| | | alert(L"ä¿åæå!"); |
| | | |
| | | SendMessage(hObject, 0x401, (LPARAM)L"xmRefresh", 0); |
| | | CloseWindow(); |
| | | } |
| | | else |
| | | { |
| | | alert(L"ä¿å失败!"); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | 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_base"; |
| | | xstring ETD = L""; |
| | | |
| | | if (value == L"") return 1; |
| | | if (colname == L"SupplierID") |
| | | { |
| | | dw_base.SetItemString(1, L"APSupplierID", dw_base.GetItemString(1, L"SupplierID")); |
| | | dw_base.SetItemDisplayString(1, L"APSupplierID", dw_base.GetItemDisplayString(1, L"SupplierID")); |
| | | } |
| | | if (colname == L"Amount") |
| | | { |
| | | dw_base.SetItemString(1, L"PayedAmount", dw_base.GetItemString(1, L"Amount")); |
| | | } |
| | | if (colname == L"InvoiceNo") |
| | | { |
| | | dw_base.SetItemString(1, L"NotifyInvoiceNo", dw_base.GetItemString(1, L"InvoiceNo")); |
| | | |
| | | xml x11 = ViewObject::RetrieveData(L"/sale/data/AP/GetInvoiceNo", L"InvoiceNo", dw_base.GetItemString(1, L"InvoiceNo")); |
| | | if (x11) |
| | | { |
| | | ETD = x11.text(); |
| | | } |
| | | dw_base.SetItemString(1, L"GDNDate", ETD); |
| | | } |
| | | |
| | | return 1; |
| | | |
| | | } |
| | | int OnImport() |
| | | { |
| | | xaserverarg arg1; |
| | | |
| | | arg1.AddArg(L"PONo", dw_base.GetItemString(1, L"PONo")); |
| | | OpenWindow(L"dev:xpage[Select.AP.vx]", arg1); |
| | | xstring str = arg1.GetArgString(L"items"); |
| | | if (str != L"") |
| | | { |
| | | xml x ; |
| | | |
| | | x.loadXML(str); |
| | | KXMLDOMNodeList items = x.selectNodes(L"data/item"); |
| | | KXMLDOMNode t = items.item(0); |
| | | KXMLDOMNodeList items1 = x.selectNodes(L"data"); |
| | | KXMLDOMNode t1 = items1.item(0); |
| | | if (t1.selectSingleNode(L"item/@guid"))dw_base.SetItemString(1, L"AdvanceID", t1.selectSingleNode(L"item/@guid").text()); |
| | | if (t.selectSingleNode(L"PONo"))dw_base.SetItemString(1, L"PONo", t.selectSingleNode(L"PONo").text()); |
| | | if (t.selectSingleNode(L"OrgName"))dw_base.SetItemString(1, L"OrgName", t.selectSingleNode(L"OrgName").text()); |
| | | if (t.selectSingleNode(L"SalespersonID/@_displaystring"))dw_base.SetItemDisplayString(1, L"SalespersonID", t.selectSingleNode(L"SalespersonID/@_displaystring").text()); |
| | | if (t.selectSingleNode(L"SalespersonID"))dw_base.SetItemString(1, L"SalespersonID", t.selectSingleNode(L"SalespersonID").text()); |
| | | if (t.selectSingleNode(L"AdvancedMoney"))dw_base.SetItemString(1, L"Amount", t.selectSingleNode(L"AdvancedMoney").text()); |
| | | if (t.selectSingleNode(L"AdvancedMoney"))dw_base.SetItemString(1, L"PayedAmount", t.selectSingleNode(L"AdvancedMoney").text()); |
| | | if (t.selectSingleNode(L"PartyID"))dw_base.SetItemString(1, L"SupplierID", t.selectSingleNode(L"PartyID").text()); |
| | | if (t.selectSingleNode(L"PartyID"))dw_base.SetItemString(1, L"APSupplierID", t.selectSingleNode(L"PartyID").text()); |
| | | if (t.selectSingleNode(L"ShortName"))dw_base.SetItemDisplayString(1, L"APSupplierID", t.selectSingleNode(L"ShortName").text()); |
| | | if (t.selectSingleNode(L"ShortName"))dw_base.SetItemDisplayString(1, L"SupplierID", t.selectSingleNode(L"ShortName").text()); |
| | | if (t.selectSingleNode(L"SONo"))dw_base.SetItemString(1, L"SONO", t.selectSingleNode(L"SONo").text()); |
| | | |
| | | if (t.selectSingleNode(L"POAmount"))dw_base.SetItemString(1, L"POAmount", t.selectSingleNode(L"POAmount").text()); |
| | | } |
| | | return 1; |
| | | } |
| | | //å½ä»¤åå¸å½æ° |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid == L"xmImport") |
| | | { |
| | | OnImport(); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmClose") |
| | | { |
| | | CloseWindow(); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmSave") |
| | | { |
| | | return OnSave(); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | //å½ä»¤å¤çäºä»¶ |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //ç»å®å·¥å
·æ¡ç¹å»äºä»¶ |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&MaintAP::OnXCommand); |
| | | AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", (FEvent)&MaintAP::OnItemChanged); |
| | | //è·åç¦ç¹äºä»¶ï¼ç¨äºé置工å
·æ¡ |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&MaintAP::OnSetFocus); |
| | | return 1; |
| | | } |
| | | |
| | | int OnRetrieve() |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"EntityID", APID); |
| | | if (getUrl(L"/sale/data/AP/base", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_base.Retrieve(x); |
| | | dw_base.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | APID = L""; |
| | | APType = L""; |
| | | if (GetWinParam()) |
| | | { |
| | | xaserverarg arg=GetArg(); |
| | | |
| | | APID = arg.GetArgString(L"APID"); |
| | | APType = arg.GetArgString(L"APType"); |
| | | } |
| | | dw_base = GetControl(L"dw_base"); |
| | | dw_base.openUrl(L"/sale/view/AP/template/Base1"); |
| | | dw_base.SetColHeaderHeight(0); |
| | | dw_base.SetRowSelectorWidth(0); |
| | | dw_base.SetHScrollState(false); |
| | | dw_base.SetVScrollState(false); |
| | | |
| | | OnAttachEvent(); |
| | | |
| | | if (APID != L"") |
| | | { |
| | | OnRetrieve(); |
| | | } |
| | | else |
| | | { |
| | | xstring sdate = publiccode::GetCurrentDate(); |
| | | dw_base.SetItemString(1, L"APDate", sdate); |
| | | dw_base.SetItemString(1, L"PayedDate", sdate); |
| | | dw_base.SetItemString(1, L"CreateDate", sdate); |
| | | xstring suserid = publiccode::GetUser().id; |
| | | xstring susername = publiccode::GetUser().name; |
| | | dw_base.SetItemString(1, L"CreatorID", suserid); |
| | | dw_base.SetItemDisplayString(1, L"CreatorID", susername); |
| | | dw_base.SetItemString(1, L"APType", L"001"); |
| | | dw_base.SetItemDisplayString(1, L"APType", L"é¢ä»æ¬¾"); |
| | | dw_base.SetItemString(1, L"ApprovalStatus", L"6"); |
| | | |
| | | } |
| | | for (int m = 1; m <= dw_base.GetColumnCount(); m++) |
| | | { |
| | | xstring col = dw_base.GetColumnName(m); |
| | | if (col == L"OrgName" || col == L"APNo") |
| | | dw_base.SetColumnProp(col, L"cellprotect", L"1"); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | |
| | | return 1; |
| | | } |
| | | }; |