/// <summary> /// 根据港股交易商品代码删除港股交易商品(相关表的记录同时删除) /// </summary> /// <param name="HKCommodityCode">港股商品代码</param> /// <returns></returns> public bool DeleteHKCommodity(string HKCommodityCode) { HK_CommodityDAL hKCommodityDAL = new HK_CommodityDAL(); RC_TradeCommodityAssignDAL TradeCommodityAssignDAL = new RC_TradeCommodityAssignDAL(); DbConnection Conn = null; Database db = DatabaseFactory.CreateDatabase(); Conn = db.CreateConnection(); if (Conn.State != ConnectionState.Open) { Conn.Open(); } DbTransaction Tran = Conn.BeginTransaction(); try { TradeCommodityAssignDAL.DeleteByCommodityCode(HKCommodityCode, Tran, db); if (!hKCommodityDAL.Delete(HKCommodityCode, Tran, db)) { Tran.Rollback(); return(false); } Tran.Commit(); return(true); } catch (Exception ex) { Tran.Rollback(); string errCode = "GL-7752"; 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(); } } }
/// <summary> /// 根据商品代码删除交易商品(相关表的记录同时删除) /// </summary> /// <param name="CommodityCode">商品代码</param> /// <param name="BreedClassID">品种ID</param> /// <returns></returns> public bool DeleteCMCommodity(string CommodityCode, int BreedClassID) { CM_CommodityDAL cMCommodityDAL = new CM_CommodityDAL(); RC_TradeCommodityAssignDAL TradeCommodityAssignDAL = new RC_TradeCommodityAssignDAL(); CM_CommodityFuseDAL cMCommodityFuseDAL = new CM_CommodityFuseDAL(); CM_FuseTimesectionDAL cMFuseTimesectionDAL = new CM_FuseTimesectionDAL(); CM_BreedClassBLL cM_BreedClassBLL = new CM_BreedClassBLL(); DbConnection Conn = null; Database db = DatabaseFactory.CreateDatabase(); Conn = db.CreateConnection(); if (Conn.State != ConnectionState.Open) { Conn.Open(); } DbTransaction Tran = Conn.BeginTransaction(); try { int breedClassTypeID = AppGlobalVariable.INIT_INT;//品种类型ID List <CM_BreedClass> cM_BreedClassList = cM_BreedClassBLL.GetListArray(string.Format("BreedClassID={0}", BreedClassID)); if (cM_BreedClassList.Count > 0) { CM_BreedClass cM_BreedClass = cM_BreedClassList[0]; if (cM_BreedClass != null) { breedClassTypeID = Convert.ToInt32(cM_BreedClass.BreedClassTypeID); } } if (breedClassTypeID == (int)GTA.VTS.Common.CommonObject.Types.BreedClassTypeEnum.StockIndexFuture) { if (!string.IsNullOrEmpty(CommodityCode)) { if (!cMFuseTimesectionDAL.DeleteByCommodityCode(CommodityCode, Tran, db)) { Tran.Rollback(); return(false); } else { if (!cMCommodityFuseDAL.Delete(CommodityCode, Tran, db)) { Tran.Rollback(); return(false); } } } TradeCommodityAssignDAL.DeleteByCommodityCode(CommodityCode, Tran, db); if (!cMCommodityDAL.Delete(CommodityCode, Tran, db)) { Tran.Rollback(); return(false); } } else { TradeCommodityAssignDAL.DeleteByCommodityCode(CommodityCode, Tran, db); if (!cMCommodityDAL.Delete(CommodityCode, Tran, db)) { Tran.Rollback(); return(false); } } Tran.Commit(); return(true); } catch (Exception ex) { Tran.Rollback(); string errCode = "GL-4301"; 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(); } } }