|  |  | 
 |  |  | #include <xcontrol/xcombobox.hpp> | 
 |  |  |  | 
 |  |  | #include <vbusiness/vutil/publiccode.vutil.vbusiness.hpp> | 
 |  |  | #include "viewobject/view.base.hpp"" | 
 |  |  | #include "viewobject/view.base.hpp" | 
 |  |  |  | 
 |  |  |  | 
 |  |  | using xml = KXMLDOMDocument; | 
 |  |  | 
 |  |  | { | 
 |  |  | public: | 
 |  |  |    ViewTotalWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} | 
 |  |  | public: | 
 |  |  |    static ViewTotalWin* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |    { | 
 |  |  |       return new ViewTotalWin(implPtr, (HWND)hWnd); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  | public: | 
 |  |  |    xdwgrid   dw_list; | 
 |  |  |    xoffice    dw_office; | 
 |  |  |    xcell      dw_cell; | 
 |  |  | 
 |  |  |  | 
 |  |  |       int hCursor = 0; | 
 |  |  |       if (comdid == L"xmSearch") return OnSearch(); | 
 |  |  |  | 
 |  |  |       if (comdid == L"xmOwner") return OnOwnerData(); | 
 |  |  |       //if(UserNo !=L"00603") | 
 |  |  |       //{ | 
 |  |  |       if (comdid == L"xmAnalysis") | 
 |  |  | 
 |  |  |             Content = t.selectSingleNode(L"Content").text(); | 
 |  |  |          } | 
 |  |  |  | 
 |  |  |          xaserverarg arg1 ; | 
 |  |  |          xaserverarg arg1 =GetArg(); | 
 |  |  |          arg1.AddArg(L"value", Content); | 
 |  |  |          OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg1); | 
 |  |  |          return 1; | 
 |  |  | 
 |  |  |             if (argUrl != L"") | 
 |  |  |             { | 
 |  |  |                xaserverarg ar ; | 
 |  |  |                ar.setNativePointer(ar.CreateInstance()); | 
 |  |  |                //ar.setNativePointer(ar.CreateInstance()); | 
 |  |  |                ar.AddArg(L"argurl", argUrl); | 
 |  |  |                if (argStr != L"") | 
 |  |  |                   ar.AddArg(L"arg", argStr); | 
 |  |  | 
 |  |  |       for (int i = 1; i < dw.GetColumnCount(); i++) | 
 |  |  |       { | 
 |  |  |          xstring colname = dw.GetColumnName(i); | 
 |  |  |          if (str.find(L"!" + colname + L",L") >= 0) | 
 |  |  |          if (str.find(L"!" + colname + L",") >= 0) | 
 |  |  |          { | 
 |  |  |             dw.SetColumnState(colname, false); | 
 |  |  |             dw.SetColumnState((LPCTSTR)colname.c_str(), false); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  | 
 |  |  |          HCURSOR hCursor = xutil::SetCursorWait(); | 
 |  |  |          KXMLDOMElement e = xcombobox::GetItemData(evt->command.hCtrl, h); | 
 |  |  |          SwitchReport(e); | 
 |  |  |          PostMessage(GetHWND(), 0x401, L"xmQuery", 0); | 
 |  |  |          PostMessage(GetHWND(), 0x401, (WPARAM)L"xmQuery", 0); | 
 |  |  |          //OnCmdDispatch(L"xmQuery"); | 
 |  |  |          xutil::RestoreCursor(hCursor); | 
 |  |  |       } | 
 |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnOwnerData() | 
 |  |  |    { | 
 |  |  |       int ret = MessageBox(GetHWND(), L"是否更新归属数据?\n更新过程预计需要些时间,如果中间弹出等待时间过长的提示,请点击中间重试按钮,或等待到一定时间再点击", L"提示", 0x4 /*yesno*/); | 
 |  |  |       if (ret != 6 /*IDYES */) return 1; | 
 |  |  |  | 
 |  |  |       xml x; | 
 |  |  |       HCURSOR hCursor = xutil::SetCursorWait(); | 
 |  |  |       if (xurl::get(L"/sale/data/CustomerV3/owner/reload", L"", x) != 1) | 
 |  |  |       { | 
 |  |  |          xutil::RestoreCursor(hCursor); | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  |          xutil::RestoreCursor(hCursor); | 
 |  |  |          alert(x.text()); | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    //命令处理事件 | 
 |  |  |    int OnXCommand(TEvent* evt, int param) | 
 |  |  |    { | 
 |  |  |       return OnCmdDispatch(evt->command.pStrID); | 
 |  |  |       return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int SendImageMessage(int row) | 
 |  |  |    { | 
 |  |  |       if (dw_list.GetItemString(row, L"GDNLineID") != L"") | 
 |  |  |          SendMessage(hWndImageView, 0x401, (WPARAM)(L"xmRetrieve:GDNLineID:" + dw_list.GetItemString(row, L"GDNLineID"), 0).c_str()); | 
 |  |  |          SendMessage(hWndImageView, 0x401, (WPARAM)(L"xmRetrieve:GDNLineID:" + dw_list.GetItemString(row, L"GDNLineID")).c_str(),0); | 
 |  |  |       else if (dw_list.GetItemString(row, L"ItemID") != L"") | 
 |  |  |          SendMessage(hWndImageView, 0x401, (WPARAM)L"xmRetrieve:SKUID:" + dw_list.GetItemString(row, L"ItemID"), 0); | 
 |  |  |          SendMessage(hWndImageView, 0x401, (WPARAM)(L"xmRetrieve:SKUID:" + dw_list.GetItemString(row, L"ItemID")).c_str(), 0); | 
 |  |  |       else if (dw_list.GetItemString(row, L"SKUID") != L"") | 
 |  |  |          SendMessage(hWndImageView, 0x401, (WPARAM)L"xmRetrieve:SKUID:" + dw_list.GetItemString(row, L"SKUID"), 0); | 
 |  |  |          SendMessage(hWndImageView, 0x401, (WPARAM)(L"xmRetrieve:SKUID:" + dw_list.GetItemString(row, L"SKUID")).c_str(), 0); | 
 |  |  |       else if (dw_list.GetItemString(row, L"GoodsNo") != L"") | 
 |  |  |          SendMessage(hWndImageView, 0x401, (WPARAM)L"xmRetrieve:GoodsNo:" + dw_list.GetItemString(row, L"GoodsNo"), 0); | 
 |  |  |          SendMessage(hWndImageView, 0x401, (WPARAM)(L"xmRetrieve:GoodsNo:" + dw_list.GetItemString(row, L"GoodsNo")).c_str(), 0); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnDWClick(ref TNotifyEvent evt, int p) | 
 |  |  |    int OnDWClick(TEvent* evt, int p) | 
 |  |  |    { | 
 |  |  |       ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR); | 
 |  |  |       DWNMHDR&  hdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |       xstring value = hdr.data; | 
 |  |  |       xstring colname = hdr.colname; | 
 |  |  |       int row = hdr.row; | 
 |  |  | 
 |  |  |       } | 
 |  |  |       else if (colname == L"HasImage") | 
 |  |  |       { | 
 |  |  |          xwin pwin = OpenWindow(L"dev:xpage[testImage.vx]", 0); | 
 |  |  |          hWndImageView = pwin.GetHWND(); | 
 |  |  |          xwin* pwin = OpenWindow(L"dev:xpage[testImage.vx]", 0); | 
 |  |  |          hWndImageView = pwin->GetHWND(); | 
 |  |  |          SendImageMessage(row); | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnRowChanged(ref TNotifyEvent evt, int p) | 
 |  |  |    int OnRowChanged(TEvent* evt, int p) | 
 |  |  |    { | 
 |  |  |  | 
 |  |  |       ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR); | 
 |  |  |       DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |       int row = hdr.row; | 
 |  |  |       if (row < 1) return 1; | 
 |  |  |  | 
 |  |  | 
 |  |  |    int ShowRetrieveingTip() | 
 |  |  |    { | 
 |  |  |       dataretrieveing = true; | 
 |  |  |       xwin pwin = OpenWindow(L"dev:xpage[TestRetrieveing.vx]", 0); | 
 |  |  |       hWndRetrieveTip = pwin.GetHWND(); | 
 |  |  |       xwin* pwin = OpenWindow(L"dev:xpage[TestRetrieveing.vx]", 0); | 
 |  |  |       hWndRetrieveTip = pwin->GetHWND(); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int CloseRetrieveTip() | 
 |  |  |    { | 
 |  |  |       dataretrieveing = false; | 
 |  |  |       SendMessage(hWndRetrieveTip, 0x401, L"RetrieveFinished", 0); | 
 |  |  |       SendMessage(hWndRetrieveTip, 0x401, (WPARAM)L"RetrieveFinished", 0); | 
 |  |  |       hWndRetrieveTip = 0; | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnRetrieveFinished(ref TNotifyEvent evt, int p) | 
 |  |  |    int OnRetrieveFinished(TEvent* evt, int p) | 
 |  |  |    { | 
 |  |  |       CloseRetrieveTip(); | 
 |  |  |       //dataretrieveing = false; | 
 |  |  | 
 |  |  |    int OnAttachEvent() | 
 |  |  |    { | 
 |  |  |       //绑定工具条点击事件 | 
 |  |  |       AttachEvent(L"WM_XCOMMAND", OnXCommand); | 
 |  |  |       AttachEvent(L"WM_XCOMMAND", (FEvent)&ViewTotalWin::OnXCommand); | 
 |  |  |       //获取焦点事件,用于重置工具条 | 
 |  |  |       AttachEvent(L"WM_SETFOCUS", OnSetFocus); | 
 |  |  |       AttachEvent(L"cb_report", L"CBN_SELCHANGE", OnCombboChanged); | 
 |  |  |       AttachEvent(L"dw_report", L"DWV_CLICKED", OnDWClick); | 
 |  |  |       AttachEvent(L"dw_report", L"DWV_ROWFOCUSCHANGED", OnRowChanged);//绑定行更改触发事件OnRowChanged | 
 |  |  |       AttachEvent(L"dw_report", (0x400 + 81).toString(), OnRetrieveFinished); | 
 |  |  |       AttachEvent(L"WM_SETFOCUS", (FEvent)&ViewTotalWin::OnSetFocus); | 
 |  |  |       AttachEvent(L"cb_report", L"CBN_SELCHANGE", (FEvent)&ViewTotalWin::OnCombboChanged); | 
 |  |  |       AttachEvent(L"dw_report", L"DWV_CLICKED", (FEvent)&ViewTotalWin::OnDWClick); | 
 |  |  |       AttachEvent(L"dw_report", L"DWV_ROWFOCUSCHANGED", (FEvent)&ViewTotalWin::OnRowChanged);//绑定行更改触发事件OnRowChanged | 
 |  |  |       AttachEvent(L"dw_report", xstring(0x400 + 81), (FEvent)&ViewTotalWin::OnRetrieveFinished); | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int  OnRetrieve(xstring dataurl, xstring argstr) | 
 |  |  | 
 |  |  |       if (dataretrieveing) return -1; | 
 |  |  |       dw_list.Reset(); | 
 |  |  |  | 
 |  |  |       xml x = new.xml(); | 
 |  |  |       x.setNativePointer(xml::CreateInstance()); | 
 |  |  |       xml x ; | 
 |  |  |       xaserverarg arg ; | 
 |  |  |        | 
 |  |  |       arg.AddArg(L"arg", argstr); | 
 |  |  | 
 |  |  |       xstring sheettype = rptEle.getAttribute(L"reporttype"); | 
 |  |  |       if (sheettype == L"") sheettype = L"report"; | 
 |  |  |       //ShowRetrieveingTip(); | 
 |  |  |       if (url::get(dataurl, arg.GetString(), x) != 1) | 
 |  |  |       if (xurl::get(dataurl, arg.GetString(), x) != 1) | 
 |  |  |       { | 
 |  |  |  | 
 |  |  |          trace(L"错误信息=L" + x.text); | 
 |  |  |          trace((xstring)L"错误信息=L" + x.text()); | 
 |  |  |          dw_list.Redraw(); | 
 |  |  |          return -1; | 
 |  |  |       } | 
 |  |  | 
 |  |  |          } | 
 |  |  |          else if (sheettype == L"office") | 
 |  |  |          { | 
 |  |  |             dw_office.LoadTemplate(x); | 
 |  |  |             dw_office.LoadTemplate(x,0); | 
 |  |  |             for (int i = 0; i < dw_office.GetSheetCount(); i++) | 
 |  |  |             { | 
 |  |  |                xcell sheet = dw_office.GetSheet(i); | 
 |  |  | 
 |  |  |  | 
 |  |  |    xml getReportSet(xstring category) | 
 |  |  |    { | 
 |  |  |       xml x = new.xml(); | 
 |  |  |       x.setNativePointer(xml::CreateInstance()); | 
 |  |  |       xml x ; | 
 |  |  |       xaserverarg arg ; | 
 |  |  |        | 
 |  |  |       arg.AddArg(L"category", category); | 
 |  |  |       if (url::get(L"/sale/data/Total3/reportset", arg.GetString(), x) != 1) | 
 |  |  |       if (xurl::get(L"/sale/data/Total3/reportset", arg.GetString(), x) != 1) | 
 |  |  |       { | 
 |  |  |          return 0; | 
 |  |  |       } | 
 |  |  | 
 |  |  |  | 
 |  |  |    xstring GetReportFieldRole() | 
 |  |  |    { | 
 |  |  |       xml x = new.xml(); | 
 |  |  |       x.setNativePointer(xml::CreateInstance()); | 
 |  |  |       xml x ; | 
 |  |  |       xaserverarg arg ; | 
 |  |  |        | 
 |  |  |       if (url::get(L"/sale/data/Total3/report/field", arg.GetString(), x) != 1) | 
 |  |  |       if (xurl::get(L"/sale/data/Total3/report/field", arg.GetString(), x) != 1) | 
 |  |  |       { | 
 |  |  |          return ""; | 
 |  |  |          return L""; | 
 |  |  |       } | 
 |  |  |       xstring str = x.text; | 
 |  |  |       xstring str = x.text(); | 
 |  |  |       return str; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  | 
 |  |  |       fieldRoleStr = GetReportFieldRole(); | 
 |  |  |  | 
 |  |  |       argStr = L""; | 
 |  |  |       rptEle = 0; | 
 |  |  |       xcombobox xc = GetControl(L"cb_report"); | 
 |  |  |  | 
 |  |  |       m_category = L"total/trade"; | 
 |  |  |       if (GetParam()) { | 
 |  |  |          xaserverarg arg ; | 
 |  |  |          arg.setNativePointer(GetParam()); | 
 |  |  |       SetArg(); | 
 |  |  |       if (GetWinParam()) { | 
 |  |  |          xaserverarg arg = GetArg(); | 
 |  |  |          m_category = arg.GetArgString(L"category"); | 
 |  |  |       } | 
 |  |  |       xml x = getReportSet(m_category); | 
 |  |  |       if (x) | 
 |  |  |       { | 
 |  |  |          KXMLDOMNodeList nlist = x.selectNodes(L"//reports/report"); | 
 |  |  |          int len = nlist.length; | 
 |  |  |          int len = nlist.length(); | 
 |  |  |          for (int i = 0; i < len; i++) | 
 |  |  |          { | 
 |  |  |             KXMLDOMElement rpt = nlist.item(i); | 
 |  |  |             xstring name = rpt.getAttribute(L"name"); | 
 |  |  |             xcombobox::AddItem(xc.GetId(), name, trust(rpt as int)); | 
 |  |  |             xc.AddItem( name, rpt.ptr()); | 
 |  |  |             if (i == 0) xc.SetText(name); | 
 |  |  |             if (i == 0) rptEle = rpt; | 
 |  |  |          } |