/// <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(); } } }