¶Ô±ÈÐÂÎļþ |
| | |
| | | #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) ExchangeInputView : public xframe |
| | | { |
| | | public: |
| | | xdwgrid dw_list; |
| | | xdwgrid dw_signed; |
| | | xdwgrid dw_unexch; |
| | | xdwgrid dw_exch; |
| | | xdwgrid dw_adjust; |
| | | xdwtable dw_arg; |
| | | xnode m_agentNode; //Agent Condition |
| | | xstring tabname; |
| | | xstring tabagent; |
| | | int hSignWin; |
| | | |
| | | ///sale/data/AR/list |
| | | public: |
| | | ExchangeInputView(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static ExchangeInputView* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | ExchangeInputView* pWin = new ExchangeInputView(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | int SetAgent() |
| | | { |
| | | xstring xfNodeAgentArea = L"agentarea"; |
| | | xnode anode = GetAgentNode(xfNodeAgentArea); |
| | | if (tabagent == tabname && m_agentNode) |
| | | { |
| | | SetAgentNode(anode, m_agentNode); |
| | | } |
| | | else |
| | | { |
| | | tabagent = tabname; |
| | | KXMLDOMElement xframeElement = GetElement(); |
| | | KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[@id='" + tabname + L"']/*"); |
| | | if (agent) |
| | | { |
| | | xstring s = agent.xml(); |
| | | m_agentNode = SetAgentNode(anode, s); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnSaveEx() |
| | | { |
| | | xml x; |
| | | |
| | | dw_adjust.AcceptText(); |
| | | dw_adjust.DwUpdateAllToEx(x); |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"content", x.xml()); |
| | | |
| | | //trace(x.xml()); |
| | | if (xurl::get(L"/sale/data/AR/update/item", 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_adjust.ResetUpdateStatus(); |
| | | alert(L"ä¿åæå!"); |
| | | } |
| | | else |
| | | { |
| | | alert(L"ä¿å失败!"); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnSave() |
| | | { |
| | | xml x; |
| | | |
| | | dw_list.AcceptText(); |
| | | dw_list.DwUpdateAllToEx(x); |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"content", x.xml()); |
| | | |
| | | //trace(x.xml()); |
| | | if (xurl::get(L"/sale/data/AR/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 OnSetFocus(TEvent* evt, LPARAM param) |
| | | { |
| | | //é置工å
·æ¡ |
| | | SetAgent(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnDeleteRow() |
| | | { |
| | | dw_list.DeleteRow(0); |
| | | return 1; |
| | | } |
| | | |
| | | int OnInsertRow() |
| | | { |
| | | int row = dw_list.InsertRow(0); |
| | | xstring sdate = publiccode::GetCurrentDate(); |
| | | dw_list.SetItemString(row, L"CreateDate", sdate); |
| | | dw_list.SetItemString(row, L"SEDate", sdate); |
| | | dw_list.SetItemString(row, L"CurrencyCode", L"USD"); |
| | | xstring suserid = publiccode::GetUser().id; |
| | | xstring susername = publiccode::GetUser().name; |
| | | dw_list.SetItemString(row, L"CreatorID", suserid); |
| | | dw_list.SetItemDisplayString(row, L"CreatorID", susername); |
| | | |
| | | if (row > 1) |
| | | { |
| | | xstring exchrate = dw_list.GetItemString(row - 1, L"ExchRate"); |
| | | if (exchrate != L"") dw_list.SetItemString(row, L"ExchRate", exchrate); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnSign() |
| | | { |
| | | OpenWindow(L"dev:xpage[ExchangeSignFast.vx]", cast(dw_list as int)); |
| | | return 1; |
| | | } |
| | | |
| | | int OnCustomerEx() |
| | | { |
| | | xml xc; |
| | | |
| | | if (getUrl(L"/sale/data/AR/tran/customer", L"", xc) != 1) |
| | | { |
| | | trace(xc.text()); |
| | | return -1; |
| | | } |
| | | KXMLDOMDocument xdoc = xc; |
| | | if (xdoc) |
| | | { |
| | | for (int row = 1; row <= dw_list.GetRowCount(); ++row) |
| | | { |
| | | xstring val = dw_list.GetItemString(row, L"Customer"); |
| | | KXMLDOMNode n1 = xdoc.selectSingleNode(L"/data/Item[contains(\"" + val + L"\",RawColumn)]"); |
| | | if (n1) |
| | | { |
| | | dw_list.SetItemString(row, L"CustomerID", n1.selectSingleNode(L"DataColumn").text()); |
| | | dw_list.SetItemDisplayString(row, L"CustomerID", n1.selectSingleNode(L"DataColumn/@_displaystring").text()); |
| | | } |
| | | } |
| | | } |
| | | dw_list.Redraw(); |
| | | OnSave(); |
| | | //alert(L"é对åºå®æ!"); |
| | | return 1; |
| | | } |
| | | |
| | | int OnImprt() |
| | | { |
| | | xaserverarg args ; |
| | | |
| | | args.AddArg(L"src", L"data/SettleExchange"); |
| | | args.AddArg(L"process", L"data"); |
| | | OpenWindow(L"dev:xpage[trade.document.selectdlg.vx]",args); |
| | | return 1; |
| | | } |
| | | |
| | | int RetrieveData() |
| | | { |
| | | if (tabname == L"sign") return OnRetrieve(L"/sale/data/AR/list", dw_list); |
| | | if (tabname == L"signed") return OnRetrieve(L"/sale/data/AR/listFinish", dw_signed); |
| | | if (tabname == L"exch") return OnRetrieve(L"/sale/data/AR/gdn/exch/list", dw_exch); |
| | | if (tabname == L"unexch") return OnRetrieve(L"/sale/data/AR/gdn/noexch/list", dw_unexch); |
| | | if (tabname == L"adjust") return OnRetrieve(L"/sale/data/AR/Adjust", dw_adjust); |
| | | return 1; |
| | | } |
| | | |
| | | //å½ä»¤åå¸å½æ° |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid == L"xmAddRow") |
| | | { |
| | | return OnInsertRow(); |
| | | } |
| | | else if (comdid == L"xmImportRow") |
| | | { |
| | | return OnImprt(); |
| | | } |
| | | else if (comdid == L"xmCustomerEx") |
| | | { |
| | | return OnCustomerEx(); |
| | | } |
| | | else if (comdid == L"xmDeleteRow") |
| | | { |
| | | return OnDeleteRow(); |
| | | } |
| | | else if (comdid == L"xmDelete") |
| | | { |
| | | int MB_OKCANCEL = 1; |
| | | int IDOK = 1; |
| | | int ret = MessageBox(GetHWND(), L"确认æ¯å¦å é¤?", L"æç¤º", MB_OKCANCEL); |
| | | if (ret == IDOK) |
| | | { |
| | | ViewObject::RetrieveData(L"/sale/data/expense3/delete/SettlementExchange", L"EntityID", dw_list.GetGuid(dw_list.GetRow())); |
| | | OnRetrieve(L"/sale/data/AR/list", dw_list); |
| | | } |
| | | } |
| | | else if (comdid == L"xmDeleteRowEx") |
| | | { |
| | | /*int len = dw_adjust.GetRowCount(); |
| | | for(int i = 0; i< len ; i++) |
| | | { |
| | | dw_adjust.DeleteRow(0); |
| | | } |
| | | alert(L"end");*/ |
| | | dw_adjust.DeleteRow(0); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmAddRowEx") |
| | | { |
| | | /*int row = dw_signed.GetRowCount(); |
| | | for(int i = 1;i < dw_signed.GetRowCount();i++) |
| | | { |
| | | double BalanceAmt=dw_signed.GetItemDouble(i,L"BalanceAmt"); |
| | | double DraftAmount=dw_signed.GetItemDouble(i,L"DraftAmount"); |
| | | xstring Remark = dw_signed.GetItemString(i,L"Remark"); |
| | | if(BalanceAmt != 0.00) |
| | | { |
| | | int row1 = dw_adjust.InsertRow(0); |
| | | xstring InvoiceNo = dw_signed.GetItemString(i,L"InvoiceNo"); |
| | | dw_adjust.SetItemString(row1,L"InvoiceNo",InvoiceNo); |
| | | dw_adjust.SetItemDouble(row1,L"Amount",BalanceAmt); |
| | | dw_adjust.SetItemDouble(row1,L"åºç»æ±ç¾å
éé¢",DraftAmount); |
| | | dw_adjust.SetItemDouble(row1,L"åºæ¶æ±éé¢",DraftAmount); |
| | | dw_adjust.SetItemString(row1,L"Note",Remark); |
| | | } |
| | | } |
| | | alert(L"end");*/ |
| | | dw_adjust.InsertRow(1); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmClient") |
| | | { |
| | | OpenWindow(L"dev:xpage[CustomerTran.AR.vx]"); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmExchangeFile") |
| | | { |
| | | //if(iswindow(hSignWin) & 0x1) return 1; |
| | | xwin xw = OpenWindow(L"dev:xpage[ExchageFile.vx]", 0); |
| | | hSignWin = xw.GetHWND(); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmRefresh") |
| | | { |
| | | |
| | | return RetrieveData(); |
| | | } |
| | | else if (comdid == L"xmSave") |
| | | { |
| | | return OnSave(); |
| | | } |
| | | else if (comdid == L"xmSaveEx") |
| | | { |
| | | return OnSaveEx(); |
| | | } |
| | | else if (comdid == L"xmSign") |
| | | { |
| | | return OnSign(); |
| | | } |
| | | else if (comdid.find(L"xmSignEx") >= 0) |
| | | { |
| | | xstring id = comdid.mid(comdid.find(L":") + 1, 9999); |
| | | trace(L"----\r\n" + id); |
| | | int frow = 0; |
| | | for (frow = 1; frow <= dw_list.GetRowCount(); frow++) |
| | | { |
| | | if (frow == 1) |
| | | trace(L"----\r\n" + dw_list.GetGuid(frow)); |
| | | if (id == dw_list.GetGuid(frow)) break; |
| | | } |
| | | if (frow > dw_list.GetRowCount()) return 1; |
| | | dw_list.SetRow(frow); |
| | | OpenWindow(L"dev:xpage[ExchangeSignFast.vx]", cast(dw_list as int)); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmAdd") |
| | | { |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"HWND", GetHWND()); |
| | | |
| | | OpenWindow(L"dev:xpage[maint.SettlementExchange.vx]", arg); |
| | | } |
| | | else if (comdid == L"xmEdit") |
| | | { |
| | | xaserverarg arg1 ; |
| | | |
| | | arg1.AddArg(L"HWND", GetHWND().toString()); |
| | | arg1.AddArg(L"SettlementExchangeID", dw_list.GetGuid(dw_list.GetRow())); |
| | | |
| | | OpenWindow(L"dev:xpage[maint.SettlementExchange.vx]", arg1); |
| | | } |
| | | else if (comdid == L"Deduction") |
| | | { |
| | | int row = dw_adjust.GetRow(); |
| | | if (row < 1) |
| | | return 1; |
| | | xstring InvoiceNoExs = dw_adjust.GetItemString(row, L"InvoiceNo"); |
| | | if (InvoiceNoExs != L"") |
| | | { |
| | | xaserverarg argEx ; |
| | | |
| | | argEx.AddArg(L"EntityID", dw_adjust.GetGuid(row)); |
| | | argEx.AddArg(L"InvoiceNo", InvoiceNoExs); |
| | | trace(dw_adjust.GetGuid(row) + InvoiceNoExs); |
| | | OpenWindow(L"dev:xpage[Deduction.vx]", argEx); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | alert(L"å¤è¿ç¼å·ä¸ºç©ºï¼æ æ³åé
ï¼"); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | int OnCombboChanged(ref TCommandEvent evt, int lParam) |
| | | { |
| | | xstring id = L""; |
| | | xstring name = L""; |
| | | int h = xcombobox::GetCurSel(evt.hCtrl); |
| | | if (h > -1) |
| | | { |
| | | tabname = xcombobox::GetItemData(evt.hCtrl, h); |
| | | SwitchLayer(L"sheet" + (h + 1).toString(), L"frame"); |
| | | RetrieveData(); |
| | | SetAgent(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //å½ä»¤å¤çäºä»¶ |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnBaseItemChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | xstring colname = hdr.colname; |
| | | xstring value = hdr.data; |
| | | |
| | | xstring dwname = L"dw_adjust"; |
| | | if (value != L"") |
| | | { |
| | | KXMLDOMNodeList nlist = GetElement().selectNodes(L"//*[@name='" + dwname + L"']/trans[@for='" + colname + L"']"); |
| | | ViewObject::TransData(nlist, dw_adjust, hdr.row, colname, value); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | int OnDoubleClicked(TEvent* evt, LPARAM p) |
| | | { |
| | | return OnCmdDispatch(L"xmEdit"); |
| | | } |
| | | |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //ç»å®å·¥å
·æ¡ç¹å»äºä»¶ |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&ExchangeInputView::OnXCommand); |
| | | //è·åç¦ç¹äºä»¶ï¼ç¨äºé置工å
·æ¡ |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&ExchangeInputView::OnSetFocus); |
| | | AttachEvent(L"cbx_type", L"CBN_SELCHANGE", (FEvent)&ExchangeInputView::OnCombboChanged);//屿§ç»åæ¢listä¸åçæ°éåå |
| | | AttachEvent(L"dw_adjust", L"DWV_ITEMCHANGED", (FEvent)&ExchangeInputView::OnBaseItemChanged); |
| | | AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&ExchangeInputView::OnDoubleClicked);//è¡åå» |
| | | return 1; |
| | | |
| | | } |
| | | |
| | | xstring GetQueryArg() |
| | | { |
| | | dw_arg.AcceptText(); |
| | | xml x; |
| | | |
| | | dw_arg.DwUpdateAllTo(x); |
| | | trace(x.text()); |
| | | return x.xml(); |
| | | } |
| | | |
| | | int OnRetrieve(xstring dataUrl, xdwgrid dw_obj) |
| | | { |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | xml x; |
| | | |
| | | xaserverarg arg ; |
| | | |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg(L"QueryTxt", GetControl(L"sle_search").GetText()); |
| | | arg.AddArg(L"QueryArg", GetQueryArg()); |
| | | //trace(L"QueryArg======L"+GetQueryArg()); |
| | | if (getUrl(dataUrl, arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | xutil::RestoreCursor(hCursor); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | //trace(x.xml()); |
| | | dw_obj.Retrieve(x); |
| | | dw_obj.Redraw(); |
| | | } |
| | | //dw_obj.SetReadOnly(false); |
| | | dw_obj.SetSelectionMode(1); |
| | | xutil::RestoreCursor(hCursor); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.openUrl(L"/sale/view/AR/template/list"); |
| | | |
| | | |
| | | dw_signed = GetControl(L"dw_signed"); |
| | | dw_signed.openUrl(L"/sale/view/AR/template/listFinish"); |
| | | dw_exch = GetControl(L"dw_exch"); |
| | | dw_exch.openUrl(L"/sale/view/AR/template/unexch"); |
| | | dw_unexch = GetControl(L"dw_unexch"); |
| | | dw_unexch.openUrl(L"/sale/view/AR/template/unexch"); |
| | | dw_adjust = GetControl(L"dw_adjust"); |
| | | dw_adjust.openUrl(L"/sale/view/AR/template/adjust"); |
| | | |
| | | dw_unexch.SetColumnState(L"SEItemID", false); |
| | | dw_unexch.SetColumnState(L"SEID", false); |
| | | dw_exch.SetColumnState(L"SEItemID", false); |
| | | dw_exch.SetColumnState(L"SEID", false); |
| | | dw_exch.SetColumnState(L"BankDeduction", false); |
| | | dw_exch.SetColumnState(L"宿¶æ±éé¢", 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); |
| | | |
| | | tabname = L"sign"; |
| | | tabagent = L""; |
| | | |
| | | OnAttachEvent(); |
| | | hSignWin = 0; |
| | | RetrieveData(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | |
| | | return 1; |
| | | } |
| | | }; |