From cfe2fd47edee46fea43cc6bda85e74cd30beeaef Mon Sep 17 00:00:00 2001 From: xj qian <qianxj15@sina.com> Date: 星期四, 27 六月 2024 16:02:09 +0800 Subject: [PATCH] this update tree data item --- jrj/ext-jrj/delivery.base.maint.so.cpp | 191 ++++ jrj/ext-jrj/select.item.so.cpp | 157 +++ jrj/project/business/GDN3.list.cpp | 2 jrj/ext-jrj/ext-jrj.aps | 0 jrj/ext-jrj/ext-jrj.vcxproj | 9 jrj/project/business/SO/paymentterm.base.maint.so.cpp | 406 +++++++++ jrj/ext-jrj/Product.Select.SO.cpp | 1330 ++++++++++++++++++++++++++++++ jrj/ext-jrj/maint.Document.SO3.v3.cpp | 476 +++++++++++ 8 files changed, 2,569 insertions(+), 2 deletions(-) diff --git a/jrj/ext-jrj/Product.Select.SO.cpp b/jrj/ext-jrj/Product.Select.SO.cpp new file mode 100644 index 0000000..90126fe --- /dev/null +++ b/jrj/ext-jrj/Product.Select.SO.cpp @@ -0,0 +1,1330 @@ +#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/saleorder.view.hpp" +#include "viewobject/quote.view.hpp" +#include "viewobject/shoppingcart.view.hpp" +#include "viewobject/productLibrary.view.hpp" +#include "xcontrol/xcheckbox.hpp" +#include "xcontrol/xshtml.hpp" + + + class __declspec(dllexport) ProductSelectSOWin : public xwin + { + public: + int hObject = 0; + xstring CustomerID; + xstring CustomerName; + + //产品库产品列表 + xdwgrid dw_list; + //购物车产品列表 + xdwgrid dwc_list; + + //产品缓存对象 + //xdataset g_xdoc_product; + //xdataset g_xdoc_shoppingcart; + + xcombobox cbx_goodscar; + //是否多选 + + xnode m_agentNode; //Agent Condition + xtreeview tv_folder; + xstring agentFor; + xstring impStr; + public: + ProductSelectSOWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} + public: + static ProductSelectSOWin* CreateInstance(void* implPtr, void* hWnd) + { + ProductSelectSOWin* pWin = new ProductSelectSOWin(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; + } + + //焦点激活处理函数 + int OnSetFocus(TEvent* evt, int param) + { + //重置工具条 + SetAgent(); + return 1; + } + + KXMLDOMElement OnGetCarListRowElement(int row = 0) + { + if (row < 1) row = dwc_list.GetRow(); + if (row < 1 || row > dwc_list.GetRowCount()) return 1; + KXMLDOMElement e = g_xdoc_shoppingcart.getRowElement(L"data/Item", row); + return e; + } + + 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 skuno = g_xdoc_product.getData(0, L"data/Item", row, L"SKUNo"); + OnShowImage(skuno); + + 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(); + + xstring skuno = g_xdoc_shoppingcart.getData(0, L"data/Item", row, L"No"); + //alert(skuno); + OnShowImage(skuno); + + return 1; + } + + int DeleteRow(int row) + { + int IDOK = 1; + int MB_OKCANCEL = 1; + int MB_ICONQUESTION = 32; + if (MessageBoxW(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) + { + /* + if (state== 1) + { + dw_obj.SetSelectionMode(3); + } + else if (state==-1) + { + dw_obj.SelectRow(0,false); + dw_obj.SetSelectionMode(0); + }*/ + 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* evt, 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.setNativePointer(arg.CreateInstance()); + 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; + } + + int OnShowImage(xstring skuno) + { + ximageview im = GetControl(L"im1"); + im.RemoveImage(); + + xml xp ; + xaserverarg arg_pic ; + arg_pic.AddArg(L"SKUNo", skuno); + if (xurl::get(L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo", arg_pic.GetString(), xp) != 1) + { + trace(xstring(L"xxx") + xp.xml()); + } + 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); + } + im.Redraw(); + } + return 1; + } + + 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 = 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") + + 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'>" + 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 += (xstring)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 += (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>" + 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 += (xstring)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"") + { + //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' >" + 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.toUpper(); + 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>"; + //trace(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 += (xstring)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 >" + 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 CarGoodsDelete() + { + return 1; + } + + int Up(xstring name) { + //int ret1 = 3; + xstring str = name.mid(0, 2); + str = str.toUpper(); + //alert(str); + int ret1 = xaserver::UploadFile(L"product" + str, name + L".jpg", GetHWND(), L"", false); + + //trace(ret1); + return ret1; + } + int OnAddImage() { + int row = dw_list.GetNextSelectRow(1); + if (row < 1) row = dw_list.GetRow(); + if (row < 1 || row > dw_list.GetRowCount()) return 0; + KXMLDOMElement e = g_xdoc_product.getRowElement(L"data/Item", row); + //KXMLDOMElement e = dw_list.GetRowElement(row); + //alert(e.xml); + xstring id = g_xdoc_product.getData(0, L"data/Item", row, L"@guid"); + //alert(id); + int ret1 = Up(id); + //alert(ret1.toString()); + if (ret1 == -1) + return -1; + if (ret1 == 0) + { + alert(L"上传图片失败"); + return -1; + } + + //GoodsLib:GetList($parent) goodslib.object.xq + // 图片名加入数据库 + xstring path = L"data/Item"; + g_xdoc_product.xdoc.SetXPath(path); + g_xdoc_product.setItem(path, row, L"ImgName", id + L".jpg"); + KXMLDOMElement e1 = g_xdoc_product.getRowElement(L"data/Item", row); + xstring val = e1.xml(); //g_xdoc_product.GetContent(); + //trace(val); + xml x ; + xaserverarg arg; + arg.AddArg(L"content", val); + if (xurl::get(L"/sale/data/ProductLibrary/image/update", arg.GetString(), x) != 1) + { + alert(x.text()); + return -1; + } + //alert(x.GetXml()); + //xstring ImgName = g_xdoc_product.getItemString(path,row, L"ImgName"); + //alert(ImgName); + + //刷新一下界面,显示图片 + xshtml xs = GetControl(L"html_detail"); + xstring html = makeHtml(row); + xs.SetContent(html); + xs.Redraw(); + + //alert(L"上传图片成功!"); + return 1; + } + int OnDeleteImage() { + int row = dw_list.GetNextSelectRow(1); + if (row < 1) row = dw_list.GetRow(); + if (row < 1 || row > dw_list.GetRowCount()) return 0; + KXMLDOMElement e1 = g_xdoc_product.getRowElement(L"data/Item", row); + xstring val = e1.xml(); + xml x ; + + xaserverarg arg; + + arg.AddArg(L"content", val); + if (xurl::get(L"/sale/data/ProductLibrary/image/delete", arg.GetString(), x) != 1) + { + alert(x.text()); + return -1; + } + + return 1; + } + int OnPreviewImage() + { + int row = dw_list.GetNextSelectRow(1); + if (row < 1) row = dw_list.GetRow(); + if (row < 1 || row > dw_list.GetRowCount()) return 0; + KXMLDOMElement e = g_xdoc_product.getRowElement(L"data/Item", row); + //KXMLDOMElement e = dw_list.GetRowElement(row); + //alert(e.xml); + xstring id = g_xdoc_product.getData(0, L"data/Item", row, L"@guid"); + + int pr = g_xdoc_product; + OpenWindow(L"dev:xpage[PictureView.Product3.vx]", pr); + + return 1; + } + + int ItemMaint() + { + HTREEITEM hItem = tv_folder.GetSelectedItem(); + KXMLDOMElement& e = *(KXMLDOMElement*)tv_folder.GetItemData(hItem); + //xstring no = e.getAttribute(L"no"); + //if(no==L"") return 1; + xstring guid = e.getAttribute(L"guid"); + if (guid == L"") return 1; + + /* + if(no==L"NP0000FS" || no==L"UP0000FS") + { + OpenWindow(L"dev:xpage[PackSchemaMaint.goodslib.vx]"); + }else + { + int pr = g_xdoc_product; + OpenWindow(L"dev:xpage[ProductLibraryItemMaint.vx]",pr); + } + */ + + int pr = g_xdoc_product; + OpenWindow(L"dev:xpage[ProductLibraryItemMaint3.vx]", pr); + + return 1; + } + + int ItemAdd() + { + + HTREEITEM hItem = tv_folder.GetSelectedItem(); + + KXMLDOMElement& e = *(KXMLDOMElement*)tv_folder.GetItemData(hItem); + + + //alert(e.xml); + /*xstring no = e.getAttribute(L"no"); + if(no==L"") return 1; + if(no==L"NP0000FS" || no==L"UP0000FS") + { + OpenWindow(L"dev:xpage[PackSchemaMaint.goodslib.vx]"); + }else + { + int p = no; + OpenWindow(L"dev:xpage[SO.autolist.goodslib.add.vx]",p); + }*/ + xstring guid = e.getAttribute(L"guid"); + if (guid == L"") return 1; + xaserverarg arg; + arg.setNativePointer(arg.CreateInstance()); + arg.AddArg(L"guid", e.getAttribute(L"guid")); + arg.AddArg(L"No", e.getAttribute(L"CategoryNo")); + arg.AddArg(L"CName", e.getAttribute(L"CName")); + int p = arg; + OpenWindow(L"dev:xpage[Quick.Input.Product.vx]", p); + + return 1; + } + + int OnImport() + { + if (!hObject) return 1; + + int rw = 0; + xstring ls_nos = L"ImportXml:"; + /* + if(agentFor !=L"goodscar") + { + rw = dw_list.GetNextSelectRow(1); + if (rw<1 || rw > dw_list.GetRowCount()) + { + alert(L"请选择商品!"); + return 1; + } + + + while (rw>0) + { + ls_nos += L",L"+dw_list.GetItemString(rw, L"SKUNo"); + //ls_nos += L",L"+dw_list.GetItemString(rw, L"GoodsNo"); + //ls_nos += L",L"+dw_list.GetItemString(rw, L"GoodNo"); + rw = dw_list.GetNextSelectRow(rw + 1); + } + dw_list.SelectRow(0,false); + dw_list.Redraw(); + } + else + { + rw = dwc_list.GetNextSelectRow(1); + if (rw<1 || rw > dwc_list.GetRowCount()) + { + alert(L"请选择商品!"); + return 1; + } + + int hItem = tv_folder.GetSelectedItem(); + hItem = LookupCustomerFolder(hItem); + if(!hItem) + { + //trace(L"-------"); + return 1; + } + + KXMLDOMElement e = cast(tv_folder.GetItemData(hItem) as KXMLDOMElement); + xstring no = e.getAttribute(L"no"); + xstring name = e.getAttribute(L"name"); + xstring customer = no.mid(no.find(L":")+1,99999); + xstring customername = name.mid(no.find(L":")+1,99999); + if(CustomerID !=L"" && CustomerID != customer) + { + alert(L"只能转入"+CustomerName+L"报价数据!"); + return 1; + } + if(CustomerID==L"") + { + CustomerID = customer; + CustomerName = customername; + win32::SendMessage(hObject,0x401,L"xmSetCustomer:"+CustomerID+L"\t"+CustomerName,0); + } + + while (rw>0) + { + xstring ql = g_xdoc_shoppingcart.getData(0,L"data/Item",rw,L"QuoteLineID"); + if(ql !=L"") + ls_nos +=L" "+L"ql:"+ql; + else if(dwc_list.GetItemString(rw, L"SKUNo") !=L"") + ls_nos += L" "+dwc_list.GetItemString(rw, L"SKUNo"); + else + ls_nos += L" "+dwc_list.GetItemString(rw, L"No"); + //trace(ls_nos); + rw = dwc_list.GetNextSelectRow(rw + 1); + } + dwc_list.SelectRow(0,false); + dwc_list.Redraw(); + } + */ + if (impStr == L"") + { + alert(L"请选择商品!"); + return 1; + } + ls_nos += impStr; + dwc_list.SelectRow(0, false); + dwc_list.Redraw(); + dw_list.SelectRow(0, false); + dw_list.Redraw(); + impStr = L""; + + SendMessageW(hObject, 0x401, ls_nos, 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"xmCarGoodsDelete") + { + CarGoodsDelete(); + return 1; + } + else if (comdid == L"xmClose") + { + CloseWindow(); + return 1; + } + else if (comdid == L"xmCarGoodsMaint") + { + OpenWindow(L"dev:xpage[ShoppingCartProductMaint.vx]", trust(g_xdoc_shoppingcart as int)); + return 1; + } + else if (comdid == L"xmCarMaint") + { + OpenWindow(L"dev:xpage[SO.autolist.Shopcar.vx]"); + return 1; + } + else if (comdid == L"xmSaleOrder") + { + int rw = dwc_list.GetNextSelectRow(1); + xstring content = L"<data>"; + while (rw > 0) + { + KXMLDOMElement xe = OnGetCarListRowElement(rw); + content += xe.xml(); + rw = dwc_list.GetNextSelectRow(rw + 1); + + } + content += L"</data>"; + xaserverarg carg; + carg.AddArg(L"content", content); + + OpenWindow(L"dev:xpage[SO.Simulation.Import.vx]", (LPARAM)&carg); + return 1; + } + else if (comdid == L"xmEnquiry") + { + int rw = dwc_list.GetNextSelectRow(1); + xstring content = L"<data>"; + while (rw > 0) + { + KXMLDOMElement xe = OnGetCarListRowElement(rw); + content += xe.xml(); + rw = dwc_list.GetNextSelectRow(rw + 1); + } + content += L"</data>"; + xaserverarg carg; + + carg.AddArg(L"content", content); + + OpenWindow(L"dev:xpage[Enquiry.Import.vx]", (LPARAM)&carg); + return 1; + } + else if (comdid == L"xmPurchar") + { + int rw = dwc_list.GetNextSelectRow(1); + xstring content = L"<data>"; + while (rw > 0) + { + KXMLDOMElement xe = OnGetCarListRowElement(rw); + content += xe.xml(); + rw = dwc_list.GetNextSelectRow(rw + 1); + } + content += L"</data>"; + xaserverarg carg ; + + carg.AddArg(L"content", content); + + OpenWindow(L"dev:xpage[PO.Import.vx]", (LPARAM)&carg); + return 1; + } + else if (comdid == L"xmQuote") + { + int rw = dwc_list.GetNextSelectRow(1); + xstring content = L"<data>"; + while (rw > 0) + { + KXMLDOMElement xe = OnGetCarListRowElement(rw); + content += xe.xml(); + rw = dwc_list.GetNextSelectRow(rw + 1); + + } + content += L"</data>"; + xaserverarg carg; + + carg.AddArg(L"content", content); + + OpenWindow(L"dev:xpage[Quote.Import.vx]", (LPARAM)&carg); + return 1; + } + else if (comdid == L"xmAdd") + { + return ItemAdd(); + } + else if (comdid == L"xmDelete") + { + int row = dw_list.GetRow(); + if (row < 1) return 1; + DeleteRow(row); + + return 1; + } + else if (comdid == L"xmCarAdd") + { + HCURSOR hCursor = xutil::SetCursorWait(); + + name = xcontrol(GetControl(L"frame:ed_goodscar")).GetText(); + if (name != L"") + { + if (ShoppingCartView::AddCar(name) == 1) + { + tv_folder.InsertChildItem(LookupTopFolder(tv_folder.GetSelectedItem()), + name, 0, 35); + } + } + xutil::RestoreCursor(hCursor); + return 1; + } + else if (comdid == L"xmMaint") + { + return ItemMaint(); + } + else if (comdid == L"xmAddImage") + { + return OnAddImage(); + } + else if (comdid == L"xmDeleteImage") + { + return OnDeleteImage(); + } + else if (comdid == L"xmPreviewImage") + { + return OnPreviewImage(); + } + else if (comdid == L"xmPropConfigure") + { + int r = cast(g_xdoc_product.getData(L"data/Item", L"@guid") as int); + OpenWindow(L"dev:xpage[Product.ItemProp.Maint.vx]", r); + return 1; + } + else if (comdid == L"xmRertieve") + { + int hItem1 = tv_folder.GetSelectedItem(); + KXMLDOMElement e2 = tv_folder.GetItemData(hItem1); + xstring no1 = e2.getAttribute(L"no"); + xml x2 = vcontrol::RetrieveData(L"/sale/data/SO/goods/usergoods/listex1", L"parent", no1); + g_xdoc_product.Retrieve(x2); + dwc_list.PostRetrieve(); + dw_list.PostRetrieve(); + + return 1; + } + else if (comdid == L"xmToCar") + { + name = xcontrol(GetControl(L"frame:cbx_goodscar")).GetText(); + if (name == L"==选择购物车==L") + { + alert(L"请选择购物车"); + return 1; + } + int xrow = dw_list.GetNextSelectRow(1); + xstring goodsid = L""; + xstring html = L"<data>"; + while (xrow > 0) + { + KXMLDOMElement e = g_xdoc_product.getRowElement(L"data/Item", xrow); + goodsid = ProductLibraryView::GetElementString(e, L"@guid"); + html += L"<item goodid='" + goodsid + L"' id ='" + ProductLibraryView::GetGuid() + L"'/>"; + xrow = dw_list.GetNextSelectRow(xrow + 1); + } + html += L"</data>"; + trace(html); + if (ShoppingCartView::GoodsImport(name, html) == 1) + alert(L"添加错误!"); + else + alert(L"添加成功"); + return 1; + } + else if (comdid == L"xmImport") + { + OnImport(); + CloseWindow(); + return 1; + } + else if (comdid == L"xmSearch") + { + OnSearch(); + return 1; + } + return 0; + } + + //命令处理事件 + int OnXCommand(TEvent* evt, int param) + { + return OnCmdDispatch(evt->xcommand.pStrID); + } + + HTREEITEM LookupCustomerFolder(HTREEITEM hItem) + { + KXMLDOMElement e = tv_folder.GetItemData(hItem); + xstring no = e.getAttribute(L"no"); + if (no.find(L"Customer1:") >= 0) return hItem; + + while (tv_folder.GetParentItem(hItem)) + { + hItem = tv_folder.GetParentItem(hItem); + e = tv_folder.GetItemData(hItem); + no = e.getAttribute(L"no"); + if (no.find(L"Customer1:") >= 0) return hItem; + } + return 0; + } + + //查找当前树项的顶级目录 + 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; + + KXMLDOMNodeList nlist = x.selectNodes(L"//Item"); + int len = nlist.length(); + for (int i = 0; i < len; i++) + { + KXMLDOMElement& e = *new KXMLDOMElement(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, (LPARAM)&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 = *new KXMLDOMElement(nlist.item(i)); + xstring name = e.getAttribute(L"name"); + HTREEITEM h = tv_folder.InsertChildItem(hItem, name, (LPARAM)&e, image); + ExpandCatChildFolder(h, e, 35); + } + return 1; + } + int MakeGoodCarFolderItem(HTREEITEM hItem) + { + xml x = ShoppingCartView::GetRoleList(); + if (!x) return 0; + KXMLDOMNodeList nlist = x.selectNodes(L"/data/item"); + int len = nlist.length(); + for (int i = 0; i < len; i++) + { + KXMLDOMElement& e = *new KXMLDOMElement(nlist.item(i)); + xstring name = e.getAttribute(L"name"); + HTREEITEM h = tv_folder.InsertChildItem(hItem, name, (LPARAM)&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"N000005"; + 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"U000005"; + if (hTopItem != hItem) + { + e = tv_folder.GetItemData(hItem); + no = e.getAttribute(L"no"); + } + MakeGoodsFolderItem(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 RetrieveItem(HTREEITEM hItem) + { + HTREEITEM hTopItem = LookupTopFolder(hItem); + xstring name = tv_folder.GetItemLabel(hTopItem); + xstring selectname = tv_folder.GetItemLabel(hItem); + dw_list.SelectRow(0, false); + dwc_list.SelectRow(0, false); + + 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"); + if (str.find(L"Customer1:") == 0 || str.find(L"Customer:") == 0 || str.find(L"SO:") == 0 || str.find(L"Quote:") == 0) + { + if (str.find(L"Customer:") == 0 || str.find(L"Customer1:") == 0) + dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodscustomerlist"); + else { + dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodssolist"); + } + dwc_list.SetReadOnly(true); + trace(str + L"+++++L" + queryString); + 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).GetXmlDoc()); + dwc_list.SetReadOnly(true); + + g_xdoc_shoppingcart.Retrieve(ProductLibraryView::GetMaintList3(categoryid, queryString, L"")); + } + else + { + + dwc_list.openUrl(L"/sale/view/ProductLibrary/template/cart/goodslist"); + dwc_list.SetReadOnly(true); + g_xdoc_shoppingcart.Retrieve(ShoppingCartView::GetGoodsList(selectname, queryString)); + } + dwc_list.PostRetrieve(); + dwc_list.Redraw(); + + if (dwc_list.GetRowCount() >= 0) + { + xshtml xs = GetControl(L"html_detail"); + xs.SetContent(makeGoodscarHtml(1)); + } + else + { + xs = GetControl(L"html_detail"); + xs.SetContent(L"<html><body/></html>"); + } + xs.Redraw(); + } + } + else + { + if (agentFor != L"goodslib")SwitchLayer(L"goodslibsheet", L"sheetframe"); + 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).GetXmlDoc()); + dw_list = GetControl(L"dw_list"); + dw_list.SetReadOnly(true); + + g_xdoc_product.Retrieve(ProductLibraryView::GetMaintList3(no, queryString, L"")); + dw_list.PostRetrieve(); + dw_list.Redraw(); + + if (dw_list.GetRowCount() >= 0) + { + xs = GetControl(L"html_detail"); + xs.SetContent(makeHtml(1)); + } + else + { + xs = GetControl(L"html_detail"); + xs.SetContent(L"<html/>"); + } + xs.Redraw(); + xutil::RestoreCursor(hCursor); + } + } + + return 1; + } + + int OnTreeSelChanged(TEvent* evt, int 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 = *new KXMLDOMElement(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, (LPARAM)&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, LPARAM 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 = g_xdoc_shoppingcart.getData(0, L"data/Item", row, L"QuoteLineID"); + if (str != L"") + str = L"ql:" + 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 = 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""; + win32::SendMessage(hObject, 0x401, ls_nos, 0); + + xutil::RestoreCursor(hCursor); + CloseWindow(); + return 1; + } + + int OnAttachEvent() + { + //绑定工具条点击事件 + AttachEvent(L"WM_XCOMMAND", (FEvent)&ProductSelectSOWin::OnXCommand); + //获取焦点事件,用于重置工具条 + AttachEvent(L"WM_SETFOCUS", (FEvent)&ProductSelectSOWin::OnSetFocus); + AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&ProductSelectSOWin::OnRowChanged); + AttachEvent(L"dwc_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&ProductSelectSOWin::OnGoodsCarRowChanged); + AttachEvent(L"tv_folder", L"TVN_ITEMEXPANDING", (FEvent)&ProductSelectSOWin::OnTreeExpanding); + AttachEvent(L"tv_folder", L"TVN_SELCHANGED", (FEvent)&ProductSelectSOWin::OnTreeSelChanged); + AttachEvent(L"WM_COMMAND", (FEvent)&ProductSelectSOWin::OnCkbCLick); //checkbox打钩事件 + AttachEvent(L"WM_COMMAND", (FEvent)&ProductSelectSOWin::OnCkbCLick2); //checkbox打钩事件 + AttachEvent(L"dw_list", L"DWV_CLICKED", (FEvent)&ProductSelectSOWin::OnDwClicked); + AttachEvent(L"dwc_list", L"DWV_CLICKED", (FEvent)&ProductSelectSOWin::OnDwcClicked); + + AttachEvent(L"dwc_list", L"DWV_DOUBLECLICKED", (FEvent)&ProductSelectSOWin::OnImport); + } + + int onload() + { + agentFor = L"goodslib"; + + OnAttachEvent(); + + tv_folder = GetControl(L"tv_folder"); + dw_list = GetControl(L"dw_list"); + dwc_list = GetControl(L"dwc_list"); + + xaserverarg arg; + CustomerID = L""; + CustomerName = L""; + hObject = 0; + if (arg) + { + hObject = (int)arg.GetArgString(L"HWND"); + 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"").GetXmlDoc()); + 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)); + } + + //xtreeview::ExpandItem(tv_folder.GetId(), + // xtreeview::GetNextItem(tv_folder.GetId(),xtreeview::GetRootItem(tv_folder.GetId()))); + xtreeview::ExpandItem(tv_folder.GetId(), xtreeview::GetRootItem(tv_folder.GetId())); + + dw_list.SetSelectionMode(3); + dwc_list.SetSelectionMode(3); + + return 1; + } + + int onloaded() + { + SetAgent(); + + return 1; + } + }; \ No newline at end of file diff --git a/jrj/ext-jrj/delivery.base.maint.so.cpp b/jrj/ext-jrj/delivery.base.maint.so.cpp new file mode 100644 index 0000000..b674738 --- /dev/null +++ b/jrj/ext-jrj/delivery.base.maint.so.cpp @@ -0,0 +1,191 @@ +#include <wobject/xstring.hpp> +#include <xcontrol/xtreeview.hpp> +#include <xcontrol/xdwgrid.hpp> +#include <xcontrol/xcell.hpp> + + +#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" +#include "viewobject/view.base.hpp" + + + + class __declspec(dllexport) DeliveryEdit : public xframe + { + public: + xdwtable dw_1; + + vcontrol vc; + xcell dw_cell; + + public: + DeliveryEdit(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} + public: + static DeliveryEdit* CreateInstance(void* implPtr, void* hWnd) + { + DeliveryEdit* pWin = new DeliveryEdit(implPtr, (HWND)hWnd); + return pWin; + } + + xstring OnCreateTxt() + { + //dw_1.AcceptText(); //不能加会报错 + xstring sType; + xstring sDeliveryRule; + xstring sDeliveryDays; + xstring sScheduleShipDate; + xstring sTxt; + + sType = dw_1.GetItemString(1, L"DeliveryRule"); + sDeliveryRule = dw_1.GetItemDisplayString(1, L"DeliveryRule"); + sDeliveryDays = dw_1.GetItemString(1, L"DeliveryDays"); + sScheduleShipDate = dw_1.GetItemString(1, L"ScheduleShipDate"); + + if (sType == L"1") + { + if (sDeliveryDays != L"") + sTxt = L"Shipment within " + sDeliveryDays + L" days after receipt of L/C."; + else + sTxt = L""; + } + else if (sType == L"2") + { + if (sDeliveryDays != L"") + sTxt = L"Within " + sDeliveryDays + L" days after receiving the deposit."; + else + sTxt = L""; + } + else if (sType == L"3") + if (sDeliveryDays != L"") + sTxt = L"Within " + sDeliveryDays + L" days after receiving the signed P/I."; + else + sTxt = L""; + else if (sType == L"4") + { + if (sScheduleShipDate != L"") + sTxt = sScheduleShipDate; + else + sTxt = L""; + } + else + sTxt = L""; + + return sTxt; + } + + int OnOk() + { + dw_1.AcceptText(); + + CloseWindow(); + + return 1; + } + + int OnItemChanged(TEvent* evt, LPARAM p) + { + DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; + xstring colname = hdr.colname; + xstring value = hdr.data; + + if (colname == L"DeliveryRule") + { + xstring sP = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='保护' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial=''><edit edittype=''/></cellprop>"; + xstring sUp = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial=''><edit edittype=''/></cellprop>"; + + if (value == L"1" || value == L"2" || value == L"3") + { + dw_cell.SetCellProps(3, 3, sUp); + dw_cell.SetCellProps(4, 3, sP); + } + else if (value == L"4") + { + dw_cell.SetCellProps(3, 3, sP); + dw_1.SetItemString(1, L"DeliveryDays", L""); + } + else + { + dw_cell.SetCellProps(3, 3, sP); + dw_cell.SetCellProps(4, 3, sUp); + dw_1.SetItemString(1, L"DeliveryDays", L""); + } + + } + + //生成交货期 + if (colname == L"DeliveryRule" || colname == L"DeliveryDays" || colname == L"ScheduleShipDate") + { + xstring sTxt = OnCreateTxt(); + dw_1.SetItemString(1, L"DeliveryTime", sTxt); + } + + return 1; + } + + int OnCmdDispatch(xstring comdid) + { + + if (comdid == L"xmOk") return OnOk(); + + return 0; + } + + int OnXCommand(TEvent* evt, LPARAM p) + { + + return OnCmdDispatch(evt->xcommand.pStrID); + } + + int OnAttachEvent() + { + AttachEvent(L"WM_XCOMMAND", (FEvent)&DeliveryEdit::OnXCommand); + AttachEvent(L"dw_1", L"DWV_ITEMCHANGED", (FEvent)&DeliveryEdit::OnItemChanged); + + return 1; + } + + int OnInit() + { + int iArgs = GetParam(); + + XXmlContentSvr xdoc = new XXmlContentSvr; + xdoc.setNativePointer(iArgs); + vc = new vcontrol; + vc.xdoc = xdoc; + + vbind bind = new vbind; + bind.bind(dw_1, vc); + + xml x; + x = new xml; + x.setNativePointer(xml::CreateInstance()); + x.LoadXml(vc.GetContent()); + + dw_1.Retrieve(x); + + xstring sDeliveryRule = dw_1.GetItemString(1, L"DeliveryRule"); + xstring sP = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='保护' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial=''><edit edittype=''/></cellprop>"; + if (sDeliveryRule != L"1" && sDeliveryRule != L"2" && sDeliveryRule != L"3") + dw_cell.SetCellProps(3, 3, sP); + if (sDeliveryRule != L"5") + dw_cell.SetCellProps(4, 3, sP); + + return 1; + } + + int onload() + { + dw_1 = GetControl(L"dw_1"); + dw_1.openUrl(L"/sale/view/SaleOrder/template/delivery"); //base.maint.so.tpl/delivery + dw_1.SetColHeaderHeight(0); + dw_1.SetRowSelectorWidth(0); + dw_1.SetScrollState(false); + + dw_cell = new xcell; + dw_cell.setNativePointer(dw_1.QueryItem(L"ixcell")); + OnAttachEvent(); + + if (GetParam())OnInit(); + + return 1; + } + }; diff --git a/jrj/ext-jrj/ext-jrj.aps b/jrj/ext-jrj/ext-jrj.aps new file mode 100644 index 0000000..ca66535 --- /dev/null +++ b/jrj/ext-jrj/ext-jrj.aps Binary files differ diff --git a/jrj/ext-jrj/ext-jrj.vcxproj b/jrj/ext-jrj/ext-jrj.vcxproj index 9535065..b8129f0 100644 --- a/jrj/ext-jrj/ext-jrj.vcxproj +++ b/jrj/ext-jrj/ext-jrj.vcxproj @@ -252,7 +252,9 @@ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> - <ClCompile Include="..\project\business\quote.enquiry.cpp" /> + <ClCompile Include="..\project\business\quote.enquiry.cpp"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + </ClCompile> <ClCompile Include="..\project\business\Quote3.list3.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> </ClCompile> @@ -263,6 +265,7 @@ <ClCompile Include="..\project\business\SO3.maint.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> </ClCompile> + <ClCompile Include="..\project\business\SO\paymentterm.base.maint.so.cpp" /> <ClCompile Include="..\project\business\Supplier.maint.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> </ClCompile> @@ -276,13 +279,17 @@ <ClCompile Include="..\xframe\src\nmemory.cpp" /> <ClCompile Include="..\xframe\src\nstring.cpp" /> <ClCompile Include="..\xframe\src\xstring.cpp" /> + <ClCompile Include="delivery.base.maint.so.cpp" /> <ClCompile Include="dllmain.cpp" /> + <ClCompile Include="maint.Document.SO3.v3.cpp" /> <ClCompile Include="pch.cpp"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> </ClCompile> + <ClCompile Include="Product.Select.SO.cpp" /> + <ClCompile Include="select.item.so.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/jrj/ext-jrj/maint.Document.SO3.v3.cpp b/jrj/ext-jrj/maint.Document.SO3.v3.cpp new file mode 100644 index 0000000..843f83b --- /dev/null +++ b/jrj/ext-jrj/maint.Document.SO3.v3.cpp @@ -0,0 +1,476 @@ +#include <wobject/xstring.hpp> +#include <xcontrol/xtreeview.hpp> +#include <xcontrol/xdwgrid.hpp> + +#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" +#include "viewobject/view.base.hpp" + +using xml = KXMLDOMDocument; + + class __declspec(dllexport) DocSO3 : public xframe + { + public: + DocSO3(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} + public: + static DocSO3* CreateInstance(void* implPtr, void* hWnd) + { + DocSO3* pWin = new DocSO3(implPtr, (HWND)hWnd); + return pWin; + } + public: + //xdwgrid dw_list; + xlistview lv_view; + xnode m_agentNode; //Agent Condition + int columnCount; + xstring entityid; + int hObject = 0; + xstring TypeEx; + xstring Type; + xstring ApprovalStatus; + + int SetAgent() + { + xstring xfNodeAgentArea = L"agentarea"; + xnode anode = GetAgentNode(xfNodeAgentArea); + if (m_agentNode) + { + //SetAgentNodeContent + 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 p) + { + //重置工具条 + SetAgent(); + return 1; + } + + int OnListViewDoubleClicked(TEvent* evt, LPARAM p) + { + //重置工具条 + //SetAgent(); + + OnDocumentOpen(); + //CloseWindow(); + return 1; + } + + int OnDocumentOpen() + { + //return 1; + + int LVNI_ALL = 0x0000; + int LVNI_FOCUSED = 0x0001; + int LVNI_SELECTED = 0x0002; + int LVNI_CUT = 0x0004; + int LVNI_DROPHILITED = 0x0008; + + int nItem = xlistview::GetNextItem(lv_view.GetId(), -1, LVNI_FOCUSED); + if (nItem < 0) return 1; + + int LVIF_PARAM = 0x0004; + + lvitem lvItem; + lvItem.iItem = nItem; + lvItem.iSubItem = 0; + lvItem.mask = LVIF_PARAM; + + xlistview::GetItem(lv_view.GetId(), lvItem); + KXMLDOMElement ele = trust(lvItem.lParam as KXMLDOMElement); + + xstring src = ele.getAttribute(L"url"); + xstring name = ele.getAttribute(L"caption"); + xstring file = L""; + if (src.find(L"/file/") > 0) file = src.mid(src.find(L"/file/") + 6, 9999); + if (file == L"") return 1; + xstring str = file.left(2); + xstring ext = L""; + if (name.find(L".") >= 0) ext = name.mid(name.find(L"."), name.length()); + xstring sfile = file; + + xaserverarg arg ; + if (arg) + { + arg.AddArg(L"result", L"ok"); + if ((arg.GetArgString(L"process") == L"path" || arg.GetArgString(L"process") == L"data")) + { + arg.AddArg(L"path", src); + arg.AddArg(L"filename", name); + arg.AddArg(L"src", L"/business/attachment/" + str + L"/" + file + L".jpg"); + if (arg.GetArgString(L"process") == L"path") return 1; + } + } + + + /* + const xstring d = m_Html.GetData(p.object); + if(d == L"") return -1; + xstring file = d.mid(0, d.find(L"|##@@|",0)); + xstring name = d.mid(d.find(L"|##@@|",0)+6, d.length()); + */ + + xaserver::__CreateDirectory(L"C:/Temp"); + if (arg) + { + if (arg.GetArgString(L"process") == L"data") + { + xml x ; + + xaserver::LoadUrl(GetServerUrl(), L"/business/attachment/" + str + L"/" + file + L".jpg", L"", x); + arg.AddArg(L"data", x.xml()); + return 1; + } + } + + int openRet = xaserver::DownLoadFile(GetServerUrl(), L"/business/attachment/" + str + L"/" + file + L".jpg", L"", L"C:/Temp/" + sfile + ext); + + + + //alert(L"/business/attachment/"+str+L"/"+ file+L".jpg"); + if (openRet < 0) + { + alert(L"文件打开失败1!"); + return -1; + } + //openRet = win32::ShellExecute(0,L"open",L"C:/Temp/"+name,L"",L"",5); + openRet = ShellExecuteW(0, L"open", L"C:/Temp/" + sfile + ext, L"", L"", 5); + if (openRet < 32) + { + alert(L"文件打开失败2!"); + return -1; + } + + return 1; + } + + int OnAddAttachment() + { + xstring PayType = GetPayType(); + xstring sguid = publiccode::GetGuid(); + xstring sname = sguid; + xstring str = sname.mid(0, 2); + str = str.toUpper(); + xstring suri = L"attachment" + str; + xstring ret = xaserver::UploadFile(suri, sname + L".jpg", GetHWND(), L"", false); + if (ret == L"-1") + { + alert(L"上传的文件没选择!"); + return 0; + } + else + { + while (ret.find(L"\\", 0) >= 0) + ret = ret.mid(ret.find(L"\\", 0) + 1, 9999); + + + xstring myurl = L"object/Forwarder"; + xml x; + + xaserverarg args ; + args.setNativePointer(args.CreateInstance()); + args.AddArg(L"myurl", myurl); + args.AddArg(L"name", ret); + args.AddArg(L"filepath", sname); + args.AddArg(L"fileext", L""); + args.AddArg(L"filesource", ret); + args.AddArg(L"entityid", entityid); + args.AddArg(L"Type", PayType); + + /*xml x1 = ViewObject::RetrieveData(L"/sale/data/TDocument3/attachment/GetFileFormat",L"Name",ret); + KXMLDOMNodeList items = x1.GetXmlDoc().selectNodes(L"data/Item"); + KXMLDOMNode t = items.item(0); + xstring FileFormat=L""; + if(t.selectSingleNode(L"FileFormat"))FileFormat=t.selectSingleNode(L"FileFormat").text; + if(FileFormat !=L"pdf" && FileFormat !=L"PDF") + { + alert(L"请上传PDF格式的文件"); + return 0; + }*/ + //alert(L"myurl:"+myurl+L"--name:"+ret+L"--filepath:"+sname+L"--filesource:"+ret+L"--entityid:"+entityid); + if (xurl::get(L"/sale/data/TDocument3/attachment/addex", args.GetString(), x) != 1) + { + alert(L"保存出错了!"); + return 0; + } + else + { + alert(x.text()); + Retrieve(entityid); + } + } + return 0; + } + int OnDocumentOpen() + { + int LVNI_ALL = 0x0000; + int LVNI_FOCUSED = 0x0001; + int LVNI_SELECTED = 0x0002; + int LVNI_CUT = 0x0004; + int LVNI_DROPHILITED = 0x0008; + + int nItem = xlistview::GetNextItem(lv_view.GetId(), -1, LVNI_FOCUSED); + if (nItem < 0) return 1; + + int LVIF_PARAM = 0x0004; + + lvitem lvItem; + lvItem.iItem = nItem; + lvItem.iSubItem = 0; + lvItem.mask = LVIF_PARAM; + + xlistview::GetItem(lv_view.GetId(), lvItem); + KXMLDOMElement ele = trust(lvItem.lParam as KXMLDOMElement); + + xstring src = ele.getAttribute(L"url"); + xstring file = L""; + if (src.find(L"/file/") > 0) file = src.mid(src.find(L"/file/") + 6, 9999); + if (file == L"") return 1; + + xstring name = ele.getAttribute(L"caption"); + + xaserver::__CreateDirectory(L"C:/Temp"); + xstring str = file.left(2); + xstring ext = L""; + if (name.find(L".") >= 0) ext = name.mid(name.find(L"."), name.length()); + xstring sfile = file; + int openRet = xaserver::DownLoadFile(GetServerUrl(), L"/business/attachment/" + str + L"/" + file + L".jpg", L"", L"C:/Temp/" + sfile + ext); + + if (openRet < 0) + { + alert(L"文件打开失败1!"); + return -1; + } + + openRet = ShellExecuteW(0, L"open", L"C:/Temp/" + sfile + ext, L"", L"", 5); + if (openRet < 32) + { + alert(L"文件打开失败2!"); + return -1; + } + + return -1; + } + + int OnDeleteFile() + { + int LVNI_ALL = 0x0000; + int LVNI_FOCUSED = 0x0001; + int LVNI_SELECTED = 0x0002; + int LVNI_CUT = 0x0004; + int LVNI_DROPHILITED = 0x0008; + + int nItem = xlistview::GetNextItem(lv_view.GetId(), -1, LVNI_FOCUSED); + if (nItem < 0) return 1; + + int LVIF_PARAM = 0x0004; + + lvitem lvItem; + lvItem.iItem = nItem; + lvItem.iSubItem = 0; + lvItem.mask = LVIF_PARAM; + + xlistview::GetItem(lv_view.GetId(), lvItem); + KXMLDOMElement ele = trust(lvItem.lParam as KXMLDOMElement); + + xstring src = ele.getAttribute(L"url"); + xstring file = L""; + if (src.find(L"/file/") > 0) file = src.mid(src.find(L"/file/") + 6, 9999); + if (file == L"") return 1; + + xstring name = ele.getAttribute(L"caption"); + if (MessageBoxW(GetHWND(), L"确定要删除文件" + name + L"?", L"提示", 1) == 2) + return 0; + + xaserverarg arg ; + arg.setNativePointer(arg.CreateInstance()); + arg.AddArg(L"filepath", file); + xml x ; + if (xurl::get(L"/sale/data/TDocument3/file/delete", arg.GetString(), x) != 1) + { + alert(L"删除出错了!"); + return 1; + } + else + { + //alert(x.GetXmlDoc().text); + xlistview::DeleteItem(lv_view.GetId(), nItem); + } + + return 1; + } + + xstring GetPayType() + { + xcombobox cbx_type = GetControl(L"cbx_type"); + int h = xcombobox::GetCurSel(cbx_type.GetId()); + if (h < 0) return L""; + return xcombobox::GetLBText(cbx_type.GetId(), h); + } + + //命令发布函数 + int OnCmdDispatch(xstring comdid) + { + if (comdid == L"xmOpen") + { + return OnDocumentOpen(); + } + if (Type != L"Y") + { + if (ApprovalStatus != L"3") + { + if (comdid == L"xmUpload") + { + return OnAddAttachment(); + } + if (TypeEx != L"Y") + { + if (comdid == L"xmDelete") + { + return OnDeleteFile(); + } + } + } + } + if (comdid == L"xmClose") + { + CloseWindow(); + return 1; + } + return 0; + } + + //命令处理事件 + int OnXCommand(TEvent* evt, LPARAM param) + { + return OnCmdDispatch(evt->xcommand.pStrID); + } + + int OnAttachEvent() + { + //绑定工具条点击事件 + AttachEvent(L"WM_XCOMMAND", (FEvent)&DocSO3::OnXCommand); + //获取焦点事件,用于重置工具条 + //AttachEvent(L"WM_SETFOCUS",OnSetFocus); + } + + /* + int OnRetrieve() + { + xml x = new xml; + x.setNativePointer(xml::CreateInstance()); + xaserverarg arg = new xaserverarg; + arg.setNativePointer(arg.CreateInstance()); + arg.AddArg(L"xxx",L"xxx"); + if (getUrl(L"",arg.GetString(),x)!=1) + { + trace(x.GetXmlDoc().text); + return -1; + }else + { + //dw_list.Retrieve(x); + //dw_list.Redraw(); + } + return 1; + } + */ + + int SetListViewHeaderColumn(xstring Url) + { + const int LVCFMT_LEFT = 0; + for (int i = 0; i < 3; i++) lv_view.DeleteColumn(lv_view.GetId(), 1); + lv_view.InsertColumn(lv_view.GetId(), 0, L"类型", 0, 80, 0); + lv_view.InsertColumn(lv_view.GetId(), 0, L"创建日期", LVCFMT_LEFT, 80, 0); + lv_view.InsertColumn(lv_view.GetId(), 0, L"创建人员", LVCFMT_LEFT, 80, 0); + lv_view.InsertColumn(lv_view.GetId(), 0, L"名称", 0, 120, 0); + + columnCount = 3; + return 1; + } + + int Retrieve(xstring entityid) + { + lv_view.DeleteItemAll(lv_view.GetId()); + xstring src = L"object/Forwarder"; + xml x = ViewObject::RetrieveData(L"/sale/data/TDocument3/folder/listex", L"src", src, L"entityid", entityid); + if (x) + { + KXMLDOMElement ele = x.documentElement(); + KXMLDOMNodeList nlist = ele.selectNodes(L"*"); + int s = nlist.length(); + if (s > 0) + { + for (int i = 0; i < s; i++) + { + KXMLDOMElement e = nlist.item(i); + xstring name = e.getAttribute(L"caption"); + + int nItem = xlistview::InsertItemEx(lv_view.GetId(), 0, name, 23, cast(e as int)); + xlistview::SetItemText(lv_view.GetId(), nItem, 1, e.getAttribute(L"Creator")); + xlistview::SetItemText(lv_view.GetId(), nItem, 2, e.getAttribute(L"CreateDate")); + xlistview::SetItemText(lv_view.GetId(), nItem, 3, e.getAttribute(L"Type")); + + } + } + } + return 1; + } + + int GetSODocument(xstring entityid) + { + xml x = ViewObject::RetrieveData(L"/sale/data/SaleOrder/GetSODocument", L"SOID", entityid); + xstring r = x.text(); + int r1 = r.toInt(); + if (x) + { + if (r1 > 0) + { + TypeEx = L"Y"; + return 1; + } + } + return 1; + } + + int onload() + { + + lv_view = GetControl(L"lv_view"); + columnCount = 0; + SetListViewHeaderColumn(L""); + AttachEvent(L"lv_view", L"NM_DBLCLK", (FEvent)&DocSO3::OnListViewDoubleClicked); + + if (GetWinParam()) + { + xaserverarg arg; + entityid = arg.GetArgString(L"entityid"); + Type = arg.GetArgString(L"Type"); + ApprovalStatus = arg.GetArgString(L"ApprovalStatus"); + Retrieve(entityid); + } + + GetSODocument(entityid); + + OnAttachEvent(); + return 1; + } + + int onloaded() + { + //SetAgent(); + + return 1; + } + }; diff --git a/jrj/ext-jrj/select.item.so.cpp b/jrj/ext-jrj/select.item.so.cpp new file mode 100644 index 0000000..e6369a6 --- /dev/null +++ b/jrj/ext-jrj/select.item.so.cpp @@ -0,0 +1,157 @@ +#include <wobject/xstring.hpp> +#include <xcontrol/xtreeview.hpp> +#include <xcontrol/xdwgrid.hpp> + +#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" +#include "viewobject/view.base.hpp" + +using xml = KXMLDOMDocument; + class __declspec(dllexport) SelectItemSOWin : public xframe + { + public: + SelectItemSOWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} + public: + static SelectItemSOWin* CreateInstance(void* implPtr, void* hWnd) + { + SelectItemSOWin* pWin = new SelectItemSOWin(implPtr, (HWND)hWnd); + return pWin; + } + public: + xdwgrid dw_list; + + xnode m_agentNode; //Agent Condition + + 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 p) + { + //重置工具条 + //SetAgent(); + return 1; + } + + //命令发布函数 + int OnCmdDispatch(xstring comdid) + { + + if (comdid == L"xmSelectAll") + { + for (int i = 1; i <= dw_list.GetRowCount(); i++) + { + dw_list.SelectRow(i, true); + } + dw_list.Redraw(); + return 1; + } + else if (comdid == L"xmSelectNo") + { + dw_list.SelectRow(0, false); + dw_list.Redraw(); + + return 1; + } + else if (comdid == L"xmOk") + { + xaserverarg arg; + arg.AddArg(L"items", L""); + xstring str = L""; + int row = dw_list.GetNextSelectRow(1); + while (row > 0 && row <= dw_list.GetRowCount()) + { + KXMLDOMElement ele = dw_list.GetRowElement(row); + str += ele.xml(); + ele.Release(); + row = dw_list.GetNextSelectRow(row + 1); + } + if (str != L"") + arg.AddArg(L"items", L"<data>" + str + L"</data>"); + CloseWindow(); + return 1; + } + else if (comdid == L"xmCancel") + { + CloseWindow(); + return 1; + } + + return 0; + } + + //命令处理事件 + int OnXCommand(TEvent* evt, LPARAM p) + { + return OnCmdDispatch(evt->xcommand.pStrID); + } + + int OnAttachEvent() + { + //绑定工具条点击事件 + AttachEvent(L"WM_XCOMMAND", (FEvent)&SelectItemSOWin::OnXCommand); + //获取焦点事件,用于重置工具条 + AttachEvent(L"WM_SETFOCUS", (FEvent)&SelectItemSOWin::OnSetFocus); + } + + int onload() + { + dw_list = GetControl(L"dw_list"); + dw_list.openUrl(L"/sale/view/SaleOrder/template/item"); + + dw_list.SetColumnState(L"EnquiryPriceListID", false); + dw_list.SetColumnState(L"ItemID", false); + dw_list.SetColumnState(L"LineType", false); + dw_list.SetColumnState(L"Assortment", false); + dw_list.SetColumnState(L"ClassifyID", false); + dw_list.SetColumnState(L"UnitFreight", false); + dw_list.SetColumnState(L"CName", false); + dw_list.SetColumnState(L"QuoteLineID", false); + dw_list.SetColumnState(L"POSupplierID", false); + + dw_list.SetColumnState(L"ScheduleShipDate", false); + dw_list.SetColumnState(L"PONo", false); + dw_list.SetColumnState(L"PaperPODate", false); + + xml x; + + + xaserverarg arg; + if (arg) + { + xstring SONo = arg.GetArgString(L"SONo"); + x = SaleOrderView::GetMaintFormForItemList(SONo); + dw_list.Retrieve(x); + dw_list.SetReadOnly(true); + dw_list.SetSelectionMode(3); + arg.AddArg(L"items", L""); + } + OnAttachEvent(); + + return 1; + } + + int onloaded() + { + //SetAgent(); + + return 1; + } + }; diff --git a/jrj/project/business/GDN3.list.cpp b/jrj/project/business/GDN3.list.cpp index cef6bc4..8d9a8fd 100644 --- a/jrj/project/business/GDN3.list.cpp +++ b/jrj/project/business/GDN3.list.cpp @@ -4,7 +4,7 @@ #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" - + class __declspec(dllexport) ListGDN3Win : public listwin { public: diff --git a/jrj/project/business/SO/paymentterm.base.maint.so.cpp b/jrj/project/business/SO/paymentterm.base.maint.so.cpp new file mode 100644 index 0000000..523590b --- /dev/null +++ b/jrj/project/business/SO/paymentterm.base.maint.so.cpp @@ -0,0 +1,406 @@ +#include <wobject/xstring.hpp> +#include <xcontrol/xtreeview.hpp> +#include <xcontrol/xdwgrid.hpp> +#include <xcontrol/xcell.hpp> + + +#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" +#include "viewobject/view.base.hpp" + +using xml = KXMLDOMDocument; + + class __declspec(dllexport) PaymentTermEdit : public xframe + { + public: + xdwtable dw_1; + xdwtable dw_p; + + xcell dw_cell; + vcontrol vc; + + xstring sCryno; + + public: + PaymentTermEdit(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} + public: + static PaymentTermEdit* CreateInstance(void* implPtr, void* hWnd) + { + PaymentTermEdit* pWin = new PaymentTermEdit(implPtr, (HWND)hWnd); + return pWin; + } + + int OnAddrow() + { + dw_p = dw_1.FindDwTable(L"Item"); + int i; + double dDueAmount = 0; + double dPercnet = 100; + for (i = 1; i <= dw_p.GetRowCount(); i++) + { + dDueAmount = dw_p.GetItemDouble(i, L"DueAmount"); + if (dDueAmount > 0) + break; + dPercnet = dPercnet - dw_p.GetItemDouble(i, L"DuePercent"); + } + int irow = dw_p.InsertRow(0); + if (dDueAmount <= 0) + dw_p.SetItemDouble(irow, L"DuePercent", dPercnet); + + return 1; + } + + int OnDeleterow() + { + dw_p = dw_1.FindDwTable(L"Item"); + int row2 = dw_p.GetRow(); + if (row2 < 1) return 0; + dw_p.DeleteRow(row2); + + return 1; + } + + xstring OnCreateTxt() + { + //dw_1.AcceptText(); //涓嶈兘鍔犱細鎶ラ敊 + int irow; + //int icnt = dw_1.GetRowCount(); + dw_p = dw_1.FindDwTable(L"Item"); + int icnt = dw_p.GetRowCount(); + if (icnt < 1) return L""; + xstring sTxt = L""; + //double dPercnet = 100; + for (irow = 1; irow <= icnt; irow++) + { + xstring sPaymentMethod = dw_p.GetItemString(irow, L"PaymentMethod"); //鏀粯鏂瑰紡 + //xstring sDueDays = dw_p.GetItemDisplayString(irow,L"DueDays"); + xstring sDueDays = dw_p.GetItemString(irow, L"DueDays"); //鏈熼檺 + xstring sDuePercent = dw_p.GetItemString(irow, L"DuePercent"); //姣斾緥 + xstring sDueAmount = dw_p.GetItemString(irow, L"DueAmount"); //閲戦 + + if (!sPaymentMethod || sPaymentMethod == L"") + sTxt = sTxt + L""; + if (!sDueDays || sDueDays == L"") + sTxt = sTxt + L""; + else + { + if (sDueDays == L"-1") sDueDays = L" IN ADVANCE"; + else if (sDueDays == L"0") sDueDays = L" AT SIGHT"; + else + { + if (sPaymentMethod == L"T/T") + sDueDays = L" WITHIN " + sDueDays + L" DAYS AFTER SHIPMENT"; + else + sDueDays = L" AT " + sDueDays + L" DAYS"; + } + + if (!sDuePercent || sDuePercent == L"") + { + if (!sDueAmount || sDueAmount == L"") + sTxt = sTxt + L""; + else + { + + sTxt = sTxt + sCryno + L" " + sDueAmount + L" " + sPaymentMethod + sDueDays + L";"; + } + } + else + { + if (sDuePercent.find(L".", 0) >= 0) + { + while (sDuePercent.right(1) == L"0") + { + sDuePercent = sDuePercent.left(sDuePercent.length() - 1); + } + if (sDuePercent.right(1) == L".") + sDuePercent = sDuePercent.left(sDuePercent.length() - 1); + } + + sTxt = sTxt + sDuePercent + L"% " + sPaymentMethod + sDueDays + L";"; + } + } + } + + sTxt = sTxt.mid(0, sTxt.length() - 1); + if (sTxt != L"") + sTxt = sTxt + L"."; + return sTxt; + } + + int OnOk() + { + dw_1.AcceptText(); + //鍒ゆ柇鏄惁鏈夊繀杈撳�间负绌� + dw_p = dw_1.FindDwTable(L"Item"); + double dPercnet = 0; + double dAmount = 0; + xstring sChargeAll = L""; + if (dw_p) + { + int i; + for (i = 1; i <= dw_p.GetRowCount(); i++) + { + xstring sPaymentMethod = dw_p.GetItemString(i, L"PaymentMethod"); + xstring sDueDays = dw_p.GetItemString(i, L"DueDays"); + xstring sDuePercent = dw_p.GetItemString(i, L"DuePercent"); + dPercnet = dPercnet + sDuePercent.toDouble(); + xstring sDueAmount = dw_p.GetItemString(i, L"DueAmount"); + dAmount = dAmount + sDueAmount.toDouble(); + if (!sPaymentMethod) sPaymentMethod = L""; + if (!sDueDays) sDueDays = L""; + if (!sDuePercent) sDuePercent = L""; + if (!sDueAmount) sDueAmount = L""; + sChargeAll = sPaymentMethod + sDueDays + sDuePercent + sDueAmount; + if (sChargeAll != L"") + { + if (sPaymentMethod == L"") + { + alert(L"鏀粯鏂瑰紡涓嶈兘涓虹┖锛�"); + return 0; + } + if (sDueDays == L"") + { + alert(L"鏈熼檺涓嶈兘涓虹┖锛�"); + return 0; + } + + } + } + } + + //鐧惧垎姣旀牎楠� + if (dw_p.GetRowCount() <= 1 && sChargeAll == L"") + { + } + else + { + if (dPercnet != 100.00) + { + //alert(dPercnet.toString()); + if (dAmount <= 0.0) + { + alert(L"姣旂巼涓嶇瓑浜�100锛�"); + return 0; + } + } + } + + xstring sTxt = OnCreateTxt(); + dw_1.SetItemString(1, L"PaymentTermEx", sTxt); + + CloseWindow(); + + return 1; + } + + int OnItemChanged(TEvent* evt, LPARAM p) + { + DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; + xstring colname = hdr.colname; + xstring value = hdr.data; + int row = hdr.row; + + if (colname == L"DueDays") + { + xdwtable dw; + dw = dw_1.FindDwTable(L"Item"); + + if (dw) + { + xstring sPaymentMethod = dw.GetItemString(row, L"PaymentMethod"); + if (value == L"0") + { + if (sPaymentMethod == L"T/T") + { + //alert(L"姝ゆ敮浠樻柟寮忔湡闄愪笉鑳戒负 0 锛圓T SIGHT锛�"); + //return -1; + } + } + else if (value == L"-1") + { + if (sPaymentMethod != L"T/T") + { + alert(L"姝ゆ敮浠樻柟寮忔湡闄愪笉鑳戒负 -1锛圛N ADVANCE锛�"); + return -1; + } + } + } + + } + //鐢熸垚鏀粯鏉℃鏂囨湰 + if (colname == L"PaymentMethod" || colname == L"DueDays" || colname == L"DuePercent" || colname == L"DueAmount") + { + xstring sTxt = OnCreateTxt(); + //alert(sTxt); + dw_1.SetItemString(1, L"PaymentTermEx", sTxt); + } + + return 1; + } + + int OnClick(TEvent* evt, LPARAM p) + { + /* + ref DWNMHDR hdr = trust(evt.pnmh as ref DWNMHDR); + xstring value = hdr.data; + xstring colname = hdr.colname; + int row = hdr.row; + xaserverarg arg=new xaserverarg; + arg.setNativePointer(arg.CreateInstance()); + xdwtable dw; + dw = dw_1.FindDwTable(L"Item"); + if (dw) + { + if (colname == L"DuePercent") + { + int i; + int icnt = dw.GetRowCount(); + if (icnt < 1) + return 0; + double dDueAmount = 0; + for (i = 1 ; i <= icnt ; i++) + { + dDueAmount = dw.GetItemDouble(i,L"DueAmount"); + if (dDueAmount > 0) + break; + } + if (dDueAmount > 0) + { + xstring strold = dw_cell.GetCellProps(row,4); + if (strold.find(L"cellprotect=\"淇濇姢\"") > 0) + return 0; + strold = strold.replace(L"cellprotect=\"\"",L"cellprotect=\"淇濇姢\"",0); + dw_cell.SetCellProps(row,4,strold); + } + else + { + xstring strold1 = dw_cell.GetCellProps(row,4); + if (strold1.find(L"cellprotect=\"淇濇姢\"") > 0) + { + strold1 = strold1.replace(L"cellprotect=\"淇濇姢\"",L"cellprotect=\"\"",0); + dw_cell.SetCellProps(row,4,strold1); + } + } + + } + + if (colname == L"DueAmount") + { + int j; + int jcnt = dw.GetRowCount(); + if (jcnt < 1) + return 0; + double dDuePercent = 0; + for (j = 1 ; j <= jcnt ; j++) + { + dDuePercent = dw.GetItemDouble(j,L"DuePercent"); + if (dDuePercent > 0) + break; + } + if (dDuePercent > 0) + { + xstring strold2 = dw_cell.GetCellProps(row,5); + + if (strold2.find(L"cellprotect=\"淇濇姢\"") > 0) + return 0; + strold2 = strold2.replace(L"cellprotect=\"\"",L"cellprotect=\"淇濇姢\"",0); + dw_cell.SetCellProps(row,5,strold2); + } + else + { + xstring strold3 = dw_cell.GetCellProps(row,5); + if (strold3.find(L"cellprotect=\"淇濇姢\"") > 0) + { + strold3 = strold3.replace(L"cellprotect=\"淇濇姢\"",L"cellprotect=\"\"",0); + dw_cell.SetCellProps(row,5,strold3); + } + } + } + + } + */ + return 1; + } + + int OnCmdDispatch(xstring comdid) + { + + if (comdid == L"addrow") return OnAddrow(); + else if (comdid == L"deleterow") return OnDeleterow(); + else if (comdid == L"xmOk") return OnOk(); + + return 0; + } + + int OnXCommand(TEvent* evt, LPARAM p) + { + return OnCmdDispatch(evt->xcommand.pStrID); + } + + int OnAttachEvent() + { + AttachEvent(L"WM_XCOMMAND", (FEvent)&PaymentTermEdit::OnXCommand); + AttachEvent(L"dw_1", L"DWV_ITEMCHANGED", (FEvent)&PaymentTermEdit::OnItemChanged); + AttachEvent(L"dw_1", L"DWV_CLICKED", (FEvent)&PaymentTermEdit::OnClick); + + return 1; + } + + int OnInit() + { + xaserver Args = GetArg(); + + XXmlContentSvr xdoc = new XXmlContentSvr; + xdoc.setNativePointer(Args); + vc = new vcontrol; + vc.xdoc = xdoc; + + vbind bind = new vbind; + bind.bind(dw_1, vc); + + xml x; + + x.loadXML(vc.GetContent()); + + //alert(x.GetXml()); + + dw_1.Retrieve(x); + + //if (x.GetXmlDoc().documentElement.selectSingleNode(L"CurrencyCode")) + //{ + // sCryno = x.GetXmlDoc().documentElement.selectSingleNode(L"CurrencyCode").text; + //} + + return 1; + } + + int onload() + { + dw_1 = GetControl(L"dw_1"); + dw_1.openUrl(L"/sale/view/SaleOrder/template/payment"); //base.maint.so.tpl/payment + + /* + xml x = new xml; + x.setNativePointer(xml::CreateInstance()); + if(url::get(L"/sale/view/SaleOrder/template/SaleOrder/payment1",L"",x)!=1) //SO.updata.oldserver.pr.xq + { + xstring error = x.GetXmlDoc().text; + trace(error); + return 0; + } + + alert(L"1:"+x.GetXml());*/ + + dw_1.SetColHeaderHeight(0); + dw_1.SetRowSelectorWidth(0); + dw_1.SetScrollState(false); + + dw_cell = new xcell; + dw_cell.setNativePointer(dw_1.QueryItem(L"ixcell")); + + OnAttachEvent(); + + if (GetParam())OnInit(); + + return 1; + } + }; -- Gitblit v1.9.3