| | |
| | | #include <wobject/xstring.hpp> |
| | | #include <xcontrol/xtreeview.hpp> |
| | | #include <xcontrol/xdwgrid.hpp> |
| | | use "win.vl" |
| | | use "dev:vm[xdwgrid.vm]" |
| | | use "dev:vm[xdwtable.vm]" |
| | | use "pref.vl" |
| | | use "dev:vm[xml.vm]" |
| | | use "dev:vm[xaserverarg.vm]" |
| | | use "dev:vm[xaserver.vm]" |
| | | use "dev:vm[xutil.vm]" |
| | | use "list.vl" |
| | | use "treeview.vm" |
| | | //unit vclient.vobject tpp |
| | | unit vbusiness.xpage |
| | | [ |
| | | HrEmployee is extend list; |
| | | about HrEmployee |
| | | [ |
| | | field: |
| | | [ |
| | | treeview__ tv_org; |
| | | xdwgrid__ dw_emp; |
| | | |
| | | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" |
| | | #include "viewobject/view.base.hpp" |
| | | string is_orgid |
| | | string is_orgname; |
| | | string is_inflag; |
| | | xdwtable__ dw_empmaint; |
| | | xnode__ m_agentNode; //Agent Condition |
| | | string m_agentCond; //Agent Node |
| | | ] |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | class __declspec(dllexport) Deduction : public xframe |
| | | { |
| | | public: |
| | | xdwgrid dw_list; |
| | | xstring EntityID; |
| | | xstring InvoiceNo; |
| | | |
| | | xnode m_agentNode; //Agent Condition |
| | | |
| | | public: |
| | | Deduction(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static Deduction* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | Deduction* pWin = new Deduction(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) |
| | | method: |
| | | [ |
| | | int SetAgent() |
| | | { |
| | | xstring s = agent.xml(); |
| | | m_agentNode = SetAgentNode(anode, s); |
| | | string xfNodeAgentArea = "agentarea"; |
| | | xnode__ anode = new xnode__; |
| | | anode.setNativePointer(GetAgentNode(xfNodeAgentArea)); |
| | | var xframeElement = GetElement(); |
| | | var agent = xframeElement.selectSingleNode("agent/" + xfNodeAgentArea + "/*[1]"); |
| | | if (agent) |
| | | { |
| | | string s = agent.xml; |
| | | SetAgentNodeContent(anode, s); |
| | | } |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | //焦点激活处理函数 |
| | | int OnSetFocus(ref TEvent evt, int p) |
| | | { |
| | | SetAgent(); |
| | | //重置工具条 |
| | | return 1; |
| | | } |
| | | |
| | | int OnRowChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | SetAgent(); |
| | | return 1; |
| | | } |
| | | int OnRetrieve(string ls_orgid) |
| | | { |
| | | xml__ x = new xml__; |
| | | x.setNativePointer(x.CreateInstance()); |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("OrgID", ls_orgid); |
| | | //trace(ls_orgid); |
| | | //if (xaserver__::ExecXQuery(GetServerUrl(),"[MSSqlHrEmployee.xq]",arg.GetString(),x) == 1) |
| | | if (url::get("OrganizationStruct/list.Employee", arg.GetString(), x) == 1) |
| | | { |
| | | dw_emp.Retrieve(x); |
| | | dw_emp.Redraw(); |
| | | } |
| | | //trace(x.GetXml()); |
| | | return 1; |
| | | } |
| | | |
| | | //焦点激活处理函数 |
| | | int OnSetFocus(TEvent* evt, LPARAM param) |
| | | { |
| | | //重置工具条 |
| | | SetAgent(); |
| | | return 1; |
| | | } |
| | | int OnSave() |
| | | { |
| | | int hIcon = xutil__::SetCursorWait(); |
| | | xml__ x = new xml__; |
| | | x.setNativePointer(x.CreateInstance()); |
| | | dw_emp.AcceptText(); |
| | | dw_emp.DwUpdateAllToEx(x.GetXmlDoc()); |
| | | |
| | | //命令发布函数 |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid == L"xmSave") |
| | | { |
| | | OnSave(); |
| | | return 1; |
| | | } |
| | | if (comdid == L"xmSearch") |
| | | { |
| | | OnRetrieve(InvoiceNo, EntityID); |
| | | return 1; |
| | | } |
| | | if (comdid == L"xmClose") |
| | | { |
| | | CloseWindow(); |
| | | return 1; |
| | | } |
| | | return 0; |
| | | } |
| | | string val = x.GetXml(); |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("content", val); |
| | | //trace(x.GetXml()); |
| | | //return 1; |
| | | if (url::post("OrganizationStruct/update.Employee", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.GetXmlDoc().documentElement.text); |
| | | alert("保存失败"); |
| | | } |
| | | else { |
| | | dw_emp.ResetUpdateStatus(); |
| | | alert("保存成功"); |
| | | } |
| | | trace(x.GetXml()); |
| | | xutil__::RestoreCursor(hIcon); |
| | | return 1; |
| | | } |
| | | |
| | | //命令处理事件 |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | int OnSubTree(string id, int parentitem) |
| | | { |
| | | int wid = tv_org.GetId(); |
| | | if (treeview__::GetChildItem(wid, parentitem) > 0) return 1; |
| | | xml__ x = new xml__; |
| | | x.setNativePointer(xml__::CreateInstance()); |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("sguid", id); |
| | | if (url::post("/sale/data/OrganizationStruct/tree.child.OrgChart", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.GetXml()); |
| | | return -1; |
| | | } |
| | | //trace(x.GetXml()); |
| | | var list = x.GetXmlDoc().selectNodes("//item"); |
| | | int i = 0, s = list.length; |
| | | msxml::IXMLDOMElement xitem; |
| | | string sName; |
| | | string sguid; |
| | | string stype; |
| | | if (s > 0) |
| | | { |
| | | for (i = 0; i < s; i++) |
| | | { |
| | | xitem = list.item(i); |
| | | sName = xitem.SelectSingleNode("name").text; |
| | | sguid = xitem.SelectSingleNode("id").text; |
| | | stype = xitem.SelectSingleNode("typ").text; |
| | | //int curItem = tv_org.InsertChildItemEx(wid,parentitem,sName,xitem,15,4); |
| | | int curItem = 0; |
| | | if (stype == "Org") |
| | | { |
| | | curItem = tv_org.InsertChildItemEx(wid, parentitem, sName, xitem, 15, 4); |
| | | tv_org.SetItemChild1(wid, curItem, 1); |
| | | } |
| | | else |
| | | { |
| | | curItem = tv_org.InsertChildItemEx(wid, parentitem, sName, xitem, 21, 21); |
| | | } |
| | | //OnSubTree(sguid,curItem); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | xstring GetGuid() |
| | | { |
| | | return publiccode::GetGuid(); |
| | | } |
| | | int OnCreateTree(string id, int parentitem) |
| | | { |
| | | //while (tv_1.GetRootItem()>0) |
| | | // tv_1.DeleteItem(tv_1.GetRootItem()); |
| | | int wid = tv_org.GetId(); |
| | | xml__ x = new xml__; |
| | | x.setNativePointer(xml__::CreateInstance()); |
| | | x.LoadXml("<item><id>" + id + "</id><no/><name>宁波家尔佳</name><typ>Org</typ></item>"); |
| | | //msxml::IXMLDOMDocument root = x.GetXmlDoc(); |
| | | //msxml::IXMLDOMElement RDoc = x.GetXmlDoc().documentElement; |
| | | //msxml::IXMLDOMElement ele = RDoc.SelectSingleNode("//Org"); |
| | | msxml::IXMLDOMElement ele = x.GetXmlDoc().SelectSingleNode("//item"); |
| | | int hItem = treeview__::InsertChildItemEx(wid, 0, "宁波家尔佳", ele, 15, 4); |
| | | treeview__::SetItemChild1(wid, hItem, 1); |
| | | return 1; |
| | | |
| | | int OnSave() |
| | | { |
| | | xml x; |
| | | |
| | | dw_list.AcceptText(); |
| | | dw_list.DwUpdateAllToEx(x); |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"content", x.xml()); |
| | | trace(x.xml()); |
| | | if (xurl::get(L"/sale/data/AR/update/ARDeduction", arg.GetString(), x) != 1) |
| | | { |
| | | xstring error = x.text(); |
| | | alert(L"err:" + error); |
| | | return 1; |
| | | } |
| | | xstring str = x.documentElement().getAttribute(L"text"); |
| | | if (str == L"true") |
| | | { |
| | | dw_list.ResetUpdateStatus(); |
| | | alert(L"保存成功!"); |
| | | } |
| | | else |
| | | { |
| | | alert(L"保存失败!"); |
| | | } |
| | | return 1; |
| | | } |
| | | /*xaserverarg__ arg=new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("sguid",id); |
| | | if(url::post("/sale/data/OrganizationStruct/tree.child.OrgChart",arg.GetString(),x)!=1) |
| | | { |
| | | trace(x.GetXml()); |
| | | return -1; |
| | | } |
| | | //trace(x.GetXml()); |
| | | var list=x.GetXmlDoc().selectNodes("//item"); |
| | | int i=0,s=list.length; |
| | | msxml::IXMLDOMElement xitem; |
| | | string sName; |
| | | string sguid; |
| | | if (s >0) |
| | | { |
| | | for (i=0;i<s;i++) |
| | | { |
| | | xitem= list.item(i); |
| | | sName = xitem.SelectSingleNode("@name").text; |
| | | sguid = xitem.SelectSingleNode("@id").text; |
| | | int curItem = tv_org.InsertChildItemEx(wid,hItem,sName,xitem,15,4); |
| | | tv_org.SetItemChild1(wid,curItem,1); |
| | | //OnSubTree(sguid,curItem); |
| | | } |
| | | } |
| | | return 1;*/ |
| | | } |
| | | |
| | | int OnItemChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | xstring colname = hdr.colname; |
| | | xstring value = hdr.data; |
| | | int row = hdr.row; |
| | | xstring dwname = L"dw_list"; |
| | | if (colname == L"DeductionAmount") |
| | | { |
| | | dw_list.SetItemString(row, L"SettlementAdjustID", EntityID); |
| | | xstring id = publiccode::GetGuid(); |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | ele.setAttribute(L"guid", id); |
| | | //dw_list.SetGuid(row,id); |
| | | //alert(ele.xml); |
| | | //alert(dw_list.GetGuid(row)); |
| | | } |
| | | dw_list.Redraw(); |
| | | return 1; |
| | | } |
| | | int OnTreeExpanding(ref TNotifyEvent evt, int p) |
| | | { |
| | | ref NMTREEVIEW nmtv = evt.pnmh; |
| | | int sitem = nmtv.itemNew.hItem; |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //绑定工具条点击事件 |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&Deduction::OnXCommand); |
| | | //获取焦点事件,用于重置工具条 |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&Deduction::OnSetFocus); |
| | | AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&Deduction::OnRowChanged); |
| | | AttachEvent(L"dw_list", L"DWV_ITEMCHANGED", (FEvent)&Deduction::OnItemChanged); |
| | | return 1; |
| | | } |
| | | int hCursor = xutil__::SetCursorWait(); |
| | | //string id = treeview__::GetItemData(tv_org.GetId(), sitem); |
| | | msxml::IXMLDOMElement ele = treeview__::GetItemData(tv_org.GetId(), sitem); |
| | | string id = ele.SelectSingleNode("id").text; |
| | | OnSubTree(id, sitem); |
| | | xutil__::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | int OnTreeSelChanged(ref TXCommandEvent evt, int p) |
| | | { |
| | | int wid = tv_org.GetId(); |
| | | int hitem = treeview__::GetSelectedItem(wid); |
| | | msxml::IXMLDOMElement ele = treeview__::GetItemData(wid, hitem); |
| | | if (ele) |
| | | { |
| | | string ls_orgid = ele.SelectSingleNode("id").text; |
| | | is_orgid = ls_orgid; |
| | | OnRetrieve(ls_orgid); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnRetrieve(xstring InvoiceNo, xstring EntityID) |
| | | { |
| | | xml x; |
| | | |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"InvoiceNo", InvoiceNo); |
| | | arg.AddArg(L"InvoiceNoEx", xcontrol(GetControl(L"search")).GetText()); |
| | | arg.AddArg(L"EntityID", EntityID); |
| | | int OnAddRow() |
| | | { |
| | | int wid = tv_org.GetId(); |
| | | int hitem = treeview__::GetSelectedItem(wid); |
| | | if (!hitem) |
| | | { |
| | | alert("请选择岗位!"); |
| | | return 0; |
| | | } |
| | | else |
| | | { |
| | | msxml::IXMLDOMElement ele = treeview__::GetItemData(wid, hitem); |
| | | string stype = ele.SelectSingleNode("typ").text; |
| | | if (stype != "Pos") |
| | | { |
| | | alert("请选择岗位!"); |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | //trace(GetControl(L"search").GetText()); |
| | | if (getUrl(L"/sale/data/AR/DeductionList", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_list.Retrieve(x); |
| | | dw_list.Redraw(); |
| | | } |
| | | dw_list.SetSelectionMode(1); |
| | | return 1; |
| | | } |
| | | OpenWindow("dev:xpage[HrEmployeeAdd.vx]", this); |
| | | //openUrl("组织架构.vface/xpage/Hr/HrEmployeeAdd", this); |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | SetArg(); |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.openUrl(L"/sale/view/AR/template/Deduction"); |
| | | int OnModifyRow() |
| | | { |
| | | int row = dw_emp.GetNextSelectRow(1); |
| | | if (row < 1) |
| | | { |
| | | row = dw_emp.GetRow(); |
| | | if (row < 1) |
| | | { |
| | | win__::MessageBox(GetHWND(), "请选中要修改的任职信息行!", "提示", 0); |
| | | return -1; |
| | | } |
| | | } |
| | | int wid = dw_emp.GetId(); |
| | | msxml::IXMLDOMElement e = dw_emp.GetRowElement(row); |
| | | string sPersonID = e.selectSingleNode("PersonID").text; |
| | | //trace(e.xml); |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("operate", "modify"); |
| | | arg.AddArg("guid", sPersonID); |
| | | //xwin::OpenWindow("dev:xpage[HrPersonMaint.xpage]",arg); |
| | | openUrl("组织架构.vface/xpage/Hr/HrPersonMaint", arg); |
| | | return 1; |
| | | } |
| | | |
| | | dw_list.SetColumnState(L"ID", false); |
| | | dw_list.SetColumnState(L"GDNLineID", false); |
| | | dw_list.SetColumnState(L"SettlementAdjustID", false); |
| | | int OnDeleteRow() |
| | | { |
| | | int ll_row = dw_emp.GetNextSelectRow(1); |
| | | if (ll_row < 1) |
| | | { |
| | | ll_row = dw_emp.GetRow(); |
| | | if (ll_row < 1) |
| | | { |
| | | win__::MessageBox(GetHWND(), "请选中要删除的任职信息行!", "提示", 0); |
| | | return -1; |
| | | } |
| | | } |
| | | string sName = dw_emp.GetItemDisplayString(ll_row, "PersonID", 0); |
| | | if (win__::MessageBox(GetHWND(), "确定删除" + sName + "任职信息吗?", "提示", 1) != 1) |
| | | return 0; |
| | | |
| | | msxml::IXMLDOMElement ele = dw_emp.GetRowElement(ll_row); |
| | | string empid = ele.selectSingleNode("@guid").text; |
| | | |
| | | if (GetWinParam()) |
| | | { |
| | | xaserverarg arg = GetArg(); |
| | | EntityID = arg.GetArgString(L"EntityID"); |
| | | InvoiceNo = arg.GetArgString(L"InvoiceNo"); |
| | | } |
| | | trace(InvoiceNo); |
| | | OnRetrieve(InvoiceNo, EntityID); |
| | | OnAttachEvent(); |
| | | return 1; |
| | | } |
| | | xml__ x = new xml__; |
| | | x.setNativePointer(x.CreateInstance()); |
| | | xaserverarg__ args = new xaserverarg__; |
| | | args.setNativePointer(args.CreateInstance()); |
| | | args.AddArg("guid", empid); |
| | | //if(xaserver__::ExecXAction(GetServerUrl(),"[MSSqlHrEmployeeDel.xq]",args.GetString(),x) !=1) |
| | | if (url::post("OrganizationStruct/delete.Employee", args.GetString(), x) != 1) |
| | | { |
| | | string error = x.GetXmlDoc().text; |
| | | trace(error); |
| | | } |
| | | else |
| | | { |
| | | dw_emp.DeleteRow(ll_row); |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | return 1; |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | }; |
| | | int SetText() |
| | | { |
| | | win__::SetWindowText(GetHWND(), "所属组织:" + is_orgname + " 操作状态:" + is_inflag); |
| | | return 1; |
| | | } |
| | | |
| | | //xgridex双击 |
| | | int OnDoubleClicked(ref TNotifyEvent evt, int p) |
| | | { |
| | | ref DWNMHDR hdr = evt.pnmh; |
| | | int row = hdr.row; |
| | | if (row < 1 || row > dw_emp.GetRowCount()) |
| | | return 1; |
| | | msxml::IXMLDOMElement e = dw_emp.GetRowElement(row); |
| | | string sPersonID = e.selectSingleNode("PersonID").text; |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("operate", "modify"); |
| | | arg.AddArg("guid", sPersonID); |
| | | //xwin::OpenWindow("dev:xpage[HrPersonMaint.xpage]",arg); |
| | | openUrl("组织架构.vface/xpage/Hr/HrPersonMaint", arg); |
| | | return 1; |
| | | } |
| | | |
| | | //命令发布函数 |
| | | int OnCmdDispatch(string comdid) |
| | | { |
| | | if (comdid == "Save") return OnSave(); |
| | | else if (comdid == "AddRow") return OnAddRow(); |
| | | else if (comdid == "ModifyRow") return OnModifyRow(); |
| | | else if (comdid == "DeleteRow") return OnDeleteRow(); |
| | | else if (comdid == "Refresh") return OnRetrieve(is_orgid); |
| | | /*else if(comdid =="adjustorg") return OnAdjustOrg();*/ |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | //命令处理事件 |
| | | int OnXCommand(ref TXCommandEvent evt, int p) |
| | | { |
| | | return OnCmdDispatch(evt.pStrID); |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //绑定工具条点击事件 |
| | | AttachEvent("WM_XCOMMAND", OnXCommand); |
| | | //获取焦点事件,用于重置工具条 |
| | | AttachEvent("WM_SETFOCUS", OnSetFocus); |
| | | //获得树的选择事件 |
| | | AttachEvent("tv_org", "TVN_SELCHANGED", OnTreeSelChanged); |
| | | AttachEvent("tv_org", "TVN_ITEMEXPANDING", OnTreeExpanding); |
| | | AttachEvent("dw_emp", "DWV_DOUBLECLICKED", OnDoubleClicked); |
| | | } |
| | | |
| | | int OnInitial() |
| | | { |
| | | m_agentNode = new xnode__; |
| | | SetAgent(); |
| | | OnAttachEvent(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | tv_org = new treeview__; |
| | | tv_org.setNativePointer(this.GetControl("tv_org")); |
| | | dw_emp = new xdwgrid__; |
| | | dw_emp.setNativePointer(this.GetControl("dw_emp")); |
| | | dw_emp.openUrl("组织架构.vface/template/HrEmployee/list"); |
| | | //dw_emp.SetReadOnly(true); |
| | | //dw_emp.SetSelectionMode(1); |
| | | |
| | | OnInitial(); |
| | | OnCreateTree("00000000-0000-0000-0000-000000000000", 0); |
| | | int wid = tv_org.GetId(); |
| | | int root = treeview__::GetRootItem(wid); |
| | | treeview__::ExpandItem(wid, root); |
| | | return 1; |
| | | } |
| | | ] |
| | | |
| | | ] |
| | | ] |