Esempio n. 1
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;
            }
        }