/// <summary> /// 根据现货交易商品品种_持仓限制表中的品种ID获取品种名称 /// </summary> /// <returns></returns> public DataSet GetSpotPositionBreedClassName() { try { XH_SpotPositionDAL xHSpotPositionDAL = new XH_SpotPositionDAL(); return(xHSpotPositionDAL.GetSpotPositionBreedClassName()); } catch (Exception ex) { string errCode = "GL-5656"; string errMsg = "根据现货交易商品品种_持仓限制表中的品种ID获取品种名称失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(null); } }
/// <summary> /// 根据品种ID,判断现货_交易商品品种_持仓限制记录是否已存在 /// </summary> /// <param name="BreedClassID"></param> /// <returns></returns> public bool ExistsXHSpotPosition(int BreedClassID) { try { XH_SpotPositionDAL xHSpotPositionDAL = new XH_SpotPositionDAL(); return(xHSpotPositionDAL.Exists(BreedClassID)); } catch (Exception ex) { string errCode = "GL-5650"; string errMsg = "根据品种ID,判断现货_交易商品品种_持仓限制记录是否已存在失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(false); } }
/// <summary> /// 获取所有现货_交易商品品种_持仓限制 /// </summary> /// <param name="BreedClassName">品种名称</param> /// <param name="pageNo">当前页</param> /// <param name="pageSize">显示记录数</param> /// <param name="rowCount">总行数</param> /// <returns></returns> public DataSet GetAllXHSpotPosition(string BreedClassName, int pageNo, int pageSize, out int rowCount) { try { XH_SpotPositionDAL xHSpotPositionDAL = new XH_SpotPositionDAL(); return(xHSpotPositionDAL.GetAllXHSpotPosition(BreedClassName, pageNo, pageSize, out rowCount)); } catch (Exception ex) { rowCount = AppGlobalVariable.INIT_INT; string errCode = "GL-5654"; string errMsg = "获取所有现货_交易商品品种_持仓限制失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(null); } }
/// <summary> ///根据品种标识,品种涨跌幅标识,品种有效申报标识,删除现货品种交易规则(规则相关表全部删除) /// </summary> /// <param name="BreedClassID">品种标识</param> ///// <param name="BreedClassHighLowID">品种涨跌幅标识</param> ///// <param name="BreedClassValidID">品种有效申报标识</param> /// <returns></returns> public bool DeleteSpotTradeRulesAboutAll(int BreedClassID) { XH_SpotTradeRulesDAL xHSpotTradeRulesDAL = new XH_SpotTradeRulesDAL(); XH_SpotPositionDAL xHSpotPositionDAL = new XH_SpotPositionDAL(); XH_SpotHighLowValueDAL xHSpotHighLowValueDAL = new XH_SpotHighLowValueDAL(); XH_ValidDeclareValueDAL xHValidDeclareValueDAL = new XH_ValidDeclareValueDAL(); //XH_MinChangePriceValueDAL xHMinChangePriceValueDAL = new XH_MinChangePriceValueDAL(); CM_FieldRangeDAL cMFieldRangeDAL = new CM_FieldRangeDAL(); XH_ValidDeclareTypeDAL xHValidDeclareTypeDAL = new XH_ValidDeclareTypeDAL(); XH_MinVolumeOfBusinessDAL xHMinVolumeOfBusinessDAL = new XH_MinVolumeOfBusinessDAL(); XH_SpotHighLowControlTypeDAL xHSpotHighLowControlTypeDAL = new XH_SpotHighLowControlTypeDAL(); CM_UnitConversionDAL cM_UnitConversionDAL = new CM_UnitConversionDAL(); DbConnection Conn = null; Database db = DatabaseFactory.CreateDatabase(); Conn = db.CreateConnection(); if (Conn.State != ConnectionState.Open) { Conn.Open(); } DbTransaction Tran = Conn.BeginTransaction(); try { int BreedClassHighLowID = AppGlobalVariable.INIT_INT; int BreedClassValidID = AppGlobalVariable.INIT_INT; XH_SpotTradeRules xHSpotTradeRules = new XH_SpotTradeRules(); xHSpotTradeRules = xHSpotTradeRulesDAL.GetModel(BreedClassID); if (xHSpotTradeRules != null) { if (!string.IsNullOrEmpty(xHSpotTradeRules.BreedClassHighLowID.ToString())) { BreedClassHighLowID = Convert.ToInt32(xHSpotTradeRules.BreedClassHighLowID); } if (!string.IsNullOrEmpty(xHSpotTradeRules.BreedClassValidID.ToString())) { BreedClassValidID = Convert.ToInt32(xHSpotTradeRules.BreedClassValidID); } if (BreedClassHighLowID != AppGlobalVariable.INIT_INT) { if (!xHSpotHighLowValueDAL.DeleteSpotHighLowValue(BreedClassHighLowID, Tran, db)) { Tran.Rollback(); return(false); } } if (BreedClassValidID != AppGlobalVariable.INIT_INT) { if (!xHValidDeclareValueDAL.DeleteVDeclareValue(BreedClassValidID, Tran, db)) { Tran.Rollback(); return(false); } } //if (!xHMinChangePriceValueDAL.Delete(BreedClassID, Tran, db)) //{ // Tran.Rollback(); // return false; //} //List<Model.XH_MinChangePriceValue> xhMinCHangePriceV = // xHMinChangePriceValueDAL.GetListArray(string.Format("BreedClassID={0}", BreedClassID), Tran, db); //foreach (Model.XH_MinChangePriceValue FieldRangeID in xhMinCHangePriceV) //{ // if (!cMFieldRangeDAL.Delete(FieldRangeID.FieldRangeID)) // { // Tran.Rollback(); // return false; // } //} if (!xHMinVolumeOfBusinessDAL.DeleteXHMinVolumeOfBusByBreedClassID(BreedClassID, Tran, db)) { Tran.Rollback(); return(false); } //添加删除现货单位换算 List <Model.CM_UnitConversion> cMUnitC = cM_UnitConversionDAL.GetListArray(string.Format("BreedClassID={0}", BreedClassID)); foreach (Model.CM_UnitConversion unitConversion in cMUnitC) { if (!cM_UnitConversionDAL.DeleteUnitConversionByBreedClassID(Convert.ToInt32(unitConversion.BreedClassID), Tran, db)) { Tran.Rollback(); return(false); } } if (!xHSpotTradeRulesDAL.Delete(BreedClassID, Tran, db)) { Tran.Rollback(); return(false); } if (!xHValidDeclareTypeDAL.DeleteValidDeclareType(BreedClassValidID, Tran, db)) { Tran.Rollback(); return(false); } if (!xHSpotHighLowControlTypeDAL.Delete(BreedClassHighLowID, Tran, db)) { Tran.Rollback(); return(false); } } Tran.Commit(); return(true); } catch (Exception ex) { Tran.Rollback(); string errCode = "GL-5202"; 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> /// 删除品种时,则根据品种ID,删除所有相关联的表 /// </summary> /// <param name="BreedClassID">品种ID</param> /// <returns></returns> public bool DeleteCMBreedClassALLAbout(int BreedClassID) { XH_SpotTradeRulesBLL xH_SpotTradeRulesBLL = new XH_SpotTradeRulesBLL(); QH_FuturesTradeRulesBLL qH_FuturesTradeRulesBLL = new QH_FuturesTradeRulesBLL(); QH_SIFPositionBLL qH_SIFPositionBLL = new QH_SIFPositionBLL(); CM_CommodityDAL cM_CommodityDAL = new CM_CommodityDAL(); CM_BreedClassDAL cMBreedClassDAL = new CM_BreedClassDAL(); CM_BreedClass cM_BreedClass = new CM_BreedClass(); XH_SpotPositionDAL xH_SpotPositionDAL = new XH_SpotPositionDAL(); UM_DealerTradeBreedClassDAL uM_DealerTradeBreedClassDAL = new UM_DealerTradeBreedClassDAL(); UM_DealerTradeBreedClass uM_DealerTradeBreedClass = new UM_DealerTradeBreedClass(); //QH_SIFPositionDAL qH_SIFPositionDAL=new QH_SIFPositionDAL();//股指期货持仓限制 //QH_SIFPosition qH_SIFPosition=new QH_SIFPosition(); QH_PositionLimitValueDAL qH_PositionLimitValueDAL = new QH_PositionLimitValueDAL(); //期货持仓限制 XH_SpotCostsDAL xH_SpotCostsDAL = new XH_SpotCostsDAL(); //现货交易费用 QH_FutureCostsDAL qH_FutureCostsDAL = new QH_FutureCostsDAL(); //期货交易费用 QH_CFBailScaleValueDAL qH_CFBailScaleValueDAL = new QH_CFBailScaleValueDAL(); //商品期货_保证金比例 HK_SpotTradeRulesBLL hK_SpotTradeRulesBLL = new HK_SpotTradeRulesBLL(); //港股交易规则BLL HK_SpotCostsDAL hK_SpotCostsDAL = new HK_SpotCostsDAL(); //港股交易费用 HK_CommodityDAL hK_CommodityDAL = new HK_CommodityDAL(); //港股交易商品 //期货保证金 add by 董鹏 2010-02-02 QH_SIFBailDAL qh_SIFBailDal = new QH_SIFBailDAL(); RC_TradeCommodityAssignDAL rC_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 { int NewBreedClassID = AppGlobalVariable.INIT_INT; //未分配品种ID //获取系统默认未分配品种的品种ID List <CM_BreedClass> cMBreedClassList = cMBreedClassDAL.GetListArray(string.Format("DeleteState={0}", (int)Types.IsYesOrNo.Yes)); if (cMBreedClassList.Count == 0) { return(false); } if (cMBreedClassList[0].ISSysDefaultBreed == (int)Types.IsYesOrNo.Yes) { NewBreedClassID = cMBreedClassList[0].BreedClassID; } cM_BreedClass = cMBreedClassDAL.GetModel(BreedClassID); if (cM_BreedClass == null) { return(false); } //删除撮合机里的代码 int ISHKBreedClassType = Convert.ToInt32(cM_BreedClass.ISHKBreedClassType); //是否港股类型 if (ISHKBreedClassType == (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.Yes) //当品种类型是港股时 { List <ManagementCenter.Model.HK_Commodity> hkCommodityList = hK_CommodityDAL.GetListArray(string.Format("BreedClassID={0}", BreedClassID)); if (hkCommodityList.Count > 0) { List <ManagementCenter.Model.RC_TradeCommodityAssign> rcTradeCommodityAssignList = rC_TradeCommodityAssignDAL.GetListArray(string.Format("CodeFormSource={0}", (int)Types.IsCodeFormSource.No)); if (rcTradeCommodityAssignList.Count > 0) { for (int i = 0; i < hkCommodityList.Count; i++) { for (int j = i; j < rcTradeCommodityAssignList.Count; j++) { if (hkCommodityList[i].HKCommodityCode == rcTradeCommodityAssignList[j].CommodityCode) { if (!rC_TradeCommodityAssignDAL.DeleteRCByCommodityCode(hkCommodityList[i].HKCommodityCode, Tran, db)) { Tran.Rollback(); return(false); } break; } } } } } } else if (ISHKBreedClassType == (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.No)//当其它品种类型是时) { List <ManagementCenter.Model.CM_Commodity> cmCommodityList = cM_CommodityDAL.GetListArray(string.Format("BreedClassID={0}", BreedClassID)); if (cmCommodityList.Count > 0) { List <ManagementCenter.Model.RC_TradeCommodityAssign> rcTradeCommodityAssignList = rC_TradeCommodityAssignDAL.GetListArray(string.Format("CodeFormSource={0}", (int)Types.IsCodeFormSource.Yes)); if (rcTradeCommodityAssignList.Count > 0) { for (int i = 0; i < cmCommodityList.Count; i++) { for (int j = i; j < rcTradeCommodityAssignList.Count; j++) { if (cmCommodityList[i].CommodityCode == rcTradeCommodityAssignList[j].CommodityCode) { if (!rC_TradeCommodityAssignDAL.DeleteRCByCommodityCode(cmCommodityList[i].CommodityCode, Tran, db)) { Tran.Rollback(); return(false); } break; } } } } } } //品种类型ID int breedClassType = Convert.ToInt32(cM_BreedClass.BreedClassTypeID); if (breedClassType == (int)GTA.VTS.Common.CommonObject.Types.BreedClassTypeEnum.Stock) { if (!xH_SpotTradeRulesBLL.DeleteSpotTradeRulesAboutAll(BreedClassID)) { Tran.Rollback(); return(false); } if (!xH_SpotPositionDAL.Delete(BreedClassID, Tran, db)) //删除持仓 { Tran.Rollback(); return(false); } if (!xH_SpotCostsDAL.Delete(BreedClassID, Tran, db)) //删除现货交易费用 { Tran.Rollback(); return(false); } } else if (breedClassType == (int)GTA.VTS.Common.CommonObject.Types.BreedClassTypeEnum.StockIndexFuture) { if (!qH_FuturesTradeRulesBLL.DeleteFuturesTradeRulesAboutAll(BreedClassID)) { Tran.Rollback(); return(false); } if (!qH_SIFPositionBLL.DeleteQHSIFPositionAndQHSIFBail(BreedClassID)) { Tran.Rollback(); return(false); } if (!qH_PositionLimitValueDAL.DeletePositionLimitVByBreedClassID(BreedClassID, Tran, db)) { Tran.Rollback(); return(false); } if (!qH_FutureCostsDAL.Delete(BreedClassID, Tran, db)) //删除期货交易费用 { Tran.Rollback(); return(false); } if (!qH_CFBailScaleValueDAL.DeleteCFBailScaleVByBreedClassID(BreedClassID, Tran, db))//删除商品期货_保证金比例 { Tran.Rollback(); return(false); } } else if (breedClassType == (int)GTA.VTS.Common.CommonObject.Types.BreedClassTypeEnum.HKStock) { if (!hK_SpotTradeRulesBLL.DeleteHKSpotTradeRulesAbout(BreedClassID)) { Tran.Rollback(); return(false); } if (!hK_SpotCostsDAL.Delete(BreedClassID, Tran, db)) //删除港股交易费用 { Tran.Rollback(); return(false); } if (!xH_SpotPositionDAL.Delete(BreedClassID, Tran, db)) //删除持仓 { Tran.Rollback(); return(false); } //根据品种ID,更新港股交易商品表中的品种ID( if (!hK_CommodityDAL.UpdateHKBreedClassID(BreedClassID, NewBreedClassID, Tran, db)) { Tran.Rollback(); return(false); } } if (breedClassType != (int)GTA.VTS.Common.CommonObject.Types.BreedClassTypeEnum.HKStock) { //根据品种ID,更新交易商品表中的品种ID( if (!cM_CommodityDAL.UpdateBreedClassID(BreedClassID, NewBreedClassID, Tran, db)) { Tran.Rollback(); return(false); } } //删除品种权限表记录 List <Model.UM_DealerTradeBreedClass> uMDealerTradeBreedClass = uM_DealerTradeBreedClassDAL.GetListArray(string.Format("BreedClassID={0}", BreedClassID)); foreach (Model.UM_DealerTradeBreedClass umDTradeBreedClass in uMDealerTradeBreedClass) { if (!uM_DealerTradeBreedClassDAL.DeleteDealerTradeByBreedClassID(Convert.ToInt32(umDTradeBreedClass.BreedClassID), Tran, db)) { Tran.Rollback(); return(false); } } //删除期货保证金记录 add by 董鹏 2010-02-02 if (!qh_SIFBailDal.Delete(BreedClassID, Tran, db)) { Tran.Rollback(); return(false); } if (!cMBreedClassDAL.Delete(BreedClassID, Tran, db)) { Tran.Rollback(); return(false); } Tran.Commit(); return(true); } catch (Exception ex) { Tran.Rollback(); string errCode = "GL-4115"; string errMsg = " 删除品种时,则根据品种ID,删除所有相关联的表失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(false); } finally { if (Conn.State == ConnectionState.Open) { Conn.Close(); } } }