LiFan
2024-07-19 a21121b4ad92f88af51fbf4ab9e1011f2789ff83
update
已添加5个文件
已修改2个文件
1603 ■■■■■ 文件已修改
jrj/ext-jrj/ext-jrj.vcxproj 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/ext-jrj/ext-jrj.vcxproj.filters 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/project/business/VATNotify/VATInvoiceNew.cpp 529 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/project/business/VATNotify/del.vatinvoice.cpp 180 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/project/business/VATNotify/list.vatinvoice.cpp 329 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/project/business/VATNotify/maint.vatinvoice..cpp 400 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/project/business/VATNotify/maint.vatinvoiceEx.cpp 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/ext-jrj/ext-jrj.vcxproj
@@ -942,18 +942,23 @@
    <ClCompile Include="..\project\business\SystemSettings\view.assignadjust.cpp">
      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
    </ClCompile>
    <ClCompile Include="..\project\business\VATNotify\del.vatinvoice.cpp" />
    <ClCompile Include="..\project\business\VATNotify\list.vatinvoice.cpp" />
    <ClCompile Include="..\project\business\VATNotify\list.vatnotify.cpp">
      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
    </ClCompile>
    <ClCompile Include="..\project\business\VATNotify\maint.papercard.vatnotify.cpp">
      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
    </ClCompile>
    <ClCompile Include="..\project\business\VATNotify\maint.vatinvoice..cpp" />
    <ClCompile Include="..\project\business\VATNotify\maint.vatinvoiceEx.cpp" />
    <ClCompile Include="..\project\business\VATNotify\simple.maint.vatnotify.cpp">
      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
    </ClCompile>
    <ClCompile Include="..\project\business\VATNotify\update.vatnotify.cpp">
      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
    </ClCompile>
    <ClCompile Include="..\project\business\VATNotify\VATInvoiceNew.cpp" />
    <ClCompile Include="..\project\business\VATNotify\VATNotifyParse.cpp">
      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
    </ClCompile>
jrj/ext-jrj/ext-jrj.vcxproj.filters
@@ -1139,5 +1139,26 @@
    <ClCompile Include="..\project\business\PO\PO.maint.item.line.cpp">
      <Filter>project\business\PO</Filter>
    </ClCompile>
    <ClCompile Include="..\project\business\VATNotify\del.vatinvoice.cpp">
      <Filter>project\business\VATNotify</Filter>
    </ClCompile>
    <ClCompile Include="..\project\business\VATNotify\list.vatinvoice.cpp">
      <Filter>project\business\VATNotify</Filter>
    </ClCompile>
    <ClCompile Include="..\project\business\VATNotify\maint.vatinvoice..cpp">
      <Filter>project\business\VATNotify</Filter>
    </ClCompile>
    <ClCompile Include="..\project\business\VATNotify\maint.vatinvoiceEx.cpp">
      <Filter>project\business\VATNotify</Filter>
    </ClCompile>
    <ClCompile Include="..\project\business\VATNotify\VATInvoiceNew.cpp">
      <Filter>project\business\VATNotify</Filter>
    </ClCompile>
    <ClCompile Include="..\project\business\AP\list.RefundGDNLine.Entity.xarch.cpp">
      <Filter>project\business\AP</Filter>
    </ClCompile>
    <ClCompile Include="..\project\business\AP\list.RefundSourcingLine.Entity.xarch.cpp">
      <Filter>project\business\AP</Filter>
    </ClCompile>
  </ItemGroup>
</Project>
jrj/project/business/VATNotify/VATInvoiceNew.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,529 @@
#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 = new xml;
            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")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")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;
        }
    };
jrj/project/business/VATNotify/del.vatinvoice.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,180 @@
#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) DelVATInvoice :  public xframe
    {
    public:
        xdwgrid    dw_list;
        xcombobox cbx_type;
        xdwtable dw_arg;
        xnode    m_agentNode;    //Agent Condition
    public:
        DelVATInvoice(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
    public:
        static DelVATInvoice* CreateInstance(void* implPtr, void* hWnd)
        {
            DelVATInvoice* pWin = new DelVATInvoice(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;
        }
        int OnDoubleClicked(TEvent* evt, LPARAM p)
        {
            return OnCmdDispatch(L"xmModifyRow");
        }
        //命令发布函数
        int OnCmdDispatch(xstring comdid)
        {
             if(comdid==L"xmSaveAs")
            {
                dw_list.SaveAs(L"");
                return 1;
            }
             else if(comdid==L"xmModifyRow" )
            {
                int row2 = dw_list.GetRow();
                xstring VatInvoiceID = dw_list.GetItemString(row2,L"VATInvoiceID");
                xaserverarg arg ;
                arg.AddArg(L"VatInvoiceID",VatInvoiceID);
                OpenWindow(L"dev:xpage[maint.vatinvoiceEx.vx]",arg );
                return 1;
            }
            else if(comdid==L"xmRetrieve")
            {
                OnRetrieve();
                return 1;
            }
            else if(comdid==L"xmRecovery")
            {
                int row = dw_list.GetRow();
                xstring VATInvoiceID = dw_list.GetItemString(row,L"VATInvoiceID");
                alert(VATInvoiceID);
                int MB_OKCANCEL = 1;
                int IDOK  = 1;
                int ret = MessageBox(GetHWND(),L"确认恢复?",L"提示",MB_OKCANCEL);
                if(ret == IDOK)
                {
                    ViewObject::RetrieveData(L"/sale/data/VATNotify/DeleteRecovery",L"VATInvoiceID",VATInvoiceID);
                    OnRetrieve();
                }
                return 1;
            }
            return 0;
        }
        //命令处理事件
    int OnXCommand(TEvent* evt, LPARAM param)
        {
            return OnCmdDispatch(evt->xcommand.pStrID);
        }
        int OnAttachEvent()
        {
            //绑定工具条点击事件
            AttachEvent(L"WM_XCOMMAND", (FEvent)&DelVATInvoice::OnXCommand);
            //获取焦点事件,用于重置工具条
            AttachEvent(L"WM_SETFOCUS", (FEvent)&DelVATInvoice::OnSetFocus);
            AttachEvent(L"dw_list",L"DWV_DOUBLECLICKED", (FEvent)&DelVATInvoice::OnDoubleClicked);//行双击
            return 1;
        }
        xstring GetQueryArg()
        {
            dw_arg.AcceptText();
            xml x ;
            dw_arg.DwUpdateAllTo(x);
            return x.xml();
        }
        int  OnRetrieve()
        {
            HCURSOR  hCursor = xutil::SetCursorWait();
            xml x ;
            xaserverarg arg ;
            arg.AddArg(L"QueryTxt",xcontrol( GetControl(L"sle_search")).GetText());
            arg.AddArg(L"QueryArg",GetQueryArg());
            //alert(arg.GetString());
            if (getUrl(L"/sale/data/VATNotify/list/vatinvoiceEx",arg.GetString(),x)!=1)
            {
                xutil::RestoreCursor(hCursor);
                return -1;
            }else
            {
                dw_list.Retrieve(x);
                dw_list.Redraw();
            }
            xutil::RestoreCursor(hCursor);
            return 1;
        }
        int onload()
        {
            dw_list = GetControl(L"dw_list");
            dw_list.openUrl(L"/sale/view/VATNotify/template/VATInvoice/list");
            dw_list.SetColumnState(L"VATInvoiceID",false);
            dw_list.SetColumnState(L"GRNDate",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();
            OnRetrieve();
            return 1;
        }
        int onloaded()
        {
            SetAgent();
            return 1;
        }
    };
jrj/project/business/VATNotify/list.vatinvoice.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,329 @@
#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) ListVATInvoice :  public xframe
    {
    public:
        xdwgrid    dw_list;
        xcombobox cbx_type;
        xdwtable dw_arg;
        xnode    m_agentNode;    //Agent Condition
        xstring DatePicker;
    public:
        ListVATInvoice(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
    public:
        static ListVATInvoice* CreateInstance(void* implPtr, void* hWnd)
        {
            ListVATInvoice* pWin = new ListVATInvoice(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 GetEntityName(int pr)
        {
            return L"VATInvoice3";
        }
        xstring GetEntityIDName(int /*param*/ pr)
        {
            return L"VTAInvoiceID";
        }
        xstring GetEntityID(int /*param*/ pr)
        {
            return dw_list.GetItemString(dw_list.GetRow(),L"VATInvoiceID");
        }
        int ViewUpdate(int pr,xstring updateItem,xaserverarg  arg)
        {
            if(    updateItem==L"del")
            {
                int DelRow = dw_list.GetRow();
                dw_list.DeleteRow(DelRow);
                return 1;
            }
            return 1;
        }
        int  OnAnalysis()
        {
            HCURSOR hCursor = xutil::SetCursorWait();
            xstring str = dw_list.DataAnalysis(L"");
            xaserverarg arg;
            arg.AddArg(L"html", str);
            OpenWindow(L"dev:xpage[data.vanalysis.vx]",arg);
            xutil::RestoreCursor(hCursor);
            return 1;
        }
        int OnCombboChanged(TEvent* evt, int p)
        {
            xstring id = L"";
            xstring name = L"";
            int h = xcombobox::GetCurSel(evt->command.hCtrl);
            if(h > -1)
            {
                xstring txt = xcombobox::GetLBText(evt->command.hCtrl, h);
                if(txt==L"增值税票")
                {
                    dw_list.openUrl(L"/sale/view/VATNotify/template/VATInvoice/list");
                    dw_list.SetColumnState(L"VATInvoiceID",false);
                    dw_list.SetColumnState(L"GRNDate",false);
                    OnRetrieve(DatePicker);
                }
                else if(txt==L"未开增值税票")
                {
                    dw_list.openUrl(L"/sale/view/VATNotify/template/VATNotify/ListNoVATInvoice");
                    OnRetrieveEx();
                }
                else if(txt==L"增值税票商品")
                {
                    dw_list.openUrl(L"/sale/view/VATNotify/template/VATInvoice/list1");
                    dw_list.SetColumnState(L"VATInvoiceID",false);
                    OnRetrieveEx1();
                }
            }
            return 1;
        }
        int OnDoubleClicked(TEvent* evt, int p)
        {
            return OnCmdDispatch(L"xmModifyRow");
        }
        //命令发布函数
        int OnCmdDispatch(xstring comdid)
        {
            if(comdid==L"xmAnalysis") return OnAnalysis();
            if(comdid==L"xmAddRow")
            {
                OpenWindow(L"dev:xpage[VATInvoiceNew.vx]");
                return 1;
            }
            else if(comdid==L"xmModifyRow" )
            {
                if(xcontrol(GetControl(L"cbx_type")).GetText() ==L"未开增值税票" ) return 1;
                int row = dw_list.GetRow();
                xaserverarg arg;
                xstring VatInvoiceID = dw_list.GetItemString(row,L"VATInvoiceID");
                OpenWindow(L"dev:xpage[maint.vatinvoice.vx]", arg);
                return 1;
            }
            else if(comdid==L"xmSaveAs")
            {
                dw_list.SaveAs(L"");
                return 1;
            }
            else if(comdid==L"xmRetrieve" || comdid==L"xmSearch" )
            {
                if(xcontrol(GetControl(L"cbx_type")).GetText() ==L"未开增值税票")
                {
                    OnRetrieveEx();
                }
                else if(xcontrol(GetControl(L"cbx_type")).GetText() ==L"增值税票商品")
                {
                    OnRetrieveEx1();
                }
                else
                    OnRetrieve(DatePicker);
                return 1;
            }
            else if(comdid.find(L"action:",0)>=0)
            {
                ProcessFlowAction(comdid,1);
            }
            else    if(comdid==L"DeletedOne")
            {
                OpenWindow(L"dev:xpage[del.vatinvoice.vx]");
                return 1;
            }
            return 0;
        }
        //命令处理事件
        int OnXCommand(TEvent* evt, LPARAM param)
        {
            return OnCmdDispatch(evt->xcommand.pStrID);
        }
        int OnAttachEvent()
        {
            //绑定工具条点击事件
            AttachEvent(L"WM_XCOMMAND", (FEvent)&ListVATInvoice::OnXCommand);
            //获取焦点事件,用于重置工具条
            AttachEvent(L"WM_SETFOCUS", (FEvent)&ListVATInvoice::OnSetFocus);
            AttachEvent(L"dw_list",L"DWV_DOUBLECLICKED", (FEvent)&ListVATInvoice::OnDoubleClicked);//行双击
            AttachEvent(L"cbx_type",L"CBN_SELCHANGE", (FEvent)&ListVATInvoice::OnCombboChanged);//属性组切换list中列的数量变化
            AttachEvent(L"cbx_state",L"CBN_SELCHANGE", (FEvent)&ListVATInvoice::OnDatePicker);
            return 1;
        }
        int OnDatePicker(TEvent* evt, int lParam)
        {
            int h = xcombobox::GetCurSel(evt->command.hCtrl);
            if(h > -1)
            {
                xstring txt = xcombobox::GetLBText(evt->command.hCtrl, h);
                if(txt==L"出运日期")
                {
                    DatePicker=L"ETD";
                    OnRetrieve(DatePicker);
                }
                else if(txt==L"开票日期")
                {
                    DatePicker=L"VATDate";
                    OnRetrieve(DatePicker);
                }
            }
            return 1;
        }
        int  OnRetrieveEx1()
        {
            HCURSOR  hCursor = xutil::SetCursorWait();
            xml x ;
            xaserverarg arg ;
            arg.AddArg(L"QueryTxt",xcontrol(GetControl(L"sle_search")).GetText());
            arg.AddArg(L"QueryArg",GetQueryArg());
            if (getUrl(L"/sale/data/VATNotify/list/novatinvoice1",arg.GetString(),x)!=1)
            {
                xutil::RestoreCursor(hCursor);
                return -1;
            }else
            {
                dw_list.Retrieve(x);
                dw_list.Redraw();
            }
            dw_list.SetReadOnly(true);
            xutil::RestoreCursor(hCursor);
            return 1;
        }
        int  OnRetrieveEx()
        {
            HCURSOR  hCursor = xutil::SetCursorWait();
            xml x ;
            xaserverarg arg ;
            arg.AddArg(L"QueryTxt",xcontrol(GetControl(L"sle_search")).GetText());
            arg.AddArg(L"QueryArg",GetQueryArg());
            if (getUrl(L"/sale/data/VATNotify/list/novatinvoice",arg.GetString(),x)!=1)
            {
                xutil::RestoreCursor(hCursor);
                return -1;
            }else
            {
                dw_list.Retrieve(x);
                dw_list.Redraw();
            }
            dw_list.SetReadOnly(true);
            xutil::RestoreCursor(hCursor);
            return 1;
        }
        xstring GetQueryArg()
        {
            dw_arg.AcceptText();
            xml x ;
            dw_arg.DwUpdateAllTo(x);
            return x.xml();
        }
        int  OnRetrieve(xstring DatePicker)
        {
            HCURSOR  hCursor = xutil::SetCursorWait();
            xml x ;
            xaserverarg arg ;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg(L"QueryTxt",xcontrol(GetControl(L"sle_search")).GetText());
            arg.AddArg(L"QueryArg",GetQueryArg());
            arg.AddArg(L"DatePicker",DatePicker);
            //alert(arg.GetString());
            if (getUrl(L"/sale/data/VATNotify/list/vatinvoice",arg.GetString(),x)!=1)
            {
                xutil::RestoreCursor(hCursor);
                return -1;
            }else
            {
                dw_list.Retrieve(x);
                dw_list.Redraw();
            }
            xutil::RestoreCursor(hCursor);
            return 1;
        }
        int onload()
        {
            dw_list = GetControl(L"dw_list");
            dw_list.openUrl(L"/sale/view/VATNotify/template/VATInvoice/list");
            dw_list.SetColumnState(L"VATInvoiceID",false);
            dw_list.SetColumnState(L"GRNDate",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();
            OnRetrieve(DatePicker);
            return 1;
        }
        int onloaded()
        {
            SetAgent();
            return 1;
        }
    };
jrj/project/business/VATNotify/maint.vatinvoice..cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,400 @@
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <wobject/xdouble.hpp>
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
using xml = KXMLDOMDocument;
    class __declspec(dllexport) MaintVATInvoice :  public xframe
    {
    public:
        xdwgrid    dw_list;
        xdwtable dw_base;
        xstring VATInvoiceID;
        xnode    m_agentNode;    //Agent Condition
    public:
        MaintVATInvoice(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
    public:
        static MaintVATInvoice* CreateInstance(void* implPtr, void* hWnd)
        {
            MaintVATInvoice* pWin = new MaintVATInvoice(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 OnSave()
        {
            dw_list.AcceptText();
            xstring error;
            xstring str;
            xml x ;
            xaserverarg arg ;
            dw_list.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_base.AcceptText();
            xml x1 ;
            dw_base.DwUpdateAllTo(x1);
            arg.AddArg(L"content",x1.xml());
            if(xurl::get(L"/sale/data/VATNotify/vatinvoice/update", arg.GetString(),x1)!=1)
            {
                error = x1.text();
                alert(L"err:"+error);
                return 1;
            }
            str = x1.documentElement().getAttribute(L"text");
            if(str != L"true")
            {
                alert(L"保存失败!");
                return 1;
            }
            dw_list.ResetUpdateStatus();
            dw_base.ResetUpdateStatus();
            alert(L"保存成功!");
            CloseWindow();
            return 1;
        }
        int RecalcVatAmt(int row)
        {
            double VatRate = dw_list.GetItemDouble(row,L"VATRate");
            if((int)(VatRate*100) < 1) VatRate = 17.0;
            double VATRefundRate = dw_list.GetItemDouble(row,L"VATRefundRate");
            double billAmt = dw_list.GetItemDouble(row,L"VATBillAmount");
            double VatAmt = billAmt /(100.0+VatRate)*VatRate;
            double VATRefundAmt = billAmt /(100.0+VatRate)*VATRefundRate;
            dw_list.SetItemDouble(row,L"VATAmount",VatAmt);
            dw_list.SetItemDouble(row,L"RefundAmount",VATRefundAmt);
            dw_list.SetItemDouble(row,L"NetAmount",billAmt - VatAmt);
            return 1;
        }
        //合计
        int SUMRecalcVatAmt()
        {
            double VATBillAmountEx=0;
            double DeduceAmountEx=0;
            double GoodsAmountEx=0;
            double OverAmountEx=0;
            double RefundAmountEx=0;
            double VATAmountEx=0;
            for(int i = 1;i <=dw_list.GetRowCount(); ++i)
            {
                    double VATBillAmount=dw_list.GetItemDouble(i,L"VATBillAmount");
                    VATBillAmountEx+=VATBillAmount;
                    double DeduceAmount=dw_list.GetItemDouble(i,L"DeduceAmount");
                    DeduceAmountEx+=DeduceAmount;
                    double NetAmount=dw_list.GetItemDouble(i,L"NetAmount");
                    GoodsAmountEx+=NetAmount;
                    double OverAmount=dw_list.GetItemDouble(i,L"OverAmount");
                    OverAmountEx+=OverAmount;
                    double RefundAmount=dw_list.GetItemDouble(i,L"RefundAmount");
                    RefundAmountEx+=RefundAmount;
                    double VATAmount=dw_list.GetItemDouble(i,L"VATAmount");
                    VATAmountEx+=VATAmount;
            }
            dw_base.SetItemDouble(1,L"VATBillAmount",VATBillAmountEx);
            dw_base.SetItemDouble(1,L"DeduceAmount",DeduceAmountEx);
            dw_base.SetItemDouble(1,L"GoodsAmount",GoodsAmountEx);
            dw_base.SetItemDouble(1,L"OverAmount",OverAmountEx);
            dw_base.SetItemDouble(1,L"RefundAmount",RefundAmountEx);
            dw_base.SetItemDouble(1,L"VATAmount",VATAmountEx);
            dw_base.Redraw();
            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_list.GetItemDouble(row,L"VATAmount");
                double billAmtt= dw_list.GetItemDouble(row,L"VATBillAmount");
                double v4= billAmtt - VATAmount;
                int v5=(int)VATAmount;
                if(v5>=0){
                    dw_list.SetItemDouble(row,L"NetAmount",v4);
                    dw_list.Redraw();
                    dw_base.SetItemDouble(1,L"GoodsAmount",v4);
                    dw_base.SetItemDouble(1,L"VATAmount",VATAmount);
                    dw_base.Redraw();
                }
                SUMRecalcVatAmt();
            }
            else if(colname==L"RefundAmount")
            {
                double RefundAmountt=dw_list.GetItemDouble(row,L"RefundAmount");
                //dw_base.SetItemDouble(1,L"RefundAmount",RefundAmountt);
                //dw_base.Redraw();
                SUMRecalcVatAmt();
            }
            else if(colname==L"VATBillAmount")
            {
                RecalcVatAmt(row);
                if(value==L"" || value==L"0.00")
                {
                    dw_list.SetItemString(row,L"OverAmount",L"");
                    dw_list.SetItemString(row,L"DeduceAmount",L"");
                }else
                {
                    double NAmount = dw_list.GetItemDouble(row,L"NAmount");
                    double billAmt = dw_list.GetItemDouble(row,L"VATBillAmount");//开票金额
                    double VATAmount1=dw_list.GetItemDouble(row,L"VATAmount");        //增值税额
                    double oAmt1 = dw_list.GetItemDouble(row,L"OverAmount");//多开金额
                    double RefundAmount = dw_list.GetItemDouble(row,L"RefundAmount");
                    double dAmt1 = dw_list.GetItemDouble(row,L"DeduceAmount");//扣款金额
                    double Amt = NAmount - billAmt ;
                    int v1 = (int)Amt;
                    int v2 = (billAmt - NAmount);
                    if(v2 < 0) v2 = - v2;
                    if(v1 <0 || v2<49 )
                    {
                        dw_list.SetItemDouble(row,L"OverAmount",billAmt - NAmount);
                        dw_list.SetItemDouble(row,L"DeduceAmount",0.0);
                        /*dw_base.SetItemDouble(1,L"GoodsAmount",billAmt - VATAmount1);
                        dw_base.SetItemDouble(1,L"VATAmount",VATAmount1);
                        dw_base.SetItemDouble(1,L"VATBillAmount",billAmt);
                        dw_base.SetItemDouble(1,L"DeduceAmount",0.0);
                        dw_base.SetItemDouble(1,L"OverAmount",billAmt - NAmount);
                        dw_base.SetItemDouble(1,L"RefundAmount",RefundAmount);*/
                    }
                    else
                    {
                        dw_list.SetItemDouble(row,L"OverAmount",0.0);
                        dw_list.SetItemDouble(row,L"DeduceAmount", NAmount - billAmt);
                        /*dw_base.SetItemDouble(1,L"GoodsAmount",billAmt - VATAmount1);
                        dw_base.SetItemDouble(1,L"VATAmount",VATAmount1);
                        dw_base.SetItemDouble(1,L"VATBillAmount",billAmt);
                        dw_base.SetItemDouble(1,L"DeduceAmount",NAmount - billAmt);
                        dw_base.SetItemDouble(1,L"OverAmount",0.0);
                        dw_base.SetItemDouble(1,L"RefundAmount",RefundAmount);*/
                    }
                }
                SUMRecalcVatAmt();
                dw_list.Redraw();
            }
            else if(colname==L"DeduceAmount" || colname==L"OverAmount")
            {
                double dAmt = dw_list.GetItemDouble(row,L"DeduceAmount");
                double oAmt = dw_list.GetItemDouble(row,L"OverAmount");
                double nAmt = dw_list.GetItemDouble(row,L"NAmount");
                double VatRate = dw_list.GetItemDouble(row,L"VATRate");
                if((int)(VatRate*100) < 1) VatRate = 17.0;
                double VatAmt = (nAmt + oAmt - dAmt)/(100.0+VatRate)*VatRate;    //增值税额
                dw_list.SetItemDouble(row,L"VATBillAmount",nAmt + oAmt - dAmt);
                /*if(oAmt>0){
                dw_base.SetItemDouble(1,L"GoodsAmount",nAmt + oAmt - dAmt - VatAmt);
                dw_base.SetItemDouble(1,L"VATAmount",VatAmt);
                dw_base.SetItemDouble(1,L"VATBillAmount",nAmt + oAmt - dAmt);
                dw_base.SetItemDouble(1,L"OverAmount",oAmt);
                }*/
                RecalcVatAmt(row);
                SUMRecalcVatAmt();
                dw_list.Redraw();
            }
            return 1;
        }
        //焦点激活处理函数
        int OnSetFocus(TEvent* evt, LPARAM param)
        {
            //重置工具条
            SetAgent();
            return 1;
        }
        //命令发布函数
        int OnCmdDispatch(xstring comdid)
        {
            if(comdid==L"xmClose")
            {
                CloseWindow();
                return 1;
            }else if(comdid==L"xmSave")
            {
                return OnSave();
            }
            return 0;
        }
        //命令处理事件
        int OnXCommand(TEvent* evt, LPARAM param)
        {
            return OnCmdDispatch(evt->xcommand.pStrID);
        }
        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_base.GetItemDouble(hdr.row,L"RefundAmount");
                dw_base.SetItemDouble(hdr.row,L"TaxfundAmount", xdouble((RefundAmount2)).round(2));
            }
            double RefundAmount= dw_base.GetItemDouble(hdr.row,L"RefundAmount");
            double TaxfundAmount1 = dw_base.GetItemDouble(hdr.row,L"TaxfundAmount");
            if(TaxfundAmount1 ==0.00)
            {
                dw_base.SetItemDouble(hdr.row,L"TaxfundAmount", xdouble((RefundAmount)).round(2));
            }
            if (colname == L"TaxfundAmount" || colname == L"AlreadyRefundAmount" || colname == L"RefundAmount")
            {
                double TaxfundAmount = dw_base.GetItemDouble(hdr.row,L"TaxfundAmount");
                double AlreadyRefundAmount = dw_base.GetItemDouble(hdr.row,L"AlreadyRefundAmount");
                dw_base.SetItemDouble(hdr.row,L"NotRefundAmount", xdouble((TaxfundAmount - AlreadyRefundAmount)).round(2));
            }
            return 1;
        }
        int OnAttachEvent()
        {
            //绑定工具条点击事件
            AttachEvent(L"WM_XCOMMAND", (FEvent)&MaintVATInvoice::OnXCommand);
            //获取焦点事件,用于重置工具条
            AttachEvent(L"WM_SETFOCUS", (FEvent)&MaintVATInvoice::OnSetFocus);
            AttachEvent(L"dw_list",L"DWV_ITEMCHANGED", (FEvent)&MaintVATInvoice::OnItemChanged);
            AttachEvent(L"dw_base",L"DWV_ITEMCHANGED", (FEvent)&MaintVATInvoice::OnItemChangedTwo);
            return 1;
        }
        int  OnRetrieve()
        {
            xml x ;
            xaserverarg arg = GetArg();
            arg.AddArg(L"VATInvoiceID",VATInvoiceID);
            if (getUrl(L"/sale/data/VATNotify/vatinvoice/base",arg.GetString(),x)!=1)
            {
                trace(x.text());
                return -1;
            }else
            {
                dw_base.Retrieve(x);
                dw_base.Redraw();
            }
            if (getUrl(L"/sale/data/VATNotify/vatinvoice/item",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.openUrl(L"/sale/view/VATNotify/template/VATInvoice/item");
            dw_base = GetControl(L"dw_base");
            dw_base.openUrl(L"/sale/view/VATNotify/template/VATInvoice/base");
            VATInvoiceID = L"";
            if (GetWinParam())
            {
                xaserverarg arg = GetArg();
                VATInvoiceID = arg.GetArgString(L"VATInvoiceID");
            }
            OnAttachEvent();
            if(VATInvoiceID !=L"") OnRetrieve();
            return 1;
        }
        int onloaded()
        {
            SetAgent();
            return 1;
        }
    };
jrj/project/business/VATNotify/maint.vatinvoiceEx.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,139 @@
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <wobject/xdouble.hpp>
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
using xml = KXMLDOMDocument;
    class __declspec(dllexport) MaintVATInvoiceEx :  public xframe
    {
    public:
        xdwgrid    dw_list;
        xdwtable dw_base;
        xnode    m_agentNode;    //Agent Condition
    public:
        MaintVATInvoiceEx(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
    public:
        static MaintVATInvoiceEx* CreateInstance(void* implPtr, void* hWnd)
        {
            MaintVATInvoiceEx* pWin = new MaintVATInvoiceEx(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;
        }
        //命令发布函数
        int OnCmdDispatch(xstring comdid)
        {
            if(comdid==L"xmClose")
            {
                CloseWindow();
                return 1;
            }
            return 0;
        }
        //命令处理事件
        int OnXCommand(TEvent* evt, LPARAM param)
        {
            return OnCmdDispatch(evt->xcommand.pStrID);
        }
        int OnAttachEvent()
        {
            //绑定工具条点击事件
            AttachEvent(L"WM_XCOMMAND", (FEvent)&MaintVATInvoiceEx::OnXCommand);
            //获取焦点事件,用于重置工具条
            AttachEvent(L"WM_SETFOCUS", (FEvent)&MaintVATInvoiceEx::OnSetFocus);
            return 1;
        }
        int  OnRetrieve(xstring VATInvoiceID)
        {
            xml x ;
            xaserverarg arg ;
            arg.AddArg(L"VATInvoiceID",VATInvoiceID);
            if (getUrl(L"/sale/data/VATNotify/vatinvoice/baseEx",arg.GetString(),x)!=1)
            {
                trace(x.text());
                return -1;
            }else
            {
                dw_base.Retrieve(x);
                dw_base.Redraw();
            }
            if (getUrl(L"/sale/data/VATNotify/vatinvoice/itemEx",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.openUrl(L"/sale/view/VATNotify/template/VATInvoice/item");
            dw_base = GetControl(L"dw_base");
            dw_base.openUrl(L"/sale/view/VATNotify/template/VATInvoice/base");
            xaserverarg arg = GetArg();
            xstring VATInvoiceID = arg.GetArgString(L"VatInvoiceID");
            OnRetrieve(VATInvoiceID);
            OnAttachEvent();
            return 1;
        }
        int onloaded()
        {
            SetAgent();
            return 1;
        }
    };