¶Ô±ÈÐÂÎļþ |
| | |
| | | #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) ListAP : public xframe |
| | | { |
| | | public: |
| | | xstring apType; |
| | | xstring DatePicker; |
| | | xstring DatePickerOne; |
| | | xdwgrid dw_list; |
| | | xdwtable dw_arg; |
| | | xnode m_agentNode; //Agent Condition |
| | | |
| | | public: |
| | | ListAP(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static ListAP* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | ListAP* pWin = new ListAP(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); |
| | | } |
| | | |
| | | xstring GetEntityName(int pr) |
| | | { |
| | | return L"AP3"; |
| | | } |
| | | |
| | | xstring GetEntityIDName(int /*param*/ pr) |
| | | { |
| | | return L"APID"; |
| | | } |
| | | |
| | | xstring GetEntityID(int /*param*/ pr) |
| | | { |
| | | return dw_list.GetItemString(dw_list.GetRow(), L"APID"); |
| | | } |
| | | |
| | | int ViewUpdate(int pr, xstring updateItem, xaserverarg arg) |
| | | { |
| | | if (updateItem == L"del") |
| | | { |
| | | int DelRow = dw_list.GetRow(); |
| | | dw_list.DeleteRow(DelRow); |
| | | return 1; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | 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) |
| | | { |
| | | if (comdid == L"xmBank") return OnBank(); |
| | | if (comdid == L"xmSave") return OnSave(); |
| | | if (comdid == L"xmAnalysis") return OnAnalysis(); |
| | | if (comdid == L"xmRefresh" || comdid == L"xmSearch") |
| | | { |
| | | xstring payTypeOne = GetPayType(); |
| | | if (payTypeOne == L"å·²ä»è´§æ¬¾" || payTypeOne == L"å¾
ä»è´§æ¬¾") |
| | | { |
| | | return OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | else if (payTypeOne == L"é¢ä»è´§æ¬¾") |
| | | { |
| | | apType = L"001"; |
| | | return OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | else if (payTypeOne == L"é¢ä»è´§æ¬¾(å·²å²)L") |
| | | { |
| | | apType = L"001"; |
| | | return OnRetrieveEx1(apType, DatePickerOne); |
| | | } |
| | | |
| | | } |
| | | if (comdid == L"xmAddRow") |
| | | { |
| | | xstring payType = GetPayType(); |
| | | if (payType == L"å·²ä»è´§æ¬¾" || payType == L"å¾
ä»è´§æ¬¾") |
| | | OpenWindow(L"dev:xpage[APNew3.warizd.vx]"); |
| | | else if (payType == L"é¢ä»è´§æ¬¾" || payType == L"é¢ä»è´§æ¬¾(å·²å²)L") |
| | | { |
| | | xaserverarg arg1; |
| | | |
| | | arg1.AddArg(L"APType", apType); |
| | | |
| | | OpenWindow(L"dev:xpage[maint.ap.vx]", arg1); |
| | | } |
| | | return 1; |
| | | } |
| | | if (comdid == L"xmSaveAs") |
| | | { |
| | | dw_list.SaveAs(L""); |
| | | return 1; |
| | | } |
| | | if (comdid == L"xmModifyRow") |
| | | { |
| | | |
| | | int row = dw_list.GetRow(); |
| | | if (row < 1) return 1; |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | xstring APID = ele.selectSingleNode(L"APID").text(); |
| | | ele.Release(); |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"APID", APID); |
| | | arg.AddArg(L"APType", apType); |
| | | |
| | | OpenWindow(L"dev:xpage[maint.ap.vx]", arg); |
| | | return 1; |
| | | } |
| | | if (comdid.find(L"action:", 0) >= 0) |
| | | { |
| | | xstring payType1 = GetPayType(); |
| | | if (payType1 == L"å·²ä»è´§æ¬¾" || payType1 == L"é¢ä»è´§æ¬¾") ProcessFlowAction(comdid, 1); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | int OnDoubleClicked(TEvent* evt, LPARAM p) |
| | | { |
| | | return OnCmdDispatch(L"xmModifyRow"); |
| | | } |
| | | |
| | | int OnCombboChanged(TEvent* evt, int lParam) |
| | | { |
| | | xstring id = L""; |
| | | xstring name = L""; |
| | | int h = xcombobox::GetCurSel(evt.hCtrl); |
| | | if (h > -1) |
| | | { |
| | | xstring txt = xcombobox::GetLBText(evt.hCtrl, h); |
| | | apType = L"---"; |
| | | if (txt == L"å·²ä»è´§æ¬¾") |
| | | { |
| | | dw_list.openUrl(L"/sale/view/AP/template/AP/list1"); |
| | | apType = L"000"; |
| | | OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | else if (txt == L"å¾
ä»è´§æ¬¾") |
| | | { |
| | | dw_list.openUrl(L"/sale/view/AP/template/AP/list2"); |
| | | OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | else if (txt == L"é¢ä»è´§æ¬¾") |
| | | { |
| | | dw_list.openUrl(L"/sale/view/AP/template/AP/list3"); |
| | | apType = L"001"; |
| | | OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | else if (txt == L"é¢ä»è´§æ¬¾(å·²å²)L") |
| | | { |
| | | dw_list.openUrl(L"/sale/view/AP/template/AP/list3"); |
| | | apType = L"001"; |
| | | OnRetrieveEx1(apType, DatePickerOne); |
| | | } |
| | | |
| | | dw_list.SetColumnState(L"APID", false); |
| | | |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //å½ä»¤å¤çäºä»¶ |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnItemChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | //if(datareading) return 0; |
| | | HCURSOR HCursor = xutil::SetCursorWait(); |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | xstring col = hdr.colname; |
| | | xstring data = hdr.data; |
| | | xstring ETD = L""; |
| | | if (col == L"InvoiceNo") |
| | | { |
| | | if (dw_list.GetItemString(row, L"InvoiceNo") != L"") |
| | | { |
| | | xml x12 = ViewObject::RetrieveData(L"/sale/data/AP/GetInvoiceNoEx", L"InvoiceNo", dw_list.GetItemString(row, L"InvoiceNo")); |
| | | if (x12) |
| | | { |
| | | xstring COUNT = x12.text(); |
| | | if (COUNT != L"") |
| | | { |
| | | alert(COUNT); |
| | | dw_list.SetItemString(row, L"InvoiceNo", L""); |
| | | dw_list.SetItemString(row, L"NotifyInvoiceNo", L""); |
| | | dw_list.SetItemString(row, L"GDNDate", L""); |
| | | dw_list.Redraw(); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | xml x11 = ViewObject::RetrieveData(L"/sale/data/AP/GetInvoiceNo", L"InvoiceNo", dw_list.GetItemString(row, L"InvoiceNo")); |
| | | if (x11) |
| | | { |
| | | ETD = x11.text(); |
| | | } |
| | | dw_list.SetItemString(row, L"NotifyInvoiceNo", dw_list.GetItemString(row, L"InvoiceNo")); |
| | | dw_list.SetItemString(row, L"GDNDate", ETD); |
| | | dw_list.Redraw(); |
| | | |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | dw_list.SetItemString(row, L"NotifyInvoiceNo", L""); |
| | | dw_list.SetItemString(row, L"GDNDate", L""); |
| | | dw_list.Redraw(); |
| | | } |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //ç»å®å·¥å
·æ¡ç¹å»äºä»¶ |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&ListAP::OnXCommand); |
| | | //è·åç¦ç¹äºä»¶ï¼ç¨äºé置工å
·æ¡ |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&ListAP::OnSetFocus); |
| | | AttachEvent(L"cbx_type", L"CBN_SELCHANGE", (FEvent)&ListAP::OnCombboChanged);//屿§ç»åæ¢listä¸åçæ°éåå |
| | | AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&ListAP::OnDoubleClicked);//è¡åå» |
| | | AttachEvent(L"cbx_state", L"CBN_SELCHANGE", (FEvent)&ListAP::OnDatePicker); |
| | | AttachEvent(L"dw_list", L"DWV_ITEMCHANGED", (FEvent)&ListAP::OnItemChanged); |
| | | return 1; |
| | | } |
| | | |
| | | int OnDatePicker(TEvent* evt, int lParam) |
| | | { |
| | | xstring payTypeTwo = GetPayType(); |
| | | if (payTypeTwo == L"å·²ä»è´§æ¬¾" || payTypeTwo == L"å¾
ä»è´§æ¬¾") |
| | | { |
| | | int h = xcombobox::GetCurSel(evt.hCtrl); |
| | | if (h > -1) |
| | | { |
| | | xstring txt = xcombobox::GetLBText(evt.hCtrl, h); |
| | | if (txt == L"åºè¿æ¥æ") |
| | | { |
| | | apType = L"000"; |
| | | DatePicker = L"GDNDate"; |
| | | OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | else if (txt == L"è¯·æ¬¾æ¥æ") |
| | | { |
| | | apType = L"000"; |
| | | DatePicker = L"APDate"; |
| | | OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | else if (txt == L"仿¬¾æ¥æ") |
| | | { |
| | | apType = L"000"; |
| | | DatePicker = L"PayedDate"; |
| | | OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | } |
| | | } |
| | | else if (payTypeTwo == L"é¢ä»è´§æ¬¾") |
| | | { |
| | | int h1 = xcombobox::GetCurSel(evt.hCtrl); |
| | | if (h1 > -1) |
| | | { |
| | | xstring txt1 = xcombobox::GetLBText(evt.hCtrl, h1); |
| | | if (txt1 == L"åºè¿æ¥æ") |
| | | { |
| | | apType = L"001"; |
| | | DatePicker = L"GDNDate"; |
| | | OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | else if (txt1 == L"è¯·æ¬¾æ¥æ") |
| | | { |
| | | apType = L"001"; |
| | | DatePicker = L"APDate"; |
| | | OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | else if (txt1 == L"仿¬¾æ¥æ") |
| | | { |
| | | apType = L"001"; |
| | | DatePicker = L"PayedDate"; |
| | | OnRetrieveEx(apType, DatePicker); |
| | | } |
| | | } |
| | | } |
| | | else if (payTypeTwo == L"é¢ä»è´§æ¬¾(å·²å²)L") |
| | | { |
| | | int h2 = xcombobox::GetCurSel(evt.hCtrl); |
| | | if (h2 > -1) |
| | | { |
| | | xstring txt2 = xcombobox::GetLBText(evt.hCtrl, h2); |
| | | if (txt2 == L"åºè¿æ¥æ") |
| | | { |
| | | apType = L"001"; |
| | | DatePickerOne = L"GDNDate"; |
| | | OnRetrieveEx1(apType, DatePickerOne); |
| | | } |
| | | else if (txt2 == L"è¯·æ¬¾æ¥æ") |
| | | { |
| | | apType = L"001"; |
| | | DatePickerOne = L"APDate"; |
| | | OnRetrieveEx1(apType, DatePickerOne); |
| | | } |
| | | else if (txt2 == L"仿¬¾æ¥æ") |
| | | { |
| | | apType = L"001"; |
| | | DatePickerOne = L"PayedDate"; |
| | | OnRetrieveEx1(apType, DatePickerOne); |
| | | } |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnSave() |
| | | { |
| | | xml x ; |
| | | |
| | | dw_list.DwUpdateAllToEx(x); |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"content", x.xml()); |
| | | //trace(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_list.ResetUpdateStatus(); |
| | | alert(L"ä¿åæå!"); |
| | | } |
| | | else |
| | | { |
| | | alert(L"ä¿å失败!"); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnRetrieveEx1(xstring APType, xstring DatePickerOne) |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"QueryTxt", GetControl(L"sle_search").GetText()); |
| | | arg.AddArg(L"APType", APType); |
| | | arg.AddArg(L"QueryArg", GetQueryArg()); |
| | | arg.AddArg(L"DatePicker", DatePickerOne); |
| | | |
| | | trace(GetQueryArg()); |
| | | if (getUrl(L"/sale/data/AP/list9", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_list.Retrieve(x); |
| | | dw_list.Redraw(); |
| | | dw_list.SetReadOnly(true); |
| | | dw_list.SetSelectionMode(1); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | xstring GetQueryArg() |
| | | { |
| | | dw_arg.AcceptText(); |
| | | xml x ; |
| | | |
| | | dw_arg.DwUpdateAllTo(x); |
| | | |
| | | return x.xml(); |
| | | } |
| | | |
| | | int OnRetrieveEx(xstring APType, xstring DatePicker) |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"QueryTxt", GetControl(L"sle_search").GetText()); |
| | | arg.AddArg(L"APType", APType); |
| | | arg.AddArg(L"QueryArg", GetQueryArg()); |
| | | arg.AddArg(L"DatePicker", DatePicker); |
| | | |
| | | trace(GetQueryArg()); |
| | | if (getUrl(L"/sale/data/AP/list", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | //trace(L"xml=L"+x.xml); |
| | | dw_list.Retrieve(x); |
| | | dw_list.Redraw(); |
| | | //dw_list.SetReadOnly(true); |
| | | dw_list.SetSelectionMode(1); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnAnalysis() |
| | | { |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | xstring str = dw_list.DataAnalysis(L""); |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"html", str); |
| | | int obj = cast(dw_list as int); |
| | | arg.AddArg(L"obj", obj.toString()); |
| | | OpenWindow(L"dev:xpage[data.vanalysis.vx]", arg); |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.openUrl(L"/sale/view/AP/template/AP/list1"); |
| | | dw_list.SetColumnState(L"APID", false); |
| | | dw_list.SetColumnState(L"SupplierID", false); |
| | | dw_list.SetColumnState(L"VATNo", 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"æ¬æ"); |
| | | |
| | | OnAttachEvent(); |
| | | apType = L"000"; |
| | | OnRetrieveEx(apType, DatePicker); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | |
| | | return 1; |
| | | } |
| | | }; |