xj qian
2024-06-25 53b6f7ad5895724e7db403283516775eeee7f5d8
jrj/project/business/Customer3.maint.cpp
@@ -1,12 +1,15 @@
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <xcontrol/xlayersheet.hpp>
#include "vbusiness/vframe/maint.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
class maintCustomerv3 : public maint
using xml = KXMLDOMDocument;
class __declspec(dllexport) maintCustomerv3 : public maint
{
public:
   xlayersheet xsheet;      
   xlayersheet m_layer;            
   xdwtable   dw_detail;
@@ -21,273 +24,284 @@
   xdwgrid   dw_account;
   
   int            iLayer;//页面Index
   int            iLayer;//页面Index
   int APP=1;         
   string    CustomerGoodsHWND;
   string userno;
   string ApplyStatus;
   HWND    CustomerGoodsHWND;
   xstring userno;
   xstring ApplyStatus;
   /*struct PUser
   {
      string id;
      string no;
      string name;
      xstring id;
      xstring no;
      xstring name;
   };*/
public:
   maintCustomerv3(void* implPtr, HWND hWnd) :maint(implPtr, hWnd) {}
public:
   static maintCustomerv3* CreateInstance(void* implPtr, void* hWnd)
   {
      maintCustomerv3* pWin = new maintCustomerv3(implPtr, (HWND)hWnd);
      return pWin;
   }
   string GetGuid()
   xstring GetGuid()
   {
      return publiccode::GetGuid();         
   }   
   
   int ViewUpdate(int pr,string updateItem,xaserverarg  arg)
   int ViewUpdate(int pr,xstring updateItem,xaserverarg  arg)
   {
      if(updateItem=="update")
      if(updateItem==L"update")
      {
      
         dw_detail.ResetUpdateStatus();                        
      }   
      return 1;
   }   
   string GetEntityData(int pr)
   xstring GetEntityData(LPARAM pr)
   {
      xml x = new xml;
      x.setNativePointer(xml::CreateInstance());
      dw_detail.DwUpdateAllTo(x.GetXmlDoc());
      xml x;
      
      msxml::IXMLDOMElement e=x.GetXmlDoc().documentElement;
      dw_detail.DwUpdateAllTo(x);
      
      xml x1 = new xml;
      x1.setNativePointer(xml::CreateInstance());
      dw_visit.DwUpdateAllTo(x1.GetXmlDoc());
      msxml::IXMLDOMElement e1=x1.GetXmlDoc().documentElement;
      msxml::IXMLDOMNodeList  oNodeList = e1.selectNodes("//Customer/*");
      KXMLDOMElement e=x.documentElement();
      xml x1 ;
      dw_visit.DwUpdateAllTo(x1);
      KXMLDOMElement e1=x1.documentElement();
      KXMLDOMNodeList  oNodeList = e1.selectNodes(L"//Customer/*");
      int i=0;
      for (i=0; i<oNodeList.length; i++)
      for (i=0; i<oNodeList.length(); i++)
      {
        msxml::IXMLDOMElement Item = oNodeList.item(i);
        KXMLDOMElement Item = oNodeList.item(i);
        e.appendChild(Item);
      }
      
      xml x2= new xml;
      x2.setNativePointer(xml::CreateInstance());
      dw_Meetings.DwUpdateAllTo(x2.GetXmlDoc());
      msxml::IXMLDOMElement e2=x2.GetXmlDoc().documentElement;
      msxml::IXMLDOMNodeList  oNodeList2 = e2.selectNodes("//Customer/*");
      dw_Meetings.DwUpdateAllTo(x2);
      KXMLDOMElement e2=x2.documentElement();
      KXMLDOMNodeList  oNodeList2 = e2.selectNodes(L"//Customer/*");
      int i2=0;
      for (i2=0; i2<oNodeList2.length; i2++)
      for (i2=0; i2<oNodeList2.length(); i2++)
      {
        msxml::IXMLDOMElement Item2 = oNodeList2.item(i2);
        KXMLDOMElement Item2 = oNodeList2.item(i2);
        e.appendChild(Item2);
      }
      
      xml x3= new xml;
      x3.setNativePointer(xml::CreateInstance());
      dw_MeetingsEx.DwUpdateAllTo(x3.GetXmlDoc());
      msxml::IXMLDOMElement e3=x3.GetXmlDoc().documentElement;
      msxml::IXMLDOMNodeList  oNodeList3 = e3.selectNodes("//Customer/*");
      dw_MeetingsEx.DwUpdateAllTo(x3);
      KXMLDOMElement e3=x3.documentElement();
      KXMLDOMNodeList  oNodeList3 = e3.selectNodes(L"//Customer/*");
      int i3=0;
      for (i3=0; i3<oNodeList3.length; i3++)
      for (i3=0; i3<oNodeList3.length(); i3++)
      {
        msxml::IXMLDOMElement Item3 = oNodeList3.item(i3);
        KXMLDOMElement Item3 = oNodeList3.item(i3);
        e.appendChild(Item3);
      }
      
      trace(e.xml);
      return e.xml;
      trace(e.xml());
      return e.xml();
   }
   
   int OnInit()
   {
      userno = xaserver::GetUserNo();
      //PUser User = publiccode::GetUserInfo();
      dw_detail.SetItemString(1,"SalesPersonID",xaserver::GetUserId());
      dw_detail.SetItemDisplayString(1,"SalesPersonID",publiccode::GetUser().name);
      dw_detail.SetItemString(1,"CreatorID",xaserver::GetUserId());
      dw_detail.SetItemDisplayString(1,"CreatorID",publiccode::GetUser().name);
      dw_detail.SetItemString(1,"CreateDate",publiccode::GetCurrentDate());
      dw_detail.SetItemString(1,"ModifyDate",publiccode::GetCurrentDate());
      dw_detail.SetItemString(1,"Status","1");
      dw_detail.SetItemString(1,"PAStatus","1"); //地址状态
      dw_detail.SetItemString(1,"PrimaryFlag","Y"); //主地址
      dw_detail.SetItemString(1,"Type","1"); //客户为 1
      dw_detail.SetItemString(1,"IdentifyAddressFlag","Y"); //没必要,暂时留着
      dw_detail.SetItemString(1,L"SalesPersonID",xaserver::GetUserId());
      dw_detail.SetItemDisplayString(1,L"SalesPersonID",publiccode::GetUser().name);
      dw_detail.SetItemString(1,L"CreatorID",xaserver::GetUserId());
      dw_detail.SetItemDisplayString(1,L"CreatorID",publiccode::GetUser().name);
      dw_detail.SetItemString(1,L"CreateDate",publiccode::GetCurrentDate());
      dw_detail.SetItemString(1,L"ModifyDate",publiccode::GetCurrentDate());
      dw_detail.SetItemString(1,L"Status",L"1");
      dw_detail.SetItemString(1,L"PAStatus",L"1"); //地址状态
      dw_detail.SetItemString(1,L"PrimaryFlag",L"Y"); //主地址
      dw_detail.SetItemString(1,L"Type",L"1"); //客户为 1
      dw_detail.SetItemString(1,L"IdentifyAddressFlag",L"Y"); //没必要,暂时留着
      
      string sdate = publiccode::GetCurrentDate();
      dw_detail.SetItemString(1,"ApplyDate",sdate);
      dw_detail.SetItemString(1,"ApplyStatus","新建");
      dw_detail.SetItemString(1,"Level","");
      xstring sdate = publiccode::GetCurrentDate();
      dw_detail.SetItemString(1,L"ApplyDate",sdate);
      dw_detail.SetItemString(1,L"ApplyStatus",L"新建");
      dw_detail.SetItemString(1,L"Level",L"");
      
      //dw_detail.SetItemDisplayString(1,"客户资料","客户资料附件");
      dw_detail.SetItemString(1,"客户资料","客户资料附件");
      string guid = publiccode::GetGuid();
      //dw_detail.SetItemDisplayString(1,L"客户资料",L"客户资料附件");
      dw_detail.SetItemString(1,L"客户资料",L"客户资料附件");
      xstring guid = publiccode::GetGuid();
      dw_detail.SetGuid(1,guid);
      dw_detail.Redraw();
      return 1;
   }
   
   string GetPartyID(string sName,string sType)
   xstring GetPartyID(xstring sName,xstring sType)
   {
      xml x1=new xml;
      x1.setNativePointer(xml::CreateInstance());
      xaserverarg arg=new xaserverarg;
      xaserverarg arg;
      arg.setNativePointer(arg.CreateInstance());      
      arg.AddArg("sname", sName);
      arg.AddArg("type",sType);
      if(url::get("/sale/data/"+GetEntityName(1)+"/pref/searchname",arg.GetString(),x1)!=1)
      arg.AddArg(L"sname", sName);
      arg.AddArg(L"type",sType);
      if(xurl::get(L"/sale/data/"+GetEntityName(1)+L"/pref/searchname",arg.GetString(),x1)!=1)
      {
         string error = x1.GetXmlDoc().text;
         //alert("/sale/data/"+GetEntityName(1)+"/pref/searchname");
         return "";
         xstring error = x1.text();
         //alert(L"/sale/data/"+GetEntityName(1)+L"/pref/searchname");
         return L"";
      }
      string sID="";
      if(x1.GetXmlDoc().selectSingleNode("root/PartyID"))
         sID = x1.GetXmlDoc().selectSingleNode("root/PartyID").text;
      return sID+"";
      xstring sID=L"";
      if(x1.selectSingleNode(L"root/PartyID"))
         sID = x1.selectSingleNode(L"root/PartyID").text();
      return sID+xstring(L"");
   }
   int OnItemChanged(ref TNotifyEvent evt,int p)
   int OnItemChanged(TEvent* evt, int p)
   {   
      ref DWNMHDR  hdr = evt.pnmh;
      string colname = hdr.colname;
      string coldata = hdr.data;
      //根据国别显示地区代码
      if (colname == "CountryCode")
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      xstring colname = hdr->colname;
      xstring coldata = hdr->data;
      int row = hdr->row;
      //根据国别显示地区代码
      if (colname == L"CountryCode")
      {
         xaserverarg arg = new xaserverarg;
         xaserverarg arg ;
         arg.setNativePointer(arg.CreateInstance());
         arg.AddArg("countryCode",coldata);
         xml x = new xml;
         x.setNativePointer(x.CreateInstance());
         if (getUrl("/sale/data/"+GetEntityName(1)+"/pref/areacode",arg.GetString(),x)==1)
         arg.AddArg(L"countryCode",coldata);
         xml x;
         if (getUrl(L"/sale/data/"+GetEntityName(1)+L"/pref/areacode",arg.GetString(),x)==1)
         {
            string sareacode = "";
            string sareaname = "";
            if(x.GetXmlDoc().selectSingleNode("//AreaCode"))
            xstring sareacode = L"";
            xstring sareaname = L"";
            if(x.selectSingleNode(L"//AreaCode"))
            {
               sareacode = x.GetXmlDoc().selectSingleNode("//AreaCode").text;
               sareaname = x.GetXmlDoc().selectSingleNode("//AreaName").text;
               sareacode = x.selectSingleNode(L"//AreaCode").text();
               sareaname = x.selectSingleNode(L"//AreaName").text();
            }
            dw_detail.SetItemString(1,"AreaCode",sareacode);
            dw_detail.SetItemDisplayString(1,"AreaCode",sareaname);
            dw_detail.SetItemString(1,L"AreaCode",sareacode);
            dw_detail.SetItemDisplayString(1,L"AreaCode",sareaname);
            dw_detail.Redraw();
         }
      }
      
      //只能选一个主联系人
      if (colname == "PrimaryFlag" && coldata == "Y")
      //只能选一个主联系人
      if (colname == L"PrimaryFlag" && coldata == L"Y")
      {
         xdwtable dw_pc;
         dw_pc = dw_detail.FindDwTable("item1");
         dw_pc = dw_detail.FindDwTable(L"item1");
         if (dw_pc)
         {
            int i;
            for (i=1;i <= dw_pc.GetRowCount();i++)
            {
               if (i != hdr.row)
               if (i != row)
               {
                  dw_pc.SetItemString(i,"PrimaryFlag","N");
                  dw_pc.SetItemDisplayString(i,"PrimaryFlag","");
                  dw_pc.SetItemString(i,L"PrimaryFlag",L"N");
                  dw_pc.SetItemDisplayString(i,L"PrimaryFlag",L"");
                  
               }
            }
         }
      }
      //客户名相同。
      if (colname == "Name")
      //客户名相同。
      if (colname == L"Name")
      {
      //alert(coldata);
      /*   string sguid = GetPartyID(coldata,colname);
         if (sguid != "")
      /*   xstring sguid = GetPartyID(coldata,colname);
         if (sguid != L"")
         {
            alert("客户名称与系统已有客户重复,请于管理员联系解决!");
            alert(L"客户名称与系统已有客户重复,请于管理员联系解决!");
         }*/
         //alert("ccc");
         //alert(L"ccc");
      }
   
      //客户简称
      if (colname == "ShortName")
      //客户简称
      if (colname == L"ShortName")
      {
         string sguid1 = GetPartyID(coldata,colname);
         xstring sguid1 = GetPartyID(coldata,colname);
         //trace(sguid1);
         if (sguid1 != "")
         if (sguid1 != L"")
         {
            alert("客户简称重复,请改用其他简称!");
            alert(L"客户简称重复,请改用其他简称!");
         }
      }
      //根据客户来源填写客户备注
      /*if (colname == "Source")
      //根据客户来源填写客户备注
      /*if (colname == L"Source")
      {
         if(coldata=="025")
            alert("来源备注对应填写客户如何知道我们公司");
         if(coldata=="017" || coldata=="018")
            alert("来源备注对应填写哪个客户介绍的");
         if(coldata=="019")
            alert("来源备注对应填写哪个海外办事处或者联络点介绍");
         if(coldata=="020")
            alert("来源备注对应填写哪个门店介绍");
         if(coldata=="021")
            alert("来源备注对应填写谁介绍");
         if(coldata=="026")
            alert("来源备注对应填写谁考察市场争取到的客户");
         if(coldata=="028")
            alert("来源备注对应填写国外展会名称");
         if(coldata=="034")
            alert("来源备注对应填写谁的代理业务");
         if(coldata=="001" || coldata=="002" )
            alert("来源备注对应填写客户如何知道我们公司");
         if(coldata=="0052" || coldata=="0053" || coldata=="0054" || coldata=="0055" || coldata=="0051")
            dw_detail.SetItemString(1,"SourceRemark","阿里巴巴");
         if(coldata=="0161" || coldata=="0162" )
            dw_detail.SetItemString(1,"SourceRemark","环球资源");
         if(coldata=="0061" || coldata=="0062" )
            dw_detail.SetItemString(1,"SourceRemark","中国制造网");
         if(coldata=="022" || coldata=="023"  || coldata=="037"  || coldata=="038"  || coldata=="039"  || coldata=="040"  || coldata=="007"  || coldata=="024" )
            dw_detail.SetItemString(1,"SourceRemark","MH网站");
         if(coldata==L"025")
            alert(L"来源备注对应填写客户如何知道我们公司");
         if(coldata==L"017" || coldata==L"018")
            alert(L"来源备注对应填写哪个客户介绍的");
         if(coldata==L"019")
            alert(L"来源备注对应填写哪个海外办事处或者联络点介绍");
         if(coldata==L"020")
            alert(L"来源备注对应填写哪个门店介绍");
         if(coldata==L"021")
            alert(L"来源备注对应填写谁介绍");
         if(coldata==L"026")
            alert(L"来源备注对应填写谁考察市场争取到的客户");
         if(coldata==L"028")
            alert(L"来源备注对应填写国外展会名称");
         if(coldata==L"034")
            alert(L"来源备注对应填写谁的代理业务");
         if(coldata==L"001" || coldata==L"002" )
            alert(L"来源备注对应填写客户如何知道我们公司");
         if(coldata==L"0052" || coldata==L"0053" || coldata==L"0054" || coldata==L"0055" || coldata==L"0051")
            dw_detail.SetItemString(1,L"SourceRemark",L"阿里巴巴");
         if(coldata==L"0161" || coldata==L"0162" )
            dw_detail.SetItemString(1,L"SourceRemark",L"环球资源");
         if(coldata==L"0061" || coldata==L"0062" )
            dw_detail.SetItemString(1,L"SourceRemark",L"中国制造网");
         if(coldata==L"022" || coldata==L"023"  || coldata==L"037"  || coldata==L"038"  || coldata==L"039"  || coldata==L"040"  || coldata==L"007"  || coldata==L"024" )
            dw_detail.SetItemString(1,L"SourceRemark",L"MH网站");
      }*/
      //联系人Title选择。
      if (colname == "Title")
      //联系人Title选择。
      if (colname == L"Title")
      {
         xdwtable dw_PartyContact;
         dw_PartyContact = dw_detail.FindDwTable("PartyContact");
         if(coldata=="MR")
            dw_PartyContact.SetItemString(dw_PartyContact.GetRow(),"Gender","男");
         else if(coldata=="MS" || coldata=="MADAM" || coldata=="MRS" )
            dw_PartyContact.SetItemString(dw_PartyContact.GetRow(),"Gender","女");
         dw_PartyContact = dw_detail.FindDwTable(L"PartyContact");
         if(coldata==L"MR")
            dw_PartyContact.SetItemString(dw_PartyContact.GetRow(),L"Gender",L"男");
         else if(coldata==L"MS" || coldata==L"MADAM" || coldata==L"MRS" )
            dw_PartyContact.SetItemString(dw_PartyContact.GetRow(),L"Gender",L"Ů");
         else
            dw_PartyContact.SetItemString(dw_PartyContact.GetRow(),"Gender","");
            dw_PartyContact.SetItemString(dw_PartyContact.GetRow(),L"Gender",L"");
            
      }
      if (colname=="SalesPersonID"  && coldata != "")//设置人员归属
      if (colname==L"SalesPersonID"  && coldata != L"")//设置人员归属
      {
         trace("asdasd");
         string ls_deptname,ls_teamname,ls_groupname,ls_unitname;
         trace(L"asdasd");
         xstring ls_deptname,ls_teamname,ls_groupname,ls_unitname;
         ls_deptname =  publiccode::GetUser(coldata).deptname;
         ls_teamname = publiccode::GetUser(coldata).teamname;
         ls_groupname =  publiccode::GetUser(coldata).groupname;
         ls_unitname = publiccode::GetUser(coldata).unitname;
         trace(ls_unitname);
         dw_detail.SetItemString(1,"OrgName",ls_deptname+ls_teamname+ls_groupname+ls_unitname );
         dw_detail.SetItemString(1,L"OrgName",ls_deptname+xstring(ls_teamname)+ xstring(ls_groupname)+ xstring(ls_unitname) );
      }
      //根据生日自动设置年龄。
      /*if (colname == "Birthday")
      //根据生日自动设置年龄。
      /*if (colname == L"Birthday")
      {
         xdwtable dw_PartyContact1;
         dw_PartyContact1 =dw_detail.FindDwTable("PC_OtherInfo");
         dw_PartyContact1 =dw_detail.FindDwTable(L"PC_OtherInfo");
         xml xx = new xml;
         xx.setNativePointer(xml ::CreateInstance());
         xaserverarg argnew = new xaserverarg;
         argnew.setNativePointer(argnew.CreateInstance());   
         string    agesql;
         agesql =  "select Dbo.GetAge( '{$Birthday}',getdate()) for xml PATH('root'),ELEMENTS XSINIL";
         argnew.AddArg("sql",agesql);
         argnew.AddArg("Birthday",coldata);
         xstring    agesql;
         agesql =  L"select Dbo.GetAge( '{$Birthday}',getdate()) for xml PATH('root'),ELEMENTS XSINIL";
         argnew.AddArg(L"sql",agesql);
         argnew.AddArg(L"Birthday",coldata);
         if (getSql(argnew.GetString(),xx) == 1)
         {
            msxml::IXMLDOMElement AgeEle=xx.GetXmlDoc().documentElement;
            dw_PartyContact1.SetItemString(1,"Age",AgeEle.text);
            KXMLDOMElement AgeEle=xx.documentElement;
            dw_PartyContact1.SetItemString(1,L"Age",AgeEle.text());
         }                                          
      }*/
      return 1;
@@ -298,17 +312,17 @@
      xdwtable dw_obj;            
      xdwtable dw_contact;
      dw_contact = dw_detail.GetCurTable();
      string sDwname = dw_contact.GetDwName();
      if(sDwname.find("item") >=0 ) sDwname = dw_contact.GetParent().GetDwName();
      if(sDwname=="PartyContact")
      xstring sDwname = dw_contact.GetDwName();
      if(sDwname.find(L"item") >=0 ) sDwname = dw_contact.GetParent().GetDwName();
      if(sDwname==L"PartyContact")
      {
         int iRowPc = dw_contact.InsertRow(0);
      }
      else if(sDwname=="PartyAddress")
      else if(sDwname==L"PartyAddress")
      {
         int iRowPad = dw_contact.InsertRow(0);
      }
      else if(sDwname=="PartyBankAccount")
      else if(sDwname==L"PartyBankAccount")
      {
         int iRowPba = dw_contact.InsertRow(0);
      }      
@@ -317,27 +331,27 @@
      //alert(nindex.toString());
      if(nindex==5)
      {   
         dw_obj=GetControl("dw_jzfx");
         dw_obj=GetControl(L"dw_jzfx");
         xdwtable dw = dw_obj.GetCurTable();   
         int row = dw.InsertRow(1, 0);
         dw.SetItemString(row,"SeqNo",row.toString());
         dw.SetItemString(row,L"SeqNo",xstring(row));
      }
      if(nindex==4)
      {   
         dw_obj=GetControl("dw_visit");
         dw_obj=GetControl(L"dw_visit");
         xdwtable dw1 = dw_obj.GetCurTable();            
         int row1 = dw1.InsertRow(0);   
      }
      if(nindex==3)
      {   
         dw_obj=GetControl("dw_MeetingsEx");
         dw_obj=GetControl(L"dw_MeetingsEx");
         xdwtable dw3 = dw_obj.GetCurTable();            
         int row3 = dw3.InsertRow(0);   
      }
      
      if(nindex==2)
      {   
         dw_obj=GetControl("dw_Meetings");
         dw_obj=GetControl(L"dw_Meetings");
         xdwtable dw2 = dw_obj.GetCurTable();            
         int row2 = dw2.InsertRow(0);   
      }
@@ -349,17 +363,17 @@
      xdwtable dw_obj;                  
      xdwtable dw_contact;
      dw_contact = dw_detail.GetCurTable();
      string sDwname = dw_contact.GetDwName();
      if(sDwname.find("item") >=0 ) sDwname = dw_contact.GetParent().GetDwName();
      if(sDwname=="PartyContact")
      xstring sDwname = dw_contact.GetDwName();
      if(sDwname.find(L"item") >=0 ) sDwname = dw_contact.GetParent().GetDwName();
      if(sDwname==L"PartyContact")
      {
         int iRowPc = dw_contact.InsertRow(dw_contact.GetRow());
      }
      else if(sDwname=="PartyAddress")
      else if(sDwname==L"PartyAddress")
      {
         int iRowPad = dw_contact.InsertRow(dw_contact.GetRow());
      }
      else if(sDwname=="PartyBankAccount")
      else if(sDwname==L"PartyBankAccount")
      {
         int iRowPba = dw_contact.InsertRow(dw_contact.GetRow());
      }
@@ -367,26 +381,26 @@
      int nindex = h+1;
      if(nindex==5)
      {   
         dw_obj=GetControl("dw_jzfx");
         xdwtable dw = dw_obj.FindDwTable("CustomerJzfx");
         dw_obj=GetControl(L"dw_jzfx");
         xdwtable dw = dw_obj.FindDwTable(L"CustomerJzfx");
         int row = dw.InsertRow(1,dw.GetRow());
         //dw.SetGuid(row,publiccode::GetGuid());
      }
      if(nindex==4)
      {   
         dw_obj=GetControl("dw_visit");
         dw_obj=GetControl(L"dw_visit");
         xdwtable dw1 =dw_obj.GetCurTable();   
         int row1 = dw1.InsertRow(dw1.GetRow());   
      }
      if(nindex==3)
      {   
         dw_obj=GetControl("dw_MeetingsEx");
         dw_obj=GetControl(L"dw_MeetingsEx");
         xdwtable dw3 =dw_obj.GetCurTable();   
         int row3 = dw3.InsertRow(dw3.GetRow());   
      }      
      if(nindex==2)
      {   
         dw_obj=GetControl("dw_Meetings");
         dw_obj=GetControl(L"dw_Meetings");
         xdwtable dw2 =dw_obj.GetCurTable();   
         int row2 = dw2.InsertRow(dw2.GetRow());   
      }
@@ -398,9 +412,9 @@
      xdwtable dw_obj;               
      xdwtable dw_contact;
      dw_contact = dw_detail.GetCurTable();
      string sDwname = dw_contact.GetDwName();
      if(sDwname.find("item") >=0 ) sDwname = dw_contact.GetParent().GetDwName();
      if(sDwname=="PartyContact" ||sDwname=="PartyAddress" ||sDwname=="PartyBankAccount" )
      xstring sDwname = dw_contact.GetDwName();
      if(sDwname.find(L"item") >=0 ) sDwname = dw_contact.GetParent().GetDwName();
      if(sDwname==L"PartyContact" ||sDwname==L"PartyAddress" ||sDwname==L"PartyBankAccount" )
      {
         int row = dw_contact.GetRow();
         dw_contact.DeleteRow(row);
@@ -409,7 +423,7 @@
      int nindex = h+1;
      if(nindex==5)
      {   
         dw_obj=GetControl("dw_jzfx");
         dw_obj=GetControl(L"dw_jzfx");
         xdwtable dw = dw_obj.GetCurTable();         
         int row1 = dw.GetRow();
         if(dw.GetRowCount() >1)
@@ -417,21 +431,21 @@
      }
      if(nindex==4)
      {   
         dw_obj=GetControl("dw_visit");
         dw_obj=GetControl(L"dw_visit");
         xdwtable dw1 = dw_obj.GetCurTable();         
         int row2 = dw1.GetRow();
         dw1.DeleteRow(row2);      
      }
      if(nindex==3)
      {   
         dw_obj=GetControl("dw_MeetingsEx");
         dw_obj=GetControl(L"dw_MeetingsEx");
         xdwtable dw4 = dw_obj.GetCurTable();         
         int row4 = dw4.GetRow();
         dw4.DeleteRow(row4);      
      }   
      if(nindex==2)
      {   
         dw_obj=GetControl("dw_Meetings");
         dw_obj=GetControl(L"dw_Meetings");
         xdwtable dw3 = dw_obj.GetCurTable();         
         int row3 = dw3.GetRow();
         dw3.DeleteRow(row3);      
@@ -441,204 +455,204 @@
   
   int OnDetailRow()
   {
      trace("detail");
      trace(L"detail");
      return 0;
   }
   int OnPreSave()
   {
      xml xxx = new xml;
      xxx.setNativePointer(xxx.CreateInstance());
      dw_detail.DwUpdateAllTo(xxx.GetXmlDoc());
      trace(xxx.GetXml());
      xml xxx ;
      dw_detail.DwUpdateAllTo(xxx);
      trace(xxx.xml());
      //return 0;
      
      //客户名称
      string sName;
      sName = dw_detail.GetItemString(1,"Name");
      if (sName == "")
      //客户名称
      xstring sName;
      sName = dw_detail.GetItemString(1,L"Name");
      if (sName == L"")
      {
         alert("客户名称不能为空!");
         alert(L"客户名称不能为空!");
         return 0;
      }
      
      string sShortName = dw_detail.GetItemString(1,"ShortName");
      if (sShortName == "")
      xstring sShortName = dw_detail.GetItemString(1,L"ShortName");
      if (sShortName == L"")
      {
         alert("客户简称不能为空!");
         alert(L"客户简称不能为空!");
         return 0;
      }
      string Level = dw_detail.GetItemString(1,"Level");
      /*if (Level == "")
      xstring Level = dw_detail.GetItemString(1,L"Level");
      /*if (Level == L"")
      {
         alert("客户等级不能为空!");
         alert(L"客户等级不能为空!");
         return 0;
      }*/
      
      /*
      if(dw_detail.GetItemString(1,"Address")=="")
      if(dw_detail.GetItemString(1,L"Address")==L"")
      {
         alert("客户地址不能为空!");
         alert(L"客户地址不能为空!");
         return 0;
      }
      
      if(dw_detail.GetItemString(1,"Source")=="")
      if(dw_detail.GetItemString(1,L"Source")==L"")
      {
         alert("客户来源不能为空!");
         alert(L"客户来源不能为空!");
         return 0;
      }
      if(dw_detail.GetItemString(1,"CountryCode")=="")
      if(dw_detail.GetItemString(1,L"CountryCode")==L"")
      {
         alert("客户国别不能为空!");
         alert(L"客户国别不能为空!");
         return 0;
      }
      if(dw_detail.GetItemString(1,"TEL")=="")
      if(dw_detail.GetItemString(1,L"TEL")==L"")
      {
         alert("公司电话不能为空!");
         alert(L"公司电话不能为空!");
         return 0;
      }*/
      //客户简称不能重复
      //客户简称不能重复
      /*
      string sPartyID = GetPartyID(sShortName,"ShortName");
      if (sPartyID != "")
      xstring sPartyID = GetPartyID(sShortName,L"ShortName");
      if (sPartyID != L"")
      {
         alert("此客户简称已经存在!");
         alert(L"此客户简称已经存在!");
      }
      */
      
      //客户代码
      string sPartyNo;
      sPartyNo = dw_detail.GetItemString(1,"PartyNo");
      if (sPartyNo == "" )
      //客户代码
      xstring sPartyNo;
      sPartyNo = dw_detail.GetItemString(1,L"PartyNo");
      if (sPartyNo == L"" )
      {
         //alert("客户代码不能为空!");
         //alert(L"客户代码不能为空!");
         //return 0;
         
         string sNo = publiccode::GetIdentityNo("Party1");
         if (sNo == "")
            sNo == "1000";
         dw_detail.SetItemString(1,"PartyNo",sNo);
         xstring sNo = publiccode::GetIdentityNo(L"Party1");
         if (sNo == L"")
            sNo == L"1000";
         dw_detail.SetItemString(1,L"PartyNo",sNo);
         
      }   
      //成立时间YearEstablished
      //雇员数量Employees
      //string sYearEstablished = dw_detail.GetItemString(1,"YearEstablished");
      //string sEmployees = dw_detail.GetItemString(1,"Employees");
      //成立时间YearEstablished
      //雇员数量Employees
      //xstring sYearEstablished = dw_detail.GetItemString(1,L"YearEstablished");
      //xstring sEmployees = dw_detail.GetItemString(1,L"Employees");
      //sYearEstablished.toInt();
         
      
      //联系人姓名Name-PCName,设置状态
      //联系人姓名Name-PCName,设置状态
      xdwtable dw_PartyContact;
      dw_PartyContact = dw_detail.FindDwTable("PartyContact");
      dw_PartyContact = dw_detail.FindDwTable(L"PartyContact");
      xdwtable PC_OtherInfo;
      PC_OtherInfo = dw_detail.FindDwTable("PC_OtherInfo");
      PC_OtherInfo = dw_detail.FindDwTable(L"PC_OtherInfo");
      int countflag=0;               
      if (dw_PartyContact)
      {
         int i;
         for (i=1;i <= dw_PartyContact.GetRowCount();i++)
         {
            string sPCName = dw_PartyContact.GetItemString(i,"Name");
            if (sPCName == "" )
            xstring sPCName = dw_PartyContact.GetItemString(i,L"Name");
            if (sPCName == L"" )
            {
               string sPCTitle = dw_PartyContact.GetItemString(i,"Title");
               if (sPCTitle == "") sPCTitle = "";
               string sPCJobTitle = dw_PartyContact.GetItemString(i,"JobTitle");
               if (sPCJobTitle == "") sPCJobTitle = "";
               string sPCGender = dw_PartyContact.GetItemString(i,"Gender");
               if (sPCGender == "") sPCGender = "";
               string sPCMobile = dw_PartyContact.GetItemString(i,"Mobile");
               if (sPCMobile == "") sPCMobile = "";
               string sPCTEL = dw_PartyContact.GetItemString(i,"TEL");
               if (sPCTEL == "") sPCTEL = "";
               string sPCEmail = dw_PartyContact.GetItemString(i,"Email");
               if (sPCEmail == "") sPCEmail = "";
               string sAll = sPCTitle + sPCJobTitle + sPCGender + sPCMobile + sPCTEL + sPCEmail;
               /*if (sAll != "")
               xstring sPCTitle = dw_PartyContact.GetItemString(i,L"Title");
               if (sPCTitle == L"") sPCTitle = L"";
               xstring sPCJobTitle = dw_PartyContact.GetItemString(i,L"JobTitle");
               if (sPCJobTitle == L"") sPCJobTitle = L"";
               xstring sPCGender = dw_PartyContact.GetItemString(i,L"Gender");
               if (sPCGender == L"") sPCGender = L"";
               xstring sPCMobile = dw_PartyContact.GetItemString(i,L"Mobile");
               if (sPCMobile == L"") sPCMobile = L"";
               xstring sPCTEL = dw_PartyContact.GetItemString(i,L"TEL");
               if (sPCTEL == L"") sPCTEL = L"";
               xstring sPCEmail = dw_PartyContact.GetItemString(i,L"Email");
               if (sPCEmail == L"") sPCEmail = L"";
               xstring sAll = sPCTitle + sPCJobTitle + sPCGender + sPCMobile + sPCTEL + sPCEmail;
               /*if (sAll != L"")
               {
                  alert("联系人姓名不能为空");
                  alert(L"联系人姓名不能为空");
                  return 0;
               }*/
            }
            else
            {
               string aStatus;
               aStatus = dw_PartyContact.GetItemString(i,"Status",0);
               if (aStatus=="")
               xstring aStatus;
               aStatus = dw_PartyContact.GetItemString(i,L"Status");
               if (aStatus==L"")
               {
                  dw_PartyContact.SetItemString(i,"Status","1");
                  dw_PartyContact.SetItemString(i,L"Status",L"1");
               }            
            }
            if(dw_PartyContact.GetItemString(i,"ContactID")=="")
            if(dw_PartyContact.GetItemString(i,L"ContactID")==L"")
            {   
               dw_PartyContact.SetItemString(i,"ContactID",GetGuid());
               dw_PartyContact.SetItemString(i,L"ContactID",GetGuid());
            }                     
            string sFlag = dw_PartyContact.GetItemString(i,"PrimaryFlag");
            if(sFlag=="Y")
            xstring sFlag = dw_PartyContact.GetItemString(i,L"PrimaryFlag");
            if(sFlag==L"Y")
            {               
               countflag ++;
               dw_PartyContact.SetItemString(i,"PrimaryFlag","Y");
               PC_OtherInfo.SetItemString(1,"ContactID",dw_PartyContact.GetItemString(i,"ContactID"));
               dw_PartyContact.SetItemString(i,L"PrimaryFlag",L"Y");
               PC_OtherInfo.SetItemString(1,L"ContactID",dw_PartyContact.GetItemString(i,L"ContactID"));
            
            }
            
         }
         if(countflag==0 && dw_PartyContact.GetItemString(1,"Name") !="")
         if(countflag==0 && dw_PartyContact.GetItemString(1,L"Name") !=L"")
         {   
            dw_PartyContact.SetItemString(1,"PrimaryFlag","Y");
            PC_OtherInfo.SetItemString(1,"ContactID",dw_PartyContact.GetItemString(1,"ContactID"));
            dw_PartyContact.SetItemString(1,L"PrimaryFlag",L"Y");
            PC_OtherInfo.SetItemString(1,L"ContactID",dw_PartyContact.GetItemString(1,L"ContactID"));
         }                           
      }
      //银行帐号BankName-BankName;BankAccountNo-PBABankAccountNo ; 设置状态
      //银行帐号BankName-BankName;BankAccountNo-PBABankAccountNo ; 设置状态
      xdwtable dw_PartyBankAccount;
      dw_PartyBankAccount =dw_detail.FindDwTable("PartyBankAccount");
      dw_PartyBankAccount =dw_detail.FindDwTable(L"PartyBankAccount");
      if (dw_PartyBankAccount)
      {
         int j;
         for (j=1;j <= dw_PartyBankAccount.GetRowCount();j++)
         {
            string sPBABankName = dw_PartyBankAccount.GetItemString(j,"BankName");
            string sPBABankAccountNo = dw_PartyBankAccount.GetItemString(j,"BankAccountNo");
            if (sPBABankName == "") sPBABankName = "";
            if (sPBABankAccountNo == "") sPBABankAccountNo = "";
            string sPBAAll = sPBABankName + sPBABankAccountNo;
            if (sPBAAll != "")
            xstring sPBABankName = dw_PartyBankAccount.GetItemString(j,L"BankName");
            xstring sPBABankAccountNo = dw_PartyBankAccount.GetItemString(j,L"BankAccountNo");
            if (sPBABankName == L"") sPBABankName = L"";
            if (sPBABankAccountNo == L"") sPBABankAccountNo = L"";
            xstring sPBAAll = sPBABankName + sPBABankAccountNo;
            if (sPBAAll != L"")
            {
               /*if (sPBABankName == "")
               /*if (sPBABankName == L"")
               {
                  alert("银行名称不能为空");
                  alert(L"银行名称不能为空");
                  return 0;
               }
               if (sPBABankAccountNo == "")
               if (sPBABankAccountNo == L"")
               {
                  alert("银行账户不能为空");
                  alert(L"银行账户不能为空");
                  return 0;
               }*/
               dw_PartyBankAccount.SetItemString(j,"Status","1");
               dw_PartyBankAccount.SetItemString(j,L"Status",L"1");
            }
         }
      }
   
      //地址,设置状态
      //地址,设置状态
      xdwtable dw_PartyAddress;
      dw_PartyAddress =dw_detail.FindDwTable("PartyAddress");
      dw_PartyAddress =dw_detail.FindDwTable(L"PartyAddress");
      if (dw_PartyAddress)
      {
         int k;
         for (k=1;k <= dw_PartyAddress.GetRowCount();k++)
         {
            string sPADAddressName = dw_PartyAddress.GetItemString(k,"AddressName");
            string sPADAddress = dw_PartyAddress.GetItemString(k,"Address");
            if (sPADAddressName == "") sPADAddressName = "";
            if (sPADAddress == "") sPADAddress = "";
            string sPADAll = sPADAddressName + sPADAddress;
            if (sPADAll != "")
            xstring sPADAddressName = dw_PartyAddress.GetItemString(k,L"AddressName");
            xstring sPADAddress = dw_PartyAddress.GetItemString(k,L"Address");
            if (sPADAddressName == L"") sPADAddressName = L"";
            if (sPADAddress == L"") sPADAddress = L"";
            xstring sPADAll = sPADAddressName + sPADAddress;
            if (sPADAll != L"")
            {
               dw_PartyAddress.SetItemString(k,"Status","1");
               dw_PartyAddress.SetItemString(k,"IdentifyAddressFlag","N");
               dw_PartyAddress.SetItemString(k,L"Status",L"1");
               dw_PartyAddress.SetItemString(k,L"IdentifyAddressFlag",L"N");
            }
         }   
      }
@@ -649,109 +663,110 @@
   {
      int rec =OnPreSave();
      if (rec != 1)   return 0;
      ProcessFlowAction("action:bill.update",1);
      ProcessFlowAction(L"action:bill.update",1);
      return 1;
   }
            
   int CustomerModify()//跳到客户修改界面
   int CustomerModify()//跳到客户修改界面
   {
      //trace("asdsad");
      xaserverarg arg = new xaserverarg;
      //trace(L"asdsad");
      xaserverarg& arg = *new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());   
      arg.AddArg("EntityID", maint::m_EntityID);
      openUrl("/sale/view/"+GetEntityName(1)+"/worknode/customermodify/open",arg);
      arg.AddArg(L"EntityID", maint::m_EntityID);
      openUrl(L"/sale/view/"+GetEntityName(1)+L"/worknode/customermodify/open", &arg);
      //CloseWindow();
      return 1;
   }
   int OnComdidSplit(string str){
      if(str.find("|", 0)<0)
   int OnComdidSplit(xstring str){
      if(str.find(L"|", 0)<0)
         return -1;
      CustomerGoodsHWND = str.mid(str.find("|",0) + 1, str.length());
      CustomerGoodsHWND = (HWND)str.mid(str.find(L"|",0) + 1, str.length()).toInt64();
   }   
         
   int OnShare()
   {
      xaserverarg arg = new xaserverarg;
      xaserverarg& arg = *new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());   
      int row = dw_detail.GetRow();
      if(row < 1) return 0;
      string PartyID = dw_detail.GetItemString(row,"PartyID");
      arg.AddArg("EntityID",PartyID);
      arg.AddArg("EntityName", "客户共享");
      OpenWindow("dev:xpage[UserGroupShare.vx]",cast(arg as int));
      xstring PartyID = dw_detail.GetItemString(row,L"PartyID");
      arg.AddArg(L"EntityID",PartyID);
      arg.AddArg(L"EntityName", L"客户共享");
      OpenWindow(L"dev:xpage[UserGroupShare.vx]", (LPARAM) & arg);
      return 1;
   }
   
   int OnShareMessage()
   {
      xaserverarg arg = new xaserverarg;
      xaserverarg& arg = *new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());   
      int row = dw_detail.GetRow();
      if(row < 1) return 0;
      string PartyID = dw_detail.GetItemString(row,"PartyID");
      arg.AddArg("PartyID",PartyID);
      OpenWindow("dev:xpage[XmShare.Custumer.v3.vx]",cast(arg as int));
      xstring PartyID = dw_detail.GetItemString(row,L"PartyID");
      arg.AddArg(L"PartyID",PartyID);
      OpenWindow(L"dev:xpage[XmShare.Custumer.v3.vx]", (LPARAM)&arg);
   return 1;
   }
      
   int PreOnCmdDispatch(string comdid)
   int PreOnCmdDispatch(xstring comdid)
   {
      if (comdid == "cb_save")
      if (comdid == L"cb_save")
      {   
         win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_save", 0);
         SendMessageW(CustomerGoodsHWND,0x401, (WPARAM)L"cb_save", 0);
      }
      else if (comdid == "cb_copy")
      else if (comdid == L"cb_copy")
      {   
         win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_copy", 0);
         SendMessageW(CustomerGoodsHWND,0x401, (WPARAM)L"cb_copy", 0);
      }
      else if (comdid == "cb_delete")
      else if (comdid == L"cb_delete")
      {   
         win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_delete", 0);
         SendMessageW(CustomerGoodsHWND,0x401, (WPARAM)L"cb_delete", 0);
      }
      else if (comdid == "cb_reflash")
      else if (comdid == L"cb_reflash")
      {   
         win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_reflash", 0);
         SendMessageW(CustomerGoodsHWND,0x401, (WPARAM)L"cb_reflash", 0);
      }
      else if(comdid == "cb_add")
      else if(comdid == L"cb_add")
      {   
         win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_add", 0);
         SendMessageW(CustomerGoodsHWND,0x401, (WPARAM)L"cb_add", 0);
      }
      else if(comdid == "cb_import")
      else if(comdid == L"cb_import")
      {   
         win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_import",0);
         SendMessageW(CustomerGoodsHWND,0x401, (WPARAM)L"cb_import",0);
      }            
      else if (comdid == "action:bill.row.add") return OnAddRow();
      else if (comdid == "action:bill.row.insert") return OnInsertRow();
      else if (comdid == "action:bill.row.delete") return OnDeleteRow();
      else if (comdid == "action:bill.row.detail") return OnDetailRow();
      else if (comdid == "action:bill.SourceRemark") return OnSourceRemark();
      else if (comdid == L"action:bill.row.add") return OnAddRow();
      else if (comdid == L"action:bill.row.insert") return OnInsertRow();
      else if (comdid == L"action:bill.row.delete") return OnDeleteRow();
      else if (comdid == L"action:bill.row.detail") return OnDetailRow();
      else if (comdid == L"action:bill.SourceRemark") return OnSourceRemark();
      
      else if (comdid == "action:bill.update")
      else if (comdid == L"action:bill.update")
      {
          return OnPreSave();
      }
      else if (comdid == "action:customermodify") return CustomerModify();
      else if(comdid.find("|",0)){
      else if (comdid == L"action:customermodify") return CustomerModify();
      else if(comdid.find(L"|",0)){
         OnComdidSplit(comdid);
      }
      if(comdid=="action:XmShare")
      if(comdid==L"action:XmShare")
      {
            OnShare();
            return 0;
      }
      if(comdid=="action:XmShareMessage")
      if(comdid==L"action:XmShareMessage")
      {
            OnShareMessage();
            return 0;
      }
   //   else if (comdid.find("action:",0) >= 0) return OnAction(comdid);
   //   else if (comdid.find(L"action:",0) >= 0) return OnAction(comdid);
      return -1;   
   }
   
   int PostOnCmdDispatch(string comdid)
   int PostOnCmdDispatch(xstring comdid)
   {
      if (comdid == "action:bill.update")
      if (comdid == L"action:bill.update")
      {
         dw_detail.ResetUpdateStatus();
         dw_visit.ResetUpdateStatus();
@@ -761,12 +776,12 @@
      
      return 1;
   }
   //选择tab页面
   int OnSelectedSheet(ref TNotifyEvent evt,int p)
   //选择tab页面
   int OnSelectedSheet(TEvent* evt,int p)
   {
      iLayer = m_layer.GetSheetIndex();
      if (iLayer == 0)
         SetAgent("maint",maint::m_EntityID);
         SetAgent(L"maint",maint::m_EntityID);
      else if (iLayer == 1)
      {         
         int cc=APP;
@@ -775,19 +790,20 @@
         if(cc==2)
         {   
            xsheet.DeleteSheet(1);
            string xp = "<xframe src='dev:xpage[CustomerGoodsVd.vx]' />";
            xaserverarg arg = new xaserverarg;
            xstring xp = L"<xframe src='dev:xpage[CustomerGoodsVd.vx]' />";
            xaserverarg& arg = * new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg("CustomerID", this.m_EntityID);
            arg.AddArg("FROM", "Customer");
            arg.AddArg("CustomerName", dw_detail.GetItemString(1,"Name"));
            arg.AddArg("config", "客户产品.vface/config/CustomerGoodsVdVd/view");
            arg.AddArg("CustomerHWND",this.GetHWND().toString());
            int p1 =arg.ptr_native_;
            int nIndex = xsheet.InsertSheet(-1, "客户ID货号库", xp, p1);
            arg.AddArg(L"CustomerID",m_EntityID);
            arg.AddArg(L"FROM", L"Customer");
            arg.AddArg(L"CustomerName", dw_detail.GetItemString(1,L"Name"));
            arg.AddArg(L"config", L"客户产品.vface/config/CustomerGoodsVdVd/view");
            //arg.AddArg(L"CustomerHWND",GetHWND().toString());
            arg.SetParam(L"CustomerHWND", (LPARAM)GetHWND());
            int nIndex = xsheet.InsertSheet(-1, L"客户ID货号库", xp, (void *) &arg);
            xsheet.SelectSheet(nIndex);                        
         }
         //win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "SetFocus", nil);
         //win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, L"SetFocus", nil);
      
      }            
      return 1;
@@ -795,30 +811,30 @@
         
   int OnSourceRemark()
   {
      string name = "客户管理";
      xml x = ViewObject::RetrieveData("/sale/data/TradeFinance3/GetSetUpRemarks","Type",name);
      msxml::IXMLDOMNodeList items = x.GetXmlDoc().selectNodes("data/Item");
      msxml::IXMLDOMNode t = items.item(0);
      string Content="";
      if(t.selectSingleNode("Content"))
      xstring name = L"客户管理";
      xml x = ViewObject::RetrieveData(L"/sale/data/TradeFinance3/GetSetUpRemarks",L"Type",name);
      KXMLDOMNodeList items = x.selectNodes(L"data/Item");
      KXMLDOMNode t = items.item(0);
      xstring Content=L"";
      if(t.selectSingleNode(L"Content"))
      {
         Content=t.selectSingleNode("Content").text;
         Content=t.selectSingleNode(L"Content").text();
      }
      xaserverarg arg1 = new xaserverarg;
      xaserverarg& arg1 = * new xaserverarg;
      arg1.setNativePointer(arg1.CreateInstance());   
      arg1.AddArg("value",Content);
      OpenWindow("dev:xpage[memo.edit.new.vx]",arg1.getNativePointer());
      arg1.AddArg(L"value",Content);
      OpenWindow(L"dev:xpage[memo.edit.new.vx]",(LPARAM) & arg1);
      return 1;
   }
   
         
   int OnItemClick(ref TNotifyEvent evt,int p)
   int OnItemClick(TEvent* evt,int p)
   {
      xdwtable dw = dw_detail.FindDwTable("item1",0);
      xdwtable dw1 = dw_detail.FindDwTable("item2",0);
      xdwtable dw2 = dw_detail.FindDwTable("item3",0);
      int start=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("Website"));
      xdwtable dw = dw_detail.FindDwTable(L"item1",0);
      xdwtable dw1 = dw_detail.FindDwTable(L"item2",0);
      xdwtable dw2 = dw_detail.FindDwTable(L"item3",0);
      int start=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex(L"Website"));
      int m,n,k;
      m=dw.GetRowCount();
      n=dw1.GetRowCount();
@@ -835,59 +851,60 @@
      {
         k=dw2.GetRowCount() +1;            
      }            
      ref DWNMHDR  hdr = cast(evt.pnmh as ref DWNMHDR);
      string value = hdr.data;
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      xstring value = hdr->data;
      //alert(value);
      xaserverarg arg=new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());
      if(value == "主要联系人其它信息")
      xaserverarg& arg=* new xaserverarg;
      if(value == L"主要联系人其它信息")
      {               
         dw_detail.ExpandCellRow(start +m +5,start +m+7);
      }
      else if(value == "其它地址")
      else if(value == L"其它地址")
      {   
         dw_detail.ExpandCellRow(start +m+9,start +m+9+n);
         //dw_base.ExpandMarginRow(-22,-20);
      }
      else if(value == "银行信息")
      else if(value == L"银行信息")
      {   
         dw_detail.ExpandCellRow(start +m+11+n,start +m+11+n+k);
         //dw_base.ExpandMarginRow(-22,-20);
      }
      else if(value == "业务概述")
      else if(value == L"业务概述")
      {      
         dw_detail.ExpandCellRow(start +m+13+n+k,start +m+13+n+k+2);
         //dw_base.ExpandMarginRow(-22,-20);
      }
      else if(value == "客户授信")
      else if(value == L"客户授信")
      {   
         dw_detail.ExpandCellRow(start +m+15+n+k +2,start +m+15+n+k +2+1);   
         //dw_base.ExpandMarginRow(-22,-20);
      }
      if(value == "客户资料附件")
      if(value == L"客户资料附件")
      {   
         
         if(userno == "admin" || userno == "00601" || userno == "00701")
         if(userno == L"admin" || userno == L"00601" || userno == L"00701")
          {
            //alert(dw_detail.GetGuid(1));
            arg.AddArg("entityid",dw_detail.GetGuid(1));
            int p3=cast(arg as int) ;
            OpenWindow("dev:xpage[maint.Document.Customer.v3.vx]", p3);
            arg.AddArg(L"entityid",dw_detail.GetGuid(1));
            OpenWindow(L"dev:xpage[maint.Document.Customer.v3.vx]", (LPARAM) & arg);
            return 1;
         }
      }
      if(value == "客户基本信息")
      if(value == L"客户基本信息")
      {   
         xaserverarg arg1 = new xaserverarg;
         arg1.setNativePointer(arg1.CreateInstance());
         string str = dw_detail.GetItemString(1,"BasicInformation");
         arg1.AddArg("value",str);
         OpenWindow("dev:xpage[memo.edit.new.vx]",arg1.getNativePointer());
         if(arg1.GetArgString("comdid")=="xmOK")
         xaserverarg& arg1 = *new xaserverarg;
         xstring str = dw_detail.GetItemString(1,L"BasicInformation");
         arg1.AddArg(L"value",str);
         OpenWindow(L"dev:xpage[memo.edit.new.vx]", (LPARAM)&arg1);
         if(arg1.GetArgString(L"comdid")==L"xmOK")
         {
            str = arg1.GetArgString("value");
            str = arg1.GetArgString(L"value");
            dw_detail.AcceptText();
            dw_detail.SetItemString(1,"BasicInformation",str);
            dw_detail.SetItemString(1,L"BasicInformation",str);
         }
         return 1;
         
@@ -895,92 +912,96 @@
      return 1;
   }      
   
   int OnItemClickEx(ref TNotifyEvent evt,int p)
   int OnItemClickEx(TEvent* evt, int pr)
   {
      xdwtable dw = dw_visit.FindDwTable("item",0);
      xdwtable dw = dw_visit.FindDwTable(L"item",0);
   
      
      ref DWNMHDR  hdr = cast(evt.pnmh as ref DWNMHDR);
      string value = hdr.data;
      int row = hdr.row;
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      xstring colname = hdr->colname;
      xstring value = hdr->data;
      int row = hdr->row;
      //alert(value);
      xaserverarg arg=new xaserverarg;
      xaserverarg& arg=*new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());               
      
      if(value == "上传")
      if(value == L"上传")
      {
         if(dw.GetGuid(dw.GetRow())=="")
         if(dw.GetGuid(dw.GetRow())==L"")
         {
            alert("保存后在上传!");
            alert(L"保存后在上传!");
            return 1;
         }
         
         arg.AddArg("entityid",dw.GetGuid(dw.GetRow()));
         int p4=cast(arg as int) ;
         OpenWindow("dev:xpage[maint.Document.Customer.v3.vx]", p4);
         arg.AddArg(L"entityid",dw.GetGuid(dw.GetRow()));
         OpenWindow(L"dev:xpage[maint.Document.Customer.v3.vx]", (LPARAM)&arg);
         return 1;
      }
      return 1;
   }   
   
   int OnItemClickExS(ref TNotifyEvent evt,int p)
   int OnItemClickExS(TEvent* evt,int p)
   {
      xdwtable dw = dw_Meetings.FindDwTable("item",0);
      xdwtable dw = dw_Meetings.FindDwTable(L"item",0);
   
      
      ref DWNMHDR  hdr = cast(evt.pnmh as ref DWNMHDR);
      string value = hdr.data;
      int row = hdr.row;
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      xstring colname = hdr->colname;
      xstring value = hdr->data;
      int row = hdr->row;
      //alert(value);
      xaserverarg arg=new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());
      xaserverarg& arg=*new xaserverarg;
      
      if(value == "附件上传")
      if(value == L"附件上传")
      {
         if(dw.GetGuid(dw.GetRow())=="")
         if(dw.GetGuid(dw.GetRow())==L"")
         {
            alert("保存后在上传!");
            alert(L"保存后在上传!");
            return 1;
         }
         
         arg.AddArg("entityid",dw.GetGuid(dw.GetRow()));
         int p4=cast(arg as int) ;
         OpenWindow("dev:xpage[maint.Document.Customer.v3.vx]", p4);
         arg.AddArg(L"entityid",dw.GetGuid(dw.GetRow()));
         OpenWindow(L"dev:xpage[maint.Document.Customer.v3.vx]", (LPARAM)&arg);
         return 1;
      }
         
      if(value == "人员")
      if(value == L"人员")
      {
         xaserverarg arg2 = new xaserverarg;
         arg2.setNativePointer(arg2.CreateInstance());
         xaserverarg parg2 = GetParam();
         OpenWindow("dev:xpage[UserGroupPersonSelect.vx]",cast(arg2 as int));
         if(arg2.GetArgString("comdid")=="xmOk")
         {
            string data = arg2.GetArgString("data");
            xml x2 = new xml;
            x2.setNativePointer(xml::CreateInstance());
            x2.LoadXml(data);
            msxml::IXMLDOMNodeList nodes = x2.GetXmlDoc().selectNodes("/root/item");
            trace(x2.GetXml());
         xaserverarg& arg2 =* new xaserverarg;
            
            int len = nodes.length;
         
            string Names = "";
         xaserverarg& parg2 = *(xaserverarg*)GetParam();
         OpenWindow(L"dev:xpage[UserGroupPersonSelect.vx]", (LPARAM)&arg2);
         if(arg2.GetArgString(L"comdid")==L"xmOk")
         {
            xstring data = arg2.GetArgString(L"data");
            xml x2;
            x2.loadXML(data);
            KXMLDOMNodeList nodes = x2.selectNodes(L"/root/item");
            trace(x2.xml());
            int len = nodes.length();
            xstring Names = L"";
            for(int i=0;i<len; i++)
            {
               msxml::IXMLDOMElement t= nodes.item(i);
               KXMLDOMElement t= nodes.item(i);
               
               if(t.getAttribute("Name"))
               if(t.getAttribute(L"Name"))
               {
                  string Name = t.getAttribute("Name");
                  if(Names=="")
                  xstring Name = t.getAttribute(L"Name");
                  if(Names==L"")
                     Names = Name;
                  else if(Names.find(Name) < 0) Names+=","+Name;
                  else if(Names.find(Name) < 0) Names+=L",L"+Name;
               }
            }
            dw.SetItemString(dw.GetRow(),"CMPersonnel",Names);
            dw.SetItemString(dw.GetRow(),L"CMPersonnel",Names);
                  
         }
         return 1;
@@ -989,64 +1010,65 @@
      return 1;
   }
   
   int OnItemClickExSS(ref TNotifyEvent evt,int p)
   int OnItemClickExSS(TEvent* evt,int p)
   {
      xdwtable dw = dw_MeetingsEx.FindDwTable("item",0);
      xdwtable dw = dw_MeetingsEx.FindDwTable(L"item",0);
   
      
      ref DWNMHDR  hdr = cast(evt.pnmh as ref DWNMHDR);
      string value = hdr.data;
      int row = hdr.row;
      DWNMHDR* hdr = (DWNMHDR*)evt->notify.pnmh;
      xstring colname = hdr->colname;
      xstring value = hdr->data;
      int row = hdr->row;
      //alert(value);
      xaserverarg arg=new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());
      xaserverarg& arg=*new xaserverarg;
      
      if(value == "附件上传")
      if(value == L"附件上传")
      {
         if(dw.GetGuid(dw.GetRow())=="")
         if(dw.GetGuid(dw.GetRow())==L"")
         {
            alert("保存后在上传!");
            alert(L"保存后在上传!");
            return 1;
         }
         
         arg.AddArg("entityid",dw.GetGuid(dw.GetRow()));
         int p4=cast(arg as int) ;
         OpenWindow("dev:xpage[maint.Document.Customer.v3.vx]", p4);
         arg.AddArg(L"entityid",dw.GetGuid(dw.GetRow()));
         OpenWindow(L"dev:xpage[maint.Document.Customer.v3.vx]",(LPARAM)&arg);
         return 1;
      }
         
      if(value == "人员")
      if(value == L"人员")
      {
         xaserverarg arg2 = new xaserverarg;
         arg2.setNativePointer(arg2.CreateInstance());
         xaserverarg parg2 = GetParam();
         OpenWindow("dev:xpage[UserGroupPersonSelectEx.vx]",cast(arg2 as int));
         xaserverarg& arg2 = *new xaserverarg;
         
         if(arg2.GetArgString("comdid")=="xmOk")
         xaserverarg parg2 = *(xaserverarg*)GetParam();
         OpenWindow(L"dev:xpage[UserGroupPersonSelectEx.vx]", (LPARAM)&arg2);
         if(arg2.GetArgString(L"comdid")==L"xmOk")
         {
            string data = arg2.GetArgString("data");
            xml x2 = new xml;
            x2.setNativePointer(xml::CreateInstance());
            x2.LoadXml(data);
            msxml::IXMLDOMNodeList nodes = x2.GetXmlDoc().selectNodes("/root/item");
            trace(x2.GetXml());
            xstring data = arg2.GetArgString(L"data");
            xml x2;
            
            int len = nodes.length;
            x2.loadXML(data);
            KXMLDOMNodeList nodes = x2.selectNodes(L"/root/item");
            trace(x2.xml());
            int len = nodes.length();
         
            string Names = "";
            xstring Names = L"";
            for(int i=0;i<len; i++)
            {
               msxml::IXMLDOMElement t= nodes.item(i);
               KXMLDOMElement t= nodes.item(i);
               
               if(t.getAttribute("Name"))
               if(t.getAttribute(L"Name"))
               {
                  string Name = t.getAttribute("Name");
                  if(Names=="")
                  xstring Name = t.getAttribute(L"Name");
                  if(Names==L"")
                     Names = Name;
                  else if(Names.find(Name) < 0) Names+=","+Name;
                  else if(Names.find(Name) < 0) Names+=L",L"+Name;
               }
            }
            dw.SetItemString(dw.GetRow(),"CMPersonnel",Names);
            dw.SetItemString(dw.GetRow(),L"CMPersonnel",Names);
         }
         return 1;
      }
@@ -1056,12 +1078,12 @@
                  
   int PostOnAttachEvent()
   {
      AttachEvent("dw_detail","DWV_ITEMCHANGED",OnItemChanged);
      //AttachEvent("tab_1","LYSN_SELECTEDSHEET",OnSelectedSheet);
      AttachEvent("dw_detail","DWV_CLICKED",OnItemClick);
      AttachEvent("dw_visit","DWV_CLICKED",OnItemClickEx);
      AttachEvent("dw_Meetings","DWV_CLICKED",OnItemClickExS);
      AttachEvent("dw_MeetingsEx","DWV_CLICKED",OnItemClickExSS);
      AttachEvent(L"dw_detail",L"DWV_ITEMCHANGED", (FEvent)&maintCustomerv3::OnItemChanged);
      //AttachEvent(L"tab_1",L"LYSN_SELECTEDSHEET",(FEvent)&maintCustomerv3::OnSelectedSheet);
      AttachEvent(L"dw_detail",L"DWV_CLICKED", (FEvent)&maintCustomerv3::OnItemClick);
      AttachEvent(L"dw_visit",L"DWV_CLICKED", (FEvent)&maintCustomerv3::OnItemClickEx);
      AttachEvent(L"dw_Meetings",L"DWV_CLICKED", (FEvent)&maintCustomerv3::OnItemClickExS);
      AttachEvent(L"dw_MeetingsEx",L"DWV_CLICKED", (FEvent)&maintCustomerv3::OnItemClickExSS);
      return 1;
   }
   
@@ -1076,51 +1098,51 @@
      maint::onloaded();
      
      
      m_layer = GetControl("tab_1");
      dw_detail = GetControl("dw_detail");
      m_layer = GetControl(L"tab_1");
      dw_detail = GetControl(L"dw_detail");
      dw_detail.SetColHeaderHeight(16);            
      dw_power = GetControl("dw_power");
      dw_require =GetControl("dw_require");
      dw_jzfx = GetControl("dw_jzfx");
      dw_visit = GetControl("dw_visit");
      dw_Meetings = GetControl("dw_Meetings");
      dw_MeetingsEx = GetControl("dw_MeetingsEx");
      //添加客户产品附页
      xsheet = GetControl("tab_1");
      //string xp = "<xframe src='dev:xpage[CustomerGoodsVd.vx]' />";
      dw_power = GetControl(L"dw_power");
      dw_require =GetControl(L"dw_require");
      dw_jzfx = GetControl(L"dw_jzfx");
      dw_visit = GetControl(L"dw_visit");
      dw_Meetings = GetControl(L"dw_Meetings");
      dw_MeetingsEx = GetControl(L"dw_MeetingsEx");
      //添加客户产品附页
      xsheet = GetControl(L"tab_1");
      //xstring xp = L"<xframe src='dev:xpage[CustomerGoodsVd.vx]' />";
      /*xaserverarg arg = new xaserverarg;
      arg.setNativePointer(arg.CreateInstance());
      arg.AddArg("CustomerID", this.m_EntityID);
      arg.AddArg("CustomerName", dw_detail.GetItemString(1,"Name"));
      arg.AddArg("config", "客户产品.vface/config/CustomerGoodsNewVd/view");
      arg.AddArg("CustomerHWND",this.GetHWND().toString());
      arg.AddArg(L"CustomerID", this.m_EntityID);
      arg.AddArg(L"CustomerName", dw_detail.GetItemString(1,L"Name"));
      arg.AddArg(L"config", L"客户产品.vface/config/CustomerGoodsNewVd/view");
      arg.AddArg(L"CustomerHWND",this.GetHWND().toString());
      //trace(this.m_EntityID);
      int p =arg.__nativept;*/
      //int nIndex = xsheet.InsertSheet(-1, "客户ID货号库", xp, 0);
      //int nIndex = xsheet.InsertSheet(-1, L"客户ID货号库", xp, 0);
      //xsheet.SelectSheet(nIndex);         
      //xsheet.SelectSheet(0);               
      //默认收缩
      //默认收缩
      /*xdwtable dw = new xdwtable;
      dw.setNativePointer(dw_detail.FindDwTable("PartyAddress",0));
      dw.setNativePointer(dw_detail.FindDwTable(L"PartyAddress",0));
      xdwtable dw1 = new xdwtable;
      dw1.setNativePointer(dw_detail.FindDwTable("PartyBankAccount",0));
      dw1.setNativePointer(dw_detail.FindDwTable(L"PartyBankAccount",0));
      xdwtable dw2 = new xdwtable;
      dw2.setNativePointer(dw_detail.FindDwTable("PartyContact",0));
      int start=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("Website"));
      dw2.setNativePointer(dw_detail.FindDwTable(L"PartyContact",0));
      int start=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex(L"Website"));
      dw_detail.ExpandCellRow(start + dw2.GetRowCount() +3,start +dw2.GetRowCount()+5);
      int start1=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("Website"));
      int start1=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex(L"Website"));
      dw_detail.ExpandCellRow(start1 + dw2.GetRowCount() +7,start1 + dw2.GetRowCount() +7 +dw.GetRowCount());
      int start2=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("Website"));
      int start2=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex(L"Website"));
      dw_detail.ExpandCellRow(start2 + dw2.GetRowCount() +9 +dw.GetRowCount(),start2 + dw2.GetRowCount() +9 +dw.GetRowCount() +dw1.GetRowCount());
      int start3=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("YearEstablished"));
      int start3=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex(L"YearEstablished"));
      dw_detail.ExpandCellRow(start3,start3 +2);
      int start4=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("CompanyCredit"));
      int start4=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex(L"CompanyCredit"));
      dw_detail.ExpandCellRow(start4,start4 +1);   */   
      //默认收缩
      xdwtable dw = dw_detail.FindDwTable("item1",0);
      xdwtable dw1 = dw_detail.FindDwTable("item2",0);
      xdwtable dw2 = dw_detail.FindDwTable("item3",0);
      //默认收缩
      xdwtable dw = dw_detail.FindDwTable(L"item1",0);
      xdwtable dw1 = dw_detail.FindDwTable(L"item2",0);
      xdwtable dw2 = dw_detail.FindDwTable(L"item3",0);
      int m,n,k;
      m=dw.GetRowCount();
      n=dw1.GetRowCount();
@@ -1139,7 +1161,7 @@
      }
      //trace(dw2.GetRowCount());
      
      int start=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("Website"));
      int start=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex(L"Website"));
      dw_detail.ExpandCellRow(start +m +5,start +m+7);
      //trace(start +k +3);            
      dw_detail.ExpandCellRow(start +m+9,start +m+9+n);
@@ -1156,11 +1178,11 @@
         OnInit();
      }else
      {
         //string userno = publiccode::getUserNo();
         //xstring userno = publiccode::getUserNo();
         userno = xaserver::GetUserNo();
         if(userno !="00601" && userno !="admin" && userno !="00701")
         if(userno !=L"00601" && userno !=L"admin" && userno !=L"00701")
         {
            dw_detail.SetColumnProp("SalesPersonID","cellprotect","1");
            dw_detail.SetColumnProp(L"SalesPersonID",L"cellprotect",L"1");
            
         }
      }
@@ -1169,34 +1191,35 @@
      if (GetParam())
      {
         int iArgs = GetParam();
         xaserverarg args = new xaserverarg;
         args.setNativePointer(iArgs);
         xaserverarg& args = *new xaserverarg;
         //alert(args.GetString());
         string CustomerGood = args.GetArgString("CustomerGood");
         ApplyStatus= args.GetArgString("CustomerGood");
         if(CustomerGood=="Y")
         xstring CustomerGood = args.GetArgString(L"CustomerGood");
         ApplyStatus= args.GetArgString(L"CustomerGood");
         if(CustomerGood==L"Y")
         {   
            xsheet.DeleteSheet(0);
            string xp = "<xframe src='dev:xpage[CustomerGoodsVd.vx]' />";
            xaserverarg arg = new xaserverarg;
            xstring xp = L"<xframe src='dev:xpage[CustomerGoodsVd.vx]' />";
            xaserverarg& arg = *new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg("CustomerID", this.m_EntityID);
            arg.AddArg("FROM", "Customer");
            arg.AddArg("CustomerName", dw_detail.GetItemString(1,"Name"));
            arg.AddArg("config", "客户产品.vface/config/CustomerGoodsVdVd/view");
            arg.AddArg("CustomerHWND",this.GetHWND().toString());
            int p1 =arg.ptr_native_;
            int nIndex = xsheet.InsertSheet(-1, "客户ID货号库", xp, p1);
            arg.AddArg(L"CustomerID", m_EntityID);
            arg.AddArg(L"FROM", L"Customer");
            arg.AddArg(L"CustomerName", dw_detail.GetItemString(1,L"Name"));
            arg.AddArg(L"config", L"客户产品.vface/config/CustomerGoodsVdVd/view");
            //arg.AddArg(L"CustomerHWND",GetHWND().toString());
            arg.SetParam(L"CustomerHWND", (LPARAM)GetHWND());
            int nIndex = xsheet.InsertSheet(-1, L"客户ID货号库", xp, (void*)&arg);
            xsheet.SelectSheet(nIndex);
            //xsheet.SetSheetState(0, 0);         
         }
         
         
         ApplyStatus=dw_detail.GetItemString(1,"ApplyStatus");
         ApplyStatus=dw_detail.GetItemString(1,L"ApplyStatus");
         
         if(userno !="00601" && userno !="admin" && userno !="00701")
         if(userno !=L"00601" && userno !=L"admin" && userno !=L"00701")
         {
            if(ApplyStatus =="财务已审核")
            if(ApplyStatus ==L"财务已审核")
            {
               dw_detail.SetReadOnly(true);   
            }