/// <summary>
        /// 获取需要更新的期货交易规则数据
        /// </summary>
        /// <param name="handle"></param>
        private void UpdateFuturesTradeRules(int handle)
        {
            try
            {
                if (handle < 0)
                {
                    return;
                }
                //显示添加期货规则窗体
                AddFuturesTradeRulesUI addFuturesTradeRulesUI = new AddFuturesTradeRulesUI();
                addFuturesTradeRulesUI.EditType = (int)UITypes.EditTypeEnum.UpdateUI;
                DataRow _dr          = this.gdvFuturesTradeRulesSelect.GetDataRow(handle);
                int     breedClassID = Convert.ToInt32(_dr["BreedClassID"]);
                QH_FuturesTradeRules qHFuturesTradeRules = FuturesManageCommon.GetFuturesTradeRulesModel(breedClassID);
                addFuturesTradeRulesUI.QHFuturesTradeRules = qHFuturesTradeRules;

                if (addFuturesTradeRulesUI.ShowDialog(this) == DialogResult.OK)
                {
                    this.QueryFuturesTradeRules();
                    this.gdvFuturesTradeRulesSelect.FocusedRowHandle = handle;
                }
            }
            catch (Exception ex)
            {
                string      errCode   = "GL-5823";
                string      errMsg    = "获取需要更新的期货交易规则数据失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return;
            }
        }
コード例 #2
0
        //================================  事件 ================================

        #region 添加或修改期货交易规则UI的AddFuturesTradeRulesUI_Load

        /// <summary>
        /// 添加或修改期货交易规则UI的AddFuturesTradeRulesUI_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddFuturesTradeRulesUI_Load(object sender, EventArgs e)
        {
            try
            {
                if (EditType == (int)UITypes.EditTypeEnum.AddUI)
                {
                    m_QH_FuturesTradeRules = new QH_FuturesTradeRules();
                    this.btnAgreementDeliveryMonth.Enabled = false;
                }
                this.InitBindData();

                if (EditType == (int)UITypes.EditTypeEnum.UpdateUI)
                {
                    this.UpdateInitData();
                    this.btnAgreementDeliveryMonth.Text = "合约交割月份";
                    this.btnConsignQuantum.Text         = "交易规则委托量";
                    this.btnLastTradingDay.Text         = "最后交易日";
                    this.Text = "期货交易规则";
                    this.cmbBreedClassID.Enabled = false;
                }
                BindFuturesHighLowStopVText();
            }
            catch (Exception ex)
            {
                string      errCode   = "GL-5800";
                string      errMsg    = "添加或修改期货交易规则窗体加载失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return;
            }
        }
        /// <summary>
        /// 获取当前月份最后交易日
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static int GetLastTradingDay(string code)
        {
            //CM_Commodity commodity = CommonDataCacheProxy.Instanse.GetCacheCommodityByCode(code);
            //if (commodity == null || commodity.BreedClassID.HasValue == false)
            //{
            //    throw new VTException("IsExpireLastedTradeDate", "无法获取期货合约代码对应的商品");
            //}
            //CM_BreedClass cmBreedClass = CommonDataCacheProxy.Instanse.GetCacheCM_BreedClassByKey((int)commodity.BreedClassID);
            //if (cmBreedClass == null)
            //{
            //    throw new VTException("IsExpireLastedTradeDate", "无法获取期货合约代码对应的商品类型");
            //}

            QH_FuturesTradeRules qhFuturesTradeRules = GetQH_FuturesTradeRulesByCommodityCode(code);// FuturesTradeRules.GetFuturesTradeRulesByBreedClassID(cmBreedClass.BreedClassID);

            if (qhFuturesTradeRules == null)
            {
                throw new VTException("IsExpireLastedTradeDate", "无法获取期货商品类型对应的交易规则");
            }

            // QH_LastTradingDay qhLastTradingDay = ManagementCenterDataAgent.Instanse.GetFutureTradeRulesInstanse().GetLastTradingDayByLastTradingDayID((int)qhFuturesTradeRules.LastTradingDayID);
            QH_LastTradingDay qhLastTradingDay = CommonDataCacheProxy.Instanse.GetCacheQH_LastTradingDayByID((int)qhFuturesTradeRules.LastTradingDayID);

            if (qhLastTradingDay == null)
            {
                throw new VTException("IsExpireLastedTradeDate", "无法获取期货商品类型对应的最后交易日");
            }

            return(GetLastTradingDay(qhLastTradingDay, code));
        }
コード例 #4
0
        /// <summary>
        /// 获取期货的交割制度
        /// </summary>
        /// <param name="code">商品代码</param>
        /// <param name="fund">资金交割制度</param>
        /// <param name="agreement">股票交割制度</param>
        /// <param name="strMessage">错误信息</param>
        /// <returns>是否成功获取</returns>
        public bool GetDeliveryInstitution(string code, out int fund, out int agreement, ref string strMessage)
        {
            bool   result  = false;
            string errCode = "GT-8212";
            string errMsg  = "无法根据商品编码从管理中心获取对于的交割制度。";

            strMessage = errCode + ":" + errMsg;

            fund      = -1;
            agreement = -1;

            CM_BreedClass breedClass = MCService.CommonPara.GetBreedClassByCommodityCode(code);

            if (breedClass != null)
            {
                QH_FuturesTradeRules rules = GetFuturesTradeRulesByBreedClassID(breedClass.BreedClassID);
                if (rules != null)
                {
                    fund      = rules.FundDeliveryInstitution.Value;
                    agreement = rules.AgreementDeliveryInstitution.Value;
                    result    = true;
                }
            }

            return(result);
        }
コード例 #5
0
        /// <summary>
        /// 根据品种获取最后交易日实体
        /// </summary>
        /// <param name="breedclass"></param>
        /// <returns></returns>
        public QH_LastTradingDay GetLastTradingDayEntity(int breedclass)
        {
            QH_FuturesTradeRulesDAL FuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL();
            QH_LastTradingDayDAL    LastTradingDayDAL    = new QH_LastTradingDayDAL();
            QH_FuturesTradeRules    FuturesTradeRules    = FuturesTradeRulesDAL.GetModel(breedclass);
            QH_LastTradingDay       LastTradingDay       = LastTradingDayDAL.GetModel((int)FuturesTradeRules.LastTradingDayID);

            return(LastTradingDay);
        }
コード例 #6
0
        /// <summary>
        /// 得到期货前缀代号
        /// </summary>
        /// <param name="BreedClassID"></param>
        /// <returns></returns>
        public string GetQH_PrefixCodeByID(int BreedClassID)
        {
            QH_FuturesTradeRulesDAL FuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL();
            QH_FuturesTradeRules    FuturesTradeRules    = FuturesTradeRulesDAL.GetModel(BreedClassID);

            if (FuturesTradeRules == null)
            {
                return(string.Empty);
            }
            return(FuturesTradeRules.FutruesCode);
        }
コード例 #7
0
        /// <summary>
        /// 添加或修改期货交易规则
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                if (EditType == (int)UITypes.EditTypeEnum.AddUI)
                {
                    if (
                        FuturesManageCommon.ExistsFuturesTradeRules(
                            ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex))
                    {
                        ShowMessageBox.ShowInformation("此品种的交易规则已存在!");
                        return;
                    }
                }

                QH_FuturesTradeRules qH_FuturesTradeRules = new QH_FuturesTradeRules();
                if (QHFuturesTradeRules != null)
                {
                    ManagementCenter.Model.CommonClass.UtilityClass.CopyEntityToEntity(QHFuturesTradeRules,
                                                                                       qH_FuturesTradeRules);
                }

                if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                {
                    qH_FuturesTradeRules.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                }
                else
                {
                    qH_FuturesTradeRules.BreedClassID = AppGlobalVariable.INIT_INT;
                }
                qH_FuturesTradeRules.FundDeliveryInstitution      = 0; //根据2010。04。26需求界面上不显示;默认T+0//Convert.ToInt32(this.speFundDeliveryIns.EditValue);
                qH_FuturesTradeRules.AgreementDeliveryInstitution = 0; //根据2010。04。26需求界面上不显示;默认T+0
                // Convert.ToInt32(this.speAgreementDeliveryIns.EditValue);

                if (!string.IsNullOrEmpty(this.cmbHighLowStopScopeID.Text))
                {
                    qH_FuturesTradeRules.HighLowStopScopeID =
                        ((UComboItem)this.cmbHighLowStopScopeID.SelectedItem).ValueIndex;
                }
                else
                {
                    qH_FuturesTradeRules.HighLowStopScopeID = AppGlobalVariable.INIT_INT;
                }
                if (!string.IsNullOrEmpty(this.cmbMarketUnitID.Text))
                {
                    qH_FuturesTradeRules.MarketUnitID =
                        ((UComboItem)this.cmbMarketUnitID.SelectedItem).ValueIndex;
                }
                else
                {
                    qH_FuturesTradeRules.MarketUnitID = AppGlobalVariable.INIT_INT;
                }

                if (!string.IsNullOrEmpty(this.cmbPriceUnit.Text))
                {
                    qH_FuturesTradeRules.PriceUnit =
                        ((UComboItem)this.cmbPriceUnit.SelectedItem).ValueIndex;
                }
                else
                {
                    qH_FuturesTradeRules.PriceUnit = AppGlobalVariable.INIT_INT;
                }

                if (!string.IsNullOrEmpty(this.cmbUnitsID.Text))
                {
                    qH_FuturesTradeRules.UnitsID =
                        ((UComboItem)this.cmbUnitsID.SelectedItem).ValueIndex;
                }
                else
                {
                    qH_FuturesTradeRules.UnitsID = AppGlobalVariable.INIT_INT;
                }

                if (!string.IsNullOrEmpty(this.txtFutruesCode.Text))
                {
                    if ((InputTest.FetureTradeCodeTest(this.txtFutruesCode.Text)) && this.txtFutruesCode.Text.Length <= 2)
                    {
                        qH_FuturesTradeRules.FutruesCode = this.txtFutruesCode.Text;
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("代码简称需要大于或小于2位的大写字母!");
                        return;
                    }
                }
                else
                {
                    ShowMessageBox.ShowInformation("请填写代码简称!");
                    return;
                }

                if (!string.IsNullOrEmpty(this.txtUnitMultiple.Text))
                {
                    if (InputTest.DecimalTest(this.txtUnitMultiple.Text))
                    {
                        qH_FuturesTradeRules.UnitMultiple = Convert.ToDecimal(this.txtUnitMultiple.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                        return;
                    }
                }
                else
                {
                    //qH_FuturesTradeRules.UnitMultiple = AppGlobalVariable.INIT_DECIMAL;
                    ShowMessageBox.ShowInformation("转换比例不能为空!");
                    return;
                }
                if (!string.IsNullOrEmpty(this.txtLeastChangePrice.Text))
                {
                    if (InputTest.DecimalTest(this.txtLeastChangePrice.Text))
                    {
                        qH_FuturesTradeRules.LeastChangePrice = Convert.ToDecimal(this.txtLeastChangePrice.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                        return;
                    }
                }
                else
                {
                    ShowMessageBox.ShowInformation("最小变动价位不能为空!");
                    return;
                }
                if (!string.IsNullOrEmpty(this.txtHighLowStopScopeValue.Text))
                {
                    if (InputTest.DecimalTest(this.txtHighLowStopScopeValue.Text))
                    {
                        qH_FuturesTradeRules.HighLowStopScopeValue = Convert.ToDecimal(this.txtHighLowStopScopeValue.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                        return;
                    }
                }
                else
                {
                    //qH_FuturesTradeRules.HighLowStopScopeValue = AppGlobalVariable.INIT_DECIMAL;
                    ShowMessageBox.ShowInformation("涨跌幅不能为空!");
                    return;
                }
                if (!string.IsNullOrEmpty(this.txtNewBreedFPHighLowStopV.Text))
                {
                    //qH_FuturesTradeRules.NewBreedFuturesPactHighLowStopValue =
                    //    Convert.ToDecimal(this.txtNewBreedFPHighLowStopV.Text);
                    if (InputTest.DecimalTest(this.txtNewBreedFPHighLowStopV.Text))
                    {
                        qH_FuturesTradeRules.NewBreedFuturesPactHighLowStopValue = Convert.ToDecimal(this.txtNewBreedFPHighLowStopV.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                        return;
                    }
                }
                else
                {
                    //qH_FuturesTradeRules.NewBreedFuturesPactHighLowStopValue = AppGlobalVariable.INIT_DECIMAL;
                    if (m_DiffFuturesType)
                    {
                        ShowMessageBox.ShowInformation("季月合约上市首日涨跌幅不能为空!");
                        return;
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("新品种合约上市当日涨跌幅不能为空!");
                        return;
                    }
                }
                if (!string.IsNullOrEmpty(this.txtNewMonthFPactHighLowStopV.Text))
                {
                    //qH_FuturesTradeRules.NewMonthFuturesPactHighLowStopValue =
                    //    Convert.ToDecimal(this.txtNewMonthFPactHighLowStopV.Text);
                    if (InputTest.DecimalTest(this.txtNewMonthFPactHighLowStopV.Text))
                    {
                        qH_FuturesTradeRules.NewMonthFuturesPactHighLowStopValue = Convert.ToDecimal(this.txtNewMonthFPactHighLowStopV.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                        return;
                    }
                }
                else
                {
                    //qH_FuturesTradeRules.NewMonthFuturesPactHighLowStopValue = AppGlobalVariable.INIT_DECIMAL;
                    if (m_DiffFuturesType)
                    {
                        ShowMessageBox.ShowInformation("合约最后交易日涨跌幅不能为空!");
                        return;
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("新月份合约上市当日涨跌幅不能为空!");
                        return;
                    }
                }
                if (!string.IsNullOrEmpty(this.txtNewMonthFPactHighLowStopV.Text))
                {
                    //qH_FuturesTradeRules.NewMonthFuturesPactHighLowStopValue =
                    //    Convert.ToDecimal(this.txtNewMonthFPactHighLowStopV.Text);
                    if (InputTest.DecimalTest(this.txtNewMonthFPactHighLowStopV.Text))
                    {
                        qH_FuturesTradeRules.NewMonthFuturesPactHighLowStopValue = Convert.ToDecimal(this.txtNewMonthFPactHighLowStopV.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                        return;
                    }
                }
                else
                {
                    if (!m_DiffFuturesType)
                    {
                        ShowMessageBox.ShowInformation("合约最后交易日涨跌幅不能为空!");
                        return;
                    }
                }

                //判断交易规则委托量ID或最后交易日ID为空时提示添加交易规则委托量和最后交易日

                if (m_ConsignQuantumID != AppGlobalVariable.INIT_INT)
                {
                    qH_FuturesTradeRules.ConsignQuantumID = m_ConsignQuantumID;
                }
                else
                {
                    if (EditType == (int)UITypes.EditTypeEnum.AddUI)
                    {
                        ShowMessageBox.ShowInformation("请添加交易规则委托量!");
                    }
                    return;
                }
                if (m_LastTradingDayID != AppGlobalVariable.INIT_INT)
                {
                    qH_FuturesTradeRules.LastTradingDayID = m_LastTradingDayID;
                }
                else
                {
                    if (EditType == (int)UITypes.EditTypeEnum.AddUI)
                    {
                        ShowMessageBox.ShowInformation("请添加最后交易日!");
                    }
                    return;
                }
                #region 交割月涨跌幅 add by 董鹏 2010-01-21
                if (!string.IsNullOrEmpty(this.txtDeliveryMonthHighLowStopValue.Text))
                {
                    if (InputTest.DecimalTest(this.txtDeliveryMonthHighLowStopValue.Text))
                    {
                        qH_FuturesTradeRules.DeliveryMonthHighLowStopValue = Convert.ToDecimal(this.txtDeliveryMonthHighLowStopValue.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                        return;
                    }
                }
                #endregion
                if (EditType == (int)UITypes.EditTypeEnum.AddUI)
                {
                    m_Result = FuturesManageCommon.AddFuturesTradeRules(qH_FuturesTradeRules);
                    if (m_Result)
                    {
                        m_BreedClassID = Convert.ToInt32(qH_FuturesTradeRules.BreedClassID);
                        ShowMessageBox.ShowInformation("添加成功!");
                        this.btnAgreementDeliveryMonth.Enabled = true;
                        ShowMessageBox.ShowInformation("请继续添加合约交割月份!");
                        this.ClearAll();
                        AddOrUpdateUIAgreementDeliveryMonth();
                        //if(m_MonthID!=AppGlobalVariable.INIT_INT)
                        //{
                        //    this.DialogResult = DialogResult.OK;
                        //    this.Close();
                        //}
                    }
                    else
                    {
                        // bool testResult = false;
                        if (m_ConsignQuantumID != AppGlobalVariable.INIT_INT)
                        {
                            FuturesManageCommon.DeleteQHConsignQuantumAndSingle(m_ConsignQuantumID);
                        }
                        if (m_LastTradingDayID != AppGlobalVariable.INIT_INT)
                        {
                            FuturesManageCommon.DeleteQHLastTradingDay(m_LastTradingDayID);
                        }
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                else if (EditType == (int)UITypes.EditTypeEnum.UpdateUI)
                {
                    m_Result = FuturesManageCommon.UpdateFuturesTradeRules(qH_FuturesTradeRules);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                string      errCode   = "GL-5802";
                string      errMsg    = "添加或修改期货交易规则失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return;
            }
        }
コード例 #8
0
        /// <summary>
        ///根据品种标识,删除期货品种交易规则(规则相关表全部删除)
        /// </summary>
        /// <param name="BreedClassID">品种标识</param>
        /// <returns></returns>
        public bool DeleteFuturesTradeRulesAboutAll(int BreedClassID)
        {
            QH_FuturesTradeRulesDAL      qHFuturesTradeRulesDAL       = new QH_FuturesTradeRulesDAL();
            QH_AgreementDeliveryMonthDAL qH_AgreementDeliveryMonthDAL = new QH_AgreementDeliveryMonthDAL();
            QH_ConsignQuantumDAL         qH_ConsignQuantumDAL         = new QH_ConsignQuantumDAL();
            QH_SingleRequestQuantityDAL  qH_SingleRequestQuantityDAL  = new QH_SingleRequestQuantityDAL();
            QH_LastTradingDayDAL         qH_LastTradingDayDAL         = new QH_LastTradingDayDAL();

            DbConnection Conn = null;
            Database     db   = DatabaseFactory.CreateDatabase();

            Conn = db.CreateConnection();
            if (Conn.State != ConnectionState.Open)
            {
                Conn.Open();
            }
            DbTransaction Tran = Conn.BeginTransaction();

            try
            {
                int ConsignQuantumID = AppGlobalVariable.INIT_INT;
                int LastTradingDayID = AppGlobalVariable.INIT_INT;
                QH_FuturesTradeRules qHFuturesTradeRules = new QH_FuturesTradeRules();
                qHFuturesTradeRules = qHFuturesTradeRulesDAL.GetModel(BreedClassID);
                if (qHFuturesTradeRules != null)
                {
                    if (!string.IsNullOrEmpty(qHFuturesTradeRules.ConsignQuantumID.ToString()))
                    {
                        ConsignQuantumID = Convert.ToInt32(qHFuturesTradeRules.ConsignQuantumID);
                    }
                    if (!string.IsNullOrEmpty(qHFuturesTradeRules.LastTradingDayID.ToString()))
                    {
                        LastTradingDayID = Convert.ToInt32(qHFuturesTradeRules.LastTradingDayID);
                    }
                    if (ConsignQuantumID != AppGlobalVariable.INIT_INT)
                    {
                        if (!qH_SingleRequestQuantityDAL.DeleteSingleRQByConsignQuantumID(ConsignQuantumID, Tran, db))
                        {
                            Tran.Rollback();
                            return(false);
                        }
                    }


                    List <Model.QH_AgreementDeliveryMonth> qHAgreementDeliveryM =
                        qH_AgreementDeliveryMonthDAL.GetListArray(string.Format("BreedClassID={0}", BreedClassID), Tran,
                                                                  db);
                    foreach (Model.QH_AgreementDeliveryMonth MonthID in qHAgreementDeliveryM)
                    {
                        if (!qH_AgreementDeliveryMonthDAL.Delete((Int32)MonthID.MonthID, BreedClassID))  //?处理
                        {
                            Tran.Rollback();
                            return(false);
                        }
                    }

                    if (!qHFuturesTradeRulesDAL.Delete(BreedClassID, Tran, db))
                    {
                        Tran.Rollback();
                        return(false);
                    }

                    if (ConsignQuantumID != AppGlobalVariable.INIT_INT)
                    {
                        if (!qH_ConsignQuantumDAL.Delete(ConsignQuantumID, Tran, db))
                        {
                            Tran.Rollback();
                            return(false);
                        }
                    }
                    if (LastTradingDayID != AppGlobalVariable.INIT_INT)
                    {
                        if (!qH_LastTradingDayDAL.Delete(LastTradingDayID, Tran, db))
                        {
                            Tran.Rollback();
                            return(false);
                        }
                    }
                }
                Tran.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                Tran.Rollback();
                string      errCode   = "GL-6004";
                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();
                }
            }
        }