/// <summary> /// 获取所有交易所类型 /// </summary> /// <param name="BourseTypeName">交易所类型名称</param> /// <param name="pageNo">当前页</param> /// <param name="pageSize">显示记录数</param> /// <param name="rowCount">总行数</param> /// <returns></returns> public static DataSet GetAllCMBourseType(string BourseTypeName, int pageNo, int pageSize, out int rowCount) { CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); return(cM_BourseTypeBLL.GetAllCMBourseType(BourseTypeName, pageNo, pageSize, out rowCount)); }
/// <summary> /// 加载页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Bourse_Machine_Load(object sender, EventArgs e) { try { ManagementCenter.BLL.CM_BourseTypeBLL BourseTypeBLL = new CM_BourseTypeBLL(); string strWhere = " DELETESTATE IS NOT NULL AND DELETESTATE<>1 "; ds = BourseTypeBLL.GetList(strWhere); ds.Tables[0].Columns.Add("MachineNo"); this.gridControl1.DataSource = ds.Tables[0]; this.gridControl1.Focus(); this.gridView1.FocusedColumn = this.gridCol_MachineNo; SendKeys.Send("{ENTER}"); this.gridControl1.Refresh(); } catch (Exception ex) { ShowMessageBox.ShowInformation("页面加载失败!"); string errCode = "GL-2052"; string errMsg = "页面加载失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); } }
/// <summary> /// 获取交易所类型UComboItem集合 /// </summary> /// <returns></returns> public static List <UComboItem> GetBourseTypeList() { UComboItem item; List <UComboItem> listUComboItem = new List <UComboItem>(); try { ManagementCenter.BLL.CM_BourseTypeBLL BourseTypeBLL = new CM_BourseTypeBLL(); string strWhere = " DELETESTATE IS NOT NULL AND DELETESTATE<>1 "; List <CM_BourseType> l = BourseTypeBLL.GetListArray(strWhere);//(string.Empty); if (l == null) { return(null); } foreach (CM_BourseType BourseType in l) { item = new UComboItem(BourseType.BourseTypeName, BourseType.BourseTypeID); listUComboItem.Add(item); } } catch { return(null); } return(listUComboItem); }
/// <summary> /// 根据交易所类型标识返回交易所类型 /// </summary> /// <param name="bourseTypeID">交易所类型标识</param> /// <returns></returns> public Entity.CM_BourseType GetBourseTypeByBourseTypeID(int bourseTypeID) { try { LogHelper.WriteDebug("Debug-8201根据交易所类型标识返回交易所类型方法名称:GetBourseTypeByBourseTypeID(int bourseTypeID)参数是:" + bourseTypeID + "时间是:" + DateTime.Now); CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); List <Entity.CM_BourseType> cM_BourseTypeList = cM_BourseTypeBLL.GetListArray(string.Format("BourseTypeID={0}", bourseTypeID)); if (cM_BourseTypeList.Count > 0) { Entity.CM_BourseType cM_BourseType = cM_BourseTypeList[0]; if (cM_BourseType != null) { return(cM_BourseType); } } return(null); } catch (Exception ex) { string errCode = "GL-8201"; string errMsg = "根据交易所类型标识返回交易所类型失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); return(null); } }
/// <summary> /// 获取所有的交易所类型 /// </summary> /// <returns></returns> public List <Entity.CM_BourseType> GetAllBourseType() { try { LogHelper.WriteDebug("Debug-8200获取所有的交易所类型方法名称:GetAllBourseType()" + DateTime.Now); CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); return(cM_BourseTypeBLL.GetListArray(string.Empty)); } catch (Exception ex) { string errCode = "GL-8200"; string errMsg = "获取所有的交易所类型失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); return(null); } }
/// <summary> /// 添加期货品种时初始化一个周期的和约代码 /// </summary> /// <param name="BreedClassID"></param> public void QHCommdityCodeInit(int BreedClassID) { CommodityCodeUpdate CCP = new CommodityCodeUpdate(); //根据品种ID,找到品种的前缀代码 string QH_PrefixCode = CCP.GetQH_PrefixCodeByID(BreedClassID); //根据品种ID,找到品种的名称 string QH_breedclassName = CCP.GetBreedClassNameByID(BreedClassID); #region 创建代码规则管理器 add by 董鹏 2010-03-10 //根据品种获取交易所 CM_BreedClassBLL bc = new CM_BreedClassBLL(); CM_BourseTypeBLL bt = new CM_BourseTypeBLL(); var bourseType = bt.GetModel(bc.GetModel(BreedClassID).BourseTypeID.Value); //创建代码规则管理 CodeRulesManager codeRule; if (bourseType.CodeRulesType.HasValue) { LogHelper.WriteDebug("===开始自动生成代码,代码规则类型:" + bourseType.CodeRulesType.ToString()); codeRule = new CodeRulesManager((Types.CodeRulesType)bourseType.CodeRulesType.Value); } else { LogHelper.WriteDebug("===开始自动生成代码,没有获取到交易所对应的代码规则,交易所:" + bourseType.BourseTypeName); codeRule = new CodeRulesManager(null); } #endregion CM_CommodityDAL CommodityDAL = new CM_CommodityDAL(); CM_Commodity CM_Commodity = new CM_Commodity(); CM_Commodity.BreedClassID = BreedClassID; CM_Commodity.GoerScale = decimal.MaxValue; CM_Commodity.LabelCommodityCode = null; CM_Commodity.StockPinYin = null; CM_Commodity.MarketDate = DateTime.Now.AddYears(-1); //暂时将日期定为一年前 DateTime.MaxValue; CM_Commodity.turnovervolume = null; CM_Commodity.IsExpired = (int)Types.IsYesOrNo.No; //初始化期货代码时,默认没有过期 CM_Commodity.ISSysDefaultCode = (int)Types.IsYesOrNo.Yes; //新增期货代码时,默认代码没有过期 QH_AgreementDeliveryMonthDAL AgreementDeliveryMonthDAL = new QH_AgreementDeliveryMonthDAL(); List <QH_AgreementDeliveryMonth> L = AgreementDeliveryMonthDAL.GetListArray(string.Format("BreedClassID={0}", BreedClassID)); foreach (QH_AgreementDeliveryMonth AgreementDeliveryMonth in L) { if ((int)AgreementDeliveryMonth.MonthID > System.DateTime.Now.Month && (int)AgreementDeliveryMonth.MonthID <= 12) { //string Code = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + // CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID); //使用代码规则管理器生成代码 string Code = codeRule.GetCode(QH_PrefixCode, DateTime.Now.Year.ToString(), CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID)); CM_Commodity.CommodityCode = Code; CM_Commodity.CommodityName = Code;// QH_breedclassName + Code.Substring(Code.Length - 4); CommodityDAL.Add(CM_Commodity); } if ((int)AgreementDeliveryMonth.MonthID < System.DateTime.Now.Month) { //string Code = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + // CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID); //使用代码规则管理器生成代码 string Code = codeRule.GetCode(QH_PrefixCode, DateTime.Now.AddYears(1).Year.ToString(), CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID)); CM_Commodity.CommodityCode = Code; CM_Commodity.CommodityName = Code;// QH_breedclassName + Code.Substring(Code.Length - 4); CommodityDAL.Add(CM_Commodity); } if ((int)AgreementDeliveryMonth.MonthID == System.DateTime.Now.Month) { int lasttradingday = CCP.GetLastTradingDay(CCP.GetLastTradingDayEntity(BreedClassID), BreedClassID); string Code = string.Empty; if (System.DateTime.Now.Day < lasttradingday) { // Code = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + //CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID); //使用代码规则管理器生成代码 Code = codeRule.GetCode(QH_PrefixCode, DateTime.Now.Year.ToString(), CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID)); } else { // Code = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + //CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID); //使用代码规则管理器生成代码 Code = codeRule.GetCode(QH_PrefixCode, DateTime.Now.AddYears(1).Year.ToString(), CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID)); } CM_Commodity.CommodityCode = Code; CM_Commodity.CommodityName = Code;// QH_breedclassName + Code.Substring(Code.Length - 4); CommodityDAL.Add(CM_Commodity); } if ((int)AgreementDeliveryMonth.MonthID == 13) { SpecialQHCodeInit(BreedClassID, QH_PrefixCode, QH_breedclassName); } } }
/// <summary> /// 期货代码更新 /// Update by: 董鹏 /// Update Date: 2010-03-10 /// Desc: 使用代码规则管理器生成代码 /// </summary> /// <param name="breedclass">品种ID</param> /// <param name="LastTradingDayEntity">期货最后交易日实体</param> public void QHCodeUpdata(int breedclass, QH_LastTradingDay LastTradingDayEntity) { try { //根据品种ID,找到品种的代码名称 string QH_Prefixname = GetQH_PrefixCodeByID(breedclass); //根据品种ID,找到品种的名称 string QH_breedclassName = GetBreedClassNameByID(breedclass); //根据品种获取交易所 CM_BreedClassBLL bc = new CM_BreedClassBLL(); CM_BourseTypeBLL bt = new CM_BourseTypeBLL(); var bourseType = bt.GetModel(bc.GetModel(breedclass).BourseTypeID.Value); //创建代码规则管理 CodeRulesManager codeRule; if (bourseType.CodeRulesType.HasValue) { LogHelper.WriteDebug("===开始自动生成代码,代码规则类型:" + bourseType.CodeRulesType.ToString()); codeRule = new CodeRulesManager((Types.CodeRulesType)bourseType.CodeRulesType.Value); } else { LogHelper.WriteDebug("===开始自动生成代码,没有获取到交易所对应的代码规则,交易所:" + bourseType.BourseTypeName); codeRule = new CodeRulesManager(null); } CM_CommodityDAL CommodityDAL = new CM_CommodityDAL(); RC_TradeCommodityAssignDAL TradeCommodityAssignDAL = new RC_TradeCommodityAssignDAL(); string Old_QH_codename; string New_QH_codename; if ((int)LastTradingDayEntity.LastTradingDayTypeID == (int)Types.QHLastTradingDayType.DeliMonthAgoMonthLastTradeDay) { //Old_QH_codename = QH_Prefixname + GetTwoLenYear(DateTime.Now) + // GetTwoLenMonth(DateTime.Now.AddMonths(1)); //New_QH_codename = QH_Prefixname + GetTwoLenYear(DateTime.Now.AddYears(1)) + // GetTwoLenMonth(DateTime.Now.AddMonths(1)); //使用代码规则管理器生成代码 Old_QH_codename = codeRule.GetCode(QH_Prefixname, DateTime.Now.Year.ToString(), DateTime.Now.AddMonths(1).Month.ToString().PadLeft(2, '0')); New_QH_codename = codeRule.GetCode(QH_Prefixname, DateTime.Now.AddYears(1).Year.ToString(), DateTime.Now.AddMonths(1).Month.ToString().PadLeft(2, '0')); } else { //Old_QH_codename = QH_Prefixname + GetTwoLenYear(DateTime.Now) + GetTwoLenMonth(DateTime.Now); //New_QH_codename = QH_Prefixname + GetTwoLenYear(DateTime.Now.AddYears(1)) + // GetTwoLenMonth(DateTime.Now); //使用代码规则管理器生成代码 Old_QH_codename = codeRule.GetCode(QH_Prefixname, DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString().PadLeft(2, '0')); New_QH_codename = codeRule.GetCode(QH_Prefixname, DateTime.Now.AddYears(1).Year.ToString(), DateTime.Now.Month.ToString().PadLeft(2, '0')); } CM_Commodity CM_Commodity = CommodityDAL.GetModel(Old_QH_codename); if (CM_Commodity == null) { CM_Commodity = new CM_Commodity(); } CM_Commodity.CommodityCode = New_QH_codename; CM_Commodity.MarketDate = DateTime.Parse(System.DateTime.Now.AddDays(1).ToShortDateString()); //若第二天是非交易日则顺延一天 add by 董鹏 2010-03-31 while (!JudgmentIsTrandingDay(CM_Commodity.MarketDate, breedclass)) { CM_Commodity.MarketDate = CM_Commodity.MarketDate.AddDays(1); } //根据确认结果 期货名称等于期货代码 CM_Commodity.CommodityName = New_QH_codename;// QH_breedclassName + New_QH_codename.Substring(New_QH_codename.Length - 4); CM_Commodity.BreedClassID = breedclass; CM_Commodity.GoerScale = decimal.MaxValue; CM_Commodity.LabelCommodityCode = null; CM_Commodity.StockPinYin = null; CM_Commodity.turnovervolume = null; CM_Commodity.IsExpired = (int)Types.IsYesOrNo.No; //新增期货代码时,默认代码没有过期 CM_Commodity.ISSysDefaultCode = (int)Types.IsYesOrNo.Yes; //新增期货代码时,默认是系统代码 #region old //bool _result = CommodityDAL.Add(CM_Commodity); //if (!_result) //{ // LogHelper.WriteDebug("添加代码失败"); // return; //} ////更新代码分配表 //TradeCommodityAssignDAL.Update(Old_QH_codename, New_QH_codename); ////CommodityDAL.Delete(Old_QH_codename); ////根据2009-7-22需求过期代码添加标识 //int isExpired = (int)Types.IsYesOrNo.Yes;//旧代码状态设置为过期 //bool _resultUpdate = CommodityDAL.Update(Old_QH_codename, isExpired); //if (!_resultUpdate) //{ // LogHelper.WriteDebug("更新代码失败"); //} ////调用把期货新增的代码自动添加到可交易商品_撮合机_分配表中的方法 //QHCodeAutoRCTradeCommodityAssign(New_QH_codename, breedclass); #endregion //前面的bool值实际上没有用处,改为直接抛出异常,并增加日志记录 update by 董鹏 2010-03-31 LogHelper.WriteDebug("===生成新代码:" + New_QH_codename); //添加新代码 CommodityDAL.Add(CM_Commodity); LogHelper.WriteDebug("===更新代码分配表"); //更新代码分配表 TradeCommodityAssignDAL.Update(Old_QH_codename, New_QH_codename); LogHelper.WriteDebug("===设置代码过期:" + Old_QH_codename); //旧代码状态设置为过期 int isExpired = (int)Types.IsYesOrNo.Yes; CommodityDAL.Update(Old_QH_codename, isExpired); LogHelper.WriteDebug("===将代码添加到撮合机分配表中"); //如果新代码未分配,将代码添加到撮合机分配表中 QHCodeAutoRCTradeCommodityAssign(New_QH_codename, breedclass); LogHelper.WriteDebug("===新代码:" + New_QH_codename + "完成生成并分配到撮合机,旧代码:" + Old_QH_codename + "完成从撮合机分配表中移除并设为过期。"); } catch (Exception ex) { string errCode = "GL-7002"; string errMsg = "执行更新方法QHCodeUpdata()失败"; //VTException exception = new VTException(errCode, errMsg, ex); //LogHelper.WriteError(exception.ToString(), exception.InnerException); LogHelper.WriteError(errCode + ":" + errMsg, ex); } }
/// <summary> /// 更新交易所类型 /// </summary> /// <param name="model">交易所类型实体</param> /// <returns></returns> public static bool UpdateCMBourseType(ManagementCenter.Model.CM_BourseType model) { CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); return(cM_BourseTypeBLL.UpdateCMBourseType(model)); }
/// <summary> /// 添加交易所类型和交易时间 /// </summary> /// <param name="cmBourseType">交易所类型实体</param> /// <param name="cmTradeTimeList">交易时间实体集合</param> /// <returns></returns> public static int AddCMBourseTypeAndTradeTime(CM_BourseType cmBourseType, List <CM_TradeTime> cmTradeTimeList) { CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); return(cM_BourseTypeBLL.AddCMBourseTypeAndTradeTime(cmBourseType, cmTradeTimeList)); }
/// <summary> /// 添加交易所类型 /// </summary> /// <param name="model">交易所类型实体</param> /// <returns></returns> public static int AddCMBourseType(ManagementCenter.Model.CM_BourseType model) { CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); return(cM_BourseTypeBLL.AddCMBourseType(model)); }
//================================ 交易所类型 ,交易所类型_交易时间,交易所类型_非交易日期方法 ================================ #region 获取交易所类型名称 /// <summary> /// 获取交易所类型名称 /// </summary> /// <returns></returns> public static DataSet GetBourseTypeName() { CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); return(cM_BourseTypeBLL.GetBourseTypeName()); }
/// <summary> /// 获取交易所类型的最大ID /// </summary> public static int GetCMBourseTypeMaxId() { CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); return(cM_BourseTypeBLL.GetCMBourseTypeMaxId()); }
/// <summary> /// 根据交易所类型ID获取交易所类型实体 /// </summary> /// <param name="BourseTypeID"></param> /// <returns></returns> public static Entity.CM_BourseType GetCMBourseTypeModel(int BourseTypeID) { CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); return(cM_BourseTypeBLL.GetModel(BourseTypeID)); }
/// <summary> /// 判断交易所名称是否已经存在 /// </summary> /// <param name="BourseTypeName">交易所名称</param> /// <returns></returns> public static bool IsExistBourseTypeName(string BourseTypeName) { CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); return(cM_BourseTypeBLL.IsExistBourseTypeName(BourseTypeName)); }
/// <summary> ///删除交易所类型及相关联的表 /// </summary> /// <param name="BourseTypeID">交易所类型ID</param> public static bool DeleteCMBourseTypeAbout(int BourseTypeID) { CM_BourseTypeBLL cM_BourseTypeBLL = new CM_BourseTypeBLL(); return(cM_BourseTypeBLL.DeleteCMBourseTypeAbout(BourseTypeID)); }