#include <wobject/xstring.hpp>
|
#include <xcontrol/xtreeview.hpp>
|
#include <xcontrol/xdwgrid.hpp>
|
|
#include "vbusiness/vframe/maint.vframe.vbusiness.hpp"
|
#include "viewobject/view.base.hpp"
|
|
class maintCustomerv3 : public maint
|
{
|
xlayersheet xsheet;
|
xlayersheet m_layer;
|
xdwtable dw_detail;
|
xdwtable dw_power;
|
xdwtable dw_require;
|
xdwtable dw_jzfx;
|
xdwtable dw_visit;
|
|
xdwtable dw_Meetings;
|
xdwtable dw_MeetingsEx;
|
|
xdwgrid dw_account;
|
|
|
int iLayer;//页面Index
|
int APP=1;
|
string CustomerGoodsHWND;
|
string userno;
|
string ApplyStatus;
|
/*struct PUser
|
{
|
string id;
|
string no;
|
string name;
|
};*/
|
|
|
string GetGuid()
|
{
|
return publiccode::GetGuid();
|
}
|
|
int ViewUpdate(int pr,string updateItem,xaserverarg arg)
|
{
|
if(updateItem=="update")
|
{
|
|
dw_detail.ResetUpdateStatus();
|
}
|
return 1;
|
}
|
|
string GetEntityData(int pr)
|
{
|
xml x = new xml;
|
x.setNativePointer(xml::CreateInstance());
|
dw_detail.DwUpdateAllTo(x.GetXmlDoc());
|
|
msxml::IXMLDOMElement e=x.GetXmlDoc().documentElement;
|
|
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/*");
|
int i=0;
|
for (i=0; i<oNodeList.length; i++)
|
{
|
msxml::IXMLDOMElement 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/*");
|
int i2=0;
|
for (i2=0; i2<oNodeList2.length; i2++)
|
{
|
msxml::IXMLDOMElement 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/*");
|
int i3=0;
|
for (i3=0; i3<oNodeList3.length; i3++)
|
{
|
msxml::IXMLDOMElement Item3 = oNodeList3.item(i3);
|
e.appendChild(Item3);
|
}
|
|
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"); //没必要,暂时留着
|
|
string sdate = publiccode::GetCurrentDate();
|
dw_detail.SetItemString(1,"ApplyDate",sdate);
|
dw_detail.SetItemString(1,"ApplyStatus","新建");
|
dw_detail.SetItemString(1,"Level","");
|
|
//dw_detail.SetItemDisplayString(1,"客户资料","客户资料附件");
|
dw_detail.SetItemString(1,"客户资料","客户资料附件");
|
string guid = publiccode::GetGuid();
|
dw_detail.SetGuid(1,guid);
|
dw_detail.Redraw();
|
return 1;
|
}
|
|
string GetPartyID(string sName,string sType)
|
{
|
xml x1=new xml;
|
x1.setNativePointer(xml::CreateInstance());
|
xaserverarg arg=new xaserverarg;
|
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)
|
{
|
string error = x1.GetXmlDoc().text;
|
//alert("/sale/data/"+GetEntityName(1)+"/pref/searchname");
|
return "";
|
}
|
string sID="";
|
if(x1.GetXmlDoc().selectSingleNode("root/PartyID"))
|
sID = x1.GetXmlDoc().selectSingleNode("root/PartyID").text;
|
return sID+"";
|
}
|
|
int OnItemChanged(ref TNotifyEvent evt,int p)
|
{
|
ref DWNMHDR hdr = evt.pnmh;
|
string colname = hdr.colname;
|
string coldata = hdr.data;
|
|
//根据国别显示地区代码
|
if (colname == "CountryCode")
|
{
|
xaserverarg arg = new xaserverarg;
|
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)
|
{
|
string sareacode = "";
|
string sareaname = "";
|
if(x.GetXmlDoc().selectSingleNode("//AreaCode"))
|
{
|
sareacode = x.GetXmlDoc().selectSingleNode("//AreaCode").text;
|
sareaname = x.GetXmlDoc().selectSingleNode("//AreaName").text;
|
}
|
dw_detail.SetItemString(1,"AreaCode",sareacode);
|
dw_detail.SetItemDisplayString(1,"AreaCode",sareaname);
|
dw_detail.Redraw();
|
}
|
}
|
|
//只能选一个主联系人
|
if (colname == "PrimaryFlag" && coldata == "Y")
|
{
|
xdwtable dw_pc;
|
dw_pc = dw_detail.FindDwTable("item1");
|
if (dw_pc)
|
{
|
int i;
|
for (i=1;i <= dw_pc.GetRowCount();i++)
|
{
|
if (i != hdr.row)
|
{
|
dw_pc.SetItemString(i,"PrimaryFlag","N");
|
dw_pc.SetItemDisplayString(i,"PrimaryFlag","");
|
|
}
|
}
|
}
|
}
|
|
//客户名相同。
|
if (colname == "Name")
|
{
|
//alert(coldata);
|
/* string sguid = GetPartyID(coldata,colname);
|
if (sguid != "")
|
{
|
alert("客户名称与系统已有客户重复,请于管理员联系解决!");
|
}*/
|
//alert("ccc");
|
}
|
|
//客户简称
|
if (colname == "ShortName")
|
{
|
string sguid1 = GetPartyID(coldata,colname);
|
//trace(sguid1);
|
if (sguid1 != "")
|
{
|
alert("客户简称重复,请改用其他简称!");
|
}
|
}
|
//根据客户来源填写客户备注
|
/*if (colname == "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网站");
|
}*/
|
//联系人Title选择。
|
if (colname == "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","女");
|
else
|
dw_PartyContact.SetItemString(dw_PartyContact.GetRow(),"Gender","");
|
|
}
|
if (colname=="SalesPersonID" && coldata != "")//设置人员归属
|
{
|
trace("asdasd");
|
string 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 );
|
}
|
//根据生日自动设置年龄。
|
/*if (colname == "Birthday")
|
{
|
xdwtable dw_PartyContact1;
|
dw_PartyContact1 =dw_detail.FindDwTable("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);
|
if (getSql(argnew.GetString(),xx) == 1)
|
{
|
msxml::IXMLDOMElement AgeEle=xx.GetXmlDoc().documentElement;
|
dw_PartyContact1.SetItemString(1,"Age",AgeEle.text);
|
}
|
}*/
|
return 1;
|
}
|
|
int OnAddRow()
|
{
|
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")
|
{
|
int iRowPc = dw_contact.InsertRow(0);
|
}
|
else if(sDwname=="PartyAddress")
|
{
|
int iRowPad = dw_contact.InsertRow(0);
|
}
|
else if(sDwname=="PartyBankAccount")
|
{
|
int iRowPba = dw_contact.InsertRow(0);
|
}
|
int h=m_layer.GetSheetIndex();
|
int nindex = h+1;
|
//alert(nindex.toString());
|
if(nindex==5)
|
{
|
dw_obj=GetControl("dw_jzfx");
|
xdwtable dw = dw_obj.GetCurTable();
|
int row = dw.InsertRow(1, 0);
|
dw.SetItemString(row,"SeqNo",row.toString());
|
}
|
if(nindex==4)
|
{
|
dw_obj=GetControl("dw_visit");
|
xdwtable dw1 = dw_obj.GetCurTable();
|
int row1 = dw1.InsertRow(0);
|
}
|
if(nindex==3)
|
{
|
dw_obj=GetControl("dw_MeetingsEx");
|
xdwtable dw3 = dw_obj.GetCurTable();
|
int row3 = dw3.InsertRow(0);
|
}
|
|
if(nindex==2)
|
{
|
dw_obj=GetControl("dw_Meetings");
|
xdwtable dw2 = dw_obj.GetCurTable();
|
int row2 = dw2.InsertRow(0);
|
}
|
return 0;
|
}
|
|
int OnInsertRow()
|
{
|
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")
|
{
|
int iRowPc = dw_contact.InsertRow(dw_contact.GetRow());
|
}
|
else if(sDwname=="PartyAddress")
|
{
|
int iRowPad = dw_contact.InsertRow(dw_contact.GetRow());
|
}
|
else if(sDwname=="PartyBankAccount")
|
{
|
int iRowPba = dw_contact.InsertRow(dw_contact.GetRow());
|
}
|
int h=m_layer.GetSheetIndex();
|
int nindex = h+1;
|
if(nindex==5)
|
{
|
dw_obj=GetControl("dw_jzfx");
|
xdwtable dw = dw_obj.FindDwTable("CustomerJzfx");
|
int row = dw.InsertRow(1,dw.GetRow());
|
//dw.SetGuid(row,publiccode::GetGuid());
|
}
|
if(nindex==4)
|
{
|
dw_obj=GetControl("dw_visit");
|
xdwtable dw1 =dw_obj.GetCurTable();
|
int row1 = dw1.InsertRow(dw1.GetRow());
|
}
|
if(nindex==3)
|
{
|
dw_obj=GetControl("dw_MeetingsEx");
|
xdwtable dw3 =dw_obj.GetCurTable();
|
int row3 = dw3.InsertRow(dw3.GetRow());
|
}
|
if(nindex==2)
|
{
|
dw_obj=GetControl("dw_Meetings");
|
xdwtable dw2 =dw_obj.GetCurTable();
|
int row2 = dw2.InsertRow(dw2.GetRow());
|
}
|
return 0;
|
}
|
|
int OnDeleteRow()
|
{
|
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" )
|
{
|
int row = dw_contact.GetRow();
|
dw_contact.DeleteRow(row);
|
}
|
int h=m_layer.GetSheetIndex();
|
int nindex = h+1;
|
if(nindex==5)
|
{
|
dw_obj=GetControl("dw_jzfx");
|
xdwtable dw = dw_obj.GetCurTable();
|
int row1 = dw.GetRow();
|
if(dw.GetRowCount() >1)
|
dw.DeleteRow(row1);
|
}
|
if(nindex==4)
|
{
|
dw_obj=GetControl("dw_visit");
|
xdwtable dw1 = dw_obj.GetCurTable();
|
int row2 = dw1.GetRow();
|
dw1.DeleteRow(row2);
|
}
|
if(nindex==3)
|
{
|
dw_obj=GetControl("dw_MeetingsEx");
|
xdwtable dw4 = dw_obj.GetCurTable();
|
int row4 = dw4.GetRow();
|
dw4.DeleteRow(row4);
|
}
|
if(nindex==2)
|
{
|
dw_obj=GetControl("dw_Meetings");
|
xdwtable dw3 = dw_obj.GetCurTable();
|
int row3 = dw3.GetRow();
|
dw3.DeleteRow(row3);
|
}
|
return 0;
|
}
|
|
int OnDetailRow()
|
{
|
trace("detail");
|
return 0;
|
}
|
|
int OnPreSave()
|
{
|
xml xxx = new xml;
|
xxx.setNativePointer(xxx.CreateInstance());
|
dw_detail.DwUpdateAllTo(xxx.GetXmlDoc());
|
trace(xxx.GetXml());
|
//return 0;
|
|
//客户名称
|
string sName;
|
sName = dw_detail.GetItemString(1,"Name");
|
if (sName == "")
|
{
|
alert("客户名称不能为空!");
|
return 0;
|
}
|
|
string sShortName = dw_detail.GetItemString(1,"ShortName");
|
if (sShortName == "")
|
{
|
alert("客户简称不能为空!");
|
return 0;
|
}
|
string Level = dw_detail.GetItemString(1,"Level");
|
/*if (Level == "")
|
{
|
alert("客户等级不能为空!");
|
return 0;
|
}*/
|
|
/*
|
if(dw_detail.GetItemString(1,"Address")=="")
|
{
|
alert("客户地址不能为空!");
|
return 0;
|
}
|
|
if(dw_detail.GetItemString(1,"Source")=="")
|
{
|
alert("客户来源不能为空!");
|
return 0;
|
}
|
if(dw_detail.GetItemString(1,"CountryCode")=="")
|
{
|
alert("客户国别不能为空!");
|
return 0;
|
}
|
if(dw_detail.GetItemString(1,"TEL")=="")
|
{
|
alert("公司电话不能为空!");
|
return 0;
|
}*/
|
//客户简称不能重复
|
/*
|
string sPartyID = GetPartyID(sShortName,"ShortName");
|
if (sPartyID != "")
|
{
|
alert("此客户简称已经存在!");
|
}
|
*/
|
|
//客户代码
|
string sPartyNo;
|
sPartyNo = dw_detail.GetItemString(1,"PartyNo");
|
if (sPartyNo == "" )
|
{
|
//alert("客户代码不能为空!");
|
//return 0;
|
|
string sNo = publiccode::GetIdentityNo("Party1");
|
if (sNo == "")
|
sNo == "1000";
|
dw_detail.SetItemString(1,"PartyNo",sNo);
|
|
}
|
|
//成立时间YearEstablished
|
//雇员数量Employees
|
//string sYearEstablished = dw_detail.GetItemString(1,"YearEstablished");
|
//string sEmployees = dw_detail.GetItemString(1,"Employees");
|
//sYearEstablished.toInt();
|
|
|
//联系人姓名Name-PCName,设置状态
|
xdwtable dw_PartyContact;
|
dw_PartyContact = dw_detail.FindDwTable("PartyContact");
|
xdwtable PC_OtherInfo;
|
PC_OtherInfo = dw_detail.FindDwTable("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 == "" )
|
{
|
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 != "")
|
{
|
alert("联系人姓名不能为空");
|
return 0;
|
}*/
|
}
|
else
|
{
|
string aStatus;
|
aStatus = dw_PartyContact.GetItemString(i,"Status",0);
|
if (aStatus=="")
|
{
|
dw_PartyContact.SetItemString(i,"Status","1");
|
}
|
}
|
if(dw_PartyContact.GetItemString(i,"ContactID")=="")
|
{
|
dw_PartyContact.SetItemString(i,"ContactID",GetGuid());
|
}
|
string sFlag = dw_PartyContact.GetItemString(i,"PrimaryFlag");
|
if(sFlag=="Y")
|
{
|
countflag ++;
|
|
dw_PartyContact.SetItemString(i,"PrimaryFlag","Y");
|
PC_OtherInfo.SetItemString(1,"ContactID",dw_PartyContact.GetItemString(i,"ContactID"));
|
|
}
|
|
}
|
if(countflag==0 && dw_PartyContact.GetItemString(1,"Name") !="")
|
{
|
dw_PartyContact.SetItemString(1,"PrimaryFlag","Y");
|
PC_OtherInfo.SetItemString(1,"ContactID",dw_PartyContact.GetItemString(1,"ContactID"));
|
}
|
}
|
|
//银行帐号BankName-BankName;BankAccountNo-PBABankAccountNo ; 设置状态
|
xdwtable dw_PartyBankAccount;
|
dw_PartyBankAccount =dw_detail.FindDwTable("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 != "")
|
{
|
/*if (sPBABankName == "")
|
{
|
alert("银行名称不能为空");
|
return 0;
|
}
|
if (sPBABankAccountNo == "")
|
{
|
alert("银行账户不能为空");
|
return 0;
|
}*/
|
dw_PartyBankAccount.SetItemString(j,"Status","1");
|
}
|
}
|
}
|
|
//地址,设置状态
|
xdwtable dw_PartyAddress;
|
dw_PartyAddress =dw_detail.FindDwTable("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 != "")
|
{
|
dw_PartyAddress.SetItemString(k,"Status","1");
|
dw_PartyAddress.SetItemString(k,"IdentifyAddressFlag","N");
|
}
|
}
|
}
|
return 1;
|
}
|
|
int DoUpdate(bool showSuccess = true)
|
{
|
int rec =OnPreSave();
|
if (rec != 1) return 0;
|
ProcessFlowAction("action:bill.update",1);
|
return 1;
|
}
|
|
int CustomerModify()//跳到客户修改界面
|
{
|
//trace("asdsad");
|
xaserverarg arg = new xaserverarg;
|
arg.setNativePointer(arg.CreateInstance());
|
arg.AddArg("EntityID", maint::m_EntityID);
|
openUrl("/sale/view/"+GetEntityName(1)+"/worknode/customermodify/open",arg);
|
//CloseWindow();
|
return 1;
|
}
|
int OnComdidSplit(string str){
|
if(str.find("|", 0)<0)
|
return -1;
|
CustomerGoodsHWND = str.mid(str.find("|",0) + 1, str.length());
|
}
|
|
|
int OnShare()
|
{
|
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));
|
return 1;
|
}
|
|
int OnShareMessage()
|
{
|
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));
|
return 1;
|
}
|
|
int PreOnCmdDispatch(string comdid)
|
{
|
if (comdid == "cb_save")
|
{
|
win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_save", 0);
|
}
|
else if (comdid == "cb_copy")
|
{
|
win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_copy", 0);
|
}
|
else if (comdid == "cb_delete")
|
{
|
win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_delete", 0);
|
}
|
else if (comdid == "cb_reflash")
|
{
|
win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_reflash", 0);
|
}
|
else if(comdid == "cb_add")
|
{
|
win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "cb_add", 0);
|
}
|
else if(comdid == "cb_import")
|
{
|
win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "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 == "action:bill.update")
|
{
|
return OnPreSave();
|
}
|
else if (comdid == "action:customermodify") return CustomerModify();
|
else if(comdid.find("|",0)){
|
OnComdidSplit(comdid);
|
}
|
if(comdid=="action:XmShare")
|
{
|
OnShare();
|
return 0;
|
}
|
if(comdid=="action:XmShareMessage")
|
{
|
OnShareMessage();
|
return 0;
|
}
|
// else if (comdid.find("action:",0) >= 0) return OnAction(comdid);
|
return -1;
|
}
|
|
int PostOnCmdDispatch(string comdid)
|
{
|
if (comdid == "action:bill.update")
|
{
|
dw_detail.ResetUpdateStatus();
|
dw_visit.ResetUpdateStatus();
|
dw_Meetings.ResetUpdateStatus();
|
dw_MeetingsEx.ResetUpdateStatus();
|
}
|
|
return 1;
|
}
|
//选择tab页面
|
int OnSelectedSheet(ref TNotifyEvent evt,int p)
|
{
|
iLayer = m_layer.GetSheetIndex();
|
if (iLayer == 0)
|
SetAgent("maint",maint::m_EntityID);
|
else if (iLayer == 1)
|
{
|
int cc=APP;
|
cc=cc +1;
|
APP=cc;
|
if(cc==2)
|
{
|
xsheet.DeleteSheet(1);
|
string xp = "<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);
|
xsheet.SelectSheet(nIndex);
|
}
|
//win32::SendMessage(CustomerGoodsHWND.toInt(),0x401, "SetFocus", nil);
|
|
}
|
return 1;
|
}
|
|
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"))
|
{
|
Content=t.selectSingleNode("Content").text;
|
}
|
xaserverarg arg1 = new xaserverarg;
|
arg1.setNativePointer(arg1.CreateInstance());
|
arg1.AddArg("value",Content);
|
OpenWindow("dev:xpage[memo.edit.new.vx]",arg1.getNativePointer());
|
|
return 1;
|
}
|
|
|
int OnItemClick(ref TNotifyEvent 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"));
|
int m,n,k;
|
m=dw.GetRowCount();
|
n=dw1.GetRowCount();
|
k=dw2.GetRowCount();
|
if(dw.GetRowCount()==0)
|
{
|
m=dw.GetRowCount() +1;
|
}
|
if(dw1.GetRowCount()==0)
|
{
|
n=dw1.GetRowCount() +1;
|
}
|
if(dw2.GetRowCount()==0)
|
{
|
k=dw2.GetRowCount() +1;
|
}
|
ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
|
string value = hdr.data;
|
//alert(value);
|
xaserverarg arg=new xaserverarg;
|
arg.setNativePointer(arg.CreateInstance());
|
if(value == "主要联系人其它信息")
|
{
|
dw_detail.ExpandCellRow(start +m +5,start +m+7);
|
}
|
else if(value == "其它地址")
|
{
|
dw_detail.ExpandCellRow(start +m+9,start +m+9+n);
|
//dw_base.ExpandMarginRow(-22,-20);
|
}
|
else if(value == "银行信息")
|
{
|
dw_detail.ExpandCellRow(start +m+11+n,start +m+11+n+k);
|
//dw_base.ExpandMarginRow(-22,-20);
|
}
|
else if(value == "业务概述")
|
{
|
dw_detail.ExpandCellRow(start +m+13+n+k,start +m+13+n+k+2);
|
//dw_base.ExpandMarginRow(-22,-20);
|
}
|
else if(value == "客户授信")
|
{
|
dw_detail.ExpandCellRow(start +m+15+n+k +2,start +m+15+n+k +2+1);
|
//dw_base.ExpandMarginRow(-22,-20);
|
}
|
if(value == "客户资料附件")
|
{
|
|
if(userno == "admin" || userno == "00601" || userno == "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);
|
return 1;
|
}
|
}
|
if(value == "客户基本信息")
|
{
|
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")
|
{
|
str = arg1.GetArgString("value");
|
dw_detail.AcceptText();
|
dw_detail.SetItemString(1,"BasicInformation",str);
|
}
|
return 1;
|
|
}
|
return 1;
|
}
|
|
int OnItemClickEx(ref TNotifyEvent evt,int p)
|
{
|
xdwtable dw = dw_visit.FindDwTable("item",0);
|
|
|
ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
|
string value = hdr.data;
|
int row = hdr.row;
|
//alert(value);
|
xaserverarg arg=new xaserverarg;
|
arg.setNativePointer(arg.CreateInstance());
|
|
if(value == "上传")
|
{
|
if(dw.GetGuid(dw.GetRow())=="")
|
{
|
alert("保存后在上传!");
|
return 1;
|
}
|
|
arg.AddArg("entityid",dw.GetGuid(dw.GetRow()));
|
int p4=cast(arg as int) ;
|
OpenWindow("dev:xpage[maint.Document.Customer.v3.vx]", p4);
|
return 1;
|
}
|
return 1;
|
}
|
|
int OnItemClickExS(ref TNotifyEvent evt,int p)
|
{
|
xdwtable dw = dw_Meetings.FindDwTable("item",0);
|
|
|
ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
|
string value = hdr.data;
|
int row = hdr.row;
|
//alert(value);
|
xaserverarg arg=new xaserverarg;
|
arg.setNativePointer(arg.CreateInstance());
|
|
if(value == "附件上传")
|
{
|
if(dw.GetGuid(dw.GetRow())=="")
|
{
|
alert("保存后在上传!");
|
return 1;
|
}
|
|
arg.AddArg("entityid",dw.GetGuid(dw.GetRow()));
|
int p4=cast(arg as int) ;
|
OpenWindow("dev:xpage[maint.Document.Customer.v3.vx]", p4);
|
return 1;
|
}
|
|
if(value == "人员")
|
{
|
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());
|
|
int len = nodes.length;
|
|
string Names = "";
|
for(int i=0;i<len; i++)
|
{
|
msxml::IXMLDOMElement t= nodes.item(i);
|
|
if(t.getAttribute("Name"))
|
{
|
string Name = t.getAttribute("Name");
|
if(Names=="")
|
Names = Name;
|
else if(Names.find(Name) < 0) Names+=","+Name;
|
}
|
}
|
dw.SetItemString(dw.GetRow(),"CMPersonnel",Names);
|
|
}
|
return 1;
|
}
|
|
return 1;
|
}
|
|
int OnItemClickExSS(ref TNotifyEvent evt,int p)
|
{
|
xdwtable dw = dw_MeetingsEx.FindDwTable("item",0);
|
|
|
ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
|
string value = hdr.data;
|
int row = hdr.row;
|
//alert(value);
|
xaserverarg arg=new xaserverarg;
|
arg.setNativePointer(arg.CreateInstance());
|
|
if(value == "附件上传")
|
{
|
if(dw.GetGuid(dw.GetRow())=="")
|
{
|
alert("保存后在上传!");
|
return 1;
|
}
|
|
arg.AddArg("entityid",dw.GetGuid(dw.GetRow()));
|
int p4=cast(arg as int) ;
|
OpenWindow("dev:xpage[maint.Document.Customer.v3.vx]", p4);
|
return 1;
|
}
|
|
if(value == "人员")
|
{
|
xaserverarg arg2 = new xaserverarg;
|
arg2.setNativePointer(arg2.CreateInstance());
|
xaserverarg parg2 = GetParam();
|
OpenWindow("dev:xpage[UserGroupPersonSelectEx.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());
|
|
int len = nodes.length;
|
|
string Names = "";
|
for(int i=0;i<len; i++)
|
{
|
msxml::IXMLDOMElement t= nodes.item(i);
|
|
if(t.getAttribute("Name"))
|
{
|
string Name = t.getAttribute("Name");
|
if(Names=="")
|
Names = Name;
|
else if(Names.find(Name) < 0) Names+=","+Name;
|
}
|
}
|
dw.SetItemString(dw.GetRow(),"CMPersonnel",Names);
|
}
|
return 1;
|
}
|
|
return 1;
|
}
|
|
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);
|
return 1;
|
}
|
|
int onload()
|
{
|
maint::onload();
|
}
|
|
int onloaded()
|
{
|
APP=1;
|
maint::onloaded();
|
|
|
m_layer = GetControl("tab_1");
|
dw_detail = GetControl("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]' />";
|
/*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());
|
//trace(this.m_EntityID);
|
int p =arg.__nativept;*/
|
//int nIndex = xsheet.InsertSheet(-1, "客户ID货号库", xp, 0);
|
//xsheet.SelectSheet(nIndex);
|
//xsheet.SelectSheet(0);
|
//默认收缩
|
/*xdwtable dw = new xdwtable;
|
dw.setNativePointer(dw_detail.FindDwTable("PartyAddress",0));
|
xdwtable dw1 = new xdwtable;
|
dw1.setNativePointer(dw_detail.FindDwTable("PartyBankAccount",0));
|
xdwtable dw2 = new xdwtable;
|
dw2.setNativePointer(dw_detail.FindDwTable("PartyContact",0));
|
int start=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("Website"));
|
dw_detail.ExpandCellRow(start + dw2.GetRowCount() +3,start +dw2.GetRowCount()+5);
|
int start1=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("Website"));
|
dw_detail.ExpandCellRow(start1 + dw2.GetRowCount() +7,start1 + dw2.GetRowCount() +7 +dw.GetRowCount());
|
int start2=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("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"));
|
dw_detail.ExpandCellRow(start3,start3 +2);
|
int start4=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("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);
|
int m,n,k;
|
m=dw.GetRowCount();
|
n=dw1.GetRowCount();
|
k=dw2.GetRowCount();
|
if(dw.GetRowCount()==0)
|
{
|
m=dw.GetRowCount() +1;
|
}
|
if(dw1.GetRowCount()==0)
|
{
|
n=dw1.GetRowCount() +1;
|
}
|
if(dw2.GetRowCount()==0)
|
{
|
k=dw2.GetRowCount() +1;
|
}
|
//trace(dw2.GetRowCount());
|
|
int start=dw_detail.GetCellRowFromRowColumn(1,dw_detail.GetColumnIndex("Website"));
|
dw_detail.ExpandCellRow(start +m +5,start +m+7);
|
//trace(start +k +3);
|
dw_detail.ExpandCellRow(start +m+9,start +m+9+n);
|
//trace(start +k+7);
|
dw_detail.ExpandCellRow(start +m+11+n,start +m+11+n+k);
|
//trace(start +k+10+m);
|
dw_detail.ExpandCellRow(start +m+13+n+k,start +m+13+n+k+2);
|
//trace(start +k+14+m+n);
|
dw_detail.ExpandCellRow(start +m+15+n+k +2,start +m+15+n+k +2+1);
|
//trace(start +k+16+m+n +2);
|
|
if (!maint::m_EntityID)
|
{
|
OnInit();
|
}else
|
{
|
//string userno = publiccode::getUserNo();
|
userno = xaserver::GetUserNo();
|
if(userno !="00601" && userno !="admin" && userno !="00701")
|
{
|
dw_detail.SetColumnProp("SalesPersonID","cellprotect","1");
|
|
}
|
}
|
|
|
if (GetParam())
|
{
|
int iArgs = GetParam();
|
xaserverarg args = new xaserverarg;
|
args.setNativePointer(iArgs);
|
//alert(args.GetString());
|
string CustomerGood = args.GetArgString("CustomerGood");
|
ApplyStatus= args.GetArgString("CustomerGood");
|
if(CustomerGood=="Y")
|
{
|
xsheet.DeleteSheet(0);
|
string xp = "<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);
|
xsheet.SelectSheet(nIndex);
|
//xsheet.SetSheetState(0, 0);
|
}
|
|
|
ApplyStatus=dw_detail.GetItemString(1,"ApplyStatus");
|
|
if(userno !="00601" && userno !="admin" && userno !="00701")
|
{
|
if(ApplyStatus =="财务已审核")
|
{
|
dw_detail.SetReadOnly(true);
|
}
|
}
|
|
|
dw_detail.SetEditUpperMode(true);
|
dw_visit.SetEditUpperMode(true);
|
dw_Meetings.SetEditUpperMode(true);
|
dw_MeetingsEx.SetEditUpperMode(true);
|
}
|
return 1;
|
}
|
};
|