| ¶Ô±ÈÐÂÎļþ |
| | |
| | | #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) UpdateVatNotifyWin : public xframe |
| | | { |
| | | public: |
| | | xdwgrid dw_list; |
| | | xdwgrid dw_item; |
| | | xdwgrid dw_goods; |
| | | xnode m_agentNode; //Agent Condition |
| | | |
| | | public: |
| | | UpdateVatNotifyWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static UpdateVatNotifyWin* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | UpdateVatNotifyWin* pWin = new UpdateVatNotifyWin(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() |
| | | { |
| | | xml x ; |
| | | |
| | | dw_list.AcceptText(); |
| | | dw_list.DwUpdateAllToEx(x); |
| | | xaserverarg arg = ViewObject::MakeArg(); |
| | | arg.AddArg(L"content", x.xml()); |
| | | |
| | | trace(x.xml()); |
| | | //return 1; |
| | | if (xurl::get(L"/sale/data/VATNotify/base/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 OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid == L"xmReplaceRow") |
| | | { |
| | | return OnReplaceRow(); |
| | | } |
| | | if (comdid == L"xmReplaceSupplier") |
| | | { |
| | | return OnReplaceSupplier(); |
| | | } |
| | | else if (comdid == L"xmAddRow") |
| | | { |
| | | return OnAddRow(); |
| | | } |
| | | else if (comdid == L"xmSave") |
| | | { |
| | | return OnSave(); |
| | | } |
| | | else if (comdid == L"xmDeleteRow") |
| | | { |
| | | return OnDeleteRow(); |
| | | } |
| | | if (comdid == L"xmClose") |
| | | { |
| | | CloseWindow(); |
| | | return 1; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | int OnDeleteRow() |
| | | { |
| | | if (dw_list.GetRowCount() == dw_item.GetRowCount()) |
| | | { |
| | | int res = MessageBox(GetHWND(), L"ä½ å¯ä»¥ç¨æ¿æ¢å®æç¸åºçæä½ï¼è¿ç»§ç»å é¤å?", L"æç¤º", 4); |
| | | if (res != 6) return 1; |
| | | } |
| | | else |
| | | { |
| | | int res1 = MessageBox(GetHWND(), L"确认å é¤å¯¹åºçè¡?", L"æç¤º", 4); |
| | | if (res1 != 6) return 1; |
| | | } |
| | | dw_list.DeleteRow(0); |
| | | dw_list.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnAddRow() |
| | | { |
| | | if (dw_item.GetRow() < 1) return 1; |
| | | int ll_row1 = dw_item.GetRow(); |
| | | dw_list.InsertRow(0); |
| | | int ll_row = dw_list.GetRowCount(); |
| | | |
| | | KXMLDOMElement e = dw_item.GetRowElement(ll_row1); |
| | | dw_list.SetItemString(ll_row, L"SupplierID", dw_item.GetItemString(ll_row1, L"SupplierID")); |
| | | dw_list.SetItemDisplayString(ll_row, L"SupplierID", dw_item.GetItemDisplayString(ll_row1, L"SupplierID")); |
| | | dw_list.SetItemString(ll_row, L"CQuantity", dw_item.GetItemString(ll_row1, L"CustQuantity")); |
| | | dw_list.SetItemString(ll_row, L"Amount", dw_item.GetItemString(ll_row1, L"Amount")); |
| | | dw_list.SetItemString(ll_row, L"ClassifyID", dw_item.GetItemString(ll_row1, L"ClassifyID")); |
| | | dw_list.SetItemDisplayString(ll_row, L"ClassifyID", dw_item.GetItemDisplayString(ll_row1, L"ClassifyID")); |
| | | dw_list.SetItemString(ll_row, L"CName", dw_item.GetItemDisplayString(ll_row1, L"ClassifyID")); |
| | | if (e.selectSingleNode(L"Quantity")) dw_list.SetItemString(ll_row, L"Quantity", e.selectSingleNode(L"Quantity").text()); |
| | | if (e.selectSingleNode(L"CreatorID")) dw_list.SetItemString(ll_row, L"CreatorID", e.selectSingleNode(L"CreatorID").text()); |
| | | if (e.selectSingleNode(L"CreateDate")) dw_list.SetItemString(ll_row, L"CreateDate", e.selectSingleNode(L"CreateDate").text()); |
| | | if (e.selectSingleNode(L"ModifierID")) dw_list.SetItemString(ll_row, L"ModifierID", e.selectSingleNode(L"ModifierID").text()); |
| | | if (e.selectSingleNode(L"ModifyDate")) dw_list.SetItemString(ll_row, L"ModifyDate", e.selectSingleNode(L"ModifyDate").text()); |
| | | if (e.selectSingleNode(L"VATRate")) dw_list.SetItemString(ll_row, L"VATRate", e.selectSingleNode(L"VATRate").text()); |
| | | if (e.selectSingleNode(L"VATRefundRate")) dw_list.SetItemString(ll_row, L"VATRefundRate", e.selectSingleNode(L"VATRefundRate").text()); |
| | | if (e.selectSingleNode(L"CustomUOM")) dw_list.SetItemString(ll_row, L"CQtyUnit", e.selectSingleNode(L"CustomUOM").text()); |
| | | if (e.selectSingleNode(L"IsFinish")) dw_list.SetItemString(ll_row, L"IsFinish", e.selectSingleNode(L"IsFinish").text()); |
| | | if (e.selectSingleNode(L"Type")) dw_list.SetItemString(ll_row, L"Type", e.selectSingleNode(L"Type").text()); |
| | | if (e.selectSingleNode(L"InvoiceNo")) dw_list.SetItemString(ll_row, L"InvoiceNo", e.selectSingleNode(L"InvoiceNo").text()); |
| | | dw_list.Redraw(); |
| | | dw_item.SetItemString(ll_row1, L"Relation", xstring(ll_row)); |
| | | dw_item.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnReplaceSupplier() |
| | | { |
| | | int ll_row = dw_list.GetRow(); |
| | | int ll_row1 = dw_item.GetRow(); |
| | | |
| | | if (ll_row < 1 || ll_row1 < 1) |
| | | { |
| | | alert(L"没ææä½!"); |
| | | return 1; |
| | | } |
| | | xstring SupplierID1 = dw_item.GetItemString(ll_row1, L"SupplierID"); |
| | | dw_list.SetItemString(ll_row, L"SupplierID", SupplierID1); |
| | | dw_list.SetItemDisplayString(ll_row, L"SupplierID", dw_item.GetItemDisplayString(ll_row1, L"SupplierID")); |
| | | dw_list.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnReplaceRow() |
| | | { |
| | | int ll_row = dw_list.GetRow(); |
| | | int ll_row1 = dw_item.GetRow(); |
| | | if (ll_row < 1 || ll_row1 < 1) |
| | | { |
| | | alert(L"没ææä½!"); |
| | | return 1; |
| | | } |
| | | |
| | | bool updateSupplier = false; |
| | | bool updatePrice = false; |
| | | bool updateClassifyID = false; |
| | | xstring SupplierID = dw_list.GetItemString(ll_row, L"SupplierID"); |
| | | xstring CQuantity = dw_list.GetItemString(ll_row, L"CQuantity"); |
| | | xstring Amount = dw_list.GetItemString(ll_row, L"Amount"); |
| | | xstring ClassifyID = dw_list.GetItemString(ll_row, L"ClassifyID"); |
| | | |
| | | xstring SupplierID1 = dw_item.GetItemString(ll_row1, L"SupplierID"); |
| | | xstring CQuantity1 = dw_item.GetItemString(ll_row1, L"CustQuantity"); |
| | | xstring Amount1 = dw_item.GetItemString(ll_row1, L"Amount"); |
| | | xstring ClassifyID1 = dw_item.GetItemString(ll_row1, L"ClassifyID"); |
| | | |
| | | if (SupplierID != SupplierID1) updateSupplier = true; |
| | | if (CQuantity != CQuantity1) updatePrice = true; |
| | | if (Amount != Amount1) updatePrice = true; |
| | | if (ClassifyID != ClassifyID1) updateClassifyID = true; |
| | | |
| | | if (updateSupplier && updatePrice && updateClassifyID) |
| | | { |
| | | int res = MessageBox(GetHWND(), L"ä¸ä¸æ°æ®æ¥å
³ååãä»·æ ¼ãå·¥åå
¨ä¸ä¸è´ï¼æ¯å¦è¦å¼ºå¶æ¿æ¢?", L"æç¤º", 4); |
| | | if (res != 6) return 1; |
| | | } |
| | | if (updateSupplier) |
| | | { |
| | | dw_list.SetItemString(ll_row, L"SupplierID", SupplierID1); |
| | | dw_list.SetItemDisplayString(ll_row, L"SupplierID", dw_item.GetItemDisplayString(ll_row1, L"SupplierID")); |
| | | } |
| | | if (updatePrice) |
| | | { |
| | | dw_list.SetItemString(ll_row, L"CQuantity", CQuantity1); |
| | | dw_list.SetItemString(ll_row, L"Amount", Amount1); |
| | | } |
| | | if (updateClassifyID) |
| | | { |
| | | dw_list.SetItemString(ll_row, L"ClassifyID", ClassifyID); |
| | | dw_list.SetItemDisplayString(ll_row, L"ClassifyID", dw_item.GetItemDisplayString(ll_row1, L"ClassifyID")); |
| | | dw_list.SetItemString(ll_row, L"CName", dw_item.GetItemDisplayString(ll_row1, L"ClassifyID")); |
| | | } |
| | | dw_list.Redraw(); |
| | | dw_item.SetItemString(ll_row1, L"Relation",xstring(ll_row)); |
| | | dw_item.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | //å½ä»¤å¤çäºä»¶ |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //ç»å®å·¥å
·æ¡ç¹å»äºä»¶ |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&UpdateVatNotifyWin::OnXCommand); |
| | | //è·åç¦ç¹äºä»¶ï¼ç¨äºé置工å
·æ¡ |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&UpdateVatNotifyWin::OnSetFocus); |
| | | AttachEvent(L"dw_item", L"DWV_ROWFOCUSCHANGED", (FEvent)&UpdateVatNotifyWin::OnRowChanged); |
| | | return 1; |
| | | } |
| | | |
| | | int RetrieveCustomSource(xstring classifyID, xstring supplierID) |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg ; |
| | | |
| | | if (GetWinParam()) |
| | | { |
| | | int pArg = GetArg(); |
| | | |
| | | } |
| | | else |
| | | arg.AddArg(L"invoiceno", L"15HDLD0720"); |
| | | |
| | | arg.AddArg(L"ClassifyID", classifyID); |
| | | arg.AddArg(L"SupplierID", supplierID); |
| | | if (getUrl(L"/sale/data/VATNotify/pref/CustomSource", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_goods.Retrieve(x); |
| | | dw_goods.Redraw(); |
| | | } |
| | | } |
| | | |
| | | int OnRowChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | |
| | | if (row < 1) return 1; |
| | | KXMLDOMElement e = dw_item.GetRowElement(row); |
| | | xstring classifyID = e.selectSingleNode(L"ClassifyID").text(); |
| | | xstring supplierID = e.selectSingleNode(L"SupplierID").text(); |
| | | e.Release(); |
| | | RetrieveCustomSource(classifyID, supplierID); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnRetrieve() |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | if (GetWinParam()) |
| | | { |
| | | int pArg = GetArg(); |
| | | |
| | | } |
| | | else |
| | | arg.AddArg(L"invoiceno", L"15HDLD0720"); |
| | | if (getUrl(L"/sale/data/VATNotify/entity/base/miss", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | //return -1; |
| | | } |
| | | else |
| | | { |
| | | //alert(x.xml); |
| | | dw_list.Retrieve(x); |
| | | dw_list.Redraw(); |
| | | } |
| | | |
| | | if (getUrl(L"/sale/data/VATNotify/pref/GdnInvoice", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_item.Retrieve(x); |
| | | dw_item.Redraw(); |
| | | dw_item.SetReadOnly(true); |
| | | if (dw_item.GetRowCount() > 0) |
| | | { |
| | | KXMLDOMElement e = dw_item.GetRowElement(1); |
| | | xstring classifyID = e.selectSingleNode(L"ClassifyID").text(); |
| | | xstring supplierID = e.selectSingleNode(L"SupplierID").text(); |
| | | e.Release(); |
| | | trace(L"!" + classifyID + L" " + supplierID); |
| | | RetrieveCustomSource(classifyID, supplierID); |
| | | } |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.openUrl(L"/sale/view/VATNotify/template/VATNotify/item"); |
| | | dw_item = GetControl(L"dw_item"); |
| | | dw_item.openUrl(L"/sale/view/VATNotify/template/VATNotify/DItem"); |
| | | dw_goods = GetControl(L"dw_goods"); |
| | | dw_goods.openUrl(L"/sale/view/VATNotify/template/VATNotify/DItem1"); |
| | | |
| | | |
| | | OnRetrieve(); |
| | | OnAttachEvent(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | //SetAgent(); |
| | | |
| | | return 1; |
| | | } |
| | | }; |