コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="AgentID"></param>
        /// <param name="InvestorGroupID"></param>
        /// <returns></returns>
        internal int AddNewIAgentGroups(int AgentID, List<int> ListInvestorGroupID)
        {
            int Result = -1;
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.IAgentGroupTableAdapter adap = new DSTableAdapters.IAgentGroupTableAdapter();

            try
            {
                conn.Open();
                adap.Connection = conn;
                int count = ListInvestorGroupID.Count;
                for (int i = 0; i < count; i++)
                {
                    Result = int.Parse(adap.AddIAgentGroup(AgentID, ListInvestorGroupID[i]).ToString());
                }

            }
            catch (Exception ex)
            {
                return -1;
            }
            finally
            {
                adap.Connection.Close();
                conn.Close();
            }

            return Result;
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="AgentID"></param>
        /// <param name="InvestorGroupID"></param>
        /// <returns></returns>
        internal int AddNewIAgentGroup(int AgentID, int InvestorGroupID)
        {
            int Result = -1;
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.IAgentGroupTableAdapter adap = new DSTableAdapters.IAgentGroupTableAdapter();

            try
            {
                conn.Open();
                adap.Connection = conn;
                Result = int.Parse(adap.AddIAgentGroup(AgentID, InvestorGroupID).ToString());
            }
            catch (Exception ex)
            {
                return -1;
            }
            finally
            {
                adap.Connection.Close();
                conn.Close();
            }

            return Result;
        }
コード例 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="AgentID"></param>
        /// <returns></returns>
        internal int DeleteIAgentGroupByAgentID(int AgentID)
        {
            int Result = -1;
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.IAgentGroupTableAdapter adap = new DSTableAdapters.IAgentGroupTableAdapter();

            try
            {
                conn.Open();
                adap.Connection = conn;
                Result = adap.DeleteIAgentGroupByAgentID(AgentID);
            }
            catch (Exception ex)
            {
                Result = -1;
            }
            finally
            {
                adap.Connection.Close();
                conn.Close();
            }

            return Result;
        }
コード例 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="IAgentGroupID"></param>
        /// <param name="AgentID"></param>
        /// <param name="InvestorGroupID"></param>
        /// <returns></returns>
        internal bool UpdateIAgentGroup(int IAgentGroupID, int AgentID, int InvestorGroupID)
        {
            bool Result = true;
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.IAgentGroupTableAdapter adap = new DSTableAdapters.IAgentGroupTableAdapter();

            try
            {
                conn.Open();
                adap.Connection = conn;
                adap.UpdateIAgentGroup(AgentID, InvestorGroupID,IAgentGroupID);
            }
            catch (Exception ex)
            {
                return false;
            }
            finally
            {
                adap.Connection.Close();
                conn.Close();
            }

            return Result;
        }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
        /// <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;
        }
コード例 #7
0
        /// <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;
        }
コード例 #8
0
 /// <summary>
 /// delete by investorgroupid
 /// </summary>
 /// <param name="id">investor group id</param>
 /// <param name="connection">opened sql connection</param>
 /// <returns></returns>
 internal bool DFDeleteByInvestorGroupID(int id, SqlConnection connection,SqlTransaction trans)
 {
     DSTableAdapters.IAgentGroupTableAdapter adap = new DSTableAdapters.IAgentGroupTableAdapter();
     adap.Connection = connection;
     adap.Transaction = trans;
     adap.DeleteIAgentGroupByIAgentGroupID(id);
     return true;
 }
コード例 #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="IAgentGroupID"></param>
        /// <returns></returns>
        internal bool DeleteIAgentGroupByIAgentGroupID(int IAgentGroupID)
        {
            bool Result = false;
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.IAgentGroupTableAdapter adap = new DSTableAdapters.IAgentGroupTableAdapter();

            try
            {
                conn.Open();
                adap.Connection = conn;
                adap.DeleteIAgentGroupByIAgentGroupID(IAgentGroupID);
                Result = true;
            }
            catch (Exception ex)
            {
                Result = false;
            }
            finally
            {
                adap.Connection.Close();
                conn.Close();
            }

            return Result;
        }
コード例 #10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="AgentID"></param>
        /// <param name="AgentGroupID"></param>
        /// <param name="Name"></param>
        internal bool UpdateAgent(Business.Agent agent)
        {
            bool Result = false;
            System.Data.SqlClient.SqlTransaction trans = null;
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.AgentTableAdapter adapAgent = new DSTableAdapters.AgentTableAdapter();
            DSTableAdapters.IAgentGroupTableAdapter adapIAgentGroup = new DSTableAdapters.IAgentGroupTableAdapter();
            try
            {
                conn.Open();
                trans                          = conn.BeginTransaction();
                adapAgent.Connection           = conn;
                adapAgent.Transaction          = trans;

                adapIAgentGroup.Connection     = conn;
                adapIAgentGroup.Transaction    = trans;

                int Record                     = adapAgent.UpdateAgent(agent.AgentGroupID, agent.Name, agent.Comment, agent.IsDisable, agent.IsIpFilter, agent.IpForm, agent.IpTo, agent.GroupCondition, agent.AgentID);
                if (Record > 0)
                {
                    Result                     = true;
                }
                else
                {
                    throw new Exception("Data error");
                }
                adapIAgentGroup.DeleteIAgentGroupByAgentID(agent.AgentID);
                List<int> listInvestorGroupIDs = new List<int>();
                listInvestorGroupIDs           = agent.MakeListIAgentGroupManager(agent.GroupCondition);
                int count                      = listInvestorGroupIDs.Count;
                for (int i = 0; i < count; i++)
                {

                    int idIAgentGroup = int.Parse(adapIAgentGroup.AddIAgentGroup(agent.AgentID, listInvestorGroupIDs[i]).ToString());
                    if (idIAgentGroup < 1)
                    {
                        throw new Exception("Data error");
                    }
                }

                trans.Commit();
            }
            catch (Exception ex)
            {
                trans.Rollback();
                Result = false;
            }
            finally
            {
                adapAgent.Connection.Close();
                adapIAgentGroup.Connection.Close();
                conn.Close();
            }
            return Result;
        }
コード例 #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="AgentGroupID"></param>
        /// <param name="Name"></param>
        /// <returns></returns>
        internal int AddNewAgent(Business.Agent agent)
        {
            int idAgent = -1;
            System.Data.SqlClient.SqlTransaction trans = null;
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection);
            DSTableAdapters.AgentTableAdapter adapAgent = new DSTableAdapters.AgentTableAdapter();
            DSTableAdapters.IAgentGroupTableAdapter adapIAgentGroup = new DSTableAdapters.IAgentGroupTableAdapter();
            try
            {
                conn.Open();
                trans                                          = conn.BeginTransaction();
                adapAgent.Connection                           = conn;
                adapAgent.Transaction                          = trans;

                adapIAgentGroup.Connection                     = conn;
                adapIAgentGroup.Transaction                    = trans;

                #region Create Investor
                Business.Investor investor                     = new Business.Investor();
                investor.InvestorStatusID                      = -1;
                investor.InvestorGroupInstance                 = new Business.InvestorGroup();
                investor.InvestorGroupInstance.InvestorGroupID = -1;
                investor.AgentID                               = string.Empty;
                investor.Balance                               = 0;
                investor.Credit                                = 0;
                investor.Code                                  = agent.Code;
                investor.PrimaryPwd                            = agent.Pwd;
                investor.ReadOnlyPwd                           = "";
                investor.PhonePwd                              = "";
                investor.IsDisable                             = true;
                investor.TaxRate                               = 0;
                investor.Leverage                              = 0;
                //Investor Profile
                DateTime registerDay                           = new DateTime();
                investor.Address                               = "";
                investor.Phone                                 = "";
                investor.City                                  = "";
                investor.Country                               = "";
                investor.Email                                 = "";
                investor.ZipCode                               = "";
                investor.RegisterDay                           = registerDay;
                investor.Comment                               = "";
                investor.State                                 = "";
                investor.NickName                              = "";
                investor.AllowChangePwd                        = false;
                investor.ReadOnly                              = false;
                investor.SendReport                            = false;
                #endregion

                int idInvestor = TradingServer.Facade.FacadeAddNewInvestor(investor);
                if (idInvestor < 1)
                {
                    throw new Exception("Data error");
                }

                agent.InvestorID = idInvestor;
                if (agent.AgentGroupID == -1)
                {
                    idAgent = int.Parse(adapAgent.AddNewAgent(null, agent.Name, agent.InvestorID, agent.Comment, agent.IsDisable, agent.IsIpFilter, agent.IpForm, agent.IpTo, agent.GroupCondition).ToString());
                }
                else idAgent = int.Parse(adapAgent.AddNewAgent(agent.AgentGroupID, agent.Name, agent.InvestorID, agent.Comment, agent.IsDisable, agent.IsIpFilter, agent.IpForm, agent.IpTo, agent.GroupCondition).ToString());
                if (idAgent < 1)
                {
                    throw new Exception("Data error");
                }

                List<int> listInvestorGroupIDs = new List<int>();
                listInvestorGroupIDs = agent.MakeListIAgentGroupManager(agent.GroupCondition);
                int count = listInvestorGroupIDs.Count;
                for (int i = 0; i < count; i++)
                {
                    int idIAgentGroup = int.Parse(adapIAgentGroup.AddIAgentGroup(idAgent, listInvestorGroupIDs[i]).ToString());
                    if (idIAgentGroup < 1)
                    {
                        throw new Exception("Data error");
                    }
                }

                trans.Commit();
            }
            catch (Exception ex)
            {
                trans.Rollback();
                idAgent = -1;
            }
            finally
            {
                adapAgent.Connection.Close();
                adapIAgentGroup.Connection.Close();
                conn.Close();
            }

            return idAgent;
        }