|  |  | 
 |  |  | use "xcontrol.vframe.vbusiness.vd" | 
 |  |  | use "xbase.vframe.vbusiness.vd" | 
 |  |  | use "base.view.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 xmQuoteBillList :  public xframe | 
 |  |  |  | 
 |  |  | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" | 
 |  |  | #include "viewobject/view.base.hpp" | 
 |  |  |  | 
 |  |  | using xml = KXMLDOMDocument; | 
 |  |  |    class __declspec(dllexport) xmQuoteBillList :  public xframe | 
 |  |  |    { | 
 |  |  |    public: | 
 |  |  |       xdwgrid   dw_list; | 
 |  |  |  | 
 |  |  |       xnode   m_agentNode;   //Agent Condition | 
 |  |  |       int hObject = 0; | 
 |  |  |     | 
 |  |  |       string QuoteNo; | 
 |  |  |       string printStr; | 
 |  |  | 	 | 
 |  |  |       xstring QuoteNo; | 
 |  |  |       xstring printStr; | 
 |  |  |    public: | 
 |  |  |       xmQuoteBillList(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} | 
 |  |  |    public: | 
 |  |  |       static xmQuoteBillList* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |       { | 
 |  |  |          xmQuoteBillList* pWin = new xmQuoteBillList(implPtr, (HWND)hWnd); | 
 |  |  |          return pWin; | 
 |  |  |       } | 
 |  |  |       int SetAgent() | 
 |  |  |       { | 
 |  |  |          string xfNodeAgentArea  = "agentarea"; | 
 |  |  |          xstring xfNodeAgentArea  = L"agentarea"; | 
 |  |  |          xnode anode = GetAgentNode(xfNodeAgentArea); | 
 |  |  |          if(m_agentNode) | 
 |  |  |          { | 
 |  |  |             SetAgentNodeContent (anode,m_agentNode); | 
 |  |  |             SetAgentNode (anode,m_agentNode); | 
 |  |  |          } | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             msxml::IXMLDOMElement xframeElement =  GetElement(); | 
 |  |  |             msxml::IXMLDOMElement agent = xframeElement.selectSingleNode("agent/"+xfNodeAgentArea+"[1]/*"); | 
 |  |  |             KXMLDOMElement xframeElement =  GetElement(); | 
 |  |  |             KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*"); | 
 |  |  |             if(agent) | 
 |  |  |             { | 
 |  |  |                string s = agent.xml; | 
 |  |  |                m_agentNode =  SetAgentNodeContent (anode,s); | 
 |  |  |                xstring s = agent.xml(); | 
 |  |  |                m_agentNode =  SetAgentNode (anode,s); | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |     | 
 |  |  |       int OnRowChanged(ref TNotifyEvent evt,int p) | 
 |  |  |       int OnRowChanged(TEvent* evt, int p) | 
 |  |  |       { | 
 |  |  |          ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR); | 
 |  |  |          DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |          int row = hdr.row; | 
 |  |  |          SetAgent(); | 
 |  |  |          return 1; | 
 |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |       //焦点激活处理函数 | 
 |  |  |       int OnSetFocus(ref TEvent evt,int param) | 
 |  |  |       int OnSetFocus(TEvent* evt, LPARAM param) | 
 |  |  |       { | 
 |  |  |          //重置工具条 | 
 |  |  |          SetAgent(); | 
 |  |  | 
 |  |  |        | 
 |  |  |           | 
 |  |  |       //命令发布函数 | 
 |  |  |       int OnCmdDispatch(string comdid) | 
 |  |  |       int OnCmdDispatch(xstring comdid) | 
 |  |  |       { | 
 |  |  |          if(comdid=="xmImport") | 
 |  |  |          if(comdid==L"xmImport") | 
 |  |  |          { | 
 |  |  |             if(GetParam()) | 
 |  |  |             if(GetWinParam()) | 
 |  |  |             { | 
 |  |  |                xaserverarg arg = GetParam(); | 
 |  |  |                arg.AddArg("items",printStr); | 
 |  |  |                xaserverarg arg = GetArg(); | 
 |  |  |                arg.AddArg(L"items",printStr); | 
 |  |  |                 | 
 |  |  |                arg.AddArg("action","ok"); | 
 |  |  |                arg.AddArg(L"action",L"ok"); | 
 |  |  |             } | 
 |  |  |             CloseWindow(); | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          if(comdid=="xmClose") | 
 |  |  |          if(comdid==L"xmClose") | 
 |  |  |          { | 
 |  |  |              | 
 |  |  |             CloseWindow(); | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          if(comdid=="xmSearch") | 
 |  |  |          if(comdid==L"xmSearch") | 
 |  |  |          { | 
 |  |  |              | 
 |  |  |             OnRetrieve(QuoteNo); | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          if(comdid=="xmSelectAll") return SelectAll(); | 
 |  |  |          if(comdid=="xmUnSelectAll") return UnSelectAll(); | 
 |  |  |          if(comdid==L"xmSelectAll") return SelectAll(); | 
 |  |  |          if(comdid==L"xmUnSelectAll") return UnSelectAll(); | 
 |  |  |           | 
 |  |  |          return 0; | 
 |  |  |       } | 
 |  |  |        | 
 |  |  |       int OnDwClicked(ref TNotifyEvent evt,int p) | 
 |  |  |       int OnDwClicked(TEvent* evt, int p) | 
 |  |  |       { | 
 |  |  |          ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR); | 
 |  |  |          DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |          char ch; | 
 |  |  |          int row = hdr.row; | 
 |  |  |          string col = hdr.colname; | 
 |  |  |          xstring col = hdr.colname; | 
 |  |  |           | 
 |  |  |          string str = ""; | 
 |  |  |          if(dw_list.GetGuid(row) !="") | 
 |  |  |          xstring str = L""; | 
 |  |  |          if(dw_list.GetGuid(row) !=L"") | 
 |  |  |          { | 
 |  |  |             str = dw_list.GetItemString(row,"QuoteLineID"); | 
 |  |  |             str = dw_list.GetItemString(row,L"QuoteLineID"); | 
 |  |  |          } | 
 |  |  |           | 
 |  |  |          if(dw_list.IsRowSelected(row) & 0xff) | 
 |  |  |          { | 
 |  |  |             printStr = printStr.replace(" "+str,""); | 
 |  |  |             printStr = printStr.replace(L" "+str,L""); | 
 |  |  |          }else | 
 |  |  |          { | 
 |  |  |             printStr += " " + str; | 
 |  |  |             printStr += L" " + str; | 
 |  |  |          } | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |       //命令处理事件 | 
 |  |  |       int OnXCommand(ref TXCommandEvent evt,int param) | 
 |  |  |       int OnXCommand(TEvent* evt, LPARAM param) | 
 |  |  |       { | 
 |  |  |          return OnCmdDispatch(evt.pStrID); | 
 |  |  |          return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |       } | 
 |  |  |        | 
 |  |  |       int SelectAll() | 
 |  |  |       { | 
 |  |  |          printStr=""; | 
 |  |  |          printStr=L""; | 
 |  |  |          for(int row = 1; row <= dw_list.GetRowCount(); row++) | 
 |  |  |          { | 
 |  |  |             dw_list.SetItemString(row,"IsSend","1"); | 
 |  |  |             dw_list.SetItemString(row,L"IsSend",L"1"); | 
 |  |  |             dw_list.SelectRow(row,true); | 
 |  |  |             string str = ""; | 
 |  |  |             if(dw_list.GetGuid(row) !="") | 
 |  |  |             xstring str = L""; | 
 |  |  |             if(dw_list.GetGuid(row) !=L"") | 
 |  |  |             { | 
 |  |  |                str = dw_list.GetItemString(row,"QuoteLineID"); | 
 |  |  |                printStr += " " + str; | 
 |  |  |                str = dw_list.GetItemString(row,L"QuoteLineID"); | 
 |  |  |                printStr += L" " + str; | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  |          dw_list.Redraw(); | 
 |  |  | 
 |  |  |        | 
 |  |  |       int UnSelectAll() | 
 |  |  |       { | 
 |  |  |          printStr=""; | 
 |  |  |          printStr=L""; | 
 |  |  |          for(int row = 1; row <= dw_list.GetRowCount(); row++) | 
 |  |  |          { | 
 |  |  |             dw_list.SetItemString(row,"IsSend","0"); | 
 |  |  |             dw_list.SetItemString(row,L"IsSend",L"0"); | 
 |  |  |             dw_list.SelectRow(row,false); | 
 |  |  |          } | 
 |  |  |          dw_list.Redraw(); | 
 |  |  | 
 |  |  |       int OnAttachEvent() | 
 |  |  |       { | 
 |  |  |          //绑定工具条点击事件 | 
 |  |  |          AttachEvent("WM_XCOMMAND",OnXCommand); | 
 |  |  |          AttachEvent(L"WM_XCOMMAND", (FEvent)&xmQuoteBillList::OnXCommand); | 
 |  |  |          //获取焦点事件,用于重置工具条 | 
 |  |  |          AttachEvent("WM_SETFOCUS",OnSetFocus); | 
 |  |  |          AttachEvent("dw_list","DWV_ROWFOCUSCHANGED",OnRowChanged);		 | 
 |  |  |          AttachEvent("dw_list","DWV_CLICKED",OnDwClicked); | 
 |  |  |          AttachEvent(L"WM_SETFOCUS", (FEvent)&xmQuoteBillList::OnSetFocus); | 
 |  |  |          AttachEvent(L"dw_list",L"DWV_ROWFOCUSCHANGED", (FEvent)&xmQuoteBillList::OnRowChanged); | 
 |  |  |          AttachEvent(L"dw_list",L"DWV_CLICKED", (FEvent)&xmQuoteBillList::OnDwClicked); | 
 |  |  |          return 1; | 
 |  |  |           | 
 |  |  |       } | 
 |  |  |        | 
 |  |  |        | 
 |  |  |       int  OnRetrieve(string QuoteNo) | 
 |  |  |       int  OnRetrieve(xstring QuoteNo) | 
 |  |  |       { | 
 |  |  |          xml x = new xml; | 
 |  |  |          x.setNativePointer(xml::CreateInstance()); | 
 |  |  |          xaserverarg arg = new xaserverarg; | 
 |  |  |          arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |          arg.AddArg("QuoteNo",QuoteNo); | 
 |  |  |          xml x ; | 
 |  |  |           | 
 |  |  |          if (getUrl("/sale/data/ProductLibrary3/QuoteBillList",arg.GetString(),x)!=1) | 
 |  |  |          xaserverarg arg ; | 
 |  |  | 			 | 
 |  |  |          arg.AddArg(L"QuoteNo",QuoteNo); | 
 |  |  | 			 | 
 |  |  |          if (getUrl(L"/sale/data/ProductLibrary3/QuoteBillList",arg.GetString(),x)!=1) | 
 |  |  |          { | 
 |  |  |             trace(x.GetXmlDoc().text); | 
 |  |  |             trace(x.text()); | 
 |  |  |             return -1; | 
 |  |  |          }else    | 
 |  |  |          { | 
 |  |  | 
 |  |  |           | 
 |  |  |       int onload() | 
 |  |  |       { | 
 |  |  |          dw_list = GetControl("dw_list"); | 
 |  |  |          dw_list.openUrl("/sale/view/Quote3/template/Quote/QuoteBillList"); | 
 |  |  |          SetArg(); | 
 |  |  |          dw_list = GetControl(L"dw_list"); | 
 |  |  |          dw_list.openUrl(L"/sale/view/Quote3/template/Quote/QuoteBillList"); | 
 |  |  |        | 
 |  |  |           | 
 |  |  |          if(GetParam()) | 
 |  |  |          if(GetWinParam()) | 
 |  |  |          { | 
 |  |  |             xaserverarg arg = GetParam(); | 
 |  |  |             QuoteNo=arg.GetArgString("QuoteNo"); | 
 |  |  |             OnRetrieve(arg.GetArgString("QuoteNo")); | 
 |  |  |             xaserverarg arg = GetArg(); | 
 |  |  |             QuoteNo=arg.GetArgString(L"QuoteNo"); | 
 |  |  |             OnRetrieve(arg.GetArgString(L"QuoteNo")); | 
 |  |  |          } | 
 |  |  |          OnRetrieve(QuoteNo); | 
 |  |  |          SelectAll(); | 
 |  |  | 
 |  |  |           | 
 |  |  |          return 1; | 
 |  |  |       }       | 
 |  |  |    }; | 
 |  |  | ] | 
 |  |  |    }; |