/// <summary> /// /// </summary> /// <param name="IAgentGroupID"></param> /// <returns></returns> internal Business.IAgentGroup GetIAgentGroupByIAgentGroupID(int IAgentGroupID) { Business.IAgentGroup Result = new Business.IAgentGroup(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.IAgentGroupTableAdapter adap = new DSTableAdapters.IAgentGroupTableAdapter(); DS.IAgentGroupDataTable tbIAgentGroup = new DS.IAgentGroupDataTable(); try { conn.Open(); adap.Connection = conn; tbIAgentGroup = adap.GetIAgentGroupByIAgentGroupID(IAgentGroupID); if (tbIAgentGroup != null) { Result.IAgentGroupID = tbIAgentGroup[0].IAgentGroupID; Result.InvestorGroupID = tbIAgentGroup[0].InvestorGroupID; Result.AgentID = tbIAgentGroup[0].AgentID; } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="InvestorGroupID"></param> /// <returns></returns> internal List<Business.IAgentGroup> GetIAgentGroupByInvestorGroupID(int InvestorGroupID) { List<Business.IAgentGroup> Result = new List<Business.IAgentGroup>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.IAgentGroupTableAdapter adap = new DSTableAdapters.IAgentGroupTableAdapter(); DS.IAgentGroupDataTable tbIAgentGroup = new DS.IAgentGroupDataTable(); try { conn.Open(); adap.Connection = conn; tbIAgentGroup = adap.GetIAgentGroupByInvestorGroupID(InvestorGroupID); 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); } } } catch (Exception ex) { return 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; }