#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) HrOrgType : public xwin 
 | 
{ 
 | 
public: 
 | 
    xdwgrid    dw_list; 
 | 
  
 | 
    xnode    m_agentNode;    //Agent Condition 
 | 
    xstring    m_agentCond;    //Agent Node 
 | 
public: 
 | 
    HrOrgType(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} 
 | 
public: 
 | 
    static HrOrgType* CreateInstance(void* implPtr, void* hWnd) 
 | 
    { 
 | 
        HrOrgType* pWin = new HrOrgType(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, LPARAM param) 
 | 
    { 
 | 
        SetAgent(); 
 | 
  
 | 
        //ÖØÖù¤¾ßÌõ 
 | 
        return 1; 
 | 
    } 
 | 
  
 | 
    int OnSave() 
 | 
    { 
 | 
        HCURSOR hIcon = xutil::SetCursorWait(); 
 | 
  
 | 
        xml x; 
 | 
  
 | 
        auto xdoc = x; 
 | 
        dw_list.AcceptText(); 
 | 
        dw_list.DwUpdateAllTo(xdoc);//dw_list.DwUpdateAllTo(xdoc); //dw_list.DwUpdateTo(xdoc); 
 | 
  
 | 
        xstring val = xdoc.xml(); 
 | 
        xaserverarg args; 
 | 
        args.AddArg(L"content", val); 
 | 
        //trace(val); 
 | 
        //return 1; 
 | 
        if (xurl::post(L"OrganizationStruct/update.HrOrgType", args.GetString(), x) != 1) 
 | 
        { 
 | 
            xstring error = x.text(); 
 | 
            trace(error); 
 | 
            xutil::RestoreCursor(hIcon); 
 | 
            return -1; 
 | 
        } 
 | 
  
 | 
        xutil::RestoreCursor(hIcon); 
 | 
        MessageBox(GetHWND(), L"±£´æ³É¹¦£¡", L"Ìáʾ", 0); 
 | 
        return 1; 
 | 
    } 
 | 
  
 | 
    int  OnRetrieve() 
 | 
    { 
 | 
        HCURSOR hIcon = xutil::SetCursorWait(); 
 | 
        xml x; 
 | 
  
 | 
        xaserverarg arg; 
 | 
  
 | 
        //arg.AddArg(L"guid",L"xxx"); 
 | 
        if (xurl::post(L"OrganizationStruct/list.HrOrgType", arg.GetString(), x) != 1) 
 | 
        { 
 | 
            trace(x.text()); 
 | 
            return -1; 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            dw_list.Retrieve(x); 
 | 
            dw_list.Redraw(); 
 | 
        } 
 | 
        xutil::RestoreCursor(hIcon); 
 | 
        return 1; 
 | 
    } 
 | 
  
 | 
    int OnAddrow() 
 | 
    { 
 | 
        dw_list.InsertRow(0); 
 | 
        return 1; 
 | 
    } 
 | 
  
 | 
    int OnInsertrow() 
 | 
    { 
 | 
        int row = dw_list.GetRow(); 
 | 
        if (row < 1) return 0; 
 | 
        dw_list.InsertRow(row); 
 | 
        return 1; 
 | 
    } 
 | 
  
 | 
    int OnDeleteRow() 
 | 
    { 
 | 
        int row = dw_list.GetRow(); 
 | 
        if (row < 1) return 0; 
 | 
  
 | 
        KXMLDOMElement e = dw_list.GetRowElement(row); 
 | 
        xstring sguid = e.selectSingleNode(L"Code").text(); //e.getAttribute(L"guid"); 
 | 
        xaserverarg arg; 
 | 
  
 | 
        arg.AddArg(L"guid", sguid); 
 | 
        //trace(sguid); 
 | 
        xml x; 
 | 
  
 | 
        if (xurl::post(L"OrganizationStruct/delete.HrOrgType", arg.GetString(), x) != 1) 
 | 
        { 
 | 
            xstring error = x.text(); 
 | 
            trace(error); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            dw_list.DeleteRow(row); 
 | 
        } 
 | 
        return 1; 
 | 
    } 
 | 
  
 | 
    //ÃüÁî·¢²¼º¯Êý 
 | 
    int OnCmdDispatch(xstring comdid) 
 | 
    { 
 | 
        if (comdid == L"save") OnSave(); 
 | 
        else if (comdid == L"addrow") OnAddrow(); 
 | 
        else if (comdid == L"insertrow") OnInsertrow(); 
 | 
        else if (comdid == L"deleterow") OnDeleteRow(); 
 | 
  
 | 
        return 0; 
 | 
    } 
 | 
  
 | 
    //ÃüÁî´¦Àíʼþ 
 | 
    int OnXCommand(TEvent* evt, LPARAM param) 
 | 
    { 
 | 
        return OnCmdDispatch(evt->xcommand.pStrID); 
 | 
    } 
 | 
  
 | 
    int OnAttachEvent() 
 | 
    { 
 | 
        //°ó¶¨¹¤¾ßÌõµã»÷ʼþ 
 | 
        AttachEvent(L"WM_XCOMMAND", (FEvent)&HrOrgType::OnXCommand); 
 | 
        //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ 
 | 
        AttachEvent(L"WM_SETFOCUS", (FEvent)&HrOrgType::OnSetFocus); 
 | 
        return 1; 
 | 
    } 
 | 
  
 | 
    int OnInitial() 
 | 
    { 
 | 
        SetAgent(); 
 | 
        OnAttachEvent(); 
 | 
        return 1; 
 | 
    } 
 | 
  
 | 
    int onload() 
 | 
    { 
 | 
        dw_list = new xdwgrid; 
 | 
        dw_list.setNativePointer(GetControl(L"dw_list")); 
 | 
        dw_list.openUrl(L"×éÖ¯¼Ü¹¹.vface/template/HrOrg/orgtype"); 
 | 
        //dw_list.SetSelectionMode(1); 
 | 
        //dw_list.SetReadOnly(true); 
 | 
  
 | 
        OnInitial(); 
 | 
        OnRetrieve(); 
 | 
  
 | 
        return 1; 
 | 
    } 
 | 
}; 
 |