| ¶Ô±ÈÐÂÎļþ |
| | |
| | | #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) ListTestAP : public xframe |
| | | { |
| | | public: |
| | | xstring apType; |
| | | xdwgrid dw_list; |
| | | xdwtable dw_arg; |
| | | xnode m_agentNode; //Agent Condition |
| | | xstring printStr = L""; |
| | | public: |
| | | ListTestAP(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static ListTestAP* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | ListTestAP* pWin = new ListTestAP(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; |
| | | } |
| | | |
| | | xstring GetPayType() |
| | | { |
| | | xcombobox cbx_type = GetControl(L"cbx_type"); |
| | | int h = xcombobox::GetCurSel(cbx_type.GetHWND()); |
| | | if (h < 0) return L""; |
| | | return xcombobox::GetLBText(cbx_type.GetHWND(), h); |
| | | } |
| | | |
| | | int OnBank() |
| | | { |
| | | xaserverarg arg; |
| | | |
| | | OpenWindow(L"dev:xpage[APBank.vx]", arg); |
| | | if (arg.GetArgString(L"result") == L"ok") |
| | | { |
| | | int ll_row = dw_list.GetNextSelectRow(1); |
| | | dw_list.AcceptText(); |
| | | |
| | | while (ll_row > 0 && ll_row <= dw_list.GetRowCount()) |
| | | { |
| | | dw_list.SetItemString(ll_row, L"PayedTerm", arg.GetArgString(L"PayedTerm")); |
| | | dw_list.SetItemString(ll_row, L"PayedBank", arg.GetArgString(L"PayedBank")); |
| | | dw_list.SetItemString(ll_row, L"PayedBankNo", arg.GetArgString(L"PayedBankNo")); |
| | | ll_row = dw_list.GetNextSelectRow(ll_row + 1); |
| | | } |
| | | dw_list.Redraw(); |
| | | return 1; |
| | | } |
| | | else return 1; |
| | | } |
| | | |
| | | //å½ä»¤åå¸å½æ° |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | xstring payType = GetPayType(); |
| | | |
| | | |
| | | |
| | | if (comdid == L"xmBank") return OnBank(); |
| | | if (comdid == L"xmSave") return OnSave(); |
| | | if (comdid == L"xmRefresh" || comdid == L"xmSearch") |
| | | { |
| | | return OnRetrieveEx(apType); |
| | | } |
| | | if (comdid == L"xmAddRow") |
| | | { |
| | | xaserverarg arg1; |
| | | |
| | | if (payType == L"è¿æè´¹" or payType == L"æµè¯è´¹") |
| | | arg1.AddArg(L"payType", payType); |
| | | OpenWindow(L"dev:xpage[maint.expense.ap.vx]", arg1); |
| | | return 1; |
| | | } |
| | | if (comdid == L"xmModifyRow") |
| | | { |
| | | xaserverarg arg; |
| | | int row = dw_list.GetRow(); |
| | | if (row < 1) return 1; |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | xstring APID = ele.selectSingleNode(L"APID").text(); |
| | | |
| | | arg.AddArg(L"APID", APID); |
| | | arg.AddArg(L"payType", payType); |
| | | OpenWindow(L"dev:xpage[maint.expense.ap.vx]", arg); |
| | | return 1; |
| | | } |
| | | if (comdid == L"xmDeleteRow") |
| | | { |
| | | int row = dw_list.GetRow(); |
| | | if (row < 1) return 1; |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | xstring APID1 = ele.selectSingleNode(L"APID").text(); |
| | | |
| | | int MB_OKCANCEL = 1; |
| | | int IDOK = 1; |
| | | int ret = MessageBox(GetHWND(), L"确认å é¤äº§åæµè¯è´¹?", L"æç¤º", MB_OKCANCEL); |
| | | if (ret == IDOK) |
| | | { |
| | | ViewObject::RetrieveData(L"/sale/data/AP/delete/AP", L"EntityID", APID1); |
| | | OnRetrieveEx(apType); |
| | | } |
| | | |
| | | |
| | | return 1; |
| | | } |
| | | if (comdid == L"xmPrint") |
| | | { |
| | | return OnPrint(); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | int OnPrint() |
| | | { |
| | | int row = dw_list.GetRow(); |
| | | if (row < 1) return 1; |
| | | xstring APID = dw_list.GetItemString(row, L"APID"); |
| | | |
| | | if (printStr == L"")printStr = L" " + APID; |
| | | |
| | | xaserverarg arg; |
| | | arg.AddArg(L"EntityName", L"AP"); |
| | | arg.AddArg(L"EntityID", printStr, L""); |
| | | arg.AddArg(L"EntityNo", L"", L""); |
| | | |
| | | openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", arg); |
| | | return 1; |
| | | } |
| | | |
| | | int OnDoubleClicked(TEvent* evt, LPARAM p) |
| | | { |
| | | return OnCmdDispatch(L"xmModifyRow"); |
| | | } |
| | | |
| | | int OnCombboChanged(TEvent* evt, LPARAM lParam) |
| | | { |
| | | xstring id = L""; |
| | | xstring name = L""; |
| | | int h = xcombobox::GetCurSel(evt->command.hCtrl); |
| | | if (h > -1) |
| | | { |
| | | xstring txt = (string)xcombobox::GetLBText(evt->command.hCtrl, h); |
| | | apType = L"---"; |
| | | if (txt == L"è¿æè´¹") |
| | | { |
| | | dw_list.openUrl(L"/sale/view/AP/template/AP/Expense/List"); |
| | | apType = L"003"; |
| | | } |
| | | if (txt == L"æµè¯è´¹") |
| | | { |
| | | dw_list.openUrl(L"/sale/view/AP/template/AP/Expense/List"); |
| | | apType = L"021"; |
| | | } |
| | | OnRetrieveEx(apType); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //å½ä»¤å¤çäºä»¶ |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //ç»å®å·¥å
·æ¡ç¹å»äºä»¶ |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&ListTestAP::OnXCommand); |
| | | //è·åç¦ç¹äºä»¶ï¼ç¨äºé置工å
·æ¡ |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&ListTestAP::OnSetFocus); |
| | | AttachEvent(L"cbx_type", L"CBN_SELCHANGE", (FEvent)&ListTestAP::OnCombboChanged);//屿§ç»åæ¢listä¸åçæ°éåå |
| | | AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&ListTestAP::OnDoubleClicked);//è¡åå» |
| | | AttachEvent(L"dw_list", L"DWV_CLICKED", (FEvent)&ListTestAP::OnDwClicked); |
| | | return 1; |
| | | } |
| | | |
| | | 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.GetItemString(row, L"APID") != L"") |
| | | { |
| | | str = dw_list.GetItemString(row, L"APID"); |
| | | } |
| | | |
| | | if (dw_list.IsRowSelected(row) & 0xff) |
| | | { |
| | | printStr = printStr.replace(L" " + str, L""); |
| | | } |
| | | else |
| | | { |
| | | printStr += L" " + str; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnSave() |
| | | { |
| | | xml x; |
| | | |
| | | dw_list.DwUpdateAllToEx(x); |
| | | |
| | | xml x1; |
| | | |
| | | x1.loadXML(L"<data/>"); |
| | | |
| | | dw_list.DwUpdateAllToEx(x); |
| | | KXMLDOMNodeList t = x.selectNodes(L"data/Item[@update.modify]"); |
| | | KXMLDOMElement e1 = x1.documentElement(); |
| | | int len = t.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | e1.appendChild(t.item(i)); |
| | | } |
| | | //t.Release(); |
| | | e1.Release(); |
| | | //trace(x1.xml()); |
| | | //return 1; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"content", x1.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_list.ResetUpdateStatus(); |
| | | alert(L"ä¿åæå!"); |
| | | } |
| | | else |
| | | { |
| | | alert(L"ä¿å失败!"); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | xstring GetQueryArg() |
| | | { |
| | | dw_arg.AcceptText(); |
| | | xml x; |
| | | |
| | | dw_arg.DwUpdateAllTo(x); |
| | | return x.xml(); |
| | | } |
| | | |
| | | int OnRetrieveEx(xstring APType) |
| | | { |
| | | xml x; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"QueryTxt", xcontrol(GetControl(L"sle_search")).GetText()); |
| | | arg.AddArg(L"APType", APType); |
| | | arg.AddArg(L"QueryArg", GetQueryArg()); |
| | | arg.AddArg(L"DatePicker", L"APDate"); |
| | | if (getUrl(L"/sale/data/AP/list", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_list.Retrieve(x); |
| | | dw_list.Redraw(); |
| | | dw_list.SetReadOnly(true); |
| | | dw_list.SetSelectionMode(3); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | int onload() |
| | | { |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.openUrl(L"/sale/view/AP/template/AP/Expense/List"); |
| | | |
| | | 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); |
| | | |
| | | |
| | | OnAttachEvent(); |
| | | apType = L"003"; |
| | | OnRetrieveEx(apType); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | |
| | | return 1; |
| | | } |
| | | }; |