#include #include #include #include #include #include "vbusiness/vframe/maint.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" #include "viewobject/saleorder.view.hpp" #include "viewobject/quote.view.hpp" class __declspec(dllexport) BaseMaintSOWin : public maint { xdwtable dw_props; xdwtable dw_base; xdwgrid dw_item; xnode m_agentNode; //Agent Condition public: BaseMaintSOWin(void* implPtr, HWND hWnd) :maint(implPtr, hWnd) {} public: static BaseMaintSOWin* CreateInstance(void* implPtr, void* hWnd) { BaseMaintSOWin* pWin = new BaseMaintSOWin(implPtr, (HWND)hWnd); return pWin; } int SetAgent() { 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) { bstring s = agent.xml(); m_agentNode = SetAgentNode(anode, s); } } return 1; } //½¹µã¼¤»î´¦Àíº¯Êý int OnSetFocus(TEvent* evt, LPARAM param) { //ÖØÖù¤¾ßÌõ //SetAgent(); //SetAgent(L"maint", m_EntityID); //SetAgent(L"maint",dw_base.GetGuid(0)); return 1; } xstring GetGuid() { return publiccode::GetGuid(); } xstring GetEntityData(LPARAM pr) { dw_item.AcceptText(); dw_base.AcceptText(); KXMLDOMDocument xbase ; dw_base.DwUpdateAllTo(xbase); KXMLDOMDocument xitem; dw_item.DwUpdateAllToEx(xitem); KXMLDOMElement ebase = xbase.documentElement(); if ((xstring)xitem.xml() != L"") { KXMLDOMElement eitem = xitem.selectSingleNode(L"data"); if (eitem) ebase.appendChild(eitem); } return ebase.xml(); } int DoUpdate(bool showSuccess) { dw_base.AcceptText(); dw_item.AcceptText(); if ((xstring)dw_base.GetItemString(1, L"SONo") == L"") { xstring SONo = SaleOrderView::MakeBillNo(); dw_base.SetItemString(1, L"SONo", SONo); } for (int i = 1; i <= dw_item.GetRowCount(); i++) { //should to sure not new state if (dw_item.GetItemString(i, L"SOLineNo") == L"") dw_item.SetItemString(i, L"SOLineNo", SaleOrderView::AskNo(GetServerUrl(),L"E")); if (dw_item.GetItemString(i, L"CustomerItemNo") == L"") { alert(L"ÇëÊäÈë¿Í»§Ðͺţ¡"); return 0; } } dw_item.Redraw(); if (dw_base.GetItemString(1, L"SODate").trim() == L"") { alert(L"ÇëÊäÈë¶©µ¥ÈÕÆÚ£¡"); return 0; } if (dw_base.GetItemString(1, L"CurrencyCode").trim() == L"") { alert(L"ÇëÊäÈë¼Æ¼Û»õ±Ò£¡"); return 0; } if (dw_base.GetItemString(1, L"CompanyID").trim() == L"") { alert(L"ÇëÊäÈ빫˾̧ͷ£¡"); return 0; } if (dw_base.GetItemString(1, L"PaymentTermEx").trim() == L"") { alert(L"ÇëÊäÈëÖ§¸¶Ìõ¿î£¡"); return 0; } if (dw_base.GetItemString(1, L"CustomerPONo").trim() == L"") { alert(L"ÇëÊäÈë¿Í»§PO#£¡"); return 0; } if (dw_base.GetItemString(1, L"Merchandiser").trim() == L"") { alert(L"ÇëÑ¡Ôñ¸úµ¥ÈËÔ±£¡"); return 0; } if (dw_base.GetItemString(1, L"PaymentTermEx").trim() == L"") { alert(L"ÇëÊäÈëÖ§¸¶Ìõ¿î£¡"); return 0; } if (dw_base.GetItemString(1, L"TransportMode").trim() == L"") { alert(L"ÇëÊäÈëÔËÊ䷽ʽ£¡"); return 0; } if (dw_base.GetItemString(1, L"POL").trim() == L"") { alert(L"ÇëÊäÈë³ö¿Ú¿Ú°¶£¡"); return 0; } if (dw_base.GetItemString(1, L"POD").trim() == L"") { alert(L"ÇëÊäÈëÄ¿µÄ¿Ú°¶£¡"); return 0; } if (dw_base.GetItemString(1, L"SalespersonID") != publiccode::GetUser().id) { alert(L"Ö»Äܱ£´æ±¾È˵ÄÊý¾Ý£¡"); return 0; } KXMLDOMDocument xbase; dw_base.DwUpdateAllTo(xbase); KXMLDOMDocument xitem ; dw_item.DwUpdateAllToEx(xitem); KXMLDOMElement ebase = xbase.documentElement(); KXMLDOMElement eitem = xitem.selectSingleNode(L"data"); ebase.appendChild(eitem); KXMLDOMDocument x ; x.loadXML(ebase.xml()); xaserverarg arg; arg.AddArg(L"content", x.xml()); if (xurl::get(GetServerUrl(),L"/sale/data/SaleOrder/update/base", arg.GetString(), x) != 1) { xstring error = x.text(); alert(L"err:" + error); return 0; } xstring str = x.documentElement().getAttribute(L"text"); if (str == L"true") { dw_base.ResetUpdateStatus(); dw_item.ResetUpdateStatus(); //vc.xdoc.SetXPath(L"SaleOrder/PaymentTerm"); if (showSuccess) alert(L"±£´æ³É¹¦!"); return 1; } else { alert(L"±£´æÊ§°Ü!"); return -1; } return 1; } int OnSaveEx() { DoUpdate(true); return 1; } //event int OnDWClick(TEvent* evt, int p) { DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh; xstring value = hdr->data; xstring colname = hdr->colname; if (value == L"Ö§¸¶Ìõ¿î") { //int p1 = vc.xdoc.getNativePointer(); //openUrl(L"/sale/view/SaleOrder/xpage/payment", p1); dw_base.AcceptText(); return 1; } //½»»õÆÚά»¤ if (value == L"½»»õÆÚ") { //int p2 = vc.xdoc.getNativePointer(); //openUrl(L"/sale/view/SaleOrder/xpage/delivery1", p2); dw_base.AcceptText(); dw_base.Redraw(); return 1; } if (value == L"¿Í»§ºÏͬ") { xstring deptname = publiccode::GetUser().deptname; if (deptname == L"²É¹º²¿") { return 1; } xaserverarg& arg= * new xaserverarg(); xstring SOID = dw_base.GetItemString(1, L"SOID"); if (SOID.length() <= 0) { alert(L"ÎÞ·¨ÉÏ´«£¬ÇëÖØÐ´ò¿ª¶©µ¥£¡"); return 1; } arg.AddArg(L"entityid", SOID); arg.AddArg(L"Type", L"N"); arg.AddArg(L"ApprovalStatus", dw_base.GetItemString(1, L"ApprovalStatus")); OpenWindow(L"dev:xpage[maint.Document.SO3.v3.vx]", (LPARAM) & arg); //DocCount(guid); } } /*int DocCount(xstring guid) { dw_base.AcceptText(); xdwtable dw = dw_base.FindDwTable(L"SaleOrder",0); xstring count = L"0"; xstring entityid = dw_base.GetItemString(1,L"SOID",0); if(entityid.length() <= 0) { entityid=guid; } KXMLDOMDocument x1 = ViewObject::RetrieveData(L"/sale/data/TDocument3/attachment/GetDocCountEx_s",L"entityid",entityid); trace(x1.xml()); KXMLDOMNodeList items = x1.selectNodes(L"data/Item"); KXMLDOMNode t = items.item(0); if(t.selectSingleNode(L"count"))count=t.selectSingleNode(L"count").text(); if(count==L"0") { dw_base.SetItemString(1,L"CType",L"N"); }else { dw_base.SetItemString(1,L"CType",L"Y"); } }*/ int SetSeqNo(xdwgrid dw_obj, xstring SeqNoColumn, int nRow) { if (nRow > 1) { int SeqNo = dw_obj.GetItemInt(nRow - 1, SeqNoColumn.c_str()); if (SeqNo != 0) SeqNo += 10; else SeqNo = nRow * 10; dw_obj.SetItemInt(nRow, SeqNoColumn.c_str(), SeqNo); } else dw_obj.SetItemInt(nRow, SeqNoColumn.c_str(), 10); return 1; } int SetRowData(int nRow, KXMLDOMElement e) { //trace(e.xml()); dw_item.SetItemString(nRow, L"SKUNo", e.getAttribute(L"SKUNo")); dw_item.SetItemString(nRow, L"ItemID", e.getAttribute(L"SKUID")); dw_item.SetItemString(nRow, L"CName", e.getAttribute(L"CName")); dw_item.SetItemString(nRow, L"EName", e.getAttribute(L"EName")); dw_item.SetItemString(nRow, L"GoodsNo", e.getAttribute(L"GoodsNo")); dw_item.SetItemString(nRow, L"CustomerItemNo", e.getAttribute(L"CustomerItemNo")); dw_item.SetItemString(nRow, L"Packing", e.getAttribute(L"Packing")); dw_item.SetItemString(nRow, L"VolumeDesc", e.getAttribute(L"VolumeDesc")); dw_item.SetItemString(nRow, L"NwPerPkg", e.getAttribute(L"NwPerPkg")); dw_item.SetItemString(nRow, L"GwPerPkg", e.getAttribute(L"GwPerPkg")); dw_item.SetItemString(nRow, L"PackingRate", e.getAttribute(L"QTYPerPkg")); dw_item.SetItemString(nRow, L"InnerQty", e.getAttribute(L"InnerQty")); dw_item.SetItemString(nRow, L"UnitCommPrice", e.getAttribute(L"UnitCommPrice")); dw_item.SetItemString(nRow, L"QuoteLineID", e.getAttribute(L"QuoteLineID")); if (e.getAttribute(L"UOMCode") == L"") { dw_item.SetItemString(nRow, L"UOMCode", L"007"); dw_item.SetItemDisplayString(nRow, L"UOMCode", L"PCS"); } else { dw_item.SetItemString(nRow, L"UOMCode", e.getAttribute(L"UOMCode")); dw_item.SetItemDisplayString(nRow, L"UOMCode", e.getAttribute(L"UOMCode_display")); } if (e.getAttribute(L"KOPCode") == L"") { dw_item.SetItemString(nRow, L"KOPCode", L"120"); dw_item.SetItemDisplayString(nRow, L"KOPCode", L"CTNS"); } else { dw_item.SetItemString(nRow, L"KOPCode", e.getAttribute(L"KOPCode")); dw_item.SetItemDisplayString(nRow, L"KOPCode", e.getAttribute(L"KOPCode_display")); } dw_item.SetItemString(nRow, L"PackageL", e.getAttribute(L"PackageL")); dw_item.SetItemString(nRow, L"PackageW", e.getAttribute(L"PackageW")); dw_item.SetItemString(nRow, L"PackageH", e.getAttribute(L"PackageH")); dw_item.SetItemString(nRow, L"UnitPrice", e.getAttribute(L"UnitPrice")); // dw_item.SetItemDisplayString(nRow,L"PriceType",e.getAttribute(L"PriceType")); dw_item.SetItemDisplayString(nRow, L"POCreatorID", e.getAttribute(L"POCreatorID._displaystring")); dw_item.SetItemString(nRow, L"POCreatorID", e.getAttribute(L"POCreatorID")); return 1; } int ImportProductByText(xstring str) { xstring CustomerID = dw_base.GetItemString(1, L"CustomerID"); //KXMLDOMDocument x = QuoteView::LookupProductsByText(str,CustomerID); //trace(str+L"--" + CustomerID); KXMLDOMDocument x = ViewObject::RetrieveData(GetServerUrl(),L"/sale/data/SaleOrder/lookup/productsex", L"str", str, L"CustomerID", CustomerID); if (!x) return 1; KXMLDOMNodeList items = x.selectNodes(L"/Items/Item"); int len = items.length(); for (int i = 0; i < len; i++) { KXMLDOMElement e = items.item(i); dw_item.InsertRow(0); int nRow = dw_item.GetRowCount(); SetSeqNo(dw_item, L"LineNo", nRow); dw_item.SetItemString(nRow, L"KOPCode", L"120"); dw_item.SetItemDisplayString(nRow, L"KOPCode", L"CTNS"); dw_item.SetItemString(nRow, L"UOMCode", L"007"); dw_item.SetItemDisplayString(nRow, L"UOMCode", L"PCS"); SetRowData(nRow, e); } dw_item.Redraw(); int row = dw_item.GetRow(); if (row >= 1) { ximageview im = GetControl(L"im1"); im.Reset(); xstring skuno = dw_item.GetItemString(row, L"SKUNo"); OnShowImage(skuno, row); im.Redraw(); } return 1; } int ReSeqNo(xstring SeqNoColumn) { for (int i = 1; i <= dw_item.GetRowCount(); i++) { dw_item.SetItemInt(i, SeqNoColumn.c_str(), (i * 10)); } dw_item.Redraw(); return 1; } int OnItemChanged(TEvent* evt, int p) { DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh; xstring colname = hdr->colname; xstring value = hdr->data; int row = hdr->row; if (colname == L"GoodsNo" && value != L"") { KXMLDOMDocument x = QuoteView::LookupProductsByText(value); if (!x) return 1; KXMLDOMNodeList items = x.selectNodes(L"/Items/Item"); int len = items.length(); if (len == 0) { alert(L"Î޴˹«Ë¾ÐͺÅ!"); return 1; } if (len > 0) { KXMLDOMElement e = items.item(0); int nRow = dw_item.GetRow(); SetRowData(nRow, e); dw_item.Redraw(); } } if (colname == L"Quantity" || colname == L"PackingRate") { //¼þÊý double dqty = dw_item.GetItemDouble(row, L"Quantity"); xstring spackingrate = dw_item.GetItemString(row, L"PackingRate"); int ipack = caclPacking(dqty, spackingrate); dw_item.SetItemInt(row, L"Packages", ipack); dw_item.Redraw(); } if (colname == L"Quantity" || colname == L"UnitCommPrice") { double dqty1 = dw_item.GetItemDouble(row, L"Quantity"); double UnitCommPrice = dw_item.GetItemDouble(row, L"UnitCommPrice"); dw_item.SetItemDouble(row, L"UnitCommPriceAmount", xdouble(dqty1 * UnitCommPrice).round(2)); dw_item.Redraw(); } if (colname == L"Quantity" || colname == L"MiddlemanAmount") { double dqty2 = dw_item.GetItemDouble(row, L"Quantity"); double MiddlemanAmount = dw_item.GetItemDouble(row, L"MiddlemanAmount"); dw_item.SetItemDouble(row, L"MiddlemanAmountS", xdouble(dqty2 * MiddlemanAmount).round(2)); dw_item.Redraw(); } if (colname == L"Quantity" || colname == L"UnitPrice" || colname == L"Amount") { double ttlamt = 0; double amt; double qty = dw_item.GetItemDouble(row, L"Quantity"); double price = dw_item.GetItemDouble(row, L"UnitPrice"); if (colname != L"Amount") { amt = qty * price; dw_item.SetItemDouble(row, L"Amount", amt); dw_item.Redraw(); } for (int i = 1; i <= dw_item.GetRowCount(); i++) { amt = dw_item.GetItemDouble(i, L"Amount"); ttlamt += amt; } double OtherExpenses = dw_base.GetItemDouble(1, L"OtherExpenses"); dw_base.SetItemDouble(1, L"Amount", ttlamt + OtherExpenses); return 1; } return 1; } //¼þÊý int caclPacking(double dQty, xstring sPRate) { if (sPRate == L"" || sPRate == L"0" || sPRate == L" ") return 0; double dPackages; int iFlag; iFlag = sPRate.find(L"/", 1); if (iFlag >= 0) { xstring sBegin = sPRate.mid(0, iFlag); xstring sEnd = sPRate.mid(iFlag + 1, sPRate.length() - iFlag + 2); if (!sBegin || sBegin == L"" || sBegin == L"0" || !sEnd || sEnd == L"" || sEnd == L"0") return 0; dPackages = dQty * sEnd.toDouble() / sBegin.toDouble(); } else { dPackages = dQty / sPRate.toDouble(); } if ((int)(dPackages * 1000) > (int)dPackages * 1000) dPackages = dPackages + 1; return (int)dPackages; } int OnBaseItemChanged(TEvent* evt, int p) { DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh; xstring colname = hdr->colname; xstring value = hdr->data; xstring dwname = L"dw_base"; if (value != L"") { KXMLDOMNodeList nlist = GetElement().selectNodes(L"//*[@name='" + dwname + L"']/trans[@for='" + colname + L"']"); ViewObject::TransData(GetServerUrl(),nlist, dw_base, hdr->row, colname, value); } if (colname == L"OtherExpenses") { double Amount = 0; double amt1; for (int i = 1; i <= dw_item.GetRowCount(); i++) { amt1 = dw_item.GetItemDouble(i, L"Amount"); Amount += amt1; } // trace(L"====ttlamt1====L"+ttlamt1.toString()); double OtherExpenses = dw_base.GetItemDouble(1, L"OtherExpenses"); //double Amount = dw_base.GetItemDouble(1,L"Amount"); double ttlamt = OtherExpenses + Amount; dw_base.SetItemDouble(1, L"Amount", ttlamt); } return 1; } int OnAskDataBase(TEvent* evt, int p) { //alert(L"xx"); DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh; xstring x = hdr->colname; if (x == L"userSalespersonID") { xstring sSalespersonID = dw_base.GetItemString(1, L"SalespersonID"); //alert(sSalespersonID); hdr->data = sSalespersonID; } return 1; } int OnAskGoodsNo() { int rowCount = dw_item.GetRowCount(); xstring skunos = L""; xstring GoodsNo1 = dw_item.GetItemString(dw_item.GetRow(), L"GoodsNo"); xstring GoodsNo2 = GoodsNo1.mid(0, 1); xstring GoodsNo3 = GoodsNo1.mid(1, 1); xstring GoodsNo4 = GoodsNo1.mid(2, 1); //trace(L"=====L"+GoodsNo2+L"=====L"+GoodsNo3+L"=====L"+GoodsNo4+L"=====L"); for (int i = 1; i <= rowCount; i++) { if (dw_item.GetItemString(i, L"SKUNo") != L"" && dw_item.GetItemString(i, L"GoodsNo") == L"" || GoodsNo1.find(L"N") >= 0 || GoodsNo1.find(L"n") >= 0 || GoodsNo4.isNumber() == false && GoodsNo2.isNumber() == true && GoodsNo3.isNumber() == true) { if (skunos == L"") skunos = dw_item.GetItemString(i, L"SKUNo"); else skunos += L",L" + dw_item.GetItemString(i, L"SKUNo"); } } xaserverarg& arg = *new xaserverarg(); arg.AddArg(L"SKUNoList", skunos); OpenWindow(L"dev:xpage[Product.FetchNo.vx]", (LPARAM) & arg); return 1; } bool SOLineMaybeDelete(xstring SOLineID) { KXMLDOMDocument x; xaserverarg arg; arg.AddArg(L"SOLineID", SOLineID); if (xurl::get(GetServerUrl(),L"/sale/data/SaleOrder/MaybeDelete", arg.GetString(), x) != 1) { xstring error = x.text(); alert(L"err:" + error); return false; } xstring val = x.documentElement().getAttribute(L"delete"); if (val == L"true") return L"true"; return false; } //ÃüÁî·¢²¼º¯Êý int OnCmdDispatch(xstring comdid) { bool bupdate = true; if (dw_base.GetItemString(1, L"ApprovalStatus") == L"3")bupdate = false; if (comdid == L"xmImportProduct" && bupdate) { //xstring str = GetControl(L"goods").GetText(); //str = str.trim(); //if(str==L"") //{ xaserverarg& arg = *new xaserverarg; arg.setNativePointer(arg.CreateInstance()); arg.AddArg(L"HWND", xstring((__int64)GetHWND())); arg.AddArg(L"CustomerID", dw_base.GetItemString(1, L"CustomerID")); OpenWindow(L"dev:xpage[Product.Select.SO.vx]", (LPARAM)&arg); //OpenWindow(L"dev:xpage[Product.Select.vx]",cast(arg1 as int)); //} //else //ImportProductByText(str); int row = dw_item.GetRow(); if (row >= 1) { ximageview im = GetControl(L"im1"); im.Reset(); xstring skuno = dw_item.GetItemString(row, L"SKUNo"); OnShowImage(skuno, row); im.Redraw(); } return 1; } else if (comdid == L"xmReSeqNo") { if (MessageBoxW(GetHWND(), L"ÊÇ·ñÖØÖÃÐòºÅ!", L"Ìáʾ1", 1) == 2) return 1; return ReSeqNo(L"LineNo"); } else if (comdid == L"xmDeleteRow" && bupdate) { int row2 = dw_item.GetRow(); xstring ChkState = dw_item.GetItemInt(row2, L"ChkState"); if (ChkState == L"") ChkState = L"1"; xstring SOLineID = dw_item.GetGuid(row2); KXMLDOMDocument x = ViewObject::RetrieveData(GetServerUrl(),L"/sale/data/SaleOrder/MaybeDeleteEx", L"SOLineID", SOLineID); xstring r = x.text(); int r1 = r.toInt(); if (x) { if (r1 > 0) { alert(L"»¹ÓжÔÓ¦µÄ²É¹º,²»ÔÊÐíɾ³ý£¡"); return 0; } } /*if(SOLineMaybeDelete(SOLineID)==false) { alert(L"»¹ÓжÔÓ¦µÄ²É¹º,²»ÔÊÐíɾ³ý£¡"); return 0; } if(ChkState != L"1" && ChkState != L"5" ) { if(SOLineMaybeDelete(SOLineID)==false) { alert(L"µ±Ç°×´Ì¬²»ÔÊÐíɾ³ý£¡"); return 0; } }*/ dw_item.DeleteRow(row2); double ttlamt = 0; double amt; for (int i = 1; i <= dw_item.GetRowCount(); i++) { amt = dw_item.GetItemDouble(i, L"Amount"); ttlamt += amt; } dw_base.SetItemDouble(1, L"Amount", ttlamt); return 1; } else if (comdid == L"xmAddRow" && bupdate) { int row = dw_item.InsertRow(0); SetSeqNo(dw_item, L"LineNo", row); dw_item.SetItemString(row, L"KOPCode", L"120"); dw_item.SetItemDisplayString(row, L"KOPCode", L"CTNS"); dw_item.SetItemString(row, L"UOMCode", L"007"); dw_item.SetItemDisplayString(row, L"UOMCode", L"PCS"); return 1; } else if (comdid.find(L"ImportXml:", 0) == 0) { xstring strImport = comdid.mid(xstring(L"ImportXml:").length(), 9999); ImportProductByText(strImport); return 1; } else if (comdid == L"xmPrint") { if (dw_base.GetItemString(1, L"SONo") == L"") { alert(L"ÇëÏȱ£´æÊý¾Ý!"); return 1; } xaserverarg& arg = * new xaserverarg; arg.setNativePointer(arg.CreateInstance()); arg.AddArg(L"EntityName", L"SaleOrder", L""); arg.AddArg(L"EntityID", dw_base.GetItemString(1, L"SOID"), L""); arg.AddArg(L"EntityNo", dw_base.GetItemString(1, L"SONo"), L""); openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", &arg); return 1; } else if (comdid == L"xmSaveEx" && bupdate) { OnSaveEx(); return 1; } else if (comdid == L"xmAskGoodsNo") { return OnAskGoodsNo(); } else if (comdid == L"xmClose") { CloseWindow(); return 1; } else if (comdid.find(L"xmSetCustomer") >= 0 && bupdate) { xstring no = comdid.mid(comdid.find(L":") + 1, 99999); xstring name = no.mid(no.find(L"\t") + 1, 999999); no = no.left(no.find(L"\t")); dw_base.SetItemString(1, L"CustomerID", no); dw_base.SetItemDisplayString(1, L"CustomerID", name); return 1; } return 0; } //°ü×°Êý¸Ä±äÑÕÉ« int OnItemAskStyle(TEvent* evt, LPARAM p) { int DMS_CSSSTYLE = 0x8; DWASKSTYLENMHDR& hdr = *(DWASKSTYLENMHDR*)evt->notify.pnmh; int row = hdr.row; int col = hdr.col; xstring colname = hdr.colname; int rows = dw_item.GetRowCount(); if (row < 1 || row > rows) { return 1; } /* KXMLDOMElement ele = dw_list.GetRowElement(dw_list.GetTreeRow(row)); xstring lineType = GetEleString(ele, L"LineType"); if(lineType == L"³ÉÆ·") return 1; if(lineType == L"1") return 1; hdr.mask = DMS_CSSSTYLE; xstring name = ele.parentNode.nodeName; if(name == L"item") hdr.cssstyle = L"color:#858585"; else hdr.cssstyle = L"color:#921D5E"; */ if (colname == L"Packages") { //trace(L"\r\ncol index: "+ col.toString()+L" name:"+ colname); int PackingRate = dw_item.GetItemString(row, L"PackingRate").toInt(); int Quantity = dw_item.GetItemString(row, L"Quantity").toInt(); if (PackingRate != 0) { if ((Quantity / PackingRate) * PackingRate != Quantity) { hdr.mask = DMS_CSSSTYLE; hdr.pCssStyle = (wchar_t*)L"color:#ff0000"; } } } return 1; } //ÃüÁî´¦Àíʼþ int OnXCommand(TEvent* evt, int param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnAttachListon() { //°ó¶¨¹¤¾ßÌõµã»÷ʼþ AttachEvent(L"WM_XCOMMAND", (FEvent)&BaseMaintSOWin::OnXCommand); //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ AttachEvent(L"WM_SETFOCUS", (FEvent)&BaseMaintSOWin::OnSetFocus); //AttachEvent(L"dw_props",L"DWV_CLICKED",(FEvent)&BaseMaintSOWin::OnDWClick); AttachEvent(L"dw_base", L"DWV_CLICKED", (FEvent)&BaseMaintSOWin::OnDWClick); AttachEvent(L"dw_item", L"DWV_ITEMCHANGED", (FEvent)&BaseMaintSOWin::OnItemChanged); AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", (FEvent)&BaseMaintSOWin::OnBaseItemChanged); AttachEvent(L"im1", L"IMG_LDBCLICK", (FEvent)&BaseMaintSOWin::OnImgDBClicked); AttachEvent(L"dw_item", L"DWV_ROWFOCUSCHANGED", (FEvent)&BaseMaintSOWin::OnRowChanged); AttachEvent(L"dw_base", L"DWV_ASKDATA", (FEvent)&BaseMaintSOWin::OnAskDataBase); AttachEvent(L"dw_item", L"DWV_ASKSTYLE", (FEvent)&BaseMaintSOWin::OnItemAskStyle); AttachEvent(L"dw_item", L"DWV_ITEMCHANGING", (FEvent)&BaseMaintSOWin::OnItemChanging); //AttachCloseWindow(); return 1; } int OnItemChanging(TEvent* evt, int p) { DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh; xstring colname = hdr->colname; xstring value = hdr->data; int row = hdr->row; #ifdef ShouldFinisg if (value == L"") return 1; xstring cellType = dw_item.GetColumnProp(colname.c_str(), L"celltype"); if (cellType == L"xs:decimal" || cellType == L"xs:integer") { if (value.isNumber() == false) { alert(value + L"²»ÊÇÊý×Ö!"); hdr->idFrom = -1; return 1; } } #endif return 1; } int OnImgDBClicked(TEvent* evt, int pr) { IMGNNMHDR* nmtv = (IMGNNMHDR *)evt->notify.pnmh; xstring src = nmtv->path; /*if(src.length() > 60) src = src.right(44); else src=src.mid(src.find(L"Thumbs", 0)+6, 50); */ xaserverarg& arg = * new xaserverarg; //arg.AddArg(L"src",L"/business/products/chanpin"+src); arg.AddArg(L"src", src); //win::OpenWindow(L"dev:xpage[BigPicture.vx]",arg); int h = openUrl(L"/sale/view/ProductLibrary/xpage/bigpictureview", &arg); /* xwin x = new xwin; x.setNativePointer(h); m_winHwnd = x.GetHWND(); xstring sh = doc.xml(); int p = cast(sh as int); win32::SendMessage(m_winHwnd, 0x401, p, 0); */ return 1; } int OnShowImage(xstring skuno, int row) { ximageview im = GetControl(L"im1"); KXMLDOMDocument xp; xaserverarg& arg_pic = *new xaserverarg; arg_pic.setNativePointer(arg_pic.CreateInstance()); arg_pic.AddArg(L"SKUNo", skuno); xstring res = L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; xstring customerID = dw_base.GetItemString(1, L"CustomerID"); xstring customerItemNo = dw_item.GetItemString(row, L"CustomerItemNo"); if (customerItemNo != L"") { //trace(customerID+L":"+customerItemNo); res = L"/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKUNo"; arg_pic.AddArg(L"CustomerID", customerID); arg_pic.AddArg(L"CustomerItemNo", customerItemNo); } bool hasIamge = false; if (xurl::get(GetServerUrl(),res, arg_pic.GetString(), xp) != 1) { //trace(xp.xml()); return 1; } else { KXMLDOMNodeList nlistp = xp.selectNodes(L"ImageList/image"); int lenp = nlistp.length(); for (int ip = 0; ip < lenp; ip++) { hasIamge = true; KXMLDOMElement xitem = nlistp.item(ip); xstring picname = xitem.selectSingleNode(L"PicPath").text(); string goodno = xitem.selectSingleNode(L"GoodsNo").text(); if (picname == L"/business/products/Thumbs//") picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg"; im.AddImages(picname, (wchar_t*)goodno); } } if (!hasIamge) { res = L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; if (xurl::get(GetServerUrl(),res, arg_pic.GetString(), xp) != 1) { //trace(xp.xml()); return 1; } else { KXMLDOMNodeList nlistp = xp.selectNodes(L"ImageList/image"); int lenp = nlistp.length(); for (int ip = 0; ip < lenp; ip++) { auto xitem = nlistp.item(ip); string picname = xitem.selectSingleNode(L"PicPath").text(); string goodno = xitem.selectSingleNode(L"GoodsNo").text(); if (picname == L"/business/products/Thumbs//") picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg"; im.AddImages(picname, (wchar_t*)goodno); } } } return 1; } int OnRowChanged(TEvent* evt, int p) { DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; int row = hdr.row; ximageview im = GetControl(L"im1"); im.Reset(); xstring skuno = dw_item.GetItemString(row, L"SKUNo"); OnShowImage(skuno, row); im.Redraw(); return 1; } int onload() { dw_props = GetControl(L"dw_props"); /*KXMLDOMDocument x = SaleOrderView::GetMaintFormForBase(); dw_props.SetDataObject(x); //dw_props.SetSelectionBorder(0); dw_props.SetColHeaderHeight(0); dw_props.SetRowSelectorWidth(0); dw_props.SetHScrollState(false);*/ dw_base = GetControl(L"dw_base"); dw_base.openUrl(L"/sale/view/SaleOrder/template/base"); dw_base.SetColHeaderHeight(0); dw_base.SetRowSelectorWidth(0); dw_base.SetHScrollState(false); dw_base.SetVScrollState(false); dw_item = GetControl(L"dw_item"); dw_item.openUrl(L"/sale/view/SaleOrder/template/item"); dw_item.SetAskStyle(true); dw_item.SetColumnState(L"ItemID", false); dw_item.SetColumnState(L"LineType", false); //dw_item.SetColumnState(L"LineNo",false); dw_item.SetColumnState(L"Assortment", false); dw_item.SetColumnState(L"ClassifyID", false); dw_item.SetColumnState(L"UnitFreight", false); //dw_item.SetColumnState(L"CName",false); dw_item.SetColumnState(L"Brand", false); dw_item.SetColumnState(L"SKUNo", false); dw_item.SetColumnState(L"SOLineNo", false); dw_item.SetColumnState(L"EnquiryPriceListID", false); dw_item.SetColumnState(L"QuoteLineID", false); dw_item.SetColumnState(L"CustomerPONo", false); dw_item.SetColumnState(L"KOPCode", false); dw_item.SetColumnState(L"PackTechNote", false); //dw_item.SetColumnState(L"ScheduleShipDate",false); dw_item.SetColumnState(L"Submitter", false); dw_item.SetColumnState(L"POSupplierID", false); xstring groupname = publiccode::GetUser().groupname; if (groupname == L"²É¹ºÐ¡×é") { dw_item.SetColumnState(L"UnitPrice", false); dw_item.SetColumnState(L"Amount", false); dw_item.SetColumnState(L"UnitCommPrice", false); dw_item.SetColumnState(L"CommissionRate", false); } //alert(groupid); /* xaserverarg arg = GetParam(); if(arg) { xstring SONo = arg.GetArgString(L"SONo"); x = SaleOrderView::GetMaintDataForBase(SONo); dw_props.Retrieve(SaleOrderView::GetMaintDataForBase(SONo)); }*/ xstring SONo; xstring CustomerID; xaserverarg arg; if (GetWinParam()) { arg = GetArg(); SONo = arg.GetArgString(L"SONo"); if (SONo == L"") SONo = arg.GetArgString(L"EntityNo"); } if (SONo != L"") { KXMLDOMDocument x = SaleOrderView::GetMaintDataForBase(SONo); dw_base.Retrieve(x); dw_item.Retrieve(x); } else { KXMLDOMDocument x = ViewObject::RetrieveData(GetServerUrl(),L"/sale/data/SaleOrder/newinitial"); dw_base.Retrieve(x); xstring sdate = publiccode::GetCurrentDate(); dw_base.SetItemString(1, L"SODate", sdate); xstring suserid = publiccode::GetUser().id; xstring susername = publiccode::GetUser().name; xstring deptname = publiccode::GetUser().deptname; dw_base.SetItemString(1, L"SalespersonID", suserid); dw_base.SetItemDisplayString(1, L"SalespersonID", susername); dw_base.SetItemString(1, L"orgname", deptname); dw_base.SetItemString(1, L"FrontMarks", L"N/M"); //dw_base.SetItemString(1,L"CurrencyCode",L"USD"); //dw_base.SetItemDisplayString(1,L"CurrencyCode",L"USD"); xstring srano = publiccode::GetRANo(L"SO", suserid); dw_base.SetItemString(1, L"RANo", srano); dw_base.SetItemDisplayString(1, L"RANo", srano); dw_base.SetItemString(1, L"CompanyID", L"E9E3C542-062C-4957-B8F4-9B92C3E351FC"); dw_base.SetItemDisplayString(1, L"CompanyID", L"Äþ²¨¼Ò¶û¼Ñ½ø³ö¿ÚÓÐÏÞ¹«Ë¾"); xstring guid = publiccode::GetGuid(); dw_base.SetGuid(1, guid); dw_base.SetItemString(1, L"@guid", dw_base.GetGuid(1)); dw_base.SetItemString(1, L"SOID", dw_base.GetGuid(1)); if (CustomerID != L"") { dw_base.ItemChangeTo(1, L"CustomerID", arg.GetArgString(L"CustomerID")); dw_base.SetItemDisplayString(1, L"CustomerID", arg.GetArgString(L"CustomerName")); xstring dwname = L"dw_base"; xstring colname = L"CustomerID"; xstring value = CustomerID; KXMLDOMNodeList nlist = GetElement().selectNodes(L"//*[@name='" + dwname + L"']/trans[@for='" + colname + L"']"); ViewObject::TransData(GetServerUrl(),nlist, dw_base, 1, colname, value); } } OnAttachListon(); return 1; } int onloaded() { SetAgent(); if (GetWinParam()) { xaserverarg arg = GetArg(); HCURSOR hCursor = xutil::SetCursorWait(); xstring SONo = arg.GetArgString(L"SONo"); if (SONo == L"") SONo = arg.GetArgString(L"EntityNo"); if (SONo != L"") { KXMLDOMDocument x = SaleOrderView::GetMaintFormForItemList(SONo); dw_item.Retrieve(x); dw_item.Redraw(); } xutil::RestoreCursor(hCursor); if (arg.GetArgString(L"ReadOnly") == L"true") { dw_base.SetReadOnly(true); dw_item.SetReadOnly(true); } } if (dw_base.GetItemString(1, L"ApprovalStatus") == L"3") { dw_base.SetReadOnly(true); dw_item.SetReadOnly(true); } /*int row3 = dw_item.GetRow(); xstring ChkStates=dw_item.GetItemInt(row3 ,L"ChkState").toString(); if(ChkStates==L"") ChkStates=L"1"; if(ChkStates !=L"1" && ChkStates !=L"5" ) { dw_item.SetReadOnly(true); //dw_item.SetColumnState(L"POCreatorID",false); }*/ //dw_base.SetEditUpperMode(true); //dw_item.SetEditUpperMode(true); if (dw_item.GetRowCount() > 0) { ximageview im = GetControl(L"im1"); im.Reset(); xstring skuno = dw_item.GetItemString(1, L"SKUNo"); OnShowImage(skuno, 1); im.Redraw(); } return 1; } };