#include <wobject/xstring.hpp> 
 | 
#include <xcontrol/xtreeview.hpp> 
 | 
#include <xcontrol/xdwgrid.hpp> 
 | 
#include <wobject/xdouble.hpp> 
 | 
#include <xcontrol/xlayersheet.hpp> 
 | 
  
 | 
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" 
 | 
#include "viewobject/view.base.hpp" 
 | 
  
 | 
using xml = KXMLDOMDocument; 
 | 
    class __declspec(dllexport) OrganizationBase :  public xframe 
 | 
    { 
 | 
    public: 
 | 
        HWND hObject = 0; 
 | 
        xdwtable    dw_base; 
 | 
        xnode    m_agentNode;    //Agent Condition 
 | 
        bool updated; 
 | 
    public: 
 | 
        OrganizationBase(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} 
 | 
    public: 
 | 
        static OrganizationBase* CreateInstance(void* implPtr, void* hWnd) 
 | 
        { 
 | 
            OrganizationBase* pWin = new OrganizationBase(implPtr, (HWND)hWnd); 
 | 
            return pWin; 
 | 
        } 
 | 
        int SetAgent() 
 | 
        { 
 | 
            return 1; 
 | 
            xstring xfNodeAgentArea  = L"agentarea"; 
 | 
            xnode anode = GetAgentNode(xfNodeAgentArea); 
 | 
            if(m_agentNode) 
 | 
            { 
 | 
                SetAgentNode (anode,m_agentNode); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                KXMLDOMElement xframeElement =  GetElement(); 
 | 
                KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*"); 
 | 
                if(agent) 
 | 
                { 
 | 
                    xstring s = agent.xml(); 
 | 
                    m_agentNode =  SetAgentNode (anode,s); 
 | 
                } 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
                 
 | 
        //½¹µã¼¤»î´¦Àíº¯Êý 
 | 
        int OnSetFocus(TEvent* evt, LPARAM param) 
 | 
        { 
 | 
            //ÖØÖù¤¾ßÌõ 
 | 
            //SetAgent(); 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
                 
 | 
        int OnSave() 
 | 
        { 
 | 
            xml x ; 
 | 
             
 | 
            xaserverarg arg ; 
 | 
                 
 | 
            dw_base.AcceptText(); 
 | 
            dw_base.DwUpdateAllTo(x); 
 | 
            xstring error = L""; 
 | 
            arg.AddArg(L"content", x.xml() ); 
 | 
            if(xurl::get(L"/sale/data/business/Update/Organization", arg.GetString(),x)!=1) 
 | 
            { 
 | 
                error = x.text(); 
 | 
                //alert(error); 
 | 
            }else 
 | 
            { 
 | 
                xstring str = x.documentElement().getAttribute(L"text"); 
 | 
                if(str == L"true") 
 | 
                { 
 | 
                    dw_base.ResetUpdateStatus(); 
 | 
                    alert(L"±£´æ³É¹¦!");  
 | 
                    SendMessage(hObject,0x401,(LPARAM)L"xmRefresh",0); 
 | 
                    CloseWindow(); 
 | 
                }else  
 | 
                { 
 | 
                    alert(L"±£´æÊ§°Ü!"); 
 | 
                } 
 | 
                //alert(str); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        //ÃüÁî·¢²¼º¯Êý 
 | 
        int OnCmdDispatch(xstring comdid) 
 | 
        { 
 | 
            if(comdid==L"xmSave") 
 | 
            { 
 | 
                OnSave(); 
 | 
                return 1; 
 | 
            } 
 | 
            else if(comdid==L"xmClose") 
 | 
            { 
 | 
                if(updated) 
 | 
                    SendMessage(hObject,0x401,(LPARAM)L"xmRefresh",0); 
 | 
                CloseWindow(); 
 | 
                return 1; 
 | 
            } 
 | 
            return 0; 
 | 
        } 
 | 
         
 | 
        //ÃüÁî´¦Àíʼþ 
 | 
        int OnXCommand(TEvent* evt, LPARAM param) 
 | 
        { 
 | 
            return OnCmdDispatch(evt->xcommand.pStrID); 
 | 
        } 
 | 
         
 | 
        int OnItemChanged(TEvent* evt, int p) 
 | 
        { 
 | 
            DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; 
 | 
            xstring colname=hdr.colname; 
 | 
            xstring value = hdr.data; 
 | 
             
 | 
            xstring dwname = L"dw_base"; 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
         
 | 
        int OnAttachEvent() 
 | 
        { 
 | 
            //°ó¶¨¹¤¾ßÌõµã»÷ʼþ 
 | 
            AttachEvent(L"WM_XCOMMAND", (FEvent)&OrganizationBase::OnXCommand); 
 | 
            //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ 
 | 
            AttachEvent(L"WM_SETFOCUS", (FEvent)&OrganizationBase::OnSetFocus); 
 | 
            AttachEvent(L"dw_base",L"DWV_ITEMCHANGED", (FEvent)&OrganizationBase::OnItemChanged); 
 | 
            return 1; 
 | 
             
 | 
        } 
 | 
         
 | 
        int  OnRetrieve(xstring ID) 
 | 
        { 
 | 
            xml x ; 
 | 
             
 | 
            xaserverarg arg ; 
 | 
                 
 | 
            arg.AddArg(L"ID",ID); 
 | 
            if (getUrl(L"/sale/data/business/GetOrganizationByID",arg.GetString(),x)!=1) 
 | 
            { 
 | 
                trace(x.text()); 
 | 
                return -1; 
 | 
            }else     
 | 
            { 
 | 
                dw_base.Retrieve(x); 
 | 
                dw_base.Redraw(); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        int onload() 
 | 
        { 
 | 
            SetArg(); 
 | 
            dw_base = GetControl(L"dw_base"); 
 | 
            dw_base.openUrl(L"/sale/view/Business3/template/OrganizationMaint"); 
 | 
            dw_base.SetColHeaderHeight(0); 
 | 
            dw_base.SetRowSelectorWidth(0); 
 | 
            dw_base.SetHScrollState(false); 
 | 
            dw_base.SetVScrollState(false); 
 | 
             
 | 
            xstring ID = L""; 
 | 
            hObject = 0; 
 | 
            if(GetWinParam()) 
 | 
            {     
 | 
                xaserverarg arg =GetArg() ; 
 | 
                 
 | 
                ID = arg.GetArgString(L"ID"); 
 | 
                hObject = (HWND)arg.GetArgString(L"HWND").toInt(); 
 | 
            } 
 | 
            if(ID != L"") 
 | 
            { 
 | 
                OnRetrieve(ID); 
 | 
            } 
 | 
             
 | 
            OnAttachEvent();     
 | 
            updated = false; 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        int onloaded() 
 | 
        { 
 | 
            //SetAgent();             
 | 
             
 | 
            return 1; 
 | 
        }         
 | 
    }; 
 |