¶Ô±ÈÐÂÎļþ |
| | |
| | | #include <wobject/xstring.hpp> |
| | | #include <xcontrol/xtreeview.hpp> |
| | | #include <xcontrol/xdwgrid.hpp> |
| | | #include <wobject/xdouble.hpp> |
| | | |
| | | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" |
| | | #include "viewobject/view.base.hpp" |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | class __declspec(dllexport) SettlementExchangeEdit : public xframe |
| | | { |
| | | public: |
| | | xdwtable dw_base; |
| | | |
| | | xnode m_agentNode; //Agent Condition |
| | | HWND hObject; |
| | | bool updated; |
| | | |
| | | public: |
| | | SettlementExchangeEdit(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static SettlementExchangeEdit* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | SettlementExchangeEdit* pWin = new SettlementExchangeEdit(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 OnSave(bool dlg = true) |
| | | { |
| | | xml x; |
| | | |
| | | dw_base.AcceptText(); |
| | | dw_base.DwUpdateAllTo(x); |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"content", x.xml()); |
| | | //alert(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_base.ResetUpdateStatus(); |
| | | dw_base.Redraw(); |
| | | updated = true; |
| | | if (dlg)alert(L"ä¿åæå!"); |
| | | |
| | | //SendMessage(hObject,0x401,L"xmSignEx:"+dw_base.GetGuid(1),0); |
| | | SendMessage(hObject, 0x401, (LPARAM)L"xmRefresh", 0); |
| | | //CloseWindow(); |
| | | } |
| | | else |
| | | { |
| | | alert(L"ä¿å失败!"); |
| | | return -1; |
| | | } |
| | | return 1; |
| | | } |
| | | //å½ä»¤åå¸å½æ° |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid == L"xmClose") |
| | | { |
| | | if (updated) |
| | | SendMessage(hObject, 0x401, (LPARAM)L"xmRefresh", 0); |
| | | CloseWindow(); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmSave") |
| | | { |
| | | OnSave(); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmSign") |
| | | { |
| | | return OnSign(); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int OnSign() |
| | | { |
| | | xaserverarg arg ; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | |
| | | xml x; |
| | | |
| | | dw_base.AcceptText(); |
| | | dw_base.DwUpdateAllTo(x); |
| | | if (x.selectSingleNode(L"//*[@update.modify='1']")) |
| | | if (OnSave(false) == -1) return 1; |
| | | |
| | | if (dw_base.GetGuid(1) == L"") |
| | | { |
| | | alert(L"请å
ä¿åï¼å¨ç¾æ¶ï¼"); |
| | | return 1; |
| | | } |
| | | |
| | | OnRetrieve(dw_base.GetGuid(1)); |
| | | |
| | | if (dw_base.GetItemString(1, L"CustomerID") == L"") |
| | | { |
| | | alert(L"客æ·ä¸å
许æªç©ºï¼"); |
| | | return 1; |
| | | } |
| | | arg.AddArg(L"CustomerID", dw_base.GetItemString(1, L"CustomerID")); |
| | | arg.AddArg(L"SEID", dw_base.GetGuid(1)); |
| | | SendMessage(hObject, 0x401, L"xmSignEx:" + dw_base.GetGuid(1), 0); |
| | | return 1; |
| | | } |
| | | |
| | | int OnItemChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | xstring colname = hdr.colname; |
| | | xstring value = hdr.data; |
| | | |
| | | xstring dwname = L"dw_base"; |
| | | |
| | | if (colname == L"Amount" || colname == L"ForeignBankDeduction" || colname == L"BankDeduction" || colname == L"BankRMBDeduction") |
| | | { |
| | | double Amount = dw_base.GetItemDouble(hdr.row, L"Amount"); |
| | | double ForeignBankDeduction = dw_base.GetItemDouble(hdr.row, L"ForeignBankDeduction"); |
| | | double BankDeduction = dw_base.GetItemDouble(hdr.row, L"BankDeduction"); |
| | | double CustomerCapitalExpense = dw_base.GetItemDouble(hdr.row, L"CustomerCapitalExpense"); |
| | | double PressureExchangeRate = dw_base.GetItemDouble(hdr.row, L"PressureExchangeRate"); |
| | | //double BankRMBDeduction = dw_base.GetItemDouble(hdr.row,L"BankRMBDeduction"); |
| | | dw_base.SetItemDouble(hdr.row, L"AmountEx", xdouble((Amount + ForeignBankDeduction + BankDeduction + CustomerCapitalExpense)).round(2)); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //å½ä»¤å¤çäºä»¶ |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //ç»å®å·¥å
·æ¡ç¹å»äºä»¶ |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&SettlementExchangeEdit::OnXCommand); |
| | | //è·åç¦ç¹äºä»¶ï¼ç¨äºé置工å
·æ¡ |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&SettlementExchangeEdit::OnSetFocus); |
| | | AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", (FEvent)&SettlementExchangeEdit::OnItemChanged); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | int OnRetrieve(xstring SettlementExchangeID) |
| | | { |
| | | xml x; |
| | | |
| | | xaserverarg arg ; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg(L"SEID", SettlementExchangeID); |
| | | |
| | | if (getUrl(L"/sale/data/AR/se/getsebyid", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_base.Retrieve(x); |
| | | dw_base.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | int onload() |
| | | { |
| | | dw_base = GetControl(L"dw_base"); |
| | | dw_base.openUrl(L"/sale/view/AR/template/SEMaint"); |
| | | dw_base.SetColHeaderHeight(0); |
| | | dw_base.SetRowSelectorWidth(0); |
| | | dw_base.SetHScrollState(false); |
| | | dw_base.SetVScrollState(false); |
| | | xstring SettlementExchangeID = L""; |
| | | hObject = 0; |
| | | if (GetWinParam()) |
| | | { |
| | | xaserverarg arg =GetArg(); |
| | | SettlementExchangeID = arg.GetArgString(L"SettlementExchangeID"); |
| | | hObject = arg.GetArgString(L"HWND").toInt(); |
| | | } |
| | | if (SettlementExchangeID != L"") |
| | | { |
| | | //alert(SettlementExchangeID); |
| | | OnRetrieve(SettlementExchangeID); |
| | | } |
| | | else |
| | | { |
| | | xstring suserid = publiccode::GetUser().id; |
| | | xstring susername = publiccode::GetUser().name; |
| | | xstring sdate = publiccode::GetCurrentDate(); |
| | | dw_base.SetItemString(1, L"SEDate", sdate); |
| | | dw_base.SetItemString(1, L"CreateDate", sdate); |
| | | dw_base.SetItemString(1, L"CurrencyCode", L"USD"); |
| | | dw_base.SetItemString(1, L"CreatorID", suserid); |
| | | dw_base.SetItemDisplayString(1, L"CreatorID", susername); |
| | | } |
| | | OnAttachEvent(); |
| | | updated = false; |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | |
| | | return 1; |
| | | } |
| | | }; |