|  |  | 
 |  |  | use "win.vl" | 
 |  |  | use "treeview.vm" | 
 |  |  | use "dev:vm[xdwgrid.vm]" | 
 |  |  | use "dev:vm[xdwtable.vm]" | 
 |  |  | use "pref.vl" | 
 |  |  | use "dev:vm[xml.vm]" | 
 |  |  | use "dev:vm[xaserverarg.vm]" | 
 |  |  | use "dev:vm[xaserver.vm]" | 
 |  |  | use "dev:vm[xutil.vm]" | 
 |  |  | use "dev:vm[pagecontrol.vm]" | 
 |  |  | use "maint.vl" | 
 |  |  | use "publiccode.vl" | 
 |  |  | #include <wobject/xstring.hpp> | 
 |  |  | #include <xcontrol/xtreeview.hpp> | 
 |  |  | #include <xcontrol/xdwgrid.hpp> | 
 |  |  | #include <wobject/xdouble.hpp> | 
 |  |  | #include <xcontrol/xlayersheet.hpp> | 
 |  |  | #include <xcontrol/xdwpages.hpp> | 
 |  |  |  | 
 |  |  | unit vbusiness.xpage | 
 |  |  | [ | 
 |  |  |    CompanyMaint is extend maint; | 
 |  |  |    about CompanyMaint | 
 |  |  |       [ | 
 |  |  |          control: | 
 |  |  | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" | 
 |  |  | #include "viewobject/view.base.hpp" | 
 |  |  |  | 
 |  |  |       method: | 
 |  |  |          [ | 
 |  |  |             pagecontrol__ m_layer; | 
 |  |  |             xdwtable__   dw_detail; | 
 |  |  |             xdwtable__   dw_bank; | 
 |  |  |             string      m_operate; | 
 |  |  |             string      m_sguid; | 
 |  |  | using xml = KXMLDOMDocument; | 
 |  |  | class __declspec(dllexport) CompanyMaint : public xframe | 
 |  |  | { | 
 |  |  | public: | 
 |  |  |    xlayersheet m_layer; | 
 |  |  |    xdwtable   dw_detail; | 
 |  |  |    xdwtable   dw_bank; | 
 |  |  |    xstring      m_operate; | 
 |  |  |    xstring      m_sguid; | 
 |  |  |  | 
 |  |  |             xnode__   m_agentNode;   //Agent Condition | 
 |  |  |             string   m_agentCond;   //Agent Node | 
 |  |  |             int SetAgent() | 
 |  |  |    xnode   m_agentNode;   //Agent Condition | 
 |  |  |    xstring   m_agentCond;   //Agent Node | 
 |  |  | public: | 
 |  |  |    CompanyMaint(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} | 
 |  |  | public: | 
 |  |  |    static CompanyMaint* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |    { | 
 |  |  |       CompanyMaint* pWin = new CompanyMaint(implPtr, (HWND)hWnd); | 
 |  |  |       return pWin; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int SetAgent() | 
 |  |  |    { | 
 |  |  |       xstring xfNodeAgentArea = L"agentarea"; | 
 |  |  |       xnode anode = GetAgentNode(xfNodeAgentArea); | 
 |  |  |       if (m_agentNode) | 
 |  |  |       { | 
 |  |  |          SetAgentNode(anode, m_agentNode); | 
 |  |  |       } | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  |          KXMLDOMElement xframeElement = GetElement(); | 
 |  |  |          KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[1]/*"); | 
 |  |  |          if (agent) | 
 |  |  |          { | 
 |  |  |             xstring s = agent.xml(); | 
 |  |  |             m_agentNode = SetAgentNode(anode, s); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    //焦点激活处理函数 | 
 |  |  |    int OnSetFocus(TEvent* evt, LPARAM param) | 
 |  |  |    { | 
 |  |  |       SetAgent(); | 
 |  |  |  | 
 |  |  |       //重置工具条 | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    int OnPreSave() | 
 |  |  |    { | 
 |  |  |       xdwtable dw = new xdwtable; | 
 |  |  |       dw.setNativePointer(dw_detail.FindDwTable(L"CompanyInfo")); | 
 |  |  |       xstring sPartyNo = dw.GetItemString(1, L"PartyNo"); | 
 |  |  |       if (sPartyNo == L"") | 
 |  |  |       { | 
 |  |  |          xstring sGetNo = publiccode::GetIdentityNo(L""); | 
 |  |  |          dw.SetItemString(1, L"PartyNo", sGetNo); | 
 |  |  |          //alert(L"公司编号为空!"); | 
 |  |  |          //return -1; | 
 |  |  |       } | 
 |  |  |       xstring sPartyName = dw.GetItemString(1, L"Name"); | 
 |  |  |       if (sPartyName == L"") | 
 |  |  |       { | 
 |  |  |          alert(L"公司名称为空!"); | 
 |  |  |          return -1; | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       xstring suserid = publiccode::GetUser().id; | 
 |  |  |       xstring sdate = publiccode::GetCurrentDate(); | 
 |  |  |       dw.SetItemString(1, L"ModifierID", suserid); | 
 |  |  |       dw.SetItemString(1, L"ModifyDate", sdate); | 
 |  |  |  | 
 |  |  |       dw.setNativePointer(dw_bank.FindDwTable(L"item", 0)); | 
 |  |  |       if (dw) | 
 |  |  |       { | 
 |  |  |          xstring sno; | 
 |  |  |          xstring sname; | 
 |  |  |          xstring status; | 
 |  |  |  | 
 |  |  |          int i; | 
 |  |  |          int row = dw.GetRowCount(); | 
 |  |  |          for (i = 1; i <= row; i++) | 
 |  |  |          { | 
 |  |  |             status = dw.GetItemString(i, L"Status") + L""; | 
 |  |  |             if (status == L"") | 
 |  |  |             { | 
 |  |  |                string xfNodeAgentArea = "agentarea"; | 
 |  |  |                xnode__ anode = new xnode__; | 
 |  |  |                anode.setNativePointer(GetAgentNode(xfNodeAgentArea)); | 
 |  |  |                var xframeElement = GetElement(); | 
 |  |  |                var agent = xframeElement.selectSingleNode("agent/" + xfNodeAgentArea + "[1]/*"); | 
 |  |  |                if (agent) | 
 |  |  |                dw.SetItemString(i, L"Status", L"Y"); | 
 |  |  |                //alert(L"第"+i.toString()+L"行状态为空"); | 
 |  |  |                //return -1; | 
 |  |  |             } | 
 |  |  |             /* | 
 |  |  |             sno=dw.GetItemString(i,L"BankAccountNo",0)+L""; | 
 |  |  |             sname=dw.GetItemString(i,L"BankName",0)+L""; | 
 |  |  |             status=dw.GetItemString(i,L"Status",0)+L""; | 
 |  |  |             if (sno==L"" || sno==nil) | 
 |  |  |             { | 
 |  |  |                if(sname !=L"" && sname != nil) | 
 |  |  |                { | 
 |  |  |                   string s = agent.xml; | 
 |  |  |                   SetAgentNodeContent(anode, s); | 
 |  |  |                   alert(L"第"+i.toString()+L"行银行编号为空"); | 
 |  |  |                   return -1; | 
 |  |  |                } | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //焦点激活处理函数 | 
 |  |  |             int OnSetFocus(ref TEvent evt, int param) | 
 |  |  |             if (sname==L"" || sname==nil) | 
 |  |  |             { | 
 |  |  |                SetAgent(); | 
 |  |  |  | 
 |  |  |                //重置工具条 | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             int OnPreSave() | 
 |  |  |             { | 
 |  |  |                xdwtable__ dw = new xdwtable__; | 
 |  |  |                dw.setNativePointer(dw_detail.FindDwTable("CompanyInfo", 0)); | 
 |  |  |                string sPartyNo = dw.GetItemString(1, "PartyNo", 0); | 
 |  |  |                if (sPartyNo == "" || sPartyNo == nil) | 
 |  |  |                if(sno !=L"" && sno != nil) | 
 |  |  |                { | 
 |  |  |                   string sGetNo = publiccode::GetIdentityNo(""); | 
 |  |  |                   dw.SetItemString(1, "PartyNo", sGetNo); | 
 |  |  |                   //alert("公司编号为空!"); | 
 |  |  |                   alert(L"第"+i.toString()+L"行银行名称为空"); | 
 |  |  |                   return -1; | 
 |  |  |                } | 
 |  |  |             } | 
 |  |  |             else | 
 |  |  |             { | 
 |  |  |                if (status==L"" || status==nil) | 
 |  |  |                { | 
 |  |  |                   dw.SetItemString(i,L"Status",L"Y"); | 
 |  |  |                   //alert(L"第"+i.toString()+L"行状态为空"); | 
 |  |  |                   //return -1; | 
 |  |  |                } | 
 |  |  |                string sPartyName = dw.GetItemString(1, "Name", 0); | 
 |  |  |                if (sPartyName == "" || sPartyName == nil) | 
 |  |  |                { | 
 |  |  |                   alert("公司名称为空!"); | 
 |  |  |                   return -1; | 
 |  |  |                } | 
 |  |  |  | 
 |  |  |                string suserid = publiccode::GetUserInfo().id; | 
 |  |  |                string sdate = publiccode::GetCurDate(); | 
 |  |  |                dw.SetItemString(1, "ModifierID", suserid); | 
 |  |  |                dw.SetItemString(1, "ModifyDate", sdate); | 
 |  |  |  | 
 |  |  |                dw.setNativePointer(dw_bank.FindDwTable("item", 0)); | 
 |  |  |                if (dw) | 
 |  |  |                { | 
 |  |  |                   string sno; | 
 |  |  |                   string sname, | 
 |  |  |                      string status; | 
 |  |  |                   int i; | 
 |  |  |                   int row = dw.GetRowCount(); | 
 |  |  |                   for (i = 1; i <= row; i++) | 
 |  |  |                   { | 
 |  |  |                      status = dw.GetItemString(i, "Status", 0) + ""; | 
 |  |  |                      if (status == "" || status == nil) | 
 |  |  |                      { | 
 |  |  |                         dw.SetItemString(i, "Status", "Y"); | 
 |  |  |                         //alert("第"+i.toString()+"行状态为空"); | 
 |  |  |                         //return -1; | 
 |  |  |                      } | 
 |  |  |                      /* | 
 |  |  |                      sno=dw.GetItemString(i,"BankAccountNo",0)+""; | 
 |  |  |                      sname=dw.GetItemString(i,"BankName",0)+""; | 
 |  |  |                      status=dw.GetItemString(i,"Status",0)+""; | 
 |  |  |                      if (sno=="" || sno==nil) | 
 |  |  |                      { | 
 |  |  |                         if(sname !="" && sname != nil) | 
 |  |  |                         { | 
 |  |  |                            alert("第"+i.toString()+"行银行编号为空"); | 
 |  |  |                            return -1; | 
 |  |  |                         } | 
 |  |  |                      } | 
 |  |  |  | 
 |  |  |                      if (sname=="" || sname==nil) | 
 |  |  |                      { | 
 |  |  |                         if(sno !="" && sno != nil) | 
 |  |  |                         { | 
 |  |  |                            alert("第"+i.toString()+"行银行名称为空"); | 
 |  |  |                            return -1; | 
 |  |  |                         } | 
 |  |  |                      } | 
 |  |  |                      else | 
 |  |  |                      { | 
 |  |  |                         if (status=="" || status==nil) | 
 |  |  |                         { | 
 |  |  |                            dw.SetItemString(i,"Status","Y"); | 
 |  |  |                            //alert("第"+i.toString()+"行状态为空"); | 
 |  |  |                            //return -1; | 
 |  |  |                         } | 
 |  |  |                      } | 
 |  |  |                      */ | 
 |  |  |                   } | 
 |  |  |                } | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |             */ | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |             int OnSave() | 
 |  |  |             { | 
 |  |  |                dw_detail.AcceptText(); | 
 |  |  |                dw_bank.AcceptText(); | 
 |  |  |                int rec; | 
 |  |  |                rec = OnPreSave(); | 
 |  |  |                if (rec == -1) | 
 |  |  |                   return -1; | 
 |  |  |    int OnSave() | 
 |  |  |    { | 
 |  |  |       dw_detail.AcceptText(); | 
 |  |  |       dw_bank.AcceptText(); | 
 |  |  |       int rec; | 
 |  |  |       rec = OnPreSave(); | 
 |  |  |       if (rec == -1) | 
 |  |  |          return -1; | 
 |  |  |  | 
 |  |  |                int hIcon = xutil__::SetCursorWait(); | 
 |  |  |       HCURSOR hIcon = xutil::SetCursorWait(); | 
 |  |  | 	 | 
 |  |  |       xstring val, val2; | 
 |  |  |       xml x; | 
 |  |  |  | 
 |  |  |                string val, val2; | 
 |  |  |                xml__ x = new xml__; | 
 |  |  |                x.setNativePointer(x.CreateInstance()); | 
 |  |  |                var xdoc = x.GetXmlDoc(); | 
 |  |  |                dw_detail.DwUpdateAllTo(xdoc); | 
 |  |  |                //val = xdoc.xml ; | 
 |  |  |                dw_bank.DwUpdateAllTo(xdoc); | 
 |  |  |                val = xdoc.xml; | 
 |  |  |                trace(val); | 
 |  |  |                xaserverarg__ args = new xaserverarg__; | 
 |  |  |                args.setNativePointer(args.CreateInstance()); | 
 |  |  |                args.AddArg("content", val); | 
 |  |  |                args.AddArg("dbmap", "CompanyInfo.dbmap"); | 
 |  |  |                //trace(m_EntityValueEx); | 
 |  |  |                xml__ x1 = new xml__; | 
 |  |  |                x1.setNativePointer(x1.CreateInstance()); | 
 |  |  |                if (url::post("OrganizationStruct/update.companyinfoex", args.GetString(), x1) != 1) | 
 |  |  |                   //if (xaserver__::ExecXAction("","[update.CompanyInfoEx.xa]",args.GetString(),x1) !=1) | 
 |  |  |                { | 
 |  |  |                   string error = x1.GetXmlDoc().text; | 
 |  |  |                   trace(error); | 
 |  |  |                } | 
 |  |  |                else | 
 |  |  |                { | 
 |  |  |                   trace(x1.GetXml()); | 
 |  |  |                   if (x1.GetXmlDoc().selectSingleNode("error")) | 
 |  |  |                   { | 
 |  |  |                      alert("保存出错2!"); | 
 |  |  |                      return 0; | 
 |  |  |                   } | 
 |  |  |                   win__::MessageBox(GetHWND(), "保存成功!", "提示", 0); | 
 |  |  |                } | 
 |  |  |                xutil__::RestoreCursor(hIcon); | 
 |  |  |                dw_detail.ResetUpdateStatus(); | 
 |  |  |                dw_bank.ResetUpdateStatus(); | 
 |  |  |                var xdoc2 = x.GetXmlDoc(); | 
 |  |  |                dw_detail.DwUpdateAllTo(xdoc2); | 
 |  |  |                val = xdoc.xml; | 
 |  |  |                trace(val); | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |       auto xdoc = x; | 
 |  |  |       dw_detail.DwUpdateAllTo(xdoc); | 
 |  |  |       //val = xdoc.xml ; | 
 |  |  |       dw_bank.DwUpdateAllTo(xdoc); | 
 |  |  |       val = xdoc.xml(); | 
 |  |  |       trace(val); | 
 |  |  |       xaserverarg args; | 
 |  |  |       args.AddArg(L"content", val); | 
 |  |  |       args.AddArg(L"dbmap", L"CompanyInfo.dbmap"); | 
 |  |  |       //trace(m_EntityValueEx); | 
 |  |  |       xml x1; | 
 |  |  | 		 | 
 |  |  |       if (xurl::post(L"OrganizationStruct/update.companyinfoex", args.GetString(), x1) != 1) | 
 |  |  |          //if (xaserver::ExecXAction(L"",L"[update.CompanyInfoEx.xa]",args.GetString(),x1) !=1) | 
 |  |  |       { | 
 |  |  |          xstring error = x1.text(); | 
 |  |  |          trace(error); | 
 |  |  |       } | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  |          trace(x1.xml()); | 
 |  |  |          if (x1.selectSingleNode(L"error")) | 
 |  |  |          { | 
 |  |  |             alert(L"保存出错2!"); | 
 |  |  |             return 0; | 
 |  |  |          } | 
 |  |  |          MessageBox(GetHWND(), L"保存成功!", L"提示", 0); | 
 |  |  |       } | 
 |  |  |       xutil::RestoreCursor(hIcon); | 
 |  |  |       dw_detail.ResetUpdateStatus(); | 
 |  |  |       dw_bank.ResetUpdateStatus(); | 
 |  |  |       dw_detail.DwUpdateAllTo(x); | 
 |  |  |       val = x.xml(); | 
 |  |  |       trace(val); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |             int OnItemChanged(ref TNotifyEvent evt, int p) | 
 |  |  |             { | 
 |  |  |                ref DWNMHDR dwhdr = evt.pnmh; | 
 |  |  |                int row = dwhdr.row; | 
 |  |  |                string col = dwhdr.colname; | 
 |  |  |                string data = dwhdr.data; | 
 |  |  |                if (col == "Name") | 
 |  |  |                { | 
 |  |  |                   xml__ x = new xml__; | 
 |  |  |                   x.setNativePointer(x.CreateInstance()); | 
 |  |  |                   xaserverarg__ arg = new xaserverarg__; | 
 |  |  |                   arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |                   arg.AddArg("Name", data); | 
 |  |  |                } | 
 |  |  |    int OnItemChanged(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       DWNMHDR& dwhdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |       int row = dwhdr.row; | 
 |  |  |       xstring col = dwhdr.colname; | 
 |  |  |       xstring data = dwhdr.data; | 
 |  |  |       if (col == L"Name") | 
 |  |  |       { | 
 |  |  |          xml x; | 
 |  |  |  | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |          xaserverarg arg; | 
 |  |  |  | 
 |  |  |             int OnChildContent(ref TNotifyEvent evt, int p) | 
 |  |  |             { | 
 |  |  |                ref DWNMHDR dwhdr = evt.pnmh; | 
 |  |  |                string col = dwhdr.colname; | 
 |  |  |                if (col != "") { | 
 |  |  |                   xml__ x = new xml__; | 
 |  |  |                   x.setNativePointer(x.CreateInstance()); | 
 |  |  |                   xaserverarg__ arg = new xaserverarg__; | 
 |  |  |                   arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |                   string query; | 
 |  |  |                   query = "[IResourceMSSql.xq]"; | 
 |  |  |                   if (col == "TradeType") { | 
 |  |  |                      arg.AddArg("ResourceType", "TradeType");//贸易方式	 | 
 |  |  |                   } | 
 |  |  |                   if (xaserver__::ExecXQuery(GetServerUrl(), query, arg.GetString(), x) == 1) | 
 |  |  |                      dwhdr.data = x.GetXml(); | 
 |  |  |                   //trace(x.GetXml()); | 
 |  |  |                } | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |          arg.AddArg(L"Name", data); | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |             int OnAddRow() | 
 |  |  |             { | 
 |  |  |                int h = m_layer.GetSheetIndex(); | 
 |  |  |                if (h == 1) | 
 |  |  |                { | 
 |  |  |                   xdwtable__ dw = new xdwtable__; | 
 |  |  |                   dw.setNativePointer(dw_bank.GetCurTable()); | 
 |  |  |                   string dw_n = dw.GetDwName(); | 
 |  |  |                   if (dw_n == "item") | 
 |  |  |                   { | 
 |  |  |                      int row = dw.InsertRow(0); | 
 |  |  |                      dw.SetItemString(row, "Status", "Y"); | 
 |  |  |                   } | 
 |  |  |                } | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |             int OnInsertRow() | 
 |  |  |             { | 
 |  |  |                int h = m_layer.GetSheetIndex(); | 
 |  |  |                if (h == 1) | 
 |  |  |                { | 
 |  |  |                   xdwtable__ dw = new xdwtable__; | 
 |  |  |                   dw.setNativePointer(dw_bank.GetCurTable()); | 
 |  |  |                   string dw_n = dw.GetDwName(); | 
 |  |  |                   if (dw_n == "item") | 
 |  |  |                   { | 
 |  |  |                      int row = dw.GetRow(); | 
 |  |  |                      int crow = dw.InsertRow(row); | 
 |  |  |                      dw.SetItemString(crow, "Status", "Y"); | 
 |  |  |                   } | 
 |  |  |                } | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |    int OnChildContent(TEvent* evt, LPARAM p) | 
 |  |  |    { | 
 |  |  |       DWNMHDR& dwhdr = *(DWNMHDR*)evt->notify.pnmh; | 
 |  |  |       xstring col = dwhdr.colname; | 
 |  |  |       if (col != L"") { | 
 |  |  |          xml x; | 
 |  |  |          xaserverarg arg; | 
 |  |  |          xstring query; | 
 |  |  |          query = L"[IResourceMSSql.xq]"; | 
 |  |  |          if (col == L"TradeType") { | 
 |  |  |             arg.AddArg(L"ResourceType", L"TradeType");//贸易方式	 | 
 |  |  |          } | 
 |  |  |          if (xaserver::ExecXQuery(GetServerUrl(), query, arg.GetString(), x) == 1) | 
 |  |  |             dwhdr.data = x.xml(); | 
 |  |  |          //trace(x.GetXml()); | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |             int OnDeleteRow() | 
 |  |  |             { | 
 |  |  |                int h = m_layer.GetSheetIndex(); | 
 |  |  |                if (h == 1) | 
 |  |  |                { | 
 |  |  |                   xdwtable__ dw = new xdwtable__; | 
 |  |  |                   dw.setNativePointer(dw_bank.GetCurTable()); | 
 |  |  |                   string dw_n = dw.GetDwName(); | 
 |  |  |                   if (dw_n == "item") | 
 |  |  |                   { | 
 |  |  |                      int row = dw.GetRow(); | 
 |  |  |                      dw.DeleteRow(row); | 
 |  |  |                   } | 
 |  |  |                } | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |    int OnAddRow() | 
 |  |  |    { | 
 |  |  |       int h = m_layer.GetSheetIndex(); | 
 |  |  |       if (h == 1) | 
 |  |  |       { | 
 |  |  |          xdwtable dw = new xdwtable; | 
 |  |  |          dw.setNativePointer(dw_bank.GetCurTable()); | 
 |  |  |          xstring dw_n = dw.GetDwName(); | 
 |  |  |          if (dw_n == L"item") | 
 |  |  |          { | 
 |  |  |             int row = dw.InsertRow(0); | 
 |  |  |             dw.SetItemString(row, L"Status", L"Y"); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |             //命令发布函数 | 
 |  |  |             int OnCmdDispatch(string comdid) | 
 |  |  |             { | 
 |  |  |                if (comdid == "Save")  OnSave(); | 
 |  |  |                else if (comdid == "AddRow") OnAddRow(); | 
 |  |  |                else if (comdid == "InsertRow") OnInsertRow(); | 
 |  |  |                else if (comdid == "DeleteRow") OnDeleteRow(); | 
 |  |  |                return 0; | 
 |  |  |             } | 
 |  |  |    int OnInsertRow() | 
 |  |  |    { | 
 |  |  |       int h = m_layer.GetSheetIndex(); | 
 |  |  |       if (h == 1) | 
 |  |  |       { | 
 |  |  |          xdwtable dw = new xdwtable; | 
 |  |  |          dw.setNativePointer(dw_bank.GetCurTable()); | 
 |  |  |          xstring dw_n = dw.GetDwName(); | 
 |  |  |          if (dw_n == L"item") | 
 |  |  |          { | 
 |  |  |             int row = dw.GetRow(); | 
 |  |  |             int crow = dw.InsertRow(row); | 
 |  |  |             dw.SetItemString(crow, L"Status", L"Y"); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |             //命令处理事件 | 
 |  |  |             int OnXCommand(ref TXCommandEvent evt, int param) | 
 |  |  |             { | 
 |  |  |                return OnCmdDispatch(evt.pStrID); | 
 |  |  |             } | 
 |  |  |    int OnDeleteRow() | 
 |  |  |    { | 
 |  |  |       int h = m_layer.GetSheetIndex(); | 
 |  |  |       if (h == 1) | 
 |  |  |       { | 
 |  |  |          xdwtable dw = new xdwtable; | 
 |  |  |          dw.setNativePointer(dw_bank.GetCurTable()); | 
 |  |  |          xstring dw_n = dw.GetDwName(); | 
 |  |  |          if (dw_n == L"item") | 
 |  |  |          { | 
 |  |  |             int row = dw.GetRow(); | 
 |  |  |             dw.DeleteRow(row); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |             int OnAttachEvent() | 
 |  |  |             { | 
 |  |  |                //绑定工具条点击事件 | 
 |  |  |                AttachEvent("WM_XCOMMAND", OnXCommand); | 
 |  |  |                //获取焦点事件,用于重置工具条 | 
 |  |  |                AttachEvent("WM_SETFOCUS", OnSetFocus); | 
 |  |  |                //下拉框  提供内容 | 
 |  |  |                AttachEvent("dw_detail", "DWV_CHILDCONTENT", OnChildContent); | 
 |  |  |                AttachEvent("dw_detail", "DWV_ITEMCHANGED", OnItemChanged); | 
 |  |  |             } | 
 |  |  |    //命令发布函数 | 
 |  |  |    int OnCmdDispatch(xstring comdid) | 
 |  |  |    { | 
 |  |  |       if (comdid == L"Save")  OnSave(); | 
 |  |  |       else if (comdid == L"AddRow") OnAddRow(); | 
 |  |  |       else if (comdid == L"InsertRow") OnInsertRow(); | 
 |  |  |       else if (comdid == L"DeleteRow") OnDeleteRow(); | 
 |  |  |       return 0; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |             int  OnRetrieve() | 
 |  |  |             { | 
 |  |  |                xml__ x = new xml__; | 
 |  |  |                x.setNativePointer(x.CreateInstance()); | 
 |  |  |                xaserverarg__ arg = new xaserverarg__; | 
 |  |  |                arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |                arg.AddArg("guid", m_sguid); | 
 |  |  |                //trace(m_sguid); | 
 |  |  |                //if (url::get("OrganizationStruct/detail.CompanyInfo",arg.GetString(),x) != 1) | 
 |  |  |                if (url::post("OrganizationStruct/detail.CompanyInfo", arg.GetString(), x) != 1) | 
 |  |  |                { | 
 |  |  |                   trace(x.GetXmlDoc().text); | 
 |  |  |                   return -1; | 
 |  |  |                } | 
 |  |  |                else | 
 |  |  |                { | 
 |  |  |                   dw_detail.Retrieve(x); | 
 |  |  |                   dw_detail.Redraw(); | 
 |  |  |                   dw_bank.Retrieve(x); | 
 |  |  |                   dw_bank.Redraw(); | 
 |  |  |                   //trace(x.GetXml()); | 
 |  |  |                } | 
 |  |  |    //命令处理事件 | 
 |  |  |    int OnXCommand(TEvent* evt, LPARAM param) | 
 |  |  |    { | 
 |  |  |       return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |    int OnAttachEvent() | 
 |  |  |    { | 
 |  |  |       //绑定工具条点击事件 | 
 |  |  |       AttachEvent(L"WM_XCOMMAND", (FEvent)&CompanyMaint::OnXCommand); | 
 |  |  |       //获取焦点事件,用于重置工具条 | 
 |  |  |       AttachEvent(L"WM_SETFOCUS", (FEvent)&CompanyMaint::OnSetFocus); | 
 |  |  |       //下拉框  提供内容 | 
 |  |  |       AttachEvent(L"dw_detail", L"DWV_CHILDCONTENT", (FEvent)&CompanyMaint::OnChildContent); | 
 |  |  |       AttachEvent(L"dw_detail", L"DWV_ITEMCHANGED", (FEvent)&CompanyMaint::OnItemChanged); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |             int OnInitial() | 
 |  |  |             { | 
 |  |  |                SetAgent(); | 
 |  |  |    int  OnRetrieve() | 
 |  |  |    { | 
 |  |  |       xml x; | 
 |  |  |       xaserverarg arg; | 
 |  |  |       arg.AddArg(L"guid", m_sguid); | 
 |  |  |       //trace(m_sguid); | 
 |  |  |       //if (xurl::get(L"OrganizationStruct/detail.CompanyInfo",arg.GetString(),x) != 1) | 
 |  |  |       if (xurl::post(L"OrganizationStruct/detail.CompanyInfo", arg.GetString(), x) != 1) | 
 |  |  |       { | 
 |  |  |          trace(x.text()); | 
 |  |  |          return -1; | 
 |  |  |       } | 
 |  |  |       else | 
 |  |  |       { | 
 |  |  |          dw_detail.Retrieve(x); | 
 |  |  |          dw_detail.Redraw(); | 
 |  |  |          dw_bank.Retrieve(x); | 
 |  |  |          dw_bank.Redraw(); | 
 |  |  |          //trace(x.GetXml()); | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |                xaserverarg__ arg = new xaserverarg__; | 
 |  |  |                arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |                arg = this.GetParam(); | 
 |  |  |                if (arg) | 
 |  |  |                { | 
 |  |  |                   m_operate = arg.GetArgString("operate"); | 
 |  |  |                   m_sguid = arg.GetArgString("guid"); | 
 |  |  |                } | 
 |  |  |                /*if ( m_sguid == "" || m_sguid == nil) | 
 |  |  |                { | 
 |  |  |                   m_sguid = win__::GetGuid(); | 
 |  |  |                   trace(m_sguid); | 
 |  |  |                }*/ | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |                OnAttachEvent(); | 
 |  |  |    int OnInitial() | 
 |  |  |    { | 
 |  |  |       SetArg(); | 
 |  |  |       SetAgent(); | 
 |  |  |       xaserverarg arg; | 
 |  |  |       arg = GetArg(); | 
 |  |  |       if (arg) | 
 |  |  |       { | 
 |  |  |          m_operate = arg.GetArgString(L"operate"); | 
 |  |  |          m_sguid = arg.GetArgString(L"guid"); | 
 |  |  |       } | 
 |  |  |       /*if ( m_sguid == L"" || m_sguid == nil) | 
 |  |  |       { | 
 |  |  |          m_sguid = win::GetGuid(); | 
 |  |  |          trace(m_sguid); | 
 |  |  |       }*/ | 
 |  |  |  | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |       OnAttachEvent(); | 
 |  |  |  | 
 |  |  |             int onload() | 
 |  |  |             { | 
 |  |  |                m_layer = new pagecontrol__; | 
 |  |  |                m_layer.setNativePointer(this.GetControl("cTab")); | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |                dw_detail = new xdwtable__; | 
 |  |  |                dw_detail.setNativePointer(this.GetControl("dw_detail")); | 
 |  |  |                dw_detail.openUrl("组织架构.vface/template/company/detail"); | 
 |  |  |                dw_detail.SetColHeaderHeight(0); | 
 |  |  |                dw_detail.SetRowSelectorWidth(0); | 
 |  |  |                dw_bank = new xdwtable__; | 
 |  |  |                dw_bank.setNativePointer(this.GetControl("dw_bank")); | 
 |  |  |                dw_bank.openUrl("组织架构.vface/template/company/bank"); | 
 |  |  |    int onload() | 
 |  |  |    { | 
 |  |  |       m_layer = GetControl(L"cTab"); | 
 |  |  |  | 
 |  |  |                OnInitial(); | 
 |  |  |                if (m_sguid != "") { | 
 |  |  |                   OnRetrieve(); | 
 |  |  |                } | 
 |  |  |                else { | 
 |  |  |                   xdwtable__ dw = new xdwtable__; | 
 |  |  |                   dw.setNativePointer(dw_detail.FindDwTable("CompanyInfo", 0)); | 
 |  |  |                   dw.SetItemString(1, "Status", "1"); | 
 |  |  |                   dw.SetItemString(1, "InternalFlag", "Y"); | 
 |  |  |                   dw.SetItemString(1, "Type", "0"); | 
 |  |  |                   string suserid = publiccode::GetUserInfo().id; | 
 |  |  |                   /*string susername = publiccode::GetUserInfo().name; | 
 |  |  |                   string sdate = publiccode::GetCurDate(); | 
 |  |  |                   dw.SetItemString(1,"CreatorID",suserid); | 
 |  |  |                   dw.SetItemDisplayString(1,"CreatorID",susername); | 
 |  |  |                   dw.SetItemString(1,"CreateDate",sdate);*/ | 
 |  |  |       dw_detail = GetControl(L"dw_detail"); | 
 |  |  |       dw_detail.openUrl(L"组织架构.vface/template/company/detail"); | 
 |  |  |       dw_detail.SetColHeaderHeight(0); | 
 |  |  |       dw_detail.SetRowSelectorWidth(0); | 
 |  |  |       dw_bank = GetControl(L"dw_bank"); | 
 |  |  |       dw_bank.openUrl(L"组织架构.vface/template/company/bank"); | 
 |  |  |  | 
 |  |  |                   dw.setNativePointer(dw_detail.FindDwTable("address", 0)); | 
 |  |  |                   dw.SetItemString(1, "IdentifyAddressFlag", "Y"); | 
 |  |  |                   dw.SetItemString(1, "Status", "1"); | 
 |  |  |                   dw.setNativePointer(dw_detail.FindDwTable("Regist", 0)); | 
 |  |  |                   dw.SetItemString(1, "IdentifyAddressFlag", "N"); | 
 |  |  |                   dw.SetItemString(1, "Status", "1"); | 
 |  |  |       OnInitial(); | 
 |  |  |       if (m_sguid != L"") { | 
 |  |  |          OnRetrieve(); | 
 |  |  |       } | 
 |  |  |       else { | 
 |  |  |          xdwtable dw = dw_detail.FindDwTable(L"CompanyInfo", 0); | 
 |  |  |          dw.SetItemString(1, L"Status", L"1"); | 
 |  |  |          dw.SetItemString(1, L"InternalFlag", L"Y"); | 
 |  |  |          dw.SetItemString(1, L"Type", L"0"); | 
 |  |  |          xstring suserid = publiccode::GetUser().id; | 
 |  |  |          /*xstring susername = publiccode::GetUserInfo().name; | 
 |  |  |          xstring sdate = publiccode::GetCurDate(); | 
 |  |  |          dw.SetItemString(1,L"CreatorID",suserid); | 
 |  |  |          dw.SetItemDisplayString(1,L"CreatorID",susername); | 
 |  |  |          dw.SetItemString(1,L"CreateDate",sdate);*/ | 
 |  |  |  | 
 |  |  |                   dw.setNativePointer(dw_bank.FindDwTable("item", 0)); | 
 |  |  |                   if (dw) { | 
 |  |  |                      //msxml::IXMLDOMElement ele = dw.GetElement(); | 
 |  |  |                      //trace(ele.xml); | 
 |  |  |                      //dw.SetItemString(1,"Status","Y"); | 
 |  |  |                   } | 
 |  |  |                } | 
 |  |  |                return 1; | 
 |  |  |             } | 
 |  |  |          dw = dw_detail.FindDwTable(L"address", 0); | 
 |  |  |          dw.SetItemString(1, L"IdentifyAddressFlag", L"Y"); | 
 |  |  |          dw.SetItemString(1, L"Status", L"1"); | 
 |  |  |          dw = dw_detail.FindDwTable(L"Regist", 0); | 
 |  |  |          dw.SetItemString(1, L"IdentifyAddressFlag", L"N"); | 
 |  |  |          dw.SetItemString(1, L"Status", L"1"); | 
 |  |  |  | 
 |  |  |          ] | 
 |  |  |          dw = dw_bank.FindDwTable(L"item", 0); | 
 |  |  |          if (dw) { | 
 |  |  |             //KXMLDOMElement ele = dw.GetElement(); | 
 |  |  |             //trace(ele.xml); | 
 |  |  |             //dw.SetItemString(1,L"Status",L"Y"); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return 1; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |       ] | 
 |  |  | ] | 
 |  |  | }; |