þÿ#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 "viewobject/saleorder.view.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) MaintPaperCardPOWin : public xframe { public: xdwgrid dw_list; xdwgrid dw_advance; xdwgrid dw_list1; xdwgrid dw_polist; xdwgrid dw_goods; xdwgrid dw_supplier; xdwtable dw_process; xdwtable dw_paper; xnode m_agentNode; //Agent Condition xstring vflag; bool hasStandPrice; int whichlist; public: MaintPaperCardPOWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static MaintPaperCardPOWin* CreateInstance(void* implPtr, void* hWnd) { MaintPaperCardPOWin* pWin = new MaintPaperCardPOWin(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, LPARAM param) { //‘Ín]åQwga SetAgent(); return 1; } int OnSaveEx() { xml x1; xml x; xml xp; dw_polist.AcceptText(); dw_list.AcceptText(); dw_list1.AcceptText(); dw_polist.DwUpdateAllToEx(xp); dw_list.DwUpdateAllToEx(x); dw_list1.DwUpdateAllToEx(x1); //trace(xp.xml()); xstring val = xp.xml(); xstring val0 = x.xml(); xstring val1 = x1.xml(); val = L"<data>" + val + val0 + val1 + L"</data>"; xaserverarg arg; arg.setNativePointer(arg.CreateInstance()); arg.AddArg(L"content", val); if (xurl::get(L"/sale/data/PurchaseOrder/update/polist", arg.GetString(), x) != 1) { xstring error = x.text(); alert(error); return 1; } else { xstring str = x.documentElement().getAttribute(L"text"); if (str == L"true") { dw_polist.ResetUpdateStatus(); dw_list.ResetUpdateStatus(); dw_list1.ResetUpdateStatus(); alert(L"OÝ[XbRŸ!"); } else { alert(L"OÝ[XY1%!"); } //alert(x.xml()); } return 1; } int OnSave() { xml x1; xml x; xml xp; xml xg; dw_polist.AcceptText(); dw_paper.AcceptText(); dw_process.AcceptText(); dw_advance.AcceptText(); xdwtable dw_item = dw_paper.FindDwTable(L"Item"); int row1 = dw_item.GetRowCount(); if (row1 > 1) { for (int row = 1; row <= dw_item.GetRowCount(); row++) { xstring GDNQuantity = dw_item.GetItemString(row, L"GDNQuantity"); int GDNQuantityEx = GDNQuantity.toInt(); xstring SOLineID = dw_item.GetItemString(row, L"SOLineID"); xstring GoodsNo = dw_item.GetItemString(row, L"GoodsNo"); xml check_x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/GetSOLineQuantity", L"SOLineID", SOLineID); if (check_x) { xstring Quantity = check_x.documentElement().getAttribute(L"Quantity"); int QuantityEx = Quantity.toInt(); if (GDNQuantityEx > QuantityEx) { alert(L"{," + xstring(row) + L"ˆL QlSøW‹S÷ÿ" + GoodsNo + L"ÿ ~¸Saep‘ÏY'NŽY•ep‘Ïÿ"); } } } } dw_polist.DwUpdateAllToEx(xp); dw_paper.DwUpdateAllTo(x); dw_process.DwUpdateAllTo(x1); dw_advance.DwUpdateAllToEx(xg); xstring val = xp.xml(); xstring val0 = x.xml(); xstring val1 = x1.xml(); xstring val2 = xg.xml(); val = L"<data>" + val + val0 + val1 + val2 + L"</data>"; //alert(val); xaserverarg arg; arg.setNativePointer(arg.CreateInstance()); arg.AddArg(L"content", val); if (xurl::get(L"/sale/data/PurchaseOrder/update/polistex", arg.GetString(), x) != 1) { xstring error = x.text(); alert(error); return 1; } else { xstring str = x.documentElement().getAttribute(L"text"); if (str == L"true") { dw_polist.ResetUpdateStatus(); dw_advance.ResetUpdateStatus(); //dw_list.ResetUpdateStatus(); //dw_list1.ResetUpdateStatus(); dw_paper.ResetUpdateStatus(); dw_process.ResetUpdateStatus(); //clear diff xaserverarg arg1; arg1.setNativePointer(arg1.CreateInstance()); xaserverarg parg = GetArg(); arg1.AddArg(L"EntityID", parg.GetArgString(L"SOID")); xurl::get(L"/sale/data/PurchaseOrder/pref/cleardiff", arg1.GetString(), x); alert(L"OÝ[XbRŸ!"); } else { alert(L"OÝ[XY1%!"); } //alert(x.xml()); } onload(); return 1; } xstring MakePONo(int row) { xaserverarg arg = GetArg(); xstring SONo = arg.GetArgString(L"SONo"); int len = SONo.trim().length(); int mseq = 0; for (int i = 1; i <= dw_polist.GetRowCount(); i++) { if (row == i) continue; xstring PONo = dw_polist.GetItemString(i, L"PONo"); xstring seq = L""; if (PONo != L"") seq = PONo.mid(len + 1, 9999); if (seq.toInt() > mseq) mseq = seq.toInt(); } return SONo + L"A" + xstring(mseq + 1); } int UpdateSupplier(int row) { xstring supplier = dw_polist.GetItemString(row, L"SupplierID"); xstring supplierName = dw_polist.GetItemDisplayString(row, L"SupplierID"); xstring PONo = dw_polist.GetItemString(row, L"PONo").trim(); double ttl = 0.0; double amt = 0.0; //sum papercard for (int i = 1; i <= dw_list.GetRowCount(); i++) { if (dw_list.GetItemString(i, L"PONo").trim() != PONo) continue; dw_list.SetItemString(i, L"SupplierID", supplier); dw_list.SetItemDisplayString(i, L"SupplierID", supplierName); evalPrice(i); evalPackPrice(i); amt = dw_list.GetItemDouble(i, L"BuyAmount"); ttl += amt; } //sum nopapercard for (int j = 1; j <= dw_list1.GetRowCount(); j++) { if (dw_list1.GetItemString(j, L"PONo").trim() != PONo) continue; dw_list.SetItemString(j, L"SupplierID", supplier); dw_list.SetItemDisplayString(j, L"SupplierID", supplierName); amt = dw_list1.GetItemDouble(j, L"BuyAmount"); ttl += amt; } dw_polist.SetItemDouble(row, L"Amount", ttl); return 1; } int RecalcAmount() { return 1; int row = 1; double ttl = 0.0; double amt = 0.0; double platefee = 0.0; double mouldfee = 0.0; //sum papercard xdwtable dw_pitem = dw_paper.FindDwTable(L"PItem"); xdwtable dw_pitem1 = dw_process.FindDwTable(L"PItem"); for (row = 1; row <= dw_pitem.GetRowCount(); row++) { amt = dw_pitem.GetItemDouble(row, L"BuyAmount"); ttl += amt; amt = dw_pitem.GetItemDouble(row, L"PlateFee"); platefee = platefee + amt; } dw_paper.SetItemDouble(1, L"Amount", ttl); dw_paper.SetItemDouble(1, L"PlateFee", platefee); //sum nopapercard ttl = 0.0; for (row = 1; row <= dw_pitem1.GetRowCount(); row++) { amt = dw_pitem1.GetItemDouble(row, L"BuyAmount"); ttl += amt; amt = dw_pitem1.GetItemDouble(row, L"MouldFee"); mouldfee += amt; } dw_process.SetItemDouble(1, L"Amount", ttl); dw_process.SetItemDouble(1, L"MouldFee", mouldfee); return 1; } int RecalcAmount(xstring PONo) { int row = 1; double ttl = 0.0; double amt = 0.0; double platefee = 0; double mouldfee = 0; //sum papercard xdwtable dw_pitem = dw_paper.FindDwTable(L"PItem"); xdwtable dw_pitem1 = dw_process.FindDwTable(L"PItem"); for (row = 1; row <= dw_pitem.GetRowCount(); row++) { if (dw_pitem.GetItemString(row, L"PONo").trim() != PONo) continue; amt = dw_pitem.GetItemDouble(row, L"BuyAmount"); ttl += amt; amt = dw_pitem.GetItemDouble(row, L"PlateFee"); platefee += amt; } //sum nopapercard for (row = 1; row <= dw_pitem1.GetRowCount(); row++) { if (dw_pitem1.GetItemString(row, L"PONo").trim() != PONo) continue; amt = dw_pitem1.GetItemDouble(row, L"BuyAmount"); ttl += amt; amt = dw_pitem1.GetItemDouble(row, L"MouldFee"); mouldfee += amt; } for (row = 1; row <= dw_polist.GetRowCount(); row++) { if (dw_polist.GetItemString(row, L"PONo").trim() == PONo) { //trace(ttl.toString()); dw_polist.SetItemDouble(row, L"Amount", ttl); dw_polist.SetItemDouble(row, L"PlateFee", platefee); dw_polist.SetItemDouble(row, L"MouldFee", mouldfee); break; } } return 1; } int RecalcSupplierID(xstring PONo) { int row = 1; xstring SupplierID = L""; xstring SupplierIDName = L""; //sum papercard xdwtable dw_pitem = dw_paper.FindDwTable(L"PItem"); xdwtable dw_pitem1 = dw_process.FindDwTable(L"PItem"); for (row = 1; row <= dw_pitem.GetRowCount(); row++) { if (dw_pitem.GetItemString(row, L"PONo").trim() != PONo) continue; SupplierID = dw_pitem.GetItemString(row, L"SupplierID"); SupplierIDName = dw_pitem.GetItemDisplayString(row, L"SupplierID"); } for (row = 1; row <= dw_pitem1.GetRowCount(); row++) { if (dw_pitem1.GetItemString(row, L"PONo").trim() != PONo) continue; SupplierID = dw_pitem1.GetItemString(row, L"SupplierID"); SupplierIDName = dw_pitem1.GetItemDisplayString(row, L"SupplierID"); } for (row = 1; row <= dw_polist.GetRowCount(); row++) { if (dw_polist.GetItemString(row, L"PONo").trim() == PONo) { dw_polist.SetItemString(row, L"SupplierID", SupplierID); dw_polist.SetItemDisplayString(row, L"SupplierID", SupplierIDName); break; } } return 1; } int AddPO() { int row = dw_polist.InsertRow(0); xaserverarg arg = GetArg(); xstring SONo = arg.GetArgString(L"SONo"); xstring SOID = SaleOrderView::GetSOID(SONo); xstring sdate = publiccode::GetCurrentDate(); dw_polist.SetItemString(row, L"PODate", sdate); dw_polist.SetItemString(row, L"PONo", MakePONo(row)); dw_polist.SetItemString(row, L"SOID", SOID); xstring suserid = publiccode::GetUser().id; xstring susername = publiccode::GetUser().name; KXMLDOMElement ele = dw_polist.GetRowElement(row); ele.setAttribute(L"guid", SaleOrderView::GetGuid()); dw_polist.SetItemString(row, L"POType", L"~¸Sa"); dw_polist.SetItemString(row, L"CurrencyCode", L"RMB"); dw_polist.SetItemString(row, L"Status", L"1"); dw_polist.SetItemDisplayString(row, L"Status", L"e°^ú"); dw_polist.SetItemString(row, L"CreatorID", suserid); dw_polist.SetItemDisplayString(row, L"CreatorID", susername); dw_polist.SetItemString(row, L"BuyerID", L"E9E3C542-062C-4957-B8F4-9B92C3E351FC"); dw_polist.SetItemDisplayString(row, L"BuyerID", L"[lâ[¶\OsÛQúSãg –PQlSø"); return 1; } int DeleteItem(xstring PONo) { int row = 0; //sum papercard for (row = dw_list.GetRowCount(); row >= 1; row--) { if (dw_list.GetItemString(row, L"PONo").trim() != PONo) continue; dw_list.DeleteRow(row); } //sum nopapercard for (row = dw_list1.GetRowCount(); row >= 1; row--) { if (dw_list1.GetItemString(row, L"PONo").trim() != PONo) continue; dw_list1.DeleteRow(row); } //clear pono xdwtable dw_pitem = dw_paper.FindDwTable(L"PItem"); xdwtable dw_pitem1 = dw_process.FindDwTable(L"PItem"); for (row = dw_pitem.GetRowCount(); row >= 1; row--) { if (dw_pitem.GetItemString(row, L"PONo").trim() != PONo) continue; dw_pitem.SetItemString(row, L"PONo", L""); dw_pitem.SetItemString(row, L"POID", L""); } for (row = dw_pitem1.GetRowCount(); row >= 1; row--) { if (dw_pitem1.GetItemString(row, L"PONo").trim() != PONo) continue; dw_pitem1.SetItemString(row, L"PONo", L""); dw_pitem1.SetItemString(row, L"POID", L""); } return 1; } int DeleteItemEx(xstring PONo) { int row = 0; xdwtable dw_pitem = dw_process.FindDwTable(L"PItem"); for (row = dw_list.GetRowCount(); row >= 1; row--) { if (dw_list.GetItemString(row, L"PONo").trim() != PONo) continue; dw_list.SetItemString(row, L"PONo", L""); dw_list.SetItemString(row, L"POID", L""); } dw_pitem = dw_paper.FindDwTable(L"PItem"); for (row = dw_pitem.GetRowCount(); row >= 1; row--) { if (dw_pitem.GetItemString(row, L"PONo").trim() != PONo) continue; dw_pitem.SetItemString(row, L"PONo", L""); dw_pitem.SetItemString(row, L"POID", L""); } return 1; } int ClearAdvance() { for (int row = dw_advance.GetRowCount(); row > 0; row--) { dw_advance.DeleteRow(row); } dw_advance.Redraw(); return 1; } int DeletePO() { int row = dw_polist.GetRow(); if (row > 0 || row <= dw_polist.GetRowCount()) { xstring PONo = dw_polist.GetItemString(row, L"PONo").trim(); int MB_OKCANCEL = 1; int IDOK = 1; int ret =MessageBox(GetHWND(), L"xn‹¤R –d‘Ǎ-‹¢SU" + PONo + L"?", L"cÐy:", MB_OKCANCEL); if (ret == IDOK) { DeleteItem(PONo); dw_polist.DeleteRow(0); ClearAdvance(); } } return 1; } int OpenPO() { int row = dw_polist.GetRow(); if (row < 1 || row > dw_polist.GetRowCount()) return 1; xstring PONo = dw_polist.GetItemString(row, L"PONo"); HCURSOR hCursor = xutil::SetCursorWait(); xaserverarg arg; arg.AddArg(L"PONo", PONo); OpenWindow(L"dev:xpage[PO.maint.base.vx]", arg); xutil::RestoreCursor(hCursor); return 1; } int AddItem(xdwgrid dw_obj) { /* dw_polist = GetControl(L"dw_polist"); int prow = dw_polist.GetRow(); if(prow <1 || prow > dw_polist.GetRowCount()) { alert(L"‹÷QHXžR NN*‘Ǎ-‹¢SU!"); return 1; } xstring supplier = dw_polist.GetItemString(prow,L"SupplierID"); if(supplier==L"") { alert(L"‹÷QHc[š‘Ǎ-‹¢SUv„O›^”UF!"); return 1; } xstring PONo = dw_polist.GetItemString(prow,L"PONo"); if(PONo==L"" || PONo.right(1)==L".") { alert(L"‹÷QHxn‹¤‘Ǎ-‹¢SUS÷!"); return 1; } xstring POID; KXMLDOMElement ele = dw_polist.GetRowElement(prow); POID = ele.getAttribute(L"guid"); ele.Release(); */ int p = GetArg(); OpenWindow(L"dev:xpage[select.item.so.vx]", p); xaserverarg arg = GetArg(); xstring str = arg.GetArgString(L"items"); if (str != L"") { xml x; x.loadXML(str); AddItems(dw_obj, x); } return 1; } int AddItems(xdwgrid dw_obj, xml x) { if (!x) return 1; KXMLDOMNodeList items = x.selectNodes(L"data/Item"); int len = items.length(); int row = 0; for (int i = 0; i < len; i++) { if (i == 0 && dw_obj.GetRowCount() > 0 && dw_obj.GetItemString(dw_obj.GetRowCount(), L"GoodsNo") == L"") { row = dw_obj.GetRowCount(); } else { row = dw_obj.InsertRow(0); } KXMLDOMNode t = items.item(i); //dw_obj.SetItemString(row,L"PONo",dw_polist.GetItemString(prow,L"PONo")); //dw_obj.SetItemString(row,L"POID",POID); //dw_obj.SetItemString(row,L"SupplierID",dw_polist.GetItemString(prow,L"SupplierID")); //dw_obj.SetItemDisplayString(row,L"SupplierID",dw_polist.GetItemDisplayString(prow,L"SupplierID")); //trace(L"@@@@"+row.toString()+L"@@@@"); if (t.selectSingleNode(L"@guid"))dw_obj.SetItemString(row, L"SOLineID", t.selectSingleNode(L"@guid").text()); if (t.selectSingleNode(L"GoodsNo"))dw_obj.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text()); if (t.selectSingleNode(L"Quantity"))dw_obj.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"Quantity").text()); if (t.selectSingleNode(L"Quantity"))dw_obj.SetItemString(row, L"BuyQuantity", t.selectSingleNode(L"Quantity").text()); if (t.selectSingleNode(L"EName"))dw_obj.SetItemString(row, L"CName", t.selectSingleNode(L"EName").text()); if (t.selectSingleNode(L"CustomerItemNo"))dw_obj.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text()); if (t.selectSingleNode(L"ItemID"))dw_obj.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text()); if (t.selectSingleNode(L"SOLineID"))dw_obj.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text()); //if(t.selectSingleNode(L"POSupplierIDAddress"))dw_obj.SetItemString(row,L"DeliveryAddr",t.selectSingleNode(L"POSupplierIDAddress").text()); if (dw_obj == dw_list)dw_obj.SetItemString(row, L"BOMPart", L"~¸Sa"); //else //dw_obj.SetItemString(row,L"BOMPart",dw_polist.GetItemString(prow,L"POType")); } return 1; } int DeleteItem(xdwgrid dw_obj) { dw_obj.DeleteRow(0); return 1; } int AddItemEx(xdwtable dw_obj) { /* dw_polist = GetControl(L"dw_polist"); int prow = dw_polist.GetRow(); if(prow <1 || prow > dw_polist.GetRowCount()) { alert(L"‹÷QHXžR NN*‘Ǎ-‹¢SU!"); return 1; } xstring supplier = dw_polist.GetItemString(prow,L"SupplierID"); if(supplier==L"") { alert(L"‹÷QHc[š‘Ǎ-‹¢SUv„O›^”UF!"); return 1; } xstring PONo = dw_polist.GetItemString(prow,L"PONo"); if(PONo==L"" || PONo.right(1)==L".") { alert(L"‹÷QHxn‹¤‘Ǎ-‹¢SUS÷!"); return 1; } xstring POID; KXMLDOMElement ele = dw_polist.GetRowElement(prow); POID = ele.getAttribute(L"guid"); ele.Release(); */ int prow = 0; xdwtable dw_pitem = dw_obj.FindDwTable(L"PItem"); xdwtable dw_item = dw_obj.FindDwTable(L"Item"); xdwtable dw = dw_obj.GetCurTable(); if (!dw) { alert(L"‹÷ N-ˆL!"); return 1; } if (dw.GetDwName() == L"PItem") { dw_pitem.InsertGroupRow(dw_item.GetRow(), 0); prow = dw_pitem.GetGroupRowCount(dw_item.GetRow()) + dw_pitem.GetGroupStartRow(dw_item.GetRow()) - 1; dw_pitem.SetItemString(prow, L"BOMRate", L"1:1"); dw_pitem.SetItemString(prow, L"BuyQuantity", dw_item.GetItemString(dw_item.GetRow(), L"GdnQuantity")); if (dw_obj == dw_paper) { dw_pitem.SetItemString(prow, L"BOMPart", L"~¸Sa"); //trace(L"########"+dw_pitem.GetItemString(dw_pitem.GetRow(),L"DeliveryAddr")+L"########"); dw_pitem.SetItemString(prow, L"DeliveryAddr", dw_pitem.GetItemString(dw_pitem.GetRow(), L"DeliveryAddr")); //dw_pitem.SetItemString(prow,L"DeliveryFactory",dw_pitem.GetItemString(dw_pitem.GetRow(),L"DeliveryFactory")); dw_pitem.SetItemString(prow, L"SOSupplierID", dw_pitem.GetItemString(dw_pitem.GetRow(), L"SOSupplierID")); } return 1; } int p = GetArg(); OpenWindow(L"dev:xpage[select.item.so.vx]", p); xaserverarg arg = GetArg(); xstring str = arg.GetArgString(L"items"); if (str != L"") { xml x; x.loadXML(str); AddItems(dw_obj, x); } return 1; } int AddItems(xdwtable dw_obj, xml x) { xdwtable dw_pitem = dw_obj.FindDwTable(L"PItem"); xdwtable dw_item = dw_obj.FindDwTable(L"Item"); KXMLDOMNodeList items = x.selectNodes(L"data/Item"); int len = items.length(); int row = 0; for (int i = 0; i < len; i++) { if (i == 0 && dw_item.GetRowCount() > 0 && dw_item.GetItemString(dw_item.GetRowCount(), L"GoodsNo") == L"") { row = dw_item.GetRowCount(); } else { row = dw_item.InsertRow(0); } KXMLDOMNode t = items.item(i); if (t.selectSingleNode(L"ShortName"))dw_item.SetItemString(row, L"ShortName", t.selectSingleNode(L"ShortName").text()); if (t.selectSingleNode(L"CustomerPONo"))dw_item.SetItemString(row, L"CustomerPONo", t.selectSingleNode(L"CustomerPONo").text()); if (t.selectSingleNode(L"SalesPersonID"))dw_item.SetItemString(row, L"SalesPersonID", t.selectSingleNode(L"SalesPersonID").text()); if (t.selectSingleNode(L"SalesPersonID/@_displaystring"))dw_item.SetItemString(row, L"SalesPersonID", t.selectSingleNode(L"SalesPersonID/@_displaystring").text()); if (t.selectSingleNode(L"Merchandiser"))dw_item.SetItemString(row, L"Merchandiser", t.selectSingleNode(L"Merchandiser").text()); if (t.selectSingleNode(L"Merchandiser/@_displaystring"))dw_item.SetItemDisplayString(row, L"Merchandiser", t.selectSingleNode(L"Merchandiser/@_displaystring").text()); if (t.selectSingleNode(L"@guid"))dw_item.SetItemString(row, L"SOLineID", t.selectSingleNode(L"@guid").text()); if (t.selectSingleNode(L"GoodsNo"))dw_item.SetItemString(row, L"GoodsNo", t.selectSingleNode(L"GoodsNo").text()); if (t.selectSingleNode(L"Quantity"))dw_item.SetItemString(row, L"GDNQuantity", t.selectSingleNode(L"Quantity").text()); if (t.selectSingleNode(L"CName"))dw_item.SetItemString(row, L"CName", t.selectSingleNode(L"CName").text()); if (t.selectSingleNode(L"CustomerItemNo"))dw_item.SetItemString(row, L"CustomerItemNo", t.selectSingleNode(L"CustomerItemNo").text()); if (t.selectSingleNode(L"ItemID"))dw_item.SetItemString(row, L"ItemID", t.selectSingleNode(L"ItemID").text()); if (t.selectSingleNode(L"SOLineID"))dw_item.SetItemString(row, L"SOLineID", t.selectSingleNode(L"SOLineID").text()); if (t.selectSingleNode(L"PackingRate"))dw_item.SetItemString(row, L"PackingRate", t.selectSingleNode(L"PackingRate").text()); if (t.selectSingleNode(L"InnerQty"))dw_item.SetItemString(row, L"InnerQty", t.selectSingleNode(L"InnerQty").text()); if (t.selectSingleNode(L"ScheduleShipDate"))dw_item.SetItemString(row, L"ScheduleShipDate", t.selectSingleNode(L"ScheduleShipDate").text()); if (dw_obj == dw_paper)dw_item.SetItemString(row, L"BOMPart", L"~¸Sa"); int prow = dw_pitem.GetGroupStartRow(row); if (dw_obj == dw_paper)dw_pitem.SetItemString(prow, L"BOMPart", L"~¸Sa"); dw_pitem.SetItemString(prow, L"BOMRate", L"1:1"); if (t.selectSingleNode(L"Quantity"))dw_pitem.SetItemString(prow, L"BuyQuantity", t.selectSingleNode(L"Quantity").text()); if (t.selectSingleNode(L"PackingMethod"))dw_pitem.SetItemString(prow, L"PackingMethod", t.selectSingleNode(L"PackingMethod").text()); if (t.selectSingleNode(L"POSupplierIDAddress"))dw_pitem.SetItemString(prow, L"DeliveryAddr", t.selectSingleNode(L"POSupplierIDAddress").text()); if (dw_obj == dw_process) { KXMLDOMNodeList poitems = t.selectNodes(L"PO/Item"); int count = poitems.length(); for (int k = 0; k < count; k++) { if (k != 0) dw_pitem.InsertGroupRow(row, 0); int row1 = dw_pitem.GetGroupStartRow(row) + k; KXMLDOMNode tp = poitems.item(k); if (tp.selectSingleNode(L"SupplierID"))dw_pitem.SetItemString(row1, L"SupplierID", tp.selectSingleNode(L"SupplierID").text()); if (tp.selectSingleNode(L"SupplierID/@_displaystring"))dw_pitem.SetItemDisplayString(row1, L"SupplierID", tp.selectSingleNode(L"SupplierID/@_displaystring").text()); if (tp.selectSingleNode(L"BOMType"))dw_pitem.SetItemString(row1, L"BOMPart", tp.selectSingleNode(L"BOMType").text()); if (tp.selectSingleNode(L"POPrice"))dw_pitem.ItemChangeTo(row1, L"BuyUnitPrice", tp.selectSingleNode(L"POPrice").text()); if (tp.selectSingleNode(L"PriceType"))dw_pitem.SetItemString(row1, L"PriceType", tp.selectSingleNode(L"PriceType").text()); if (tp.selectSingleNode(L"productdesc"))dw_pitem.SetItemString(row1, L"TechNote", tp.selectSingleNode(L"productdesc").text()); } } /*if(dw_obj == dw_paper) { xdwtable PItem = dw_process.FindDwTable(L"PItem"); for(int row2 = 1; row2 <=PItem.GetRowCount(); row2++) { xstring BOMPart = PItem.GetItemString(row2,L"BOMPart"); xstring SupplierID = PItem.GetItemString(row,L"SupplierID"); //trace(L"SupplierID++++L"+SupplierID); if(BOMPart == L"bTÁ") { trace(L"----=================================L"); if(SupplierID !=L"") { xml x1 = ViewObject::RetrieveData(L"/sale/data/trade.view/habit/quotecustomer/Contact",L"CustomerID", SupplierID); if(x1.selectSingleNode(L"data/item/DeliveryAddr")) xstring DeliveryAddr = x1.selectSingleNode(L"data/item/DeliveryAddr").text(); //dw_pitem.SetItemString(dw_pitem.GetRowCount(),L"SupplierID",SupplierID); dw_pitem.SetItemString(dw_pitem.GetRowCount(),L"DeliveryAddr",DeliveryAddr); }else { dw_pitem.SetItemString(dw_pitem.GetRowCount(),L"DeliveryAddr",L""); } //trace(PItem.GetItemString(row2,L"address")); for(int row3 = 1; row3 <=dw_supplier.GetRowCount(); row3++) { xstring PartyID = dw_supplier.GetItemString(row3,L"PartyID"); if(PartyID == SupplierID) { dw_pitem.SetItemString(dw_pitem.GetRowCount(),L"SOSupplierID",dw_supplier.GetGuid(row3)); } } break; } } }*/ //continue; //break; } return 1; } int DeleteItemEx(xdwtable dw_obj) { xdwtable dw = dw_obj.GetCurTable(); xstring dw_n = dw.GetDwName(); xdwtable dw_term = dw_obj.FindDwTable(L"PItem"); xdwtable dw_item = dw_obj.FindDwTable(L"Item"); int row = 0; xstring col = dw_item.GetColumnName(dw_item.GetColumn()); trace(col); if (col != L"CName") { if (dw_n == L"Item") { row = dw_term.GetGroupStartRow(dw_item.GetRow()); xstring BuyQuantity = dw_term.GetItemString(row, L"BuyQuantity"); if (BuyQuantity != L"") { alert(L"QHR –d‘Ǎ-f~Æÿ QR –dN;Oá`o"); return 1; } } if (dw_n == L"PItem") { xstring PONo = dw_term.GetItemString(row, L"PONo"); dw.DeleteRow(0); RecalcAmount(); if (PONo != L"") RecalcAmount(PONo); } else { dw.DeleteRow(0); } } return 1; } int OnTech(xdwtable dw_obj) { xdwtable dw_term = dw_obj.FindDwTable(L"PItem"); xaserverarg arg; int row = dw_term.GetRow(); if (row < 1) return 0; xstring str = dw_term.GetItemString(row, L"TechNote"); arg.AddArg(L"value", str); OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg); if (arg.GetArgString(L"comdid") == L"xmOK") { str = arg.GetArgString(L"value"); dw_term.AcceptText(); dw_term.SetItemString(row, L"TechNote", str); //dw_term.Redraw(); } return 0; } int OnTech2(xdwtable dw_obj) { xdwtable dw_term = dw_obj.FindDwTable(L"PItem"); xaserverarg arg; int row = dw_term.GetRow(); if (row < 1) return 0; xstring str = dw_term.GetItemString(row, L"Remarks"); arg.AddArg(L"value", str); OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg); if (arg.GetArgString(L"comdid") == L"xmOK") { str = arg.GetArgString(L"value"); dw_term.AcceptText(); dw_term.SetItemString(row, L"Remarks", str); //dw_term.Redraw(); } return 0; } int OnTech3(xdwtable dw_obj) { xdwtable dw_term = dw_obj.FindDwTable(L"PItem"); xaserverarg arg; int row = dw_term.GetRow(); if (row < 1) return 0; xstring str = dw_term.GetItemString(row, L"RemarksEx"); arg.AddArg(L"value", str); OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg); if (arg.GetArgString(L"comdid") == L"xmOK") { str = arg.GetArgString(L"value"); dw_term.AcceptText(); dw_term.SetItemString(row, L"RemarksEx", str); //dw_term.Redraw(); } return 0; } int OnRemarksSize(xdwtable dw_obj) { xdwtable dw_term = dw_obj.FindDwTable(L"PItem"); xaserverarg arg; int row = dw_term.GetRow(); if (row < 1) return 0; xstring str = dw_term.GetItemString(row, L"RemarksSize"); arg.AddArg(L"value", str); OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg); if (arg.GetArgString(L"comdid") == L"xmOK") { str = arg.GetArgString(L"value"); dw_term.AcceptText(); dw_term.SetItemString(row, L"RemarksSize", str); //dw_term.Redraw(); } return 0; } int OnRemarks(xdwtable dw_obj) { xdwtable dw_term = dw_obj.FindDwTable(L"PItem"); xaserverarg arg; int row = dw_term.GetRow(); if (row < 1) return 0; xstring str = dw_term.GetItemString(row, L"Remarks"); arg.AddArg(L"value", str); OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg); if (arg.GetArgString(L"comdid") == L"xmOK") { str = arg.GetArgString(L"value"); dw_term.AcceptText(); dw_term.SetItemString(row, L"Remarks", str); //dw_term.Redraw(); } return 0; } int AddItem2() { int row = dw_polist.GetRow(); xstring PONo = dw_polist.GetItemString(row, L"PONo"); //alert(PONo); xml x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/po/advanceEx", L"PONo", PONo); //alert(x.xml()); KXMLDOMNodeList items = x.selectNodes(L"PO/item"); KXMLDOMNode t = items.item(0); int row1 = dw_advance.InsertRow(0); if (t.selectSingleNode(L"CustomerPONo")) dw_advance.SetItemString(row1, L"CustomerPONo", t.selectSingleNode(L"CustomerPONo").text()); if (t.selectSingleNode(L"ShortName")) dw_advance.SetItemString(row1, L"ShortName", t.selectSingleNode(L"ShortName").text()); if (t.selectSingleNode(L"POID")) dw_advance.SetItemString(row1, L"POID", t.selectSingleNode(L"POID").text()); return 1; } int DeleteItem2() { int row = dw_advance.GetRow(); dw_advance.DeleteRow(row); return 1; } int SplitPO() { xdwtable dw_pitem = dw_process.FindDwTable(L"PItem"); xdwtable dw = dw_process.GetCurTable(); if (dw.GetDwName() != L"PItem") { alert(L"‹÷ N-UFTÁˆL!"); return 0; } int row = dw_pitem.GetRow(); xstring PONo = dw_pitem.GetItemString(row, L"PONo"); int MB_OKCANCEL = 1; int IDOK = 1; int ret = MessageBox(GetHWND(), L"xn‹¤1y»‘Ǎ-‹¢SU" + PONo + L"?", L"cÐy:", MB_OKCANCEL); if (ret != IDOK) { return 0; } for (int row1 = 1; row1 <= dw_polist.GetRowCount(); row1++) { xstring POID1 = dw_polist.GetRowElement(row1).getAttribute(L"guid"); xstring POID2 = dw_pitem.GetItemString(row, L"POID"); if (POID1 == POID2) { double amount = dw_polist.GetItemDouble(row1, L"Amount") - dw_pitem.GetItemDouble(row, L"BuyAmount"); dw_polist.SetItemDouble(row1, L"Amount", amount); amount = dw_polist.GetItemDouble(row1, L"Amount"); if (amount <= 0.00) { dw_polist.DeleteRow(row1); ClearAdvance(); } break; } } dw_pitem.SetItemString(row, L"PONo", L""); dw_pitem.SetItemString(row, L"POID", L""); OnSave(); return 1; } int SplitPOOne() { xdwtable dw_pitem = dw_paper.FindDwTable(L"PItem"); xdwtable dw = dw_paper.GetCurTable(); if (dw.GetDwName() != L"PItem") { alert(L"‹÷ N-UFTÁˆL!"); return 0; } int row = dw_pitem.GetRow(); xstring PONo = dw_pitem.GetItemString(row, L"PONo"); int MB_OKCANCEL = 1; int IDOK = 1; int ret = MessageBox(GetHWND(), L"xn‹¤1y»‘Ǎ-‹¢SU" + PONo + L"?", L"cÐy:", MB_OKCANCEL); if (ret != IDOK) { return 0; } for (int row1 = 1; row1 <= dw_polist.GetRowCount(); row1++) { xstring POID2 = dw_pitem.GetItemString(row, L"POID"); xstring POID1 = dw_polist.GetRowElement(row1).getAttribute(L"guid"); if (POID1 == POID2) { double amount = dw_polist.GetItemDouble(row1, L"Amount") - dw_pitem.GetItemDouble(row, L"BuyAmount"); dw_polist.SetItemDouble(row1, L"Amount", amount); amount = dw_polist.GetItemDouble(row1, L"Amount"); if (amount <= 0.00) { dw_polist.DeleteRow(row1); ClearAdvance(); } break; } } dw_pitem.SetItemString(row, L"PONo", L""); dw_pitem.SetItemString(row, L"POID", L""); OnSave(); return 1; } int ProcessUsedArg(xaserverarg arg) { arg.AddArg(L"EntityID", GetEntityID(1)); return 1; } xstring GetEntityName(int pr) { return L"SaleItem3"; } xstring GetEntityID(int pr) { /*xdwtable dw_item = dw_process.FindDwTable(L"Item"); int row = dw_item.GetRow(); xstring id=dw_item.GetGuid(row); return id;*/ xaserverarg arg = GetArg(); return arg.GetArgString(L"EntityID"); } //T}NäSÑ^Qýep int OnCmdDispatch(xstring comdid) { xdwtable dw_cur; if (comdid == L"xmSave") { return OnSave(); } if (comdid == L"xmWhichList") { return OnWhichList(); } else if (comdid == L"xmTech") { return OnTech(dw_process); } else if (comdid == L"xmTech2") { return OnTech2(dw_process); } else if (comdid == L"xmTech3") { return OnTech3(dw_process); } else if (comdid == L"RemarksSize") { return OnRemarksSize(dw_paper); } else if (comdid == L"Remarks") { return OnRemarks(dw_paper); } else if (comdid == L"xmPaperAll") { xdwtable dw_item = dw_paper.FindDwTable(L"Item"); if (dw_item.GetRowCount() == 1 && dw_item.GetItemString(1, L"GoodsNo") == L"") { xaserverarg arg1 = GetArg(); xstring SONo = arg1.GetArgString(L"SONo"); xml x = SaleOrderView::GetMaintFormForItemList(SONo); AddItems(dw_paper, x); } return 1; } else if (comdid == L"xmAddRow") { AddItemEx(dw_paper); return 1; } else if (comdid == L"xmDeleteRow") { DeleteItemEx(dw_paper); return 1; } else if (comdid == L"xmAddRow1") { /*dw_cur = dw_process.GetCurTable(); if(dw_cur.GetDwName()==L"Item") return 0; dw_cur.InsertRow(-1); return 1;*/ //return AddItem(dw_list1); return AddItemEx(dw_process); } else if (comdid == L"xmDeleteRow1") { /*dw_cur = dw_process.GetCurTable(); if(dw_cur.GetDwName()==L"Item") return 0; dw_cur.DeleteRow(0); return 1;*/ //return DeleteItem(dw_list1); return DeleteItemEx(dw_process); } else if (comdid == L"xmAddRow2") { return AddItem2(); } else if (comdid == L"xmDeleteRow2") { return DeleteItem2(); } else if (comdid == L"xmAddPO") { return AddPO(); } else if (comdid == L"xmMakePO") { int p = this; OpenWindow(L"dev:xpage[MakeAllPOEx.PO.vx]", p); return 1; } else if (comdid == L"xmSplitPOOne") { return SplitPOOne(); } else if (comdid == L"xmInsertPO") { p = this; xdwtable dw_pitem = dw_process.FindDwTable(L"PItem"); xdwtable dw = dw_process.GetCurTable(); if (dw.GetDwName() != L"PItem") { alert(L"‹÷ N-UFTÁˆL!"); return 1; } OpenWindow(L"dev:xpage[InsertPO.PO.vx]", p); return 1; } else if (comdid == L"xmSplitPO") { return SplitPO(); } else if (comdid == L"xmDeletePO") { xstring PONo = dw_polist.GetItemString(dw_polist.GetRow(), L"PONo"); xml supplier_x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/AdvanceNumberone", L"PONo", PONo); xstring PONoEx = supplier_x.text(); int PONoEx1 = PONoEx.toInt(); if (PONoEx1) { if (PONoEx1 > 0) { alert(L"‹¢SUg ˜„NØk>ÿ N QA‹¸R –dÿ"); return 0; } } return DeletePO(); } else if (comdid == L"xmOpenPO") { return OpenPO(); } else if (comdid == L"xmPrintPO") { return PrintPO(); } else if (comdid == L"xmHabitPO") { xaserverarg arg = GetArg(); //xstring SONo= arg.GetArgString(L"SONo"); //xstring SOID= SaleOrderView::GetSOID(SONo); //arg.AddArg(L"SOID",SOID); int k = dw_paper; int m = dw_process; arg.AddArg(L"dw_paper", xstring(k)); arg.AddArg(L"dw_nopaper", xstring(m)); OpenWindow(L"dev:xpage[Habit.PO.vx]", arg); return 1; } else if (comdid == L"xmClose") { int MB_OKCANCEL = 1; int IDOK = 1; int ret1 = MessageBox(GetHWND(), L"f/T&cÐN¤‹¢SU?", L"cÐy:", MB_OKCANCEL); if (ret1 == IDOK) { ProcessFlowAction(L"action:bill.check.agree", 1); PostMessage(GetFrameWindow().GetHWND(), 0x401, (LPARAM)L"xmRefresh", 0); } CloseWindow(); return 1; } else if (comdid == L"xmDocument") { xstring potype = dw_polist.GetItemString(dw_polist.GetRow(), L"POType"); if (potype != L"~¸Sa") OnDocumentEx(); else alert(L"~¸Saeà—[Xhc"); return 1; } else if (comdid == L"xmView") { OnView(); return 1; } else if (comdid == L"xmAddImage") { onAddImage(); return 1; } else if (comdid == L"xmLookImage") { onLookImage(); return 1; } return 0; } xstring GetSupplerID(xdwtable dw_obj, int row) { xstring supplier = L""; int i=0; for ( i = row; i >= 1; i--) { supplier = dw_obj.GetItemString(i, L"SupplierID"); if (supplier != L"") break; } if ( i > 0 && i != row && supplier != L"") dw_obj.SetItemString(row, L"SupplierID", supplier); dw_obj.SetItemDisplayString(row, L"SupplierID", dw_obj.GetItemDisplayString(i, L"SupplierID")); return supplier; } xstring GetSupplerID(int row) { xstring supplier = L""; int i = 0; for ( i = row; i >= 1; i--) { supplier = dw_list.GetItemString(i, L"SupplierID"); if (supplier != L"") break; } if ( i > 0 && i != row && supplier != L"") dw_list.SetItemString(row, L"SupplierID", supplier); dw_list.SetItemDisplayString(row, L"SupplierID", dw_list.GetItemDisplayString(i, L"SupplierID")); return supplier; } int evalPrice(xdwtable dw_obj, int row) { xstring supplier = GetSupplerID(dw_obj, row); xstring material = dw_obj.GetItemString(row, L"Material"); //xstring BuySize = dw_obj.GetItemString(row,L"BuySize"); if (supplier != L"" && material != L"") { xml x; xaserverarg arg; arg.AddArg(L"SupplierID", supplier); arg.AddArg(L"Material", material); if (getUrl(L"/sale/data/PaperCard3/lookup/item", arg.GetString(), x) == 1) { //alert(x.xml()); KXMLDOMNode n = x.selectSingleNode(L"item/UnitPrice"); if (n) dw_obj.SetItemString(row, L"StandUnitPrice", n.text()); else dw_obj.SetItemString(row, L"StandUnitPrice", L""); n = x.selectSingleNode(L"item/UnitPriceRate"); if (n) dw_obj.SetItemString(row, L"UnitPriceRate", n.text()); else dw_obj.SetItemString(row, L"UnitPriceRate", L""); evalPriceEx(dw_obj, row); } else { //alert(L"xxx1"); dw_obj.SetItemString(row, L"StandUnitPrice", L""); dw_obj.SetItemString(row, L"UnitPriceRate", L""); evalPriceEx(dw_obj, row); } } else { dw_obj.SetItemString(row, L"StandUnitPrice", L""); dw_obj.SetItemString(row, L"UnitPriceRate", L""); evalPriceEx(dw_obj, row); } return 1; } int evalPrice(int row) { xstring supplier = GetSupplerID(row); xstring material = dw_list.GetItemString(row, L"Material"); //xstring BuySize = dw_list.GetItemString(row,L"BuySize"); if (supplier != L"" && material != L"") { xml x; xaserverarg arg; arg.AddArg(L"SupplierID", supplier); arg.AddArg(L"Material", material); if (getUrl(L"/sale/data/PaperCard3/lookup/item", arg.GetString(), x) == 1) { trace(x.xml()); KXMLDOMNode n = x.selectSingleNode(L"item/UnitPrice"); if (n) dw_list.SetItemString(row, L"StandUnitPrice", n.text()); else dw_list.SetItemString(row, L"StandUnitPrice", L""); n = x.selectSingleNode(L"item/UnitPriceRate"); if (n) dw_list.SetItemString(row, L"UnitPriceRate", n.text()); else dw_list.SetItemString(row, L"UnitPriceRate", L""); evalPriceEx(row); } else { //alert(L"xxx1"); dw_list.SetItemString(row, L"StandUnitPrice", L""); dw_list.SetItemString(row, L"UnitPriceRate", L""); evalPriceEx(row); } } else { dw_list.SetItemString(row, L"StandUnitPrice", L""); dw_list.SetItemString(row, L"UnitPriceRate", L""); evalPriceEx(row); } return 1; } int evalPriceEx(xdwtable dw_obj, int row) { xstring BuySize = dw_obj.GetItemString(row, L"BuySize"); if (BuySize != L"" && BuySize.find(L"*") >= 0) { int pos = BuySize.find(L"*"); xstring w1 = BuySize.left(pos); xstring w2 = BuySize.mid(pos + 1, 9999); double d1 = w1.toDouble(); double d2 = w2.toDouble(); double d = d1 * d2 / 100.0 / 100.0; double sprice = dw_obj.GetItemDouble(row, L"StandUnitPrice"); xstring rate = dw_obj.GetItemString(row, L"UnitPriceRate"); double pricerate = 1.0; if (rate != L"") pricerate = rate.toDouble(); double packprice = dw_obj.GetItemDouble(row, L"PackUnitPrice"); double price = (sprice * pricerate + packprice) * d; //double price = sprice *pricerate * d + packprice; dw_obj.SetItemDouble(row, L"BuyUnitPrice", price); double quantity = dw_obj.GetItemDouble(row, L"BuyQuantity"); double amount = quantity * price; dw_obj.SetItemDouble(row, L"BuyAmount", amount); xstring PONo = dw_obj.GetItemString(row, L"PONo").trim(); RecalcAmount(); RecalcAmount(PONo); //dw_obj.RedrawEx(); } return 1; } int evalPriceEx(int row) { xstring BuySize = dw_list.GetItemString(row, L"BuySize"); if (BuySize != L"" && BuySize.find(L"*") >= 0) { int pos = BuySize.find(L"*"); xstring w1 = BuySize.left(pos); xstring w2 = BuySize.mid(pos + 1, 9999); double d1 = w1.toDouble(); double d2 = w2.toDouble(); double d = d1 * d2 / 100.0 / 100.0; double sprice = dw_list.GetItemDouble(row, L"StandUnitPrice"); xstring rate = dw_list.GetItemString(row, L"UnitPriceRate"); double pricerate = 1.0; if (rate != L"") pricerate = rate.toDouble(); double packprice = dw_list.GetItemDouble(row, L"PackUnitPrice"); double price = (sprice * pricerate + packprice) * d; //double price = sprice *pricerate * d + packprice; dw_list.SetItemDouble(row, L"BuyUnitPrice", price); double quantity = dw_list.GetItemDouble(row, L"BuyQuantity"); double amount = quantity * price; dw_list.SetItemDouble(row, L"BuyAmount", amount); xstring PONo = dw_list.GetItemString(row, L"PONo").trim(); //trace(L"PONO===L"+PONo); RecalcAmount(); RecalcAmount(PONo); dw_list.Redraw(); } return 1; } int evalPackPrice(xdwtable dw_obj, int row) { xstring supplier = GetSupplerID(dw_obj, row); xstring material = dw_obj.GetItemString(row, L"PaperCardPacking"); if (supplier != L"" && material != L"") { xml x; xaserverarg arg; arg.AddArg(L"SupplierID", supplier); arg.AddArg(L"Material", material); if (getUrl(L"/sale/data/PaperCard3/lookup/item", arg.GetString(), x) == 1) { KXMLDOMNode n = x.selectSingleNode(L"item/UnitPrice"); if (n) { //dw_obj.SetItemString(row,L"PackUnitPrice",n.text()); dw_obj.SetItemString(row, L"PackUnitPrice", L""); } else dw_obj.SetItemString(row, L"PackUnitPrice", L""); } else { dw_obj.SetItemString(row, L"PackUnitPrice", L""); } evalPriceEx(dw_obj, row); } //dw_obj.RedrawEx(); return 1; } int evalPackPrice(int row) { xstring supplier = GetSupplerID(row); xstring material = dw_list.GetItemString(row, L"PaperCardPacking"); if (supplier != L"" && material != L"") { xml x; xaserverarg arg; arg.AddArg(L"SupplierID", supplier); arg.AddArg(L"Material", material); if (getUrl(L"/sale/data/PaperCard3/lookup/item", arg.GetString(), x) == 1) { KXMLDOMNode n = x.selectSingleNode(L"item/UnitPrice"); if (n) { //dw_list.SetItemString(row,L"PackUnitPrice",n.text()); dw_list.SetItemString(row, L"PackUnitPrice", L""); } else dw_list.SetItemString(row, L"PackUnitPrice", L""); } else { dw_list.SetItemString(row, L"PackUnitPrice", L""); } evalPriceEx(row); } dw_list.Redraw(); return 1; } int evalBomRate(int row, xdwgrid dw_obj) { xstring value = dw_obj.GetItemString(row, L"BOMRate"); if (value == L"") return 1; int pos = value.find(L":"); if (pos < 1) pos = value.find(L"/"); double qty = dw_obj.GetItemDouble(row, L"GDNQuantity"); if (pos < 1) { double rate = value.toDouble(); if (rate != 0) dw_obj.ItemChangeTo(row, L"BuyQuantity", xstring(qty / rate)); } else { double rate1 = value.left(pos).toDouble(); xstring str = value.mid(pos + 1, 99999); double rate2 = 0; double inc = 0; xstring adjust = L""; if (str.find(L"+L") > 0 || str.find(L"-") > 0) { bool more = true; int pos1 = str.find(L"+L"); if (pos1 < 1) { pos1 = str.find(L"-"); more = false; } adjust = str.mid(pos1 + 1, 9999); if (more) inc = adjust.toDouble(); else inc = -1 * adjust.toDouble(); str = str.left(pos1); } rate2 = str.toDouble(); if (rate1 != 0) dw_obj.ItemChangeTo(row, L"BuyQuantity", xstring(qty * rate2 / rate1)); if (adjust != L"") { dw_obj.ItemChangeTo(row, L"BuyQuantity", xstring(dw_obj.GetItemDouble(row, L"BuyQuantity") + inc)); } dw_obj.Redraw(); } return 1; } int evalBomRate(int row, xdwtable dw_obj) { xstring value = dw_obj.GetItemString(row, L"BOMRate"); if (value == L"") return 1; int pos = value.find(L":"); if (pos < 1) pos = value.find(L"/"); xdwtable dw_source = dw_obj.FindDwTable(L"Item"); double qty = dw_source.GetItemDouble(dw_obj.GetGroupFromRow(row), L"GDNQuantity"); //trace(value); if (pos < 1) { double rate = value.toDouble(); if (rate != 0) dw_obj.ItemChangeTo(row, L"BuyQuantity", xstring(qty / rate)); } else { double rate1 = value.left(pos).toDouble(); xstring str = value.mid(pos + 1, 99999); double rate2 = 0; double inc = 0; xstring adjust = L""; if (str.find(L"+L") > 0 || str.find(L"-") > 0) { bool more = true; int pos1 = str.find(L"+L"); if (pos1 < 1) { pos1 = str.find(L"-"); more = false; } adjust = str.mid(pos1 + 1, 9999); if (more) inc = adjust.toDouble(); else inc = -1 * adjust.toDouble(); str = str.left(pos1); } rate2 = str.toDouble(); if (rate1 != 0) dw_obj.ItemChangeTo(row, L"BuyQuantity", xstring((qty * rate2 / rate1))); if (adjust != L"") { dw_obj.ItemChangeTo(row, L"BuyQuantity", xstring(dw_obj.GetItemDouble(row, L"BuyQuantity") + inc)); } //dw_obj.Redraw(); } return 1; } int OnItemChangedEx(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"SupplierID") UpdateSupplier(row); return 1; } int OnPaperItemChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname = hdr.colname; xstring value = hdr.data; int row = hdr.row; xdwtable dw_pitem = dw_paper.FindDwTable(L"PItem"); xdwtable dw_item = dw_paper.FindDwTable(L"Item"); if (colname == L"BOMRate") evalBomRate(row, dw_pitem); if (colname == L"GDNQuantity") { if (dw_pitem.GetItemString(row, L"BOMRate") != L"") evalBomRate(row, dw_pitem); } if (colname == L"BuyQuantity" || colname == L"BOMRate") { if (dw_pitem.GetItemString(row, L"BOMPart") == L"") dw_pitem.SetItemString(row, L"BOMPart", L"~¸Sa"); } if (colname == L"BuyAmount") { xstring PONoOne = dw_pitem.GetItemString(row, L"PONo").trim(); RecalcAmount(); RecalcAmount(PONoOne); } if (colname == L"BuyUnitPrice" || colname == L"BuyQuantity") { double price = value.toDouble(); double packprice = dw_pitem.GetItemDouble(row, L"PackUnitPrice"); double sprice = dw_pitem.GetItemDouble(row, L"StandUnitPrice"); xstring BuySize = dw_pitem.GetItemString(row, L"BuySize"); if (BuySize != L"" && BuySize.find(L"*") >= 0) { int pos = BuySize.find(L"*"); xstring w1 = BuySize.left(pos); xstring w2 = BuySize.mid(pos + 1, 9999); double d1 = w1.toDouble(); double d2 = w2.toDouble(); double d = d1 * d2 / 100.0 / 100.0; if (dw_pitem.GetItemString(row, L"StandUnitPrice") != L"") { double price3 = dw_pitem.GetItemDouble(row, L"StandUnitPrice") * 100.0; if (xstring(price3).toInt() != 0) { //double rate = (price /d - packprice)/sprice; double rate = (price / d) / sprice; dw_pitem.SetItemDouble(row, L"UnitPriceRate", rate); } else dw_pitem.SetItemString(row, L"UnitPriceRate", L""); } else dw_pitem.SetItemString(row, L"UnitPriceRate", L""); } double quantity = dw_pitem.GetItemDouble(row, L"BuyQuantity"); double packUnitPrice = dw_pitem.GetItemDouble(row, L"PackUnitPrice"); double amount = quantity * price + packUnitPrice; dw_pitem.SetItemDouble(row, L"BuyAmount", amount); xstring PONo = dw_pitem.GetItemString(row, L"PONo").trim(); RecalcAmount(); RecalcAmount(PONo); } if (colname == L"PlateFee") { xstring PONo2 = dw_pitem.GetItemString(row, L"PONo").trim(); RecalcAmount(); RecalcAmount(PONo2); } if (colname == L"BuyQuantity" || colname == L"PackUnitPrice") { double price1 = dw_pitem.GetItemDouble(row, L"BuyUnitPrice"); double quantity1 = dw_pitem.GetItemDouble(row, L"BuyQuantity"); double packUnitPrice1 = dw_pitem.GetItemDouble(row, L"PackUnitPrice"); double amount1 = quantity1 * price1 + packUnitPrice1; dw_pitem.SetItemDouble(row, L"BuyAmount", amount1); xstring PONo1 = dw_pitem.GetItemString(row, L"PONo").trim(); RecalcAmount(); RecalcAmount(PONo1); } //alert(colname); if (colname == L"Material" /*|| colname==L"BuySize"*/) { dw_pitem.SetItemString(row, L"UnitPriceRate", L""); dw_pitem.SetItemString(row, L"StandUnitPrice", L""); if (hasStandPrice)evalPrice(dw_pitem, row); } if (colname == L"PaperCardPacking") { dw_pitem.SetItemString(row, L"PackUnitPrice", L""); if (hasStandPrice)evalPackPrice(dw_pitem, row); } if (colname == L"BuySize" || colname == L"UnitPriceRate") { if (hasStandPrice)evalPriceEx(dw_pitem, row); } if (colname == L"SupplierID") { evalPackPrice(dw_pitem, row); if (hasStandPrice)evalPrice(dw_pitem, row); xstring SupplierID = dw_pitem.GetItemString(row, L"SupplierID"); /* if(SupplierID != L"") { xml x = ViewObject::RetrieveData(L"/sale/data/trade.view/habit/quotecustomer/Contact",L"CustomerID", SupplierID); if(x.selectSingleNode(L"data/item/DeliveryAddr")) xstring DeliveryAddr = x.selectSingleNode(L"data/item/DeliveryAddr").text(); dw_pitem.SetItemString(row,L"DeliveryAddr",DeliveryAddr); }*/ } if (colname == L"StandUnitPrice") { if (hasStandPrice)evalPriceEx(dw_pitem, row); } 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"BOMRate") evalBomRate(row, dw_list); if (colname == L"GDNQuantity") { if (dw_list.GetItemString(row, L"BOMRate") != L"") evalBomRate(row, dw_list); } if (colname == L"BuyUnitPrice") { double price = value.toDouble(); double packprice = dw_list.GetItemDouble(row, L"PackUnitPrice"); double sprice = dw_list.GetItemDouble(row, L"StandUnitPrice"); xstring BuySize = dw_list.GetItemString(row, L"BuySize"); if (BuySize != L"" && BuySize.find(L"*") >= 0) { int pos = BuySize.find(L"*"); xstring w1 = BuySize.left(pos); xstring w2 = BuySize.mid(pos + 1, 9999); double d1 = w1.toDouble(); double d2 = w2.toDouble(); double d = d1 * d2 / 100.0 / 100.0; double rate = (price / d - packprice) / sprice; dw_list.SetItemDouble(row, L"UnitPriceRate", rate); } double quantity = dw_list.GetItemDouble(row, L"BuyQuantity"); double amount = quantity * price; dw_list.SetItemDouble(row, L"BuyAmount", amount); xstring PONo = dw_list.GetItemString(row, L"PONo").trim(); RecalcAmount(PONo); dw_list.Redraw(); } if (colname == L"BuyQuantity") { double price1 = dw_list.GetItemDouble(row, L"BuyUnitPrice"); double quantity1 = dw_list.GetItemDouble(row, L"BuyQuantity"); double amount1 = quantity1 * price1; dw_list.SetItemDouble(row, L"BuyAmount", amount1); xstring PONo1 = dw_list.GetItemString(row, L"PONo").trim(); RecalcAmount(PONo1); dw_list.Redraw(); } //if(colname==L"" //alert(colname); if (colname == L"Material" /*|| colname==L"BuySize"*/) { dw_list.SetItemString(row, L"UnitPriceRate", L""); dw_list.SetItemString(row, L"StandUnitPrice", L""); evalPrice(row); } if (colname == L"PaperCardPacking") { dw_list.SetItemString(row, L"PackUnitPrice", L""); evalPackPrice(row); } if (colname == L"BuySize" || colname == L"UnitPriceRate") evalPriceEx(row); if (colname == L"SupplierID") { evalPackPrice(row); evalPrice(row); /*xstring SupplierID = dw_list.GetItemString(row,L"SupplierID"); if(SupplierID != L"") { xml x = ViewObject::RetrieveData(L"/sale/data/trade.view/habit/quotecustomer/Contact",L"CustomerID", SupplierID); if(x.selectSingleNode(L"data/item/DeliveryAddr")) xstring DeliveryAddr = x.selectSingleNode(L"data/item/DeliveryAddr").text(); dw_list.SetItemString(row,L"DeliveryAddr",DeliveryAddr); }*/ } return 1; } int OnProcessItemChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname = hdr.colname; xstring value = hdr.data; int row = hdr.row; xdwtable dw_object = dw_process.FindDwTable(L"PItem"); xdwtable dw_source = dw_process.FindDwTable(L"Item"); //return 1; if (colname == L"BOMRate") evalBomRate(row, dw_object); if (colname == L"GDNQuantity") { if (dw_object.GetItemString(row, L"BOMRate") != L"") evalBomRate(row, dw_object); } if (colname == L"MouldFee") { xstring PONo1 = dw_object.GetItemString(row, L"PONo").trim(); RecalcAmount(); RecalcAmount(PONo1); } /*if ( colname == L"BuyUnitPrice" || colname==L"BuyQuantity") { double price = dw_object.GetItemDouble(row,L"BuyUnitPrice");//‘Ǎ-SUN÷ double quantity = dw_object.GetItemDouble(row,L"BuyQuantity"); double amount = quantity * price; dw_object.SetItemDouble(row,L"BuyAmount",amount); xstring PONo = dw_source.GetItemString(dw_object.GetGroupFromRow(row),L"PONo").trim(); RecalcAmount(); RecalcAmount(PONo); //dw_object.Redraw(); }*/ if (colname == L"BuyItemPrice") { double buyItemPrice1 = dw_object.GetItemDouble(row, L"BuyItemPrice"); xstring PONo = dw_object.GetItemString(row, L"PONo").trim(); double quantity = dw_object.GetItemDouble(row, L"BuyQuantity"); double amount = quantity * buyItemPrice1; dw_object.SetItemDouble(row, L"BuyAmount", amount); RecalcAmount(); RecalcAmount(PONo); } if (colname == L"BuyAmount") { xstring PONoTwo = dw_object.GetItemString(row, L"PONo").trim(); RecalcAmount(); RecalcAmount(PONoTwo); } if (colname == L"BuyUnitPrice" || colname == L"OtherFee" || colname == L"DeductionFee" || colname == L"BuyQuantity") { double price1 = dw_object.GetItemDouble(row, L"BuyUnitPrice"); double x1 = dw_object.GetItemDouble(row, L"OtherFee"); double x2 = dw_object.GetItemDouble(row, L"DeductionFee"); double buyItemPrice = price1 + x1 - x2; dw_object.SetItemDouble(row, L"BuyItemPrice", buyItemPrice); double quantity1 = dw_object.GetItemDouble(row, L"BuyQuantity"); double amount1 = quantity1 * buyItemPrice; dw_object.SetItemDouble(row, L"BuyAmount", amount1); xstring PONo2 = dw_object.GetItemString(row, L"PONo").trim(); RecalcAmount(); //trace(L"PONo2====L"+PONo2); RecalcAmount(PONo2); } if (colname == L"SupplierID") { xstring PONo3 = dw_object.GetItemString(row, L"PONo").trim(); RecalcSupplierID(PONo3); } return 1; } int OnItemChanged1(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"BOMRate") evalBomRate(row, dw_list1); if (colname == L"GDNQuantity") { if (dw_list1.GetItemString(row, L"BOMRate") != L"") evalBomRate(row, dw_list1); } if (colname == L"BuyUnitPrice" || colname == L"BuyQuantity") { double price = dw_list1.GetItemDouble(row, L"BuyUnitPrice"); double quantity = dw_list1.GetItemDouble(row, L"BuyQuantity"); double amount = quantity * price; dw_list1.SetItemDouble(row, L"BuyAmount", amount); xstring PONo = dw_list1.GetItemString(row, L"PONo").trim(); RecalcAmount(PONo); dw_list1.Redraw(); } return 1; } //T}NäYtN‹Nö int OnXCommand(TEvent* evt, int param) { 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 OnOk() { return 1; } int PrintPO() { int row = dw_polist.GetRow(); if (row < 1 || row > dw_polist.GetRowCount()) return 1; KXMLDOMElement ele = dw_polist.GetRowElement(row); xstring POID = ele.getAttribute(L"guid"); //trace(L"POID:"+POID); xaserverarg& arg = *new xaserverarg; arg.AddArg(L"EntityName", L"PurchaseOrder"); arg.AddArg(L"EntityID", POID); arg.AddArg(L"EntityNo", dw_polist.GetItemString(row, L"PONo")); openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", &arg); return 1; } int OnDoubleClicked(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname = hdr.colname; int row = hdr.row; if (colname == L"PONo") { HCURSOR hCursor = xutil::SetCursorWait(); OpenPO(); xutil::RestoreCursor(hCursor); } return 1; } int OnRowChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; int row = hdr.row; HCURSOR hCursor = xutil::SetCursorWait(); xstring PONo = dw_polist.GetItemString(row, L"PONo"); //trace(PONo); xml x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/po/advance", L"PONo", PONo); if (x)dw_advance.Retrieve(x); x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/po/goods", L"PONo", PONo); if (x)dw_goods.Retrieve(x); dw_advance.Redraw(); dw_goods.Redraw(); dw_goods.SetReadOnly(true); xutil::RestoreCursor(hCursor); return 1; } int OnAdvancedChanged(TEvent* evt, LPARAM p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; xstring colname = hdr.colname; xstring value = hdr.data; int row = hdr.row; int row1 = dw_polist.GetRow(); if (colname == L"Ratio") { double ratio = dw_advance.GetItemDouble(row, L"Ratio"); double totalAdvancedMoney = dw_polist.GetItemDouble(row1, L"Amount"); double advancedMoney = totalAdvancedMoney * (ratio / 100); dw_advance.SetItemDouble(row, L"AdvancedMoney", advancedMoney); } dw_advance.Redraw(); return 1; } int OnAttachEvent() { //~Ñ[š]åQwgap¹QûN‹Nö AttachEvent(L"WM_XCOMMAND", (FEvent)&MaintPaperCardPOWin::OnXCommand); //ƒ·SÖq&p¹N‹Nöÿ u(NŽ‘Ín]åQwga AttachEvent(L"WM_SETFOCUS", (FEvent)&MaintPaperCardPOWin::OnSetFocus); AttachEvent(L"dw_list", L"DWV_ITEMCHANGED", (FEvent)&MaintPaperCardPOWin::OnItemChanged); AttachEvent(L"dw_list1", L"DWV_ITEMCHANGED", (FEvent)&MaintPaperCardPOWin::OnItemChanged1); AttachEvent(L"dw_polist", L"DWV_ITEMCHANGED", (FEvent)&MaintPaperCardPOWin::OnItemChangedEx); AttachEvent(L"dw_polist", L"DWV_DOUBLECLICKED", (FEvent)&MaintPaperCardPOWin::OnDoubleClicked); AttachEvent(L"dw_process", L"DWV_ITEMCHANGED", (FEvent)&MaintPaperCardPOWin::OnProcessItemChanged); AttachEvent(L"dw_paper", L"DWV_ITEMCHANGED", (FEvent)&MaintPaperCardPOWin::OnPaperItemChanged); AttachEvent(L"dw_polist", L"DWV_ROWFOCUSCHANGED", (FEvent)&MaintPaperCardPOWin::OnRowChanged); AttachEvent(L"dw_advance", L"DWV_ITEMCHANGED", (FEvent)&MaintPaperCardPOWin::OnAdvancedChanged); return 1; } int OnView() { xaserverarg& arg = *new xaserverarg; arg.setNativePointer(arg.CreateInstance()); xstring src = L"<ImageList><image>" + dw_polist.GetGuid(dw_polist.GetRow()) + L".jpg</image></ImageList>"; arg.AddArg(L"src", src); openUrl(L"/sale/view/SupplierV3/xpage/supplierattachment/picture", &arg); return 1; } int OnDocumentEx() { xaserverarg arg; arg.setNativePointer(arg.CreateInstance()); int row = dw_polist.GetRow(); xstring guid = dw_polist.GetGuid(row); if (guid.length() <= 0) { guid = publiccode::GetGuid(); dw_polist.SetGuid(row, guid); } arg.AddArg(L"entityid", guid); //trace(dw_polist.GetGuid(1)); OpenWindow(L"dev:xpage[maint.Document.PO.v3.vx]", arg); } int OnDocument() { if (dw_polist.GetRowCount() < 1) return 1; xstring id = dw_polist.GetGuid(dw_polist.GetRow()); xstring typ = L"supplier"; int ret1 = UpLoad(id, typ); if (ret1 == -1) return -1; if (ret1 == 0) { alert(L"N O e‡NöY1%"); return -1; } else { alert(L"N O e‡NöbRŸ"); dw_polist.SetItemString(dw_polist.GetRow(), L"OnloadFlag", L"Y"); xml x1; dw_polist.AcceptText(); dw_polist.DwUpdateAllToEx(x1); xstring val = x1.xml(); val = L"<data>" + val + L"</data>"; xaserverarg arg; arg.setNativePointer(arg.CreateInstance()); arg.AddArg(L"content", val); xurl::get(L"/sale/data/PurchaseOrder/update/polistex", arg.GetString(), x1); } return 1; } int onAddImage() { xdwtable dw_pitem = dw_paper.FindDwTable(L"PItem"); int row = dw_pitem.GetRow(); if (row < 0) { alert(L"‹÷ béR"); return 0; } xstring guid = dw_pitem.GetGuid(dw_pitem.GetRow()); if (guid.length() <= 0) { guid = publiccode::GetGuid(); dw_pitem.SetGuid(dw_pitem.GetRow(), guid); } int ret1 = UpLoad(guid, L"product"); if (ret1 == -1) return -1; if (ret1 == 0) { alert(L"N O e‡NöY1%"); return -1; } else { alert(L"N O e‡NöbRŸ"); } return 1; } int onLookImage() { xdwtable dw_pitem = dw_paper.FindDwTable(L"PItem"); int row = dw_pitem.GetRow(); xstring guid = dw_pitem.GetGuid(dw_pitem.GetRow()); HCURSOR hCursor = xutil::SetCursorWait(); xaserverarg arg; arg.AddArg(L"guid", guid); OpenWindow(L"dev:xpage[paperImage.vx]", arg); xutil::RestoreCursor(hCursor); return 1; } //--------- int UpLoad(xstring name, xstring typ) { xstring str = name.mid(0, 2); str = str.toUpper(); int ret1 = xaserver::Upload(typ + str, name + L".jpg", GetHWND(), L"", false); return ret1; } xstring OnLoadDiff() { xml x; xaserverarg arg; arg.setNativePointer(arg.CreateInstance()); //arg.AddArg(L"EntityID",maint::m_EntityID); xaserverarg parg = GetArg(); arg.AddArg(L"Type", L"SO"); arg.AddArg(L"EntityID", parg.GetArgString(L"SOID")); if (parg.GetArgString(L"SOLineID") != L"") { arg.AddArg(L"Type", L"SOLine"); arg.AddArg(L"EntityID", parg.GetArgString(L"SOLineID")); } getUrl(L"/sale/data/PurchaseOrder/pref/diffval", arg.GetString(), x); return x.xml(); } int OnRetrieveDiff() { xstring str = OnLoadDiff(); xml x; x.loadXML(str); dw_process.RetrieveDiff(x); dw_process.SetColHeaderHeight(16); dw_process.Redraw(); return 1; } int OnWhichList() { xml xp; dw_process.AcceptText(); dw_process.DwUpdateAllTo(xp); if (whichlist == 0) { dw_process = GetControl(L"dw_process"); //dw_process.openUrl(L"/sale/view/PurchaseOrder/template/item/nopapercardex"); dw_process.openUrl(L"/sale/view/PurchaseOrder/template/POItemForm"); //dw_process.SetColHeaderHeight(0); //dw_process.SetRowSelectorWidth(0); whichlist = 0; } else { dw_process = GetControl(L"dw_process"); dw_process.openUrl(L"/sale/view/PurchaseOrder/template/item/nopapercardex"); whichlist = 1; } dw_process.Retrieve(xp); dw_process.Redraw(); RecalcAmount(); return 1; } int onload() { SetArg(); dw_list = GetControl(L"dw_list"); dw_list.openUrl(L"/sale/view/PurchaseOrder/template/item/papercard"); dw_list1 = GetControl(L"dw_list1"); dw_list1.openUrl(L"/sale/view/PurchaseOrder/template/item/nopapercard"); dw_polist = GetControl(L"dw_polist"); dw_polist.openUrl(L"/sale/view/PurchaseOrder/template/purchaseorder/polist"); dw_advance = GetControl(L"dw_advance"); dw_advance.openUrl(L"/sale/view/PurchaseOrder/template/purchaseorder/POAdvance"); dw_goods = GetControl(L"dw_goods"); dw_goods.openUrl(L"/sale/view/PurchaseOrder/template/purchaseorder/POGoods"); dw_paper = GetControl(L"dw_paper"); dw_paper.openUrl(L"/sale/view/PurchaseOrder/template/item/papercardex"); dw_paper.SetRowSelectorWidth(0); dw_process = GetControl(L"dw_process"); //dw_process.openUrl(L"/sale/view/PurchaseOrder/template/item/nopapercardex"); dw_process.openUrl(L"/sale/view/PurchaseOrder/template/POItemForm"); dw_supplier = GetControl(L"dw_supplier"); dw_supplier.openUrl(L"/sale/view/PurchaseOrder/template/purchaseorder/FactoryInformation"); xaserverarg arg = GetArg(); xstring SOLineID = arg.GetArgString(L"SOLineID"); if (SOLineID != L"") { arg.AddArg(L"SONo", SaleOrderView::GetSONoByLineID(SOLineID)); vflag = L"soline"; } xstring SONo = arg.GetArgString(L"SONo"); OnAttachEvent(); SetAgent(); xstring SOID = SaleOrderView::GetSOID(SONo); arg.AddArg(L"SOID", SOID); xml x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/so/polist", L"SOID", SOID); //trace(L"====L"+x.xml()); if (x)dw_polist.Retrieve(x); x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/so/poitemlist/papercard", L"SOID", SOID); //if(x)dw_list.Retrieve(x); if (x) { //alert(SOID+L" "+x.xml()); dw_paper.Retrieve(x); } if (vflag == L"soline") { x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/so/poitemlist/nopapercard2", L"SOLineID", SOLineID); } else { x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/so/poitemlist/nopapercard", L"SOID", SOID); } if (x) { dw_process.Retrieve(x); OnRetrieveDiff(); //dw_process.SetReadOnly(true); } xdwtable dw_pitem1 = dw_process.FindDwTable(L"PItem"); /*for(int m=1;m<=dw_pitem1.GetColumnCount();m++) { xstring ChkState=dw_pitem1.GetItemString(m,L"ChkState"); xstring col = dw_pitem1.GetColumnName(m); if(ChkState !=L"1") { if(col !=L"" && col !=L"DeductionFee" && col !=L"OtherFee" && col !=L"HasVATInvoice") dw_pitem1.SetColumnProp(col,L"cellprotect",L"1"); } if(col !=L"" && col !=L"DeductionFee" && col !=L"OtherFee" && col !=L"HasVATInvoice" && col !=L"BuyUnitPrice") dw_pitem1.SetColumnProp(col,L"cellprotect",L"1"); }*/ x = ViewObject::RetrieveData(L"/sale/data/PurchaseOrder/so/SOPurchaseInfo", L"SOID", SOID); if (x)dw_supplier.Retrieve(x); dw_supplier.SetReadOnly(true); xdwtable dw_item = dw_process.FindDwTable(L"Item"); if (dw_item.GetRowCount() == 1 && dw_item.GetItemString(1, L"GoodsNo") == L"") { x = SaleOrderView::GetMaintFormForItemListForPO(SONo); AddItems(dw_process, x); } dw_polist.SetColumnState(L"SOID", false); dw_polist.SetColumnState(L"PaymentTermDesc", false); dw_list.SetColumnState(L"SOLineID", false); dw_list.SetColumnState(L"POID", false); dw_list.SetColumnState(L"BOMPart", false); dw_list.SetColumnState(L"ItemID", false); dw_polist.SetColumnState(L"OnloadFlag", false); dw_polist.SetColumnState(L"BuyerID", false); xdwtable dw_pitem3 = dw_process.FindDwTable(L"PItem"); dw_pitem3.SetColumnProp(L"BuyUnitPrice", L"cellprotect", L"1"); dw_pitem3.SetColumnProp(L"SupplierID", L"cellprotect", L"1"); dw_pitem3.SetColumnProp(L"OrigSupplierID", L"cellprotect", L"1"); dw_pitem3.SetColumnProp(L"BuyItemPrice", L"cellprotect", L"1"); dw_pitem3.SetColumnProp(L"Remarks", L"cellprotect", L"1"); dw_pitem3.SetColumnProp(L"RemarksE", L"cellprotect", L"1"); dw_list1.SetColumnState(L"SOLineID", false); dw_list1.SetColumnState(L"POID", false); dw_list1.SetColumnState(L"ItemID", false); dw_advance.SetColumnState(L"POID", false); dw_advance.SetColumnState(L"PONo", false); dw_supplier.SetColumnState(L"SOID", false); dw_supplier.SetColumnState(L"ContactID", false); dw_supplier.SetColumnState(L"PartyID", false); dw_paper.SetEditUpperMode(true); dw_process.SetEditUpperMode(true); xcell x1 = GetControl(L"dw_process"); //x1.SetColumnCount(x1.GetValidCol()); x1.SetColumnCount(29); x1 = GetControl(L"dw_paper"); //x1.SetColumnCount(x1.GetValidCol()); x1.SetColumnCount(24); xdwtable dw_pitem = dw_process.FindDwTable(L"PItem"); /*qianxj dw_list dw_pitem dw_parper dw_process dw_pitem.SetColumnProp(L"SupplierID",L"cellprotect",L"1"); dw_pitem.SetColumnProp(L"BuyQuantity",L"cellprotect",L"1"); dw_pitem.SetColumnProp(L"BuyUnitPrice",L"cellprotect",L"1"); dw_pitem.SetColumnProp(L"BOMRate",L"cellprotect",L"1"); dw_pitem.SetColumnProp(L"BOMPart",L"cellprotect",L"1"); dw_pitem.SetColumnProp(L"GDNQuantity",L"cellprotect",L"1"); */ hasStandPrice = true;//false; whichlist = 1; return 1; } int onloaded() { return 1; } };