|  |  | 
 |  |  | use "system.vl" | 
 |  |  | use "win.vl" | 
 |  |  | use "maint.vl" | 
 |  |  | use "file.vl" | 
 |  |  | use "dev:vm[xcell.vm]" | 
 |  |  | unit vbusiness.entity | 
 |  |  | [ | 
 |  |  |    ExpressMaint is extend maint; | 
 |  |  |    about ExpressMaint | 
 |  |  |    [ | 
 |  |  |       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,"PartyID",GetGuid());						 | 
 |  |  |                dw_base.SetItemString(1,"PStatus","1"); | 
 |  |  |                dw_base.SetItemDisplayString(1,"PStatus","有效");	 | 
 |  |  |                dw_base.SetItemString(1,"PADStatus","1"); | 
 |  |  |                dw_base.SetItemString(1,"CreatorID",m_userid);				 | 
 |  |  |                dw_base.SetItemString(1,"AddressID",GetGuid()); | 
 |  |  |                dw_base.SetItemString(1,"PADIdentifyAddressFlag","Y");	 | 
 |  |  |                dw_base.SetItemString(1,"PrimaryFlag","Y");								 | 
 |  |  |                dw_base.SetItemString(1,"Type","8");					 | 
 |  |  |                dw_base.SetItemString(1,"EnterName",m_userid); | 
 |  |  |                dw_base.SetItemDisplayString(1,"EnterName",m_username);				 | 
 |  |  |                dw_base.SetItemString(1,"CreateDate",TApp::GetCurDate());			 | 
 |  |  |                dw_base.SetItemString(1,"PBAStatus","Y");					 | 
 |  |  | 						 | 
 |  |  | 			 | 
 |  |  |             } | 
 |  |  |             return 0; | 
 |  |  |          }					 | 
 |  |  | 		 | 
 |  |  |          int OnSetFocus(ref TNotifyEvent evt,int p) | 
 |  |  |          { | 
 |  |  |             SetAgent("maint"); | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          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; | 
 |  |  |          } | 
 |  |  | #include <wobject/xstring.hpp> | 
 |  |  | #include <xcontrol/xtreeview.hpp> | 
 |  |  | #include <xcontrol/xdwgrid.hpp> | 
 |  |  | #include <wobject/xdouble.hpp> | 
 |  |  | #include <xcontrol/xlayersheet.hpp> | 
 |  |  | #include <xcontrol/xcell.hpp> | 
 |  |  |  | 
 |  |  |          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;						 | 
 |  |  |                   }	 | 
 |  |  | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" | 
 |  |  | #include "vbusiness/vframe/maint.vframe.vbusiness.hpp" | 
 |  |  | #include "viewobject/view.base.hpp" | 
 |  |  |  | 
 |  |  |                }*/				 | 
 |  |  |                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/express/PartyNo",arg.GetString(),x) != 1) | 
 |  |  |             { | 
 |  |  |                trace(x.GetXml()); | 
 |  |  |                return ""; | 
 |  |  |             }			 | 
 |  |  |             msxml::IXMLDOMElement e = x.GetXmlDoc().documentElement; | 
 |  |  |             if(e) | 
 |  |  |             { | 
 |  |  |                string code = e.text; | 
 |  |  |             trace(code); | 
 |  |  |                return "E"+code; | 
 |  |  |             } | 
 |  |  |             return "E1000"; | 
 |  |  |          }			 | 
 |  |  |          int OnPreSave() | 
 |  |  |          { | 
 |  |  |             dw_base.AcceptText();					 | 
 |  |  |             dw_base = new xdwtable__; | 
 |  |  |             dw_base.setNativePointer(this.GetControl("dw_base")); | 
 |  |  |             string ExpressNo = dw_base.GetItemString(1,"ExpressNo",0); | 
 |  |  |             if (ExpressNo=="" || ExpressNo== nil)  | 
 |  |  |                { | 
 |  |  |                dw_base.SetItemString(1,"ExpressNo",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); | 
 |  |  |                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);	 | 
 |  |  |                   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","1");					 | 
 |  |  |                         //dw_base.SetItemString(1,"PrimaryContactID",dwcon.GetItemString(1,"ContactID"));								 | 
 |  |  |                      }	 | 
 |  |  | 						 | 
 |  |  | using xml = KXMLDOMDocument; | 
 |  |  | class __declspec(dllexport) ExpressMaint : public maint | 
 |  |  | { | 
 |  |  | public: | 
 |  |  |    KXMLDOMDocument m_configDoc; | 
 |  |  |    xdwtable dw_base; | 
 |  |  |    xstring m_userid; | 
 |  |  |    xstring m_username; | 
 |  |  |    xstring ContactID; | 
 |  |  |    xcell dw_cell; | 
 |  |  |    xstring m_EntityID = L""; | 
 |  |  | public: | 
 |  |  |    ExpressMaint(void* implPtr, HWND hWnd) :maint(implPtr, hWnd) {} | 
 |  |  | public: | 
 |  |  |    static ExpressMaint* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |    { | 
 |  |  |       ExpressMaint* pWin = new ExpressMaint(implPtr, (HWND)hWnd); | 
 |  |  |       return pWin; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int setCellReadOnly() | 
 |  |  |    { | 
 |  |  |       dw_base = GetControl(L"dw_base"); | 
 |  |  |       dw_cell = dw_base.QueryItem(L"ixcell"); | 
 |  |  |       xstring strnew = L"<cellprop celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='保护' cellvisibleex='' cellvisible='' cellvalid='' cellinitial=''/>"; | 
 |  |  |       dw_cell.SetCellProps(2, 2, strnew); | 
 |  |  |       return 0; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                } | 
 |  |  |             } | 
 |  |  |             xdwtable__ dwcon1 =  new xdwtable__;				 | 
 |  |  |             dwcon1.setNativePointer(dw_base.FindDwTable("PartyBankAccount",0)); | 
 |  |  |             int j; | 
 |  |  |             for (j=1;j <= dwcon1.GetRowCount();j++) | 
 |  |  |             { | 
 |  |  |                string sPBABankName = dwcon1.GetItemString(j,"Bank"); | 
 |  |  |                string sPBABankAccountNo = dwcon1.GetItemString(j,"BankNo"); | 
 |  |  |                if (sPBABankName == nil) sPBABankName = ""; | 
 |  |  |                if (sPBABankAccountNo == nil) sPBABankAccountNo = ""; | 
 |  |  |                string sPBAAll = sPBABankName + sPBABankAccountNo; | 
 |  |  |                if (sPBAAll != "") | 
 |  |  |                { | 
 |  |  |                   if (sPBABankName == "") | 
 |  |  |                   { | 
 |  |  |                      alert("银行名称不能为空"); | 
 |  |  |                      return -1; | 
 |  |  |                   } | 
 |  |  |                   if (sPBABankAccountNo == "") | 
 |  |  |                   { | 
 |  |  |                      alert("银行账户不能为空"); | 
 |  |  |                      return -1; | 
 |  |  |                   }				 | 
 |  |  |                } | 
 |  |  |             }							 | 
 |  |  |             return 1;					 | 
 |  |  |          }			 | 
 |  |  |          int OnSave() | 
 |  |  |    xstring GetGuid() { | 
 |  |  |       return publiccode::GetGuid(); | 
 |  |  |    } | 
 |  |  |    int OnClear() { | 
 |  |  |       if (m_EntityID == L"") { | 
 |  |  |          //trace(1); | 
 |  |  |          m_userid = publiccode::GetUser().personid; | 
 |  |  |          m_username = publiccode::GetUser().name; | 
 |  |  |          dw_base = GetControl(L"dw_base"); | 
 |  |  |          dw_base.SetItemString(1, L"PartyID", GetGuid()); | 
 |  |  |          dw_base.SetItemString(1, L"PStatus", L"1"); | 
 |  |  |          dw_base.SetItemDisplayString(1, L"PStatus", L"有效"); | 
 |  |  |          dw_base.SetItemString(1, L"PADStatus", L"1"); | 
 |  |  |          dw_base.SetItemString(1, L"CreatorID", m_userid); | 
 |  |  |          dw_base.SetItemString(1, L"AddressID", GetGuid()); | 
 |  |  |          dw_base.SetItemString(1, L"PADIdentifyAddressFlag", L"Y"); | 
 |  |  |          dw_base.SetItemString(1, L"PrimaryFlag", L"Y"); | 
 |  |  |          dw_base.SetItemString(1, L"Type", L"8"); | 
 |  |  |          dw_base.SetItemString(1, L"EnterName", m_userid); | 
 |  |  |          dw_base.SetItemDisplayString(1, L"EnterName", m_username); | 
 |  |  |          dw_base.SetItemString(1, L"CreateDate", publiccode::GetCurrentDate()); | 
 |  |  |          dw_base.SetItemString(1, L"PBAStatus", L"Y"); | 
 |  |  |          return 0; | 
 |  |  |  | 
 |  |  |       } | 
 |  |  |       return 0; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnSetFocus(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       SetAgent(L"maint"); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnAddrow() | 
 |  |  |    { | 
 |  |  |       dw_base = GetControl(L"dw_base"); | 
 |  |  |       xdwtable dw =dw_base.GetCurTable(); | 
 |  |  |       xstring dw_n = dw.GetDwName(); | 
 |  |  |       if (dw_n == L"item") | 
 |  |  |       { | 
 |  |  |          dw.InsertRow(0); | 
 |  |  |          int rows = dw.GetRowCount(); | 
 |  |  |          dw.SetRow(rows); | 
 |  |  |  | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnInsertRow() | 
 |  |  |    { | 
 |  |  |       dw_base =GetControl(L"dw_base"); | 
 |  |  |       xdwtable dw = dw_base.GetCurTable(); | 
 |  |  |       xstring dw_n = dw.GetDwName(); | 
 |  |  |       if (dw_n == L"item") | 
 |  |  |       { | 
 |  |  |          int row = dw.GetRow(); | 
 |  |  |          if (row < 1) return 0; | 
 |  |  |          dw.InsertRow(row); | 
 |  |  |          dw.SetRow(row); | 
 |  |  |  | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnDeleteRow() | 
 |  |  |    { | 
 |  |  |       dw_base = GetControl(L"dw_base"); | 
 |  |  |       xdwtable dw = dw_base.GetCurTable(); | 
 |  |  |       xstring dw_n = dw.GetDwName(); | 
 |  |  |       if (dw_n == L"item") | 
 |  |  |       { | 
 |  |  |          int row = dw.GetRow(); | 
 |  |  |          if (row < 1) return 0; | 
 |  |  |          /*xstring del = dw.GetItemString(row,8); | 
 |  |  |          if(del!=L"") | 
 |  |  |          { | 
 |  |  |             dw_base = new xdwtable__; | 
 |  |  |             dw_base.setNativePointer(this.GetControl("dw_base"));							 | 
 |  |  |             string SName = dw_base.GetItemString(1,"Name"); | 
 |  |  |             if(SName==""){ | 
 |  |  |                alert("请输入快递公司名称!"); | 
 |  |  |             if(m_dels==L"") | 
 |  |  |             { | 
 |  |  |                m_dels=del; | 
 |  |  |             } | 
 |  |  |             else | 
 |  |  |             { | 
 |  |  |                xstring temp=m_dels; | 
 |  |  |                m_dels=del + L"|" + temp; | 
 |  |  |             //+= L"|"+del; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |          }*/ | 
 |  |  |          dw.DeleteRow(row); | 
 |  |  |          dw.SetRow(row - 1); | 
 |  |  |       } | 
 |  |  |       //trace(m_dels); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    xstring getGoodsNo() | 
 |  |  |    { | 
 |  |  |       xml x; | 
 |  |  |  | 
 |  |  |       xaserverarg arg; | 
 |  |  |  | 
 |  |  |       if (getUrl(L"/sale/data/LogisticsCode/pref/express/PartyNo", arg.GetString(), x) != 1) | 
 |  |  |       { | 
 |  |  |          trace(x.xml()); | 
 |  |  |          return L""; | 
 |  |  |       } | 
 |  |  |       KXMLDOMElement e = x.documentElement(); | 
 |  |  |       if (e) | 
 |  |  |       { | 
 |  |  |          xstring code = e.text(); | 
 |  |  |          trace(code); | 
 |  |  |          return L"E" + code; | 
 |  |  |       } | 
 |  |  |       return L"E1000"; | 
 |  |  |    } | 
 |  |  |    int OnPreSave() | 
 |  |  |    { | 
 |  |  |       dw_base.AcceptText(); | 
 |  |  |       dw_base = GetControl(L"dw_base"); | 
 |  |  |       xstring ExpressNo = dw_base.GetItemString(1, L"ExpressNo"); | 
 |  |  |       if (ExpressNo == L"") | 
 |  |  |       { | 
 |  |  |          dw_base.SetItemString(1, L"ExpressNo", getGoodsNo()); | 
 |  |  |       } | 
 |  |  |       xdwtable dwcon = dw_base.FindDwTable(L"item", 0); | 
 |  |  |       int i; | 
 |  |  |       for (i = 1; i <= dwcon.GetRowCount(); i++) | 
 |  |  |       { | 
 |  |  |          xstring aTemp; | 
 |  |  |          xstring aName = dwcon.GetItemString(i, L"ContacterName"); | 
 |  |  |          if (aName == L"") | 
 |  |  |          { | 
 |  |  |             aTemp = dwcon.GetItemString(i, L"Mobile") + dwcon.GetItemString(i, L"TEL") + dwcon.GetItemString(i, L"Fax") + dwcon.GetItemString(i, L"Email") + dwcon.GetItemString(i, L"PCRemark"); | 
 |  |  |             trace(aTemp); | 
 |  |  |             if (aTemp != L"") | 
 |  |  |             { | 
 |  |  |                alert(L"联系人名称必填!"); | 
 |  |  |                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","Express.dbmap"); | 
 |  |  |             //arg.AddArg("m_dels",m_dels);				 | 
 |  |  |             if (getUrl("/sale/data/LogisticsCode/entity/express/save",arg.GetString(),x) != 1) | 
 |  |  |          } | 
 |  |  |          else { | 
 |  |  |             xstring ContactID = dwcon.GetItemString(i, L"ContactID"); | 
 |  |  |             if (ContactID == L"") | 
 |  |  |             { | 
 |  |  |                trace("error:"+x.GetXml()); | 
 |  |  |                alert("保存失败!"); | 
 |  |  |                return 0; | 
 |  |  |             }						 | 
 |  |  |             else | 
 |  |  |             {	 | 
 |  |  |                trace(x.GetXml()); | 
 |  |  |                if(x.GetXmlDoc().selectSingleNode("error")) | 
 |  |  |                { | 
 |  |  |                   alert("保存出错2!"); | 
 |  |  |                   return 0;				 | 
 |  |  |                } | 
 |  |  |                alert("保存成功!"); | 
 |  |  |                dw_base.ResetUpdateStatus(); | 
 |  |  |                setCellReadOnly();						 | 
 |  |  |                dwcon.SetItemString(i, L"ContactID", GetGuid()); | 
 |  |  |                dwcon.SetItemString(i, L"PCStatus", L"1"); | 
 |  |  |                //dw_base.SetItemString(1,L"PrimaryContactID",dwcon.GetItemString(1,L"ContactID"));								 | 
 |  |  |             } | 
 |  |  |             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) | 
 |  |  |       } | 
 |  |  |       xdwtable dwcon1 = dw_base.FindDwTable(L"PartyBankAccount", 0); | 
 |  |  |       int j; | 
 |  |  |       xstring sPBABankName = L""; | 
 |  |  |       xstring sPBABankAccountNo = L""; | 
 |  |  |       for (j = 1; j <= dwcon1.GetRowCount(); j++) | 
 |  |  |       { | 
 |  |  |          xstring sPBABankName = dwcon1.GetItemString(j, L"Bank"); | 
 |  |  |          xstring sPBABankAccountNo = dwcon1.GetItemString(j, L"BankNo"); | 
 |  |  |  | 
 |  |  |          xstring sPBAAll = sPBABankName + sPBABankAccountNo; | 
 |  |  |          if (sPBAAll != L"") | 
 |  |  |          { | 
 |  |  |             dw_base = new xdwtable__; | 
 |  |  |             dw_base.setNativePointer(this.GetControl("dw_base"));						 | 
 |  |  |             ref DWNMHDR  hdr = evt.pnmh; | 
 |  |  |             string colname=hdr.colname; | 
 |  |  |             //trace(colname); | 
 |  |  |             if(colname=="ExpressNo") | 
 |  |  |             if (sPBABankName == L"") | 
 |  |  |             { | 
 |  |  |                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; | 
 |  |  |                } | 
 |  |  | 					 | 
 |  |  |                alert(L"银行名称不能为空"); | 
 |  |  |                return -1; | 
 |  |  |             } | 
 |  |  |             return 1; | 
 |  |  |          }			 | 
 |  |  |          int OnAttachEvent() | 
 |  |  |             if (sPBABankAccountNo == L"") | 
 |  |  |             { | 
 |  |  |                alert(L"银行账户不能为空"); | 
 |  |  |                return -1; | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnSave() | 
 |  |  |    { | 
 |  |  |       dw_base = GetControl(L"dw_base"); | 
 |  |  |       xstring SName = dw_base.GetItemString(1, L"Name"); | 
 |  |  |       if (SName == L"") { | 
 |  |  |          alert(L"请输入快递公司名称!"); | 
 |  |  |          return -1; | 
 |  |  |       } | 
 |  |  |       int rec = OnPreSave(); | 
 |  |  |       if (rec == -1)   return -1; | 
 |  |  |       xml x; | 
 |  |  |  | 
 |  |  |       dw_base.DwUpdateAllTo(x); | 
 |  |  |       trace(x.xml()); | 
 |  |  |       xaserverarg arg; | 
 |  |  |  | 
 |  |  |       arg.AddArg(L"content", x.xml()); | 
 |  |  |       arg.AddArg(L"dbmap", L"Express.dbmap"); | 
 |  |  |       //arg.AddArg(L"m_dels",m_dels);				 | 
 |  |  |       if (getUrl(L"/sale/data/LogisticsCode/entity/express/save", arg.GetString(), x) != 1) | 
 |  |  |       { | 
 |  |  |          trace(L"error:" + (xstring)x.xml()); | 
 |  |  |          alert(L"保存失败!"); | 
 |  |  |          return 0; | 
 |  |  |       } | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  |          trace(x.xml()); | 
 |  |  |          if (x.selectSingleNode(L"error")) | 
 |  |  |          { | 
 |  |  |             AttachEvent("WM_XCOMMAND",OnXCommand); | 
 |  |  |             AttachEvent("WM_SETFOCUS",OnSetFocus); | 
 |  |  |             AttachEvent("dw_base","DWV_ITEMCHANGED",OnCellChanged);				 | 
 |  |  |             alert(L"保存出错2!"); | 
 |  |  |             return 0; | 
 |  |  |          } | 
 |  |  | 					 | 
 |  |  |          int onload() | 
 |  |  |          {			 | 
 |  |  |             dw_base = new xdwtable__; | 
 |  |  |             dw_base.setNativePointer(this.GetControl("dw_base"));			 | 
 |  |  | 								 | 
 |  |  |             OnAttachEvent();								 | 
 |  |  |             //if(!m_configDoc) return -1; | 
 |  |  |          alert(L"保存成功!"); | 
 |  |  |          dw_base.ResetUpdateStatus(); | 
 |  |  |          setCellReadOnly(); | 
 |  |  |       } | 
 |  |  |       dw_base.Redraw(); | 
 |  |  |       //m_dels=L"";				 | 
 |  |  |       return 0; | 
 |  |  |    } | 
 |  |  |    int OnCmdDispatch(xstring comdid) | 
 |  |  |    { | 
 |  |  |       if (comdid.find(L"action:bill.row.add", 0) >= 0) { | 
 |  |  |          OnAddrow(); | 
 |  |  |       } | 
 |  |  |       else if (comdid.find(L"bill.row.insert", 0) >= 0) { | 
 |  |  |          OnInsertRow(); | 
 |  |  |       } | 
 |  |  |       else if (comdid.find(L"bill.row.delete", 0) >= 0) { | 
 |  |  |          OnDeleteRow(); | 
 |  |  |       } | 
 |  |  |       else if (comdid.find(L"bill.save", 0) >= 0) { | 
 |  |  |          //trace(1); | 
 |  |  |          OnSave(); | 
 |  |  |       } | 
 |  |  |       return 0; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |             maint::onload(); | 
 |  |  |             OnClear();				 | 
 |  |  |    int OnXCommand(TEvent* evt, LPARAM param) | 
 |  |  |    { | 
 |  |  |       return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |    } | 
 |  |  |    int OnCellChanged(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       dw_base = GetControl(L"dw_base"); | 
 |  |  |       DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |       xstring colname = hdr.colname; | 
 |  |  |       //trace(colname); | 
 |  |  |       if (colname == L"ExpressNo") | 
 |  |  |       { | 
 |  |  |          xstring cspec = dw_base.GetItemString(1, 1); | 
 |  |  |          trace(cspec); | 
 |  |  |          xstring SpecRule = L"^\\d*$"; | 
 |  |  |          xaserverarg args; | 
 |  |  |  | 
 |  |  |          args.AddArg(L"CSpec", cspec); | 
 |  |  |          args.AddArg(L"SpecRule", SpecRule); | 
 |  |  |          xml  x; | 
 |  |  |  | 
 |  |  |          getUrl(L"/sale/data/LogisticsCode/pref/forwarderno/check", args.GetString(), x); | 
 |  |  |          if (x.selectSingleNode(L"root/spec")) | 
 |  |  |          { | 
 |  |  |             alert(L"请输入数字!"); | 
 |  |  |             return 0; | 
 |  |  |          } | 
 |  |  |  | 
 |  |  |       ] | 
 |  |  |    ] | 
 |  |  | ] | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnAttachEvent() | 
 |  |  |    { | 
 |  |  |       AttachEvent(L"WM_XCOMMAND", (FEvent)&ExpressMaint::OnXCommand); | 
 |  |  |       AttachEvent(L"WM_SETFOCUS", (FEvent)&ExpressMaint::OnSetFocus); | 
 |  |  |       AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", (FEvent)&ExpressMaint::OnCellChanged); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int onload() | 
 |  |  |    { | 
 |  |  |       SetArg(); | 
 |  |  |       dw_base = GetControl(L"dw_base"); | 
 |  |  |  | 
 |  |  |       OnAttachEvent(); | 
 |  |  |       //if(!m_configDoc) return -1; | 
 |  |  |  | 
 |  |  |       maint::onload(); | 
 |  |  |       OnClear(); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int onloaded() | 
 |  |  |    { | 
 |  |  |       return maint::onloaded(); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  | }; |