þÿ#include <wobject/xstring.hpp> #include <wobject/xdouble.hpp> #include <xcontrol/xtreeview.hpp> #include <xcontrol/xdwgrid.hpp> #include <xcontrol/ximageview.hpp> #include "vbusiness/vframe/maint.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" #include "viewobject/quote.view.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) Quote3MaintWin : public maint { public: xdwgrid dw_goods; xdwtable dw_base; xnode m_agentNode; //Agent Condition public: Quote3MaintWin(void* implPtr, HWND hWnd) :maint(implPtr, hWnd) {} public: static Quote3MaintWin* CreateInstance(void* implPtr, void* hWnd) { Quote3MaintWin* pWin = new Quote3MaintWin(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) { 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; } xstring GetEntityData(LPARAM pr) { dw_base.AcceptText(); dw_goods.AcceptText(); if (dw_base.GetItemString(1, L"QuoteNo") == L"") { xstring QuoteNo = QuoteView::MakeBillNo(); dw_base.SetItemString(1, L"QuoteNo", QuoteNo); } KXMLDOMDocument x; xaserverarg& arg = *new xaserverarg; dw_goods.DwUpdateAllToEx(x); dw_base.DwUpdateAllTo(x); return x.xml(); } int SetSeqNo(xdwgrid dw_obj, xstring SeqNoColumn, int nRow) { if (nRow > 1) { int SeqNo = dw_goods.GetItemInt(nRow - 1, SeqNoColumn); if (SeqNo != 0) SeqNo += 10; else SeqNo = nRow * 10; dw_obj.SetItemInt(nRow, SeqNoColumn, SeqNo); } else dw_obj.SetItemInt(nRow, SeqNoColumn, 10); return 1; } int DoUpdate(bool showSuccess) { if (publiccode::GetUser().id != dw_base.GetItemString(1, L"SalespersonID")) { alert(L"SêQA‹¸_SRMg,NºOîe9ÿ OÝ[Xÿ"); return 0; } dw_base.AcceptText(); dw_goods.AcceptText(); if (dw_base.GetItemString(1, L"QuoteNo") == L"") { xstring QuoteNo = QuoteView::MakeBillNo(); dw_base.SetItemString(1, L"QuoteNo", QuoteNo); } xstring Source = dw_base.GetItemString(1, L"Source"); if (Source != L"[¢b7 SU") { if (dw_base.GetItemString(1, L"CustomerID") == L"") { alert(L"‹÷“Qe[¢b7!"); return 0; } if (dw_base.GetItemString(1, L"PriceTerm") == L"") { alert(L"‹÷“QeN÷h!"); return 0; } if (dw_base.GetItemString(1, L"LoadPort") == L"") { alert(L"‹÷“QeQúSãSã\¸!"); return 0; } } KXMLDOMDocument x; xaserverarg& arg = *new xaserverarg; arg.setNativePointer(arg.CreateInstance()); dw_goods.DwUpdateAllToEx(x); dw_base.DwUpdateAllTo(x); //trace(x.GetXml()); //return 1; if (dw_goods.GetRowCount() == 0) { alert(L"‹÷lQeN§TÁ!"); return 0; } if (Source != L"[¢b7 SU") { for (int i = 1; i <= dw_goods.GetRowCount(); i++) { if (dw_goods.GetItemString(i, L"FobUnitPrice") == L"" || dw_goods.GetItemString(i, L"FobUnitPrice") == L".000") { alert(L"‹÷“QeFOBN÷h<!"); return 0; } if (dw_goods.GetItemString(i, L"PaperCardPrice") == L"" || dw_goods.GetItemString(i, L"PaperCardPrice") == L".0000") { alert(L"‹÷“Qe~¸SaN÷!"); return 0; } if (dw_goods.GetItemString(i, L"VATRefundRate") == L"") { alert(L"‹÷“Qezs‡!"); return 0; } if (dw_goods.GetItemString(i, L"ItemMiniQty") == L"") { alert(L"‹÷“Qew‹¢‘Ï!"); return 0; } if (dw_goods.GetItemString(i, L"ItemName") == L"") { alert(L"‹÷“Qe‚ñe‡TÁT !"); return 0; } if (dw_goods.GetItemString(i, L"Packages") == L"" || dw_goods.GetItemString(i, L"Packages") == L"0") { alert(L"‹÷“QeY{±ˆÅep!"); return 0; } } } xstring error = L""; arg.AddArg(L"content", x.xml()); trace(x.xml()); if (xurl::get(L"/sale/data/Quote/update", arg.GetString(), x) != 1) { error = x.text(); alert(error); } else { xstring str = x.documentElement().getAttribute(L"text"); if (str == L"true") { dw_goods.ResetUpdateStatus(); dw_base.ResetUpdateStatus(); if (showSuccess)alert(L"OÝ[XbRŸ!"); OnRetrieve(dw_base.GetGuid(1)); return -1; } else { if (showSuccess)alert(L"OÝ[XY1%!"); return -1; } } return 1; } int OnSave() { DoUpdate(true); return 1; } int ImportProductByText(xstring str) { xstring CustomerID = dw_base.GetItemString(1, L"CustomerID"); //alert(str+L"----"+CustomerID); xml x; if (CustomerID == L"") x = QuoteView::LookupProductsByText(str); else x = QuoteView::LookupProductsByText(str, 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_goods.InsertRow(0); //alert(e.xml); int nRow = dw_goods.GetRowCount(); SetSeqNo(dw_goods, L"SeqNo", nRow); dw_goods.SetItemString(nRow, L"UOMCode", L"007"); dw_goods.SetItemDisplayString(nRow, L"UOMCode", L"PCS"); dw_goods.SetItemString(nRow, L"KOPCode", L"120"); dw_goods.SetItemDisplayString(nRow, L"KOPCode", L"CTNS"); dw_goods.SetItemString(nRow, L"SKUNo", e.getAttribute(L"SKUNo")); dw_goods.SetItemString(nRow, L"ItemID", e.getAttribute(L"SKUID")); dw_goods.SetItemString(nRow, L"ItemName", e.getAttribute(L"EName")); dw_goods.SetItemString(nRow, L"GoodsNo", e.getAttribute(L"GoodsNo")); dw_goods.SetItemString(nRow, L"CustomerItemNo", e.getAttribute(L"CustomerItemNo")); dw_goods.SetItemString(nRow, L"Packing", e.getAttribute(L"Packing")); dw_goods.SetItemString(nRow, L"VolumeDesc", e.getAttribute(L"VolumeDesc")); dw_goods.SetItemString(nRow, L"Packages", e.getAttribute(L"QtyPerPkg")); dw_goods.SetItemString(nRow, L"VATRefundRate", e.getAttribute(L"VATRefundRate")); dw_goods.SetItemString(nRow, L"VATRate", e.getAttribute(L"VATRate")); dw_goods.SetItemString(nRow, L"HSCode", e.getAttribute(L"HSCode")); dw_goods.SetItemString(nRow, L"POPrice", e.getAttribute(L"POPrice")); dw_goods.SetItemString(nRow, L"SampleFee", e.getAttribute(L"SampleFee")); dw_goods.SetItemString(nRow, L"TestFee", e.getAttribute(L"TestFee")); dw_goods.SetItemString(nRow, L"ModelFee", e.getAttribute(L"ModelFee")); dw_goods.SetItemString(nRow, L"ProductDesc", e.getAttribute(L"ProductDesc")); xstring POPrice_display = e.getAttribute(L"POPrice_displaystring"); if (POPrice_display != L"") dw_goods.SetItemDisplayString(nRow, L"POPrice", POPrice_display); //xstring POPrice_display = e.getAttribute(L"POPrice_tipstring"); //if(POPrice_display !=L"") dw_goods.SetItemDisplayString(nRow,L"POPrice",POPrice_display); dw_goods.SetItemString(nRow, L"CurPOPrice", e.getAttribute(L"CurPOPrice")); dw_goods.SetItemString(nRow, L"EnquiryLineID", e.getAttribute(L"EnquiryLineID")); dw_goods.SetItemString(nRow, L"EnquiryPriceListID", e.getAttribute(L"EnquiryPriceListID")); dw_goods.SetItemString(nRow, L"PurcharID", e.getAttribute(L"PurcharID")); //alert(e.getAttribute(L"ItemMiniQty")); dw_goods.SetItemString(nRow, L"ItemMiniQty", e.getAttribute(L"ItemMiniQty")); if (dw_goods.GetItemString(nRow, L"VolumeDesc") != L"" && dw_goods.GetItemString(nRow, L"Packages") != L"") { int qty = EvalQtyPerFCL45H(nRow); dw_goods.SetItemString(nRow, L"Packages45H", xstring(qty)); dw_goods.SetItemDouble(nRow, L"TransportationFee", 5000.0 / qty); } dw_goods.SetItemString(nRow, L"NwPerPkg", e.getAttribute(L"NwPerPkg")); dw_goods.SetItemString(nRow, L"GwPerPkg", e.getAttribute(L"GwPerPkg")); dw_goods.SetItemString(nRow, L"QtyPerPk", e.getAttribute(L"QtyPerPk")); dw_goods.SetItemString(nRow, L"InnerQty", e.getAttribute(L"InnerQty")); } dw_goods.Redraw(); int row = dw_goods.GetRow(); if (row >= 1) { ximageview im = GetControl(L"im1"); im.Reset(); xstring skuno = dw_goods.GetItemString(row, L"SKUNo"); OnShowImage(skuno, row); im.Redraw(); } return 1; } double EvalCost(int row) { double cost = 0.0; cost += dw_goods.GetItemDouble(row, L"POPrice"); cost += dw_goods.GetItemDouble(row, L"PaperCardPrice"); cost += dw_goods.GetItemDouble(row, L"TransportationFee"); cost += dw_goods.GetItemDouble(row, L"OtherFee"); cost += dw_goods.GetItemDouble(row, L"ManagementFee"); return cost; } double EvalRefund(int row) { double VATRefundRate = dw_goods.GetItemDouble(row, L"VATRefundRate"); double VATRefund = dw_goods.GetItemDouble(row, L"POPrice") * VATRefundRate / 117.0; VATRefund += dw_goods.GetItemDouble(row, L"PaperCardPrice") * 13.0 / 117.0; return VATRefund; } int EvalQtyPerFCL45H(int row) { double vol = EvalVol(dw_goods.GetItemString(row, L"VolumeDesc")); double packages = dw_goods.GetItemDouble(row, L"Packages"); return int(packages * 65.0 / vol); } double EvalUnitProfit(int row) { double ExchangeRate = dw_base.GetItemDouble(1, L"ExchangeRate"); double FobUnitPrice = dw_goods.GetItemDouble(row, L"FobUnitPrice"); double UnitCost = dw_goods.GetItemDouble(row, L"UnitCost"); double VATRefund = dw_goods.GetItemDouble(row, L"VATRefund"); return ExchangeRate * FobUnitPrice - UnitCost + VATRefund; } double EvalProfitRate(int row) { double UnitProfit = EvalUnitProfit(row); double UnitCost = dw_goods.GetItemDouble(row, L"UnitCost"); return UnitProfit / UnitCost; } double EvalSaleProfitRate(int row) { double UnitProfit = EvalUnitProfit(row); double FobUnitPrice = dw_goods.GetItemDouble(row, L"FobUnitPrice"); return UnitProfit / FobUnitPrice; } double EvalExchangeCostRate(int row) { double FobUnitPrice = dw_goods.GetItemDouble(row, L"FobUnitPrice"); double UnitCost = dw_goods.GetItemDouble(row, L"UnitCost"); double VATRefund = dw_goods.GetItemDouble(row, L"VATRefund"); return (UnitCost - VATRefund) / FobUnitPrice; } double EvalTransportationFee(int row) { double vol = EvalVol(dw_goods.GetItemString(row, L"VolumeDesc")); double packages = dw_goods.GetItemDouble(row, L"Packages"); return 80 * vol / packages; } double EvalVol(xstring value) { double vol = 1.0; xstring volstr = value; int pos1 = volstr.find(L"*"); int pos2 = volstr.find(L"X"); int pos3 = volstr.find(L"x"); int pos = pos1; trace(L"pos: " + xstring(pos) + L"pos1: " + xstring(pos1) + L"pos2: " + xstring(pos2) + L"pos3: " + xstring(pos3)); if (pos2 > 0 && pos == -1) pos = pos2; if (pos2 >= 0 && pos2 < pos) pos = pos2; trace(L"pos: " + xstring(pos) + L"pos1: " + xstring(pos1) + L"pos2: " + xstring(pos2) + L"pos3: " + xstring(pos3)); if (pos3 > 0 && pos == -1) pos = pos3; if (pos3 >= 0 && pos3 < pos) pos = pos3; trace(L"pos: " + xstring(pos) + L"pos1: " + xstring(pos1) + L"pos2: " + xstring(pos2) + L"pos3: " + xstring(pos3)); while (pos >= 0) { xstring tm = volstr.left(pos); volstr = volstr.mid(pos + 1, 9999); vol *= tm.toDouble(); pos1 = volstr.find(L"*"); pos2 = volstr.find(L"X"); pos3 = volstr.find(L"x"); pos = pos1; if (pos2 > 0 && pos == -1) pos = pos2; if (pos2 >= 0 && pos2 < pos) pos = pos2; if (pos3 > 0 && pos == -1) pos = pos3; if (pos3 >= 0 && pos3 < pos) pos = pos3; } if (volstr != L"") vol *= volstr.toDouble(); return vol / 1000000.0; } int ClassifyChanged(int row, xstring ClassifyID) { xml x = ViewObject::RetrieveData(L"/sale/data/Custom3/custom/classifyinfo", L"ClassifyID", ClassifyID); if (x) { KXMLDOMNode o = x.selectSingleNode(L"data/Item"); if (o.selectSingleNode(L"VATRefundRate")) { //dw_goods.SetItemString(i,L"VATRefundRate",o.selectSingleNode(L"VATRefundRate").text); dw_goods.ItemChangeTo(row, L"VATRefundRate", o.selectSingleNode(L"VATRefundRate").text()); } else { dw_goods.ItemChangeTo(row, L"VATRefundRate", L""); } } return 1; } //SˆÅepe9Sؘœ‚r 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_goods.GetRowCount(); if (row < 1 || row > rows) { return 1; } if (colname == L"POPrice") { xstring POPrice = dw_goods.GetItemDisplayString(row, L"POPrice"); if (POPrice == L"") POPrice = dw_goods.GetItemString(row, L"POPrice"); xstring CurPOPrice = dw_goods.GetItemDisplayString(row, L"CurPOPrice"); xstring POPrices = dw_goods.GetItemString(row, L"POPrices"); if (POPrice == L"" || CurPOPrice == L"" || POPrices == L"") return 1; if (CurPOPrice.find(POPrice, 0) < 0) //if(POPrice.find(POPrices,0)<0) { hdr.mask = DMS_CSSSTYLE; hdr.pCssStyle = (wchar_t*)L"color:#ff0000"; } } 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; double VATRefund = 0.0; double VATRefundRate = 0.0; if (colname == L"ClassifyID") { return ClassifyChanged(row, value); } if ((colname == L"GoodsNo" || colname == L"CustomerItemNo") && value != L"") { if (colname == L"CustomerItemNo") { if (dw_goods.GetItemString(row, L"GoodsNo") != L"") return 1; } xml x; xstring CustomerID = dw_base.GetItemString(1, L"CustomerID"); xstring sval = value; if (colname == L"GoodsNo") sval = L"gs:" + value; if (colname == L"CustomerItemNo") sval = L"cs:" + value; if (CustomerID != L"") x = QuoteView::LookupProductsByText(sval, CustomerID); else x = QuoteView::LookupProductsByText(sval); if (!x) return 1; KXMLDOMNodeList items = x.selectNodes(L"/Items/Item"); int len = items.length(); if (len == 0) { if (colname == L"GoodsNo")alert(L"l¡g kdQlSøW‹S÷!"); return 1; } if (len >= 1) { KXMLDOMElement e = items.item(0); int nRow = dw_goods.GetRow(); dw_goods.SetItemString(nRow, L"SKUNo", e.getAttribute(L"SKUNo")); dw_goods.SetItemString(nRow, L"ItemID", e.getAttribute(L"SKUID")); dw_goods.SetItemString(nRow, L"ItemName", e.getAttribute(L"EName")); if (colname == L"CustomerItemNo")dw_goods.SetItemString(nRow, L"GoodsNo", e.getAttribute(L"GoodsNo")); if (colname == L"GoodsNo")dw_goods.SetItemString(nRow, L"CustomerItemNo", e.getAttribute(L"CustomerItemNo")); dw_goods.SetItemString(nRow, L"Packing", e.getAttribute(L"Packing")); dw_goods.SetItemString(nRow, L"VolumeDesc", e.getAttribute(L"VolumeDesc")); dw_goods.SetItemString(nRow, L"Packages", e.getAttribute(L"QTYPerPkg")); if (dw_goods.GetItemString(nRow, L"VolumeDesc") != L"" && dw_goods.GetItemString(nRow, L"Packages") != L"") { int qty1 = EvalQtyPerFCL45H(nRow); dw_goods.SetItemString(nRow, L"Packages45H", xstring(qty1)); dw_goods.SetItemDouble(nRow, L"TransportationFee", 5000.0 / qty1); } dw_goods.Redraw(); } } else if (colname == L"POPrice" || colname == L"PaperCardPrice" || colname == L"TransportationFee" || colname == L"OtherFee" || colname == L"ManagementFee") { dw_goods.SetItemDouble(row, L"UnitCost", EvalCost(row)); if ((colname == L"POPrice" || colname == L"PaperCardPrice") && dw_goods.GetItemString(row, L"VATRefundRate") != L"") { dw_goods.SetItemDouble(row, L"VATRefund", EvalRefund(row)); } } else if (colname == L"VATRefundRate" && value != L"") { dw_goods.SetItemDouble(row, L"VATRefund", EvalRefund(row)); } else if (colname == L"VolumeDesc" || colname == L"Packages") { if (dw_goods.GetItemString(row, L"VolumeDesc") != L"" && dw_goods.GetItemString(row, L"Packages") != L"") { int qty = EvalQtyPerFCL45H(row); dw_goods.SetItemString(row, L"Packages45H", xstring(qty)); dw_goods.SetItemDouble(row, L"TransportationFee", EvalTransportationFee(row)); dw_goods.SetItemDouble(row, L"UnitCost", EvalCost(row)); } } else if (colname == L"FobUnitPrice") { xstring CurrencyCode = dw_base.GetItemString(1, L"CurrencyCode"); xstring expRate = L""; xstring exchRate = L""; xstring prepareFeeRate = L""; xml x0 = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"mgtFeeRate"); if (x0.selectSingleNode(L"root/item/@value")) expRate = x0.selectSingleNode(L"root/item/@value").text(); x0 = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate"); if (x0.selectSingleNode(L"root/item/@value")) exchRate = x0.selectSingleNode(L"root/item/@value").text(); x0 = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"prepareFeeRate"); if (x0.selectSingleNode(L"root/item/@value")) prepareFeeRate = x0.selectSingleNode(L"root/item/@value").text(); //alert(exchRate); //alert(expRate); double r1 = exchRate.toDouble(); double r2 = expRate.toDouble(); double r3 = prepareFeeRate.toDouble(); double val = value.toDouble(); if (CurrencyCode == L"RMB" || CurrencyCode == L"CNY") { if (exchRate != L"") { double ManagementFee = (val / r1) * r1; double OtherFee = (val / r1) * r3; dw_goods.SetItemDouble(row, L"ManagementFee", ManagementFee); dw_goods.SetItemDouble(row, L"OtherFee", OtherFee); } } else { dw_goods.SetItemDouble(row, L"ManagementFee", val * r2); dw_goods.SetItemDouble(row, L"OtherFee", val * r3); } dw_goods.SetItemDouble(row, L"UnitCost", EvalCost(row)); } if (dw_goods.GetItemString(row, L"FobUnitPrice") != L"" && dw_goods.GetItemString(row, L"POPrice") != L"" && dw_goods.GetItemString(row, L"VolumeDesc") != L"" && dw_goods.GetItemString(row, L"Packages") != L"") { dw_goods.SetItemDouble(row, L"UnitProfit", EvalUnitProfit(row)); dw_goods.SetItemDouble(row, L"ProfitRate", EvalProfitRate(row)); dw_goods.SetItemDouble(row, L"SaleProfitRate", EvalSaleProfitRate(row)); dw_goods.SetItemDouble(row, L"ExchangeCostRate", EvalExchangeCostRate(row)); } dw_goods.Redraw(); return 1; } 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"ExchangeRate") { if (dw_goods.GetRowCount() > 0) { for (int i = 1; i <= dw_goods.GetRowCount(); i++) { dw_goods.SetItemDouble(i, L"UnitProfit", EvalUnitProfit(i)); dw_goods.SetItemDouble(i, L"ProfitRate", EvalProfitRate(i)); dw_goods.SetItemDouble(i, L"SaleProfitRate", EvalSaleProfitRate(i)); dw_goods.SetItemDouble(i, L"ExchangeCostRate", EvalExchangeCostRate(i)); } } dw_goods.Redraw(); } return 1; } int OnPriceEval() { OpenWindow(L"dev:xpage[eval.quote3.vx]", (LPARAM)&dw_goods); 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_goods.GetItemString(row, L"SKUNo"); OnShowImage(skuno, row); im.Redraw(); return 1; } int OnShowImage() { int rowCount = dw_goods.GetRowCount(); xstring skunos; for (int i = 1; i <= rowCount; i++) { xstring skuno = dw_goods.GetItemString(i, L"SKUNo"); if (i == 1) skunos = skuno; else skunos += L",L" + skuno; } xaserverarg& arg_pic = *new xaserverarg; arg_pic.setNativePointer(arg_pic.CreateInstance()); arg_pic.AddArg(L"SKUNoList", skunos); arg_pic.SetParam(L"ParentWindow", (LPARAM)GetHWND()); arg_pic.AddArg(L"OpenFlag", L"1"); OpenWindow(L"dev:xpage[SKU.PictureView.Product3.vx]", (LPARAM)&arg_pic); return 1; } int OnShowImage(xstring skuno, int row) { ximageview im = GetControl(L"im1"); xml xp; xaserverarg arg_pic; 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_goods.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(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(); xstring 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, goodno); } } if (!hasIamge) { res = L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; if (xurl::get(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++) { KXMLDOMElement xitem = nlistp.item(ip); xstring picname = xitem.selectSingleNode(L"PicPath").text(); xstring 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, goodno); } } } return 1; } int OnPrint() { if (dw_base.GetItemString(1, L"QuoteNo") == L"") { alert(L"‹÷QHOÝ[Xepcn!"); return 1; } xaserverarg& arg = *new xaserverarg; arg.AddArg(L"EntityName", L"Quote", L""); arg.AddArg(L"EntityID", dw_base.GetItemString(1, L"QuoteID"), L""); arg.AddArg(L"EntityNo", dw_base.GetItemString(1, L"QuoteNo"), L""); trace(dw_base.GetItemString(1, L"QuoteID") + L"***" + dw_base.GetItemString(1, L"QuoteNo")); openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", &arg); return 1; } int ReSeqNo(xstring SeqNoColumn) { for (int i = 1; i <= dw_goods.GetRowCount(); i++) { dw_goods.SetItemString(i, SeqNoColumn.c_str(), xstring((i * 10))); } dw_goods.Redraw(); return 1; } //T}NäSÑ^Qýep int OnCmdDispatch(xstring comdid) { if (comdid == L"xmNewProduct") { //xaserverarg arg = new xaserverarg; //arg.setNativePointer(arg.CreateInstance()); openUrl(L"/sale/view/Quote3/xpage/quick/newestproduct", (xaserverarg*)GetHWND()); return 1; } else if (comdid == L"xmPrint") return OnPrint(); else if (comdid == L"xmImage") return OnShowImage(); else if (comdid == L"xmImportProduct") { xstring str = xcontrol(GetControl(L"goods")).GetText(); str = str.trim(); if (str == L"") { xaserverarg& arg1 = *new xaserverarg; arg1.SetParam(L"ParentWindow", (LPARAM)GetHWND()); arg1.AddArg(L"CustomerID", dw_base.GetItemString(1, L"CustomerID")); OpenWindow(L"dev:xpage[Product.Select.vx]", (LPARAM)&arg1); int row = dw_goods.GetRow(); if (row >= 1) { ximageview im = GetControl(L"im1"); im.Reset(); xstring skuno = dw_goods.GetItemString(row, L"SKUNo"); OnShowImage(skuno, row); im.Redraw(); } } else ImportProductByText(str); return 1; } else if (comdid == L"xmSave") { if (publiccode::GetUser().id != dw_base.GetItemString(1, L"SalespersonID")) { alert(L"SêQA‹¸_SRMg,NºOîe9ÿ OÝ[Xÿ"); return 0; } OnSave(); return 1; } else if (comdid == L"xmPriceEval") return OnPriceEval(); else if (comdid == L"xmOpen") { xaserverarg& arg = *new xaserverarg; OpenWindow(L"dev:xpage[SOQuote.list.vx]", (LPARAM)&arg); if (arg.GetArgString(L"id") != L"") return OnRetrieve(arg.GetArgString(L"id")); return 1; } else if (comdid == L"xmDeleteRow") { dw_goods.DeleteRow(0); return 1; } else if (comdid == L"xmAskGoodsNo") { return OnAskGoodsNo(); } else if (comdid == L"xmReSeqNo") { if (MessageBoxW(GetHWND(), L"f/T&‘Ín^S÷!", L"cÐy:1", 1) == 2) return 1; return ReSeqNo(L"SeqNo"); } else if (comdid == L"xmProductDesc") { xaserverarg& arg2 = *new xaserverarg; int row2 = dw_goods.GetRow(); if (row2 < 1) return 0; xstring str2 = dw_goods.GetItemString(row2, L"ProductDesc"); arg2.AddArg(L"value", str2); OpenWindow(L"dev:xpage[memo.edit.new.vx]", (LPARAM)&arg2); return 1; } else if (comdid == L"xmDescription") { xaserverarg& arg6 = *new xaserverarg; arg6 = *new xaserverarg; int row6 = dw_goods.GetRow(); if (row6 < 1) return 0; xstring str6 = dw_goods.GetItemString(row6, L"Description"); arg6.AddArg(L"value", str6); OpenWindow(L"dev:xpage[memo.edit.new.vx]", (LPARAM)&arg6); if (arg6.GetArgString(L"comdid") == L"xmOK") { str6 = arg6.GetArgString(L"value"); dw_goods.AcceptText(); dw_goods.SetItemString(row6, L"Description", str6); dw_goods.Redraw(); } return 1; } else if (comdid == L"xmAddRow") { int nRow = dw_goods.InsertRow(0); SetSeqNo(dw_goods, L"SeqNo", nRow); dw_goods.SetItemString(nRow, L"UOMCode", L"007"); dw_goods.SetItemDisplayString(nRow, L"UOMCode", L"PCS"); dw_goods.SetItemString(nRow, L"KOPCode", L"120"); dw_goods.SetItemDisplayString(nRow, L"KOPCode", L"CTNS"); return 1; } else if (comdid == L"xmClose") { CloseWindow(); return 1; } else if (comdid.find(L"ImportXml:", 0) == 0) { xstring strImport = comdid.mid(xstring(L"ImportXml:").length(), 9999); ImportProductByText(strImport); return 1; } return 0; } 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.setNativePointer(arg.CreateInstance()); //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); return 1; /* xwin x = new xwin; x.setNativePointer(h); m_winHwnd = x.GetHWND(); xstring sh = doc.GetXml(); int p = cast(sh as int); win32::SendMessage(m_winHwnd, 0x401, p, 0); */ return 1; } //T}NäYtN‹Nö int OnXCommand(TEvent* evt, int param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnDoubleClicked(TEvent* evt, int p) { DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh; xstring colname = hdr->colname; xstring value = hdr->data; int row = hdr->row; dw_goods.AcceptText(); HCURSOR hCursor = xutil::SetCursorWait(); if (colname == L"CurPOPrice") { xstring str = dw_goods.GetItemDisplayString(row, L"CurPOPrice"); //xstring str =dw_goods.GetItemString(row,L"POPrices"); if (str.find(L"[", 0) > 0) { xstring val = str.left(str.find(L"[", 0)); xstring val1 = val; if (val.right(1) == L"A" or val.right(1) == L"B" or val.right(1) == L"C") val1 = val.left(val.length() - 1); dw_goods.ItemChangeTo(dw_goods.GetRow(), L"POPrice", val1); dw_goods.SetItemDisplayString(dw_goods.GetRow(), L"POPrice", val); } //alert(dw_goods.GetItemString(dw_goods.GetRow(),L"CurPOPrice")); dw_goods.SetItemString(dw_goods.GetRow(), L"EnquiryPriceListID", dw_goods.GetItemString(dw_goods.GetRow(), L"CurPOPrice")); //dw_goods.SetItemString(dw_goods.GetRow(),L"EnquiryLineID", // dw_goods.GetItemString(dw_goods.GetRow(),L"CurPOPrice")); } dw_goods.Redraw(); xutil::RestoreCursor(hCursor); return 1; } int OnAttachEvent() { //~Ñ[š]åQwgap¹QûN‹Nö AttachEvent(L"WM_XCOMMAND", (FEvent)&Quote3MaintWin::OnXCommand); //ƒ·SÖq&p¹N‹Nöÿ u(NŽ‘Ín]åQwga AttachEvent(L"WM_SETFOCUS", (FEvent)&Quote3MaintWin::OnSetFocus); AttachEvent(L"dw_goods", L"DWV_ITEMCHANGED", (FEvent)&Quote3MaintWin::OnItemChanged); AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", (FEvent)&Quote3MaintWin::OnBaseItemChanged); AttachEvent(L"im1", L"IMG_LDBCLICK", (FEvent)&Quote3MaintWin::OnImgDBClicked); AttachEvent(L"dw_goods", L"DWV_ROWFOCUSCHANGED", (FEvent)&Quote3MaintWin::OnRowChanged); AttachEvent(L"dw_goods", L"DWV_ASKSTYLE", (FEvent)&Quote3MaintWin::OnItemAskStyle); AttachEvent(L"dw_goods", L"DWV_DOUBLECLICKED", (FEvent)&Quote3MaintWin::OnDoubleClicked);//ˆLSÌQû AttachEvent(L"dw_goods", L"DWV_ITEMCHANGING", (FEvent)&Quote3MaintWin::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; #if 1 if (value == L"") return 1; xstring cellType = dw_goods.GetColumnProp(colname.c_str(), L"celltype"); if (cellType == L"xs:decimal" || cellType == L"xs:integer") { if (value.isNumber() == false) { alert(value + L"N f/ep[W!"); hdr->idFrom = -1; return 1; } } #endif // 0 } int OnRetrieve(xstring id) { xml x; xaserverarg& arg = *new xaserverarg; arg.setNativePointer(arg.CreateInstance()); arg.AddArg(L"id", id); //alert(id); if (getUrl(L"/sale/data/Quote/maint", arg.GetString(), x) != 1) { trace(x.text()); return -1; } else { trace(x.xml()); dw_base.Retrieve(x); dw_base.Redraw(); dw_goods.Retrieve(x); dw_goods.Redraw(); if (dw_goods.GetRowCount() > 0) { ximageview im = GetControl(L"im1"); im.Reset(); xstring skuno = dw_goods.GetItemString(1, L"SKUNo"); OnShowImage(skuno, 1); im.Redraw(); } } return 1; } xstring GetExchangeRate(xstring pcur, xstring pdate) { if (pcur.toUpper() == L"RMB") return 1; xstring exchangeRate = L""; if (exchangeRate == L"") { xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/param", L"item", L"cryrate"); if (x.selectSingleNode(L"root/item/@value")) exchangeRate = x.selectSingleNode(L"root/item/@value").text(); } /*xml x = new xml; x.setNativePointer(xml::CreateInstance()); xaserverarg args=new xaserverarg; args.setNativePointer(args.CreateInstance()); args.AddArg(L"currency", pcur); if(pdate != L"") args.AddArg(L"date", pcur); xstring ls_date=L""; if(xaserver::ExecXQuery(L"",L"[GetCurrencyExchangeRate.xq]",args.GetString(),x)==1) { KXMLDOMElement e= x.documentElement; if(e) if(e.selectSingleNode(L"ExchangeRate")) ls_date = e.selectSingleNode(L"ExchangeRate").text; //e.getAttribute(L"date"); } return ls_date+L""; */ return exchangeRate; } xstring GetExchangeRate(xstring pcur) { return GetExchangeRate(pcur, L""); } int OnInit() { //QlSøb¬Y40b¥N÷Nº0b¥N÷eåg xstring sdate = publiccode::GetCurrentDate(); dw_base.SetItemString(1, L"QuoteDate", sdate); xstring suserid = publiccode::GetUser().id; xstring susername = publiccode::GetUser().name; dw_base.SetItemString(1, L"SalespersonID", suserid); dw_base.SetItemDisplayString(1, L"SalespersonID", susername); dw_base.SetItemString(1, L"CurrencyCode", L"USD"); dw_base.SetItemDisplayString(1, L"CurrencyCode", L"USD"); xstring exchangeRate = L""; xml x = ViewObject::RetrieveData(L"/sale/data/GDN3/profit/paramEx", L"ETD", sdate); if (x.selectSingleNode(L"root/item/@value")) exchangeRate = x.selectSingleNode(L"root/item/@value").text(); if (exchangeRate != L"") { dw_base.SetItemString(1, L"ExchangeRate", exchangeRate); } else { dw_base.SetItemString(1, L"ExchangeRate", L"6.49"); } //dw_base.SetItemString(1,L"ExchangeRate",GetExchangeRate(L"USD")); dw_base.SetItemString(1, L"CompanyID", L"E9E3C542-062C-4957-B8F4-9B92C3E351FC"); dw_base.SetItemDisplayString(1, L"CompanyID", L"[lâ[¶\OsÛQúSãg –PQlSø"); /*xstring ss = L"select (select EnglishName from Party where PartyID = CompanyID) as 'CompanyID/@_displaystring',CompanyID from HR_Org where OrgID = '{$id}' for xml PATH('root'),ELEMENTS XSINIL"; xstring scguid; xstring sCename; xml x1 = RetrieveSqlData(ss,L"id",sg); KXMLDOMElement e1 = x1.documentElement; scguid = sureNodeText(e1,L"CompanyID"); sCename = sureNodeText(e1,L"CompanyID/@_displaystring"); */ return 1; } int QuoteList(xstring QuoteID) { xml x; xaserverarg arg; arg.setNativePointer(arg.CreateInstance()); arg.AddArg(L"id", QuoteID); if (getUrl(L"/sale/data/Quote/maintOne", arg.GetString(), x) != 1) { trace(x.text()); return -1; } else { dw_base.Retrieve(x); dw_base.Redraw(); dw_goods.Retrieve(x); dw_goods.Redraw(); if (dw_goods.GetRowCount() > 0) { ximageview im = GetControl(L"im1"); im.Reset(); xstring skuno = dw_goods.GetItemString(1, L"SKUNo"); OnShowImage(skuno, 1); im.Redraw(); } } dw_base.SetItemString(1, L"QuoteNo", L""); return 1; } int onload() { dw_goods = GetControl(L"dw_goods"); //dw_goods .openUrl(L"/sale/view/Quote3/template/goods"); dw_goods.openUrl(L"/sale/view/Quote3/template/item/pricelist"); dw_goods.SetColumnState(L"ItemID", false); dw_goods.SetColumnState(L"EnquiryLineID", false); dw_goods.SetColumnState(L"EnquiryPriceListID", false); dw_goods.SetColumnState(L"POPrices", false); dw_goods.SetColumnState(L"ClassifyID", false); dw_goods.SetColumnState(L"Description", false); dw_goods.SetAskStyle(true); dw_base = GetControl(L"dw_base"); dw_base.openUrl(L"/sale/view/Quote3/template/base"); //dw_base.SetSelectionBorder(0); dw_base.SetColHeaderHeight(0); dw_base.SetRowSelectorWidth(0); dw_base.SetHScrollState(false); dw_base.SetVScrollState(false); if (GetWinParam()) { xaserverarg arg = GetArg(); xstring QName = arg.GetArgString(L"QuoteName"); if (QName != L"") { if (arg.GetArgString(L"QuoteID") != L"") { QuoteList(arg.GetArgString(L"QuoteID")); } } //alert(arg.GetString()); xstring QuoteNo = arg.GetArgString(L"QuoteNo"); if (QuoteNo == L"") QuoteNo = arg.GetArgString(L"EntityNo"); if (QuoteNo != L"") { OnRetrieve(QuoteNo); } else { OnInit(); if (arg.GetArgString(L"CustomerID") != L"") { dw_base.SetItemDisplayString(1, L"CustomerID", arg.GetArgString(L"CustomerName")); dw_base.ItemChangeTo(1, L"CustomerID", arg.GetArgString(L"CustomerID")); xstring dwname = L"dw_base"; xstring colname = L"CustomerID"; xstring value = arg.GetArgString(L"CustomerID"); KXMLDOMNodeList nlist = GetElement().selectNodes(L"//*[@name='" + dwname + L"']/trans[@for='" + colname + L"']"); ViewObject::TransData(GetServerUrl(), nlist, dw_base, 1, colname, value); } } } else OnInit(); OnAttachEvent(); //dw_base.SetEditUpperMode(true); //dw_goods.SetEditUpperMode(true); return 1; } int OnAskGoodsNo() { int rowCount = dw_goods.GetRowCount(); xstring skunos = L""; for (int i = 1; i <= rowCount; i++) { if (dw_goods.GetItemString(i, L"SKUNo") != L"" && dw_goods.GetItemString(i, L"GoodsNo") == L"") { if (skunos == L"") skunos = dw_goods.GetItemString(i, L"SKUNo"); else skunos += L",L" + dw_goods.GetItemString(i, L"SKUNo"); } } xaserverarg arg; arg.AddArg(L"SKUNoList", skunos); OpenWindow(L"dev:xpage[Product.FetchNo.vx]", (LPARAM) & arg); return 1; } int onloaded() { SetAgent(); return 1; } };