#include <wobject/xstring.hpp> 
 | 
#include <xcontrol/xtreeview.hpp> 
 | 
#include <xcontrol/xdwgrid.hpp> 
 | 
  
 | 
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" 
 | 
#include "viewobject/view.base.hpp" 
 | 
  
 | 
using xml = KXMLDOMDocument; 
 | 
  
 | 
    class __declspec(dllexport) ApplySOItem : public xframe 
 | 
    { 
 | 
    public: 
 | 
        ApplySOItem(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} 
 | 
    public: 
 | 
        static ApplySOItem* CreateInstance(void* implPtr, void* hWnd) 
 | 
        { 
 | 
            ApplySOItem* pWin = new ApplySOItem(implPtr, (HWND)hWnd); 
 | 
            return pWin; 
 | 
        } 
 | 
  
 | 
    public: 
 | 
        xdwgrid    dw_list; 
 | 
        xnode    m_agentNode;    //Agent Condition 
 | 
  
 | 
        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 ProcessUsedArg(xaserverarg arg) 
 | 
        { 
 | 
            xstring EntityIDList = L""; 
 | 
            int ll_row = dw_list.GetNextSelectRow(1); 
 | 
            while (ll_row > 0 && ll_row <= dw_list.GetRowCount()) 
 | 
            { 
 | 
                xstring id = dw_list.GetGuid(ll_row); 
 | 
                if (EntityIDList == L"") EntityIDList = id; else EntityIDList += L"," + id; 
 | 
                ll_row = dw_list.GetNextSelectRow(ll_row + 1); 
 | 
            } 
 | 
            if (EntityIDList != L"") arg.AddArg(L"EntityID", EntityIDList); 
 | 
            //alert(EntityIDList); 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        xstring GetEntityName(LPARAM pr) 
 | 
        { 
 | 
            return L"SaleItem3"; 
 | 
        } 
 | 
  
 | 
        xstring GetEntityID(LPARAM pr) 
 | 
        { 
 | 
            int row = dw_list.GetRow(); 
 | 
            xstring id = dw_list.GetGuid(row); 
 | 
            return id; 
 | 
        } 
 | 
  
 | 
        int ViewUpdate(LPARAM pr, xstring updateItem, xaserverarg  arg) 
 | 
        { 
 | 
            if (updateItem == L"del") 
 | 
            { 
 | 
                int DelRow = dw_list.GetRow(); 
 | 
                dw_list.DeleteRow(DelRow); 
 | 
                return 1; 
 | 
            } 
 | 
            else if (updateItem == L"setstate") 
 | 
            { 
 | 
                int row = dw_list.GetRow(); 
 | 
                if (row < 1) return 1; 
 | 
  
 | 
                if (arg.GetArgString(L"billstatus") != L"") 
 | 
                { 
 | 
                    xstring billstatus = arg.GetArgString(L"billstatus"); 
 | 
                    xstring statusName = GetBillStatusName(billstatus); 
 | 
                    dw_list.SetItemString(row, L"ChkState", billstatus); 
 | 
                    dw_list.SetItemDisplayString(row, L"ChkState", statusName); 
 | 
                } 
 | 
                dw_list.Redraw(); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        //½¹µã¼¤»î´¦Àíº¯Êý 
 | 
        int OnSetFocus(TEvent* evt, LPARAM p) 
 | 
        { 
 | 
            //ÖØÖù¤¾ßÌõ 
 | 
            SetAgent(); 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
  
 | 
        /* 
 | 
        int OnApply() 
 | 
        { 
 | 
            int row =  dw_list.GetNextSelectRow(1); 
 | 
            if(row < 1) return 1; 
 | 
  
 | 
            while (row>0) 
 | 
            { 
 | 
                dw_list.SetItemString(row,L"ChkState",L"2"); 
 | 
                row =  dw_list.GetNextSelectRow(row + 1); 
 | 
            } 
 | 
            if(OnSave()==1) 
 | 
            { 
 | 
                xaserverarg arg = new xaserverarg; 
 | 
                arg.setNativePointer(arg.CreateInstance()); 
 | 
                xml x ; 
 | 
                x.setNativePointer(x.CreateInstance()); 
 | 
  
 | 
                arg.AddArg(L"FlowID",L"1A83D53D-DD12-4FDB-A274-FA8D5982AB53"); 
 | 
                arg.AddArg(L"Category",L"PurchesItem3"); 
 | 
                arg.AddArg(L"Reciever",L"admin"); 
 | 
                arg.AddArg(L"Status",L"ÒµÎñÉóºË"); 
 | 
  
 | 
                xaserverarg parg = GetParam(); 
 | 
                xstring SONo = parg.GetArgString(L"SONo"); 
 | 
  
 | 
                row =  dw_list.GetNextSelectRow(1); 
 | 
                while (row>0) 
 | 
                { 
 | 
                    arg.AddArg(L"EntityID",dw_list.GetGuid(row)); 
 | 
                    arg.AddArg(L"EntityNo",dw_list.GetItemString(row,L"GoodsNo")); 
 | 
                    arg.AddArg(L"Subject",L"ÇëºË×¼¶©µ¥"+SONo+L"²É¹ºÊý¾Ý,»õºÅΪ"+dw_list.GetItemString(row,L"GoodsNo")); 
 | 
  
 | 
                    if(url::get(L"/sale/data/PurchaseOrder/task/add", arg.GetString(),x)!=1) 
 | 
                    { 
 | 
                        xstring error = x.GetXmlDoc().text; 
 | 
                        alert(error); 
 | 
                        return -1; 
 | 
                    }else 
 | 
                    { 
 | 
                        trace(x.GetXml()); 
 | 
                    } 
 | 
                    row =  dw_list.GetNextSelectRow(row + 1); 
 | 
                } 
 | 
  
 | 
                alert(L"Ìá½»³É¹¦"); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
        */ 
 | 
        int OnAskGoodsNo() 
 | 
        { 
 | 
            int rowCount = dw_list.GetRowCount(); 
 | 
            xstring skunos = L""; 
 | 
            xstring GoodsNo1 = dw_list.GetItemString(dw_list.GetRow(), L"GoodsNo"); 
 | 
            xstring GoodsNo2 = GoodsNo1.mid(0, 1); 
 | 
            xstring GoodsNo3 = GoodsNo1.mid(1, 1); 
 | 
            xstring GoodsNo4 = GoodsNo1.mid(2, 1); 
 | 
  
 | 
            for (int i = 1; i <= rowCount; i++) 
 | 
            { 
 | 
                if (dw_list.GetItemString(i, L"SKUNo") != L"" && dw_list.GetItemString(i, L"GoodsNo") == L"" || GoodsNo1.find(L"N") >= 0 
 | 
                    || GoodsNo1.find(L"n") >= 0 || GoodsNo4.isNumber() == false && GoodsNo2.isNumber() == true && GoodsNo3.isNumber() == true) 
 | 
                { 
 | 
                    if (skunos == L"") 
 | 
                        skunos = dw_list.GetItemString(i, L"SKUNo"); 
 | 
                    else 
 | 
                        skunos += L"," + dw_list.GetItemString(i, L"SKUNo"); 
 | 
                } 
 | 
            } 
 | 
            xaserverarg arg ; 
 | 
            arg.AddArg(L"SKUNoList", skunos); 
 | 
            OpenWindow(L"dev:xpage[Product.FetchNo.vx]", arg); 
 | 
            return 1; 
 | 
        } 
 | 
        //ÃüÁî·¢²¼º¯Êý 
 | 
        int OnCmdDispatch(xstring comdid) 
 | 
        { 
 | 
            if (comdid == L"xmCancel") 
 | 
            { 
 | 
                CloseWindow(); 
 | 
                return 1; 
 | 
            } 
 | 
            else if (comdid == L"xmAskGoodsNo") 
 | 
            { 
 | 
                OnAskGoodsNo(); 
 | 
            } 
 | 
            //else if(comdid==L"xmApply") return OnApply(); 
 | 
            else if (comdid.find(L"action:", 0) >= 0) 
 | 
            { 
 | 
                xstring GoodsNo = dw_list.GetItemString(dw_list.GetRow(), L"GoodsNo"); 
 | 
                xstring GoodsNo2 = GoodsNo.mid(0, 2); 
 | 
                xstring GoodsNo4 = GoodsNo.mid(2, 1); 
 | 
  
 | 
                if (GoodsNo == L"") 
 | 
                { 
 | 
                    alert(L"¹«Ë¾»õºÅδָ¶¨"); 
 | 
                    return 0; 
 | 
                } 
 | 
                if (GoodsNo.find(L"N") >= 0 || GoodsNo.find(L"n") >= 0) { 
 | 
                    alert(L"¹«Ë¾»õºÅ´øÓÐN"); 
 | 
                    return 0; 
 | 
                } 
 | 
                if (GoodsNo4 >= L"A" && GoodsNo4 <= L"z" && GoodsNo2 >= L"22" && GoodsNo2 <= L"99") 
 | 
                { 
 | 
                    alert(L"¹«Ë¾»õºÅΪÐÂÆ·»õºÅ"); 
 | 
                    return 0; 
 | 
                } 
 | 
                xstring CType = dw_list.GetItemString(dw_list.GetRow(), L"CType"); 
 | 
  
 | 
                if (CType == L"") 
 | 
                { 
 | 
                    alert(L"¿Í»§ºÏͬ¸½¼þδÉÏ´«£¡"); 
 | 
                    return 0; 
 | 
                } 
 | 
                int ret = ProcessFlowAction(comdid, 1); 
 | 
                return ret; 
 | 
            } 
 | 
            return 0; 
 | 
        } 
 | 
  
 | 
        //ÃüÁî´¦Àíʼþ 
 | 
        int OnXCommand(TEvent* evt, LPARAM p) 
 | 
        { 
 | 
            return OnCmdDispatch(evt->xcommand.pStrID); 
 | 
        } 
 | 
  
 | 
        int OnAttachEvent() 
 | 
        { 
 | 
            //°ó¶¨¹¤¾ßÌõµã»÷ʼþ 
 | 
            AttachEvent(L"WM_XCOMMAND", (FEvent)&ApplySOItem::OnXCommand); 
 | 
            //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ 
 | 
            //AttachEvent(L"WM_SETFOCUS",OnSetFocus); 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int  OnRetrieve() 
 | 
        { 
 | 
            xml x; 
 | 
            xaserverarg arg=GetArg(); 
 | 
  
 | 
            arg.AddArg(L"id", arg.GetArgString(L"EntityNo")); 
 | 
            if (getUrl(L"/sale/data/SaleOrder/maint/item", arg.GetString(), x) != 1) 
 | 
            { 
 | 
                //trace(x.GetXmlDoc().text); 
 | 
                return -1; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                dw_list.Retrieve(x); 
 | 
                dw_list.Redraw(); 
 | 
            } 
 | 
            dw_list.SetReadOnly(true); 
 | 
            dw_list.SetSelectionMode(3); 
 | 
  
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int onload() 
 | 
        { 
 | 
             
 | 
  
 | 
            dw_list = GetControl(L"dw_list"); 
 | 
            dw_list.openUrl(L"/sale/view/SaleOrder/template/item"); 
 | 
            dw_list.SetReadOnly(true); 
 | 
            dw_list.SetColumnState(L"EnquiryPriceListID", false); 
 | 
            dw_list.SetColumnState(L"ItemID", false); 
 | 
            dw_list.SetColumnState(L"LineType", false); 
 | 
            dw_list.SetColumnState(L"Assortment", false); 
 | 
            dw_list.SetColumnState(L"ClassifyID", false); 
 | 
            dw_list.SetColumnState(L"UnitFreight", false); 
 | 
            dw_list.SetColumnState(L"CName", false); 
 | 
            dw_list.SetColumnState(L"QuoteLineID", false); 
 | 
            dw_list.SetColumnState(L"POSupplierID", false); 
 | 
            dw_list.SetColumnState(L"Submitter", false); 
 | 
            dw_list.SetColumnState(L"ScheduleShipDate", false); 
 | 
            OnAttachEvent(); 
 | 
  
 | 
            SetArg(); 
 | 
            OnRetrieve(); 
 | 
  
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int onloaded() 
 | 
        { 
 | 
            //SetAgent();             
 | 
  
 | 
            return 1; 
 | 
        } 
 | 
    }; 
 |