LiFan
2024-07-18 b6e2fbfc0469657db86b9757c1813d72f6727962
jrj/project/business/Quote/QuoteSupplierItem.cpp
@@ -1,37 +1,51 @@
use "xcontrol.vframe.vbusiness.vd"
use "xbase.vframe.vbusiness.vd"
use "supplier.view.vd"
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <wobject/xdouble.hpp>
#include <xcontrol/xlayersheet.hpp>
#include <xcontrol/xdatetimepick.hpp>
unit trade
[
   class QuoteSupplierItem :  public xframe
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
using xml = KXMLDOMDocument;
   class __declspec(dllexport) QuoteSupplierItem :  public xframe
   {
   public:
      xdwgrid   dw_list;
      xnode   m_agentNode;   //Agent Condition
   public:
      QuoteSupplierItem(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
   public:
      static QuoteSupplierItem* CreateInstance(void* implPtr, void* hWnd)
      {
         QuoteSupplierItem* pWin = new QuoteSupplierItem(implPtr, (HWND)hWnd);
         return pWin;
      }
      int SetAgent()
      {
         string xfNodeAgentArea  = "agentarea";
         xstring xfNodeAgentArea  = L"agentarea";
         xnode anode = GetAgentNode(xfNodeAgentArea);
         if(m_agentNode)
         {
            SetAgentNodeContent (anode,m_agentNode);
            SetAgentNode (anode,m_agentNode);
         }
         else
         {
            msxml::IXMLDOMElement xframeElement =  GetElement();
            msxml::IXMLDOMElement agent = xframeElement.selectSingleNode("agent/"+xfNodeAgentArea+"[1]/*");
            KXMLDOMElement xframeElement =  GetElement();
            KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*");
            if(agent)
            {
               string s = agent.xml;
               m_agentNode =  SetAgentNodeContent (anode,s);
               xstring s = agent.xml();
               m_agentNode =  SetAgentNode (anode,s);
            }
         }
         return 1;
      }
      //焦点激活处理函数
      int OnSetFocus(ref TEvent evt,int param)
      int OnSetFocus(TEvent* evt, LPARAM param)
      {
         //重置工具条
         //SetAgent();
@@ -51,19 +65,19 @@
      }
      
      //命令发布函数
      int OnCmdDispatch(string comdid)
      int OnCmdDispatch(xstring comdid)
      {
         if(comdid=="xmCancel") return OnCancel();
         else if(comdid=="xmOK") return OnOk();
         else if(comdid=="xmDelete") return OnDelete();
         if(comdid==L"xmCancel") return OnCancel();
         else if(comdid==L"xmOK") return OnOk();
         else if(comdid==L"xmDelete") return OnDelete();
         
         return 0;
      }
      
      //命令处理事件
      int OnXCommand(ref TXCommandEvent evt,int param)
      int OnXCommand(TEvent* evt, LPARAM param)
      {
         return OnCmdDispatch(evt.pStrID);
         return OnCmdDispatch(evt->xcommand.pStrID);
      }
      
      int OnDelete()
@@ -76,30 +90,29 @@
      {
         dw_list.AcceptText();
         
         xml xitem = new xml;
         xitem.setNativePointer(xml::CreateInstance());
         msxml::IXMLDOMDocument xitemdoc = xitem.GetXmlDoc();
         xml xitem ;
         KXMLDOMDocument xitemdoc = xitem;
         dw_list.DwUpdateAllToEx(xitemdoc);
         xaserverarg arg = new xaserverarg;
         arg.setNativePointer(arg.CreateInstance());
         arg.AddArg("content",xitem.GetXml());
         xaserverarg arg ;
         
         //alert(xitem.GetXml());
         arg.AddArg(L"content",xitem.xml());
         //alert(xitem.xml());
         //return 1;
         
         if(url::get("/sale/data/SupplierV3/entity/update/quotemysupplier", arg.GetString(),xitem)!=1)
         if(xurl::get(L"/sale/data/SupplierV3/entity/update/quotemysupplier", arg.GetString(),xitem)!=1)
         {
            string error1 = xitem.GetXmlDoc().text;
            xstring error1 = xitem.text();
            return 1;
         }else
         {
            string str = xitem.GetXmlDoc().documentElement.getAttribute("text");
            if(str == "false")
            xstring str = xitem.documentElement().getAttribute(L"text");
            if(str == L"false")
            {
               alert("保存失败!");
               alert(L"保存失败!");
               return -1;
            }
            alert("保存成功!");
            alert(L"保存成功!");
            dw_list.ResetUpdateStatus();
         }
         
@@ -109,33 +122,34 @@
      int OnAttachEvent()
      {
         //绑定工具条点击事件
         AttachEvent("WM_XCOMMAND",OnXCommand);
         AttachEvent(L"WM_XCOMMAND", (FEvent)&QuoteSupplierItem::OnXCommand);
         //获取焦点事件,用于重置工具条
         AttachEvent("WM_SETFOCUS",OnSetFocus);
         AttachEvent(L"WM_SETFOCUS", (FEvent)&QuoteSupplierItem::OnSetFocus);
         return 1;
      }
      
      int  OnRetrieve()
      {
         if(GetParam())
         if(GetWinParam())
         {
            xaserverarg arg = GetParam();
            string val = arg.GetArgString("value");
            xml x = new xml;
            x.setNativePointer(x.CreateInstance());
            x.LoadXml(val);
            xaserverarg arg = GetArg();
            xstring val = arg.GetArgString(L"value");
            xml x ;
            x.loadXML(val);
            dw_list.Retrieve(x);
            dw_list.Redraw();
         
            string sPartyNo = publiccode::GetIdentityNo("Party2");
            string No ="";
            string Name ="";
            string NameEx ="";
            xstring sPartyNo = publiccode::GetIdentityNo(L"Party2");
            xstring No =L"";
            xstring Name =L"";
            xstring NameEx =L"";
            /*for(int i=0; i <=dw_list.GetRowCount() ;i++)
            {
               Name=dw_list.GetItemString(i,"Name");
               if(Name !="")
               Name=dw_list.GetItemString(i,L"Name");
               if(Name !=L"")
               {
                  if(NameEx =="")
                  if(NameEx ==L"")
                  {
                     NameEx = Name;
                  }
@@ -153,15 +167,15 @@
               if(row==1) 
                  No = sPartyNo;
               else
                  No = ("0000"+(No.toInt()+1).toString()).right(4);
               dw_list.SetItemString(row,"PartyNo",No+"N");
               dw_list.SetItemString(row,"Type","12");
               dw_list.SetItemString(row,"IdentifyAddressFlag","Y");
               dw_list.SetItemString(row,"PrimaryFlag","Y");
                  No = (L"0000"+xstring((No.toInt()+1))).right(4);
               dw_list.SetItemString(row,L"PartyNo",No+L"N");
               dw_list.SetItemString(row,L"Type",L"12");
               dw_list.SetItemString(row,L"IdentifyAddressFlag",L"Y");
               dw_list.SetItemString(row,L"PrimaryFlag",L"Y");
               
               string id = ViewObject::GetGuid();
               msxml::IXMLDOMElement ele = dw_list.GetRowElement(row);
               ele.SetAttribute("guid",id);
               xstring id = ViewObject::GetGuid();
               KXMLDOMElement ele = dw_list.GetRowElement(row);
               ele.setAttribute(L"guid",id);
               //dw_list.SetGuid(row,id);
            }
         }
@@ -170,8 +184,9 @@
      
      int onload()
      {
         dw_list = GetControl("dw_list");
         dw_list.openUrl("/sale/view/Quote3/template/Quote/QuoteSupplierItem");
         SetArg();
         dw_list = GetControl(L"dw_list");
         dw_list.openUrl(L"/sale/view/Quote3/template/Quote/QuoteSupplierItem");
      
         OnAttachEvent();   
         OnRetrieve();
@@ -186,4 +201,3 @@
         return 1;
      }      
   };
]