| | |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | class __declspec(dllexport) ProductSelectWin : public xwin |
| | | { |
| | | public: |
| | | HWND hObject = 0; |
| | | xstring CustomerID; |
| | | xstring m_customer; |
| | | public: |
| | | ProductSelectWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} |
| | | public: |
| | | static ProductSelectWin* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | public: |
| | | int hObject = 0; |
| | | xstring CustomerID; |
| | | xstring m_customer; |
| | | public: |
| | | ProductSelectWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} |
| | | public: |
| | | static ProductSelectWin* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | ProductSelectWin* pWin = new ProductSelectWin(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | //产品库产品列表 |
| | | xdwgrid dw_list; |
| | | //购物车产品列表 |
| | | xdwgrid dwc_list; |
| | | ProductSelectWin* pWin = new ProductSelectWin(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | //产品库产品列表 |
| | | xdwgrid dw_list; |
| | | //购物车产品列表 |
| | | xdwgrid dwc_list; |
| | | |
| | | //产品缓存对象 |
| | | xdataset g_xdoc_product; |
| | | xdataset g_xdoc_shoppingcart; |
| | | //产品缓存对象 |
| | | //xdataset g_xdoc_product; |
| | | //xdataset g_xdoc_shoppingcart; |
| | | |
| | | xcombobox cbx_goodscar; |
| | | //是否多选 |
| | | xcombobox cbx_goodscar; |
| | | //是否多选 |
| | | |
| | | xnode m_agentNode; //Agent Condition |
| | | xtreeview tv_folder; |
| | | xstring agentFor; |
| | | xnode m_agentNode; //Agent Condition |
| | | xtreeview tv_folder; |
| | | xstring agentFor; |
| | | |
| | | xstring impStr; |
| | | xstring impStr; |
| | | |
| | | int FillGoodsCarList() |
| | | { |
| | | xcombobox xc = GetControl(L"frame:cbx_goodscar"); |
| | | if(!xc) return 0; |
| | | xml x = ShoppingCartView::GetRoleList(CustomerID); |
| | | if(!x) return 0; |
| | | xc.SetText(L"==选择购物车==L"); |
| | | int FillGoodsCarList() |
| | | { |
| | | xcombobox xc = GetControl(L"frame:cbx_goodscar"); |
| | | if(!xc) return 0; |
| | | xml x = ShoppingCartView::GetRoleList(CustomerID); |
| | | if(!x) return 0; |
| | | xc.SetText(L"==选择购物车==L"); |
| | | |
| | | KXMLDOMNodeList nlist = x.selectNodes(L"//item"); |
| | | int len = nlist.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"name"); |
| | | xcombobox::AddItem(xc.GetId(),name); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | //焦点激活处理函数 |
| | | int OnSetFocus(TEvent* evt, LPARAM param) |
| | | { |
| | | //重置工具条 |
| | | SetAgent(); |
| | | return 1; |
| | | } |
| | | |
| | | KXMLDOMElement OnGetCarListRowElement(int row=0) |
| | | { |
| | | if(row < 1) row = dwc_list.GetRow(); |
| | | if(row < 1 || row > dwc_list.GetRowCount()) return 0; |
| | | KXMLDOMElement e = g_xdoc_shoppingcart.getRowElement(L"data/Item", row); |
| | | return e; |
| | | } |
| | | |
| | | int OnShowImage(xstring skuid) |
| | | { |
| | | imageview im = GetControl(L"im1"); |
| | | //im.RemoveImage(); |
| | | im.ResetEx(); |
| | | |
| | | xml xp=new xml; |
| | | |
| | | xaserverarg arg_pic; |
| | | arg_pic.setNativePointer(arg_pic.CreateInstance()); |
| | | arg_pic.AddArg(L"SKUID",skuid); |
| | | if(xurl::get(L"/sale/data/ProductLibrary3/pref/picture/imagelistSKU",arg_pic.GetString(),xp)!=1) |
| | | { |
| | | trace(L"xxx",xp.xml()); |
| | | }else |
| | | { |
| | | //imageElement = xp.documentElement(); |
| | | 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, L""); |
| | | } |
| | | im.Redraw(); |
| | | //SendMessage(im.GetId(),0x000f,0,1); |
| | | //InvalidateRect(im.GetId(),cast(0 as ref xrect),true); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnShowImage(xstring skuid, xstring customerItemNo) |
| | | { |
| | | imageview im = GetControl(L"im1"); |
| | | //im.RemoveImage(); |
| | | im.ResetEx(); |
| | | |
| | | xml xp=new xml; |
| | | |
| | | xaserverarg arg_pic; |
| | | arg_pic.setNativePointer(arg_pic.CreateInstance()); |
| | | arg_pic.AddArg(L"SKUID",skuid); |
| | | arg_pic.AddArg(L"CustomerID",m_customer); |
| | | arg_pic.AddArg(L"CustomerItemNo",customerItemNo); |
| | | |
| | | if(xurl::get(L"/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKU",arg_pic.GetString(),xp)!=1) |
| | | { |
| | | trace(L"error:" + xp.xml()); |
| | | }else |
| | | { |
| | | //imageElement = xp.documentElement(); |
| | | 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, L""); |
| | | } |
| | | im.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int ItemAdd() |
| | | { |
| | | int hItem = tv_folder.GetSelectedItem(); |
| | | int hTopItem = LookupTopFolder(hItem); |
| | | xstring name = tv_folder.GetItemLabel(hTopItem); |
| | | |
| | | KXMLDOMElement e= tv_folder.GetItemData(hItem); |
| | | xstring guid = e.getAttribute(L"guid"); |
| | | if(guid==L"") return 1; |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"guid", e.getAttribute(L"guid")); |
| | | if(name==L"个人产品") |
| | | arg.AddArg(L"FolderID", e.getAttribute(L"guid")); |
| | | else |
| | | arg.AddArg(L"CategoryID", e.getAttribute(L"guid")); |
| | | xstring No = e.getAttribute(L"CategoryNo"); |
| | | if(No==L"") No = e.getAttribute(L"no"); |
| | | xstring Name = e.getAttribute(L"CName"); |
| | | if(Name==L"") Name = e.getAttribute(L"cname"); |
| | | arg.AddArg(L"No",No); |
| | | arg.AddArg(L"CName",Name); |
| | | int p = arg; |
| | | OpenWindow(L"dev:xpage[Quick.Input.NewProduct.vx]",p); |
| | | //if(arg.GetArgString(L"data.modify")==L"1")RetrieveData(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnRowChanged(ref TNotifyEvent evt,int p) |
| | | { |
| | | ref DWNMHDR hdr = trust(evt.pnmh as ref DWNMHDR); |
| | | int row = hdr.row; |
| | | |
| | | htmlctrl xs = GetControl(L"html_detail"); |
| | | xstring html = makeHtml(row); |
| | | xs.SetContent(html); |
| | | xs.Redraw(); |
| | | |
| | | xstring id = g_xdoc_product.getData(0,L"data/Item",row,L"@guid"); |
| | | OnShowImage(id); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnGoodsCarRowChanged(ref TNotifyEvent evt,int p) |
| | | { |
| | | ref DWNMHDR hdr = trust(evt.pnmh as ref DWNMHDR); |
| | | int row = hdr.row; |
| | | |
| | | htmlctrl xs = GetControl(L"html_detail"); |
| | | xstring html = makeGoodscarHtml(row); |
| | | xs.SetContent(html); |
| | | xs.Redraw(); |
| | | if(m_customer) |
| | | { |
| | | xstring id = g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"SKUID"); |
| | | xstring customerItemNo = g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"CustomerItemNo"); |
| | | OnShowImage(id,customerItemNo); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int DeleteRow(int row) |
| | | { |
| | | int IDOK = 1; |
| | | int MB_OKCANCEL = 1; |
| | | int MB_ICONQUESTION = 32; |
| | | if(MessageBox(GetHWND(),L"确认删除指定的项,删除后将不能恢复?",L"提示",MB_OKCANCEL|MB_ICONQUESTION)!=IDOK) return 1; |
| | | xstring id = g_xdoc_product.getData(0,L"data/Item",row,L"@guid"); |
| | | |
| | | if(ProductLibraryView::DeleteItem(id)==1) dw_list.DeleteRow(0); |
| | | return 1; |
| | | } |
| | | |
| | | int SetSelectState(xdwgrid dw_obj, int state) |
| | | { |
| | | dw_obj.SetSelectionMode(3); |
| | | return 1; |
| | | } |
| | | |
| | | int OnCkbCLick(ref TEvent evt,int p) |
| | | KXMLDOMNodeList nlist = x.selectNodes(L"//item"); |
| | | int len = nlist.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | xcheckbox cbx_1 = GetControl(L"frame:cbx1"); |
| | | int state=cbx_1.GetCheck(cbx_1.GetId()); |
| | | return SetSelectState(dw_list,state); |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"name"); |
| | | xc.AddItem(name); |
| | | } |
| | | |
| | | int OnCkbCLick2(ref TEvent evt,int p) |
| | | { |
| | | xcheckbox cbx_2 = GetControl(L"frame:cbx2"); |
| | | int state=cbx_2.GetCheck(cbx_2.GetId()); |
| | | return SetSelectState(dwc_list,state); |
| | | } |
| | | |
| | | xml GetGoodsPropList(xstring guid) |
| | | return 1; |
| | | } |
| | | |
| | | int SetAgent() |
| | | { |
| | | xstring xfNodeAgentArea = L"agentarea"; |
| | | xnode anode = GetAgentNode(xfNodeAgentArea); |
| | | if(m_agentNode) |
| | | { |
| | | xml x=new xml; |
| | | |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"guid", guid); |
| | | if(xurl::get(L"/sale/data/SO/goods/goodsprop/list", arg.GetString(),x)!=1) |
| | | { |
| | | xstring error = x.text(); |
| | | alert(error); |
| | | } |
| | | return x; |
| | | SetAgentNode (anode,m_agentNode); |
| | | } |
| | | |
| | | |
| | | xml GetGoodsPropListEx(xstring guid) |
| | | { |
| | | xml x=new xml; |
| | | |
| | | xstring fields=L"<data>"; |
| | | |
| | | /* |
| | | fields +=L"<field name='HighestPrice' label='最高价'/>"; |
| | | fields +=L"<field name='LowestPrice' label='最低价'/>"; |
| | | |
| | | fields +=L"<field name='BulkPrice' label='散货价'/>"; |
| | | fields +=L"<field name='CardPrice' label='纸卡价'/>"; |
| | | fields +=L"<field name='BuyPrice' label='采购价'/>"; |
| | | fields +=L"<field name='SupplierID' label='货源'/>"; |
| | | */ |
| | | |
| | | fields +=L"<field name='Packing' label='包装方式'/>"; |
| | | fields +=L"<field name='PackingRate' label='每箱数量'/>"; |
| | | fields +=L"<field name='VolumeDesc' label='包装尺码'/>"; |
| | | fields +=L"<field name='GWPerPkg' label='毛重'/>"; |
| | | fields +=L"<field name='NWPerPkg' label='净重'/>"; |
| | | //fields +=L"<field name='DeveloperID' label='开发人员'/>"; |
| | | fields +=L"<field name='AttributeValue_1' label='产品属性'/>"; |
| | | //fields +=L"<field name='Remark' label='备注'/>"; |
| | | |
| | | fields += L"</data>"; |
| | | x.loadXML(fields); |
| | | |
| | | return x; |
| | | } |
| | | |
| | | xstring makeHtml(int row) |
| | | { |
| | | xstring id = g_xdoc_product.getData(0,L"data/Item",row,L"@guid"); |
| | | xml x = GetGoodsPropList(id); |
| | | xml x1 = GetGoodsPropListEx(id); |
| | | |
| | | xstring html=L"<html><style> .text(){ font-weight:400} .label { font-weight:400;}</style><body style='margin:2;background-color1:#ccdccc none #f0f0f0 none'>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >编号:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"No")+ |
| | | "</span> <span style='font-weight:700;width:50;font-size:10pt' >类项:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"RefNo")+ |
| | | "</span></div>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >货号:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"GoodsNo")+ |
| | | "</span></div>" ; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >品名:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"CName")+ |
| | | "</span></div>" ; |
| | | if(dw_list.GetItemString(row,L"CSpec")!=L"") |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >规格:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"CSpec")+ |
| | | "</span></div>" ; |
| | | |
| | | KXMLDOMNodeList fieldsEx = x1.selectNodes(L"data/field"); |
| | | xstring ls_detail=L""; |
| | | xstring ls_item =L""; |
| | | xstring name; |
| | | xstring label; |
| | | int len = fieldsEx.length(); |
| | | int i= 0; |
| | | |
| | | for(i=0;i<len; true) |
| | | { |
| | | int cnt = 0; |
| | | ls_item = L""; |
| | | while(cnt < 2) |
| | | { |
| | | name = fieldsEx.item(i).selectSingleNode(L"@name").text(); |
| | | label = fieldsEx.item(i).selectSingleNode(L"@label").text(); |
| | | ls_item += L"<td>" + label + L"</td>" + L"<td style='text-align:center'>" + g_xdoc_product.getData(0,L"data/Item",row,name) + L"</td>" ; |
| | | cnt++; |
| | | i++; |
| | | if(i ==len)break; |
| | | } |
| | | ls_detail += L"<tr>" + ls_item + L"</tr>"; |
| | | } |
| | | html += L"<div style='margin-left:8px;margin-right:16px;'>" + |
| | | +L"<table><colgroup span='1' width='70'/><colgroup span='1' width='120'/><colgroup span='1' width='70'/><colgroup span='1' width='120'/>" |
| | | + ls_detail |
| | | +L"</table>" |
| | | +L"</div>" ; |
| | | |
| | | xstring ls_star=L""; |
| | | KXMLDOMNodeList fields = x.selectNodes(L"data/field"); |
| | | len = fields.length(); |
| | | |
| | | ls_detail = L""; |
| | | if(len > 0) |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >技术要求:</span></div>" ; |
| | | for(i=0;i<len; true) |
| | | { |
| | | ls_item=L""; |
| | | |
| | | int count = 0; |
| | | while(count < 2) |
| | | { |
| | | name = fields.item(i).selectSingleNode(L"@name").text(); |
| | | label = fields.item(i).selectSingleNode(L"@label").text(); |
| | | |
| | | if(name==L"QualityTerm" || name==L"PackTerm" || label==L"质量" || label==L"包装质量" || label==L"技术要求") |
| | | { |
| | | i++; |
| | | if(i >= len)count = 2; |
| | | continue; |
| | | } |
| | | else if(g_xdoc_product.getData(0,L"data/Item",row,name)==L"") |
| | | { |
| | | KXMLDOMNodeList options = fields.item(i).selectNodes(L"item"); |
| | | int tlen = options.length(); |
| | | xstring terms = L"" ; |
| | | for(int k=0; k<tlen; k++) |
| | | { |
| | | if(options.item(k).text()) |
| | | { |
| | | if(k>0) terms += L", L"; |
| | | terms += L"[" + options.item(k).text() +L"]"; |
| | | } |
| | | } |
| | | ls_star += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >" + label +L"*:</span><span style='width:90;font-size:10pt'>" + terms + L"</span></div>" ; |
| | | }else |
| | | { |
| | | ls_item = L"<td>" + label + L"</td>" + L"<td>" + g_xdoc_product.getData(0,L"data/Item",row,name) + L"</td>" ; |
| | | count++; |
| | | } |
| | | i++; |
| | | if(i >= len)count = 2; |
| | | } |
| | | ls_item = L"<tr>" + ls_item + L"</tr>"; |
| | | ls_detail += ls_item; |
| | | } |
| | | |
| | | html += L"<div style='margin-left:8px;margin-right:16px;'>" + |
| | | +L"<table><colgroup span='1' width='70'/><colgroup span='1' width='120'/><colgroup span='1' width='70'/><colgroup span='1' width='120'/>" |
| | | + ls_detail |
| | | +L"</table>" |
| | | +L"</div>" ; |
| | | if(dw_list.GetItemString(row,L"QualityTerm")!=L"") |
| | | { |
| | | html += L"<div style='height:12px'/>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >质量:</span></div>" ; |
| | | html += L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + dw_list.GetItemString(row,L"QualityTerm") + L"</span></div>" ; |
| | | } |
| | | |
| | | if(dw_list.GetItemString(row,L"PackTerm")!=L"") |
| | | { |
| | | html += L"<div style='height:12px'/>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >包装质量:</span></div>" ; |
| | | html += L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + dw_list.GetItemString(row,L"PackTerm") + L"</span></div>" ; |
| | | } |
| | | |
| | | if(g_xdoc_product.getData(0,L"data/Item",row,L"Remark") != L"" && id == L"23A8BBA2-DEF1-4C00-978E-646151A6082E") |
| | | { |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >备注:</span></div>" ; |
| | | html += L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + g_xdoc_product.getData(0,L"data/Item",row,L"Remark") + L"</span></div>" ; |
| | | } |
| | | |
| | | html += L"<div style='height:24px'/>"; |
| | | |
| | | //星标项 |
| | | html += ls_star; |
| | | |
| | | //显示图片 |
| | | /*xstring picname = L"1FA9E331-F95C-4E51-B80C-73FB9B911D8D.jpg";//dw_list.GetItemString(row,L"ImgName"); //ItemID+L".jpg"; |
| | | xstring str = picname.mid(0,2); |
| | | str = str.upper(); |
| | | xstring serversrc =L"http://192.168.7.241:1001/business/products/chanpin/"+str+L"/"+picname; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >ͼƬ:</span>"; |
| | | html += L"<control visible='layer' controlclass='ximage' data='' src='"+ serversrc +L"'/></div>"; |
| | | */ |
| | | html += L"</body></html>"; |
| | | return html; |
| | | } |
| | | |
| | | xstring makeGoodscarHtml(int row) |
| | | { |
| | | xstring No = dwc_list.GetItemString(row,L"RefNo");//获取属性值id |
| | | xml x = GetGoodsPropList(No); |
| | | |
| | | xstring html=L"<html><style> .text(){ font-weight:400} .label { font-weight:400;}</style><body style='margin:2;background-color1:#ccdccc none #f0f0f0 none'>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >编号:</span><span style='width:90;font-size:10pt'>" + dwc_list.GetItemString(row,L"No")+ |
| | | "</span></div>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >品名:</span><span style='width:90;font-size:10pt'>" + dwc_list.GetItemString(row,L"CName")+ |
| | | "</span></div>" ; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >规格:</span><span style='width:90;font-size:10pt'>" + dwc_list.GetItemString(row,L"CSpec")+ |
| | | "</span></div>" ; |
| | | |
| | | KXMLDOMNodeList fields = x.selectNodes(L"data/field"); |
| | | int len = fields.length(); |
| | | html += L"<table>" + |
| | | "<colgroup span='1' width='80'/>" + |
| | | "<colgroup span='1' width='120'/>" + |
| | | "<colgroup span='1' width='420'/>" ; |
| | | html += L"<tr>" ; |
| | | html += L"<td style='text-align:center'>编号</td><td style='text-align:center'>项目</td><td style='text-align:center'>内容</td>" ; |
| | | html +=L"</tr>"; |
| | | for(int i=0;i<len; i++) |
| | | { |
| | | xstring name = fields.item(i).selectSingleNode(L"@name").text(); |
| | | xstring label = fields.item(i).selectSingleNode(L"@label").text(); |
| | | html += L"<tr>" ; |
| | | if(i==0) |
| | | html += L"<td rowspan='" + len.toString() + L"'>" + No + L"</td><td >"+ label + L"</td><td >"+L"</td>" ; |
| | | else |
| | | html += L"<td >"+ label + L"</td><td >"+ g_xdoc_shoppingcart.getData(0,L"data/Item",row,name)+L"</td>" ; |
| | | html +=L"</tr>"; |
| | | } |
| | | |
| | | html += L"<tr>" ; |
| | | html += L"<td rowspan='3'>" + g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"PackCode") + L"</td><td >包装方式</td><td >"+ |
| | | g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"CPack") + L"</td>" ; |
| | | html +=L"</tr>"; |
| | | html += L"<tr height='48'>" ; |
| | | html += L"<td >包装要求</td><td >"+ g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"PackQualityTerm")+L"</td>" ; |
| | | html +=L"</tr>"; |
| | | html += L"<tr>" ; |
| | | html += L"<td >侧唛</td><td ></td>" ; |
| | | html +=L"</tr>"; |
| | | |
| | | html += L"<tr height='72'>" ; |
| | | html += L"<td>" + g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"QualityCode") + L"</td><td >质量要求</td><td >"+ |
| | | g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"QualityTerm") + L"</td>" ; |
| | | html +=L"</tr>"; |
| | | |
| | | html +=L"</table>"; |
| | | |
| | | html += L"</body></html>"; |
| | | return html; |
| | | } |
| | | |
| | | int OnImport() |
| | | { |
| | | if(!hObject ) return 1; |
| | | |
| | | int rw = 0; |
| | | xstring ls_nos = L"ImportXml:"; |
| | | |
| | | if (impStr==L"") |
| | | { |
| | | alert(L"请选择商品!"); |
| | | return 1; |
| | | } |
| | | ls_nos += impStr; |
| | | trace(impStr); |
| | | dwc_list.SelectRow(0,false); |
| | | dwc_list.Redraw(); |
| | | dw_list.SelectRow(0,false); |
| | | dw_list.Redraw(); |
| | | impStr =L""; |
| | | //alert(ls_nos); |
| | | SendMessage(hObject,0x401,ls_nos,0); |
| | | alert(L"转入完成"); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnSearch() |
| | | { |
| | | int hItem = tv_folder.GetSelectedItem(); |
| | | return RetrieveItem(hItem); |
| | | } |
| | | |
| | | //命令发布函数 |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | int hCursor; |
| | | xstring name=L""; |
| | | if(comdid==L"xmClose") |
| | | { |
| | | CloseWindow(); |
| | | return 1; |
| | | } |
| | | else if(comdid==L"xmImport") |
| | | { |
| | | OnImport(); |
| | | return 1; |
| | | } |
| | | else if(comdid==L"xmAdd") |
| | | { |
| | | ItemAdd(); |
| | | return 1; |
| | | } |
| | | else if(comdid==L"xmSearch") |
| | | { |
| | | OnSearch(); |
| | | return 1; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | //命令处理事件 |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | //查找当前树项的顶级目录 |
| | | int LookupTopFolder(int hItem) |
| | | { |
| | | int hRoot = tv_folder.GetRootItem(); |
| | | while(tv_folder.GetParentItem(hItem)) hItem = tv_folder.GetParentItem(hItem); |
| | | return hItem; |
| | | } |
| | | |
| | | //插入产品类项的子项 |
| | | int MakeGoodsFolderItem(int hItem, xstring sno) |
| | | { |
| | | xml x = ProductLibraryView::GetTreeChildItems3(sno); |
| | | if(!x) return 0; |
| | | |
| | | KXMLDOMNodeList nlist = x.selectNodes(L"//Item"); |
| | | int len = nlist.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"CName"); |
| | | xstring no = e.getAttribute(L"CategoryNo"); |
| | | xstring label = no.trim() + L" " + name; |
| | | |
| | | int h= tv_folder.InsertChildItem(hItem,label, trust(e as int),15); |
| | | tv_folder.SetItemChild(h,1); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //插入新产品目录子项 |
| | | int MakeUserGoodsFolderItem(int hItem, xstring sno) |
| | | { |
| | | xml x = ProductLibraryView::GetTreeUserChildItems3(sno); |
| | | if(!x) return 0; |
| | | |
| | | KXMLDOMNodeList nlist = x.selectNodes(L"//Item"); |
| | | int len = nlist.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"CName"); |
| | | xstring no = e.getAttribute(L"CategoryNo"); |
| | | xstring label = no.trim() + L" " + name; |
| | | |
| | | int h= tv_folder.InsertChildItem(hItem,label, trust(e as int),15); |
| | | xstring child = e.getAttribute(L"Childs"); |
| | | if(child==L"") |
| | | tv_folder.SetItemChild(h,1); |
| | | else if(child !=L"0") |
| | | tv_folder.SetItemChild(h,1); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //插入购物车项 |
| | | int ExpandCatChildFolder(int hItem, KXMLDOMElement ele ,int image) |
| | | { |
| | | KXMLDOMNodeList nlist = ele.selectNodes(L"item"); |
| | | int len = nlist.length(); |
| | | if(len > 0) tv_folder.SetItemChild(hItem,1); |
| | | for (int i= 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"name"); |
| | | int h = tv_folder.InsertChildItem(hItem,name, trust(e as int),image); |
| | | ExpandCatChildFolder(h,e,35); |
| | | } |
| | | return 1; |
| | | } |
| | | int MakeGoodCarFolderItem(int hItem) |
| | | { |
| | | //trace(L"\r\nCustomerID:"+CustomerID); |
| | | xml x = ShoppingCartView::GetRoleList(CustomerID); |
| | | //if(x) alert(x.xml()); |
| | | if(!x) return 0; |
| | | KXMLDOMNodeList nlist = x.selectNodes(L"/data/item"); |
| | | int len = nlist.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"name"); |
| | | int h = tv_folder.InsertChildItem(hItem,name, trust(e as int),35); |
| | | ExpandCatChildFolder(h,e,35); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //树展开 |
| | | int OnTreeExpanding(ref TNotifyEvent evt,int p) |
| | | { |
| | | ref NMTREEVIEW nmtv = evt.pnmh; |
| | | int hItem = nmtv.itemNew.hItem; |
| | | int hTopItem = LookupTopFolder(hItem); |
| | | xstring name = tv_folder.GetItemLabel(hTopItem); |
| | | int child = tv_folder.GetChildItem(hItem); |
| | | xstring no =L""; |
| | | KXMLDOMElement e; |
| | | if(name == L"公司库" && !child ) |
| | | { |
| | | no =L""; |
| | | if(hTopItem != hItem) |
| | | { |
| | | e= tv_folder.GetItemData(hItem); |
| | | no = e.getAttribute(L"categoryid"); |
| | | }else |
| | | { |
| | | e= tv_folder.GetItemData(hItem); |
| | | no = e.getAttribute(L"categoryid"); |
| | | } |
| | | MakeGoodsFolderItem(hItem, no); |
| | | } |
| | | else if(name == L"个人库" && !child ) |
| | | { |
| | | no =L""; |
| | | if(hTopItem != hItem) |
| | | { |
| | | e= tv_folder.GetItemData(hItem); |
| | | no = e.getAttribute(L"categoryid"); |
| | | MakeUserGoodsFolderItem(hItem, no); |
| | | } |
| | | } |
| | | else if(name == L"购物车" && !child ) |
| | | { |
| | | if(hItem==hTopItem)MakeGoodCarFolderItem(hItem); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int ResetAgent(xstring agentAsk) |
| | | { |
| | | if(agentFor != agentAsk) |
| | | { |
| | | agentFor = agentAsk; |
| | | m_agentNode = 0; |
| | | SetAgent(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int LookupCustomerFolder(int hItem) |
| | | { |
| | | while(true) |
| | | { |
| | | KXMLDOMElement e1 = cast(tv_folder.GetItemData(hItem) as KXMLDOMElement); |
| | | xstring str = e1.getAttribute(L"no"); |
| | | if(str.find(L"Customer:")>=0) return hItem; |
| | | hItem = tv_folder.GetParentItem(hItem); |
| | | if(hItem==0) break; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | xstring LookupCustomer(int hItem) |
| | | { |
| | | hItem = LookupCustomerFolder(hItem); |
| | | if(hItem==0) return ""; |
| | | KXMLDOMElement e1 = cast(tv_folder.GetItemData(hItem) as KXMLDOMElement); |
| | | xstring str = e1.getAttribute(L"no"); |
| | | return str.mid(L"Customer:".length()(),9999); |
| | | } |
| | | |
| | | int RetrieveItem(int hItem) |
| | | { |
| | | int hTopItem = LookupTopFolder(hItem); |
| | | xstring name = tv_folder.GetItemLabel(hTopItem); |
| | | xstring selectname = tv_folder.GetItemLabel(hItem); |
| | | imageview im = GetControl(L"im1"); |
| | | m_customer = L""; |
| | | xcontrol query = GetControl(L"sl_search"); |
| | | xstring queryString = query.GetText(); |
| | | |
| | | if(name == L"购物车") |
| | | { |
| | | if(agentFor !=L"goodscar")SwitchLayer(L"goodscarsheet",L"sheetframe"); |
| | | ResetAgent(L"goodscar"); |
| | | if(selectname !=name) |
| | | { |
| | | KXMLDOMElement e1 = cast(tv_folder.GetItemData(hItem) as KXMLDOMElement); |
| | | xstring str = e1.getAttribute(L"no"); |
| | | |
| | | trace(L"\r\n-------"+str+L"--------"+queryString); |
| | | |
| | | if(str==L"Supplier") |
| | | { |
| | | return 1; |
| | | } |
| | | //alert(str); |
| | | if(str.find(L"Customer:")==0 || str.find(L"SO:")==0 || str.find(L"Purcherex:")==0|| str.find(L"Purcher:")==0 || str.find(L"Supplier:")==0|| str.find(L"Enquiry:")==0) |
| | | { |
| | | m_customer = LookupCustomer(hItem); |
| | | if(str.find(L"Customer:")==0) |
| | | { |
| | | dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodscustomerlist"); |
| | | } |
| | | else |
| | | { |
| | | dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodssolist"); |
| | | } |
| | | dwc_list.Reset(); |
| | | dwc_list.SetReadOnly(true); |
| | | dwc_list.SetColumnState(L"CurrencyCode",false); |
| | | //alert(str); |
| | | if(queryString==L"") |
| | | g_xdoc_shoppingcart.Retrieve(ShoppingCartView::GetGoodsList(str)); |
| | | else |
| | | g_xdoc_shoppingcart.Retrieve(ShoppingCartView::GetGoodsList(str,queryString)); |
| | | } |
| | | else if(e1.getAttribute(L"categoryid") !=L"") |
| | | { |
| | | xstring categoryid = e1.getAttribute(L"categoryid"); |
| | | dwc_list.SetDataObject(ProductLibraryView::GetMaintListForm3(categoryid)); |
| | | dwc_list.SetReadOnly(true); |
| | | dwc_list.Reset(); |
| | | if(queryString==L"") |
| | | g_xdoc_shoppingcart.Retrieve(ProductLibraryView::GetMaintList3(categoryid )); |
| | | else |
| | | g_xdoc_shoppingcart.Retrieve(ProductLibraryView::GetMaintList3(categoryid, queryString,L"")); |
| | | } |
| | | else |
| | | { |
| | | dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodslist"); |
| | | dwc_list.SetReadOnly(true); |
| | | dwc_list.Reset(); |
| | | if(queryString==L"") |
| | | g_xdoc_shoppingcart.Retrieve(ShoppingCartView::GetGoodsList(selectname)); |
| | | else |
| | | g_xdoc_shoppingcart.Retrieve(ShoppingCartView::GetGoodsList(selectname,queryString)); |
| | | } |
| | | dwc_list.PostRetrieve(); |
| | | dwc_list.Redraw(); |
| | | |
| | | if(dwc_list.GetRowCount() >= 1 ) |
| | | { |
| | | htmlctrl xs = GetControl(L"html_detail"); |
| | | xs.SetContent(makeGoodscarHtml(1)); |
| | | |
| | | if(m_customer !=L"") |
| | | { |
| | | xstring skuid = g_xdoc_shoppingcart.getData(0,L"data/Item",1,L"SKUID"); |
| | | xstring customerItemNo = g_xdoc_shoppingcart.getData(0,L"data/Item",1,L"CustomerItemNo"); |
| | | OnShowImage(skuid,customerItemNo); |
| | | } |
| | | } else { |
| | | im.ResetEx(); |
| | | im.Redraw(); |
| | | |
| | | xs = GetControl(L"html_detail"); |
| | | xs.SetContent(L"<html><body style='margin:2;background-color:#ccdccc none #f0f0f0 none'/></html>"); |
| | | } |
| | | xs.Redraw(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(agentFor !=L"goodslib")SwitchLayer(L"goodslibsheet",L"sheetframe"); |
| | | if(name == L"个人库") |
| | | ResetAgent(L"userlib"); |
| | | else |
| | | ResetAgent(L"goodslib"); |
| | | int hCursor = xutil::SetCursorWait(); |
| | | |
| | | if(name == L"个人库" || name==L"公司库") |
| | | { |
| | | xstring no=L"N000005"; |
| | | if(name==L"个人库") no=L"U000005"; |
| | | if(hItem != hTopItem) |
| | | { |
| | | KXMLDOMElement e= tv_folder.GetItemData(hItem); |
| | | no = e.getAttribute(L"guid"); |
| | | } |
| | | dw_list.SetDataObject(ProductLibraryView::GetMaintListForm3(no)); |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.Reset(); |
| | | dw_list.SetReadOnly(true); |
| | | |
| | | xml x; |
| | | if(queryString==L"") |
| | | { |
| | | if(name == L"个人库") |
| | | x = ProductLibraryView::GetMaintRoleList3(no); |
| | | else |
| | | x = ProductLibraryView::GetMaintList3(no); |
| | | } |
| | | else |
| | | { |
| | | if(name == L"个人库") |
| | | x = ProductLibraryView::GetMaintRoleList3(no,queryString); |
| | | else |
| | | { |
| | | if(queryString !=L"") |
| | | { |
| | | if(no==L"N000005") |
| | | x = ProductLibraryView::GetMaintList3(L"",queryString,L""); |
| | | else |
| | | x = ProductLibraryView::GetMaintList3(no,queryString,L""); |
| | | }else |
| | | x = ProductLibraryView::GetMaintList3(no); |
| | | } |
| | | } |
| | | if(x) g_xdoc_product.Retrieve(x); |
| | | dw_list.PostRetrieve(); |
| | | dw_list.Redraw(); |
| | | |
| | | if(dw_list.GetRowCount() >0) |
| | | { |
| | | xs = GetControl(L"html_detail"); |
| | | xs.SetContent(makeHtml(1)); |
| | | xstring id = g_xdoc_product.getData(0,L"data/Item",1,L"@guid"); |
| | | OnShowImage(id); |
| | | }else |
| | | { |
| | | im.ResetEx(); |
| | | im.Redraw(); |
| | | |
| | | xs = GetControl(L"html_detail"); |
| | | xs.SetContent(L"<html><body style='margin:2;background-color:#ccdccc none #f0f0f0 none'/></html>"); |
| | | } |
| | | xs.Redraw(); |
| | | xutil::RestoreCursor(hCursor); |
| | | } |
| | | } |
| | | impStr = L""; |
| | | } |
| | | |
| | | int OnTreeSelChanged(ref TNotifyEvent evt,int p) |
| | | { |
| | | ref NMTREEVIEW nmtv = cast(evt.pnmh as NMTREEVIEW); |
| | | int hItem = nmtv.itemNew.hItem; |
| | | return RetrieveItem(hItem); |
| | | } |
| | | |
| | | int ExpandChildFolder(int hItem, KXMLDOMElement pElement) |
| | | { |
| | | KXMLDOMNodeList nlist = pElement.selectNodes(L"Item"); |
| | | int len = nlist.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"cname"); |
| | | xstring sImage = e.getAttribute(L"image"); |
| | | int image = 15; |
| | | //if(sImage) image = sImage.toInt(); |
| | | int h= tv_folder.InsertChildItem(tv_folder.GetId(),hItem,name, trust(e as int),image); |
| | | tv_folder.SetItemChild(h,1); |
| | | ExpandChildFolder(h,e); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int InitialFolder() |
| | | else |
| | | { |
| | | KXMLDOMElement xframeElement = GetElement(); |
| | | KXMLDOMElement e = xframeElement.selectSingleNode(L"//xtree[@name='tv_folder']/initial"); |
| | | ExpandChildFolder(0,e); |
| | | return 1; |
| | | } |
| | | |
| | | int OnDwClicked(ref TNotifyEvent evt,int p) |
| | | { |
| | | ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR); |
| | | char ch; |
| | | int row = hdr.row; |
| | | xstring col = hdr.colname; |
| | | |
| | | xstring str = L""; |
| | | if(dw_list.GetItemString(row, L"SKUNo") !=L"") |
| | | str =dw_list.GetItemString(row, L"SKUNo"); |
| | | else |
| | | str =dw_list.GetItemString(row, L"No"); |
| | | |
| | | if(dw_list.IsRowSelected(row) & 0xff) |
| | | KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*"); |
| | | if(agent) |
| | | { |
| | | //will unselect |
| | | impStr = impStr.replace(L" "+str,L""); |
| | | }else |
| | | { |
| | | //will select |
| | | impStr += L" " + str; |
| | | xstring s = agent.xml(); |
| | | m_agentNode = SetAgentNode (anode,s); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnDwcClicked(ref TNotifyEvent evt,int p) |
| | | { |
| | | ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR); |
| | | char ch; |
| | | int row = hdr.row; |
| | | xstring col = hdr.colname; |
| | | |
| | | xstring str = g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"SOLineID"); |
| | | //xstring str1 = g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"EnquiryLineID"); |
| | | xstring str1 = g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"EnquiryPriceListID"); |
| | | if(str1 !=L"") |
| | | str += L"el:" + str1; |
| | | else if(str != L"") |
| | | str = L"sl:"+str; |
| | | else if(dwc_list.GetItemString(row, L"SKUNo") !=L"") |
| | | str =dwc_list.GetItemString(row, L"SKUNo"); |
| | | else |
| | | str =dwc_list.GetItemString(row, L"No"); |
| | | |
| | | if(dwc_list.IsRowSelected(row) & 0xff) |
| | | { |
| | | //will unselect |
| | | impStr = impStr.replace(L" "+str,L""); |
| | | }else |
| | | { |
| | | //will select |
| | | impStr += L" " + str; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnDoubleClicked(ref TNotifyEvent evt,int p) |
| | | { |
| | | int hCursor = xutil::SetCursorWait(); |
| | | ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR); |
| | | int row = hdr.row; |
| | | xstring ls_nos = L"ImportXml:"; |
| | | xstring str = g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"SOLineID"); |
| | | xstring str1 = g_xdoc_shoppingcart.getData(0,L"data/Item",row,L"EnquiryPriceListID"); |
| | | if(str1 !=L"") |
| | | str += L"el:" + str1; |
| | | else if(str != L"") |
| | | str = L"sl:"+str; |
| | | else if(dwc_list.GetItemString(row, L"SKUNo") !=L"") |
| | | str =dwc_list.GetItemString(row, L"SKUNo"); |
| | | else |
| | | str =dwc_list.GetItemString(row, L"No"); |
| | | ls_nos += str; |
| | | |
| | | dw_list.SelectRow(0,false); |
| | | dwc_list.SelectRow(0,false); |
| | | dw_list.Redraw(); |
| | | dwc_list.Redraw(); |
| | | impStr =L""; |
| | | |
| | | SendMessage(hObject,0x401,ls_nos,0); |
| | | return 1; |
| | | } |
| | | |
| | | //焦点激活处理函数 |
| | | int OnSetFocus(TEvent* evt, LPARAM param) |
| | | { |
| | | //重置工具条 |
| | | SetAgent(); |
| | | return 1; |
| | | } |
| | | |
| | | xutil::RestoreCursor(hCursor); |
| | | KXMLDOMElement OnGetCarListRowElement(int row=0) |
| | | { |
| | | if(row < 1) row = dwc_list.GetRow(); |
| | | if(row < 1 || row > dwc_list.GetRowCount()) return KXMLDOMElement(); |
| | | KXMLDOMElement e =dwc_list.GetRowElement(row); |
| | | return e; |
| | | } |
| | | |
| | | int OnShowImage(xstring skuid) |
| | | { |
| | | ximageview im = GetControl(L"im1"); |
| | | //im.RemoveImage(); |
| | | im.Reset(); |
| | | |
| | | xml xp; |
| | | |
| | | xaserverarg arg_pic; |
| | | arg_pic.setNativePointer(arg_pic.CreateInstance()); |
| | | arg_pic.AddArg(L"SKUID",skuid); |
| | | if(xurl::get(L"/sale/data/ProductLibrary3/pref/picture/imagelistSKU",arg_pic.GetString(),xp)!=1) |
| | | { |
| | | trace(xp.xml()); |
| | | }else |
| | | { |
| | | //imageElement = xp.documentElement(); |
| | | 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, L""); |
| | | } |
| | | im.Redraw(); |
| | | //SendMessage(im.GetId(),0x000f,0,1); |
| | | //InvalidateRect(im.GetId(),cast(0 as ref xrect),true); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnShowImage(xstring skuid, xstring customerItemNo) |
| | | { |
| | | ximageview im = GetControl(L"im1"); |
| | | //im.RemoveImage(); |
| | | im.Reset(); |
| | | |
| | | xml xp; |
| | | |
| | | xaserverarg arg_pic; |
| | | arg_pic.setNativePointer(arg_pic.CreateInstance()); |
| | | arg_pic.AddArg(L"SKUID",skuid); |
| | | arg_pic.AddArg(L"CustomerID",m_customer); |
| | | arg_pic.AddArg(L"CustomerItemNo",customerItemNo); |
| | | |
| | | if(xurl::get(L"/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKU",arg_pic.GetString(),xp)!=1) |
| | | { |
| | | trace((xstring)L"error:" + xp.xml()); |
| | | }else |
| | | { |
| | | //imageElement = xp.documentElement(); |
| | | 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, L""); |
| | | } |
| | | im.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int ItemAdd() |
| | | { |
| | | HTREEITEM hItem = tv_folder.GetSelectedItem(); |
| | | HTREEITEM hTopItem = LookupTopFolder(hItem); |
| | | xstring name = tv_folder.GetItemLabel(hTopItem); |
| | | |
| | | KXMLDOMElement e= tv_folder.GetItemData(hItem); |
| | | xstring guid = e.getAttribute(L"guid"); |
| | | if(guid==L"") return 1; |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"guid", e.getAttribute(L"guid")); |
| | | if(name==L"个人产品") |
| | | arg.AddArg(L"FolderID", e.getAttribute(L"guid")); |
| | | else |
| | | arg.AddArg(L"CategoryID", e.getAttribute(L"guid")); |
| | | xstring No = e.getAttribute(L"CategoryNo"); |
| | | if(No==L"") No = e.getAttribute(L"no"); |
| | | xstring Name = e.getAttribute(L"CName"); |
| | | if(Name==L"") Name = e.getAttribute(L"cname"); |
| | | arg.AddArg(L"No",No); |
| | | arg.AddArg(L"CName",Name); |
| | | int p = arg; |
| | | OpenWindow(L"dev:xpage[Quick.Input.NewProduct.vx]",p); |
| | | //if(arg.GetArgString(L"data.modify")==L"1")RetrieveData(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnRowChanged(TEvent* evt,LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | |
| | | xshtml xs = GetControl(L"html_detail"); |
| | | xstring html = makeHtml(row); |
| | | xs.SetContent(html); |
| | | xs.Redraw(); |
| | | |
| | | xstring id = dw_list.GetGuid(row); |
| | | OnShowImage(id); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnGoodsCarRowChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | |
| | | xshtml xs = GetControl(L"html_detail"); |
| | | xstring html = makeGoodscarHtml(row); |
| | | xs.SetContent(html); |
| | | xs.Redraw(); |
| | | if(m_customer) |
| | | { |
| | | xstring id = dwc_list.GetItemString(row, L"SKUID"); |
| | | xstring customerItemNo = dwc_list.GetItemString(row,L"CustomerItemNo"); |
| | | OnShowImage(id,customerItemNo); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int DeleteRow(int row) |
| | | { |
| | | int IDOK = 1; |
| | | int MB_OKCANCEL = 1; |
| | | int MB_ICONQUESTION = 32; |
| | | if(MessageBox(GetHWND(),L"确认删除指定的项,删除后将不能恢复?",L"提示",MB_OKCANCEL|MB_ICONQUESTION)!=IDOK) return 1; |
| | | xstring id = dw_list.GetItemString(row,L"@guid"); |
| | | |
| | | if(ProductLibraryView::DeleteItem(id)==1) dw_list.DeleteRow(0); |
| | | return 1; |
| | | } |
| | | |
| | | int SetSelectState(xdwgrid dw_obj, int state) |
| | | { |
| | | dw_obj.SetSelectionMode(3); |
| | | return 1; |
| | | } |
| | | |
| | | int OnCkbCLick(TEvent* evt,int p) |
| | | { |
| | | xcheckbox cbx_1 = GetControl(L"frame:cbx1"); |
| | | int state=cbx_1.GetCheck(); |
| | | return SetSelectState(dw_list,state); |
| | | } |
| | | |
| | | int OnCkbCLick2(TEvent*,int p) |
| | | { |
| | | xcheckbox cbx_2 = GetControl(L"frame:cbx2"); |
| | | int state=cbx_2.GetCheck(); |
| | | return SetSelectState(dwc_list,state); |
| | | } |
| | | |
| | | xml GetGoodsPropList(xstring guid) |
| | | { |
| | | xml x; |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"guid", guid); |
| | | if(xurl::get(L"/sale/data/SO/goods/goodsprop/list", arg.GetString(),x)!=1) |
| | | { |
| | | xstring error = x.text(); |
| | | alert(error); |
| | | } |
| | | return x; |
| | | } |
| | | |
| | | |
| | | xml GetGoodsPropListEx(xstring guid) |
| | | { |
| | | xml x; |
| | | |
| | | xstring fields=L"<data>"; |
| | | |
| | | /* |
| | | fields +=L"<field name='HighestPrice' label='最高价'/>"; |
| | | fields +=L"<field name='LowestPrice' label='最低价'/>"; |
| | | |
| | | fields +=L"<field name='BulkPrice' label='散货价'/>"; |
| | | fields +=L"<field name='CardPrice' label='纸卡价'/>"; |
| | | fields +=L"<field name='BuyPrice' label='采购价'/>"; |
| | | fields +=L"<field name='SupplierID' label='货源'/>"; |
| | | */ |
| | | |
| | | fields +=L"<field name='Packing' label='包装方式'/>"; |
| | | fields +=L"<field name='PackingRate' label='每箱数量'/>"; |
| | | fields +=L"<field name='VolumeDesc' label='包装尺码'/>"; |
| | | fields +=L"<field name='GWPerPkg' label='毛重'/>"; |
| | | fields +=L"<field name='NWPerPkg' label='净重'/>"; |
| | | //fields +=L"<field name='DeveloperID' label='开发人员'/>"; |
| | | fields +=L"<field name='AttributeValue_1' label='产品属性'/>"; |
| | | //fields +=L"<field name='Remark' label='备注'/>"; |
| | | |
| | | fields += L"</data>"; |
| | | x.loadXML(fields); |
| | | |
| | | return x; |
| | | } |
| | | |
| | | xstring makeHtml(int row) |
| | | { |
| | | xstring id = dw_list.GetItemString(row,L"@guid"); |
| | | xml x = GetGoodsPropList(id); |
| | | xml x1 = GetGoodsPropListEx(id); |
| | | |
| | | xstring html=L"<html><style> .text(){ font-weight:400} .label { font-weight:400;}</style><body style='margin:2;background-color1:#ccdccc none #f0f0f0 none'>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >编号:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"No")+ |
| | | L"</span> <span style='font-weight:700;width:50;font-size:10pt' >类项:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"RefNo")+ |
| | | L"</span></div>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >货号:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"GoodsNo")+ |
| | | L"</span></div>" ; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >品名:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"CName")+ |
| | | L"</span></div>" ; |
| | | if(dw_list.GetItemString(row,L"CSpec")!=L"") |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >规格:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"CSpec")+ |
| | | L"</span></div>" ; |
| | | |
| | | KXMLDOMNodeList fieldsEx = x1.selectNodes(L"data/field"); |
| | | xstring ls_detail=L""; |
| | | xstring ls_item =L""; |
| | | xstring name; |
| | | xstring label; |
| | | int len = fieldsEx.length(); |
| | | int i= 0; |
| | | |
| | | for(i=0;i<len; true) |
| | | { |
| | | int cnt = 0; |
| | | ls_item = L""; |
| | | while(cnt < 2) |
| | | { |
| | | name = fieldsEx.item(i).selectSingleNode(L"@name").text(); |
| | | label = fieldsEx.item(i).selectSingleNode(L"@label").text(); |
| | | ls_item += L"<td>" + label + L"</td>" + L"<td style='text-align:center'>" + dw_list.GetItemString(row,name.c_str()) + L"</td>" ; |
| | | cnt++; |
| | | i++; |
| | | if(i ==len)break; |
| | | } |
| | | ls_detail += L"<tr>" + ls_item + L"</tr>"; |
| | | } |
| | | html += L"<div style='margin-left:8px;margin-right:16px;'>" |
| | | L"<table><colgroup span='1' width='70'/><colgroup span='1' width='120'/><colgroup span='1' width='70'/><colgroup span='1' width='120'/>" |
| | | + ls_detail |
| | | +L"</table>" |
| | | +L"</div>" ; |
| | | |
| | | xstring ls_star=L""; |
| | | KXMLDOMNodeList fields = x.selectNodes(L"data/field"); |
| | | len = fields.length(); |
| | | |
| | | ls_detail = L""; |
| | | if(len > 0) |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >技术要求:</span></div>" ; |
| | | for(i=0;i<len; true) |
| | | { |
| | | ls_item=L""; |
| | | |
| | | int count = 0; |
| | | while(count < 2) |
| | | { |
| | | name = fields.item(i).selectSingleNode(L"@name").text(); |
| | | label = fields.item(i).selectSingleNode(L"@label").text(); |
| | | |
| | | if(name==L"QualityTerm" || name==L"PackTerm" || label==L"质量" || label==L"包装质量" || label==L"技术要求") |
| | | { |
| | | i++; |
| | | if(i >= len)count = 2; |
| | | continue; |
| | | } |
| | | else if(dw_list.GetItemString(row,name.c_str())==L"") |
| | | { |
| | | KXMLDOMNodeList options = fields.item(i).selectNodes(L"item"); |
| | | int tlen = options.length(); |
| | | xstring terms = L"" ; |
| | | for(int k=0; k<tlen; k++) |
| | | { |
| | | if(options.item(k).text()) |
| | | { |
| | | if(k>0) terms += L", L"; |
| | | terms += (xstring)L"[" + options.item(k).text() +L"]"; |
| | | } |
| | | } |
| | | ls_star += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >" + label +L"*:</span><span style='width:90;font-size:10pt'>" + terms + L"</span></div>" ; |
| | | }else |
| | | { |
| | | ls_item = L"<td>" + label + L"</td>" + L"<td>" + dw_list.GetItemString(row,name.c_str()) + L"</td>" ; |
| | | count++; |
| | | } |
| | | i++; |
| | | if(i >= len)count = 2; |
| | | } |
| | | ls_item = L"<tr>" + ls_item + L"</tr>"; |
| | | ls_detail += ls_item; |
| | | } |
| | | |
| | | html += L"<div style='margin-left:8px;margin-right:16px;'>" |
| | | L"<table><colgroup span='1' width='70'/><colgroup span='1' width='120'/><colgroup span='1' width='70'/><colgroup span='1' width='120'/>" |
| | | + ls_detail |
| | | +L"</table>" |
| | | +L"</div>" ; |
| | | if(dw_list.GetItemString(row,L"QualityTerm")!=L"") |
| | | { |
| | | html += L"<div style='height:12px'/>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >质量:</span></div>" ; |
| | | html += L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + dw_list.GetItemString(row,L"QualityTerm") + L"</span></div>" ; |
| | | } |
| | | |
| | | if(dw_list.GetItemString(row,L"PackTerm")!=L"") |
| | | { |
| | | html += L"<div style='height:12px'/>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >包装质量:</span></div>" ; |
| | | html += L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + dw_list.GetItemString(row,L"PackTerm") + L"</span></div>" ; |
| | | } |
| | | |
| | | if(dw_list.GetItemString(row,L"Remark") != L"" && id == L"23A8BBA2-DEF1-4C00-978E-646151A6082E") |
| | | { |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >备注:</span></div>" ; |
| | | html += L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + dw_list.GetItemString(row,L"Remark") + L"</span></div>" ; |
| | | } |
| | | |
| | | html += L"<div style='height:24px'/>"; |
| | | |
| | | //星标项 |
| | | html += ls_star; |
| | | |
| | | //显示图片 |
| | | /*xstring picname = L"1FA9E331-F95C-4E51-B80C-73FB9B911D8D.jpg";//dw_list.GetItemString(row,L"ImgName"); //ItemID+L".jpg"; |
| | | xstring str = picname.mid(0,2); |
| | | str = str.upper(); |
| | | xstring serversrc =L"http://192.168.7.241:1001/business/products/chanpin/"+str+L"/"+picname; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >ͼƬ:</span>"; |
| | | html += L"<control visible='layer' controlclass='ximage' data='' src='"+ serversrc +L"'/></div>"; |
| | | */ |
| | | html += L"</body></html>"; |
| | | return html; |
| | | } |
| | | |
| | | xstring makeGoodscarHtml(int row) |
| | | { |
| | | xstring No = dwc_list.GetItemString(row,L"RefNo");//获取属性值id |
| | | xml x = GetGoodsPropList(No); |
| | | |
| | | xstring html=L"<html><style> .text(){ font-weight:400} .label { font-weight:400;}</style><body style='margin:2;background-color1:#ccdccc none #f0f0f0 none'>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >编号:</span><span style='width:90;font-size:10pt'>" + dwc_list.GetItemString(row,L"No")+ |
| | | L"</span></div>"; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >品名:</span><span style='width:90;font-size:10pt'>" + dwc_list.GetItemString(row,L"CName")+ |
| | | L"</span></div>" ; |
| | | html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >规格:</span><span style='width:90;font-size:10pt'>" + dwc_list.GetItemString(row,L"CSpec")+ |
| | | L"</span></div>" ; |
| | | |
| | | KXMLDOMNodeList fields = x.selectNodes(L"data/field"); |
| | | int len = fields.length(); |
| | | html += L"<table>" |
| | | L"<colgroup span='1' width='80'/>" |
| | | L"<colgroup span='1' width='120'/>" |
| | | L"<colgroup span='1' width='420'/>" ; |
| | | html += L"<tr>" ; |
| | | html += L"<td style='text-align:center'>编号</td><td style='text-align:center'>项目</td><td style='text-align:center'>内容</td>" ; |
| | | html +=L"</tr>"; |
| | | for(int i=0;i<len; i++) |
| | | { |
| | | xstring name = fields.item(i).selectSingleNode(L"@name").text(); |
| | | xstring label = fields.item(i).selectSingleNode(L"@label").text(); |
| | | html += L"<tr>" ; |
| | | if(i==0) |
| | | html += L"<td rowspan='" + xstring(len) + L"'>" + No + L"</td><td >" + label + L"</td><td >" + L"</td>"; |
| | | else |
| | | html += L"<td >"+ label + L"</td><td >"+ dwc_list.GetItemString(row,name.c_str())+L"</td>" ; |
| | | html +=L"</tr>"; |
| | | } |
| | | |
| | | html += L"<tr>" ; |
| | | html += L"<td rowspan='3'>" + dwc_list.GetItemString(row,L"PackCode") + L"</td><td >包装方式</td><td >"+ |
| | | dwc_list.GetItemString(row,L"CPack") + L"</td>" ; |
| | | html +=L"</tr>"; |
| | | html += L"<tr height='48'>" ; |
| | | html += L"<td >包装要求</td><td >"+ dwc_list.GetItemString(row,L"PackQualityTerm")+L"</td>" ; |
| | | html +=L"</tr>"; |
| | | html += L"<tr>" ; |
| | | html += L"<td >侧唛</td><td ></td>" ; |
| | | html +=L"</tr>"; |
| | | |
| | | html += L"<tr height='72'>" ; |
| | | html += L"<td>" + dwc_list.GetItemString(row,L"QualityCode") + L"</td><td >质量要求</td><td >"+ |
| | | dwc_list.GetItemString(row,L"QualityTerm") + L"</td>" ; |
| | | html +=L"</tr>"; |
| | | |
| | | html +=L"</table>"; |
| | | |
| | | html += L"</body></html>"; |
| | | return html; |
| | | } |
| | | |
| | | int OnImport() |
| | | { |
| | | if(!hObject ) return 1; |
| | | |
| | | int rw = 0; |
| | | xstring ls_nos = L"ImportXml:"; |
| | | |
| | | if (impStr==L"") |
| | | { |
| | | alert(L"请选择商品!"); |
| | | return 1; |
| | | } |
| | | ls_nos += impStr; |
| | | trace(impStr); |
| | | dwc_list.SelectRow(0,false); |
| | | dwc_list.Redraw(); |
| | | dw_list.SelectRow(0,false); |
| | | dw_list.Redraw(); |
| | | impStr =L""; |
| | | //alert(ls_nos); |
| | | SendMessage(hObject,0x401,(LPARAM)ls_nos.c_str(), 0); |
| | | alert(L"转入完成"); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnSearch() |
| | | { |
| | | HTREEITEM hItem = tv_folder.GetSelectedItem(); |
| | | return RetrieveItem(hItem); |
| | | } |
| | | |
| | | //命令发布函数 |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | int hCursor; |
| | | xstring name=L""; |
| | | if(comdid==L"xmClose") |
| | | { |
| | | CloseWindow(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //绑定工具条点击事件 |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&ProductSelectWin::OnXCommand); |
| | | //获取焦点事件,用于重置工具条 |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&ProductSelectWin::OnSetFocus); |
| | | AttachEvent(L"dw_list",L"DWV_ROWFOCUSCHANGED", (FEvent)&ProductSelectWin::OnRowChanged); |
| | | AttachEvent(L"dwc_list",L"DWV_ROWFOCUSCHANGED", (FEvent)&ProductSelectWin::OnGoodsCarRowChanged); |
| | | AttachEvent(L"tv_folder", L"TVN_ITEMEXPANDING", (FEvent)&ProductSelectWin::OnTreeExpanding); |
| | | AttachEvent(L"tv_folder", L"TVN_SELCHANGED", (FEvent)&ProductSelectWin::OnTreeSelChanged); |
| | | |
| | | AttachEvent(L"dwc_list",L"DWV_DOUBLECLICKED", (FEvent)&ProductSelectWin::OnDoubleClicked); |
| | | |
| | | AttachEvent(L"WM_COMMAND", (FEvent)&ProductSelectWin::OnCkbCLick); //checkbox打钩事件 |
| | | AttachEvent(L"WM_COMMAND", (FEvent)&ProductSelectWin::OnCkbCLick2); //checkbox打钩事件 |
| | | |
| | | AttachEvent(L"dw_list",L"DWV_CLICKED", (FEvent)&ProductSelectWin::OnDwClicked); |
| | | AttachEvent(L"dwc_list",L"DWV_CLICKED", (FEvent)&ProductSelectWin::OnDwcClicked); |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | else if(comdid==L"xmImport") |
| | | { |
| | | agentFor = L"goodslib"; |
| | | impStr = L""; |
| | | |
| | | OnAttachEvent(); |
| | | |
| | | tv_folder = GetControl(L"tv_folder"); |
| | | dw_list = GetControl(L"dw_list"); |
| | | dwc_list = GetControl(L"dwc_list"); |
| | | |
| | | xaserverarg arg = GetParam(); |
| | | CustomerID = L""; |
| | | m_customer =L""; |
| | | hObject = 0; |
| | | if(arg) |
| | | { |
| | | hObject = arg.GetArgString(L"HWND").toInt(); |
| | | CustomerID = arg.GetArgString(L"CustomerID"); |
| | | } |
| | | InitialFolder(); |
| | | |
| | | g_xdoc_product = new xdataset; |
| | | g_xdoc_product.Init(); |
| | | xbind bindproduct = new xbind; |
| | | bindproduct.bindEx(dw_list, g_xdoc_product,L""); |
| | | |
| | | g_xdoc_shoppingcart = new xdataset; |
| | | g_xdoc_shoppingcart.Init(); |
| | | |
| | | xbind bindcart = new xbind; |
| | | bindcart.bindEx(dwc_list, g_xdoc_shoppingcart,L""); |
| | | |
| | | dw_list.SetDataObject(ProductLibraryView::GetMaintListForm3(L"")); |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.SetReadOnly(true); |
| | | |
| | | dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodslist"); |
| | | dwc_list.SetReadOnly(true); |
| | | |
| | | if(dw_list.GetRowCount()) |
| | | { |
| | | htmlctrl xs = GetControl(L"html_detail"); |
| | | xs.SetContent(makeHtml(1)); |
| | | } |
| | | |
| | | xtreeview::ExpandItem(tv_folder.GetId(), |
| | | xtreeview::GetNextItem(tv_folder.GetId(),xtreeview::GetRootItem(tv_folder.GetId()))); |
| | | xtreeview::ExpandItem(tv_folder.GetId(), |
| | | xtreeview::GetNextItem(tv_folder.GetId(),xtreeview::GetNextItem(tv_folder.GetId(),xtreeview::GetRootItem(tv_folder.GetId())))); |
| | | |
| | | dw_list.SetSelectionMode(3); |
| | | dwc_list.SetSelectionMode(3); |
| | | |
| | | OnImport(); |
| | | return 1; |
| | | } |
| | | else if(comdid==L"xmAdd") |
| | | { |
| | | ItemAdd(); |
| | | return 1; |
| | | } |
| | | else if(comdid==L"xmSearch") |
| | | { |
| | | OnSearch(); |
| | | return 1; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | //命令处理事件 |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | //查找当前树项的顶级目录 |
| | | HTREEITEM LookupTopFolder(HTREEITEM hItem) |
| | | { |
| | | HTREEITEM hRoot = tv_folder.GetRootItem(); |
| | | while(tv_folder.GetParentItem(hItem)) hItem = tv_folder.GetParentItem(hItem); |
| | | return hItem; |
| | | } |
| | | |
| | | //插入产品类项的子项 |
| | | int MakeGoodsFolderItem(HTREEITEM hItem, xstring sno) |
| | | { |
| | | xml x = ProductLibraryView::GetTreeChildItems3(sno); |
| | | if(!x) return 0; |
| | | |
| | | return 1; |
| | | KXMLDOMNodeList nlist = x.selectNodes(L"//Item"); |
| | | int len = nlist.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"CName"); |
| | | xstring no = e.getAttribute(L"CategoryNo"); |
| | | xstring label = no.trim() + L" " + name; |
| | | |
| | | HTREEITEM h= tv_folder.InsertChildItem(hItem,label, e,15); |
| | | tv_folder.SetItemChild(h,1); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //插入新产品目录子项 |
| | | int MakeUserGoodsFolderItem(HTREEITEM hItem, xstring sno) |
| | | { |
| | | xml x = ProductLibraryView::GetTreeUserChildItems3(sno); |
| | | if(!x) return 0; |
| | | |
| | | KXMLDOMNodeList nlist = x.selectNodes(L"//Item"); |
| | | int len = nlist.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"CName"); |
| | | xstring no = e.getAttribute(L"CategoryNo"); |
| | | xstring label = no.trim() + L" " + name; |
| | | |
| | | HTREEITEM h= tv_folder.InsertChildItem(hItem,label, e,15); |
| | | xstring child = e.getAttribute(L"Childs"); |
| | | if(child==L"") |
| | | tv_folder.SetItemChild(h,1); |
| | | else if(child !=L"0") |
| | | tv_folder.SetItemChild(h,1); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //插入购物车项 |
| | | int ExpandCatChildFolder(HTREEITEM hItem, KXMLDOMElement ele ,int image) |
| | | { |
| | | KXMLDOMNodeList nlist = ele.selectNodes(L"item"); |
| | | int len = nlist.length(); |
| | | if(len > 0) tv_folder.SetItemChild(hItem,1); |
| | | for (int i= 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"name"); |
| | | HTREEITEM h = tv_folder.InsertChildItem(hItem,name, e,image); |
| | | ExpandCatChildFolder(h,e,35); |
| | | } |
| | | return 1; |
| | | } |
| | | int MakeGoodCarFolderItem(HTREEITEM hItem) |
| | | { |
| | | //trace(L"\r\nCustomerID:"+CustomerID); |
| | | xml x = ShoppingCartView::GetRoleList(CustomerID); |
| | | //if(x) alert(x.xml()); |
| | | if(!x) return 0; |
| | | KXMLDOMNodeList nlist = x.selectNodes(L"/data/item"); |
| | | int len = nlist.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"name"); |
| | | HTREEITEM h = tv_folder.InsertChildItem(hItem,name, e,35); |
| | | ExpandCatChildFolder(h,e,35); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //树展开 |
| | | int OnTreeExpanding(TEvent* evt,int p) |
| | | { |
| | | NMTREEVIEW& nmtv = *(NMTREEVIEW*)evt->notify.pnmh; |
| | | HTREEITEM hItem = nmtv.itemNew.hItem; |
| | | HTREEITEM hTopItem = LookupTopFolder(hItem); |
| | | xstring name = tv_folder.GetItemLabel(hTopItem); |
| | | HTREEITEM child = tv_folder.GetChildItem(hItem); |
| | | xstring no =L""; |
| | | KXMLDOMElement e; |
| | | if(name == L"公司库" && !child ) |
| | | { |
| | | no =L""; |
| | | if(hTopItem != hItem) |
| | | { |
| | | e= tv_folder.GetItemData(hItem); |
| | | no = e.getAttribute(L"categoryid"); |
| | | }else |
| | | { |
| | | e= tv_folder.GetItemData(hItem); |
| | | no = e.getAttribute(L"categoryid"); |
| | | } |
| | | MakeGoodsFolderItem(hItem, no); |
| | | } |
| | | else if(name == L"个人库" && !child ) |
| | | { |
| | | no =L""; |
| | | if(hTopItem != hItem) |
| | | { |
| | | e= tv_folder.GetItemData(hItem); |
| | | no = e.getAttribute(L"categoryid"); |
| | | MakeUserGoodsFolderItem(hItem, no); |
| | | } |
| | | } |
| | | else if(name == L"购物车" && !child ) |
| | | { |
| | | if(hItem==hTopItem)MakeGoodCarFolderItem(hItem); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int ResetAgent(xstring agentAsk) |
| | | { |
| | | if(agentFor != agentAsk) |
| | | { |
| | | agentFor = agentAsk; |
| | | m_agentNode = 0; |
| | | SetAgent(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | HTREEITEM LookupCustomerFolder(HTREEITEM hItem) |
| | | { |
| | | while(true) |
| | | { |
| | | KXMLDOMElement e1 = tv_folder.GetItemData(hItem); |
| | | xstring str = e1.getAttribute(L"no"); |
| | | if(str.find(L"Customer:")>=0) return hItem; |
| | | hItem = tv_folder.GetParentItem(hItem); |
| | | if(hItem==0) break; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | xstring LookupCustomer(HTREEITEM hItem) |
| | | { |
| | | hItem = LookupCustomerFolder(hItem); |
| | | if(hItem==0) return L""; |
| | | KXMLDOMElement e1 = tv_folder.GetItemData(hItem); |
| | | xstring str = e1.getAttribute(L"no"); |
| | | return str.mid(xstring(L"Customer:").length(),9999); |
| | | } |
| | | |
| | | int RetrieveItem(HTREEITEM hItem) |
| | | { |
| | | HTREEITEM hTopItem = LookupTopFolder(hItem); |
| | | xstring name = tv_folder.GetItemLabel(hTopItem); |
| | | xstring selectname = tv_folder.GetItemLabel(hItem); |
| | | ximageview im = GetControl(L"im1"); |
| | | m_customer = L""; |
| | | xcontrol query = GetControl(L"sl_search"); |
| | | xstring queryString = query.GetText(); |
| | | |
| | | if(name == L"购物车") |
| | | { |
| | | if(agentFor !=L"goodscar")SwitchLayer(L"goodscarsheet",L"sheetframe"); |
| | | ResetAgent(L"goodscar"); |
| | | if(selectname !=name) |
| | | { |
| | | KXMLDOMElement e1 = tv_folder.GetItemData(hItem); |
| | | xstring str = e1.getAttribute(L"no"); |
| | | |
| | | trace(L"\r\n-------"+str+L"--------"+queryString); |
| | | |
| | | if(str==L"Supplier") |
| | | { |
| | | return 1; |
| | | } |
| | | //alert(str); |
| | | xshtml xs = GetControl(L"html_detail"); |
| | | if(str.find(L"Customer:")==0 || str.find(L"SO:")==0 || str.find(L"Purcherex:")==0|| str.find(L"Purcher:")==0 || str.find(L"Supplier:")==0|| str.find(L"Enquiry:")==0) |
| | | { |
| | | m_customer = LookupCustomer(hItem); |
| | | if(str.find(L"Customer:")==0) |
| | | { |
| | | dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodscustomerlist"); |
| | | } |
| | | else |
| | | { |
| | | dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodssolist"); |
| | | } |
| | | dwc_list.Reset(); |
| | | dwc_list.SetReadOnly(true); |
| | | dwc_list.SetColumnState(L"CurrencyCode",false); |
| | | //alert(str); |
| | | if(queryString==L"") |
| | | dwc_list.Retrieve(ShoppingCartView::GetGoodsList(str)); |
| | | else |
| | | dwc_list.Retrieve(ShoppingCartView::GetGoodsList(str,queryString)); |
| | | } |
| | | else if(e1.getAttribute(L"categoryid") !=L"") |
| | | { |
| | | xstring categoryid = e1.getAttribute(L"categoryid"); |
| | | dwc_list.SetDataObject(ProductLibraryView::GetMaintListForm3(categoryid)); |
| | | dwc_list.SetReadOnly(true); |
| | | dwc_list.Reset(); |
| | | if(queryString==L"") |
| | | dwc_list.Retrieve(ProductLibraryView::GetMaintList3(categoryid )); |
| | | else |
| | | dwc_list.Retrieve(ProductLibraryView::GetMaintList3(categoryid, queryString,L"")); |
| | | } |
| | | else |
| | | { |
| | | dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodslist"); |
| | | dwc_list.SetReadOnly(true); |
| | | dwc_list.Reset(); |
| | | if(queryString==L"") |
| | | dwc_list.Retrieve(ShoppingCartView::GetGoodsList(selectname)); |
| | | else |
| | | dwc_list.Retrieve(ShoppingCartView::GetGoodsList(selectname,queryString)); |
| | | } |
| | | dwc_list.Redraw(); |
| | | |
| | | if(dwc_list.GetRowCount() >= 1 ) |
| | | { |
| | | |
| | | xs.SetContent(makeGoodscarHtml(1)); |
| | | |
| | | if(m_customer !=L"") |
| | | { |
| | | xstring skuid = dwc_list.GetItemString(1,L"SKUID"); |
| | | xstring customerItemNo = dwc_list.GetItemString(1,L"CustomerItemNo"); |
| | | OnShowImage(skuid,customerItemNo); |
| | | } |
| | | } else { |
| | | im.Reset(); |
| | | im.Redraw(); |
| | | |
| | | xs = GetControl(L"html_detail"); |
| | | xs.SetContent(L"<html><body style='margin:2;background-color:#ccdccc none #f0f0f0 none'/></html>"); |
| | | } |
| | | xs.Redraw(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(agentFor !=L"goodslib")SwitchLayer(L"goodslibsheet",L"sheetframe"); |
| | | if(name == L"个人库") |
| | | ResetAgent(L"userlib"); |
| | | else |
| | | ResetAgent(L"goodslib"); |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | |
| | | if(name == L"个人库" || name==L"公司库") |
| | | { |
| | | xstring no=L"N000005"; |
| | | if(name==L"个人库") no=L"U000005"; |
| | | if(hItem != hTopItem) |
| | | { |
| | | KXMLDOMElement e= tv_folder.GetItemData(hItem); |
| | | no = e.getAttribute(L"guid"); |
| | | } |
| | | dw_list.SetDataObject(ProductLibraryView::GetMaintListForm3(no)); |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.Reset(); |
| | | dw_list.SetReadOnly(true); |
| | | |
| | | xml x; |
| | | if(queryString==L"") |
| | | { |
| | | if(name == L"个人库") |
| | | x = ProductLibraryView::GetMaintRoleList3(no); |
| | | else |
| | | x = ProductLibraryView::GetMaintList3(no); |
| | | } |
| | | else |
| | | { |
| | | if(name == L"个人库") |
| | | x = ProductLibraryView::GetMaintRoleList3(no,queryString); |
| | | else |
| | | { |
| | | if(queryString !=L"") |
| | | { |
| | | if(no==L"N000005") |
| | | x = ProductLibraryView::GetMaintList3(L"",queryString,L""); |
| | | else |
| | | x = ProductLibraryView::GetMaintList3(no,queryString,L""); |
| | | }else |
| | | x = ProductLibraryView::GetMaintList3(no); |
| | | } |
| | | } |
| | | if(x) dw_list.Retrieve(x); |
| | | dw_list.Redraw(); |
| | | |
| | | xshtml xs = GetControl(L"html_detail"); |
| | | if(dw_list.GetRowCount() >0) |
| | | { |
| | | xs = GetControl(L"html_detail"); |
| | | xs.SetContent(makeHtml(1)); |
| | | xstring id = dw_list.GetItemString(1,L"@guid"); |
| | | OnShowImage(id); |
| | | }else |
| | | { |
| | | im.Reset(); |
| | | im.Redraw(); |
| | | |
| | | |
| | | xs.SetContent(L"<html><body style='margin:2;background-color:#ccdccc none #f0f0f0 none'/></html>"); |
| | | } |
| | | xs.Redraw(); |
| | | xutil::RestoreCursor(hCursor); |
| | | } |
| | | } |
| | | }; |
| | | ] |
| | | impStr = L""; |
| | | } |
| | | |
| | | int OnTreeSelChanged(TEvent * evt,LPARAM p) |
| | | { |
| | | NMTREEVIEW& nmtv = *(NMTREEVIEW*)evt->notify.pnmh; |
| | | HTREEITEM hItem = nmtv.itemNew.hItem; |
| | | return RetrieveItem(hItem); |
| | | } |
| | | |
| | | int ExpandChildFolder(HTREEITEM hItem, KXMLDOMElement pElement) |
| | | { |
| | | KXMLDOMNodeList nlist = pElement.selectNodes(L"Item"); |
| | | int len = nlist.length(); |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.getAttribute(L"cname"); |
| | | xstring sImage = e.getAttribute(L"image"); |
| | | int image = 15; |
| | | //if(sImage) image = sImage.toInt(); |
| | | HTREEITEM h= tv_folder.InsertChildItem(hItem,name, e,image); |
| | | tv_folder.SetItemChild(h,1); |
| | | ExpandChildFolder(h,e); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int InitialFolder() |
| | | { |
| | | KXMLDOMElement xframeElement = GetElement(); |
| | | KXMLDOMElement e = xframeElement.selectSingleNode(L"//xtree[@name='tv_folder']/initial"); |
| | | ExpandChildFolder(0,e); |
| | | return 1; |
| | | } |
| | | |
| | | int OnDwClicked(TEvent* evt,int p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | char ch; |
| | | int row = hdr.row; |
| | | xstring col = hdr.colname; |
| | | |
| | | xstring str = L""; |
| | | if(dw_list.GetItemString(row, L"SKUNo") !=L"") |
| | | str =dw_list.GetItemString(row, L"SKUNo"); |
| | | else |
| | | str =dw_list.GetItemString(row, L"No"); |
| | | |
| | | if(dw_list.IsRowSelected(row) & 0xff) |
| | | { |
| | | //will unselect |
| | | impStr = impStr.replace(L" "+str,L""); |
| | | }else |
| | | { |
| | | //will select |
| | | impStr += L" " + str; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnDwcClicked(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | char ch; |
| | | int row = hdr.row; |
| | | xstring col = hdr.colname; |
| | | |
| | | xstring str = dwc_list.GetItemString(row,L"SOLineID"); |
| | | //xstring str1 = dwc_list.GetItemString(row,L"EnquiryLineID"); |
| | | xstring str1 = dwc_list.GetItemString(row,L"EnquiryPriceListID"); |
| | | if(str1 !=L"") |
| | | str += L"el:" + str1; |
| | | else if(str != L"") |
| | | str = L"sl:"+str; |
| | | else if(dwc_list.GetItemString(row, L"SKUNo") !=L"") |
| | | str =dwc_list.GetItemString(row, L"SKUNo"); |
| | | else |
| | | str =dwc_list.GetItemString(row, L"No"); |
| | | |
| | | if(dwc_list.IsRowSelected(row) & 0xff) |
| | | { |
| | | //will unselect |
| | | impStr = impStr.replace(L" "+str,L""); |
| | | }else |
| | | { |
| | | //will select |
| | | impStr += L" " + str; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnDoubleClicked(TEvent* evt, LPARAM p) |
| | | { |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | xstring ls_nos = L"ImportXml:"; |
| | | xstring str = dwc_list.GetItemString(row,L"SOLineID"); |
| | | xstring str1 = dwc_list.GetItemString(row,L"EnquiryPriceListID"); |
| | | if(str1 !=L"") |
| | | str += L"el:" + str1; |
| | | else if(str != L"") |
| | | str = L"sl:"+str; |
| | | else if(dwc_list.GetItemString(row, L"SKUNo") !=L"") |
| | | str =dwc_list.GetItemString(row, L"SKUNo"); |
| | | else |
| | | str =dwc_list.GetItemString(row, L"No"); |
| | | ls_nos += str; |
| | | |
| | | dw_list.SelectRow(0,false); |
| | | dwc_list.SelectRow(0,false); |
| | | dw_list.Redraw(); |
| | | dwc_list.Redraw(); |
| | | impStr =L""; |
| | | |
| | | SendMessage(hObject,0x401,(WPARAM)ls_nos.c_str(), 0); |
| | | |
| | | xutil::RestoreCursor(hCursor); |
| | | CloseWindow(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //绑定工具条点击事件 |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&ProductSelectWin::OnXCommand); |
| | | //获取焦点事件,用于重置工具条 |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&ProductSelectWin::OnSetFocus); |
| | | AttachEvent(L"dw_list",L"DWV_ROWFOCUSCHANGED", (FEvent)&ProductSelectWin::OnRowChanged); |
| | | AttachEvent(L"dwc_list",L"DWV_ROWFOCUSCHANGED", (FEvent)&ProductSelectWin::OnGoodsCarRowChanged); |
| | | AttachEvent(L"tv_folder", L"TVN_ITEMEXPANDING", (FEvent)&ProductSelectWin::OnTreeExpanding); |
| | | AttachEvent(L"tv_folder", L"TVN_SELCHANGED", (FEvent)&ProductSelectWin::OnTreeSelChanged); |
| | | |
| | | AttachEvent(L"dwc_list",L"DWV_DOUBLECLICKED", (FEvent)&ProductSelectWin::OnDoubleClicked); |
| | | |
| | | AttachEvent(L"WM_COMMAND", (FEvent)&ProductSelectWin::OnCkbCLick); //checkbox打钩事件 |
| | | AttachEvent(L"WM_COMMAND", (FEvent)&ProductSelectWin::OnCkbCLick2); //checkbox打钩事件 |
| | | |
| | | AttachEvent(L"dw_list",L"DWV_CLICKED", (FEvent)&ProductSelectWin::OnDwClicked); |
| | | AttachEvent(L"dwc_list",L"DWV_CLICKED", (FEvent)&ProductSelectWin::OnDwcClicked); |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | SetArg(); |
| | | agentFor = L"goodslib"; |
| | | impStr = L""; |
| | | |
| | | OnAttachEvent(); |
| | | |
| | | tv_folder = GetControl(L"tv_folder"); |
| | | dw_list = GetControl(L"dw_list"); |
| | | dwc_list = GetControl(L"dwc_list"); |
| | | |
| | | xaserverarg arg = GetArg(); |
| | | CustomerID = L""; |
| | | m_customer =L""; |
| | | hObject = 0; |
| | | if(arg) |
| | | { |
| | | hObject = (HWND)arg.GetParam(L"ParentWindow"); |
| | | CustomerID = arg.GetArgString(L"CustomerID"); |
| | | } |
| | | InitialFolder(); |
| | | |
| | | dw_list.SetDataObject(ProductLibraryView::GetMaintListForm3(L"")); |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.SetReadOnly(true); |
| | | |
| | | dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodslist"); |
| | | dwc_list.SetReadOnly(true); |
| | | |
| | | if(dw_list.GetRowCount()) |
| | | { |
| | | xshtml xs = GetControl(L"html_detail"); |
| | | xs.SetContent(makeHtml(1)); |
| | | } |
| | | |
| | | tv_folder.ExpandItem(tv_folder.GetNextItem(tv_folder.GetRootItem())); |
| | | tv_folder.ExpandItem(tv_folder.GetNextItem(tv_folder.GetNextItem(tv_folder.GetRootItem()))); |
| | | |
| | | dw_list.SetSelectionMode(3); |
| | | dwc_list.SetSelectionMode(3); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | |
| | | return 1; |
| | | } |
| | | }; |