use "system.vl"
|
use "win.vl"
|
use "maint.vl"
|
use "file.vl"
|
use "dev:vm[xcell.vm]"
|
unit vbusiness.entity
|
[
|
ForwarderMaint is extend maint;
|
about ForwarderMaint
|
[
|
field:
|
[
|
msxml::IXMLDOMDocument m_configDoc;
|
|
xdwtable__ dw_base;
|
string m_userid;
|
string m_username;
|
string ContactID;
|
xcell__ dw_cell;
|
]
|
|
method:
|
[
|
int alert(string str)
|
{
|
//win__::MessageBox(this.GetHWND(),str,"Ìáʾ22:",0);
|
TApp::alert(this,str);
|
return 0;
|
}
|
int setCellReadOnly()
|
{
|
dw_base = new xdwtable__;
|
dw_base.setNativePointer(this.GetControl("dw_base"));
|
dw_cell = new xcell__;
|
dw_cell.setNativePointer(dw_base.QueryItem("ixcell"));
|
string strnew = "<cellprop celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='±£»¤' cellvisibleex='' cellvisible='' cellvalid='' cellinitial=''/>";
|
//dw_cell.SetCellProps(2,2,strnew);
|
return 0;
|
}
|
|
string GetGuid(){
|
return TApp::GetGuid();
|
}
|
int OnClear(){
|
if(this.m_EntityID ==""){
|
trace(1);
|
m_userid = TApp::GetUserInfo().id;
|
m_username = TApp::GetUserInfo().name;
|
dw_base = new xdwtable__;
|
dw_base.setNativePointer(this.GetControl("dw_base"));
|
dw_base.SetItemString(1,"ForwarderID",GetGuid());
|
dw_base.SetItemString(1,"PartyID",GetGuid());
|
dw_base.SetItemString(1,"PStatus","1");
|
dw_base.SetItemDisplayString(1,"PStatus","ÆÕͨ");
|
dw_base.SetItemString(1,"CreatorID",m_userid);
|
dw_base.SetItemString(1,"PADStatus","1");
|
dw_base.SetItemString(1,"AddressID",GetGuid());
|
dw_base.SetItemString(1,"PADIdentifyAddressFlag","Y");
|
dw_base.SetItemString(1,"PADPrimaryFlag","Y");
|
//dw_base.SetItemString(1,"BankAccountID",GetGuid());
|
dw_base.SetItemString(1,"Type","5");
|
dw_base.SetItemString(1,"EnterName",m_userid);
|
dw_base.SetItemDisplayString(1,"EnterName",m_username);
|
dw_base.SetItemString(1,"CreateDate",TApp::GetCurDate());
|
/*xdwtable__ dw = new xdwtable__;
|
dw.setNativePointer(dw_base.GetCurTable());
|
xdwtable__ dwcon = new xdwtable__;
|
dwcon.setNativePointer(dw.FindDwTable("Contacters",0));
|
dwcon.SetItemString(1,"ContactID",GetGuid());
|
dwcon.SetItemString(1,"PCStatus","1");*/
|
//dw_base.SetItemString(1,"EBankAccountID",GetGuid());
|
//dw_base.SetItemString(1,"CBankAccountID",GetGuid());
|
/*xdwtable__ dweon = new xdwtable__;
|
dweon.setNativePointer(dw_base.FindDwTable("item1",0));
|
xdwtable__ dwcon = new xdwtable__;
|
dwcon.setNativePointer(dw_base.FindDwTable("item2",0));
|
dweon.SetItemString(1,"EPBAStatus","Y");
|
dwcon.SetItemString(1,"CPBAStatus","Y");
|
dweon.SetItemString(1,"ECurrencyCode","USD");
|
dwcon.SetItemString(1,"CCurrencyCode","RMB");*/
|
dw_base.SetItemString(1,"ForwarderType","1");
|
dw_base.SetItemDisplayString(1,"ForwarderType","Ô¤¸¶»õ");
|
//dw_base.SetItemString(1,"PrimaryContactID",dwcon.GetItemString(1,"ContactID"));
|
|
}
|
else
|
{
|
setCellReadOnly();
|
}
|
return 0;
|
}
|
|
int OnAddrow()
|
{
|
dw_base = new xdwtable__;
|
dw_base.setNativePointer(this.GetControl("dw_base"));
|
xdwtable__ dw = new xdwtable__;
|
dw.setNativePointer(dw_base.GetCurTable());
|
string dw_n=dw.GetDwName();
|
if(dw_n=="item")
|
{
|
dw.InsertRow(0);
|
int rows = dw.GetRowCount();
|
dw.SetRow(rows);
|
}
|
return 1;
|
}
|
int OnInsertRow()
|
{
|
dw_base = new xdwtable__;
|
dw_base.setNativePointer(this.GetControl("dw_base"));
|
xdwtable__ dw = new xdwtable__;
|
dw.setNativePointer(dw_base.GetCurTable());
|
string dw_n=dw.GetDwName();
|
if(dw_n=="item")
|
{
|
int row=dw.GetRow();
|
if(row<1) return 0;
|
dw.InsertRow(row);
|
dw.SetRow(row);
|
}
|
return 1;
|
}
|
|
int OnDeleteRow()
|
{
|
dw_base = new xdwtable__;
|
dw_base.setNativePointer(this.GetControl("dw_base"));
|
xdwtable__ dw = new xdwtable__;
|
dw.setNativePointer(dw_base.GetCurTable());
|
string dw_n=dw.GetDwName();
|
if(dw_n=="item")
|
{
|
int row=dw.GetRow();
|
if(row<1) return 0;
|
/*string del = dw.GetItemString(row,8);
|
if(del!="")
|
{
|
if(m_dels=="")
|
{
|
m_dels=del;
|
}
|
else
|
{
|
string temp=m_dels;
|
m_dels=del + "|" + temp;
|
//+= "|"+del;
|
}
|
|
}*/
|
dw.DeleteRow(row);
|
dw.SetRow(row - 1);
|
}
|
//trace(m_dels);
|
return 1;
|
}
|
string getGoodsNo()
|
{
|
xml__ x=new xml__;
|
x.setNativePointer(xml__::CreateInstance());
|
xaserverarg__ arg=new xaserverarg__;
|
arg.setNativePointer(arg.CreateInstance());
|
if (getUrl("/sale/data/LogisticsCode/pref/PartyNo",arg.GetString(),x) != 1)
|
{
|
trace(x.GetXml());
|
return "";
|
}
|
msxml::IXMLDOMElement e = x.GetXmlDoc().documentElement;
|
if(e)
|
{
|
string code = e.text;
|
trace(code);
|
return "F"+code;
|
}
|
return "F1000";
|
}
|
int OnPreSave()
|
{
|
dw_base.AcceptText();
|
dw_base = new xdwtable__;
|
dw_base.setNativePointer(this.GetControl("dw_base"));
|
string ForwarderNo = dw_base.GetItemString(1,"ForwarderNo",0);
|
if (ForwarderNo=="" || ForwarderNo== nil)
|
{
|
dw_base.SetItemString(1,"ForwarderNo",getGoodsNo());
|
}
|
xdwtable__ dwcon = new xdwtable__;
|
dwcon.setNativePointer(dw_base.FindDwTable("item",0));
|
int i;
|
for(i=1;i<=dwcon.GetRowCount();i++)
|
{
|
string aTemp;
|
string aName = dwcon.GetItemString(i,"ContacterName",0);
|
trace(aName);
|
if (aName=="" || aName== nil)
|
{
|
aTemp=dwcon.GetItemString(i,"Mobile",0)+dwcon.GetItemString(i,"TEL",0)+dwcon.GetItemString(i,"Fax",0)+dwcon.GetItemString(i,"Email",0)+dwcon.GetItemString(i,"PCRemark",0)+dwcon.GetItemString(i,"fz",0);
|
trace(aTemp);
|
if(aTemp !="" && aTemp != nil)
|
{
|
alert("ÁªÏµÈËÃû³Æ±ØÌ");
|
return -1;
|
}
|
}
|
else{
|
string ContactID = dwcon.GetItemString(i,"ContactID",0);
|
if (ContactID=="" || ContactID== nil)
|
{
|
dwcon.SetItemString(i,"ContactID",GetGuid());
|
dwcon.SetItemString(i,"PCStatus","Y");
|
dw_base.SetItemString(1,"PrimaryContactID",dwcon.GetItemString(1,"ContactID"));
|
}
|
}
|
}
|
xdwtable__ dwcon2 = new xdwtable__;
|
dwcon2.setNativePointer(dw_base.FindDwTable("item2",0));
|
int k;
|
for (k=1;k <= dwcon2.GetRowCount();k++)
|
{
|
string sPBABankName2 = dwcon2.GetItemString(k,"CBank");
|
string sPBABankAccountNo2 = dwcon2.GetItemString(k,"CBankNo");
|
if (sPBABankName2 == nil) sPBABankName2 = "";
|
if (sPBABankAccountNo2 == nil) sPBABankAccountNo2 = "";
|
string sPBAAll2 = sPBABankName2 + sPBABankAccountNo2;
|
|
if (sPBAAll2 != "")
|
{
|
if (sPBABankName2 == "")
|
{
|
alert("ÈËÃñ±ÒÒøÐÐÃû³Æ²»ÄÜΪ¿Õ");
|
return -1;
|
}
|
if (sPBABankAccountNo2 == "")
|
{
|
alert("ÈËÃñ±ÒÒøÐÐÕË»§²»ÄÜΪ¿Õ");
|
return -1;
|
}
|
dwcon2.SetItemString(k,"CPBAStatus","Y");
|
dwcon2.SetItemString(k,"CCurrencyCode","RMB");
|
dwcon2.SetItemString(k,"CBankAccountID",GetGuid());
|
|
if(dwcon2.GetItemString(k,"CBankAccountID")!="" && this.m_EntityID =="")
|
{
|
dw_base.SetItemString(1,"CBkAccountID",dwcon2.GetItemString(k,"CBankAccountID"));
|
}
|
}
|
}
|
xdwtable__ dwcon1 = new xdwtable__;
|
dwcon1.setNativePointer(dw_base.FindDwTable("item1",0));
|
int j;
|
for (j=1;j <= dwcon1.GetRowCount();j++)
|
{
|
string sPBABankName1 = dwcon1.GetItemString(j,"EBank");
|
string sPBABankAccountNo1 = dwcon1.GetItemString(j,"EBankNo");
|
if (sPBABankName1 == nil) sPBABankName1 = "";
|
if (sPBABankAccountNo1 == nil) sPBABankAccountNo1 = "";
|
string sPBAAll1 = sPBABankName1 + sPBABankAccountNo1;
|
if (sPBAAll1 != "")
|
{
|
if (sPBABankName1 == "")
|
{
|
alert("ÃÀ½ðÒøÐÐÃû³Æ²»ÄÜΪ¿Õ");
|
return -1;
|
}
|
if (sPBABankAccountNo1 == "")
|
{
|
alert("ÃÀ½ðÒøÐÐÕË»§²»ÄÜΪ¿Õ");
|
return -1;
|
}
|
dwcon1.SetItemString(j,"EPBAStatus","Y");
|
dwcon1.SetItemString(j,"ECurrencyCode","USD");
|
dwcon1.SetItemString(j,"EBankAccountID",GetGuid());
|
if(dwcon1.GetItemString(j,"EBankAccountID")!="" && this.m_EntityID =="")
|
{
|
dw_base.SetItemString(1,"EBkAccountID",dwcon1.GetItemString(j,"EBankAccountID"));
|
}
|
}
|
}
|
return 1;
|
}
|
int OnPostSave()
|
{
|
dw_base = new xdwtable__;
|
dw_base.setNativePointer(this.GetControl("dw_base"));
|
xaserverarg__ args = new xaserverarg__;
|
args.setNativePointer(args.CreateInstance());
|
xml__ x = new xml__;
|
x.setNativePointer(xml__::CreateInstance());
|
dw_base.DwUpdateAllTo(x.GetXmlDoc());
|
//trace(x.GetXml());
|
|
//Ö÷ÁªÏµÈË
|
string spGuid;
|
msxml::IXMLDOMElement e;
|
var list = x.GetXmlDoc().selectNodes("//item");
|
int nlen = list.length;
|
int i;
|
for(i=0; i<nlen; i++)
|
{
|
e = list.item(i);
|
if (i == 0) spGuid = e.selectSingleNode("@guid").text;
|
string sP = e.selectSingleNode("PPrimaryFlag").text;
|
if (sP == "Y")
|
{
|
spGuid = e.selectSingleNode("@guid").text;
|
break;
|
}
|
}
|
if (spGuid == "" || spGuid == nil)
|
{
|
trace("error");
|
return 0;
|
}
|
args.AddArg("contact",spGuid);
|
//trace("<---->");
|
//trace(spGuid);
|
xml__ x1 = new xml__;
|
x1.setNativePointer(x1.CreateInstance());
|
if (getUrl("/sale/data/SupplierSubmit/pref/primarycontact",args.GetString(),x) != 1)
|
{
|
string error = x1.GetXmlDoc().text;
|
trace(error);
|
return 0;
|
}
|
|
|
return 1;
|
}
|
int OnSave()
|
{
|
dw_base = new xdwtable__;
|
dw_base.setNativePointer(this.GetControl("dw_base"));
|
string SName = dw_base.GetItemString(1,"Name");
|
if(SName==""){
|
alert("ÇëÊäÈë»õ´úÃû³Æ£¡");
|
return -1;
|
}
|
int rec =OnPreSave();
|
if (rec== -1) return -1;
|
xml__ x=new xml__;
|
x.setNativePointer(xml__::CreateInstance());
|
dw_base.DwUpdateAllTo(x.GetXmlDoc());
|
trace(x.GetXml());
|
xaserverarg__ arg=new xaserverarg__;
|
arg.setNativePointer(arg.CreateInstance());
|
arg.AddArg("content",x.GetXml());
|
arg.AddArg("dbmap","Forwarder.dbmap");
|
//arg.AddArg("m_dels",m_dels);
|
if (getUrl("/sale/data/LogisticsCode/entity/save",arg.GetString(),x) != 1)
|
{
|
trace("error:"+x.GetXml());
|
alert("±£´æÊ§°Ü!");
|
return 0;
|
}
|
else
|
{
|
trace(x.GetXml());
|
if(x.GetXmlDoc().selectSingleNode("error"))
|
{
|
alert("±£´æ³ö´í2!");
|
return 0;
|
}
|
alert("±£´æ³É¹¦!");
|
dw_base.ResetUpdateStatus();
|
OnPostSave();
|
}
|
dw_base.Redraw();
|
//m_dels="";
|
return 0;
|
}
|
int OnCmdDispatch(string comdid)
|
{
|
if(comdid.find("action:bill.row.add",0)>=0) {
|
OnAddrow();
|
}
|
else if(comdid.find("bill.row.insert",0)>=0) {
|
OnInsertRow();
|
}
|
else if(comdid.find("bill.row.delete",0)>=0) {
|
OnDeleteRow();
|
}
|
else if(comdid.find("bill.save",0)>=0) {
|
trace(1);
|
OnSave();
|
}
|
return 0;
|
}
|
|
int OnXCommand(ref TXCommandEvent evt,int p)
|
{
|
return OnCmdDispatch(evt.pStrID);
|
}
|
int OnCellChanged(ref TNotifyEvent evt,int p)
|
{
|
dw_base = new xdwtable__;
|
dw_base.setNativePointer(this.GetControl("dw_base"));
|
ref DWNMHDR hdr = evt.pnmh;
|
string colname=hdr.colname;
|
string coldata = hdr.data;
|
trace(colname);
|
if(colname=="ForwarderNo")
|
{
|
string cspec = dw_base.GetItemString(1,1);
|
trace(cspec);
|
string SpecRule="^\\d*$";
|
xaserverarg__ args = new xaserverarg__;
|
args.setNativePointer(args.CreateInstance());
|
args.AddArg("CSpec",cspec);
|
args.AddArg("SpecRule",SpecRule);
|
xml__ x= new xml__;
|
x.setNativePointer(xml__::CreateInstance());
|
getUrl("/sale/data/LogisticsCode/pref/forwarderno/check",args.GetString(),x);
|
|
if(x.GetXmlDoc().selectSingleNode("root/spec"))
|
{
|
alert("ÇëÊäÈëÊý×Ö£¡");
|
return 0;
|
}
|
|
}
|
//Ö»ÄÜѡһ¸öÖ÷ÁªÏµÈË
|
else if (colname == "PPrimaryFlag" && coldata == "Y")
|
{
|
xdwtable__ dw_pc;
|
dw_pc = new xdwtable__;
|
dw_pc.setNativePointer(dw_base.FindDwTable("item"));
|
if (dw_pc)
|
{
|
int i;
|
for (i=1;i <= dw_pc.GetRowCount();i++)
|
{
|
if (i != hdr.row)
|
dw_pc.SetItemString(i,"PPrimaryFlag","N");
|
}
|
}
|
}
|
return 1;
|
}
|
int OnAttachEvent()
|
{
|
AttachEvent("WM_XCOMMAND",OnXCommand);
|
//AttachEvent("WM_SETFOCUS",OnSetFocus);
|
AttachEvent("dw_base","DWV_ITEMCHANGED",OnCellChanged);
|
return 0;
|
}
|
int onload()
|
{
|
dw_base = new xdwtable__;
|
dw_base.setNativePointer(this.GetControl("dw_base"));
|
|
OnAttachEvent();
|
//if(!m_configDoc) return -1;
|
|
maint::onload();
|
|
OnClear();
|
}
|
|
]
|
]
|
]
|