From 7a91c3a1ed37b0332d4ff0ebeae60bd6da3665c0 Mon Sep 17 00:00:00 2001 From: xj qian <qianxj15@sina.com> Date: 星期二, 16 七月 2024 18:28:58 +0800 Subject: [PATCH] Merge branch 'master' of http://116.62.18.175:6699/r/mis-prj --- jrj/project/business/BasicCode/PaymentTerm.maint.cpp | 429 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 429 insertions(+), 0 deletions(-) diff --git a/jrj/project/business/BasicCode/PaymentTerm.maint.cpp b/jrj/project/business/BasicCode/PaymentTerm.maint.cpp new file mode 100644 index 0000000..3604cc8 --- /dev/null +++ b/jrj/project/business/BasicCode/PaymentTerm.maint.cpp @@ -0,0 +1,429 @@ +#include <wobject/xstring.hpp> +#include <xcontrol/xtreeview.hpp> +#include <xcontrol/xdwgrid.hpp> +#include <wobject/xdouble.hpp> +#include <xcontrol/xlayersheet.hpp> + +#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" +#include "viewobject/view.base.hpp" + +using xml = KXMLDOMDocument; +class __declspec(dllexport) PaymentTermEdit : public xframe +{ +public: + xdwtable dw_base; + xdwtable dw_p; + xcell dw_cell; + xstring sCryno; +public: + PaymentTermEdit(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} +public: + static PaymentTermEdit* CreateInstance(void* implPtr, void* hWnd) + { + PaymentTermEdit* pWin = new PaymentTermEdit(implPtr, (HWND)hWnd); + return pWin; + } + int OnAddrow() + { + dw_p = dw_base.FindDwTable(L"line"); + int i; + double dDueAmount = 0; + double dPercnet = 100; + for (i = 1 ; i <= dw_p.GetRowCount();i++) + { + dDueAmount = dw_p.GetItemDouble(i,L"DueAmount"); + if (dDueAmount > 0) + break; + dPercnet = dPercnet - dw_p.GetItemDouble(i,L"DuePercent"); + } + int irow = dw_p.InsertRow(0); + dw_p.SetItemString(irow,L"SeqNo",xstring(irow)); + if (dDueAmount <= 0) + dw_p.SetItemDouble(irow,L"DuePercent",dPercnet); + + return 1; + } + int OnDeleterow() + { + dw_p = dw_base.FindDwTable(L"line"); + int row2 = dw_p.GetRow(); + if (row2 < 1) return 0; + dw_p.DeleteRow(row2); + + return 1; + } + xstring OnCreateTxt() + { + //dw_1.AcceptText(); //不能加会报错 + int irow; + //int icnt = dw_1.GetRowCount(); + dw_p = dw_base.FindDwTable(L"line"); + int icnt = dw_p.GetRowCount(); + if (icnt < 1) return L""; + xstring sTxt; + //double dPercnet = 100; + for (irow = 1;irow <= icnt ;irow ++) + { + xstring sPaymentMethod = dw_p.GetItemString(irow,L"PaymentMethod"); //支付方式 + //xstring sDueDays = dw_p.GetItemDisplayString(irow,L"DueDays"); + xstring sDueDays = dw_p.GetItemString(irow,L"DueDays"); //期限 + xstring sDuePercent = dw_p.GetItemString(irow,L"DuePercent"); //比例 + xstring sDueAmount = dw_p.GetItemString(irow,L"DueAmount"); //金额 + + if (!sPaymentMethod || sPaymentMethod == L"") + sTxt = sTxt + L""; + if (!sDueDays || sDueDays == L"") + sTxt = sTxt + L""; + else + { + if (sDueDays == L"-1") sDueDays = L" IN ADVANCE"; + else if (sDueDays == L"0") sDueDays = L" AT SIGHT"; + else + { + if (sPaymentMethod == L"T/T") + sDueDays = L" WITHIN "+sDueDays + L" DAYS AFTER SHIPMENT"; + else + sDueDays = L" AT "+sDueDays + L" DAYS"; + } + + if (!sDuePercent || sDuePercent == L"") + { + if (!sDueAmount || sDueAmount == L"") + sTxt = sTxt + L""; + else + { + + sTxt = sTxt + sCryno + L" " + sDueAmount + L" " + sPaymentMethod + sDueDays + L";"; + } + } + else + { + if (sDuePercent.find(L".",0) >= 0) + { + while (sDuePercent.right(1) == L"0") + { + sDuePercent = sDuePercent.left(sDuePercent.length() - 1); + } + if (sDuePercent.right(1) == L".") + sDuePercent = sDuePercent.left(sDuePercent.length() - 1); + } + + sTxt = sTxt + sDuePercent + L"% " + sPaymentMethod+ sDueDays + L";"; + } + } + } + + sTxt = sTxt.mid(0,sTxt.length() - 1); + if (sTxt != L"") + sTxt = sTxt + L"."; + + return sTxt; + } + int OnOk() + { + dw_base.AcceptText(); + //判断是否有必输值为空 + dw_p = dw_base.FindDwTable(L"line"); + double dPercnet = 0; + double dAmount = 0; + xstring sChargeAll = L""; + if (dw_p) + { + int i; + for (i=1;i <= dw_p.GetRowCount();i++) + { + xstring seqNo = dw_p.GetItemString(i,L"SeqNo"); + xstring sPaymentMethod = dw_p.GetItemString(i,L"PaymentMethod"); + xstring sDueDays = dw_p.GetItemString(i,L"DueDays"); + xstring sDuePercent = dw_p.GetItemString(i,L"DuePercent"); + dPercnet = dPercnet + sDuePercent.toDouble(); + xstring sDueAmount = dw_p.GetItemString(i,L"DueAmount"); + dAmount = dAmount + sDueAmount.toDouble(); + if (!seqNo) seqNo = L""; + if (!sPaymentMethod) sPaymentMethod = L""; + if (!sDueDays) sDueDays = L""; + if (!sDuePercent) sDuePercent = L""; + if (!sDueAmount) sDueAmount = L""; + dw_p.SetItemString(i,L"SeqNo",xstring(i)); + sChargeAll = sPaymentMethod + sDueDays + sDuePercent + sDueAmount; + if (sChargeAll != L"") + { + if (sPaymentMethod == L"") + { + alert(L"支付方式不能为空!"); + return 0; + } + if (sDueDays == L"") + { + alert(L"期限不能为空!"); + return 0; + } + + } + } + } + + //百分比校验 + if (dw_p.GetRowCount() <= 1 && sChargeAll == L"") + {} + else + { + if (dPercnet != 100) + { + if (dAmount <= 0) + { + alert(L"比率不等于100!"); + return 0; + } + } + } + + xstring sTxt = OnCreateTxt(); + dw_base.SetItemString(1,L"PaymentTermEx",sTxt); + + //CloseWindow(); + 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; + + if (colname == L"DueDays") + { + xdwtable dw; + dw = dw_base.FindDwTable(L"line"); + + if (dw) + { + xstring sPaymentMethod = dw.GetItemString(row,L"PaymentMethod"); + if (value == L"0") + { + if (sPaymentMethod == L"T/T") + { + //alert(L"此支付方式期限不能为 0 (AT SIGHT)"); + //return -1; + } + } + else if (value == L"-1") + { + if (sPaymentMethod != L"T/T") + { + alert(L"此支付方式期限不能为 -1(IN ADVANCE)"); + return -1; + } + } + } + + } + //生成支付条款文本 + if (colname == L"PaymentMethod" || colname == L"DueDays" || colname == L"DuePercent" || colname == L"DueAmount") + { + xstring sTxt = OnCreateTxt(); + + dw_base.SetItemString(1,L"Description",sTxt); + } + + return 1; + } + int OnClick(TEvent* evt, LPARAM p) + { + DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; + xstring value = hdr.data; + xstring colname = hdr.colname; + int row = hdr.row; + xaserverarg arg; + + //alert(row.toString()); + xdwtable dw; + dw = dw_base.FindDwTable(L"line"); + //alert(colname); + if (dw) + { + if (colname == L"DuePercent") + { + int i; + int icnt = dw.GetRowCount(); + if (icnt < 1) + return 0; + double dDueAmount = 0; + for (i = 1 ; i <= icnt ; i++) + { + dDueAmount = dw.GetItemDouble(i,L"DueAmount"); + if (dDueAmount > 0) + break; + } + dw_cell.setNativePointer(dw_base.QueryItem(L"ixcell")); + if (dDueAmount > 0) + { + dw.SetColumnProp(L"DuePercent",L"cellprotect",L"保护");//保护中文规格 + } + else + { + dw.SetColumnProp(L"DuePercent",L"cellprotect",L"不保护");//保护中文规格 + } + + } + + if (colname == L"DueAmount") + { + int j; + int jcnt = dw.GetRowCount(); + if (jcnt < 1) + return 0; + double dDuePercent = 0; + for (j = 1 ; j <= jcnt ; j++) + { + dDuePercent = dw.GetItemDouble(j,L"DuePercent"); + if (dDuePercent > 0) + break; + } + if (dDuePercent > 0) + { + dw.SetColumnProp(L"DueAmount",L"cellprotect",L"保护");//保护中文规格 + } + else + { + dw.SetColumnProp(L"DueAmount",L"cellprotect",L"不保护");//保护中文规格 + } + } + + } + + return 1; + } + + //保存事件 + int OnSave() + { + if(OnOk()<1)return 0; + dw_base = GetControl(L"dw_base"); + dw_base.AcceptText(); + //dw_bank.AcceptText(); + xml x ; + xaserverarg arg ; + + dw_base.DwUpdateAllTo(x); + //dw_bank.DwUpdateAllTo(x); + //alert(x.xml()); + + arg.AddArg(L"content",x.xml()); + arg.AddArg(L"dbmap",L"FND_PaymentTerm.dbmap"); + //return 0; + if (getUrl(L"/sale/data/PaymentTerm/entity/company/save",arg.GetString(),x) != 1) + { + alert(L"保存失败!"); + return 0; + } + else + { + //alert(x.xml()); + if(x.selectSingleNode(L"error")) + { + alert(L"保存出错2!"); + return 0; + } + arg.AddArg(L"ret",L"Ok"); + MessageBox(GetHWND(),L"保存成功!",L"提示",0); + //alert(L"保存成功"); + dw_base.ResetUpdateStatus(); + //dw_bank.ResetUpdateStatus(); + //xwin::SendMessage(parenthwnd, 0x401, L"maintsave", 0);//通知list窗口更新数据 + } + //alert(L"保存成功"); + dw_base.Redraw(); + //dw_bank.Redraw(); + CloseWindow(); + return 0; + } + + int OnCmdDispatch(xstring comdid) + { + //alert(comdid); + if(comdid==L"xmOk") OnSave(); + else if(comdid==L"addrow") OnAddrow(); + else if(comdid==L"deleterow") OnDeleterow(); + //else if(comdid==L"AddRow") OnAddRow(); + //else if(comdid==L"InsertRow") OnInsertRow(); + //else if(comdid==L"DeleteRow")OnDeleteRow(); + return 1; + } + + //按钮事件 + int OnXCommand(TEvent* evt, LPARAM param) + { + return OnCmdDispatch(evt->xcommand.pStrID); + } + + int OnAttachEvent() + { + //按钮事件 + AttachEvent(L"WM_XCOMMAND", (FEvent)&PaymentTermEdit::OnXCommand); + //获取焦点事件,用于重置工具条 + //AttachEvent(L"WM_SETFOCUS",OnSetFocus); + AttachEvent(L"dw_base",L"DWV_ITEMCHANGED", (FEvent)&PaymentTermEdit::OnItemChanged); + AttachEvent(L"dw_base",L"DWV_CLICKED", (FEvent)&PaymentTermEdit::OnClick); + return 1; + } + int OnRetrieve() + { + if(GetWinParam()) + { + int p = GetArg(); + xaserverarg args ; + + xstring id = args.GetArgString(L"EntityID"); + //alert(id); + if(id==L"new") + { + + //OnAddNew(); + } + else + { + xml x ; + + if(getUrl(L"/sale/data/PaymentTerm/entity/base12", args.GetString(), x) != 1) + { + alert(L"错误"); + return -1; + } + //alert(x.xml()); + dw_base.Retrieve(x); + //dw_bank.Retrieve(x); + dw_base.Redraw(); + //dw_bank.Redraw(); + } + } + return 1; + } + + int onload() + { + SetArg(); + //maint::onload(); + //maint::onloaded(); + dw_base = GetControl(L"dw_base"); + dw_cell = new xcell; + dw_cell.setNativePointer(dw_base.QueryItem(L"ixcell")); + dw_base.openUrl(L"/sale/view/Payment/template/Payment/maint"); + //alert(L"1233"); + OnRetrieve(); + OnAttachEvent(); + //dw_base = GetControl(L"dw_base"); + + } + + int onloaded() + { + //maint::onloaded(); + //alert(L"response"); + //dw_base = GetControl(L"dw_base"); + //dw_cell = new xcell; + //dw_cell.setNativePointer(dw_base.QueryItem(L"ixcell")); + return -1; + } + +}; \ No newline at end of file -- Gitblit v1.9.3