þÿ#include <wobject/xstring.hpp> #include <xcontrol/xtreeview.hpp> #include <xcontrol/xdwgrid.hpp> #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" #include "vbusiness/vframe/frame.vframe.vbusiness.hpp" #include "viewobject/saleorder.view.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport)HabitPOWin : public xframe { public: xdwtable dw_nopaper; xdwtable dw_paper; xdwtable dw_nopaper1; xdwtable dw_paper1; xnode m_agentNode; //Agent Condition public: HabitPOWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static HabitPOWin* CreateInstance(void* implPtr, void* hWnd) { HabitPOWin* pWin = new HabitPOWin(implPtr, (HWND)hWnd); return pWin; } int SetAgent() { return 1; 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; } //q&p¹oÀm;YtQýep int OnSetFocus(TEvent* evt, int param) { //‘Ín]åQwga SetAgent(); return 1; } //T}NäSÑ^Qýep int OnCmdDispatch(xstring comdid) { if (comdid == L"xmCancel") { CloseWindow(); return 1; } else if (comdid == L"xmApply") { return OnOk(); } return 0; } //T}NäYtN‹Nö int OnXCommand(TEvent* evt, LPARAM p) { return OnCmdDispatch(evt->xcommand.pStrID); } int SureItem(xdwtable dw_dest, xdwgrid dw_src, int drow, int srow, xstring colname, bool display = false, bool changed = false) { if (dw_dest.GetItemString(drow, colname) != dw_src.GetItemString(srow, colname)) { if (changed) dw_dest.ItemChangeTo(drow, colname, dw_src.GetItemString(srow, colname)); else dw_dest.SetItemString(drow, colname, dw_src.GetItemString(srow, colname)); if (display) dw_dest.SetItemDisplayString(drow, colname, dw_src.GetItemDisplayString(srow, colname)); } } int OnUse(xdwtable dw_src, xdwtable dw_dest) { xdwtable dw_item = dw_src.FindDwTable(L"Item"); // R ]å^ú‹® xdwtable dw_pitem = dw_src.FindDwTable(L"PItem"); for (int i = 1; i <= dw_item.GetRowCount(); i++) { xstring state = dw_item.GetItemString(i, L"Used"); if (state == L"Y") { int pRow = dw_pitem.GetGroupStartRow(i); xstring skuno = dw_item.GetItemString(i, L"SKUNo"); //xstring PurchaseType = dw_pitem.GetItemDisplayString(pRow,L"PurchaseType"); //xstring scheme = dw_pitem.GetItemDisplayString(pRow,L"BOMSchemeID"); xdwtable dw_item1 = dw_dest.FindDwTable(L"Item"); //QúÐ'n xdwtable dw_pitem1 = dw_dest.FindDwTable(L"PItem"); int k = 1; for (k = 1; k <= dw_item1.GetRowCount(); k++) { if (dw_item1.GetItemString(k, L"GoodsNo").trim() == dw_item.GetItemString(i, L"GoodsNo").trim()) { if (dw_item1.GetItemString(k, L"CustomerItemNo").trim() == dw_item.GetItemString(i, L"CustomerItemNo").trim()) { break; } } } if (k > dw_item1.GetRowCount()) { continue; //dw_item1.InsertRow(0); } if (dw_item1.GetItemString(k, L"GoodsNo") == L"") { dw_item1.SetItemString(k, L"GoodsNo", dw_item.GetItemString(i, L"GoodsNo")); dw_item1.SetItemString(k, L"CName", dw_item.GetItemString(i, L"CName")); dw_item1.SetItemString(k, L"CustomerItemNo", dw_item.GetItemString(i, L"CustomerItemNo")); dw_item1.SetItemString(k, L"BOMPart", dw_item.GetItemString(i, L"BOMPart")); } int r = dw_pitem1.GetGroupStartRow(k); int rc = dw_pitem1.GetGroupRowCount(k); int srow = dw_pitem.GetGroupStartRow(i); for (int m = 1; m <= dw_pitem.GetGroupRowCount(i); m++) { if (m > rc) { dw_pitem1.InsertGroupRow(k, 0); rc++; //dw_pitem1.SetItemString(r + m - 1, L"BuyQuantity", dw_pitem1.GetItemString(r + m - 2,L"BuyQuantity")); } if (dw_pitem.GetItemString(srow + m - 1, L"BOMRate") == L"") dw_pitem1.ItemChangeTo(r + m - 1, L"BOMRate", L"1:1"); else dw_pitem1.ItemChangeTo(r + m - 1, L"BOMRate", dw_pitem.GetItemString(srow + m - 1, L"BOMRate")); dw_pitem1.SetItemString(r + m - 1, L"Material", dw_pitem.GetItemString(srow + m - 1, L"Material")); dw_pitem1.SetItemDisplayString(r + m - 1, L"Material", dw_pitem.GetItemDisplayString(srow + m - 1, L"Material")); dw_pitem1.SetItemString(r + m - 1, L"PaperCardPacking", dw_pitem.GetItemString(srow + m - 1, L"PaperCardPacking")); dw_pitem1.SetItemDisplayString(r + m - 1, L"PaperCardPacking", dw_pitem.GetItemDisplayString(srow + m - 1, L"PaperCardPacking")); dw_pitem1.SetItemString(r + m - 1, L"BuySize", dw_pitem.GetItemString(srow + m - 1, L"BuySize")); dw_pitem1.SetItemString(r + m - 1, L"SupplierID", dw_pitem.GetItemString(srow + m - 1, L"SupplierID")); dw_pitem1.SetItemDisplayString(r + m - 1, L"SupplierID", dw_pitem.GetItemDisplayString(srow + m - 1, L"SupplierID")); dw_pitem1.SetItemString(r + m - 1, L"DeliveryAddr", dw_pitem.GetItemString(srow + m - 1, L"DeliveryAddr")); dw_pitem1.SetItemString(r + m - 1, L"StandUnitPrice", dw_pitem.GetItemString(srow + m - 1, L"StandUnitPrice")); dw_pitem1.SetItemString(r + m - 1, L"UnitPriceRate", dw_pitem.GetItemString(srow + m - 1, L"UnitPriceRate")); dw_pitem1.SetItemString(r + m - 1, L"PackUnitPrice", dw_pitem.GetItemString(srow + m - 1, L"PackUnitPrice")); dw_pitem1.ItemChangeTo(r + m - 1, L"BuyUnitPrice", dw_pitem.GetItemString(srow + m - 1, L"BuyUnitPrice")); dw_pitem1.SetItemString(r + m - 1, L"BOMPart", dw_pitem.GetItemString(srow + m - 1, L"BOMPart")); dw_pitem1.SetItemString(r + m - 1, L"ItemID", dw_pitem.GetItemString(srow + m - 1, L"ItemID")); dw_pitem1.SetItemString(r + m - 1, L"HasVATInvoice", dw_pitem.GetItemString(srow + m - 1, L"HasVATInvoice")); dw_pitem1.SetItemString(r + m - 1, L"TechNote", dw_pitem.GetItemString(srow + m - 1, L"TechNote")); dw_pitem1.SetItemString(r + m - 1, L"TestNote", dw_pitem.GetItemString(srow + m - 1, L"TestNote")); dw_pitem1.SetItemString(r + m - 1, L"PackingMethod", dw_pitem.GetItemString(srow + m - 1, L"PackingMethod")); dw_pitem1.SetItemString(r + m - 1, L"Remarks", dw_pitem.GetItemString(srow + m - 1, L"Remarks")); dw_pitem1.SetItemString(r + m - 1, L"MouldBelong", dw_pitem.GetItemString(srow + m - 1, L"MouldBelong")); dw_pitem1.SetItemString(r + m - 1, L"PrenatalSamplingTime", dw_pitem.GetItemString(srow + m - 1, L"PrenatalSamplingTime")); dw_pitem1.SetItemString(r + m - 1, L"OpeningCompletionTime", dw_pitem.GetItemString(srow + m - 1, L"OpeningCompletionTime")); dw_pitem1.SetItemString(r + m - 1, L"DeliveryDate", dw_pitem.GetItemString(srow + m - 1, L"DeliveryDate")); dw_pitem1.SetItemString(r + m - 1, L"SampleNumber", dw_pitem.GetItemString(srow + m - 1, L"SampleNumber")); } } } dw_dest.Redraw(); return 1; } int OnOk() //OÝ[X { OnUse(dw_paper, dw_paper1); OnUse(dw_nopaper, dw_nopaper1); CloseWindow(); return 1; } int OnAttachEvent() { //~Ñ[š]åQwgap¹QûN‹Nö AttachEvent(L"WM_XCOMMAND", (FEvent)&HabitPOWin::OnXCommand); //ƒ·SÖq&p¹N‹Nöÿ u(NŽ‘Ín]åQwga AttachEvent(L"WM_SETFOCUS", (FEvent)&HabitPOWin::OnSetFocus); return 1; } int onload() { SetArg(); dw_nopaper = GetControl(L"dw_nopaper"); dw_nopaper.openUrl(L"/sale/view/PurchaseOrder/template/item/nopapercardex/habit"); dw_nopaper.SetRowSelectorWidth(0); dw_paper = GetControl(L"dw_paper"); dw_paper.openUrl(L"/sale/view/PurchaseOrder/template/item/papercardex/habit"); dw_paper.SetRowSelectorWidth(0); OnAttachEvent(); SetAgent(); xaserverarg arg = GetArg(); xstring SONo = arg.GetArgString(L"SONo"); xstring SOID = SaleOrderView::GetSOID(SONo); arg.AddArg(L"SOID", SOID); xml x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/so/poitemlist/papercard/habit", L"SOID", SOID); if (x) dw_paper.Retrieve(x); x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/so/poitemlist/nopapercard/habit", L"SOID", SOID); if (x) dw_nopaper.Retrieve(x); dw_paper1 = arg.GetArgString(L"dw_paper").toInt(); dw_nopaper1 = arg.GetArgString(L"dw_nopaper").toInt(); return 1; } int onloaded() { return 1; } };