#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) ListAP : public xframe 
 | 
    { 
 | 
    public: 
 | 
        xstring apType; 
 | 
        xstring DatePicker; 
 | 
        xstring DatePickerOne; 
 | 
        xdwgrid    dw_list; 
 | 
        xdwtable dw_arg; 
 | 
        xnode    m_agentNode;    //Agent Condition 
 | 
  
 | 
    public: 
 | 
        ListAP(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} 
 | 
    public: 
 | 
        static ListAP* CreateInstance(void* implPtr, void* hWnd) 
 | 
        { 
 | 
            ListAP* pWin = new ListAP(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 OnSetFocus(TEvent* evt, LPARAM param) 
 | 
        { 
 | 
            //ÖØÖù¤¾ßÌõ 
 | 
            SetAgent(); 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        xstring GetPayType() 
 | 
        { 
 | 
            xcombobox cbx_type = GetControl(L"cbx_type"); 
 | 
            int h = xcombobox::GetCurSel(cbx_type.GetHWND()); 
 | 
            if (h < 0) return L""; 
 | 
            return xcombobox::GetLBText(cbx_type.GetHWND(), h); 
 | 
        } 
 | 
  
 | 
        xstring GetEntityName(LPARAM pr) 
 | 
        { 
 | 
            return L"AP3"; 
 | 
        } 
 | 
  
 | 
        xstring GetEntityIDName(LPARAM /*param*/ pr) 
 | 
        { 
 | 
            return L"APID"; 
 | 
        } 
 | 
  
 | 
        xstring GetEntityID(LPARAM /*param*/ pr) 
 | 
        { 
 | 
            return dw_list.GetItemString(dw_list.GetRow(), L"APID"); 
 | 
        } 
 | 
  
 | 
        int ViewUpdate(LPARAM pr, xstring updateItem, xaserverarg  arg) 
 | 
        { 
 | 
            if (updateItem == L"del") 
 | 
            { 
 | 
                int DelRow = dw_list.GetRow(); 
 | 
                dw_list.DeleteRow(DelRow); 
 | 
                return 1; 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int OnBank() 
 | 
        { 
 | 
            xaserverarg arg; 
 | 
             
 | 
            OpenWindow(L"dev:xpage[APBank.vx]", arg); 
 | 
            if (arg.GetArgString(L"result") == L"ok") 
 | 
            { 
 | 
                int ll_row = dw_list.GetNextSelectRow(1); 
 | 
                dw_list.AcceptText(); 
 | 
  
 | 
                while (ll_row > 0 && ll_row <= dw_list.GetRowCount()) 
 | 
                { 
 | 
                    dw_list.SetItemString(ll_row, L"PayedTerm", arg.GetArgString(L"PayedTerm")); 
 | 
                    dw_list.SetItemString(ll_row, L"PayedBank", arg.GetArgString(L"PayedBank")); 
 | 
                    dw_list.SetItemString(ll_row, L"PayedBankNo", arg.GetArgString(L"PayedBankNo")); 
 | 
                    ll_row = dw_list.GetNextSelectRow(ll_row + 1); 
 | 
                } 
 | 
                dw_list.Redraw(); 
 | 
                return 1; 
 | 
            } 
 | 
            else return 1; 
 | 
        } 
 | 
  
 | 
        //ÃüÁî·¢²¼º¯Êý 
 | 
        int OnCmdDispatch(xstring comdid) 
 | 
        { 
 | 
            if (comdid == L"xmBank") return OnBank(); 
 | 
            if (comdid == L"xmSave") return OnSave(); 
 | 
            if (comdid == L"xmAnalysis") return OnAnalysis(); 
 | 
            if (comdid == L"xmRefresh" || comdid == L"xmSearch") 
 | 
            { 
 | 
                xstring payTypeOne = GetPayType(); 
 | 
                if (payTypeOne == L"ÒѸ¶»õ¿î" || payTypeOne == L"´ý¸¶»õ¿î") 
 | 
                { 
 | 
                    return OnRetrieveEx(apType, DatePicker); 
 | 
                } 
 | 
                else if (payTypeOne == L"Ô¤¸¶»õ¿î") 
 | 
                { 
 | 
                    apType = L"001"; 
 | 
                    return OnRetrieveEx(apType, DatePicker); 
 | 
                } 
 | 
                else if (payTypeOne == L"Ô¤¸¶»õ¿î(Òѳå)L") 
 | 
                { 
 | 
                    apType = L"001"; 
 | 
                    return OnRetrieveEx1(apType, DatePickerOne); 
 | 
                } 
 | 
  
 | 
            } 
 | 
            if (comdid == L"xmAddRow") 
 | 
            { 
 | 
                xstring payType = GetPayType(); 
 | 
                if (payType == L"ÒѸ¶»õ¿î" || payType == L"´ý¸¶»õ¿î") 
 | 
                    OpenWindow(L"dev:xpage[APNew3.warizd.vx]"); 
 | 
                else if (payType == L"Ô¤¸¶»õ¿î" || payType == L"Ô¤¸¶»õ¿î(Òѳå)L") 
 | 
                { 
 | 
                    xaserverarg arg1; 
 | 
                     
 | 
                    arg1.AddArg(L"APType", apType); 
 | 
                     
 | 
                    OpenWindow(L"dev:xpage[maint.ap.vx]", arg1); 
 | 
                } 
 | 
                return 1; 
 | 
            } 
 | 
            if (comdid == L"xmSaveAs") 
 | 
            { 
 | 
                dw_list.SaveAs(L""); 
 | 
                return 1; 
 | 
            } 
 | 
            if (comdid == L"xmModifyRow") 
 | 
            { 
 | 
  
 | 
                int row = dw_list.GetRow(); 
 | 
                if (row < 1) return 1; 
 | 
                KXMLDOMElement ele = dw_list.GetRowElement(row); 
 | 
                xstring APID = ele.selectSingleNode(L"APID").text(); 
 | 
                 
 | 
                xaserverarg arg; 
 | 
                 
 | 
                arg.AddArg(L"APID", APID); 
 | 
                arg.AddArg(L"APType", apType); 
 | 
                 
 | 
                OpenWindow(L"dev:xpage[maint.ap.vx]", arg); 
 | 
                return 1; 
 | 
            } 
 | 
            if (comdid.find(L"action:", 0) >= 0) 
 | 
            { 
 | 
                xstring payType1 = GetPayType(); 
 | 
                if (payType1 == L"ÒѸ¶»õ¿î" || payType1 == L"Ô¤¸¶»õ¿î") ProcessFlowAction(comdid, 1); 
 | 
            } 
 | 
            return 0; 
 | 
        } 
 | 
  
 | 
        int OnDoubleClicked(TEvent* evt, LPARAM p) 
 | 
        { 
 | 
            return OnCmdDispatch(L"xmModifyRow"); 
 | 
        } 
 | 
  
 | 
        int OnCombboChanged(TEvent* evt, int lParam) 
 | 
        { 
 | 
            xstring id = L""; 
 | 
            xstring name = L""; 
 | 
            int h = xcombobox::GetCurSel(evt->command.hCtrl); 
 | 
            if (h > -1) 
 | 
            { 
 | 
                xstring txt = (string)xcombobox::GetLBText(evt->command.hCtrl, h); 
 | 
                apType = L"---"; 
 | 
                if (txt == L"ÒѸ¶»õ¿î") 
 | 
                { 
 | 
                    dw_list.openUrl(L"/sale/view/AP/template/AP/list1"); 
 | 
                    apType = L"000"; 
 | 
                    OnRetrieveEx(apType, DatePicker); 
 | 
                } 
 | 
                else if (txt == L"´ý¸¶»õ¿î") 
 | 
                { 
 | 
                    dw_list.openUrl(L"/sale/view/AP/template/AP/list2"); 
 | 
                    OnRetrieveEx(apType, DatePicker); 
 | 
                } 
 | 
                else if (txt == L"Ô¤¸¶»õ¿î") 
 | 
                { 
 | 
                    dw_list.openUrl(L"/sale/view/AP/template/AP/list3"); 
 | 
                    apType = L"001"; 
 | 
                    OnRetrieveEx(apType, DatePicker); 
 | 
                } 
 | 
                else if (txt == L"Ô¤¸¶»õ¿î(Òѳå)L") 
 | 
                { 
 | 
                    dw_list.openUrl(L"/sale/view/AP/template/AP/list3"); 
 | 
                    apType = L"001"; 
 | 
                    OnRetrieveEx1(apType, DatePickerOne); 
 | 
                } 
 | 
  
 | 
                dw_list.SetColumnState(L"APID", false); 
 | 
  
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        //ÃüÁî´¦Àíʼþ 
 | 
        int OnXCommand(TEvent* evt, LPARAM param) 
 | 
        { 
 | 
            return OnCmdDispatch(evt->xcommand.pStrID); 
 | 
        } 
 | 
  
 | 
        int OnItemChanged(TEvent* evt, LPARAM p) 
 | 
        { 
 | 
            //if(datareading) return 0; 
 | 
            HCURSOR HCursor = xutil::SetCursorWait(); 
 | 
            DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; 
 | 
            int row = hdr.row; 
 | 
            xstring col = hdr.colname; 
 | 
            xstring data = hdr.data; 
 | 
            xstring ETD = L""; 
 | 
            if (col == L"InvoiceNo") 
 | 
            { 
 | 
                if (dw_list.GetItemString(row, L"InvoiceNo") != L"") 
 | 
                { 
 | 
                    xml x12 = ViewObject::RetrieveData(L"/sale/data/AP/GetInvoiceNoEx", L"InvoiceNo", dw_list.GetItemString(row, L"InvoiceNo")); 
 | 
                    if (x12) 
 | 
                    { 
 | 
                        xstring COUNT = x12.text(); 
 | 
                        if (COUNT != L"") 
 | 
                        { 
 | 
                            alert(COUNT); 
 | 
                            dw_list.SetItemString(row, L"InvoiceNo", L""); 
 | 
                            dw_list.SetItemString(row, L"NotifyInvoiceNo", L""); 
 | 
                            dw_list.SetItemString(row, L"GDNDate", L""); 
 | 
                            dw_list.Redraw(); 
 | 
                            return 1; 
 | 
                        } 
 | 
                    } 
 | 
  
 | 
                    xml x11 = ViewObject::RetrieveData(L"/sale/data/AP/GetInvoiceNo", L"InvoiceNo", dw_list.GetItemString(row, L"InvoiceNo")); 
 | 
                    if (x11) 
 | 
                    { 
 | 
                         ETD = x11.text(); 
 | 
                    } 
 | 
                    dw_list.SetItemString(row, L"NotifyInvoiceNo", dw_list.GetItemString(row, L"InvoiceNo")); 
 | 
                    dw_list.SetItemString(row, L"GDNDate", ETD); 
 | 
                    dw_list.Redraw(); 
 | 
  
 | 
                    return 1; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    dw_list.SetItemString(row, L"NotifyInvoiceNo", L""); 
 | 
                    dw_list.SetItemString(row, L"GDNDate", L""); 
 | 
                    dw_list.Redraw(); 
 | 
                } 
 | 
            } 
 | 
  
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int OnAttachEvent() 
 | 
        { 
 | 
            //°ó¶¨¹¤¾ßÌõµã»÷ʼþ 
 | 
            AttachEvent(L"WM_XCOMMAND", (FEvent)&ListAP::OnXCommand); 
 | 
            //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ 
 | 
            AttachEvent(L"WM_SETFOCUS", (FEvent)&ListAP::OnSetFocus); 
 | 
            AttachEvent(L"cbx_type", L"CBN_SELCHANGE", (FEvent)&ListAP::OnCombboChanged);//ÊôÐÔ×éÇл»listÖÐÁеÄÊýÁ¿±ä»¯ 
 | 
            AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&ListAP::OnDoubleClicked);//ÐÐË«»÷ 
 | 
            AttachEvent(L"cbx_state", L"CBN_SELCHANGE", (FEvent)&ListAP::OnDatePicker); 
 | 
            AttachEvent(L"dw_list", L"DWV_ITEMCHANGED", (FEvent)&ListAP::OnItemChanged); 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int OnDatePicker(TEvent* evt, int lParam) 
 | 
        { 
 | 
            xstring payTypeTwo = GetPayType(); 
 | 
            if (payTypeTwo == L"ÒѸ¶»õ¿î" || payTypeTwo == L"´ý¸¶»õ¿î") 
 | 
            { 
 | 
                int h = xcombobox::GetCurSel(evt->command.hCtrl); 
 | 
                if (h > -1) 
 | 
                { 
 | 
                    xstring txt = (string)xcombobox::GetLBText(evt->command.hCtrl, h); 
 | 
                    if (txt == L"³öÔËÈÕÆÚ") 
 | 
                    { 
 | 
                        apType = L"000"; 
 | 
                        DatePicker = L"GDNDate"; 
 | 
                        OnRetrieveEx(apType, DatePicker); 
 | 
                    } 
 | 
                    else if (txt == L"Çë¿îÈÕÆÚ") 
 | 
                    { 
 | 
                        apType = L"000"; 
 | 
                        DatePicker = L"APDate"; 
 | 
                        OnRetrieveEx(apType, DatePicker); 
 | 
                    } 
 | 
                    else if (txt == L"¸¶¿îÈÕÆÚ") 
 | 
                    { 
 | 
                        apType = L"000"; 
 | 
                        DatePicker = L"PayedDate"; 
 | 
                        OnRetrieveEx(apType, DatePicker); 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            else if (payTypeTwo == L"Ô¤¸¶»õ¿î") 
 | 
            { 
 | 
                int h1 = xcombobox::GetCurSel(evt->command.hCtrl); 
 | 
                if (h1 > -1) 
 | 
                { 
 | 
                    xstring txt1 = (string)xcombobox::GetLBText(evt->command.hCtrl, h1); 
 | 
                    if (txt1 == L"³öÔËÈÕÆÚ") 
 | 
                    { 
 | 
                        apType = L"001"; 
 | 
                        DatePicker = L"GDNDate"; 
 | 
                        OnRetrieveEx(apType, DatePicker); 
 | 
                    } 
 | 
                    else if (txt1 == L"Çë¿îÈÕÆÚ") 
 | 
                    { 
 | 
                        apType = L"001"; 
 | 
                        DatePicker = L"APDate"; 
 | 
                        OnRetrieveEx(apType, DatePicker); 
 | 
                    } 
 | 
                    else if (txt1 == L"¸¶¿îÈÕÆÚ") 
 | 
                    { 
 | 
                        apType = L"001"; 
 | 
                        DatePicker = L"PayedDate"; 
 | 
                        OnRetrieveEx(apType, DatePicker); 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            else if (payTypeTwo == L"Ô¤¸¶»õ¿î(Òѳå)L") 
 | 
            { 
 | 
                int h2 = xcombobox::GetCurSel(evt->command.hCtrl); 
 | 
                if (h2 > -1) 
 | 
                { 
 | 
                    xstring txt2 = (string)xcombobox::GetLBText(evt->command.hCtrl, h2); 
 | 
                    if (txt2 == L"³öÔËÈÕÆÚ") 
 | 
                    { 
 | 
                        apType = L"001"; 
 | 
                        DatePickerOne = L"GDNDate"; 
 | 
                        OnRetrieveEx1(apType, DatePickerOne); 
 | 
                    } 
 | 
                    else if (txt2 == L"Çë¿îÈÕÆÚ") 
 | 
                    { 
 | 
                        apType = L"001"; 
 | 
                        DatePickerOne = L"APDate"; 
 | 
                        OnRetrieveEx1(apType, DatePickerOne); 
 | 
                    } 
 | 
                    else if (txt2 == L"¸¶¿îÈÕÆÚ") 
 | 
                    { 
 | 
                        apType = L"001"; 
 | 
                        DatePickerOne = L"PayedDate"; 
 | 
                        OnRetrieveEx1(apType, DatePickerOne); 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int OnSave() 
 | 
        { 
 | 
            xml x ; 
 | 
             
 | 
            dw_list.DwUpdateAllToEx(x); 
 | 
            xaserverarg arg; 
 | 
             
 | 
            arg.AddArg(L"content", x.xml()); 
 | 
            //trace(x.xml); 
 | 
            if (xurl::get(L"/sale/data/AP/update", 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; 
 | 
        } 
 | 
  
 | 
        int  OnRetrieveEx1(xstring APType, xstring DatePickerOne) 
 | 
        { 
 | 
            xml x ; 
 | 
             
 | 
            xaserverarg arg; 
 | 
             
 | 
            arg.AddArg(L"QueryTxt", xcontrol(GetControl(L"sle_search")).GetText()); 
 | 
            arg.AddArg(L"APType", APType); 
 | 
            arg.AddArg(L"QueryArg", GetQueryArg()); 
 | 
            arg.AddArg(L"DatePicker", DatePickerOne); 
 | 
  
 | 
            trace(GetQueryArg()); 
 | 
            if (getUrl(L"/sale/data/AP/list9", arg.GetString(), x) != 1) 
 | 
            { 
 | 
                trace(x.text()); 
 | 
                return -1; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                dw_list.Retrieve(x); 
 | 
                dw_list.Redraw(); 
 | 
                dw_list.SetReadOnly(true); 
 | 
                dw_list.SetSelectionMode(1); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        xstring GetQueryArg() 
 | 
        { 
 | 
            dw_arg.AcceptText(); 
 | 
            xml x ; 
 | 
             
 | 
            dw_arg.DwUpdateAllTo(x); 
 | 
  
 | 
            return x.xml(); 
 | 
        } 
 | 
  
 | 
        int  OnRetrieveEx(xstring APType, xstring DatePicker) 
 | 
        { 
 | 
            xml x ; 
 | 
             
 | 
            xaserverarg arg; 
 | 
            xstring queryText = xcontrol(GetControl(L"sle_search")).GetText(); 
 | 
            arg.AddArg(L"QueryTxt", queryText); 
 | 
            arg.AddArg(L"APType", APType); 
 | 
            arg.AddArg(L"QueryArg", GetQueryArg()); 
 | 
            arg.AddArg(L"DatePicker", DatePicker); 
 | 
  
 | 
            trace(GetQueryArg()); 
 | 
            if (getUrl(L"/sale/data/AP/list", arg.GetString(), x) != 1) 
 | 
            { 
 | 
                trace(x.text()); 
 | 
                return -1; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                //trace(L"xml=L"+x.xml); 
 | 
                dw_list.Retrieve(x); 
 | 
                dw_list.Redraw(); 
 | 
                //dw_list.SetReadOnly(true); 
 | 
                dw_list.SetSelectionMode(1); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int OnAnalysis() 
 | 
        { 
 | 
            HCURSOR hCursor = xutil::SetCursorWait(); 
 | 
            xstring str = dw_list.DataAnalysis(L""); 
 | 
            xaserverarg arg; 
 | 
             
 | 
            arg.AddArg(L"html", str); 
 | 
            arg.SetParam(L"obj", &dw_list); 
 | 
            OpenWindow(L"dev:xpage[data.vanalysis.vx]", arg); 
 | 
            xutil::RestoreCursor(hCursor); 
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int onload() 
 | 
        { 
 | 
            dw_list = GetControl(L"dw_list"); 
 | 
            dw_list.openUrl(L"/sale/view/AP/template/AP/list1"); 
 | 
            dw_list.SetColumnState(L"APID", false); 
 | 
            dw_list.SetColumnState(L"SupplierID", false); 
 | 
            dw_list.SetColumnState(L"VATNo", false); 
 | 
  
 | 
            dw_arg = GetControl(L"dw_arg"); 
 | 
            dw_arg.openUrl(L"/sale/view/AR/template/queryarg"); 
 | 
            dw_arg.SetColHeaderHeight(0); 
 | 
            dw_arg.SetRowSelectorWidth(0); 
 | 
            dw_arg.SetHScrollState(false); 
 | 
            dw_arg.SetVScrollState(false); 
 | 
            dw_arg.SetItemString(1, L"DateType", L"±¾ÔÂ"); 
 | 
  
 | 
            OnAttachEvent(); 
 | 
            apType = L"000"; 
 | 
            OnRetrieveEx(apType, DatePicker); 
 | 
  
 | 
            return 1; 
 | 
        } 
 | 
  
 | 
        int onloaded() 
 | 
        { 
 | 
            SetAgent(); 
 | 
  
 | 
            return 1; 
 | 
        } 
 | 
    }; 
 |