/// <summary> /// 添加交易时间 /// </summary> /// <param name="model">交易所类型_交易时间实体</param> /// <returns></returns> public static int AddCMTradeTime(ManagementCenter.Model.CM_TradeTime model) { CM_TradeTimeBLL cM_TradeTimeBLL = new CM_TradeTimeBLL(); return(cM_TradeTimeBLL.AddCMTradeTime(model)); }
/// <summary> /// 更新交易时间 /// </summary> /// <param name="model">交易所类型_交易时间实体</param> /// <returns></returns> public static bool UpdateCMTradeTime(ManagementCenter.Model.CM_TradeTime model) { CM_TradeTimeBLL cM_TradeTimeBLL = new CM_TradeTimeBLL(); return(cM_TradeTimeBLL.UpdateCMTradeTime(model)); }
/// <summary> /// 添加交易时间 /// </summary> /// <param name="model">交易所类型_交易时间实体</param> /// <param name="msg">返回错误结果提示信息</param> /// <returns></returns> //public int AddCMTradeTime(ManagementCenter.Model.CM_TradeTime model, ref string msg) //{ // try // { // string m_msg = string.Empty; // if (model.StartTime > model.EndTime) // { // m_msg += "交易开始时间不能大于交易结束时间!" + "\t\n"; // } // if (model.EndTime < model.StartTime) // { // m_msg += "交易结束时间不能小于交易开始时间!" + "\t\n"; // } // if (model.StartTime == model.EndTime) // { // m_msg += "交易开始时间和交易结束时间不能相等!" + "\t\n"; // } // msg = m_msg; // if (!string.IsNullOrEmpty(msg)) // { // return AppGlobalVariable.INIT_INT; // } // return cM_TradeTimeDAL.Add(model); // } // catch (Exception ex) // { // string errCode = "GL-4740"; // string errMsg = "添加交易时间失败!"; // VTException exception = new VTException(errCode, errMsg, ex); // LogHelper.WriteError(exception.ToString(), exception.InnerException); // return AppGlobalVariable.INIT_INT; // } //} #endregion #region 更新交易时间 /// <summary> /// 更新交易时间 /// </summary> /// <param name="model">交易所类型_交易时间实体</param> /// <returns></returns> public bool UpdateCMTradeTime(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 { // return cM_TradeTimeDAL.Update(model); CM_TradeTimeDAL cM_TradeTimeDAL = new CM_TradeTimeDAL(); CM_BourseTypeDAL cM_BourseTypeDAL = new CM_BourseTypeDAL(); //交易所类型ID int bourseTypeID = AppGlobalVariable.INIT_INT; bourseTypeID = (int)model.BourseTypeID; bool updateTTimeResult = cM_TradeTimeDAL.Update(model, tran, db); if (!updateTTimeResult) { 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-4742"; 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(); } } }