#include #include #include #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=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 = ""; 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