#include <wobject/xstring.hpp> 
 | 
#include <xcontrol/xtreeview.hpp> 
 | 
#include <xcontrol/xdwgrid.hpp> 
 | 
#include <wobject/xdouble.hpp> 
 | 
#include <xcontrol/xlayersheet.hpp> 
 | 
  
 | 
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" 
 | 
#include "viewobject/view.base.hpp" 
 | 
  
 | 
using xml = KXMLDOMDocument; 
 | 
    class __declspec(dllexport) VATInvoiceNew :  public xframe 
 | 
    { 
 | 
    public: 
 | 
        xdwgrid    dw_1; 
 | 
        xdwgrid    dw_2; 
 | 
        xlayersheet m_layer; 
 | 
        xnode    m_agentNode;    //Agent Condition 
 | 
    public: 
 | 
        VATInvoiceNew(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} 
 | 
    public: 
 | 
        static VATInvoiceNew* CreateInstance(void* implPtr, void* hWnd) 
 | 
        { 
 | 
            VATInvoiceNew* pWin = new VATInvoiceNew(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 OnDoubleClicked(TEvent* evt, int p) 
 | 
        { 
 | 
            HCURSOR hCursor = xutil::SetCursorWait(); 
 | 
            int col = dw_1.GetColumn(); 
 | 
            //if(dw_1.GetColumnName(col)==L"Amount") 
 | 
            dw_1.ItemChangeTo(dw_1.GetRow(),L"VATBillAmount",dw_1.GetItemString(dw_1.GetRow(),L"NAmount")); 
 | 
            dw_1.Redraw(); 
 | 
            xutil::RestoreCursor(hCursor); 
 | 
            return 1;         
 | 
        } 
 | 
                 
 | 
        //½¹µã¼¤»î´¦Àíº¯Êý 
 | 
        int OnSetFocus(TEvent* evt, LPARAM param) 
 | 
        { 
 | 
            //ÖØÖù¤¾ßÌõ 
 | 
            //SetAgent(); 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        int ResetDataForContinue() 
 | 
        { 
 | 
            int i = 1; 
 | 
            for (i=dw_1.GetRowCount(); i>=1; i --) 
 | 
            { 
 | 
                xstring Amount = dw_1.GetItemString(i,L"VATBillAmount"); 
 | 
                if (Amount != L""  && Amount != L"0.00"  && Amount != L".00") 
 | 
                { 
 | 
                    dw_1.DeleteRow(i); 
 | 
                } 
 | 
            } 
 | 
            for (i=dw_2.GetRowCount(); i>=1; i --) 
 | 
            { 
 | 
                dw_2.DeleteRow(i); 
 | 
            } 
 | 
            dw_1.ResetUpdateStatus(); 
 | 
            dw_2.ResetUpdateStatus(); 
 | 
  
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        int OnTabSelectedSheet(TEvent* evt, int p) 
 | 
        { 
 | 
            int index = m_layer.GetSheetIndex(); 
 | 
            if (index == 1) 
 | 
            { 
 | 
                dw_1.AcceptText(); 
 | 
                while (dw_2.GetRowCount() >0) dw_2.DeleteRow(0); 
 | 
                 
 | 
                int i=0; 
 | 
                for (i=1;i <=dw_1.GetRowCount(); i++) 
 | 
                { 
 | 
                    xstring Amount = dw_1.GetItemString(i,L"VATBillAmount"); 
 | 
                    //trace(L"\r\n"+Amount); 
 | 
                    if (Amount != L""  && Amount != L"0.00"  && Amount != L".00") 
 | 
                    { 
 | 
                         
 | 
                        xstring ClassifyID = dw_1.GetItemString(i,L"NClassifyID"); 
 | 
                        xstring InvoiceNo = dw_1.GetItemString(i,L"NInvoiceNo"); 
 | 
                        if(InvoiceNo==L"") dw_1.GetItemString(i,L"InvoiceNo"); 
 | 
                        xstring SupplierID = dw_1.GetItemString(i,L"SupplierID"); 
 | 
                        xstring SupplierName = dw_1.GetItemDisplayString(i,L"SupplierID"); 
 | 
                        xstring GRNDate=dw_1.GetItemString(i,L"GRNDate"); 
 | 
                        xstring HasGRN=dw_1.GetItemString(i,L"HasGRN"); 
 | 
                        xstring HasGRNOne=dw_1.GetItemString(i,L"HasGRNOne"); 
 | 
                        xstring HasGRNTwo=dw_1.GetItemString(i,L"HasGRNTwo"); 
 | 
                        xstring SalespersonID=dw_1.GetItemString(i,L"SalespersonID"); 
 | 
                        xstring SalespersonIDName = dw_1.GetItemDisplayString(i,L"SalespersonID"); 
 | 
                        xstring Merchandiser=dw_1.GetItemString(i,L"Merchandiser"); 
 | 
                        xstring PurcharID=dw_1.GetItemString(i,L"PurcharID"); 
 | 
                        xstring CustomerName=dw_1.GetItemString(i,L"CustomerName"); 
 | 
                        int row; 
 | 
                        bool inserted = false; 
 | 
                        for(row = 1; row <= dw_2.GetRowCount(); row++) 
 | 
                        { 
 | 
                            if( InvoiceNo == dw_2.GetItemString(row,L"NInvoiceNo") && SupplierID== dw_2.GetItemString(row,L"SupplierID")) break; 
 | 
                        } 
 | 
                        if(row > dw_2.GetRowCount()) 
 | 
                        {     
 | 
                            dw_2.InsertRow(0);  
 | 
                            inserted = true; 
 | 
                        } 
 | 
                         
 | 
                        if(inserted) 
 | 
                        { 
 | 
                            xstring VATInvoiceID = publiccode::GetGuid(); 
 | 
                            dw_1.SetItemString(i,L"VATInvoiceID",VATInvoiceID); 
 | 
                            dw_2.SetItemString(row,L"VATInvoiceID",VATInvoiceID); 
 | 
                            dw_2.SetItemString(row,L"VATSupplierID",SupplierID); 
 | 
                            dw_2.SetItemDisplayString(row,L"VATSupplierID",SupplierName); 
 | 
                            dw_2.SetItemString(row,L"SupplierID",SupplierID); 
 | 
                            dw_2.SetItemDisplayString(row,L"SupplierID",SupplierName); 
 | 
                            dw_2.SetItemString(row,L"NInvoiceNo",InvoiceNo); 
 | 
                            dw_2.SetItemString(row,L"DeduceAmount",dw_1.GetItemString(i,L"DeduceAmount")); 
 | 
                            dw_2.SetItemString(row,L"OverAmount",dw_1.GetItemString(i,L"OverAmount")); 
 | 
                            dw_2.SetItemString(row,L"VATBillAmount",dw_1.GetItemString(i,L"VATBillAmount")); 
 | 
                            dw_2.SetItemString(row,L"NetAmount",dw_1.GetItemString(i,L"NetAmount")); 
 | 
                            dw_2.SetItemString(row,L"VATAmount",dw_1.GetItemString(i,L"VATAmount")); 
 | 
                            dw_2.SetItemString(row,L"RefundAmount",dw_1.GetItemString(i,L"RefundAmount")); 
 | 
                            xstring sdate = xstring(publiccode::GetCurrentDate()).left(10); 
 | 
                            dw_2.SetItemString(row,L"CreateDate",sdate); 
 | 
                            dw_2.SetItemString(row,L"VATDate",sdate); 
 | 
                            dw_2.SetItemString(row,L"VATInvoiceDate",sdate); 
 | 
                            dw_2.SetItemString(row,L"GRNDate",GRNDate); 
 | 
                            dw_2.SetItemString(row,L"HasGRN",HasGRN); 
 | 
                            dw_2.SetItemString(row,L"HasGRNOne",HasGRNOne); 
 | 
                            dw_2.SetItemString(row,L"HasGRNTwo",HasGRNTwo); 
 | 
                            xstring suserid = publiccode::GetUser().id; 
 | 
                            xstring susername = publiccode::GetUser().name; 
 | 
                            dw_2.SetItemString(row,L"CreatorID",suserid); 
 | 
                            dw_2.SetItemDisplayString(row,L"CreatorID",susername); 
 | 
                            dw_1.SetItemString(i,L"VATInvoiceID",VATInvoiceID); 
 | 
                            dw_2.SetItemString(row,L"Salesperson",SalespersonID); 
 | 
                            dw_2.SetItemDisplayString(row,L"Salesperson",SalespersonIDName); 
 | 
                            dw_2.SetItemString(row,L"Merchandiser",Merchandiser); 
 | 
                            dw_2.SetItemString(row,L"PurcharID",PurcharID); 
 | 
                            dw_2.SetItemString(row,L"CustomerName",CustomerName); 
 | 
                        }else 
 | 
                        { 
 | 
                            dw_1.SetItemString(i,L"VATInvoiceID",dw_2.GetItemString(row,L"VATInvoiceID")); 
 | 
                            double amt = 0.0; 
 | 
                            amt = dw_2.GetItemDouble(row,L"DeduceAmount"); 
 | 
                            amt += dw_1.GetItemDouble(i,L"DeduceAmount"); 
 | 
                            dw_2.SetItemDouble(row,L"DeduceAmount",amt); 
 | 
                         
 | 
                            amt = dw_2.GetItemDouble(row,L"OverAmount"); 
 | 
                            amt += dw_1.GetItemDouble(i,L"OverAmount"); 
 | 
                            dw_2.SetItemDouble(row,L"OverAmount",amt); 
 | 
  
 | 
                            amt = dw_2.GetItemDouble(row,L"RefundAmount"); 
 | 
                            amt += dw_1.GetItemDouble(i,L"RefundAmount"); 
 | 
                            dw_2.SetItemDouble(row,L"RefundAmount",amt); 
 | 
  
 | 
                            amt = dw_2.GetItemDouble(row,L"VATBillAmount"); 
 | 
                            amt += dw_1.GetItemDouble(i,L"VATBillAmount"); 
 | 
                            dw_2.SetItemDouble(row,L"VATBillAmount",amt); 
 | 
  
 | 
                            amt = dw_2.GetItemDouble(row,L"NetAmount"); 
 | 
                            amt += dw_1.GetItemDouble(i,L"NetAmount"); 
 | 
                            dw_2.SetItemDouble(row,L"NetAmount",amt); 
 | 
  
 | 
                            amt = dw_2.GetItemDouble(row,L"VATAmount"); 
 | 
                            amt += dw_1.GetItemDouble(i,L"VATAmount"); 
 | 
                            dw_2.SetItemDouble(row,L"VATAmount",amt); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        int OnSave(bool continueAdd) 
 | 
        { 
 | 
            dw_1.AcceptText(); 
 | 
            dw_2.AcceptText(); 
 | 
            xstring error; 
 | 
            xstring str; 
 | 
            xml x; 
 | 
            xaserverarg arg; 
 | 
             
 | 
            dw_1.DwUpdateAllToEx(x); 
 | 
            xml x0; 
 | 
             
 | 
            x0.loadXML(L"<data/>"); 
 | 
             
 | 
            KXMLDOMNodeList t = x.selectNodes(L"data/Item[@update.modify]"); 
 | 
            KXMLDOMElement e1= x0.documentElement(); 
 | 
            int len = t.length(); 
 | 
            for(int i=0;i<len;i++) 
 | 
            { 
 | 
                e1.appendChild(t.item(i)); 
 | 
            } 
 | 
            arg.AddArg(L"content",x0.xml()); 
 | 
             
 | 
  
 | 
            if(xurl::get(L"/sale/data/VATNotify/base/update", arg.GetString(),x0)!=1) 
 | 
            { 
 | 
                error = x0.text(); 
 | 
                alert(L"err:"+error); 
 | 
                return 1; 
 | 
            } 
 | 
            str = x0.documentElement().getAttribute(L"text"); 
 | 
            if(str != L"true") 
 | 
            { 
 | 
                alert(L"±£´æÊ§°Ü!"); 
 | 
                return 1; 
 | 
            } 
 | 
             
 | 
            dw_2.DwUpdateAllToEx(x); 
 | 
            arg.AddArg(L"content",x.xml()); 
 | 
             
 | 
             
 | 
            if(xurl::get(L"/sale/data/VATNotify/vatinvoice/update", arg.GetString(),x)!=1) 
 | 
            { 
 | 
                error = x.text(); 
 | 
                alert(L"err:"+error); 
 | 
                return 1; 
 | 
            } 
 | 
            str = x.documentElement().getAttribute(L"text"); 
 | 
            if(str != L"true") 
 | 
            { 
 | 
                alert(L"±£´æÊ§°Ü!"); 
 | 
                return 1; 
 | 
            }             
 | 
             
 | 
            dw_1.ResetUpdateStatus();     
 | 
            dw_2.ResetUpdateStatus();     
 | 
             
 | 
            if(!continueAdd) 
 | 
            { 
 | 
                alert(L"±£´æ³É¹¦!"); 
 | 
                CloseWindow(); 
 | 
            } 
 | 
            else  
 | 
            { 
 | 
                ResetDataForContinue(); 
 | 
                m_layer.SelectSheet(0); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        //ÃüÁî·¢²¼º¯Êý 
 | 
        int OnCmdDispatch(xstring comdid) 
 | 
        { 
 | 
            int index; 
 | 
            if (comdid==L"xmPrev") 
 | 
            { 
 | 
                index = m_layer.GetSheetIndex(); 
 | 
                index --; 
 | 
                m_layer.SelectSheet(index); 
 | 
            } 
 | 
            else if (comdid==L"xmNext")  
 | 
            { 
 | 
                index = m_layer.GetSheetIndex(); 
 | 
                index ++; 
 | 
                m_layer.SelectSheet(index); 
 | 
            } 
 | 
            else if(comdid==L"xmCancel") 
 | 
            { 
 | 
                CloseWindow(); 
 | 
                return 1; 
 | 
            } 
 | 
            else if(comdid==L"xmOk") 
 | 
            { 
 | 
                return OnSave(false); 
 | 
            } 
 | 
            else if(comdid==L"xmOkEx") 
 | 
            { 
 | 
                return OnSave(true); 
 | 
            } 
 | 
            else if(comdid==L"xmQuery") 
 | 
            { 
 | 
                OnRetrieve(); 
 | 
                return 1; 
 | 
            } 
 | 
            return 0; 
 | 
        } 
 | 
         
 | 
        int RecalcVatAmt(int row) 
 | 
        { 
 | 
            double VatRate = dw_1.GetItemDouble(row,L"VATRate"); 
 | 
            if((int)(VatRate*100) < 1) VatRate = 13.0; 
 | 
            double VATRefundRate = dw_1.GetItemDouble(row,L"VATRefundRate"); 
 | 
            double billAmt = dw_1.GetItemDouble(row,L"VATBillAmount"); 
 | 
            double VatAmt = billAmt /(100.0+VatRate)*VatRate; 
 | 
            double VATRefundAmt = billAmt /(100.0+VatRate)*VATRefundRate; 
 | 
            dw_1.SetItemDouble(row,L"VATAmount",VatAmt); 
 | 
            dw_1.SetItemDouble(row,L"RefundAmount",VATRefundAmt); 
 | 
            dw_1.SetItemDouble(row,L"NetAmount",billAmt - VatAmt); 
 | 
            return 1; 
 | 
        } 
 | 
             
 | 
        int OnItemChanged(TEvent* evt, LPARAM p) 
 | 
        { 
 | 
            DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; 
 | 
            xstring colname=hdr.colname; 
 | 
            xstring value = hdr.data; 
 | 
            int row = hdr.row; 
 | 
             
 | 
            if(value==L"") return 1; 
 | 
            if(colname==L"VATAmount") 
 | 
            { 
 | 
                double VATAmount=dw_1.GetItemDouble(row,L"VATAmount");     
 | 
                double billAmtt= dw_1.GetItemDouble(row,L"VATBillAmount"); 
 | 
                 
 | 
                double v4= billAmtt - VATAmount; 
 | 
                int v5=(int)VATAmount; 
 | 
                if(v5>=0){ 
 | 
                    dw_1.SetItemDouble(row,L"NetAmount",v4); 
 | 
                    dw_1.Redraw(); 
 | 
                } 
 | 
            } 
 | 
            else if(colname==L"VATBillAmount") 
 | 
            { 
 | 
                RecalcVatAmt(row); 
 | 
             
 | 
                if(value==L"" || value==L"0.00" || value==L".00") 
 | 
                { 
 | 
                    dw_1.SetItemString(row,L"OverAmount",L""); 
 | 
                    dw_1.SetItemString(row,L"DeduceAmount",L""); 
 | 
                    dw_1.SetItemString(row,L"VATBillAmount",L""); 
 | 
                }else 
 | 
                { 
 | 
                    double NAmount = dw_1.GetItemDouble(row,L"NAmount"); 
 | 
                    double billAmt = dw_1.GetItemDouble(row,L"VATBillAmount"); 
 | 
                    double Amt = NAmount - billAmt ; 
 | 
                    int v1 =(int) Amt; 
 | 
                    int v2 = (int)(billAmt - NAmount); 
 | 
                    if(v2 < 0) v2 = - v2; 
 | 
                    if(v1 <0 || v2<49 ) 
 | 
                    { 
 | 
                        dw_1.SetItemDouble(row,L"OverAmount",billAmt - NAmount); 
 | 
                        dw_1.SetItemString(row,L"DeduceAmount",L""); 
 | 
                    } 
 | 
                    else 
 | 
                    { 
 | 
                        dw_1.SetItemString(row,L"OverAmount",L""); 
 | 
                        dw_1.SetItemDouble(row,L"DeduceAmount", NAmount - billAmt); 
 | 
                    } 
 | 
                } 
 | 
                dw_1.Redraw(); 
 | 
                /* 
 | 
                if ldec_notifyamt - dec(data) < 0 or abs(dec(data) - ldec_notifyamt)<=49  then 
 | 
                            this.setItem(row,'kkamt',0) 
 | 
                            this.setItem(row,'dkamt',dec(data) - ldec_notifyamt) 
 | 
                    else     
 | 
                        this.setItem(row,'dkamt',0) 
 | 
                        this.setItem(row,'kkamt',ldec_notifyamt - dec(data)) 
 | 
                    end if 
 | 
                     
 | 
                    ll_decrate = this.getitemdecimal(row,'retax') 
 | 
                    ll_incrate = this.getitemdecimal(row,'incrate') 
 | 
                    if isnull(ll_decrate) then ll_decrate = 13 
 | 
                    if isnull(ll_incrate) or ll_incrate=0 then ll_incrate = 17 
 | 
                    this.setitem(row,'retaxamt',this.getItemDecimal(row,'billamt')/(100+ll_incrate)*ll_decrate) 
 | 
                    this.setitem(row,'inctaxamt',this.getItemDecimal(row,'billamt')/(100+ll_incrate)*ll_incrate) 
 | 
                end if 
 | 
  
 | 
                if dwo.name='kkamt' or dwo.name='dkamt'  then 
 | 
                    ls_prdname = this.object.supplier_cname[row] 
 | 
                    if isnull(ls_prdname) then ls_prdname = '' 
 | 
                    if ls_prdname <> '' then 
 | 
                            ls_firstName = LeftW (trim(ls_prdname), 2) 
 | 
                            ls_lastName = rightW (trim(ls_prdname), 1) 
 | 
                            ls_comName = ls_firstName + ls_lastName 
 | 
                    end if 
 | 
                     
 | 
                    if ls_comName <> '²úÆ·²¿' then 
 | 
                        this.setitem(row,'billamt',dec(this.Describe(L"evaluate('notifybuyamt - if(isnull(kkamt),0,kkamt) + if(isnull(dkamt),0,dkamt)',L"+xstring(row)+L")"))) 
 | 
                    else 
 | 
                        this.setitem(row,'billamt',dec(this.Describe(L"evaluate('prd_nbuyamt - if(isnull(kkamt),0,kkamt) + if(isnull(dkamt),0,dkamt)',L"+xstring(row)+L")"))) 
 | 
                    end if 
 | 
                     
 | 
                    ll_decrate = this.getitemdecimal(row,'retax') 
 | 
                    ll_incrate = this.getitemdecimal(row,'incrate') 
 | 
                    if isnull(ll_decrate) then ll_decrate = 13 
 | 
                    if isnull(ll_incrate) or ll_incrate=0 then ll_incrate = 17 
 | 
                    this.setitem(row,'retaxamt',this.getItemDecimal(row,'billamt')/(100+ll_incrate)*ll_decrate) 
 | 
                    this.setitem(row,'inctaxamt',this.getItemDecimal(row,'billamt')/(100+ll_incrate)*ll_incrate) 
 | 
                */                 
 | 
            } 
 | 
            else if(colname==L"DeduceAmount" || colname==L"OverAmount") 
 | 
            { 
 | 
                double dAmt = dw_1.GetItemDouble(row,L"DeduceAmount"); 
 | 
                double oAmt = dw_1.GetItemDouble(row,L"OverAmount"); 
 | 
                double nAmt = dw_1.GetItemDouble(row,L"NAmount"); 
 | 
                dw_1.SetItemDouble(row,L"VATBillAmount",nAmt + oAmt - dAmt); 
 | 
                RecalcVatAmt(row); 
 | 
                dw_1.Redraw(); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        int OnItemChangedTwo(TEvent* evt, LPARAM p) 
 | 
        { 
 | 
            DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; 
 | 
            xstring colname=hdr.colname; 
 | 
            xstring value = hdr.data; 
 | 
             
 | 
             
 | 
            if (colname == L"RefundAmount")  
 | 
            { 
 | 
                double RefundAmount2 = dw_2.GetItemDouble(hdr.row,L"RefundAmount"); 
 | 
                dw_2.SetItemDouble(hdr.row,L"TaxfundAmount", xdouble((RefundAmount2)).round(2)); 
 | 
            } 
 | 
             
 | 
            double RefundAmount= dw_2.GetItemDouble(hdr.row,L"RefundAmount"); 
 | 
            double TaxfundAmount1 = dw_2.GetItemDouble(hdr.row,L"TaxfundAmount"); 
 | 
            //trace(L"RefundAmount+=+++L"+RefundAmount.toString()+L"====TaxfundAmount1+++L"+TaxfundAmount1.toString()); 
 | 
            if(TaxfundAmount1 ==0.00) 
 | 
            { 
 | 
                dw_2.SetItemDouble(hdr.row,L"TaxfundAmount", xdouble((RefundAmount)).round(2)); 
 | 
            } 
 | 
            if (colname == L"TaxfundAmount" || colname == L"AlreadyRefundAmount" || colname == L"RefundAmount")  
 | 
            { 
 | 
                double TaxfundAmount = dw_2.GetItemDouble(hdr.row,L"TaxfundAmount"); 
 | 
                double AlreadyRefundAmount = dw_2.GetItemDouble(hdr.row,L"AlreadyRefundAmount"); 
 | 
                dw_2.SetItemDouble(hdr.row,L"NotRefundAmount", xdouble((TaxfundAmount - AlreadyRefundAmount)).round(2)); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
        //ÃüÁî´¦Àíʼþ 
 | 
        int OnXCommand(TEvent* evt, LPARAM param) 
 | 
        { 
 | 
            return OnCmdDispatch(evt->xcommand.pStrID); 
 | 
        } 
 | 
  
 | 
        int OnAttachEvent() 
 | 
        { 
 | 
            //°ó¶¨¹¤¾ßÌõµã»÷ʼþ 
 | 
            AttachEvent(L"WM_XCOMMAND", (FEvent)&VATInvoiceNew::OnXCommand); 
 | 
            //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ 
 | 
            AttachEvent(L"WM_SETFOCUS", (FEvent)&VATInvoiceNew::OnSetFocus); 
 | 
            AttachEvent(L"dw_1",L"DWV_DOUBLECLICKED", (FEvent)&VATInvoiceNew::OnDoubleClicked);//ÐÐË«»÷ 
 | 
            AttachEvent(L"dw_1",L"DWV_ITEMCHANGED", (FEvent)&VATInvoiceNew::OnItemChanged); 
 | 
            AttachEvent(L"dw_2",L"DWV_ITEMCHANGED", (FEvent)&VATInvoiceNew::OnItemChangedTwo); 
 | 
            AttachEvent(L"tab_1", L"LYSN_SELECTEDSHEET", (FEvent)&VATInvoiceNew::OnTabSelectedSheet); 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        int  OnRetrieve() 
 | 
        { 
 | 
            xml x; 
 | 
            xaserverarg arg; 
 | 
             
 | 
            arg.AddArg(L"QueryTxt",xcontrol(GetControl(L"sle_search")).GetText()); 
 | 
            arg.AddArg(L"QueryArg",L"<arg/>"); 
 | 
            if (getUrl(L"/sale/data/VATNotify/list/novatinvoice",arg.GetString(),x)!=1) 
 | 
            { 
 | 
                trace(x.text()); 
 | 
                return -1; 
 | 
            }else     
 | 
            { 
 | 
                //alert(x.GetXml()); 
 | 
                dw_1.Retrieve(x); 
 | 
                dw_1.Redraw(); 
 | 
            } 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        int onload() 
 | 
        { 
 | 
            m_layer = GetControl(L"tab_1"); 
 | 
            dw_1 = GetControl(L"dw_1"); 
 | 
            dw_1.openUrl(L"/sale/view/VATNotify/template/VATInvoice/ImportList1"); 
 | 
             
 | 
            dw_1.SetColumnState(L"GRNDate",false); 
 | 
            dw_1.SetColumnState(L"NSupplierID",false); 
 | 
             
 | 
            dw_2 = GetControl(L"dw_2"); 
 | 
            dw_2.openUrl(L"/sale/view/VATNotify/template/VATInvoice/ImportList2"); 
 | 
             
 | 
            dw_2.SetColumnState(L"GRNDate",false); 
 | 
            dw_2.SetColumnState(L"NSupplierID",false); 
 | 
             
 | 
             
 | 
            xml x; 
 | 
            xaserverarg arg = GetArg(); 
 | 
            if(arg) 
 | 
            { 
 | 
                xstring InvoiceNo = arg.GetArgString(L"InvoiceNo"); 
 | 
                x = ViewObject::RetrieveData(L"/sale/data/VATNotify/list/novatinvoice",L"QueryTxt",InvoiceNo,L"QueryArg",L"<arg/>"); 
 | 
                if(x)dw_1.Retrieve(x); 
 | 
            } 
 | 
            OnAttachEvent();     
 | 
            //OnRetrieve(); 
 | 
            return 1; 
 | 
        } 
 | 
         
 | 
        int onloaded() 
 | 
        { 
 | 
            //SetAgent();     
 | 
            return 1; 
 | 
        }         
 | 
    }; 
 |