#include #include #include #include #include #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) HrEmployeex : public xwin { public: xtreeview tv_org; xdwtable dw_1; xnode m_agentNode; xstring is_orgid; xstring is_orgname; xstring is_inflag; xdwtable dw_empmaint; public: HrEmployeex(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} public: static HrEmployeex* CreateInstance(void* implPtr, void* hWnd) { HrEmployeex* pWin = new HrEmployeex(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(); xstring val; xml x; var xdoc = x; dw_1.AcceptText(); dw_1.DwUpdateAllTo(xdoc); val = xdoc.xml; //trace(val); //return 1; xaserverarg args; args.AddArg(L"content", val); xml x1; if (xurl::post(L"OrganizationStruct/update.Employee", args.GetString(), x1) != 1) { xstring error = x1.text(); trace(error); } else { MessageBox(GetHWND(), L"±£´æ³É¹¦£¡", L"Ìáʾ", 0); } xutil::RestoreCursor(hIcon); return 1; } int OnRetrieve(xstring ls_orgid) { xml x; xaserverarg arg; arg.AddArg(L"OrgID", ls_orgid); //trace(ls_orgid); //if (xaserver::ExecXQuery(GetServerUrl(),L"[MSSqlHrEmployee.xq]",arg.GetString(),x) == 1) if (xurl::get(L"OrganizationStruct/detail.Employee", arg.GetString(), x) == 1) { dw_1.openUrl(L"×éÖ¯¼Ü¹¹.vface/template/HrEmployee/detail"); dw_1.Retrieve(x); dw_1.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(); is_orgid = ls_orgid; //trace(is_orgid); OnRetrieve(ls_orgid); return 1; } int OnAddRow() { xdwtable dw = new xdwtable; dw.setNativePointer(dw_1.GetCurTable()); xstring dw_n = dw.GetDwName(); if (dw_n == L"HrEmployee") dw.InsertRow(0); return 1; } int OnInsertRow() { xdwtable dw = new xdwtable; dw.setNativePointer(dw_1.GetCurTable()); xstring dw_n = dw.GetDwName(); if (dw_n == L"HrEmployee") { int row = dw.GetRow(); dw.InsertRow(row); } return 1; } int OnDeleteRow() { xdwtable dw = new xdwtable; dw.setNativePointer(dw_1.GetCurTable()); xstring dw_n = dw.GetDwName(); if (dw_n == L"HrEmployee") { int row = dw.GetRow(); dw.DeleteRow(row); } return 1; } int OnChildContent(TEvent* evt, LPARAM 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"PositionID") { arg.AddArg(L"ResourceType", L"HrPosition"); } else if (col == L"PersonID") { arg.AddArg(L"ResourceType", L"HrPerson"); } else 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 OnItemChanged(TEvent* evt, LPARAM p) { DWNMHDR& dwhdr = *(DWNMHDR*)evt->notify.pnmh; HCURSOR HCursor = xutil::SetCursorWait(); int row = dwhdr.row; xstring col = dwhdr.colname; xstring data = dwhdr.data; trace(xstring(row)); if (col == L"PositionID") { xdwtable dw_HrEmployee = new xdwtable; dw_HrEmployee.setNativePointer(dw_1.FindDwTable(L"HrEmployee")); xstring sPositionID = dw_HrEmployee.GetItemString(row, L"PositionID"); if (sPositionID == L"") return 1; xml x; xaserverarg arg; arg.AddArg(L"guid", sPositionID); arg.AddArg(L"type", L"GetOrgIDJobID"); //trace(arg.GetString()); if (xurl::get(L"OrganizationStruct/GetOrgIDJobID", arg.GetString(), x) != 1) { trace(x.text()); return -1; } else { KXMLDOMDocument xdoc = x; //IXMLDOMNodeList nlist = xdoc.getElementsByTagName(L"OrgID"); KXMLDOMElement e = xdoc.documentElement(); xstring sOrgID = e.selectSingleNode(L"@OrgID").text(); xstring sOrgName = e.selectSingleNode(L"@OrgName").text(); xstring sJobID = e.selectSingleNode(L"@JobID").text(); xstring sJobName = e.selectSingleNode(L"@JobName").text(); dw_HrEmployee.SetItemString(row, L"OrgID", sOrgID); dw_HrEmployee.SetItemDisplayString(row, L"OrgID", sOrgName); dw_HrEmployee.SetItemString(row, L"JobID", sJobID); dw_HrEmployee.SetItemDisplayString(row, L"JobID", sJobName); } } xutil::RestoreCursor(HCursor); return 0; } int OnImportData() { openUrl(L"×éÖ¯¼Ü¹¹.vface/xpage/Hr/HrPersonSel", this); return 1; } //ÃüÁî·¢²¼º¯Êý int OnCmdDispatch(xstring comdid) { if (comdid == L"AddRow") return OnAddRow(); else if (comdid == L"InsertRow") return OnInsertRow(); else if (comdid == L"DeleteRow") return OnDeleteRow(); else if (comdid == L"Save") return OnSave(); else if (comdid == L"ImportData") return OnImportData(); return 0; } //ÃüÁî´¦Àíʼþ int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnAttachEvent() { //°ó¶¨¹¤¾ßÌõµã»÷ʼþ AttachEvent(L"WM_XCOMMAND", (FEvent)&HrEmployeex::OnXCommand); //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ AttachEvent(L"WM_SETFOCUS", (FEvent)&HrEmployeex::OnSetFocus); //»ñµÃÊ÷µÄÑ¡Ôñʼþ AttachEvent(L"tv_org", L"TVN_SELCHANGED", (FEvent)&HrEmployeex::OnTreeSelChanged); //ÏÂÀ­¿ò ÌṩÄÚÈÝ AttachEvent(L"dw_1", L"DWV_CHILDCONTENT", (FEvent)&HrEmployeex::OnChildContent); AttachEvent(L"dw_1", L"DWV_ITEMCHANGED", (FEvent)&HrEmployeex::OnItemChanged); return 1; } int OnInitial() { SetAgent(); OnAttachEvent(); return 1; } int onload() { tv_org = new treeview; tv_org.setNativePointer(GetControl(L"tv_org")); dw_1 = new xdwtable; dw_1.setNativePointer(GetControl(L"dw_1")); dw_1.openUrl(L"×éÖ¯¼Ü¹¹.vface/template/HrEmployee/detail"); OnInitial(); //int wid = tv_org.GetId(); HTREEITEM root = tv_org.GetRootItem(); tv_org.ExpandItem( root); return 1; } };