From 6e93e717799723de98287f5a036ab34367bd08cd Mon Sep 17 00:00:00 2001
From: xj qian <qianxj15@sina.com>
Date: 星期五, 05 七月 2024 17:15:44 +0800
Subject: [PATCH] update some
---
jrj/project/business/VATNotify/update.vatnotify.cpp | 366 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 366 insertions(+), 0 deletions(-)
diff --git a/jrj/project/business/VATNotify/update.vatnotify.cpp b/jrj/project/business/VATNotify/update.vatnotify.cpp
new file mode 100644
index 0000000..9ed58ae
--- /dev/null
+++ b/jrj/project/business/VATNotify/update.vatnotify.cpp
@@ -0,0 +1,366 @@
+#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;
+ }
+ };
--
Gitblit v1.9.3