#include #include #include #include #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) DeliveryEdit : public xframe { public: xdwtable dw_1; xcell dw_cell; public: DeliveryEdit(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static DeliveryEdit* CreateInstance(void* implPtr, void* hWnd) { DeliveryEdit* pWin = new DeliveryEdit(implPtr, (HWND)hWnd); return pWin; } xstring OnCreateTxt() { //dw_1.AcceptText(); //不能加会报错 xstring sType; xstring sDeliveryRule; xstring sDeliveryDays; xstring sScheduleShipDate; xstring sTxt; sType = dw_1.GetItemString(1, L"DeliveryRule"); sDeliveryRule = dw_1.GetItemDisplayString(1, L"DeliveryRule"); sDeliveryDays = dw_1.GetItemString(1, L"DeliveryDays"); sScheduleShipDate = dw_1.GetItemString(1, L"ScheduleShipDate"); if (sType == L"1") { if (sDeliveryDays != L"") sTxt = L"Shipment within " + sDeliveryDays + L" days after receipt of L/C."; else sTxt = L""; } else if (sType == L"2") { if (sDeliveryDays != L"") sTxt = L"Within " + sDeliveryDays + L" days after receiving the deposit."; else sTxt = L""; } else if (sType == L"3") if (sDeliveryDays != L"") sTxt = L"Within " + sDeliveryDays + L" days after receiving the signed P/I."; else sTxt = L""; else if (sType == L"4") { if (sScheduleShipDate != L"") sTxt = sScheduleShipDate; else sTxt = L""; } else sTxt = L""; return sTxt; } int OnOk() { xml x; dw_1.AcceptText(); dw_1.DwUpdateAllTo(x); GetArg().SetArg(L"content", x.xml()); GetArg().SetArg(L"process",L"ok"); CloseWindow(); return 1; } int OnItemChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname = hdr.colname; xstring value = hdr.data; if (colname == L"DeliveryRule") { xstring sP = L""; xstring sUp = L""; if (value == L"1" || value == L"2" || value == L"3") { dw_cell.SetCellProps(3, 3, sUp); dw_cell.SetCellProps(4, 3, sP); } else if (value == L"4") { dw_cell.SetCellProps(3, 3, sP); dw_1.SetItemString(1, L"DeliveryDays", L""); } else { dw_cell.SetCellProps(3, 3, sP); dw_cell.SetCellProps(4, 3, sUp); dw_1.SetItemString(1, L"DeliveryDays", L""); } } //生成交货期 if (colname == L"DeliveryRule" || colname == L"DeliveryDays" || colname == L"ScheduleShipDate") { xstring sTxt = OnCreateTxt(); dw_1.SetItemString(1, L"DeliveryTime", sTxt); } return 1; } int OnCmdDispatch(xstring comdid) { if (comdid == L"xmOk") return OnOk(); return 0; } int OnXCommand(TEvent* evt, LPARAM p) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnAttachEvent() { AttachEvent(L"WM_XCOMMAND", (FEvent)&DeliveryEdit::OnXCommand); AttachEvent(L"dw_1", L"DWV_ITEMCHANGED", (FEvent)&DeliveryEdit::OnItemChanged); return 1; } int OnInit() { /* int iArgs = GetArg(); XXmlContentSvr xdoc = new XXmlContentSvr; xdoc.setNativePointer(iArgs); vc = new vcontrol; vc.xdoc = xdoc; vbind bind = new vbind; bind.bind(dw_1, vc); */ xml x; xstring xs = GetArg().GetArgString(L"content"); x.loadXML(xs.c_str()); dw_1.Retrieve(x); xstring sDeliveryRule = dw_1.GetItemString(1, L"DeliveryRule"); xstring sP = L""; if (sDeliveryRule != L"1" && sDeliveryRule != L"2" && sDeliveryRule != L"3") dw_cell.SetCellProps(3, 3, sP); if (sDeliveryRule != L"5") dw_cell.SetCellProps(4, 3, sP); return 1; } int onload() { SetArg(); dw_1 = GetControl(L"dw_1"); dw_1.openUrl(L"/sale/view/SaleOrder/template/delivery"); //base.maint.so.tpl/delivery dw_1.SetColHeaderHeight(0); dw_1.SetRowSelectorWidth(0); dw_1.SetScrollState(false); dw_cell = new xcell; dw_cell.setNativePointer(dw_1.QueryItem(L"ixcell")); OnAttachEvent(); if (GetWinParam())OnInit(); return 1; } };