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/AP/list.ap.cpp |  515 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 515 insertions(+), 0 deletions(-)

diff --git a/jrj/project/business/AP/list.ap.cpp b/jrj/project/business/AP/list.ap.cpp
new file mode 100644
index 0000000..9792b26
--- /dev/null
+++ b/jrj/project/business/AP/list.ap.cpp
@@ -0,0 +1,515 @@
+#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;
+		}
+	};

--
Gitblit v1.9.3