|  |  | 
 |  |  | use "xcontrol.vframe.vbusiness.vd" | 
 |  |  | use "xbase.vframe.vbusiness.vd" | 
 |  |  | use "xcontrol.vframe.vbusiness.vd" | 
 |  |  | use "xbase.vframe.vbusiness.vd" | 
 |  |  | use "vbind.vbind.wface.vd" | 
 |  |  | use "publiccode.vutil.vbusiness.vd" | 
 |  |  | use "multi.vbind.vbind.wface.vd" | 
 |  |  | #include <wobject/xstring.hpp> | 
 |  |  | #include <xcontrol/xtreeview.hpp> | 
 |  |  | #include <xcontrol/xdwgrid.hpp> | 
 |  |  | #include <xcontrol/xcell.hpp> | 
 |  |  |  | 
 |  |  | unit trade | 
 |  |  | [ | 
 |  |  |    class ViewManpowerFileWiondow : public xframe | 
 |  |  |  | 
 |  |  | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" | 
 |  |  | #include "viewobject/view.base.hpp" | 
 |  |  |  | 
 |  |  | using xml = KXMLDOMDocument; | 
 |  |  |    class __declspec(dllexport) ViewManpowerFileWiondow : public xframe | 
 |  |  |    { | 
 |  |  |    public: | 
 |  |  |       //xdwgrid   dw_list;//新建列表时使用 | 
 |  |  |       xdwtable dw_base;//新增弹窗时使用 | 
 |  |  |       string mfid; | 
 |  |  |       xstring mfid; | 
 |  |  |       xnode   m_agentNode;   //Agent Condition | 
 |  |  |  | 
 |  |  |       bool updated; | 
 |  |  | 		 | 
 |  |  |       xstring UserNo; | 
 |  |  |    public: | 
 |  |  |       ViewManpowerFileWiondow(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} | 
 |  |  |    public: | 
 |  |  |       static ViewManpowerFileWiondow* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |       { | 
 |  |  |          ViewManpowerFileWiondow* pWin = new ViewManpowerFileWiondow(implPtr, (HWND)hWnd); | 
 |  |  |          return pWin; | 
 |  |  |       } | 
 |  |  |       /*int SetAgent() | 
 |  |  |       { | 
 |  |  |          string xfNodeAgentArea  = "agentarea"; | 
 |  |  |          xstring xfNodeAgentArea  = L"agentarea"; | 
 |  |  |          xnode anode = GetAgentNode(xfNodeAgentArea); | 
 |  |  |          if(m_agentNode) | 
 |  |  |          { | 
 |  |  | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             msxml::IXMLDOMElement xframeElement =  GetElement(); | 
 |  |  |             msxml::IXMLDOMElement agent = xframeElement.selectSingleNode("agent/"+xfNodeAgentArea+"[1]/*"); | 
 |  |  |             msxml::IXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*"); | 
 |  |  |             if(agent) | 
 |  |  |             { | 
 |  |  |                string s = agent.xml; | 
 |  |  |                xstring s = agent.xml; | 
 |  |  |                m_agentNode =  SetAgentNodeContent (anode,s); | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  | 
 |  |  |       }*/ | 
 |  |  |  | 
 |  |  |       //焦点激活处理函数 | 
 |  |  |       int OnSetFocus(ref TEvent evt, int param) | 
 |  |  |       int OnSetFocus(TEvent* evt, LPARAM p) | 
 |  |  |       { | 
 |  |  |          //重置工具条 | 
 |  |  |          SetAgent(); | 
 |  |  | 
 |  |  |       //保存数据 | 
 |  |  |       int OnSave() | 
 |  |  |       { | 
 |  |  |          xml x = new xml; | 
 |  |  |          x.setNativePointer(xml::CreateInstance()); | 
 |  |  |          xml x ; | 
 |  |  | 			 | 
 |  |  |          dw_base.AcceptText(); | 
 |  |  |          dw_base.DwUpdateAllTo(x.GetXmlDoc()); | 
 |  |  |          xaserverarg arg = new xaserverarg; | 
 |  |  |          arg.setNativePointer(xaserverarg::CreateInstance()); | 
 |  |  |          arg.AddArg("content", x.GetXml()); | 
 |  |  |          //trace(x.GetXml()); | 
 |  |  |          if (url::get("/sale/data/ManpowerFile/update", arg.GetString(), x) != 1) | 
 |  |  |          dw_base.DwUpdateAllTo(x); | 
 |  |  |          xaserverarg arg; | 
 |  |  | 			 | 
 |  |  |          arg.AddArg(L"content", x.xml()); | 
 |  |  |          //trace(x.xml()); | 
 |  |  |          if (xurl::get(L"/sale/data/ManpowerFile/update", arg.GetString(), x) != 1) | 
 |  |  |          { | 
 |  |  |             string error = x.GetXmlDoc().text; | 
 |  |  |             alert("err:" + error); | 
 |  |  |             xstring error = x.text(); | 
 |  |  |             alert(L"err:" + error); | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          //trace("返回值="+x.GetXml()); | 
 |  |  |          string str = x.GetXmlDoc().documentElement.getAttribute("text"); | 
 |  |  |          if (str == "true") | 
 |  |  |          //trace(L"返回值=L"+x.xml()); | 
 |  |  |          xstring str = x.documentElement().getAttribute(L"text"); | 
 |  |  |          if (str == L"true") | 
 |  |  |          { | 
 |  |  |             dw_base.ResetUpdateStatus(); | 
 |  |  |             CloseWindow(); | 
 |  |  |             alert("保存成功!"); | 
 |  |  |             alert(L"保存成功!"); | 
 |  |  |          } | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             alert("保存失败!"); | 
 |  |  |             alert(L"保存失败!"); | 
 |  |  |          } | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       //命令发布函数 | 
 |  |  |       int OnCmdDispatch(string comdid) | 
 |  |  |       int OnCmdDispatch(xstring comdid) | 
 |  |  |       { | 
 |  |  |          if (comdid == "xmClose") {//关闭窗口 | 
 |  |  |          if (comdid == L"xmClose") {//关闭窗口 | 
 |  |  |             CloseWindow(); | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          else if (comdid == "xmSave") {//保存窗口 | 
 |  |  |          else if (comdid == L"xmSave") {//保存窗口 | 
 |  |  |             return OnSave(); | 
 |  |  |          } | 
 |  |  |          return 0; | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       //命令处理事件 | 
 |  |  |       int OnXCommand(ref TXCommandEvent evt, int param) | 
 |  |  |       int OnXCommand(TEvent* evt, LPARAM p) | 
 |  |  |       { | 
 |  |  |          return OnCmdDispatch(evt.pStrID); | 
 |  |  |          return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       int OnAttachEvent() | 
 |  |  |       { | 
 |  |  |          //绑定工具条点击事件 | 
 |  |  |          AttachEvent("WM_XCOMMAND", OnXCommand); | 
 |  |  |          AttachEvent(L"WM_XCOMMAND", (FEvent)&ViewManpowerFileWiondow::OnXCommand); | 
 |  |  |          //获取焦点事件,用于重置工具条 | 
 |  |  |          AttachEvent("WM_SETFOCUS", OnSetFocus); | 
 |  |  |          AttachEvent("dw_base", "DWV_ITEMCHANGING", OnItemChanging); | 
 |  |  |          AttachEvent(L"WM_SETFOCUS", (FEvent)&ViewManpowerFileWiondow::OnSetFocus); | 
 |  |  |          AttachEvent(L"dw_base", L"DWV_ITEMCHANGING", (FEvent)&ViewManpowerFileWiondow::OnItemChanging); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       int OnItemChanging(ref TNotifyEvent evt, int p) | 
 |  |  |       int OnItemChanging(TEvent* evt, LPARAM p) | 
 |  |  |       { | 
 |  |  |          ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR); | 
 |  |  |          string colname = hdr.colname; | 
 |  |  |          string value = hdr.data; | 
 |  |  |          DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |          xstring colname = hdr.colname; | 
 |  |  |          xstring value = hdr.data; | 
 |  |  |          int row = hdr.row; | 
 |  |  | #if 0 | 
 |  |  |  | 
 |  |  |          if (value == "") return 1; | 
 |  |  |          string cellType = dw_base.GetColumnProp(colname, "celltype"); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |          if (value == L"") return 1; | 
 |  |  |          xstring cellType = dw_base.GetColumnProp(colname, L"celltype"); | 
 |  |  |          //alert(cellType); | 
 |  |  |          if (cellType == "xs:decimal" || cellType == "xs:integer") | 
 |  |  |          if (cellType == L"xs:decimal" || cellType == L"xs:integer") | 
 |  |  |          { | 
 |  |  |             if (value.isNumber() == false) | 
 |  |  |             { | 
 |  |  |                alert(value + "不是数字!"); | 
 |  |  |                alert(value + L"不是数字!"); | 
 |  |  |                hdr.idFrom = -1; | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  | #endif // 0 | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       int  OnRetrieve() | 
 |  |  |       { | 
 |  |  |          xml x = new xml; | 
 |  |  |          x.setNativePointer(xml::CreateInstance()); | 
 |  |  |          xaserverarg arg = new xaserverarg; | 
 |  |  |          arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |          arg.AddArg("mfid", mfid); | 
 |  |  |          if (getUrl("/sale/data/ManpowerFile/getsingle", arg.GetString(), x) != 1) | 
 |  |  |          xml x ; | 
 |  |  | 			 | 
 |  |  |          xaserverarg arg; | 
 |  |  | 			 | 
 |  |  |          arg.AddArg(L"mfid", mfid); | 
 |  |  |          if (getUrl(L"/sale/data/ManpowerFile/getsingle", arg.GetString(), x) != 1) | 
 |  |  |          { | 
 |  |  |             trace("错误信息=" + x.GetXmlDoc().text); | 
 |  |  |             trace(L"错误信息=L" + xstring(x.text())); | 
 |  |  |             return -1; | 
 |  |  |          } | 
 |  |  |          else | 
 |  |  |          { | 
 |  |  |             //trace("返回信息="+x.GetXml()); | 
 |  |  |             //trace(L"返回信息=L"+x.xml()); | 
 |  |  |             dw_base.Retrieve(x); | 
 |  |  |             dw_base.Redraw(); | 
 |  |  |          } | 
 |  |  | 
 |  |  |  | 
 |  |  |       int onload() | 
 |  |  |       { | 
 |  |  |          dw_base = GetControl("dw_base"); | 
 |  |  |          dw_base.openUrl("/sale/view/ManpowerFile/template/win"); | 
 |  |  |          mfid = ""; | 
 |  |  |          if (GetParam()) | 
 |  |  |             mfid = GetParam(); | 
 |  |  |          if (mfid != "") | 
 |  |  |          //SetArg(); | 
 |  |  |          dw_base = GetControl(L"dw_base"); | 
 |  |  |          dw_base.openUrl(L"/sale/view/ManpowerFile/template/win"); | 
 |  |  |          mfid = L""; | 
 |  |  |          if (GetWinParam()) | 
 |  |  |             mfid = GetParamString(); | 
 |  |  |          if (mfid != L"") | 
 |  |  |          { | 
 |  |  |             OnRetrieve(); | 
 |  |  |          } | 
 |  |  | 
 |  |  |          dw_base.SetRowSelectorWidth(0); | 
 |  |  |          dw_base.SetHScrollState(false); | 
 |  |  |          dw_base.SetVScrollState(false); | 
 |  |  |  | 
 |  |  |          OnAttachEvent(); | 
 |  |  |  | 
 |  |  |          UserNo = publiccode::GetUser().name; | 
 |  |  | 			 | 
 |  |  |          if (UserNo.find(L"周冉") >= 0) { | 
 |  |  |             dw_base.SetItemString(1, L"Position", L"周冉"); | 
 |  |  |          } | 
 |  |  |  | 
 |  |  | 			 | 
 |  |  |  | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  | 
 |  |  |  | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |    }; | 
 |  |  | ] | 
 |  |  |    }; |