コード例 #1
0
        /// <summary>
        /// 确定按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (m_EditType == 1)
            {
                #region 添加操作
                try
                {
                    if (
                        FuturesManageCommon.ExistsFutureCosts(
                            ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex))
                    {
                        ShowMessageBox.ShowInformation("此品种的交易费用已存在!");
                        return;
                    }
                    QH_FutureCosts qH_FutureCosts = new QH_FutureCosts();

                    if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                    {
                        qH_FutureCosts.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    }
                    else
                    {
                        qH_FutureCosts.BreedClassID = AppGlobalVariable.INIT_INT;
                    }
                    qH_FutureCosts.CurrencyTypeID = ((UComboItem)this.cmbCurrencyTypeID.SelectedItem).ValueIndex;
                    qH_FutureCosts.CostType       = ((UComboItem)this.cmbCostType.SelectedItem).ValueIndex;
                    //if (this.cmbCostType.SelectedIndex == (int)GTA.VTS.Common.CommonObject.Types.FutrueCostType.TradeUnitCharge - 1)
                    //{
                    //    if (!string.IsNullOrEmpty(this.txtCost.Text))
                    //    {
                    //        if (InputTest.DecimalTest(this.txtCost.Text))
                    //        {
                    //            qH_FutureCosts.TradeUnitCharge = Convert.ToDecimal(this.txtCost.Text);
                    //        }
                    //        else
                    //        {
                    //            ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                    //            return;
                    //        }
                    //    }
                    //    else
                    //    {
                    //        //qH_FutureCosts.TradeUnitCharge = AppGlobalVariable.INIT_DECIMAL;
                    //        ShowMessageBox.ShowInformation("请填写手续费!");
                    //        return;
                    //    }
                    //}
                    //else
                    //{
                    if (!string.IsNullOrEmpty(this.txtCost.Text))
                    {
                        if (InputTest.DecimalTest(this.txtCost.Text))
                        {
                            qH_FutureCosts.TurnoverRateOfServiceCharge = Convert.ToDecimal(this.txtCost.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                            return;
                        }
                    }
                    else
                    {
                        //qH_FutureCosts.TurnoverRateOfServiceCharge = AppGlobalVariable.INIT_DECIMAL;
                        ShowMessageBox.ShowInformation("请填写手续费!");
                        return;
                    }
                    //}
                    m_Result = FuturesManageCommon.AddQHFutureCosts(qH_FutureCosts);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("添加成功!");
                        this.ClearAll();
                        this.QueryQHFutureCosts();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-6201";
                    string      errMsg    = "添加品种_期货_交易费用失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }
                #endregion
            }
            else if (m_EditType == 2)
            {
                #region 修改操作
                try
                {
                    QH_FutureCosts qH_FutureCosts = new QH_FutureCosts();
                    if (m_BreedClassID == AppGlobalVariable.INIT_INT)
                    {
                        ShowMessageBox.ShowInformation("请选择更新数据!");
                        return;
                    }
                    this.cmbBreedClassID.Enabled  = false;
                    qH_FutureCosts.BreedClassID   = m_BreedClassID;
                    qH_FutureCosts.BreedClassID   = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    qH_FutureCosts.CurrencyTypeID = ((UComboItem)this.cmbCurrencyTypeID.SelectedItem).ValueIndex;
                    qH_FutureCosts.CostType       = ((UComboItem)this.cmbCostType.SelectedItem).ValueIndex;

                    //if (this.cmbCostType.SelectedIndex == (int)GTA.VTS.Common.CommonObject.Types.FutrueCostType.TradeUnitCharge - 1)
                    //{
                    //    if (!string.IsNullOrEmpty(this.txtCost.Text))
                    //    {
                    //        if (InputTest.DecimalTest(this.txtCost.Text))
                    //        {
                    //            qH_FutureCosts.TradeUnitCharge = Convert.ToDecimal(this.txtCost.Text);
                    //        }
                    //        else
                    //        {
                    //            ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                    //            return;
                    //        }
                    //    }
                    //    else
                    //    {
                    //        //qH_FutureCosts.TradeUnitCharge = AppGlobalVariable.INIT_DECIMAL;
                    //        ShowMessageBox.ShowInformation("请填写手续费!");
                    //        return;
                    //    }
                    //}
                    //else
                    //{
                    if (!string.IsNullOrEmpty(this.txtCost.Text))
                    {
                        if (InputTest.DecimalTest(this.txtCost.Text))
                        {
                            qH_FutureCosts.TurnoverRateOfServiceCharge = Convert.ToDecimal(this.txtCost.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                            return;
                        }
                    }
                    else
                    {
                        //qH_FutureCosts.TurnoverRateOfServiceCharge = AppGlobalVariable.INIT_DECIMAL;
                        ShowMessageBox.ShowInformation("请填写手续费!");
                        return;
                    }
                    //}
                    m_Result = FuturesManageCommon.UpdateQHFutureCosts(qH_FutureCosts);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.cmbBreedClassID.Enabled = true;
                        this.ClearAll();
                        m_BreedClassID = AppGlobalVariable.INIT_INT;
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                    this.QueryQHFutureCosts();
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-6202";
                    string      errMsg    = "更新品种_期货_交易费用失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }
                #endregion
            }
        }