#pragma once #include #include #include #include #include #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) HrPosition : public xframe { public: xtreeview tv_org; xdwgrid dw_list; xstring sOrgID; xstring sOrgName; xnode m_agentNode; //Agent Condition xstring m_agentCond; //Agent Node public: HrPosition(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} public: static HrPosition* CreateInstance(void* implPtr, void* hWnd) { HrPosition* pWin = new HrPosition(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 OnRetrieve(xstring ls_orgid) { xstring query = L"[MSSqlHrPosition.xq]"; xml x; xaserverarg arg; arg.AddArg(L"orgID", ls_orgid); //if (xaserver::ExecXQuery(GetServerUrl(),query,arg.GetString(),x)!=1) if (xurl::post(L"OrganizationStruct/list.Position", arg.GetString(), x) != 1) { trace(x.text()); return -1; } else { //trace(x.GetXml()); //dw_list.openUrl(L"×éÖ¯¼Ü¹¹.vface/template/HrPosition/list"); dw_list.Retrieve(x); dw_list.Redraw(); } return 1; } int OnTreeSelChanged(TEvent* evt, int p) { //int wid = tv_org.GetId(); HTREEITEM hitem = tv_org.GetSelectedItem(); KXMLDOMElement ele = tv_org.GetItemData(hitem); xstring ls_orgid = ele.selectSingleNode(L"@guid").text(); sOrgID = ls_orgid + L""; sOrgName = ele.selectSingleNode(L"OrgName").text(); OnRetrieve(ls_orgid); return 1; } int OnSave() { xml x; dw_list.AcceptText(); dw_list.DwUpdateAllToEx(x); xstring xdata = x.xml(); xaserverarg arg; arg.AddArg(L"xdata", xdata); //trace(x.GetXml()); //return 1; //xstring xAction=L"[MSSqlHrPositionUpdate.xa]"; //if(xaserver::ExecXAction(GetServerUrl(),xAction,arg.GetString())!=1) if (xurl::post(L"OrganizationStruct/update.Position", arg.GetString(), x) != 1) { trace(x.documentElement().text()); alert(L"±£´æÊ§°Ü1"); } else { dw_list.ResetUpdateStatus(); alert(L"±£´æ³É¹¦"); } return 1; } int OnAddRow() { //int wid = tv_org.GetId(); HTREEITEM hitem = tv_org.GetSelectedItem(); if (!hitem) { alert(L"ÇëÑ¡Ôñ×éÖ¯¼Ü¹¹£¡"); return 0; } //openUrl(L"×éÖ¯¼Ü¹¹.vface/xpage/Hr/HrPositionAdd", this); OpenWindow(L"dev:xpage[HrPositionAdd.vx]", (LPARAM)this); return 1; } int OnInsertRow() { int row = dw_list.GetRow(); dw_list.InsertRow(row); return 1; } int OnDeleteRow() { int row = dw_list.GetRow(); if (row > 0) { xstring sPositionName = dw_list.GetItemString(row, L"PositionName"); int del_flog =MessageBox(0, L"È·¶¨ÒªÉ¾³ýÑ¡ÖеĸÚλ " + sPositionName + L" Âð£¿", L"Ìáʾ", 4); if (del_flog == 7) { return 0; } //ÅжÏHrEmployeeÀïÃæÊÇ·ñ´æÔڸøÚλ //xstring sPositionID = dw_list.GetItemString(row,L"PositionID",0); KXMLDOMElement e = dw_list.GetRowElement(row); xstring sPositionID = e.selectSingleNode(L"@guid").text(); xml x; xaserverarg args; args.AddArg(L"guid", sPositionID); //if(xaserver::ExecXQuery(GetServerUrl(),L"[HrpositionSel.xq]",args.GetString(),x)!=1) if (xurl::post(L"OrganizationStruct/select.Position", args.GetString(), x) != 1) { trace(x.xml()); return 0; } auto doc = x; xstring cnt = doc.text(); int ll_cnt = cnt.toInt(); if (ll_cnt == 0) //ÅжÏHrEmploeeÀïÃæÊÇ·ñ´æÔڸøÚλ { args.ClearArgs(); //xaserverarg Args; //Args.setNativePointer(Args.CreateInstance()); args.AddArg(L"guid", sPositionID); //if(xaserver::ExecXAction(GetServerUrl(),L"[HrPositionDel.xa]",Args.GetString(),x)!=1) if (xurl::post(L"OrganizationStruct/delete.Position", args.GetString(), x) != 1) { trace(x.documentElement().text()); alert(L"ɾ³ýʧ°Ü"); } else { dw_list.DeleteRow(row); alert(L"ɾ³ý³É¹¦"); } } else { alert(L"ÆäËûµØ·½ÒѾ­Ê¹ÓøøÚ룬²»ÔÊÐíɾ³ý£¡"); return 0; } } return 1; } int OnChildContent(TEvent* evt, int p) { DWNMHDR& dwhdr = *(DWNMHDR*)evt->notify.pnmh; xstring col = dwhdr.colname; if (col != L"") { xml x; xaserverarg arg; xstring query; query = L"[IResourceMSSql.xq]"; if (col == L"OrgID") { arg.AddArg(L"ResourceType", L"HrOrg"); } else if (col == L"JobID") { arg.AddArg(L"ResourceType", L"HrJob"); } if (xaserver::ExecXQuery(GetServerUrl(), query, arg.GetString(), x) == 1) dwhdr.data = x.xml(); //trace(x.GetXml()); } 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)&HrPosition::OnXCommand); //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ AttachEvent(L"WM_SETFOCUS", (FEvent)&HrPosition::OnSetFocus); //»ñµÃÊ÷µÄÑ¡Ôñʼþ AttachEvent(L"tv_org", L"TVN_SELCHANGED", (FEvent)&HrPosition::OnTreeSelChanged); //AttachEvent(L"dw_list",L"DWV_CHILDCONTENT",OnChildContent); //AttachEvent(L"dw_list",L"DWV_ITEMCHANGED",OnItemChanged); return 1; } int OnInitial() { SetAgent(); OnAttachEvent(); return 1; } int onload() { tv_org = GetControl(L"tv_org"); dw_list = new xdwgrid; dw_list.setNativePointer(GetControl(L"dw_list")); dw_list.openUrl(L"×éÖ¯¼Ü¹¹.vface/template/HrPosition/list"); OnInitial(); //int wid = tv_org.GetId(); HTREEITEM root = tv_org.GetRootItem(); tv_org.ExpandItem( root); //OnRetrieve(); return 1; } };