/// <summary> /// /// </summary> /// <returns></returns> internal List<Business.Agent> GetAllAgent() { List<Business.Agent> Result = new List<Business.Agent>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.AgentTableAdapter adap = new DSTableAdapters.AgentTableAdapter(); DS.AgentDataTable tbAgent = new DS.AgentDataTable(); try { conn.Open(); adap.Connection = conn; tbAgent = adap.GetData(); if (tbAgent != null) { int count = tbAgent.Count; for (int i = 0; i < count; i++) { Business.Agent newAgent = new Business.Agent(); newAgent.AgentID = tbAgent[i].AgentID; newAgent.AgentGroupID = tbAgent[i].AgentGroupID; newAgent.Name = tbAgent[i].Name; newAgent.InvestorID = tbAgent[i].InvestorID; newAgent.Comment = tbAgent[i].Comment; newAgent.IsDisable = tbAgent[i].Isdiable; newAgent.IsOnline = false; newAgent.Code = tbAgent[i].Code; newAgent.IsIpFilter = tbAgent[i].IsIpFilter; newAgent.IpForm = tbAgent[i].IpForm; newAgent.IpTo = tbAgent[i].IpTo; newAgent.GroupCondition = tbAgent[i].GroupCondition; Result.Add(newAgent); } } } catch (Exception ex) { Result = null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="AgentID"></param> /// <returns></returns> internal List<Business.IAgentGroup> GetIAgentGroupByAgentID(int AgentID) { List<Business.IAgentGroup> Result = new List<Business.IAgentGroup>(); Business.Agent Agent = new Business.Agent(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.IAgentGroupTableAdapter adapIAgentGroup = new DSTableAdapters.IAgentGroupTableAdapter(); DS.IAgentGroupDataTable tbIAgentGroup = new DS.IAgentGroupDataTable(); DSTableAdapters.AgentTableAdapter adapAgent = new DSTableAdapters.AgentTableAdapter(); DS.AgentDataTable tbAgent = new DS.AgentDataTable(); try { conn.Open(); adapIAgentGroup.Connection = conn; tbIAgentGroup = adapIAgentGroup.GetIAgentGroupByAgentID(AgentID); adapAgent.Connection = conn; tbAgent = adapAgent.GetAgentByAgentID(AgentID); if (tbIAgentGroup != null) { int count = tbIAgentGroup.Count; for (int i = 0; i < count; i++) { Business.IAgentGroup newIGroupSymbol = new Business.IAgentGroup(); newIGroupSymbol.IAgentGroupID = tbIAgentGroup[i].IAgentGroupID; newIGroupSymbol.InvestorGroupID = tbIAgentGroup[i].InvestorGroupID; newIGroupSymbol.AgentID = tbIAgentGroup[i].AgentID; Result.Add(newIGroupSymbol); } if (tbAgent != null) { Agent.AgentID = tbAgent[0].AgentID; Agent.AgentGroupID = tbAgent[0].AgentGroupID; Agent.Name = tbAgent[0].Name; Agent.InvestorID = tbAgent[0].InvestorID; Agent.Comment = tbAgent[0].Comment; Agent.IsDisable = tbAgent[0].Isdiable; Agent.IsIpFilter = tbAgent[0].IsIpFilter; Agent.IpForm = tbAgent[0].IpForm; Agent.IpTo = tbAgent[0].IpTo; Agent.GroupCondition = tbAgent[0].GroupCondition; List<int> listInvestorGroupIDs = Agent.MakeListIAgentGroupManager(Agent.GroupCondition); for (int i = 0; i < listInvestorGroupIDs.Count; i++) { bool check = true; for (int j = 0; j < Result.Count; j++) { if (listInvestorGroupIDs[i] == Result[j].InvestorGroupID) { check = false; break; } } if (check == true) { int idIAgentGroup = int.Parse(adapIAgentGroup.AddIAgentGroup(Agent.AgentID, listInvestorGroupIDs[i]).ToString()); if (idIAgentGroup > 0) { Business.IAgentGroup newIGroupSymbol = new Business.IAgentGroup(); newIGroupSymbol.IAgentGroupID = idIAgentGroup; newIGroupSymbol.InvestorGroupID = listInvestorGroupIDs[i]; newIGroupSymbol.AgentID = Agent.AgentID; Result.Add(newIGroupSymbol); } } } } } } catch (Exception ex) { return null; } finally { adapIAgentGroup.Connection.Close(); adapAgent.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="InvestorID"></param> /// <returns></returns> internal Business.Agent GetAgentByInvestorID(int InvestorID) { Business.Agent Result = new Business.Agent(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.AgentTableAdapter adap = new DSTableAdapters.AgentTableAdapter(); DS.AgentDataTable tbAgent = new DS.AgentDataTable(); try { conn.Open(); adap.Connection = conn; tbAgent = adap.GetAgentByInvestorID(InvestorID); if (tbAgent != null) { Result.AgentID = tbAgent[0].AgentID; Result.AgentGroupID = tbAgent[0].AgentGroupID; Result.Name = tbAgent[0].Name; Result.InvestorID = tbAgent[0].InvestorID; Result.Comment = tbAgent[0].Comment; Result.IsDisable = tbAgent[0].Isdiable; Result.IsIpFilter = tbAgent[0].IsIpFilter; Result.IpForm = tbAgent[0].IpForm; Result.IpTo = tbAgent[0].IpTo; Result.GroupCondition = tbAgent[0].GroupCondition; } } catch (Exception ex) { Result = null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }