LiFan
2024-07-25 5442aa2a75d2f40287ebeecd0afb9d1576661603
update
已添加1个文件
已修改3个文件
337 ■■■■■ 文件已修改
jrj/ext-jrj/ext-jrj.vcxproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/ext-jrj/ext-jrj.vcxproj.filters 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/project/business/Enquiry/Entity.Product.Select.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/project/business/Enquiry/Quick.Input.NewProductEx.cpp 329 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jrj/ext-jrj/ext-jrj.vcxproj
@@ -494,6 +494,7 @@
      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
    </ClCompile>
    <ClCompile Include="..\project\business\Enquiry\Quick.Input.NewProductEx.cpp" />
    <ClCompile Include="..\project\business\Enquiry\SKU.PictureView.Product3.cpp">
      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
jrj/ext-jrj/ext-jrj.vcxproj.filters
@@ -1265,5 +1265,8 @@
    <ClCompile Include="..\project\business\Expense\FreightExpenseList.cpp">
      <Filter>project\business\Expense</Filter>
    </ClCompile>
    <ClCompile Include="..\project\business\Enquiry\Quick.Input.NewProductEx.cpp">
      <Filter>project\business\Enquiry</Filter>
    </ClCompile>
  </ItemGroup>
</Project>
jrj/project/business/Enquiry/Entity.Product.Select.cpp
@@ -848,8 +848,8 @@
            if (Name == L"") Name = e.getAttribute(L"cname");
            arg.AddArg(L"No", No);
            arg.AddArg(L"CName", Name);
            int p = arg;
            OpenWindow(L"dev:xpage[Quick.Input.NewProductEx.vx]", p);
            OpenWindow(L"dev:xpage[Quick.Input.NewProductEx.vx]", arg);
            if (arg.GetArgString(L"data.modify") == L"1")RetrieveItem(hItem);
            return 1;
        }
jrj/project/business/Enquiry/Quick.Input.NewProductEx.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,329 @@
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <wobject/xdouble.hpp>
#include <xcontrol/xlayersheet.hpp>
#include <xcontrol/xdatetimepick.hpp>
#include <adt/xarray.hpp>
#include <xcontrol/xcell.hpp>
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
using xml = KXMLDOMDocument;
    class __declspec(dllexport) QuickInputNewProductExWin :  public xwin
    {
    public:
        QuickInputNewProductExWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {}
    public:
        static QuickInputNewProductExWin* CreateInstance(void* implPtr, void* hWnd)
        {
            return  new QuickInputNewProductExWin(implPtr, (HWND)hWnd);
        }
    public:
        xdwtable dw_detail;
        xdwtable dw_props;
        xdwtable dw_base;
        xdwgrid dw_list;
        xnode  m_agentNode;    //Agent Condition
        xstring    m_refno;
        xaserverarg parg;
        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;
        }
        //读取产品树的子项
        xml  RetrieveGoodsTreeChildItems(xstring sno)
        {
            xml x ;
            xaserverarg arg ;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg(L"no",sno);
            if(xurl::get(L"/sale/data/SO/goods/goodslib/ChildFolderList", arg.GetString(),x)!=1)
            {
                xstring error = x.text();
                //alert(error);
                return 0;
            }else
                return x;
        }
        //插入产品类项的子项
        int MakeGoodsFolder(xstring sno,int level )
        {
            xcombobox cbx_type = GetControl(L"cbx_category");
            xml x = RetrieveGoodsTreeChildItems(sno);
            if(!x) return 0;
            KXMLDOMNodeList nlist = x.selectNodes(L"//Item");
            int len = nlist.length();
            for (int i = 0; i < len; i++)
            {
                KXMLDOMElement e = nlist.item(i);
                xstring name = e.getAttribute(L"cname");
                xstring no= e.getAttribute(L"no");
                if(level == 1)
                    cbx_type.AddItem(no +L" "+ name);
                else
                    cbx_type.AddItem(L"   "+ no +L" " + name);
                if(level ==1)
                    MakeGoodsFolder(no,level + 1);
            }
            return 1;
        }
        //焦点激活处理函数
        int OnSetFocus(TEvent* evt, LPARAM param)
        {
            //重置工具条
            SetAgent();
            return 1;
        }
        xstring GetNo()
        {
            xstring  typ=L"C";
            if(m_refno.left(1)==L"[")    typ=L"N";
            xml x;
            xaserverarg arg ;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg(L"count", L"1" );
            arg.AddArg(L"type", typ );
            if(xurl::get(L"/sale/data/SO/goods/usegoods/goodslib/asknos", arg.GetString(),x)!=1)return L"";
            return x.text();
        }
        int OnSave()
        {
            int row = 0;
            for( row = 1;row <= dw_list.GetRowCount();row++)
            {
                if(dw_list.GetItemString(row,L"Cname") == L"")
                {
                    alert(L"第"+xstring(row)+L"行请输入中文名称");
                    return 0;
                }
                if(dw_list.GetItemString(row,L"PackingRate") == L"")
                {
                    alert(L"第"+ xstring(row) +L"行请输入包装方式");
                    return 0;
                }
                if(dw_list.GetItemString(row,L"InnerQty") == L"")
                {
                    alert(L"第"+ xstring(row) +L"行请输入内装数");
                    return 0;
                }
                if(dw_list.GetItemString(row,L"PackingRate") == L"")
                {
                    alert(L"第"+ xstring(row) +L"行请输入外装数");
                    return 0;
                }
                if(dw_list.GetItemString(row,L"PackageL") == L"")
                {
                    alert(L"第"+ xstring(row) +L"行请输入长度");
                    return 0;
                }
                if(dw_list.GetItemString(row,L"PackageW") == L"")
                {
                    alert(L"第"+ xstring(row) +L"行请输入宽度");
                    return 0;
                }
                if(dw_list.GetItemString(row,L"PackageH") == L"")
                {
                    alert(L"第"+ xstring(row) +L"行请输入高度");
                    return 0;
                }
            }
            for(row = 1;row <= dw_list.GetRowCount();row++)
            {
                dw_list.SetItemString(row,L"No",GetNo());
            }
            dw_list.Redraw();
            xml x ;
            dw_list.AcceptText();
            dw_list.DwUpdateAllToEx(x);
            xaserverarg arg ;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg(L"content",x.xml());
            if(xurl::get(L"/sale/data/ProductLibrary3/update/newestproduct", arg.GetString(),x)!=1)
            {
                xstring error = x.text();
                alert(error);
                return 1;
            }else
            {
                alert(L"保存成功!");
                dw_base.ResetUpdateStatus();
                dw_list.ResetUpdateStatus();
                if(parg)parg.AddArg(L"data.modify",L"1");
            }
            return 1;
        }
        int OnAddItem()
        {
            dw_list.InsertRow(0);
            int row = dw_list.GetRowCount();
            xstring sdate = publiccode::GetCurrentDate();
            xstring suserid = publiccode::GetUser().id;
            xstring categoryID = dw_base.GetItemString(1,L"CategoryID");
            xstring supplierID = dw_base.GetItemString(1,L"SupplierID");
            dw_list.SetItemString(row,L"FolderID",parg.GetArgString(L"guid"));
            if(categoryID)dw_list.SetItemString(row,L"CategoryID",categoryID);
            if(supplierID)dw_list.SetItemString(row,L"SupplierID",supplierID);
            dw_list.SetItemString(row,L"CreateID",suserid);
            dw_list.SetItemString(row,L"CreateDate",sdate);
            dw_list.SetItemString(row,L"ModifierID",suserid);
            dw_list.SetItemString(row,L"ModifyDate",sdate);
            return 1;
        }
        //命令发布函数
        int OnCmdDispatch(xstring comdid)
        {
            if(comdid == L"xmAdd")
            {
                OnAddItem();
            }
            else if(comdid == L"xmDelete")
            {
                dw_list.DeleteRow(dw_list.GetRow());
            }
            else if(comdid == L"xmSave")
            {
                OnSave();
            }
            else if(comdid==L"xmCancel")
            {
                CloseWindow();
                return 1;
            }
            return 0;
        }
        int OnCategoryChanged(TEvent* evt, int lParam)
        {
            xstring id = L"";
            xstring name = L"";
            xcombobox cbx_type = GetControl(L"cbx_category");
            int h = cbx_type.GetCurSel();
            xstring str = cbx_type.GetLBText(h);
            str = str.trim();
            return 1;
        }
        int OnItemChanged(TEvent* evt, int p)
        {
            DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
            xstring colname=hdr.colname;
            xstring value = hdr.data;
            int row = hdr.row;
            if(colname == L"CategoryID" || colname == L"SupplierID")
            {
                xstring categoryID = dw_base.GetItemString(1,L"CategoryID");
                xstring supplierID = dw_base.GetItemString(1,L"SupplierID");
                for(int i=1;i<=dw_list.GetRowCount();i++)
                {
                    dw_list.SetItemString(i,L"CategoryID",categoryID);
                    dw_list.SetItemString(i,L"SupplierID",supplierID);
                }
            }
            return 1;
        }
        //命令处理事件
        int OnXCommand(TEvent* evt, LPARAM param)
        {
            return OnCmdDispatch(evt->xcommand.pStrID);
        }
        int OnAttachEvent()
        {
            //绑定工具条点击事件
            AttachEvent(L"WM_XCOMMAND", (FEvent)&QuickInputNewProductExWin::OnXCommand);
            //获取焦点事件,用于重置工具条
            AttachEvent(L"WM_SETFOCUS", (FEvent)&QuickInputNewProductExWin::OnSetFocus);
            AttachEvent(L"dw_base",L"DWV_ITEMCHANGED", (FEvent)&QuickInputNewProductExWin::OnItemChanged);
            AttachEvent(L"cbx_category",L"CBN_SELCHANGE", (FEvent)&QuickInputNewProductExWin::OnCategoryChanged);
            return 1;
        }
        int OnInit()
        {
            dw_base.SetItemString(1,L"CategoryID",L"EF37E57D-5833-4AF9-BA5E-01CCF39C1F20");
            dw_base.SetItemDisplayString(1,L"CategoryID",L"礼品");
            dw_base.Redraw();
            OnAddItem();
            return 1;
        }
        int onload()
        {
            SetArg();
            dw_base = GetControl(L"dw_base");
            dw_base.openUrl(L"/sale/view/ProductLibrary/template/newitemgroup");
            dw_base.SetColHeaderHeight(0);
            dw_base.SetRowSelectorWidth(0);
            dw_base.SetHScrollState(false);
            dw_base.SetVScrollState(false);
            dw_base.SetEditUpperMode(true);
            dw_list = GetControl(L"dw_list");
            dw_list.openUrl(L"/sale/view/ProductLibrary/template/newProductItem");
            dw_list.SetColumnState(L"CategoryID",false);
            dw_list.SetColumnState(L"FolderID",false);
            dw_list.SetColumnState(L"SupplierID",false);
            dw_list.SetColumnState(L"CreateID",false);
            dw_list.SetColumnState(L"CreateDate",false);
            dw_list.SetColumnState(L"ModifierID",false);
            dw_list.SetColumnState(L"ModifyDate",false);
            if(GetWinParam())
            {
                parg = GetArg();
                xcombobox cbx_type = GetControl(L"cbx_category");
                xstring txt = parg.GetArgString(L"CategoryNo").trim() + L" " +  parg.GetArgString(L"CName").trim();
                cbx_type.AddItem(txt, (LPARAM)parg.GetArgString(L"guid").c_str(true)); //leak
                cbx_type.SetText(txt);
            }
            OnAttachEvent();
            OnInit();
            return 1;
        }
        int onloaded()
        {
            SetAgent();
            return 1;
        }
    };