| | |
| | | use "xcontrol.vframe.vbusiness.vd" |
| | | use "xbase.vframe.vbusiness.vd" |
| | | #include <wobject/xstring.hpp> |
| | | #include <xcontrol/xtreeview.hpp> |
| | | #include <xcontrol/xdwgrid.hpp> |
| | | #include <wobject/xdouble.hpp> |
| | | #include <xcontrol/xlayersheet.hpp> |
| | | #include <xcontrol/xdatetimepick.hpp> |
| | | |
| | | unit trade |
| | | [ |
| | | class levelCustomerv3 : public listwin |
| | | |
| | | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" |
| | | #include "viewobject/view.base.hpp" |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | class __declspec(dllexport) levelCustomerv3 : public listwin |
| | | { |
| | | public: |
| | | xdwgrid dw_goods; |
| | | xtreeview tv_1; |
| | | xcombobox ddlb_1; |
| | | int changeddlb; |
| | | |
| | | string m_sType; //type |
| | | string m_sTypeTxt; //选中树的data |
| | | // string m_searchtxt; |
| | | xstring m_sType; //type |
| | | xstring m_sTypeTxt; //选中树的data |
| | | // xstring m_searchtxt; |
| | | int PIndex; |
| | | xnode m_agentNode; //Agent Condition |
| | | string m_agentCond; //Agent Node |
| | | xstring m_agentCond; //Agent Node |
| | | |
| | | |
| | | public: |
| | | levelCustomerv3(void* implPtr, HWND hWnd) :listwin(implPtr, hWnd) {} |
| | | public: |
| | | static levelCustomerv3* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | levelCustomerv3* pWin = new levelCustomerv3(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | int OnPreRetrieve() |
| | | { |
| | | xml x = new xml; |
| | | x.setNativePointer(xml ::CreateInstance()); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("pageindex", PIndex.toString()); //第几页 |
| | | arg.AddArg("pagenumber", m_pageNumber.toString()); //每页数量 |
| | | arg.AddArg("QueryTxt",m_QueryTxt ); |
| | | arg.AddArg("sType", m_sType);//没有参数 |
| | | arg.AddArg("sTypeTxt", m_sTypeTxt);//没有参数 |
| | | xml x; |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"pageindex", xstring(PIndex)); //第几页 |
| | | arg.AddArg(L"pagenumber", xstring(m_pageNumber)); //每页数量 |
| | | arg.AddArg(L"QueryTxt",m_QueryTxt ); |
| | | arg.AddArg(L"sType", m_sType);//没有参数 |
| | | arg.AddArg(L"sTypeTxt", m_sTypeTxt);//没有参数 |
| | | |
| | | if(getUrl("/sale/data/"+GetEntityName(1)+"/entity/list",arg.GetString(),x)!=1) |
| | | if(getUrl(L"/sale/data/"+GetEntityName(1)+L"/entity/list",arg.GetString(),x)!=1) |
| | | { |
| | | alert("出现错误请联系管理员!"); |
| | | alert(L"出现错误请联系管理员!"); |
| | | return 0; |
| | | }else |
| | | { |
| | | msxml::IXMLDOMElement e=x.GetXmlDoc().documentElement; |
| | | if(listwin::dw_pages.ptr_native_ && e.selectSingleNode("@TotalPage")) |
| | | KXMLDOMElement e=x.documentElement(); |
| | | if(listwin::dw_pages && e.selectSingleNode(L"@TotalPage")) |
| | | { |
| | | string s=e.selectSingleNode("@TotalPage").text; //总数量 |
| | | xstring s=e.selectSingleNode(L"@TotalPage").text(); //总数量 |
| | | listwin::dw_pages.SetMaxPage(s.toInt()); |
| | | } |
| | | listwin::dw_list.Retrieve(x); |
| | |
| | | return 1; |
| | | } |
| | | |
| | | int OnChangePages(ref TNotifyEvent evt,int p) |
| | | int OnChangePages(TEvent* evt, int p) |
| | | { |
| | | ref PAGENMHDR h = evt.pnmh; |
| | | PAGENMHDR& h = *(PAGENMHDR*)evt->notify.pnmh; |
| | | |
| | | int c = h.cur; |
| | | int hCursor = xutil::SetCursorWait(); |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | OnRetrieve(); |
| | | PIndex=c; |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | int ViewUpdate(int pr,string updateItem,xaserverarg arg) |
| | | int ViewUpdate(LPARAM pr,xstring updateItem,xaserverarg arg) |
| | | { |
| | | if(updateItem == "refresh") |
| | | if(updateItem == L"refresh") |
| | | { |
| | | xdwpages zz = this.GetControl("pages"); |
| | | xdwpages zz = GetControl(L"pages"); |
| | | int h = zz.SetCurPage(1); |
| | | OnRetrieve(); |
| | | } |
| | |
| | | } |
| | | |
| | | //树选择 |
| | | int OnTreeSelChanged(ref TNotifyEvent evt,int p) |
| | | int OnTreeSelChanged(TEvent* evt, int p) |
| | | { |
| | | if (changeddlb != 1) |
| | | { |
| | | int wid = tv_1.GetId(); |
| | | int h=xtreeview::GetSelectedItem(wid); |
| | | msxml::IXMLDOMElement e = xtreeview::GetItemData(wid,h); |
| | | |
| | | string t = e.SelectSingleNode("@type").text; |
| | | m_sType=t+""; |
| | | string txt = e.SelectSingleNode("@code").text; |
| | | if (txt == "") |
| | | txt = e.SelectSingleNode("@name").text; |
| | | m_sTypeTxt= txt+""; |
| | | HTREEITEM h=tv_1.GetSelectedItem(); |
| | | KXMLDOMElement e = tv_1.GetItemData(h); |
| | | |
| | | xstring t = e.selectSingleNode(L"@type").text(); |
| | | m_sType=t+L""; |
| | | xstring txt = e.selectSingleNode(L"@code").text(); |
| | | if (txt == L"") |
| | | txt = e.selectSingleNode(L"@name").text(); |
| | | m_sTypeTxt= txt+L""; |
| | | |
| | | PIndex= 1; |
| | | OnRetrieve(); |
| | |
| | | return 1; |
| | | } |
| | | |
| | | int createSubTree(int wid,int h, msxml::IXMLDOMElement ele) |
| | | int createSubTree(HTREEITEM h, KXMLDOMElement ele) |
| | | { |
| | | msxml::IXMLDOMNodeList nlist=ele.SelectNodes("item"); |
| | | KXMLDOMNodeList nlist=ele.selectNodes(L"item"); |
| | | int i; |
| | | int s=nlist.length; |
| | | int s=nlist.length(); |
| | | if (s>0) |
| | | for (i=0; i<s; i++) |
| | | { |
| | | msxml::IXMLDOMElement e=nlist.item(i); |
| | | string name=e.SelectSingleNode("@name").text; |
| | | int hw=xtreeview::InsertChildItem(wid,h,name,trust(e as int),15); |
| | | createSubTree(wid,hw, e); |
| | | KXMLDOMElement e =nlist.item(i); |
| | | xstring name = e.selectSingleNode(L"@name").text(); |
| | | HTREEITEM hw = tv_1.InsertChildItem(h, name, e, 15); |
| | | createSubTree(hw, e); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnCreateTree(string sType) |
| | | |
| | | int OnCreateTree(xstring sType) |
| | | { |
| | | int wid = tv_1.GetId(); |
| | | while (xtreeview::GetRootItem(wid)>0) |
| | | xtreeview::DeleteItem(wid,xtreeview::GetRootItem(wid)); |
| | | |
| | | xml x = new xml; |
| | | x.setNativePointer(x.CreateInstance()); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("sType",sType); |
| | | if(getUrl("/sale/data/"+GetEntityName(1)+"/pref/list/tree",arg.GetString(),x)!=1) |
| | | while (tv_1.GetRootItem()) |
| | | tv_1.DeleteItem(tv_1.GetRootItem()); |
| | | |
| | | xml x; |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"sType",sType); |
| | | if(getUrl(L"/sale/data/"+GetEntityName(1)+L"/pref/list/tree",arg.GetString(),x)!=1) |
| | | { |
| | | trace(x.GetXmlDoc().text); |
| | | trace(x.text()); |
| | | return -1; |
| | | }else |
| | | { |
| | | msxml::IXMLDOMNodeList nlist=x.GetXmlDoc().SelectNodes("root/item"); |
| | | int len = nlist.length; |
| | | KXMLDOMNodeList nlist=x.selectNodes(L"root/item"); |
| | | int len = nlist.length(); |
| | | if (len >0) |
| | | { |
| | | int i; |
| | | for (i=0;i <len; i++) |
| | | { |
| | | msxml::IXMLDOMElement e = nlist.item(i); |
| | | string name = e.SelectSingleNode("@name").text; |
| | | int h = xtreeview::InsertChildItem(wid,0,name,trust(e as int),15); |
| | | createSubTree(wid,h,e); |
| | | xtreeview::ExpandItem(wid,h); |
| | | KXMLDOMElement e = nlist.item(i); |
| | | xstring name = e.selectSingleNode(L"@name").text(); |
| | | HTREEITEM hw = tv_1.InsertChildItem(0, name, e, 15); |
| | | |
| | | createSubTree(hw, e); |
| | | tv_1.ExpandItem(hw); |
| | | } |
| | | xtreeview::ExpandItem(wid,0); |
| | | tv_1.ExpandItem(0); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //xcombobox下拉 |
| | | int OnSelectDdlb(ref TNotifyEvent evt,int p) |
| | | int OnSelectDdlb(TEvent* evt, int p) |
| | | { |
| | | changeddlb=1; |
| | | int wid = ddlb_1.GetId(); |
| | | int CB_GETCURSEL = 0x0147; |
| | | int nIndex = win32::SendMessage(wid,CB_GETCURSEL,0,0); |
| | | msxml::IXMLDOMElement e = ddlb_1.GetElement(); |
| | | msxml::IXMLDOMElement e2 = e.selectSingleNode("item["+(nIndex+1).toString()+"]"); |
| | | string text=e2.selectSingleNode("@element").text; |
| | | changeddlb = 1; |
| | | |
| | | int CB_GETCURSEL = 0x0147; |
| | | int nIndex = SendMessageW(ddlb_1.GetHWND(), CB_GETCURSEL, 0, 0); |
| | | KXMLDOMElement e = ddlb_1.GetElement();//GetitemData(wid,nIndex);//ddlb_1.GetElement(); |
| | | KXMLDOMElement e2 = e.selectSingleNode(L"item[" + xstring((nIndex + 1)) + L"]"); |
| | | xstring text = e2.selectSingleNode(L"@element").text(); |
| | | OnCreateTree(text); |
| | | changeddlb=0; |
| | | changeddlb = 0; |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | msxml::IXMLDOMElement e = listwin::dw_list.GetRowElement(row); |
| | | string sguid = e.SelectSingleNode("@guid").text; |
| | | string sName = e.selectSingleNode("Name").text+""; |
| | | KXMLDOMElement e = listwin::dw_list.GetRowElement(row); |
| | | xstring sguid = e.selectSingleNode(L"@guid").text(); |
| | | xstring sName = e.selectSingleNode(L"Name").text()+(xstring)L""; |
| | | int MB_YESNO = 0x00000004; |
| | | int IDYES = 6; |
| | | if(win32::MessageBox(GetHWND(),"确认要删除客户 "+sName+" 的信息吗?","提示",MB_YESNO)!=IDYES) return 1; |
| | | xml x = new xml; |
| | | x.setNativePointer(x.CreateInstance()); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("guid",sguid); |
| | | if (url::post("/sale/data/"+GetEntityName(1)+"/entity/delete",arg.GetString(),x) != 1) |
| | | if(MessageBox(GetHWND(),L"确认要删除客户 "+sName+L" 的信息吗?",L"提示",MB_YESNO)!=IDYES) return 1; |
| | | xml x; |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"guid",sguid); |
| | | if (xurl::post(L"/sale/data/"+GetEntityName(1)+L"/entity/delete",arg.GetString(),x) != 1) |
| | | { |
| | | string error = x.GetXmlDoc().text; |
| | | xstring error = x.text(); |
| | | trace(error); |
| | | } |
| | | else |
| | |
| | | return 1; |
| | | } |
| | | |
| | | int OnRClick(ref TNotifyEvent evt,int p) |
| | | int OnRClick(TEvent* evt, int p) |
| | | { |
| | | return 1; |
| | | } |
| | |
| | | //设置层级弹出窗与保存 |
| | | int OnLevelCustomer() |
| | | { |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | OpenWindow("dev:xpage[maint.Level.Customer3.vx]", cast(arg as int)); |
| | | xaserverarg arg; |
| | | |
| | | xml ux = new xml; |
| | | ux.setNativePointer(ux.CreateInstance()); |
| | | ux.LoadXml("<Partys/>"); |
| | | msxml::IXMLDOMElement ele = ux.GetXmlDoc().documentElement; |
| | | OpenWindow(L"dev:xpage[maint.Level.Customer3.vx]", arg); |
| | | |
| | | xml ux ; |
| | | |
| | | ux.loadXML(L"<Partys/>"); |
| | | KXMLDOMElement ele = ux.documentElement(); |
| | | |
| | | if(arg.GetArgString("ok")=="true") |
| | | if(arg.GetArgString(L"ok")==L"true") |
| | | { |
| | | xml x = new xml; |
| | | x.setNativePointer(x.CreateInstance()); |
| | | x.LoadXml(arg.GetArgString("arg")); |
| | | msxml::IXMLDOMElement uele = x.GetXmlDoc().documentElement; |
| | | string ParentPartyID = uele.selectSingleNode("//ParentPartyID").text; |
| | | string ParentPartyName = ""; |
| | | string GroupPartyID = uele.selectSingleNode("//GroupPartyID").text; |
| | | string GroupPartyName = ""; |
| | | xml x; |
| | | |
| | | if( uele.selectSingleNode("//ParentPartyID/@_displaystring")) |
| | | ParentPartyName = uele.selectSingleNode("//ParentPartyID/@_displaystring").text; |
| | | if(uele.selectSingleNode("//GroupPartyID/@_displaystring")) |
| | | GroupPartyName = uele.selectSingleNode("//GroupPartyID/@_displaystring").text; |
| | | x.loadXML(arg.GetArgString(L"arg")); |
| | | KXMLDOMElement uele = x.documentElement(); |
| | | xstring ParentPartyID = uele.selectSingleNode(L"//ParentPartyID").text(); |
| | | xstring ParentPartyName = L""; |
| | | xstring GroupPartyID = uele.selectSingleNode(L"//GroupPartyID").text(); |
| | | xstring GroupPartyName = L""; |
| | | |
| | | if( uele.selectSingleNode(L"//ParentPartyID/@_displaystring")) |
| | | ParentPartyName = uele.selectSingleNode(L"//ParentPartyID/@_displaystring").text(); |
| | | if(uele.selectSingleNode(L"//GroupPartyID/@_displaystring")) |
| | | GroupPartyName = uele.selectSingleNode(L"//GroupPartyID/@_displaystring").text(); |
| | | |
| | | int row = dw_list.GetNextSelectRow(1); |
| | | while(row > 0) |
| | | { |
| | | dw_list.SetItemString(row,"ParentPartyID",ParentPartyID); |
| | | dw_list.SetItemDisplayString(row,"ParentPartyID",ParentPartyName); |
| | | dw_list.SetItemString(row,"GroupPartyID",GroupPartyID); |
| | | dw_list.SetItemDisplayString(row,"GroupPartyID",GroupPartyName); |
| | | dw_list.SetItemString(row,L"ParentPartyID",ParentPartyID); |
| | | dw_list.SetItemDisplayString(row,L"ParentPartyID",ParentPartyName); |
| | | dw_list.SetItemString(row,L"GroupPartyID",GroupPartyID); |
| | | dw_list.SetItemDisplayString(row,L"GroupPartyID",GroupPartyName); |
| | | ele.appendChild(dw_list.GetRowElement(row).cloneNode(-1)); |
| | | row = dw_list.GetNextSelectRow(row + 1); |
| | | } |
| | | dw_list.RedrawEx(); |
| | | arg.AddArg("content",ele.xml); |
| | | if (getUrl("/sale/data/CustomerV3/level/update",arg.GetString(),x)!=1) |
| | | dw_list.Redraw(); |
| | | arg.AddArg(L"content",ele.xml()); |
| | | if (getUrl(L"/sale/data/CustomerV3/level/update",arg.GetString(),x)!=1) |
| | | { |
| | | trace(x.GetXmlDoc().text); |
| | | alert("设置错误!"); |
| | | trace(x.text()); |
| | | alert(L"设置错误!"); |
| | | return -1; |
| | | }else |
| | | { |
| | | alert("设置成功!"); |
| | | alert(L"设置成功!"); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int PreOnCmdDispatch(string comdid) |
| | | int PreOnCmdDispatch(xstring comdid) |
| | | { |
| | | if(comdid.find("action:LogOff",0)>=0) return OnLogOff(); |
| | | if(comdid.find("action:bill.delete",0)>=0) return OnDeleteRow(); |
| | | //if(comdid=="action:search1") return GridSearch(); |
| | | if(comdid=="action:bill.refresh") |
| | | if(comdid.find(L"action:LogOff",0)>=0) return OnLogOff(); |
| | | if(comdid.find(L"action:bill.delete",0)>=0) return OnDeleteRow(); |
| | | //if(comdid==L"action:search1") return GridSearch(); |
| | | if(comdid==L"action:bill.refresh") |
| | | { |
| | | return OnRetrieve(); |
| | | } |
| | | if(comdid=="action:level.customer") |
| | | if(comdid==L"action:level.customer" || comdid == L"Xmlevel") |
| | | { |
| | | return OnLevelCustomer(); |
| | | } |
| | |
| | | return 1; |
| | | } |
| | | |
| | | int OnRowChangedEx(ref TNotifyEvent evt,int p) |
| | | int OnRowChangedEx(TEvent* evt, int p) |
| | | { |
| | | alert("999"); |
| | | ref DWNMHDR hdr =cast(evt.pnmh as ref DWNMHDR); |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | msxml::IXMLDOMElement ele = listwin::dw_list.GetRowElement(row); |
| | | string entity = ele.selectSingleNode("CustomerID").text; |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("EntityID",entity); |
| | | if (getUrl("/sale/data/CustomerV3/entity/customeritem",arg.GetString(),x)!=1) |
| | | KXMLDOMElement ele = listwin::dw_list.GetRowElement(row); |
| | | xstring entity = ele.selectSingleNode(L"CustomerID").text(); |
| | | xml x; |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"EntityID",entity); |
| | | if (getUrl(L"/sale/data/CustomerV3/entity/customeritem",arg.GetString(),x)!=1) |
| | | { |
| | | trace(x.GetXmlDoc().text); |
| | | trace(x.text()); |
| | | return -1; |
| | | }else |
| | | { |
| | |
| | | int PostOnAttachEvent() |
| | | { |
| | | //获得树的选择事件 |
| | | AttachEvent("tv_1", "TVN_SELCHANGED",OnTreeSelChanged); |
| | | AttachEvent("cbx_1","CBN_SELCHANGE",OnSelectDdlb); |
| | | AttachEvent("pages","PAGE_CLICK",OnChangePages); |
| | | AttachEvent("dw_list","DWV_RCLICKED",OnRClick);//鼠标右键 |
| | | //AttachEvent("dw_list","DWV_CLICKED",OnClick);//鼠标右键 |
| | | AttachEvent("dw_list","DWV_ROWFOCUSCHANGED",OnRowChangedEx); |
| | | AttachEvent(L"tv_1", L"TVN_SELCHANGED", (FEvent)&levelCustomerv3::OnTreeSelChanged); |
| | | AttachEvent(L"cbx_1",L"CBN_SELCHANGE", (FEvent)&levelCustomerv3::OnSelectDdlb); |
| | | AttachEvent(L"pages",L"PAGE_CLICK", (FEvent)&levelCustomerv3::OnChangePages); |
| | | AttachEvent(L"dw_list",L"DWV_RCLICKED", (FEvent)&levelCustomerv3::OnRClick);//鼠标右键 |
| | | //AttachEvent(L"dw_list",L"DWV_CLICKED",OnClick);//鼠标右键 |
| | | AttachEvent(L"dw_list",L"DWV_ROWFOCUSCHANGED", (FEvent)&levelCustomerv3::OnRowChangedEx); |
| | | |
| | | return 1; |
| | | } |
| | |
| | | int onload() |
| | | { |
| | | PIndex=1; |
| | | listwin::m_QueryTxt =""; //查询条件 |
| | | m_sType=""; //type |
| | | m_sTypeTxt=""; //选中树的data |
| | | listwin::m_QueryTxt =L""; //查询条件 |
| | | m_sType=L""; //type |
| | | m_sTypeTxt=L""; //选中树的data |
| | | |
| | | listwin::onload(); |
| | | |
| | | tv_1 = this.GetControl("tv_1"); |
| | | ddlb_1 = this.GetControl("cbx_1"); |
| | | tv_1 = GetControl(L"tv_1"); |
| | | ddlb_1 = GetControl(L"cbx_1"); |
| | | |
| | | changeddlb = 0; |
| | | OnCreateTree("Source"); |
| | | dw_goods = GetControl("dw_goods"); |
| | | dw_goods.openUrl("/sale/view/CustomerV3/template/customer/customeritem"); |
| | | OnCreateTree(L"Source"); |
| | | dw_goods = GetControl(L"dw_goods"); |
| | | dw_goods.openUrl(L"/sale/view/CustomerV3/template/customer/customeritem"); |
| | | |
| | | return 1; |
| | | } |
| | |
| | | { |
| | | listwin::onloaded(); |
| | | |
| | | string EntityID; |
| | | xstring EntityID; |
| | | int row = dw_list.GetRow(); |
| | | if(row<0 || row>dw_list.GetRowCount()) return ""; |
| | | msxml::IXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | string id = listwin::m_configDoc.selectSingleNode("//entity/EntityID[1]").text; |
| | | if(row<0 || row>dw_list.GetRowCount()) return (xstring)L""; |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | xstring id = listwin::m_configDoc.selectSingleNode(L"//entity/EntityID[1]").text(); |
| | | if(ele.selectSingleNode(id)) |
| | | EntityID = ele.selectSingleNode(id).text; |
| | | EntityID = ele.selectSingleNode(id).text(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | }; |
| | | ] |
| | | }; |