/// <summary>
 /// 判断交易所名称是否已经存在
 /// </summary>
 /// <param name="BourseTypeName">交易所名称</param>
 /// <returns></returns>
 public bool IsExistBourseTypeName(string BourseTypeName)
 {
     try
     {
         var     cMBourseTypeDAL = new CM_BourseTypeDAL();
         string  strWhere        = string.Format("BourseTypeName='{0}'", BourseTypeName);
         DataSet _ds             = cMBourseTypeDAL.GetList(strWhere);
         if (_ds != null)
         {
             if (_ds.Tables[0].Rows.Count == 0)
             {
                 return(true);
             }
             return(false);
         }
         return(false);
     }
     catch (Exception ex)
     {
         string errCode   = "GL-4706";
         string errMsg    = "判断交易所名称是否已经存在失败!";
         var    exception = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(exception.ToString(), exception.InnerException);
         return(false);
     }
 }
 /// <summary>
 /// 更新交易所类型的撮合接收委托开始时间和撮合接收委托结束时间(根据交易开始和结束时间更新)
 /// </summary>
 /// <param name="bourseTypeID">交易所类型ID</param>
 /// <param name="receivingConsignStartTime">撮合接收委托开始时间</param>
 /// <param name="receivingConsignEndTime">撮合接收委托结束时间</param>
 /// <returns></returns>
 public bool UpdateBourseTypeConsignTime(int bourseTypeID, DateTime receivingConsignStartTime, DateTime receivingConsignEndTime)
 {
     try
     {
         var cmBourseTypeDal = new CM_BourseTypeDAL();
         cmBourseTypeDal.Update(bourseTypeID, receivingConsignStartTime, receivingConsignEndTime);
         return(true);
     }
     catch (Exception ex)
     {
         GTA.VTS.Common.CommonUtility.LogHelper.WriteError(ex.Message, ex);
         return(false);
     }
 }
 /// <summary>
 /// 获取交易所类型名称
 /// </summary>
 /// <returns></returns>
 public DataSet GetBourseTypeName()
 {
     try
     {
         var cMBourseTypeDAL = new CM_BourseTypeDAL();
         return(cMBourseTypeDAL.GetBourseTypeName());
     }
     catch (Exception ex)
     {
         string errCode   = "GL-4704";
         string errMsg    = "获取交易所类型名称失败!";
         var    exception = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(exception.ToString(), exception.InnerException);
         return(null);
     }
 }
 /// <summary>
 /// 获取所有交易所类型
 /// </summary>
 /// <param name="BourseTypeName">交易所类型名称</param>
 /// <param name="pageNo">当前页</param>
 /// <param name="pageSize">显示记录数</param>
 /// <param name="rowCount">总行数</param>
 /// <returns></returns>
 public DataSet GetAllCMBourseType(string BourseTypeName, int pageNo, int pageSize,
                                   out int rowCount)
 {
     try
     {
         var cMBourseTypeDAL = new CM_BourseTypeDAL();
         return(cMBourseTypeDAL.GetAllCMBourseType(BourseTypeName, pageNo, pageSize, out rowCount));
     }
     catch (Exception ex)
     {
         rowCount = AppGlobalVariable.INIT_INT;
         string errCode   = "GL-4703";
         string errMsg    = "获取所有交易所类型失败!";
         var    exception = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(exception.ToString(), exception.InnerException);
         return(null);
     }
 }
        /// <summary>
        /// 添加非交易日
        /// </summary>
        /// <param name="year"></param>
        public static void InitNotTrandingDay(int year)
        {
            try
            {
                CM_BourseTypeDAL     BourseTypeDAL   = new CM_BourseTypeDAL();
                List <CM_BourseType> l               = BourseTypeDAL.GetListArray(string.Empty);
                DateTime             startDate       = DateTime.Parse(string.Format("{0}-01-01", year));
                DateTime             endDate         = DateTime.Parse(string.Format("{0}-12-31", year));
                CM_NotTradeDateDAL   NotTradeDateDAL = new CM_NotTradeDateDAL();
                CM_NotTradeDate      NotTradeDate    = new CM_NotTradeDate();

                foreach (CM_BourseType type in l)
                {
                    for (DateTime dt = startDate; dt <= endDate; dt = dt.AddDays(1))
                    {
                        DayOfWeek t = dt.DayOfWeek;
                        if (t == DayOfWeek.Sunday || t == DayOfWeek.Saturday)
                        {
                            List <ManagementCenter.Model.CM_NotTradeDate> l_NotTradeDate =
                                NotTradeDateDAL.GetListArray(string.Format("NotTradeDay='{0}' AND BourseTypeID={1}", dt, type.BourseTypeID));
                            if (l_NotTradeDate == null || l_NotTradeDate.Count < 1)
                            {
                                NotTradeDate.NotTradeDay  = dt;
                                NotTradeDate.BourseTypeID = type.BourseTypeID;
                                NotTradeDateDAL.Add(NotTradeDate);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string errMsg = "初始化非交易日失败!";
                LogHelper.WriteError(errMsg, ex);
            }
        }
        /// <summary>
        /// 添加交易所类型和交易时间
        /// </summary>
        /// <param name="cmBourseType">交易所类型实体</param>
        /// <param name="cmTradeTimeList">交易时间实体集合</param>
        /// <returns></returns>
        public int AddCMBourseTypeAndTradeTime(CM_BourseType cmBourseType, List <CM_TradeTime> cmTradeTimeList)
        {
            var          cmBourseTypeDal = new CM_BourseTypeDAL();
            var          cmTradeTimeDal  = new CM_TradeTimeDAL();
            DbConnection Conn            = null;
            Database     db = DatabaseFactory.CreateDatabase();

            Conn = db.CreateConnection();
            if (Conn.State != ConnectionState.Open)
            {
                Conn.Open();
            }
            DbTransaction tran = Conn.BeginTransaction();
            //交易所类型ID
            int BourseTypeID = AppGlobalVariable.INIT_INT;
            //交易时间ID
            int TradeTimeID = AppGlobalVariable.INIT_INT;

            try
            {
                if (cmBourseType != null && cmTradeTimeList.Count > 0)
                {
                    BourseTypeID = cmBourseTypeDal.Add(cmBourseType, tran, db);
                    if (BourseTypeID == AppGlobalVariable.INIT_INT)
                    {
                        tran.Rollback();
                    }
                    foreach (CM_TradeTime _cmTradeTime in cmTradeTimeList)
                    {
                        _cmTradeTime.BourseTypeID = BourseTypeID;
                        TradeTimeID = cmTradeTimeDal.Add(_cmTradeTime, tran, db);
                        if (TradeTimeID == AppGlobalVariable.INIT_INT)
                        {
                            tran.Rollback();
                            break;
                        }
                    }
                }
                //根据交易所类型ID获取并查找最早的交易开始时间和最晚的交易结束时间
                List <CM_TradeTime> cmTTimeList =
                    cmTradeTimeDal.GetListArray(string.Format("BourseTypeID={0}", BourseTypeID), tran, db);
                if (cmTTimeList.Count > 0)
                {
                    DateTime _tempStartTime = AppGlobalVariable.INIT_DATETIME;
                    DateTime _tempEndTime   = AppGlobalVariable.INIT_DATETIME;
                    bool     isStartTime    = true; //标志开始值是否改变
                    bool     isEndTime      = true; //标志结束值是否改变
                    for (int i = 0; i < cmTTimeList.Count; i++)
                    {
                        if (isStartTime)
                        {
                            _tempStartTime = (DateTime)cmTTimeList[0].StartTime;
                        }
                        if (isEndTime)
                        {
                            _tempEndTime = (DateTime)cmTTimeList[0].EndTime;
                        }
                        if (_tempStartTime > (DateTime)cmTTimeList[i].StartTime)
                        {
                            _tempStartTime = (DateTime)cmTTimeList[i].StartTime;
                            isStartTime    = false;
                        }
                        if (_tempEndTime < (DateTime)cmTTimeList[i].EndTime)
                        {
                            _tempEndTime = (DateTime)cmTTimeList[i].EndTime;
                            isEndTime    = false;
                        }
                    }
                    bool result = cmBourseTypeDal.Update(BourseTypeID, _tempStartTime, _tempEndTime, tran, db);
                    if (!result)
                    {
                        tran.Rollback();
                    }
                    tran.Commit();
                }
                return(BourseTypeID);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                string errCode   = "GL-4708";
                string errMsg    = "添加交易所类型和交易时间失败!";
                var    exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return(AppGlobalVariable.INIT_INT);
            }
            finally
            {
                if (Conn.State == ConnectionState.Open)
                {
                    Conn.Close();
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 根据交易时间ID,删除交易时间
        /// </summary>
        /// <param name="TradeTimeID">交易时间ID</param>
        /// <returns></returns>
        public bool DeleteCMTradeTime(int TradeTimeID)
        {
            DbConnection Conn = null;
            Database     db   = DatabaseFactory.CreateDatabase();

            Conn = db.CreateConnection();
            if (Conn.State != ConnectionState.Open)
            {
                Conn.Open();
            }
            DbTransaction tran = Conn.BeginTransaction();

            try
            {
                //return cM_TradeTimeDAL.Delete(TradeTimeID);
                CM_TradeTimeDAL  cM_TradeTimeDAL  = new CM_TradeTimeDAL();
                CM_BourseTypeDAL cM_BourseTypeDAL = new CM_BourseTypeDAL();
                CM_TradeTime     cMTradeTime      = cM_TradeTimeDAL.GetModel(TradeTimeID);
                if (cMTradeTime != null)
                {
                    //交易所类型ID
                    int bourseTypeID = AppGlobalVariable.INIT_INT;
                    bourseTypeID = (int)cMTradeTime.BourseTypeID;
                    bool deleTTimeResult = cM_TradeTimeDAL.Delete(TradeTimeID);
                    if (!deleTTimeResult)
                    {
                        tran.Rollback();
                        return(false);
                    }
                    if (bourseTypeID != AppGlobalVariable.INIT_INT)
                    {
                        //根据交易所类型ID获取并查找最早的交易开始时间和最晚的交易结束时间
                        List <CM_TradeTime> cmTTimeList =
                            cM_TradeTimeDAL.GetListArray(string.Format("BourseTypeID={0}", bourseTypeID), tran, db);
                        if (cmTTimeList.Count > 0)
                        {
                            CM_TradeTime cmTradeTime = CompareTradeTime(cmTTimeList);
                            if (cmTradeTime != null)
                            {
                                bool result = cM_BourseTypeDAL.Update(bourseTypeID, (DateTime)cmTradeTime.StartTime,
                                                                      (DateTime)cmTradeTime.EndTime, tran,
                                                                      db);
                                if (!result)
                                {
                                    tran.Rollback();
                                    return(false);
                                }
                            }
                            tran.Commit();
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                string      errCode   = "GL-4741";
                string      errMsg    = " 根据交易时间ID,删除交易时间失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return(false);
            }
            finally
            {
                if (Conn.State == ConnectionState.Open)
                {
                    Conn.Close();
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 添加交易时间
        /// </summary>
        /// <param name="model">交易所类型_交易时间实体</param>
        /// <returns></returns>
        public int AddCMTradeTime(ManagementCenter.Model.CM_TradeTime model)
        {
            DbConnection Conn = null;
            Database     db   = DatabaseFactory.CreateDatabase();

            Conn = db.CreateConnection();
            if (Conn.State != ConnectionState.Open)
            {
                Conn.Open();
            }
            DbTransaction tran = Conn.BeginTransaction();

            try
            {
                CM_TradeTimeDAL  cM_TradeTimeDAL  = new CM_TradeTimeDAL();
                CM_BourseTypeDAL cM_BourseTypeDAL = new CM_BourseTypeDAL();
                //int tradeTimeID = (int)model.TradeTimeID;
                int addTTimeResult = AppGlobalVariable.INIT_INT;
                //交易所类型ID
                int bourseTypeID = AppGlobalVariable.INIT_INT;
                bourseTypeID   = (int)model.BourseTypeID;
                addTTimeResult = cM_TradeTimeDAL.Add(model, tran, db);
                if (addTTimeResult == AppGlobalVariable.INIT_INT)
                {
                    tran.Rollback();
                    return(AppGlobalVariable.INIT_INT);
                }
                if (bourseTypeID != AppGlobalVariable.INIT_INT)
                {
                    //根据交易所类型ID获取并查找最早的交易开始时间和最晚的交易结束时间
                    List <CM_TradeTime> cmTTimeList =
                        cM_TradeTimeDAL.GetListArray(string.Format("BourseTypeID={0}", bourseTypeID), tran, db);
                    if (cmTTimeList.Count > 0)
                    {
                        CM_TradeTime cmTradeTime = CompareTradeTime(cmTTimeList);
                        if (cmTradeTime != null)
                        {
                            bool result = cM_BourseTypeDAL.Update(bourseTypeID, (DateTime)cmTradeTime.StartTime,
                                                                  (DateTime)cmTradeTime.EndTime, tran,
                                                                  db);
                            if (!result)
                            {
                                tran.Rollback();
                                return(AppGlobalVariable.INIT_INT);
                            }
                        }
                        tran.Commit();
                    }
                }
                return(addTTimeResult);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                string      errCode   = "GL-4740";
                string      errMsg    = "添加交易时间失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return(AppGlobalVariable.INIT_INT);
            }
            finally
            {
                if (Conn.State == ConnectionState.Open)
                {
                    Conn.Close();
                }
            }
        }