#include <wobject/xstring.hpp> 
 | 
#include <xcontrol/xtreeview.hpp> 
 | 
#include <xcontrol/xdwgrid.hpp> 
 | 
#include <xcontrol/xcell.hpp> 
 | 
  
 | 
  
 | 
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" 
 | 
#include "viewobject/view.base.hpp" 
 | 
#include "viewobject/productlibrary.view.hpp" 
 | 
  
 | 
using xml = KXMLDOMDocument; 
 | 
    class  __declspec(dllexport)  ProductFetchNoWin : public xframe 
 | 
    { 
 | 
    public: 
 | 
        xdwgrid    dw_list; 
 | 
  
 | 
        xnode    m_agentNode;    //Agent Condition 
 | 
    public: 
 | 
        ProductFetchNoWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} 
 | 
    public: 
 | 
        static ProductFetchNoWin* CreateInstance(void* implPtr, void* hWnd) 
 | 
        { 
 | 
            ProductFetchNoWin* pWin = new ProductFetchNoWin(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 OnRowChanged(TEvent* evt, LPARAM p) 
 | 
        { 
 | 
            DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; 
 | 
            int row = hdr.row; 
 | 
  
 | 
            /* 
 | 
            htmlctrl xs = GetControl(L"html_detail"); 
 | 
            xstring html = makeHtml(row); 
 | 
            xs.SetContent(html); 
 | 
            xs.Redraw(); 
 | 
  
 | 
            xstring id = g_xdoc_product.getData(0,L"data/Item",row,L"@guid"); 
 | 
            OnShowImage(id); 
 | 
            */ 
 | 
  
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        //½¹µã¼¤»î´¦Àíº¯Êý 
 | 
        int OnSetFocus(TEvent* evt, LPARAM p) 
 | 
        { 
 | 
            //ÖØÖù¤¾ßÌõ 
 | 
            //SetAgent(); 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int SendNotice() 
 | 
        { 
 | 
            xaserverarg arg; 
 | 
            if (dw_list.GetRowCount() < 1) return 1; 
 | 
            xstring Subject = L"±àºÅ£º" + dw_list.GetItemString(dw_list.GetRow(), L"SKUNo") + L"   Æ·Ãû£º" + dw_list.GetItemString(dw_list.GetRow(), L"CName") + L"£¬ÉêÇë»õºÅ"; 
 | 
            xstring EntityID = dw_list.GetItemString(dw_list.GetRow(), L"SKUID"); 
 | 
            xstring EntityNo = dw_list.GetItemString(dw_list.GetRow(), L"SKUNo"); 
 | 
            xstring Category = L"»õºÅÉêÇë"; 
 | 
            xstring Reciever = L"00914"; 
 | 
            xstring Content = L""; 
 | 
            //alert(L"EntityID:"+EntityID); 
 | 
            ViewObject::AddMessage( GetServerUrl(),Category, Reciever, EntityNo, EntityID, Subject, Content); 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int OnSubmit() 
 | 
        { 
 | 
            dw_list = GetControl(L"dw_list"); 
 | 
            if (dw_list.GetRowCount() < 1) return 0; 
 | 
            xml x; 
 | 
             
 | 
            dw_list.DwUpdateAllToEx(x); 
 | 
            xstring error = L""; 
 | 
            xaserverarg arg; 
 | 
            arg.AddArg(L"content", x.xml()); 
 | 
            if (xurl::get(L"/sale/data/ProductLibrary3/update/product/askgoodsno", arg.GetString(), x) != 1) 
 | 
            { 
 | 
                xstring error = x.text(); 
 | 
                trace(error); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                if (error.find(L"error") >= 0) 
 | 
                    alert(L"Ìύʧ°Ü"); 
 | 
                else 
 | 
                    alert(L"Ìá½»³É¹¦!"); 
 | 
                SendNotice(); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        /* 
 | 
        xstring makeHtml(int row) 
 | 
        { 
 | 
            xstring id = g_xdoc_product.getData(0,L"data/Item",row,L"@guid"); 
 | 
            xml x = GetGoodsPropList(id); 
 | 
            xml x1 = GetGoodsPropListEx(id); 
 | 
  
 | 
            xstring html=L"<html><style> .text{ font-weight:400} .label { font-weight:400;}</style><body style='margin:2;background-color:#ccdccc none #f0f0f0 none'>"; 
 | 
            html += L"<div ><span style='font-weight:700;width:50;font-size:10pt'  >±àºÅ:</span><span  style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"SKUNo")+ 
 | 
                        "</span> <span style='font-weight:700;width:50;font-size:10pt' >ÀàÏî:</span><span  style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"RefNo")+ 
 | 
                        "</span></div>"; 
 | 
            html +=  L"<div ><span style='font-weight:700;width:50;font-size:10pt'  >¹«Ë¾ÐͺÅ:</span><span  style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"GoodsNo")+ 
 | 
                        "</span></div>" ; 
 | 
            html +=  L"<div ><span style='font-weight:700;width:50;font-size:10pt'  >Æ·Ãû:</span><span  style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"CName")+ 
 | 
                        "</span></div>" ; 
 | 
            if(dw_list.GetItemString(row,L"CSpec")!=L"") 
 | 
                html +=  L"<div ><span style='font-weight:700;width:50;font-size:10pt'  >¹æ¸ñ:</span><span  style='width:90;font-size:10pt'>" + dw_list.GetItemString(row,L"CSpec")+ 
 | 
                            "</span></div>" ; 
 | 
  
 | 
            KXMLDOMNodeList fieldsEx = x1.GetXmlDoc().selectNodes(L"data/field"); 
 | 
            xstring ls_detail=L""; 
 | 
            xstring ls_item =L""; 
 | 
            xstring name; 
 | 
            xstring label; 
 | 
            int len = fieldsEx.length; 
 | 
            int i= 0; 
 | 
  
 | 
            for(i=0;i<len; true) 
 | 
            { 
 | 
                int cnt  = 0; 
 | 
                ls_item = L""; 
 | 
                while(cnt < 2) 
 | 
                { 
 | 
                    name = fieldsEx.item(i).selectSingleNode(L"@name").text; 
 | 
                    label  = fieldsEx.item(i).selectSingleNode(L"@label").text; 
 | 
                    ls_item += L"<td>" + label + L"</td>" + L"<td style='text-align:center'>" + g_xdoc_product.getData(0,L"data/Item",row,name) + L"</td>" ; 
 | 
                    cnt++; 
 | 
                    i++; 
 | 
                    if(i ==len)break; 
 | 
                } 
 | 
                ls_detail += L"<tr>" + ls_item + L"</tr>"; 
 | 
            } 
 | 
            html +=  L"<div style='margin-left:8px;margin-right:16px;'>" + 
 | 
                        +L"<table><colgroup span='1' width='70'/><colgroup span='1' width='120'/><colgroup span='1' width='70'/><colgroup span='1' width='120'/>" 
 | 
                        + ls_detail 
 | 
                        +L"</table>" 
 | 
                        +L"</div>" ; 
 | 
  
 | 
            xstring ls_star=L""; 
 | 
            KXMLDOMNodeList fields  = x().selectNodes(L"data/field"); 
 | 
            len = fields.length; 
 | 
  
 | 
            ls_detail = L""; 
 | 
            if(len > 0) 
 | 
                html +=  L"<div ><span style='font-weight:700;width:50;font-size:10pt'  >¼¼ÊõÒªÇó:</span></div>" ; 
 | 
            for(i=0;i<len; true) 
 | 
            { 
 | 
                ls_item=L""; 
 | 
  
 | 
                int count = 0; 
 | 
                while(count < 2) 
 | 
                { 
 | 
                    name = fields.item(i).selectSingleNode(L"@name").text; 
 | 
                    label  = fields.item(i).selectSingleNode(L"@label").text; 
 | 
                    if(name==L"QualityTerm" || name==L"PackTerm" || label==L"ÖÊÁ¿" || label==L"°ü×°ÖÊÁ¿" || label==L"¼¼ÊõÒªÇó") 
 | 
                    { 
 | 
                        i++; 
 | 
                        if(i >= len)count = 2; 
 | 
                        continue; 
 | 
                    } 
 | 
                    else if(g_xdoc_product.getData(0,L"data/Item",row,name)==L"") 
 | 
                    { 
 | 
                        KXMLDOMNodeList options = fields.item(i).selectNodes(L"item"); 
 | 
                        int tlen = options.length; 
 | 
                        xstring terms = L"" ; 
 | 
                        for(int k=0; k<tlen; k++) 
 | 
                        { 
 | 
                            if(options.item(k).text) 
 | 
                            { 
 | 
                                if(k>0) terms += L", L"; 
 | 
                                terms += L"[" + options.item(k).text +L"]"; 
 | 
                            } 
 | 
                        } 
 | 
                        ls_star += L"<div ><span style='font-weight:700;width:50;font-size:10pt'  >" + label +L"*:</span><span  style='width:90;font-size:10pt'>" + terms + L"</span></div>" ; 
 | 
                    }else 
 | 
                    { 
 | 
                        ls_item = L"<td>" + label + L"</td>" + L"<td>" + g_xdoc_product.getData(0,L"data/Item",row,name) + L"</td>" ; 
 | 
                        count++; 
 | 
                    } 
 | 
                    i++; 
 | 
                    if(i >= len)count = 2; 
 | 
                } 
 | 
                ls_item = L"<tr>" + ls_item + L"</tr>"; 
 | 
                ls_detail += ls_item; 
 | 
            } 
 | 
  
 | 
            html +=  L"<div style='margin-left:8px;margin-right:16px;'>" + 
 | 
                        +L"<table><colgroup span='1' width='70'/><colgroup span='1' width='120'/><colgroup span='1' width='70'/><colgroup span='1' width='120'/>" 
 | 
                        + ls_detail 
 | 
                        +L"</table>" 
 | 
                        +L"</div>" ; 
 | 
            if(dw_list.GetItemString(row,L"QualityTerm")!=L"") 
 | 
            { 
 | 
                html +=  L"<div style='height:12px'/>"; 
 | 
                html +=  L"<div ><span style='font-weight:700;width:50;font-size:10pt'  >ÖÊÁ¿:</span></div>" ; 
 | 
                html +=  L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt'  >" + dw_list.GetItemString(row,L"QualityTerm") +  L"</span></div>" ; 
 | 
            } 
 | 
  
 | 
            if(dw_list.GetItemString(row,L"PackTerm")!=L"") 
 | 
            { 
 | 
                html +=  L"<div style='height:12px'/>"; 
 | 
                html +=  L"<div ><span style='font-weight:700;width:50;font-size:10pt'  >°ü×°ÖÊÁ¿:</span></div>" ; 
 | 
                html +=  L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + dw_list.GetItemString(row,L"PackTerm") +  L"</span></div>" ; 
 | 
            } 
 | 
  
 | 
            if(g_xdoc_product.getData(0,L"data/Item",row,L"Remark")!=L"") 
 | 
            { 
 | 
                //html +=  L"<div style='height:12px'/>"; 
 | 
                html +=  L"<div ><span style='font-weight:700;width:50;font-size:10pt'  >±¸×¢:</span></div>" ; 
 | 
                html +=  L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + g_xdoc_product.getData(0,L"data/Item",row,L"Remark") +  L"</span></div>" ; 
 | 
            } 
 | 
  
 | 
            html +=  L"<div style='height:24px'/>"; 
 | 
  
 | 
            //ÐDZêÏî 
 | 
            html += ls_star; 
 | 
  
 | 
  
 | 
            html += L"</body></html>"; 
 | 
            //trace(html); 
 | 
            return html; 
 | 
        } 
 | 
        */ 
 | 
  
 | 
        //ÃüÁî·¢²¼º¯Êý 
 | 
        int OnCmdDispatch(xstring comdid) 
 | 
        { 
 | 
            if (comdid == L"xmSubmit") 
 | 
            { 
 | 
                return OnSubmit(); 
 | 
            } 
 | 
            if (comdid == L"xmCancel") 
 | 
            { 
 | 
                CloseWindow(); 
 | 
                return 1; 
 | 
            } 
 | 
            return 0; 
 | 
        } 
 | 
  
 | 
        //ÃüÁî´¦Àíʼþ 
 | 
        int OnXCommand(TEvent* evt, LPARAM p) 
 | 
        { 
 | 
            return OnCmdDispatch(evt->xcommand.pStrID); 
 | 
        } 
 | 
  
 | 
        int OnAttachEvent() 
 | 
        { 
 | 
            AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&ProductFetchNoWin::OnRowChanged); 
 | 
            //°ó¶¨¹¤¾ßÌõµã»÷ʼþ 
 | 
            AttachEvent(L"WM_XCOMMAND", (FEvent)&ProductFetchNoWin::OnXCommand); 
 | 
            //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ 
 | 
            AttachEvent(L"WM_SETFOCUS", (FEvent)&ProductFetchNoWin::OnSetFocus); 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        /* 
 | 
        int  OnRetrieve() 
 | 
        { 
 | 
            xml x = new.xml(); 
 | 
            x.setNativePointer(xml::CreateInstance()); 
 | 
            xaserverarg arg = new xaserverarg; 
 | 
            arg.setNativePointer(arg.CreateInstance()); 
 | 
            arg.AddArg(L"xxx",L"xxx"); 
 | 
            if (getUrl(L"",arg.GetString(),x)!=1) 
 | 
            { 
 | 
                trace(x().text); 
 | 
                return -1; 
 | 
            }else 
 | 
            { 
 | 
                //dw_list.Retrieve(x); 
 | 
                //dw_list.Redraw(); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
        */ 
 | 
  
 | 
        int onload() 
 | 
        { 
 | 
            SetArg(); 
 | 
            dw_list = GetControl(L"dw_list"); 
 | 
            dw_list.SetDataObject(ProductLibraryView::GetMaintListForm3(L"")); 
 | 
            dw_list.SetColumnState(L"SKUID", false); 
 | 
            dw_list.SetColumnState(L"category1", false); 
 | 
            dw_list.SetColumnState(L"Submitter1", false); 
 | 
  
 | 
            if (GetWinParam()) 
 | 
            { 
 | 
                xaserverarg arg=GetArg(); 
 | 
                xml x; 
 | 
                 
 | 
                if (xurl::get(L"/sale/data/ProductLibrary3/data/list/skunolist", arg.GetString(), x) != 1) 
 | 
                { 
 | 
                    xstring error = x.text(); 
 | 
                    trace(error); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                     
 | 
                    dw_list.Retrieve(x); 
 | 
                    dw_list.Redraw(); 
 | 
                } 
 | 
            } 
 | 
            OnAttachEvent(); 
 | 
            dw_list.SetReadOnly(true); 
 | 
  
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int onloaded() 
 | 
        { 
 | 
            //SetAgent();             
 | 
  
 | 
            return 1; 
 | 
        } 
 | 
    }; 
 |