|  |  | 
 |  |  | use "system.vl" | 
 |  |  | use "win.vl" | 
 |  |  | use "list.vl" | 
 |  |  | use "file.vl" | 
 |  |  | unit vbusiness.entity | 
 |  |  | [ | 
 |  |  |    CartermList is extend list; | 
 |  |  |    about CartermList | 
 |  |  |    [ | 
 |  |  |       field: | 
 |  |  |       [	 | 
 |  |  |          xdwpages__ dw_pages; | 
 |  |  |          string m_QueryTxt; | 
 |  |  |          msxml::IXMLDOMDocument m_configDoc; | 
 |  |  |          static int dw_hWnd;			 | 
 |  |  |       ] | 
 |  |  | #include <wobject/xstring.hpp> | 
 |  |  | #include <xcontrol/xtreeview.hpp> | 
 |  |  | #include <xcontrol/xdwgrid.hpp> | 
 |  |  | #include <wobject/xdouble.hpp> | 
 |  |  | #include <xcontrol/xlayersheet.hpp> | 
 |  |  |  | 
 |  |  | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" | 
 |  |  | #include "viewobject/view.base.hpp" | 
 |  |  | #include "adt/xarray.hpp" | 
 |  |  |  | 
 |  |  | using xml = KXMLDOMDocument; | 
 |  |  | class __declspec(dllexport) CartermList : public listwin | 
 |  |  | { | 
 |  |  | public: | 
 |  |  |    //xdwgrid   dw_list; | 
 |  |  |    //xdwpages dw_pages; | 
 |  |  |    //xstring m_QueryTxt; | 
 |  |  |    //KXMLDOMDocument m_configDoc; | 
 |  |  |    //static int dw_hWnd; | 
 |  |  |  | 
 |  |  | public: | 
 |  |  |    CartermList(void* implPtr, HWND hWnd) :listwin(implPtr, hWnd) {} | 
 |  |  | public: | 
 |  |  |    static CartermList* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |    { | 
 |  |  |       CartermList* pWin = new CartermList(implPtr, (HWND)hWnd); | 
 |  |  |       return pWin; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |    xstring GetGuid() { | 
 |  |  |       return publiccode::GetGuid(); | 
 |  |  |    } | 
 |  |  |    int OnAddrow() | 
 |  |  |    { | 
 |  |  |       dw_list.InsertRow(0); | 
 |  |  |       int rows = dw_list.GetRowCount(); | 
 |  |  |       dw_list.SetRow(rows); | 
 |  |  |       dw_list.SetItemString(rows, L"PartyID", GetGuid()); | 
 |  |  |       dw_list.SetItemString(rows, L"ContactID", GetGuid()); | 
 |  |  |       dw_list.SetItemString(rows, L"PAStatus", L"1"); | 
 |  |  |       dw_list.SetItemString(rows, L"PStatus", L"1"); | 
 |  |  |       dw_list.SetItemString(rows, L"PCStatus", L"1"); | 
 |  |  |       dw_list.SetItemString(rows, L"Type", L"7"); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |    int OnInsertRow() | 
 |  |  |    { | 
 |  |  |       int row = dw_list.GetRow(); | 
 |  |  |       if (row<1 || row>dw_list.GetRowCount()) return 0; | 
 |  |  |       dw_list.InsertRow(row); | 
 |  |  |       dw_list.SetItemString(row, L"PartyID", GetGuid()); | 
 |  |  |       dw_list.SetItemString(row, L"ContactID", GetGuid()); | 
 |  |  |       dw_list.SetItemString(row, L"PAStatus", L"1"); | 
 |  |  |       dw_list.SetItemString(row, L"PStatus", L"1"); | 
 |  |  |       dw_list.SetItemString(row, L"PCStatus", L"1"); | 
 |  |  |       dw_list.SetItemString(row, L"Type", L"7"); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int ViewUpdate(LPARAM pr, xstring updateItem, xaserverarg   arg) | 
 |  |  |    { | 
 |  |  |       if (updateItem == L"del") | 
 |  |  |       { | 
 |  |  |          int DelRow = dw_list.GetRow(); | 
 |  |  |          dw_list.DeleteRow(DelRow); | 
 |  |  |  | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnDeleteRow() | 
 |  |  |    { | 
 |  |  |       int rows = dw_list.GetRowCount(); | 
 |  |  |        | 
 |  |  |       method: | 
 |  |  |       [ | 
 |  |  |  | 
 |  |  |          int alert(string str) | 
 |  |  |          { | 
 |  |  |             //win__::MessageBox(this.GetHWND(),str,"提示22:",0); | 
 |  |  |             TApp::alert(this,str); | 
 |  |  |             return 0; | 
 |  |  |          }		 | 
 |  |  |  | 
 |  |  |       int row2 = dw_list.GetPrevSelectRow(rows); | 
 |  |  |       while (row2 > 0) { | 
 |  |  |          dw_list.DeleteRow(row2); | 
 |  |  |          row2 = dw_list.GetPrevSelectRow(row2 - 1); | 
 |  |  |       } | 
 |  |  |        | 
 |  |  |          string GetGuid(){ | 
 |  |  |             return TApp::GetGuid();			 | 
 |  |  |          }							 | 
 |  |  |          int OnAddrow() | 
 |  |  |          { | 
 |  |  |             this.dw_list.InsertRow(0);  | 
 |  |  |             int rows = this.dw_list.GetRowCount(); | 
 |  |  |             this.dw_list.SetRow(rows);					 | 
 |  |  |             this.dw_list.SetItemString(rows,"PartyID",GetGuid());	 | 
 |  |  |             this.dw_list.SetItemString(rows,"ContactID",GetGuid());						 | 
 |  |  |             this.dw_list.SetItemString(rows,"PAStatus","1"); | 
 |  |  |             this.dw_list.SetItemString(rows,"PStatus","1"); | 
 |  |  |             this.dw_list.SetItemString(rows,"PCStatus","1");					 | 
 |  |  |             this.dw_list.SetItemString(rows,"Type","7");					 | 
 |  |  |          } | 
 |  |  |          int OnInsertRow() | 
 |  |  |          { | 
 |  |  |             int row = this.dw_list.GetRow(); | 
 |  |  |             if(row<1 || row>this.dw_list.GetRowCount()) return 0; | 
 |  |  |             this.dw_list.InsertRow(row);  | 
 |  |  |             this.dw_list.SetItemString(row,"PartyID",GetGuid());					 | 
 |  |  |             this.dw_list.SetItemString(row,"ContactID",GetGuid());						 | 
 |  |  |             this.dw_list.SetItemString(row,"PAStatus","1"); | 
 |  |  |             this.dw_list.SetItemString(row,"PStatus","1"); | 
 |  |  |             this.dw_list.SetItemString(row,"PCStatus","1");					 | 
 |  |  |             this.dw_list.SetItemString(row,"Type","7");					 | 
 |  |  |          } | 
 |  |  | 			 | 
 |  |  |          int ViewUpdate(param pr,string updateItem,xaserverarg__   arg) | 
 |  |  |             { | 
 |  |  |                if(   updateItem=="del") | 
 |  |  |                { | 
 |  |  |                   int DelRow = this.dw_list.GetRow(); | 
 |  |  |                   this.dw_list.DeleteRow(DelRow); | 
 |  |  |       dw_list.SelectRow(0, false); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |                } | 
 |  |  |    int OnSave() | 
 |  |  |    { | 
 |  |  |       /*xstring no = dw_list.GetItemString(1,L"CarTermNo"); | 
 |  |  |       if(no==L""){ | 
 |  |  |          alert(L"请输入车队编码!"); | 
 |  |  |          return -1; | 
 |  |  |       } | 
 |  |  |       xstring SName = dw_list.GetItemString(1,L"Name"); | 
 |  |  |       if(SName==L""){ | 
 |  |  |          alert(L"请输入车队名称!"); | 
 |  |  |          return -1; | 
 |  |  |       } | 
 |  |  |       xstring ContacterName = dw_list.GetItemString(1,L"ContacterName"); | 
 |  |  |       if(ContacterName==L""){ | 
 |  |  |          alert(L"请输入联系人名称!"); | 
 |  |  |          return -1; | 
 |  |  |       }   */ | 
 |  |  |       xml x; | 
 |  |  |  | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  | 					 | 
 |  |  |          int OnDeleteRow() | 
 |  |  |          {	 | 
 |  |  |             int rows = this.dw_list.GetRowCount(); | 
 |  |  |             int row2 = this.dw_list.GetPrevSelectRow(rows); | 
 |  |  |             while(row2 > 0){ | 
 |  |  |                this.dw_list.DeleteRow(row2); | 
 |  |  |                row2 = this.dw_list.GetPrevSelectRow(row2 - 1); | 
 |  |  |             } | 
 |  |  |             this.dw_list.SelectRow(0, false);			 | 
 |  |  |          } | 
 |  |  | 			 | 
 |  |  |          int OnSave() | 
 |  |  |          {				 | 
 |  |  |             /*string no = this.dw_list.GetItemString(1,"CarTermNo"); | 
 |  |  |             if(no==""){ | 
 |  |  |                alert("请输入车队编码!"); | 
 |  |  |                return -1; | 
 |  |  |             }	 | 
 |  |  |             string SName = this.dw_list.GetItemString(1,"Name"); | 
 |  |  |             if(SName==""){ | 
 |  |  |                alert("请输入车队名称!"); | 
 |  |  |                return -1; | 
 |  |  |             } | 
 |  |  |             string ContacterName = this.dw_list.GetItemString(1,"ContacterName"); | 
 |  |  |             if(ContacterName==""){ | 
 |  |  |                alert("请输入联系人名称!"); | 
 |  |  |                return -1; | 
 |  |  |             }   */										 | 
 |  |  |             xml__ x=new xml__; | 
 |  |  |             x.setNativePointer(xml__::CreateInstance()); | 
 |  |  |             this.dw_list.AcceptText();					 | 
 |  |  |             this.dw_list.DwUpdateAllToEx(x.GetXmlDoc());  | 
 |  |  |             trace(x.GetXml()); | 
 |  |  |             xaserverarg__ arg=new xaserverarg__; | 
 |  |  |             arg.setNativePointer(arg.CreateInstance());	 | 
 |  |  |             arg.AddArg("content",x.GetXml());						 | 
 |  |  |             arg.AddArg("dbmap","CarTerm.dbmap");		 | 
 |  |  |             if (getUrl("/sale/data/CarTerm/entity/carterm/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("保存成功!");					 | 
 |  |  |                this.dw_list.ResetUpdateStatus();							 | 
 |  |  |             } | 
 |  |  |             this.dw_list.Redraw();			 | 
 |  |  |             return 0; | 
 |  |  |          }				 | 
 |  |  |          int OnCmdDispatch(string comdid) | 
 |  |  |       dw_list.AcceptText(); | 
 |  |  |       dw_list.DwUpdateAllToEx(x); | 
 |  |  |       trace(x.xml()); | 
 |  |  |       xaserverarg arg; | 
 |  |  |  | 
 |  |  |       arg.AddArg(L"content", x.xml()); | 
 |  |  |       arg.AddArg(L"dbmap", L"CarTerm.dbmap"); | 
 |  |  |       if (xurl::get(L"/sale/data/CarTerm/entity/carterm/save", arg.GetString(), x) != 1) | 
 |  |  |       { | 
 |  |  |          trace(L"error:" + (xstring)x.xml()); | 
 |  |  |          alert(L"保存失败!"); | 
 |  |  |          return 0; | 
 |  |  |       } | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  |          trace(x.xml()); | 
 |  |  |          if (x.selectSingleNode(L"error")) | 
 |  |  |          { | 
 |  |  |             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(); | 
 |  |  |             }				 | 
 |  |  |             alert(L"保存出错2!"); | 
 |  |  |             return 0; | 
 |  |  |          } | 
 |  |  |          alert(L"保存成功!"); | 
 |  |  |          dw_list.ResetUpdateStatus(); | 
 |  |  |       } | 
 |  |  |       dw_list.Redraw(); | 
 |  |  |       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; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |          int OnXCommand(ref TXCommandEvent evt,int p) | 
 |  |  |          { | 
 |  |  |             return OnCmdDispatch(evt.pStrID); | 
 |  |  |          } | 
 |  |  | 			 | 
 |  |  |          int OnAttachEvent() | 
 |  |  |          { | 
 |  |  |             AttachEvent("WM_XCOMMAND",OnXCommand);			 | 
 |  |  |             return 0; | 
 |  |  |          } | 
 |  |  | 			 | 
 |  |  |          int onload() | 
 |  |  |          {			 | 
 |  |  |             OnAttachEvent();								 | 
 |  |  |             list::onload(); | 
 |  |  |             this.dw_list.SetReadOnly(false);	 | 
 |  |  |             return -1; | 
 |  |  |          } | 
 |  |  | 					 | 
 |  |  |       ] | 
 |  |  |    ] | 
 |  |  | ] | 
 |  |  |    int OnXCommand(TEvent* evt, LPARAM param) | 
 |  |  |    { | 
 |  |  |       return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnAttachEvent() | 
 |  |  |    { | 
 |  |  |       AttachEvent(L"WM_XCOMMAND", (FEvent)&CartermList::OnXCommand); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int onload() | 
 |  |  |    { | 
 |  |  |       SetAgent(); | 
 |  |  |       OnAttachEvent(); | 
 |  |  |       listwin::onload(); | 
 |  |  |       dw_list.SetReadOnly(false); | 
 |  |  |       return -1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  | }; |