¶Ô±ÈÐÂÎļþ |
| | |
| | | #include <wobject/xstring.hpp> |
| | | #include <xcontrol/xtreeview.hpp> |
| | | #include <xcontrol/xdwgrid.hpp> |
| | | #include <wobject/xdouble.hpp> |
| | | #include <xcontrol/xlayersheet.hpp> |
| | | #include <xcontrol/xdatetimepick.hpp> |
| | | |
| | | |
| | | #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; |
| | | |
| | | xstring m_sType; //type |
| | | xstring m_sTypeTxt; //é䏿 çdata |
| | | // xstring m_searchtxt; |
| | | int PIndex; |
| | | xnode m_agentNode; //Agent Condition |
| | | 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 ; |
| | | |
| | | 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(L"/sale/data/"+GetEntityName(1)+L"/entity/list",arg.GetString(),x)!=1) |
| | | { |
| | | alert(L"åºç°é误请è系管çåï¼"); |
| | | return 0; |
| | | }else |
| | | { |
| | | KXMLDOMElement e=x.documentElement(); |
| | | if(listwin::dw_pages.ptr_native_ && e.selectSingleNode(L"@TotalPage")) |
| | | { |
| | | xstring s=e.selectSingleNode(L"@TotalPage").text(); //æ»æ°é |
| | | listwin::dw_pages.SetMaxPage(s.toInt()); |
| | | } |
| | | listwin::dw_list.Retrieve(x); |
| | | listwin::dw_list.Redraw(); |
| | | listwin::dw_list.SetReadOnly(true); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnChangePages(TEvent* evt, int p) |
| | | { |
| | | PAGENMHDR& h = *(PAGENMHDR*)evt->notify.pnmh; |
| | | |
| | | int c = h.cur; |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | OnRetrieve(); |
| | | PIndex=c; |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | int ViewUpdate(int pr,xstring updateItem,xaserverarg arg) |
| | | { |
| | | if(updateItem == L"refresh") |
| | | { |
| | | xdwpages zz = GetControl(L"pages"); |
| | | int h = zz.SetCurPage(1); |
| | | OnRetrieve(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //æ éæ© |
| | | int OnTreeSelChanged(TEvent* evt, int p) |
| | | { |
| | | if (changeddlb != 1) |
| | | { |
| | | |
| | | 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(HTREEITEM h, KXMLDOMElement ele) |
| | | { |
| | | KXMLDOMNodeList nlist=ele.selectNodes(L"item"); |
| | | int i; |
| | | int s=nlist.length(); |
| | | if (s>0) |
| | | for (i=0; i<s; i++) |
| | | { |
| | | KXMLDOMElement* e = new KXMLDOMElement(nlist.item(i)); |
| | | xstring name = e->selectSingleNode(L"@name").text(); |
| | | HTREEITEM hw = tv_1.InsertChildItem(h, name, (LPARAM)e, 15); |
| | | createSubTree(hw, *e); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | int OnCreateTree(xstring sType) |
| | | { |
| | | |
| | | while (tv_1.GetRootItem()>0) |
| | | 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.text()); |
| | | return -1; |
| | | }else |
| | | { |
| | | KXMLDOMNodeList nlist=x.selectNodes(L"root/item"); |
| | | int len = nlist.length(); |
| | | if (len >0) |
| | | { |
| | | int i; |
| | | for (i=0;i <len; i++) |
| | | { |
| | | KXMLDOMElement* e = new KXMLDOMElement(nlist.item(i)); |
| | | xstring name = e->selectSingleNode(L"@name").text(); |
| | | HTREEITEM hw = tv_1.InsertChildItem(0, name, (LPARAM)e, 15); |
| | | |
| | | createSubTree(hw, *e); |
| | | tv_1.ExpandItem(hw); |
| | | } |
| | | tv_1.ExpandItem(0); |
| | | } |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | //xcombobox䏿 |
| | | int OnSelectDdlb(TEvent* evt, int p) |
| | | { |
| | | 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; |
| | | return 1; |
| | | } |
| | | |
| | | int OnDeleteRow() |
| | | { |
| | | int row = listwin::dw_list.GetNextSelectRow(1); |
| | | if (row < 1){ |
| | | row = listwin::dw_list.GetRow(); |
| | | if (row < 1) { |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | 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(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) |
| | | { |
| | | xstring error = x.text(); |
| | | trace(error); |
| | | } |
| | | else |
| | | { |
| | | listwin::dw_list.DeleteRow(row); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnSelectAllRow() |
| | | { |
| | | int rows = listwin::dw_list.GetRowCount(); |
| | | if(rows < 1) return -1; |
| | | listwin::dw_list.SelectRow(1, rows, true); |
| | | listwin::dw_list.Redraw(); |
| | | return 1; |
| | | } |
| | | |
| | | int OnRClick(TEvent* evt, int p) |
| | | { |
| | | return 1; |
| | | } |
| | | int OnLogOff() |
| | | { |
| | | return 1; |
| | | } |
| | | //设置å±çº§å¼¹åºçªä¸ä¿å |
| | | int OnLevelCustomer() |
| | | { |
| | | xaserverarg arg ; |
| | | ; |
| | | OpenWindow(L"dev:xpage[maint.Level.Customer3.vx]", arg); |
| | | |
| | | xml ux ; |
| | | |
| | | ux.loadXML(L"<Partys/>"); |
| | | KXMLDOMElement ele = ux.documentElement(); |
| | | |
| | | if(arg.GetArgString(L"ok")==L"true") |
| | | { |
| | | xml x ; |
| | | |
| | | 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,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.Redraw(); |
| | | arg.AddArg(L"content",ele.xml()); |
| | | if (getUrl(L"/sale/data/CustomerV3/level/update",arg.GetString(),x)!=1) |
| | | { |
| | | trace(x.text()); |
| | | alert(L"设置é误!"); |
| | | return -1; |
| | | }else |
| | | { |
| | | alert(L"设置æå!"); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int PreOnCmdDispatch(xstring comdid) |
| | | { |
| | | 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==L"action:level.customer") |
| | | { |
| | | return OnLevelCustomer(); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnRowChangedEx(TEvent* evt, int p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | 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.text()); |
| | | return -1; |
| | | }else |
| | | { |
| | | dw_goods.Retrieve(x); |
| | | dw_goods.Redraw(); |
| | | dw_goods.SetReadOnly(true); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | int PostOnAttachEvent() |
| | | { |
| | | //è·å¾æ çéæ©äºä»¶ |
| | | 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 =L""; //æ¥è¯¢æ¡ä»¶ |
| | | m_sType=L""; //type |
| | | m_sTypeTxt=L""; //é䏿 çdata |
| | | |
| | | listwin::onload(); |
| | | |
| | | tv_1 = GetControl(L"tv_1"); |
| | | ddlb_1 = GetControl(L"cbx_1"); |
| | | |
| | | changeddlb = 0; |
| | | OnCreateTree(L"Source"); |
| | | dw_goods = GetControl(L"dw_goods"); |
| | | dw_goods.openUrl(L"/sale/view/CustomerV3/template/customer/customeritem"); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | listwin::onloaded(); |
| | | |
| | | xstring EntityID; |
| | | int row = dw_list.GetRow(); |
| | | 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(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | }; |