¶Ô±ÈÐÂÎļþ |
| | |
| | | #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; |
| | | } |
| | | |
| | | }; |