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/maint.papercard.vatnotify.cpp | 792 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 792 insertions(+), 0 deletions(-)
diff --git a/jrj/project/business/VATNotify/maint.papercard.vatnotify.cpp b/jrj/project/business/VATNotify/maint.papercard.vatnotify.cpp
new file mode 100644
index 0000000..d4836ac
--- /dev/null
+++ b/jrj/project/business/VATNotify/maint.papercard.vatnotify.cpp
@@ -0,0 +1,792 @@
+#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) maintpapercardvatnotifyWin : public xframe
+ {
+ public:
+ xdwtable dw_profit;
+ xdwtable dw_arg;
+ xdwgrid dw_item;
+ xdwgrid dw_fob;
+ xstring InvNo;
+ xstring CurInvNo;
+ xnode m_agentNode; //Agent Condition
+
+ public:
+ maintpapercardvatnotifyWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
+ public:
+ static maintpapercardvatnotifyWin* CreateInstance(void* implPtr, void* hWnd)
+ {
+ maintpapercardvatnotifyWin* pWin = new maintpapercardvatnotifyWin(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 OnPrint()
+ {
+ xaserverarg& arg = *new xaserverarg;
+
+ arg.AddArg(L"EntityName", L"VATNotify", L"");
+ arg.AddArg(L"EntityID", L"", L"");
+ arg.AddArg(L"EntityNo", dw_item.GetItemString(1, L"InvoiceNo"), L"");
+
+ openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", &arg);
+ return 1;
+ }
+
+ int OnPrintItem()
+ {
+ xaserverarg& arg = *new xaserverarg;
+
+ arg.AddArg(L"EntityName", L"VATNotify", L"");
+ arg.AddArg(L"EntityID", L"", L"");
+ arg.AddArg(L"EntityNo", dw_item.GetItemString(1, L"InvoiceNo"), L"");
+
+ openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", &arg);
+ return 1;
+ }
+
+
+
+ int onebill()
+ {
+ if (!GetWinParam()) return 1;
+
+ int ll_row = dw_item.GetNextSelectRow(1);
+ if (ll_row < 1) return 1;
+
+ int MB_OKCANCEL = 1;
+ int IDOK = 1;
+ int ret = MessageBox(GetHWND(), L"确认开票吗?", L"提示", MB_OKCANCEL);
+ if (ret != IDOK) return 1;
+ dw_item.AcceptText();
+
+ xaserverarg arg;
+
+ int pArg = GetArg();
+
+
+ xstring ls_dtlno = arg.GetArgString(L"invoiceno");
+ RetrieveFob(ls_dtlno);
+ RetrieveProfit(ls_dtlno);
+ while (ll_row > 0 && ll_row <= dw_item.GetRowCount())
+ {
+ dw_item.SetItemString(ll_row, L"NInvoiceNo", ls_dtlno);
+ xstring sdate = publiccode::GetCurrentDate();
+
+ dw_item.SetItemDisplayString(ll_row, L"NClassifyID", arg.GetArgString(L"CName"));
+ dw_item.SetItemString(ll_row, L"NClassifyID", arg.GetArgString(L"ClassifyID"));
+
+ int ll_find = FobLookup(arg.GetArgString(L"ClassifyID"));
+ xstring qtyUnit1 = dw_fob.GetItemString(ll_find, L"CQtyUnit");
+ dw_item.SetItemString(ll_row, L"CQtyUnit", qtyUnit1);
+ dw_item.SetItemString(ll_row, L"VATRefundRate", dw_fob.GetItemString(ll_find, L"VATRefundRate"));
+
+ dw_item.SetItemString(ll_row, L"NotifyDate", sdate);
+ dw_item.ItemChangeTo(ll_row, L"NAmount", dw_item.GetItemString(ll_row, L"Amount"));
+ ll_row = dw_item.GetNextSelectRow(ll_row + 1);
+ }
+ dw_item.Redraw();
+ return 1;
+ }
+
+ int onebillno() {
+ /*
+ int ll_row = dw_item.GetNextSelectRow(1);
+ if(ll_row < 1) return 1;
+
+ int MB_OKCANCEL = 1;
+ int IDOK = 1;
+ int ret = win32::MessageBox(GetHWND(),L"确认不予开票吗?",L"提示",MB_OKCANCEL);
+ if(ret !=IDOK) return 1;
+ dw_item.AcceptText();
+
+ while(ll_row > 0 && ll_row <= dw_item.GetRowCount())
+ {
+ xstring ls_dtlno = dw_item.GetItemString(ll_row,L"InvoiceNo");
+ dw_item.SetItemString(ll_row,L"NInvoiceNo",L"");
+ dw_item.SetItemString(ll_row,L"NAmount",L"");
+ dw_item.SetItemString(ll_row,L"NotifyDate",L"");
+ dw_item.SetItemString(ll_row,L"NClassifyID",L"");
+ dw_item.SetItemString(ll_row,L"NName",L"");
+ dw_item.ItemChangeTo(ll_row,L"NAmount",dw_item.GetItemString(ll_row,L""));
+ dw_item.ItemChangeTo(ll_row,L"NQuantity",dw_item.GetItemString(ll_row,L""));
+ ll_row = dw_item.GetNextSelectRow(ll_row + 1);
+ }
+ dw_item.Redraw();
+ */
+
+ int ll_row = dw_item.GetNextSelectRow(1);
+ if (ll_row < 1) return 1;
+
+ int MB_OKCANCEL = 1;
+ int IDOK = 1;
+ int ret = MessageBox(GetHWND(), L"确认不予开票吗?", L"提示", MB_OKCANCEL);
+ if (ret != IDOK) return 1;
+ dw_item.AcceptText();
+
+ while (ll_row > 0 && ll_row <= dw_item.GetRowCount())
+ {
+ xstring ls_dtlno = dw_item.GetItemString(ll_row, L"InvoiceNo");
+ dw_item.ItemChangeTo(ll_row, L"NAmount", dw_item.GetItemString(ll_row, L""));
+ dw_item.ItemChangeTo(ll_row, L"NQuantity", dw_item.GetItemString(ll_row, L""));
+ dw_item.SetItemString(ll_row, L"NotifyDate", L"");
+ dw_item.SetItemString(ll_row, L"NClassifyID", L"");
+ dw_item.SetItemString(ll_row, L"NName", L"");
+ dw_item.SetItemDisplayString(ll_row, L"NClassifyID", L"");
+ dw_item.SetItemString(ll_row, L"NInvoiceNo", L"");
+ ll_row = dw_item.GetNextSelectRow(ll_row + 1);
+ }
+ dw_item.Redraw();
+
+ return 1;
+ }
+
+ int CalcRate()
+ {
+ for (int row = 1; row <= dw_fob.GetRowCount(); row++)
+ {
+ xstring InvoiceNo = dw_fob.GetItemString(row, L"InvoiceNo");
+ xstring ClassifyID = dw_fob.GetItemString(row, L"ClassifyID");
+ double sumAmt = GetSumAmount(InvoiceNo, ClassifyID);
+ double sumQty = GetSumQuantity(InvoiceNo, ClassifyID);
+ double fobAmt = dw_fob.GetItemDouble(row, L"FobAmt");
+ double rate = sumAmt / fobAmt;
+ double LimitAmt = fobAmt * rate;
+ dw_fob.SetItemDouble(row, L"Rate", rate);
+ dw_fob.SetItemDouble(row, L"LimitAmt", LimitAmt);
+ dw_fob.SetItemDouble(row, L"RestAmt", LimitAmt - sumAmt);
+ }
+ RecalcProfitData();
+ dw_fob.Redraw();
+
+ return 1;
+ }
+
+ int onimport() {
+ //OpenWindow(L"dev:xpage[import.vatnotify.vx]",0);
+ return 1;
+ }
+
+ int OnFobItemChanged(TEvent* evt, LPARAM p)
+ {
+ DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
+ xstring colname = hdr.colname;
+ xstring value = hdr.data;
+ int row = hdr.row;
+
+ if (colname == L"Rate" || colname == L"FobAmt")
+ {
+ xstring InvoiceNo = dw_fob.GetItemString(row, L"InvoiceNo");
+ xstring ClassifyID = dw_fob.GetItemString(row, L"ClassifyID");
+ double sumAmt = GetSumAmount(InvoiceNo, ClassifyID);
+ double sumQty = GetSumQuantity(InvoiceNo, ClassifyID);
+ double fobAmt = dw_fob.GetItemDouble(row, L"FobAmt");
+ double rate = dw_fob.GetItemDouble(row, L"Rate");
+ double LimitAmt = fobAmt * rate;
+ dw_fob.SetItemDouble(row, L"LimitAmt", LimitAmt);
+ dw_fob.SetItemDouble(row, L"RestAmt", LimitAmt - sumAmt);
+ dw_fob.Redraw();
+ RecalcProfitData();
+ return 1;
+ }
+
+ return 1;
+ }
+
+ int OnArgChanged(TEvent* evt, LPARAM p)
+ {
+ DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
+ xstring colname = hdr.colname;
+ xstring value = hdr.data;
+ int row = hdr.row;
+ xstring SupplierID = dw_arg.GetItemString(1, L"SupplierID");
+ if (SupplierID != L"")
+ {
+ if (GetWinParam())
+ {
+ xaserverarg arg;
+
+ int pArg = GetArg();
+
+ arg.AddArg(L"SupplierID", SupplierID);
+ OnRetrieve();
+ }
+ }
+
+ return 1;
+ }
+
+ int OnItemChanged(TEvent* evt, LPARAM p)
+ {
+ DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
+ xstring colname = hdr.colname;
+ xstring value = hdr.data;
+ int row = hdr.row;
+ xstring ClassifyID = dw_item.GetItemString(row, L"NClassifyID");
+ if (ClassifyID == L"") ClassifyID = dw_item.GetItemString(row, L"ClassifyID");
+ xstring InvoiceNo = dw_item.GetItemString(row, L"NInvoiceNo");
+ if (InvoiceNo == L"") InvoiceNo = dw_item.GetItemString(row, L"InvoiceNo");
+ int ll_find = FobLookup(ClassifyID);
+ if (colname == L"NAmount")
+ {
+ if (ll_find > 0)
+ {
+ xstring qtyUnit = dw_fob.GetItemString(ll_find, L"CQtyUnit");
+ double limitAmt = dw_fob.GetItemDouble(ll_find, L"LimitAmt");
+ double CQuantity = dw_fob.GetItemDouble(ll_find, L"CQuantity");
+ double sumAmt = GetSumAmount(InvoiceNo, ClassifyID);
+ double amt = dw_item.GetItemDouble(row, L"NAmount");
+ double qty = CQuantity * amt / limitAmt;
+ if (qtyUnit.trim() != L"千克")
+ {
+ int d = xstring(qty).toInt();
+ xstring s = xstring(d);
+ qty = s.toDouble();
+ }
+ double restAmt = limitAmt - sumAmt;
+ dw_fob.SetItemDouble(ll_find, L"RestAmt", restAmt);
+ dw_item.ItemChangeTo(row, L"NQuantity", xstring(qty));
+ dw_item.Redraw();
+ dw_fob.Redraw();
+ }
+ return 1;
+ }
+ else if (colname == L"NQuantity")
+ {
+ if (ll_find > 0)
+ {
+ double CQuantity1 = dw_fob.GetItemDouble(ll_find, L"CQuantity");
+ double sumQty = GetSumQuantity(InvoiceNo, ClassifyID);
+ double restQuantity = CQuantity1 - sumQty;
+ dw_fob.SetItemDouble(ll_find, L"RestQty", restQuantity);
+ dw_fob.Redraw();
+ }
+ return 1;
+ }
+ else if (colname == L"NInvoiceNo")
+ {
+ row = dw_item.GetRow();
+ InvoiceNo = dw_item.GetItemString(row, L"NInvoiceNo");
+ if (InvoiceNo == L"") InvoiceNo = dw_item.GetItemString(row, L"InvoiceNo");
+ RetrieveFob(InvoiceNo);
+ RetrieveProfit(InvoiceNo);
+ return 1;
+ }
+ else if (colname == L"NClassifyID")
+ {
+ xstring NQuantity = dw_item.GetItemString(row, L"NQuantity");
+ if (NQuantity != L"") dw_item.ItemChangeTo(row, L"NQuantity", NQuantity);
+ xstring NAmount = dw_item.GetItemString(row, L"NAmount");
+ if (NAmount != L"") dw_item.ItemChangeTo(row, L"NAmount", NAmount);
+ xstring sdate = publiccode::GetCurrentDate();
+ dw_item.SetItemString(row, L"NotifyDate", sdate);
+
+ xstring qtyUnit1 = dw_fob.GetItemString(ll_find, L"CQtyUnit");
+ dw_item.SetItemString(row, L"CQtyUnit", qtyUnit1);
+ dw_item.SetItemString(row, L"VATRefundRate", dw_fob.GetItemString(ll_find, L"VATRefundRate"));
+ dw_item.Redraw();
+ return 1;
+ }
+ return 1;
+ }
+
+ double GetSumAmountExcept(xstring InvoiceNo, xstring ClassifyID, xstring InvoiceNoExcept)
+ {
+ xml x ;
+
+ xaserverarg arg = ViewObject::MakeArg();
+ arg.AddArg(L"ClassifyID", ClassifyID);
+ arg.AddArg(L"InvoiceNo", InvoiceNo);
+ arg.AddArg(L"InvoiceExcept", InvoiceNoExcept);
+
+ if (xurl::get(L"/sale/data/VATNotify/entity/suminfo", arg.GetString(), x) != 1)
+ {
+ xstring error = x.text();
+ alert(L"err:" + error);
+ return 0.0;
+ }
+ KXMLDOMNode n = x.selectSingleNode(L"data/Item/amt");
+ if (!n) return 0.0;
+ xstring str = n.text();
+ return str.toDouble();
+ }
+
+ double GetSumQuantityExcept(xstring InvoiceNo, xstring ClassifyID, xstring InvoiceNoExcept)
+ {
+ xml x ;
+
+ xaserverarg arg = ViewObject::MakeArg();
+ arg.AddArg(L"ClassifyID", ClassifyID);
+ arg.AddArg(L"InvoiceNo", InvoiceNo);
+ arg.AddArg(L"InvoiceExcept", InvoiceNoExcept);
+
+ if (xurl::get(L"/sale/data/VATNotify/entity/suminfo", arg.GetString(), x) != 1)
+ {
+ xstring error = x.text();
+ alert(L"err:" + error);
+ return 0.0;
+ }
+ KXMLDOMNode n = x.selectSingleNode(L"data/Item/qty");
+ if (!n) return 0.0;
+ xstring str = n.text();
+ return str.toDouble();
+ }
+
+ double GetSumAmount(xstring InvoiceNo, xstring ClassifyID)
+ {
+ double amt = 0;
+ xstring InvoiceNoExcept = dw_item.GetItemString(1, L"InvoiceNo");
+ if (InvoiceNoExcept != L"") amt = GetSumAmountExcept(InvoiceNo, ClassifyID, InvoiceNoExcept);
+
+ for (int ll_row = 1; ll_row <= dw_item.GetRowCount(); ll_row++)
+ {
+ xstring ls_dtlno = dw_item.GetItemString(ll_row, L"NInvoiceNo");
+ if (ls_dtlno == L"") ls_dtlno = dw_item.GetItemString(ll_row, L"InvoiceNo");
+ if (InvoiceNo == ls_dtlno)
+ {
+ xstring classifyID = dw_item.GetItemString(ll_row, L"NClassifyID");
+ if (classifyID == L"") classifyID = dw_item.GetItemString(ll_row, L"ClassifyID");
+ if (classifyID == ClassifyID)
+ amt += dw_item.GetItemDouble(ll_row, L"NAmount");
+ }
+ }
+ return amt;
+ }
+
+ double GetSumQuantity(xstring InvoiceNo, xstring ClassifyID)
+ {
+ double qty = 0;
+ xstring InvoiceNoExcept = dw_item.GetItemString(1, L"InvoiceNo");
+ if (InvoiceNoExcept != L"") qty = GetSumQuantityExcept(InvoiceNo, ClassifyID, InvoiceNoExcept);
+
+ for (int ll_row = 1; ll_row <= dw_item.GetRowCount(); ll_row++)
+ {
+ xstring ls_dtlno = dw_item.GetItemString(ll_row, L"NInvoiceNo");
+ if (ls_dtlno == L"") ls_dtlno = dw_item.GetItemString(ll_row, L"InvoiceNo");
+ if (InvoiceNo == ls_dtlno)
+ {
+ xstring classifyID = dw_item.GetItemString(ll_row, L"NClassifyID");
+ if (classifyID == L"") classifyID = dw_item.GetItemString(ll_row, L"ClassifyID");
+ if (classifyID == ClassifyID)
+ qty += dw_item.GetItemDouble(ll_row, L"NQuantity");
+ }
+ }
+ return qty;
+ }
+
+ int RecalcProfitData()
+ {
+ double fobAmt = GetSumFobAmt();
+ double limitAmt = GetSumLimitAmount();
+ double RefundAmt = GetSumRefund();
+ double goodsAmt = limitAmt - RefundAmt;
+ double freight = dw_profit.GetItemDouble(1, L"Freight");
+ double comm = dw_profit.GetItemDouble(1, L"Comm");
+ double netAmount = fobAmt - freight - comm;
+ double exchCost = (limitAmt - RefundAmt) / fobAmt;
+ dw_profit.SetItemDouble(1, L"NetAmount", netAmount);
+ dw_profit.SetItemDouble(1, L"SaleAmount", fobAmt);
+ dw_profit.SetItemDouble(1, L"SaleCost", goodsAmt);
+ dw_profit.SetItemDouble(1, L"Drawback", RefundAmt);
+ dw_profit.SetItemDouble(1, L"ExchCost", exchCost);
+ dw_profit.Redraw();
+ return 1;
+ }
+
+ double GetSumLimitAmount()
+ {
+ double amt = 0;
+ for (int ll_row = 1; ll_row <= dw_fob.GetRowCount(); ll_row++)
+ {
+ amt += dw_fob.GetItemDouble(ll_row, L"LimitAmt");
+ }
+ return amt;
+ }
+
+ double GetSumRefund()
+ {
+ double amt = 0;
+ for (int ll_row = 1; ll_row <= dw_fob.GetRowCount(); ll_row++)
+ {
+ double rate = dw_fob.GetItemDouble(ll_row, L"VATRate");
+ double refundRate = dw_fob.GetItemDouble(ll_row, L"VATRefundRate");
+ double d = dw_fob.GetItemDouble(ll_row, L"LimitAmt");
+ double val = d / (100.0 + rate) * refundRate;
+ amt += val;
+ }
+ return amt;
+ }
+
+ double GetSumFobAmt()
+ {
+ double amt = 0;
+ for (int ll_row = 1; ll_row <= dw_fob.GetRowCount(); ll_row++)
+ {
+ amt += dw_fob.GetItemDouble(ll_row, L"FobAmt");
+ }
+ return amt;
+ }
+
+ int FobLookup(xstring ClassifyID)
+ {
+ for (int ll_row = 1; ll_row <= dw_fob.GetRowCount(); ll_row++)
+ {
+ if (dw_fob.GetItemString(ll_row, L"ClassifyID") == ClassifyID) return ll_row;
+ }
+ return -1;
+ }
+
+ int addother() {
+ return 1;
+ }
+ int deleteother() {
+ return 1;
+ }
+ //命令发布函数
+ int OnCmdDispatch(xstring comdid)
+ {
+ if (comdid == L"save") {
+ return OnSave();
+ }
+ else if (comdid == L"onebill") {
+ return onebill();
+ }
+ else if (comdid == L"onebillno") {
+ return onebillno();
+ }
+ else if (comdid == L"xmPrint") {
+ return OnPrint();
+ }
+ else if (comdid == L"xmPrintItem") {
+ return OnPrintItem();
+ }
+ else if (comdid == L"xmCalcRate") {
+ return CalcRate();
+ }
+ return 0;
+ }
+
+ int OnRowChanged(TEvent* evt, LPARAM p)
+ {
+ DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
+ int row = hdr.row;
+
+ xstring InvoiceNo = dw_item.GetItemString(row, L"NInvoiceNo");
+ if (InvoiceNo == L"") InvoiceNo = dw_item.GetItemString(row, L"InvoiceNo");
+ if (InvoiceNo != CurInvNo)
+ {
+ CurInvNo = InvoiceNo;
+ RetrieveFob(InvoiceNo);
+ RetrieveProfit(InvoiceNo);
+ RecalcProfitData();
+ }
+
+ return 1;
+ }
+
+ //命令处理事件
+ int OnXCommand(TEvent* evt, LPARAM param)
+ {
+ return OnCmdDispatch(evt->xcommand.pStrID);
+ }
+
+ int OnSave()
+ {
+ xml x ;
+
+ dw_item.AcceptText();
+ dw_item.DwUpdateAllToEx(x);
+
+ xml x0 = ViewObject::MakeXml();
+ x0.loadXML(L"<root/>");
+
+ KXMLDOMNodeList t = x.selectNodes(L"root/item[@update.modify]");
+ KXMLDOMElement e1 = x0.documentElement();
+ int len = t.length();
+ for (int i = 0; i < len; i++)
+ {
+ e1.appendChild(t.item(i));
+ }
+ xaserverarg arg = ViewObject::MakeArg();
+ arg.AddArg(L"content", x0.xml());
+
+ //trace(x.xml);
+ //return 1;
+ if (xurl::get(L"/sale/data/VATNotify/base/update", arg.GetString(), x0) != 1)
+ {
+ xstring error = x0.text();
+ alert(L"err:" + error);
+ return 1;
+ }
+ xstring str = x0.documentElement().getAttribute(L"text");
+ if (str == L"true")
+ {
+ dw_item.ResetUpdateStatus();
+ alert(L"保存成功!");
+ }
+ else
+ {
+ alert(L"保存失败1!");
+ return 1;
+ }
+
+ dw_fob.AcceptText();
+ xml x1 ;
+
+ dw_fob.DwUpdateAllToEx(x1);
+ arg.AddArg(L"content", x1.xml());
+ if (xurl::get(L"/sale/data/VATNotify/fob/update", arg.GetString(), x1) != 1)
+ {
+ xstring error1 = x1.text();
+ alert(L"err:" + error1);
+ return 1;
+ }
+ str = x1.documentElement().getAttribute(L"text");
+ if (str == L"true")
+ {
+ dw_fob.ResetUpdateStatus();
+ alert(L"保存成功!");
+ }
+ else
+ {
+ alert(L"保存失败2!");
+ return 1;
+ }
+ return 1;
+ }
+
+ int OnAttachEvent()
+ {
+ //绑定工具条点击事件
+ AttachEvent(L"WM_XCOMMAND", (FEvent)&maintpapercardvatnotifyWin::OnXCommand);
+ //获取焦点事件,用于重置工具条
+ AttachEvent(L"WM_SETFOCUS", (FEvent)&maintpapercardvatnotifyWin::OnSetFocus);
+ AttachEvent(L"dw_item", L"DWV_ITEMCHANGED", (FEvent)&maintpapercardvatnotifyWin::OnItemChanged);
+ AttachEvent(L"dw_arg", L"DWV_ITEMCHANGED", (FEvent)&maintpapercardvatnotifyWin::OnArgChanged);
+ AttachEvent(L"dw_fob", L"DWV_ITEMCHANGED", (FEvent)&maintpapercardvatnotifyWin::OnFobItemChanged);
+ AttachEvent(L"dw_item", L"DWV_ROWFOCUSCHANGED", (FEvent)&maintpapercardvatnotifyWin::OnRowChanged);
+ AttachEvent(L"dw_item", L"DWV_ASKDATA", (FEvent)&maintpapercardvatnotifyWin::OnAskDataItem);
+ return 1;
+ }
+
+ int RetrieveFob(xstring InvoiceNo, bool start = false)
+ {
+ if (!start)
+ {
+ dw_fob.Filter(L"InvoiceNo", InvoiceNo);
+ dw_fob.Redraw();
+ if (dw_fob.GetRowCount() > 0) return 1;
+ }
+
+ //start = true;
+ xml x ;
+
+ xaserverarg arg;
+
+ arg.AddArg(L"invoiceno", InvoiceNo);
+ if (getUrl(L"/sale/data/VATNotify/entity/fob", arg.GetString(), x) != 1)
+ {
+ trace(x.text());
+ return -1;
+ }
+ else
+ {
+ //trace(x.xml);
+ if (start)
+ {
+ dw_fob.Retrieve(x);
+ dw_fob.Redraw();
+ }
+ else
+ {
+ xml x1 ;
+
+ dw_fob.DwUpdateAllToEx(x1);
+ KXMLDOMElement docElement = x1.documentElement();
+ if (docElement)
+ {
+ KXMLDOMNodeList lst = x.selectNodes(L"data/Item");
+ int n = lst.length();
+ for (int i = 0; i < n; i++)
+ {
+ KXMLDOMElement e = lst.item(i);
+ docElement.appendChild(e);
+ e.Release();
+ }
+ docElement.Release();
+ lst.Release();
+ dw_fob.Retrieve(x1);
+ }
+ else
+ {
+ dw_fob.Retrieve(x);
+ }
+ dw_fob.Filter(L"InvoiceNo", InvoiceNo);
+ dw_fob.Redraw();
+ }
+ }
+ return 1;
+ }
+
+ int RetrieveProfit(xstring InvoiceNo)
+ {
+ xml x ;
+
+ xaserverarg arg;
+
+ arg.AddArg(L"invoiceno", InvoiceNo);
+ if (getUrl(L"/sale/data/VATNotify/entity/profit", arg.GetString(), x) != 1)
+ {
+ trace(x.text());
+ return -1;
+ }
+ else
+ {
+ dw_profit.Retrieve(x);
+ dw_profit.Redraw();
+ }
+ return 1;
+ }
+
+ int OnRetrieve()
+ {
+ xml x ;
+
+ xaserverarg arg;
+
+
+ if (GetWinParam())
+ {
+ int pArg = GetArg();
+
+ }
+ else
+ return 1;
+ if (getUrl(L"/sale/data/VATNotify/entity/papercard", arg.GetString(), x) != 1)
+ {
+ trace(x.text());
+ return -1;
+ }
+ else
+ {
+ dw_item.Retrieve(x);
+ dw_item.Redraw();
+ dw_item.SetSelectionMode(3);
+ }
+ if (dw_item.GetRowCount() > 0)
+ {
+ //xstring InvoiceNo = dw_item.GetItemString(1,L"NInvoiceNo");
+ //if(InvoiceNo==L"") InvoiceNo = dw_item.GetItemString(1,L"InvoiceNo");
+ xstring InvoiceNo = arg.GetArgString(L"invoiceno");
+ CurInvNo = InvoiceNo;
+ RetrieveFob(InvoiceNo);
+ RetrieveProfit(InvoiceNo);
+ RecalcProfitData();
+ }
+
+ return 1;
+ }
+
+ //base AskData
+ int OnAskDataItem(TEvent* evt, LPARAM p)
+ {
+ DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
+ int row = hdr.row;
+ xstring x = hdr.colname;
+ if (x == L"userInvoiceNo") //下拉
+ {
+ xstring sInvoiceNo = dw_item.GetItemString(row, L"NInvoiceNo");
+ hdr.data = sInvoiceNo;
+ }
+
+ return 1;
+ }
+
+ int onload()
+ {
+ dw_item = GetControl(L"dw_item");
+ dw_item.openUrl(L"/sale/view/VATNotify/template/VATNotify/item");
+ dw_item.SetColumnState(L"CName", false);
+ dw_item.SetColumnState(L"CreatorID", false);
+ dw_item.SetColumnState(L"CreateDate", false);
+ dw_item.SetColumnState(L"VATRate", false);
+ dw_item.SetColumnState(L"VATRefundRate", false);
+ dw_item.SetColumnState(L"IsFinish", false);
+ dw_item.SetColumnState(L"Type", false);
+
+ dw_fob = GetControl(L"dw_fob");
+ dw_fob.openUrl(L"/sale/view/VATNotify/template/VATNotify/fob");
+ dw_profit = GetControl(L"dw_profit");
+ dw_profit.openUrl(L"/sale/view/VATNotify/template/VATNotify/profit");
+ dw_profit.SetColHeaderHeight(0);
+ dw_profit.SetRowSelectorWidth(0);
+ dw_profit.SetHScrollState(false);
+ dw_profit.SetVScrollState(false);
+
+ InvNo = L"";
+ CurInvNo = L"";
+ xaserverarg arg;
+
+
+ if (GetWinParam())
+ {
+ int pArg = GetArg();
+
+ InvNo = arg.GetArgString(L"invoiceno");
+ SetWindowText(GetHWND(), InvNo);
+ }
+ CurInvNo = InvNo;
+
+ dw_arg = GetControl(L"dw_arg");
+ dw_arg.openUrl(L"/sale/view/VATNotify/template/VATNotify/PaperCardArg");
+ dw_arg.SetColHeaderHeight(0);
+ dw_arg.SetRowSelectorWidth(0);
+ dw_arg.SetHScrollState(false);
+ dw_arg.SetVScrollState(false);
+
+ OnRetrieve();
+ OnAttachEvent();
+
+ return 1;
+ }
+
+ int onloaded()
+ {
+ SetAgent();
+
+ return 1;
+ }
+ };
--
Gitblit v1.9.3