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