/// <summary>
        /// 更新交割月份(包括添加,删除)
        /// </summary>
        /// <param name="addMonthID">需要添加的月份ID</param>
        /// <param name="deleteMonthID">需要删除的月份ID</param>
        /// <param name="BreedClassID">品种ID</param>
        /// <returns></returns>
        public bool UpdateQHAgreementDeliveryMonth(List <int> addMonthID, List <int> deleteMonthID, int BreedClassID)
        {
            QH_AgreementDeliveryMonthDAL qHAgreementDeliveryMonthDAL = new QH_AgreementDeliveryMonthDAL();
            QH_AgreementDeliveryMonth    QH_AgreementDeliveryMonth   = new QH_AgreementDeliveryMonth();

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

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

            try
            {
                foreach (int addM in addMonthID)
                {
                    QH_AgreementDeliveryMonth.MonthID = addM;
                    int a = qHAgreementDeliveryMonthDAL.Add(QH_AgreementDeliveryMonth, Tran, db);
                }

                foreach (int deleM in deleteMonthID)
                {
                    QH_AgreementDeliveryMonth.MonthID = deleM;
                    qHAgreementDeliveryMonthDAL.Delete(deleM, BreedClassID, Tran, db);
                }
                Tran.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                Tran.Rollback();
                string      errCode   = "GL-6060";
                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();
                }
            }
        }
Exemple #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();
                }
            }
        }