示例#1
0
        /// <summary>
        /// 根据交易规则委托量标识删除交易规则和单笔最大委托量
        /// </summary>
        /// <param name="ConsignQuantumID">交易规则委托量ID</param>
        /// <param name="tran"></param>
        /// <param name="db"></param>
        /// <param name="falg">标记是否使用了外部事务</param>
        /// <returns></returns>
        public bool DeleteQHConsignQuantumAndSingle(int ConsignQuantumID, DbTransaction tran, Database db, bool falg)
        {
            QH_ConsignQuantumDAL        qHConsignQuantumDAL        = new QH_ConsignQuantumDAL();
            QH_SingleRequestQuantityDAL qHSingleRequestQuantityDAL = new QH_SingleRequestQuantityDAL();
            DbConnection Conn = null;

            try
            {
                //创建本地事务
                if (db == null && tran == null)
                {
                    db   = DatabaseFactory.CreateDatabase();
                    Conn = db.CreateConnection();
                    if (Conn.State != ConnectionState.Open)
                    {
                        Conn.Open();
                    }
                    tran = Conn.BeginTransaction();
                }
                qHSingleRequestQuantityDAL.DeleteSingleRQByConsignQuantumID(ConsignQuantumID, tran, db);
                qHConsignQuantumDAL.Delete(ConsignQuantumID, tran, db);
                if (!falg)
                {
                    tran.Commit();
                }
                return(true);
            }
            catch (Exception ex)
            {
                if (!falg)
                {
                    tran.Rollback();
                }
                string      errCode   = "GL-6022";
                string      errMsg    = "根据交易规则委托量标识删除交易规则和单笔最大委托量失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return(false);
            }
            finally
            {
                if (Conn != null && Conn.State == ConnectionState.Open)
                {
                    if (!falg)
                    {
                        Conn.Close();
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        ///根据品种标识,删除期货品种交易规则(规则相关表全部删除)
        /// </summary>
        /// <param name="BreedClassID">品种标识</param>
        /// <returns></returns>
        public bool DeleteFuturesTradeRulesAboutAll(int BreedClassID)
        {
            QH_FuturesTradeRulesDAL      qHFuturesTradeRulesDAL       = new QH_FuturesTradeRulesDAL();
            QH_AgreementDeliveryMonthDAL qH_AgreementDeliveryMonthDAL = new QH_AgreementDeliveryMonthDAL();
            QH_ConsignQuantumDAL         qH_ConsignQuantumDAL         = new QH_ConsignQuantumDAL();
            QH_SingleRequestQuantityDAL  qH_SingleRequestQuantityDAL  = new QH_SingleRequestQuantityDAL();
            QH_LastTradingDayDAL         qH_LastTradingDayDAL         = new QH_LastTradingDayDAL();

            DbConnection Conn = null;
            Database     db   = DatabaseFactory.CreateDatabase();

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

            try
            {
                int ConsignQuantumID = AppGlobalVariable.INIT_INT;
                int LastTradingDayID = AppGlobalVariable.INIT_INT;
                QH_FuturesTradeRules qHFuturesTradeRules = new QH_FuturesTradeRules();
                qHFuturesTradeRules = qHFuturesTradeRulesDAL.GetModel(BreedClassID);
                if (qHFuturesTradeRules != null)
                {
                    if (!string.IsNullOrEmpty(qHFuturesTradeRules.ConsignQuantumID.ToString()))
                    {
                        ConsignQuantumID = Convert.ToInt32(qHFuturesTradeRules.ConsignQuantumID);
                    }
                    if (!string.IsNullOrEmpty(qHFuturesTradeRules.LastTradingDayID.ToString()))
                    {
                        LastTradingDayID = Convert.ToInt32(qHFuturesTradeRules.LastTradingDayID);
                    }
                    if (ConsignQuantumID != AppGlobalVariable.INIT_INT)
                    {
                        if (!qH_SingleRequestQuantityDAL.DeleteSingleRQByConsignQuantumID(ConsignQuantumID, Tran, db))
                        {
                            Tran.Rollback();
                            return(false);
                        }
                    }


                    List <Model.QH_AgreementDeliveryMonth> qHAgreementDeliveryM =
                        qH_AgreementDeliveryMonthDAL.GetListArray(string.Format("BreedClassID={0}", BreedClassID), Tran,
                                                                  db);
                    foreach (Model.QH_AgreementDeliveryMonth MonthID in qHAgreementDeliveryM)
                    {
                        if (!qH_AgreementDeliveryMonthDAL.Delete((Int32)MonthID.MonthID, BreedClassID))  //?处理
                        {
                            Tran.Rollback();
                            return(false);
                        }
                    }

                    if (!qHFuturesTradeRulesDAL.Delete(BreedClassID, Tran, db))
                    {
                        Tran.Rollback();
                        return(false);
                    }

                    if (ConsignQuantumID != AppGlobalVariable.INIT_INT)
                    {
                        if (!qH_ConsignQuantumDAL.Delete(ConsignQuantumID, Tran, db))
                        {
                            Tran.Rollback();
                            return(false);
                        }
                    }
                    if (LastTradingDayID != AppGlobalVariable.INIT_INT)
                    {
                        if (!qH_LastTradingDayDAL.Delete(LastTradingDayID, Tran, db))
                        {
                            Tran.Rollback();
                            return(false);
                        }
                    }
                }
                Tran.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                Tran.Rollback();
                string      errCode   = "GL-6004";
                string      errMsg    = " 根据品种标识,删除期货品种交易规则(规则相关表全部删除)失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return(false);
            }
            finally
            {
                if (Conn.State == ConnectionState.Open)
                {
                    Conn.Close();
                }
            }
        }