Ejemplo n.º 1
0
        //================================  私有  方法 ================================

        #region 设置查询实体对象

        /// <summary>
        /// 设置查询实体对象
        /// </summary>
        private bool SetQueryUserInfo()
        {
            if (QueryUserInfo == null)
            {
                QueryUserInfo = new UM_UserInfo();
            }
            if (this.txt_UserID.Text.Trim() == string.Empty)
            {
                QueryUserInfo.UserID = int.MaxValue;
            }
            else
            {
                if (InputTest.intTest(this.txt_UserID.Text.Trim()))
                {
                    QueryUserInfo.UserID = int.Parse(this.txt_UserID.Text.Trim());
                }
                else
                {
                    ShowMessageBox.ShowInformation("请输入正确的交易员编号!");
                    return(false);
                }
            }

            QueryUserInfo.LoginName = string.Empty;
            QueryUserInfo.RoleID    = (int)Types.RoleTypeEnum.Transaction;
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 设置查询实体对象
        /// </summary>
        private bool SetManagerQueryEntity()
        {
            if (managerQueryEntity == null)
            {
                managerQueryEntity = new ManagerQueryEntity();
            }
            if (this.txt_UserID.Text.Trim() == string.Empty)
            {
                managerQueryEntity.UserID = int.MaxValue;
            }
            else
            {
                if (InputTest.intTest(this.txt_UserID.Text.Trim()))
                {
                    managerQueryEntity.UserID = int.Parse(this.txt_UserID.Text.Trim());
                }
                else
                {
                    ShowMessageBox.ShowInformation("请输入正确的交易员编号!");
                    return(false);
                }
            }
            managerQueryEntity.LoginName = this.txt_LoginName.Text.Trim() != string.Empty
                                               ? this.txt_LoginName.Text.Trim()
                                               : string.Empty;

            managerQueryEntity.ManagerGroupName = this.txt_rightgroupname.Text.Trim() != string.Empty
                                                      ? this.txt_rightgroupname.Text.Trim()
                                                      : string.Empty;

            managerQueryEntity.ManagerGroupID = int.MaxValue;
            managerQueryEntity.UserName       = string.Empty;
            managerQueryEntity.RoleID         = (int)Types.RoleTypeEnum.Manager;
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 检测输入
        /// </summary>
        /// <returns></returns>
        public bool CheckInPut()
        {
            try
            {
                if (MatchCenter == null)
                {
                    MatchCenter = new RC_MatchCenter();
                }

                if (this.txt_CenterName.Text == string.Empty)
                {
                    ShowMessageBox.ShowInformation("请输入撮合中心名称!");
                    return(false);
                }
                MatchCenter.MatchCenterName = this.txt_CenterName.Text;
                if (this.txt_CenterIP.Text == string.Empty)
                {
                    ShowMessageBox.ShowInformation("请输入IP地址!");
                    return(false);
                }
                if (!InputTest.IPTest(this.txt_CenterIP.Text.Trim()))
                {
                    ShowMessageBox.ShowInformation("IP地址,输入有误,请重新输入!");
                    return(false);
                }
                MatchCenter.IP = this.txt_CenterIP.Text;
                if (!InputTest.intTest(this.txt_Port.Text))
                {
                    ShowMessageBox.ShowInformation("端口输入有误,请重新输入!");
                    return(false);
                }
                MatchCenter.Port = int.Parse(this.txt_Port.Text);
                if (this.txt_cuoheService.Text == string.Empty)
                {
                    ShowMessageBox.ShowInformation("请输入撮合服务的名称!");
                    return(false);
                }
                MatchCenter.CuoHeService = this.txt_cuoheService.Text;
                if (this.txt_xiadanService.Text == string.Empty)
                {
                    ShowMessageBox.ShowInformation("请输入下单服务的名称!");
                    return(false);
                }
                MatchCenter.XiaDanService = this.txt_xiadanService.Text;
                return(true);
            }
            catch (Exception ex)
            {
                string      errCode = "GL-2004";
                string      errMsg  = "检测输入失败";
                VTException vte     = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
                return(false);
            }
        }
 /// <summary>
 /// 检验港股品种交易规则的输入
 /// </summary>
 /// <param name="strMess">提示信息</param>
 /// <returns></returns>
 private HK_SpotTradeRules VerifyHKSpotTradeRules(ref string strMess)
 {
     try
     {
         HK_SpotTradeRules hK_SpotTradeRules = new HK_SpotTradeRules();
         strMess = string.Empty;
         if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
         {
             hK_SpotTradeRules.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
         }
         else
         {
             strMess = "请选择品种类型!";
         }
         hK_SpotTradeRules.FundDeliveryInstitution  = Convert.ToInt32(this.speFundDeliveryIns.EditValue);
         hK_SpotTradeRules.StockDeliveryInstitution = Convert.ToInt32(this.speStockDeliveryIns.EditValue);
         if (!string.IsNullOrEmpty(this.txtMaxLeaveQuantity.Text))
         {
             if (InputTest.intTest(this.txtMaxLeaveQuantity.Text))
             {
                 hK_SpotTradeRules.MaxLeaveQuantity = Convert.ToInt32(this.txtMaxLeaveQuantity.Text);
             }
             else
             {
                 strMess = "请输入数字且第一位数不能为0!";
             }
         }
         else
         {
             strMess = "每笔最大委托量不能为空!";
         }
         if (!string.IsNullOrEmpty(this.cmbPriceUnit.Text))
         {
             hK_SpotTradeRules.PriceUnit = ((UComboItem)this.cmbPriceUnit.SelectedItem).ValueIndex;
         }
         else
         {
             strMess = "计价单位不能为空!";
         }
         if (!string.IsNullOrEmpty(this.cmbMarketUnitID.Text))
         {
             hK_SpotTradeRules.MarketUnitID = ((UComboItem)this.cmbMarketUnitID.SelectedItem).ValueIndex;
         }
         else
         {
             strMess = "行情成交量单位不能为空!";
         }
         return(hK_SpotTradeRules);
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex.Message, ex);
         return(null);
     }
 }
        /// <summary>
        /// 设置查询实体对象
        /// </summary>
        private bool SetQueryUserInfo()
        {
            if (QueryUserInfo == null)
            {
                QueryUserInfo = new UM_UserInfo();
            }
            if (this.txt_UserID.Text.Trim() == string.Empty)
            {
                QueryUserInfo.UserID = int.MaxValue;
            }
            else
            {
                if (InputTest.intTest(this.txt_UserID.Text.Trim()))
                {
                    QueryUserInfo.UserID = int.Parse(this.txt_UserID.Text.Trim());
                }
                else
                {
                    ShowMessageBox.ShowInformation("请输入正确的交易员编号!");
                    return(false);
                }
            }

            QueryUserInfo.UserName = this.txt_Name.Text.Trim() != string.Empty
                                         ? this.txt_Name.Text.Trim()
                                         : string.Empty;

            //if (this.txt_CounterID.Text.Trim() == string.Empty)
            //{
            //    QueryUserInfo.CouterID = int.MaxValue;
            //}
            //else
            //{
            //    if (InputTest.intTest(this.txt_CounterID.Text.Trim()))
            //    {
            //        QueryUserInfo.CouterID = int.Parse(this.txt_CounterID.Text.Trim());
            //    }
            //    else
            //    {
            //        ShowMessageBox.ShowInformation("请输入正确的柜台编号!");
            //        return false;
            //    }
            //}
            //柜台名称
            QueryUserInfo.Name = this.txt_CounterName.Text.Trim() != string.Empty
                                         ? this.txt_CounterName.Text.Trim()
                                         : string.Empty;
            QueryUserInfo.LoginName = string.Empty;
            QueryUserInfo.RoleID    = (int)Types.RoleTypeEnum.Transaction;
            return(true);
        }
        /// <summary>
        /// 现货最小交易单位数据输入检测
        /// </summary>
        /// <param name="msg">提示信息</param>
        /// <returns></returns>
        private XH_MinVolumeOfBusiness VerifyXHMinVolumeOfBusInput(ref string msg)
        {
            try
            {
                msg = string.Empty;
                XH_MinVolumeOfBusiness xH_MinVolumeOfBusiness = new XH_MinVolumeOfBusiness();

                if (!string.IsNullOrEmpty(this.txtVolumeOfBusiness.Text))
                {
                    if (InputTest.intTest(this.txtVolumeOfBusiness.Text))
                    {
                        xH_MinVolumeOfBusiness.VolumeOfBusiness =
                            Convert.ToInt32(this.txtVolumeOfBusiness.Text);
                    }
                    else
                    {
                        msg = "请输入数字且第一位数不能为0!";
                    }
                }
                else
                {
                    msg = "最小交易量不能为空!";
                }
                xH_MinVolumeOfBusiness.BreedClassID =
                    ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                xH_MinVolumeOfBusiness.UnitID =
                    ((UComboItem)this.cmbUnitID.SelectedItem).ValueIndex;
                xH_MinVolumeOfBusiness.TradeWayID =
                    ((UComboItem)this.cmbTradeWayID.SelectedItem).ValueIndex;
                if (EditType == (int)UITypes.EditTypeEnum.UpdateUI)
                {
                    xH_MinVolumeOfBusiness.MinVolumeOfBusinessID = m_MinVolumeOfBusinessID;
                }
                return(xH_MinVolumeOfBusiness);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex.Message, ex);
                return(null);
            }
        }
 /// <summary>
 /// 现货单位换算数据输入检测
 /// </summary>
 /// <param name="msg">提示信息</param>
 /// <returns></returns>
 private CM_UnitConversion VerifyUnitConversionInput(ref string msg)
 {
     try
     {
         msg = string.Empty;
         CM_UnitConversion cM_UnitConversion = new CM_UnitConversion();
         if (!string.IsNullOrEmpty(this.txtValue.Text))
         {
             if (InputTest.intTest(this.txtValue.Text))
             {
                 cM_UnitConversion.Value = Convert.ToInt32(this.txtValue.Text);
             }
             else
             {
                 msg = "请输入数字且第一位数不能为0!";
             }
         }
         else
         {
             msg = "比例不能为空!";
         }
         cM_UnitConversion.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
         cM_UnitConversion.UnitIDFrom   = ((UComboItem)this.cmbUnitIDFrom.SelectedItem).ValueIndex;
         cM_UnitConversion.UnitIDTo     = ((UComboItem)this.cmbUnitIDTo.SelectedItem).ValueIndex;
         if (EditType == (int)UITypes.EditTypeEnum.UpdateUI)
         {
             cM_UnitConversion.UnitConversionID = m_UnitConversionID;
         }
         return(cM_UnitConversion);
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex.Message, ex);
         return(null);
     }
 }
 /// <summary>
 /// 数据检测
 /// </summary>
 /// <returns></returns>
 public bool CheckData()
 {
     try
     {
         DataTable editData = ds.Tables[0];
         for (int i = 0; i < editData.Rows.Count; i++)
         {
             if (!InputTest.intTest(editData.Rows[i]["MachineNo"].ToString()))
             {
                 ShowMessageBox.ShowInformation("请为每个交易所分配正确的撮合机个数!");
                 return(false);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         string      errCode = "GL-2053";
         string      errMsg  = "数据检测失败";
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         return(false);
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 确定按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            //根据状态进行操作 1:添加  2:修改
            if (m_EditType == 1)
            {
                #region 添加操作

                try
                {
                    CM_Commodity cM_Commodity = new CM_Commodity();

                    if (!string.IsNullOrEmpty(this.txtCommodityCode.Text))
                    {
                        if (!CommonParameterSetCommon.IsExistCommodityCode(this.txtCommodityCode.Text))
                        {
                            ShowMessageBox.ShowInformation("代码已经存在!");
                            return;
                        }
                        if (InputTest.zeroXHAndQHStartIntTest(this.txtCommodityCode.Text))
                        {
                            if (this.txtCommodityCode.Text.Length == 6 || this.txtCommodityCode.Text.Length == 5)
                            {
                                cM_Commodity.CommodityCode = this.txtCommodityCode.Text;
                            }
                            else
                            {
                                ShowMessageBox.ShowInformation("代码长度是5或6!");
                                return;
                            }
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入期货代码简称+数字或6个数字!");
                            return;
                        }
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请输入代码!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtCommodityName.Text))
                    {
                        if (!CommonParameterSetCommon.IsExistCommodityName(this.txtCommodityName.Text))
                        {
                            ShowMessageBox.ShowInformation("代码名称已经存在!");
                            return;
                        }
                        cM_Commodity.CommodityName = this.txtCommodityName.Text;
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请输入代码名称!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                    {
                        cM_Commodity.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    }
                    else
                    {
                        //cM_Commodity.BreedClassID = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("请选择品种类型!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.txtLabelCommodityCode.Text))
                    {
                        cM_Commodity.LabelCommodityCode = this.txtLabelCommodityCode.Text;
                    }
                    else
                    {
                        cM_Commodity.LabelCommodityCode = AppGlobalVariable.INIT_STRING;
                    }

                    if (!string.IsNullOrEmpty(this.txtGoerScale.Text))
                    {
                        cM_Commodity.GoerScale = Convert.ToDecimal(this.txtGoerScale.Text);
                    }
                    else
                    {
                        cM_Commodity.GoerScale = AppGlobalVariable.INIT_DECIMAL;
                    }
                    //if (!string.IsNullOrEmpty(this.txtStockPinYin.Text))
                    //{
                    //cM_Commodity.StockPinYin = this.txtStockPinYin.Text;
                    //}
                    //else
                    //{
                    //    cM_Commodity.StockPinYin = AppGlobalVariable.INIT_STRING;
                    //    //ShowMessageBox.ShowInformation("拼音简称不能为空!");
                    //    //return;
                    //}

                    if (!string.IsNullOrEmpty(this.txtStockPinYin.Text))
                    {
                        if (m_DiffBreeadClassType)
                        {
                            cM_Commodity.StockPinYin = this.txtStockPinYin.Text;
                        }
                        else
                        {
                            cM_Commodity.StockPinYin = AppGlobalVariable.INIT_STRING;
                        }
                    }
                    else
                    {
                        if (m_DiffBreeadClassType)
                        {
                            ShowMessageBox.ShowInformation("拼音简称不能为空!");
                            return;
                        }
                        else
                        {
                            cM_Commodity.StockPinYin = AppGlobalVariable.INIT_STRING; //期货时此值为空
                        }
                    }

                    if (!string.IsNullOrEmpty(this.dtMarketDate.Text))
                    {
                        cM_Commodity.MarketDate = Convert.ToDateTime(this.dtMarketDate.Text);
                    }
                    else
                    {
                        //cM_Commodity.MarketDate = AppGlobalVariable.INIT_DATETIME;
                        ShowMessageBox.ShowInformation("请选择上市日期!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.txtturnovervolume.Text))
                    {
                        if (m_DiffBreeadClassType)
                        {
                            if (InputTest.intTest(this.txtturnovervolume.Text))
                            {
                                cM_Commodity.turnovervolume = Convert.ToDouble(this.txtturnovervolume.Text);
                            }
                            else
                            {
                                ShowMessageBox.ShowInformation("请输入正整数!");
                                return;
                            }
                        }
                        else
                        {
                            cM_Commodity.turnovervolume = null; //期货时此值为空
                        }
                    }
                    else
                    {
                        if (m_DiffBreeadClassType)
                        {
                            ShowMessageBox.ShowInformation("请输入流通股数!");
                            return;
                        }
                        else
                        {
                            cM_Commodity.turnovervolume = null; //期货时此值为空
                        }
                    }
                    cM_Commodity.IsExpired = AppGlobalVariable.INIT_INT; //默认int初始值
                    // cM_Commodity.ISSysDefaultCode = AppGlobalVariable.INIT_INT;//用户添加的代码不是系统默认代码
                    cM_Commodity.ISSysDefaultCode = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.No;
                    //用户添加的代码不是系统默认代码
                    m_Result = CommonParameterSetCommon.AddCMCommodity(cM_Commodity);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("添加成功!");
                        this.ClearAll();
                        this.QueryCMCommodity();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-4201";
                    string      errMsg    = "添加交易商品失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }

                #endregion
            }
            else if (m_EditType == 2)
            {
                #region 修改商品操作

                try
                {
                    CM_Commodity cM_Commodity = new CM_Commodity();

                    if (string.IsNullOrEmpty(this.txtCommodityCode.Text))
                    {
                        ShowMessageBox.ShowInformation("请选择更新数据!");
                        return;
                    }
                    cM_Commodity.CommodityCode = this.txtCommodityCode.Text;
                    if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                    {
                        cM_Commodity.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    }
                    else
                    {
                        //cM_Commodity.BreedClassID = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("请选择品种类型!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(dtMarketDate.Text))
                    {
                        cM_Commodity.MarketDate = dtMarketDate.DateTime;
                    }
                    cM_Commodity.IsExpired = AppGlobalVariable.INIT_INT; //默认int初始值
                    //cM_Commodity.ISSysDefaultCode = AppGlobalVariable.INIT_INT;//用户添加的代码不是系统默认代码
                    cM_Commodity.ISSysDefaultCode = m_ISSysDefaultCode;  //当是修改时不改变原来的系统默认代码默认值
                    m_Result = CommonParameterSetCommon.UpdateCMCommodity(cM_Commodity);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.ClearAll();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                    m_ISSysDefaultCode = AppGlobalVariable.INIT_INT;
                    this.QueryCMCommodity();
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-4203";
                    string      errMsg    = "修改交易商品失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }

                #endregion
            }
        }
        /// <summary>
        /// 添加或修改(商品)期货持仓限制
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                QH_PositionLimitValue qH_PositionLimitValue = new QH_PositionLimitValue();

                if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                {
                    qH_PositionLimitValue.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                }
                else
                {
                    ShowMessageBox.ShowInformation("请选择品种!");
                    this.cmbBreedClassID.Focus();
                    return;
                }
                if (!string.IsNullOrEmpty(this.txtStart.Text) && !string.IsNullOrEmpty(this.txtEnds.Text))
                {
                    if (InputTest.zeroStartIntTest(this.txtStart.Text) && InputTest.intTest(this.txtEnds.Text))
                    {
                        if (Convert.ToInt32(this.txtStart.Text) < Convert.ToInt32(this.txtEnds.Text))
                        {
                            qH_PositionLimitValue.Start = Convert.ToInt32(this.txtStart.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("起始值不能大于或等于结束值!");
                            this.txtStart.Focus();
                            return;
                        }
                        if (Convert.ToInt32(this.txtEnds.Text) > Convert.ToInt32(this.txtStart.Text))
                        {
                            qH_PositionLimitValue.Ends = Convert.ToInt32(this.txtEnds.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("结束值不能小于或等于起始值!");
                            this.txtEnds.Focus();
                            return;
                        }
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请输入数字!");
                        this.txtStart.Focus();
                        this.txtEnds.Focus();
                        return;
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(this.txtStart.Text) && string.IsNullOrEmpty(this.txtEnds.Text))
                    {
                        ShowMessageBox.ShowInformation("范围值不能为空!");
                        this.txtStart.Focus();
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtStart.Text))
                    {
                        if (InputTest.zeroStartIntTest(this.txtStart.Text))
                        {
                            qH_PositionLimitValue.Start = Convert.ToInt32(this.txtStart.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入数字!");
                            this.txtStart.Focus();
                            return;
                        }
                    }
                    if (!string.IsNullOrEmpty(this.txtEnds.Text))
                    {
                        if (InputTest.intTest(this.txtEnds.Text))
                        {
                            qH_PositionLimitValue.Ends = Convert.ToInt32(this.txtEnds.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入数字!");
                            this.txtEnds.Focus();
                            return;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(this.txtPositionValue.Text))
                {
                    if (InputTest.DecimalTest(this.txtPositionValue.Text))
                    {
                        qH_PositionLimitValue.PositionValue = Convert.ToDecimal(this.txtPositionValue.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请输入数字!");
                        this.txtPositionValue.Focus();
                        return;
                    }
                }
                else
                {
                    ShowMessageBox.ShowInformation("请输入持仓!");
                    this.txtPositionValue.Focus();
                    return;
                }

                if (!string.IsNullOrEmpty(this.cmbDeliveryMonthTypeID.Text))
                {
                    qH_PositionLimitValue.DeliveryMonthType = ((UComboItem)this.cmbDeliveryMonthTypeID.SelectedItem).ValueIndex;
                }
                else
                {
                    qH_PositionLimitValue.DeliveryMonthType = AppGlobalVariable.INIT_INT;
                }
                if (checkBox2.Checked)
                {
                    qH_PositionLimitValue.LowerLimitIfEquation = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.Yes;
                }
                else
                {
                    qH_PositionLimitValue.LowerLimitIfEquation = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.No;
                }
                if (checkBox3.Checked)
                {
                    qH_PositionLimitValue.UpperLimitIfEquation = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.Yes;
                }
                else
                {
                    qH_PositionLimitValue.UpperLimitIfEquation = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.No;
                }

                if (!string.IsNullOrEmpty(this.cmbPositionBailTypeID.Text))
                {
                    qH_PositionLimitValue.PositionBailTypeID = ((UComboItem)this.cmbPositionBailTypeID.SelectedItem).ValueIndex;
                }
                if (radioButton1.Checked)
                {
                    qH_PositionLimitValue.PositionValueTypeID = (int)GTA.VTS.Common.CommonObject.Types.QHPositionValueType.Positions;
                }
                if (radioButton2.Checked)
                {
                    qH_PositionLimitValue.PositionValueTypeID = (int)GTA.VTS.Common.CommonObject.Types.QHPositionValueType.Scales;
                }
                //if (!string.IsNullOrEmpty(this.cmbPositionValueTypeID.Text))
                //{
                //    qH_PositionLimitValue.PositionValueTypeID = ((UComboItem)this.cmbPositionValueTypeID.SelectedItem).ValueIndex;
                //}
                //else
                //{
                //    qH_PositionLimitValue.PositionValueTypeID = AppGlobalVariable.INIT_INT;
                //}
                //if (!string.IsNullOrEmpty(this.cmbPositionLimitType.Text))
                //{
                //    qH_PositionLimitValue.PositionLimitType = ((UComboItem)this.cmbPositionLimitType.SelectedItem).ValueIndex;
                //}
                if (checkBox1.Checked)
                {
                    int minUnit;
                    int.TryParse(txtMinUnit.Text, out minUnit);
                    if (string.IsNullOrEmpty(txtMinUnit.Text) || minUnit == 0)
                    {
                        ShowMessageBox.ShowInformation("请输入最小交割单位!");
                        this.txtMinUnit.Focus();
                        return;
                    }
                    qH_PositionLimitValue.MinUnitLimit = Convert.ToInt32(txtMinUnit.Text);
                }
                else
                {
                    qH_PositionLimitValue.MinUnitLimit = null;
                }

                if (EditType == (int)UITypes.EditTypeEnum.AddUI)
                {
                    int result = FuturesManageCommon.AddQHPositionLimitValue(qH_PositionLimitValue);
                    if (result != AppGlobalVariable.INIT_INT)
                    {
                        FireSaved(this, new EventArgs());
                        ShowMessageBox.ShowInformation("添加成功!");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                else if (EditType == (int)UITypes.EditTypeEnum.UpdateUI)
                {
                    if (m_PositionLimitValueID != AppGlobalVariable.INIT_INT)
                    {
                        qH_PositionLimitValue.PositionLimitValueID = m_PositionLimitValueID;
                    }
                    m_Result = FuturesManageCommon.UpdateQHPositionLimitValue(qH_PositionLimitValue);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                string      errCode   = "GL-6422";
                string      errMsg    = "添加或修改(商品)期货持仓限制失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return;
            }
        }
        /// <summary>
        /// 添加或修改现货交易规则  btnOK_Click
        /// </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 (
                        SpotManageCommon.ExistsSpotTradeRules(
                            ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex))
                    {
                        ShowMessageBox.ShowInformation("此品种的交易规则已存在!");
                        return;
                    }
                }

                XH_SpotTradeRules xH_SpotTradeRules = new XH_SpotTradeRules();
                if (XHSpotTradeRules != null)
                {
                    ManagementCenter.Model.CommonClass.UtilityClass.CopyEntityToEntity(XHSpotTradeRules,
                                                                                       xH_SpotTradeRules);
                }

                if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                {
                    xH_SpotTradeRules.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                }
                else
                {
                    xH_SpotTradeRules.BreedClassID = AppGlobalVariable.INIT_INT;
                }
                xH_SpotTradeRules.FundDeliveryInstitution  = Convert.ToInt32(this.speFundDeliveryIns.EditValue);
                xH_SpotTradeRules.StockDeliveryInstitution = Convert.ToInt32(this.speStockDeliveryIns.EditValue);

                //if (!string.IsNullOrEmpty(this.cmbMinChangePriceVType.Text))
                //{
                xH_SpotTradeRules.ValueTypeMinChangePrice = (int)GTA.VTS.Common.CommonObject.Types.GetValueTypeEnum.Single;
                //        ((UComboItem) this.cmbMinChangePriceVType.SelectedItem).ValueIndex;
                //}
                //else
                //{
                //    xH_SpotTradeRules.ValueTypeMinChangePrice = AppGlobalVariable.INIT_INT;
                //}
                if (!string.IsNullOrEmpty(this.txtMinChangePrice.Text))
                {
                    if (InputTest.DecimalTest(this.txtMinChangePrice.Text))
                    {
                        xH_SpotTradeRules.MinChangePrice = Convert.ToDecimal(this.txtMinChangePrice.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                        return;
                    }
                }
                else
                {
                    //if ((int) CommonObject.Types.GetValueTypeEnum.Single ==
                    //    ((UComboItem) this.cmbMinChangePriceVType.SelectedItem).ValueIndex)
                    //{
                    //    this.txtMinChangePrice.Enabled = true;
                    ShowMessageBox.ShowInformation("最小变动价位不能为空!");
                    return;
                    //}
                    //this.txtMinChangePrice.Enabled = false;
                    //xH_SpotTradeRules.MinChangePrice = 0; //最小变动价位=0时说明是范围值// AppGlobalVariable.INIT_INT; //money类型
                }
                if (!string.IsNullOrEmpty(this.txtMaxLeaveQuantity.Text))
                {
                    if (InputTest.intTest(this.txtMaxLeaveQuantity.Text))
                    {
                        xH_SpotTradeRules.MaxLeaveQuantity = Convert.ToInt32(this.txtMaxLeaveQuantity.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请输入数字且第一位数不能为0!");
                        return;
                    }
                }
                else
                {
                    //xH_SpotTradeRules.MaxLeaveQuantity = AppGlobalVariable.INIT_INT;
                    ShowMessageBox.ShowInformation("每笔最大委托量不能为空!");
                    return;
                }
                //if (!string.IsNullOrEmpty(this.cmbMaxLeaveQuantityUnit.Text))
                //根据20009.05.15界面修改确认结果 计价单位赋给每笔最大委托量单,每笔最大委托量单位在界面上不显示
                if (!string.IsNullOrEmpty(this.cmbPriceUnit.Text))
                {
                    xH_SpotTradeRules.MaxLeaveQuantityUnit =
                        ((UComboItem)this.cmbPriceUnit.SelectedItem).ValueIndex;
                }
                else
                {
                    xH_SpotTradeRules.MaxLeaveQuantityUnit = AppGlobalVariable.INIT_INT;
                }
                if (!string.IsNullOrEmpty(this.cmbPriceUnit.Text))
                {
                    xH_SpotTradeRules.PriceUnit = ((UComboItem)this.cmbPriceUnit.SelectedItem).ValueIndex;
                }
                else
                {
                    xH_SpotTradeRules.PriceUnit = AppGlobalVariable.INIT_INT;
                }
                if (!string.IsNullOrEmpty(this.cmbMarketUnitID.Text))
                {
                    xH_SpotTradeRules.MarketUnitID = ((UComboItem)this.cmbMarketUnitID.SelectedItem).ValueIndex;
                }
                else
                {
                    xH_SpotTradeRules.MarketUnitID = AppGlobalVariable.INIT_INT;
                }

                //根据20009.05.15界面修改确认结果 最小交易单位倍数在界面上不显示。此值从最小交易单位管理界面中已存在
                xH_SpotTradeRules.MinVolumeMultiples = 0;
                //判断品种涨跌幅ID或品种有效申报ID为空时提示添加品种涨跌幅和品种有效申报

                if (m_BreedClassHighLowID != AppGlobalVariable.INIT_INT && m_BreedClassValidID != AppGlobalVariable.INIT_INT)
                {
                    xH_SpotTradeRules.BreedClassHighLowID = m_BreedClassHighLowID;
                    xH_SpotTradeRules.BreedClassValidID   = m_BreedClassValidID;
                }
                else
                {
                    if (EditType == (int)UITypes.EditTypeEnum.AddUI)
                    {
                        ShowMessageBox.ShowInformation("请添加涨跌幅!");
                        return;
                    }
                }

                if (EditType == (int)UITypes.EditTypeEnum.AddUI)
                {
                    m_Result = SpotManageCommon.AddXHSpotTradeRules(xH_SpotTradeRules);
                    if (m_Result)
                    {
                        m_ValueType    = Convert.ToInt32(xH_SpotTradeRules.ValueTypeMinChangePrice);
                        m_BreedClassID = Convert.ToInt32(xH_SpotTradeRules.BreedClassID);
                        ShowMessageBox.ShowInformation("添加成功!");
                        this.ClearAll();
                    }
                    else
                    {
                        if (m_BreedClassValidID != AppGlobalVariable.INIT_INT)
                        {
                            SpotManageCommon.DeleteValidDeclareValue(m_BreedClassValidID);
                        }
                        if (m_BreedClassHighLowID != AppGlobalVariable.INIT_INT)
                        {
                            SpotManageCommon.DeleteSpotHighLowValue(m_BreedClassHighLowID);
                        }
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                else if (EditType == (int)UITypes.EditTypeEnum.UpdateUI)
                {
                    m_Result = SpotManageCommon.UpdateSpotTradeRules(xH_SpotTradeRules);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                string      errCode   = "GL-5001";
                string      errMsg    = "添加或修改现货交易规则失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return;
            }
        }
        /// <summary>
        /// 确定按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (m_EditType == 1)
            {
                #region 添加操作

                try
                {
                    CM_CommodityFuse cM_CommodityFuse = new CM_CommodityFuse();
                    if (CommonParameterSetCommon.ExistsCommodityCode(this.cmbCommodityCode.Text))
                    {
                        ShowMessageBox.ShowInformation("此代码的熔断已存在!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.cmbCommodityCode.Text))
                    {
                        cM_CommodityFuse.CommodityCode = this.cmbCommodityCode.SelectedItem.ToString();
                    }
                    else
                    {
                        //cM_CommodityFuse.CommodityCode = AppGlobalVariable.INIT_STRING;
                        ShowMessageBox.ShowInformation("请选择代码!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.txTriggeringScale.Text))
                    {
                        //cM_CommodityFuse.TriggeringScale = Convert.ToDecimal(this.txTriggeringScale.Text);
                        if (InputTest.DecimalTest(this.txTriggeringScale.Text))
                        {
                            cM_CommodityFuse.TriggeringScale = Convert.ToDecimal(this.txTriggeringScale.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入数字或小数点!");
                            return;
                        }
                    }
                    else
                    {
                        //cM_CommodityFuse.TriggeringScale = AppGlobalVariable.INIT_DECIMAL;
                        ShowMessageBox.ShowInformation("触发比例不能为空!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtFuseTimeOfDay.Text))
                    {
                        if (InputTest.intTest(this.txtFuseTimeOfDay.Text))
                        {
                            cM_CommodityFuse.FuseTimeOfDay = Convert.ToInt32(this.txtFuseTimeOfDay.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入整数!");
                            return;
                        }
                    }
                    else
                    {
                        // cM_CommodityFuse.FuseTimeOfDay = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("熔断次数不能为空!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtTriggeringDuration.Text))
                    {
                        //cM_CommodityFuse.TriggeringDuration = Convert.ToInt32(this.txtTriggeringDuration.Text);
                        if (InputTest.intTest(this.txtTriggeringDuration.Text))
                        {
                            cM_CommodityFuse.TriggeringDuration = Convert.ToInt32(this.txtTriggeringDuration.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入整数!");
                            return;
                        }
                    }
                    else
                    {
                        //cM_CommodityFuse.TriggeringDuration = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("触发持续时间限制不能为空!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtFuseDurationLimit.Text))
                    {
                        if (InputTest.intTest(this.txtFuseDurationLimit.Text))
                        {
                            cM_CommodityFuse.FuseDurationLimit = Convert.ToInt32(this.txtFuseDurationLimit.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入整数!");
                            return;
                        }
                    }
                    else
                    {
                        // cM_CommodityFuse.FuseDurationLimit = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("熔断持续时间限制不能为空!");
                        return;
                    }
                    m_Result = CommonParameterSetCommon.AddCMCommodityFuse(cM_CommodityFuse);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("添加成功!");
                        this.ClearAll();
                        this.QueryCMCommodityFuse();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-6801";
                    string      errMsg    = "添加可交易商品_熔断失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }

                #endregion
            }
            else if (m_EditType == 2)
            {
                #region 修改操作

                try
                {
                    CM_CommodityFuse cM_CommodityFuse = new CM_CommodityFuse();
                    if (m_CommodityCode == AppGlobalVariable.INIT_STRING)
                    {
                        ShowMessageBox.ShowInformation("请选择更新数据!");
                        return;
                    }
                    cM_CommodityFuse.CommodityCode = this.cmbCommodityCode.SelectedItem.ToString();
                    //cM_CommodityFuse.TriggeringScale = Convert.ToDecimal(this.txTriggeringScale.Text);
                    if (!string.IsNullOrEmpty(this.txTriggeringScale.Text))
                    {
                        if (InputTest.DecimalTest(this.txTriggeringScale.Text))
                        {
                            cM_CommodityFuse.TriggeringScale = Convert.ToDecimal(this.txTriggeringScale.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入数字或小数点!");
                            return;
                        }
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("触发比例不能为空!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtFuseTimeOfDay.Text))
                    {
                        if (InputTest.intTest(this.txtFuseTimeOfDay.Text))
                        {
                            cM_CommodityFuse.FuseTimeOfDay = Convert.ToInt32(this.txtFuseTimeOfDay.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入整数!");
                            return;
                        }
                    }
                    else
                    {
                        //cM_CommodityFuse.FuseTimeOfDay = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("熔断次数不能为空!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtTriggeringDuration.Text))
                    {
                        if (InputTest.intTest(this.txtTriggeringDuration.Text))
                        {
                            cM_CommodityFuse.TriggeringDuration = Convert.ToInt32(this.txtTriggeringDuration.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入整数!");
                            return;
                        }
                    }
                    else
                    {
                        //cM_CommodityFuse.TriggeringDuration = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("触发持续时间限制不能为空!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.txtFuseDurationLimit.Text))
                    {
                        if (InputTest.intTest(this.txtFuseDurationLimit.Text))
                        {
                            cM_CommodityFuse.FuseDurationLimit = Convert.ToInt32(this.txtFuseDurationLimit.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入整数!");
                            return;
                        }
                    }
                    else
                    {
                        //cM_CommodityFuse.FuseDurationLimit = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("熔断持续时间限制不能为空!");
                        return;
                    }
                    m_Result = CommonParameterSetCommon.UpdateCMCommodityFuse(cM_CommodityFuse);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.ClearAll();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                    this.QueryCMCommodityFuse();
                    this.cmbCommodityCode.Enabled = true;
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-6802";
                    string      errMsg    = "修改可交易商品_熔断失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }

                #endregion
            }
        }
        /// <summary>
        /// 添加或修改期货最小和最大委托量
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                QH_ConsignQuantum        qH_ConsignQuantum = new QH_ConsignQuantum();
                QH_SingleRequestQuantity qH_SingleRequestQuantity1;
                QH_SingleRequestQuantity qH_SingleRequestQuantity2;

                if (this.txtLimitQuantum.Text != string.Empty)
                {
                    if (InputTest.intTest(this.txtLimitQuantum.Text))
                    {
                        qH_SingleRequestQuantity1 = new QH_SingleRequestQuantity();
                        qH_SingleRequestQuantity1.ConsignInstructionTypeID = (int)GTA.VTS.Common.CommonObject.Types.MarketPriceType.otherPrice;
                        qH_SingleRequestQuantity1.MaxConsignQuanturm       = int.Parse(this.txtLimitQuantum.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请输入正整数!");
                        return;
                    }
                }
                else
                {
                    qH_SingleRequestQuantity1 = null;
                }
                if (this.txtMarketQuantum.Text != string.Empty)
                {
                    if (InputTest.intTest(this.txtMarketQuantum.Text))
                    {
                        qH_SingleRequestQuantity2 = new QH_SingleRequestQuantity();
                        qH_SingleRequestQuantity2.ConsignInstructionTypeID =
                            (int)GTA.VTS.Common.CommonObject.Types.MarketPriceType.MarketPrice;
                        qH_SingleRequestQuantity2.MaxConsignQuanturm = int.Parse(this.txtMarketQuantum.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请输入正整数!");
                        return;
                    }
                }
                else
                {
                    qH_SingleRequestQuantity2 = null;
                }

                if (!string.IsNullOrEmpty(this.txtMinConsignQuantum.Text))
                {
                    qH_ConsignQuantum.MinConsignQuantum = Convert.ToInt32(txtMinConsignQuantum.Text);
                }
                else
                {
                    qH_ConsignQuantum.MinConsignQuantum = AppGlobalVariable.INIT_INT;
                }

                if (m_MinAndMaxConsignQuantumUIEditType == (int)UITypes.EditTypeEnum.AddUI)
                {
                    m_Result = FuturesManageCommon.AddQHConsignQuantumAndSingle(qH_ConsignQuantum, qH_SingleRequestQuantity1, qH_SingleRequestQuantity2);
                    if (m_Result != AppGlobalVariable.INIT_INT)
                    {
                        ConsignQuantumID = m_Result;
                        ShowMessageBox.ShowInformation("添加成功!");
                        this.ClearAll();
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                else if (m_MinAndMaxConsignQuantumUIEditType == (int)UITypes.EditTypeEnum.UpdateUI)
                {
                    if (m_ConsignQuantumID != AppGlobalVariable.INIT_INT)
                    {
                        qH_ConsignQuantum.ConsignQuantumID                = m_ConsignQuantumID;
                        qH_SingleRequestQuantity1.ConsignQuantumID        = m_ConsignQuantumID;
                        qH_SingleRequestQuantity1.SingleRequestQuantityID = m_LimitSingleRequestQuantityID;
                        if (m_MarkSingleRequestQuantityID == AppGlobalVariable.INIT_INT)
                        {
                            qH_SingleRequestQuantity2 = null;
                        }
                        else
                        {
                            qH_SingleRequestQuantity2.ConsignQuantumID        = m_ConsignQuantumID;
                            qH_SingleRequestQuantity2.SingleRequestQuantityID = m_MarkSingleRequestQuantityID;
                        }
                    }
                    bool _UpResult = FuturesManageCommon.UpdateQHConsignQuantumAndSingle(qH_ConsignQuantum, qH_SingleRequestQuantity1, qH_SingleRequestQuantity2);
                    if (_UpResult)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                string      errCode   = "GL-5861";
                string      errMsg    = "添加或修改期货最小和最大委托量失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return;
            }
        }
        /// <summary>
        /// 添加或修改商品期货_保证金比例
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                QH_CFBailScaleValue qH_CFBailScaleValue  = new QH_CFBailScaleValue();
                QH_CFBailScaleValue qH_CFBailScaleValue2 = new QH_CFBailScaleValue();

                if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                {
                    qH_CFBailScaleValue.BreedClassID  = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    qH_CFBailScaleValue2.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                }
                else
                {
                    ShowMessageBox.ShowInformation("请选择品种!");
                    this.cmbBreedClassID.Focus();
                    return;
                }

                if (!string.IsNullOrEmpty(this.txtStart.Text) && !string.IsNullOrEmpty(this.txtEnds.Text))
                {
                    if (InputTest.intTest(this.txtStart.Text) && InputTest.intTest(this.txtEnds.Text))
                    {
                        if (Convert.ToInt32(this.txtStart.Text) < Convert.ToInt32(this.txtEnds.Text))
                        {
                            qH_CFBailScaleValue.Start = Convert.ToInt32(this.txtStart.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("起始值不能大于或等于结束值!");
                            this.txtStart.Focus();
                            return;
                        }
                        if (Convert.ToInt32(this.txtEnds.Text) > Convert.ToInt32(this.txtStart.Text))
                        {
                            qH_CFBailScaleValue.Ends = Convert.ToInt32(this.txtEnds.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("结束值不能小于或等于起始值!");
                            this.txtEnds.Focus();
                            return;
                        }
                        if (InputTest.intTest(this.txtEnds2.Text))
                        {
                            qH_CFBailScaleValue2.Ends = Convert.ToInt32(this.txtEnds2.Text);
                        }
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请输入数字!");
                        this.txtStart.Focus();
                        this.txtEnds.Focus();
                        return;
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(this.txtStart.Text) && string.IsNullOrEmpty(this.txtEnds.Text))
                    {
                        ShowMessageBox.ShowInformation("范围值不能为空!");
                        this.txtStart.Focus();
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtStart.Text))
                    {
                        if (InputTest.intTest(this.txtStart.Text))
                        {
                            qH_CFBailScaleValue.Start = Convert.ToInt32(this.txtStart.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入正整数字!");
                            this.txtStart.Focus();
                            return;
                        }
                    }
                    if (!string.IsNullOrEmpty(this.txtEnds.Text))
                    {
                        if (InputTest.intTest(this.txtEnds.Text))
                        {
                            qH_CFBailScaleValue.Ends = Convert.ToInt32(this.txtEnds.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入正整数字!");
                            this.txtEnds.Focus();
                            return;
                        }
                        if (InputTest.intTest(this.txtEnds2.Text))
                        {
                            qH_CFBailScaleValue2.Ends = Convert.ToInt32(this.txtEnds2.Text);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(this.txtBailScale.Text))
                {
                    if (InputTest.DecimalTest(this.txtBailScale.Text))
                    {
                        qH_CFBailScaleValue.BailScale = Convert.ToDecimal(this.txtBailScale.Text);
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请输入数字!");
                        this.txtBailScale.Focus();
                        return;
                    }
                    if (InputTest.DecimalTest(this.txtBailScale2.Text))
                    {
                        qH_CFBailScaleValue2.BailScale = Convert.ToDecimal(this.txtBailScale2.Text);
                    }
                }
                else
                {
                    ShowMessageBox.ShowInformation("请输入保证金比例!");
                    this.txtBailScale.Focus();
                    return;
                }

                if (!string.IsNullOrEmpty(this.cmbDeliveryMonthTypeID.Text))
                {
                    qH_CFBailScaleValue.DeliveryMonthType  = ((UComboItem)this.cmbDeliveryMonthTypeID.SelectedItem).ValueIndex;
                    qH_CFBailScaleValue2.DeliveryMonthType = ((UComboItem)this.cmbDeliveryMonthTypeID.SelectedItem).ValueIndex;
                }
                if (checkBox1.Checked)
                {
                    qH_CFBailScaleValue.LowerLimitIfEquation = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.Yes;
                }
                else
                {
                    qH_CFBailScaleValue.LowerLimitIfEquation = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.No;
                }
                if (checkBox2.Checked)
                {
                    qH_CFBailScaleValue.UpperLimitIfEquation = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.Yes;
                }
                else
                {
                    qH_CFBailScaleValue.UpperLimitIfEquation = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.No;
                }
                if (checkBox5.Checked)
                {
                    qH_CFBailScaleValue2.UpperLimitIfEquation = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.Yes;
                }
                else
                {
                    qH_CFBailScaleValue2.UpperLimitIfEquation = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.No;
                }

                if (!string.IsNullOrEmpty(this.cmbPositionBailTypeID.Text))
                {
                    qH_CFBailScaleValue.PositionBailTypeID  = ((UComboItem)this.cmbPositionBailTypeID.SelectedItem).ValueIndex;
                    qH_CFBailScaleValue2.PositionBailTypeID = ((UComboItem)this.cmbPositionBailTypeID.SelectedItem).ValueIndex;
                }
                if (EditType == (int)UITypes.EditTypeEnum.AddUI)
                {
                    int result;
                    if (!chkLastTrDay.Checked)
                    {
                        result = FuturesManageCommon.AddQHCFBailScaleValue(qH_CFBailScaleValue);
                    }
                    else
                    {
                        result = FuturesManageCommon.AddQHCFBailScaleValue(qH_CFBailScaleValue, qH_CFBailScaleValue2);
                    }
                    if (result != AppGlobalVariable.INIT_INT)
                    {
                        FireSaved(this, new EventArgs());
                        ShowMessageBox.ShowInformation("添加成功!");
                        //this.ClearAll();
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                else if (EditType == (int)UITypes.EditTypeEnum.UpdateUI)
                {
                    if (m_CFBailScaleValueID != AppGlobalVariable.INIT_INT)
                    {
                        qH_CFBailScaleValue.CFBailScaleValueID = m_CFBailScaleValueID;
                    }
                    if (m_CFBailScaleValueID2 != AppGlobalVariable.INIT_INT)
                    {
                        qH_CFBailScaleValue2.CFBailScaleValueID = m_CFBailScaleValueID2;
                        qH_CFBailScaleValue.RelationScaleID     = m_CFBailScaleValueID2;
                    }
                    if (!chkLastTrDay.Checked)
                    {
                        //当现在修改后的保证金控制类型不等于原来的保证金控制类型:交易日 时,则把原来的子记录删除,并把
                        //父记录中子记录的ID变为NULL
                        if (m_PositionBailTypeID == (int)GTA.VTS.Common.CommonObject.Types.QHPositionBailType.ByTradeDays)
                        {
                            if (((UComboItem)this.cmbPositionBailTypeID.SelectedItem).ValueIndex != m_PositionBailTypeID)
                            {
                                FuturesManageCommon.DeleteQHCFBailScaleValue(m_CFBailScaleValueID2);
                                qH_CFBailScaleValue.RelationScaleID = null;//AppGlobalVariable.INIT_INT;
                            }
                        }
                        m_Result = FuturesManageCommon.UpdateQHCFBailScaleValue(qH_CFBailScaleValue);
                    }
                    else
                    {
                        m_Result = FuturesManageCommon.UpdateQHCFBailScaleValue(qH_CFBailScaleValue, qH_CFBailScaleValue2);
                    }
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                string      errCode   = "GL-6402";
                string      errMsg    = "添加或修改商品期货_保证金比例失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return;
            }
        }
        /// <summary>
        /// 确定按钮操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (m_EditType == 1)
            {
                #region 添加操作

                try
                {
                    HK_Commodity hK_Commodity = new HK_Commodity();

                    if (!string.IsNullOrEmpty(this.txtHKCommodityCode.Text))
                    {
                        if (!HKManageCommon.IsExistHKCommodityCode(this.txtHKCommodityCode.Text))
                        {
                            ShowMessageBox.ShowInformation("代码已经存在!");
                            return;
                        }
                        if (InputTest.zeroStartIntTest(this.txtHKCommodityCode.Text))
                        {
                            if (this.txtHKCommodityCode.Text.Length == 5)
                            {
                                hK_Commodity.HKCommodityCode = this.txtHKCommodityCode.Text;
                            }
                            else
                            {
                                ShowMessageBox.ShowInformation("港股代码是五位数!");
                                return;
                            }
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入数字!");
                            return;
                        }
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请填写代码!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtHKCommodityName.Text))
                    {
                        if (!HKManageCommon.IsExistHKCommodityName(this.txtHKCommodityName.Text))
                        {
                            ShowMessageBox.ShowInformation("代码名称已经存在!");
                            return;
                        }
                        hK_Commodity.HKCommodityName = this.txtHKCommodityName.Text;
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请填写代码名称!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.txtStockPinYin.Text))
                    {
                        hK_Commodity.StockPinYin = this.txtStockPinYin.Text;
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("拼音简称不能为空!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                    {
                        hK_Commodity.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    }
                    else
                    {
                        //cM_Commodity.BreedClassID = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("请选择品种类型!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.dtMarketDate.Text))
                    {
                        hK_Commodity.MarketDate = Convert.ToDateTime(this.dtMarketDate.Text);
                    }
                    else
                    {
                        //cM_Commodity.MarketDate = AppGlobalVariable.INIT_DATETIME;
                        ShowMessageBox.ShowInformation("请选择上市日期!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.txtturnovervolume.Text))
                    {
                        if (InputTest.intTest(this.txtturnovervolume.Text))
                        {
                            hK_Commodity.turnovervolume = Convert.ToDouble(this.txtturnovervolume.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入正整数!");
                            return;
                        }
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("流通股数不能为空!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtPerHandThighOrShare.Text))
                    {
                        if (InputTest.intTest(this.txtPerHandThighOrShare.Text))
                        {
                            hK_Commodity.PerHandThighOrShare = Convert.ToInt32(this.txtPerHandThighOrShare.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入正整数!");
                            return;
                        }
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("每手股数不能为空!");
                        return;
                    }
                    hK_Commodity.ISSysDefaultCode = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.No;
                    //用户添加的代码不是系统默认代码
                    m_Result = HKManageCommon.AddHKCommodity(hK_Commodity);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("添加成功!");
                        this.ClearAll();
                        this.QueryHKCommodity();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-7703";
                    string      errMsg    = "添加港股交易商品失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }

                #endregion
            }
            else if (m_EditType == 2)
            {
                #region 修改操作

                try
                {
                    HK_Commodity hK_Commodity = new HK_Commodity();
                    if (string.IsNullOrEmpty(this.txtHKCommodityCode.Text))
                    {
                        ShowMessageBox.ShowInformation("请选择更新数据!");
                        return;
                    }
                    hK_Commodity.HKCommodityCode = this.txtHKCommodityCode.Text;
                    if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                    {
                        hK_Commodity.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    }
                    else
                    {
                        //cM_Commodity.BreedClassID = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("请选择品种类型!");
                        return;
                    }
                    //注释掉修改港股代码的系统默认代码值
                    //hK_Commodity.ISSysDefaultCode = AppGlobalVariable.INIT_INT;//用户添加的代码不是系统默认代码
                    hK_Commodity.ISSysDefaultCode = m_ISSysDefaultCode; //当是修改时不改变原来的系统默认代码默认值
                    m_Result = HKManageCommon.UpdateHKCommodity(hK_Commodity);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.ClearAll();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                    this.QueryHKCommodity();
                    //this.txtHKCommodityCode.Enabled = true;//操作结束代码变成可输入状态
                    m_ISSysDefaultCode = AppGlobalVariable.INIT_INT;
                    this.ClearAll();
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-7704";
                    string      errMsg    = "修改港股交易商品失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }

                #endregion
            }
        }
Ejemplo n.º 16
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.ExistsSIFBail(
                            ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex) &&
                        FuturesManageCommon.ExistsSIFPosition(
                            ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex))
                    {
                        ShowMessageBox.ShowInformation("此品种的持仓限制和保证金已存在!");
                        return;
                    }
                    QH_SIFBail     qH_SIFBail     = new QH_SIFBail();
                    QH_SIFPosition qH_SIFPosition = new QH_SIFPosition();
                    if (!string.IsNullOrEmpty(this.txtUnilateralPositions.Text))
                    {
                        if (InputTest.intTest(this.txtUnilateralPositions.Text))
                        {
                            qH_SIFPosition.UnilateralPositions = Convert.ToInt32(this.txtUnilateralPositions.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入数字且第一位数不能为0!");
                            return;
                        }
                    }
                    else
                    {
                        //qH_SIFPosition.UnilateralPositions = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("请填单边持仓量!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                    {
                        qH_SIFBail.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    }
                    else
                    {
                        qH_SIFBail.BreedClassID = AppGlobalVariable.INIT_INT;
                    }
                    if (!string.IsNullOrEmpty(this.txtBailScale.Text))
                    {
                        if (InputTest.DecimalTest(this.txtBailScale.Text))
                        {
                            qH_SIFBail.BailScale = Convert.ToDecimal(this.txtBailScale.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                            return;
                        }
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请填写保证金!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                    {
                        qH_SIFPosition.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    }
                    else
                    {
                        qH_SIFPosition.BreedClassID = AppGlobalVariable.INIT_INT;
                    }
                    m_Result = FuturesManageCommon.AddQHSIFPositionAndQHSIFBail(qH_SIFPosition, qH_SIFBail);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("添加成功!");
                        this.ClearAll();
                        this.QueryQHSIFPositionAndBail();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-6481";
                    string      errMsg    = "添加股指期货持仓限制和品种_股指期货_保证金失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }
                #endregion
            }
            else if (m_EditType == 2)
            {
                #region 修改操作
                try
                {
                    this.cmbBreedClassID.Enabled = false;
                    QH_SIFBail     qH_SIFBail     = new QH_SIFBail();
                    QH_SIFPosition qH_SIFPosition = new QH_SIFPosition();
                    if (m_BreedClassID == AppGlobalVariable.INIT_INT)
                    {
                        ShowMessageBox.ShowInformation("请选择更新数据!");
                        return;
                    }
                    //qH_FutureCosts.BreedClassID = m_BreedClassID;
                    qH_SIFBail.BreedClassID     = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    qH_SIFPosition.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    if (!string.IsNullOrEmpty(this.txtUnilateralPositions.Text))
                    {
                        if (InputTest.intTest(this.txtUnilateralPositions.Text))
                        {
                            qH_SIFPosition.UnilateralPositions = Convert.ToInt32(this.txtUnilateralPositions.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入数字且第一位数不能为0!");
                            return;
                        }
                    }
                    else
                    {
                        // qH_SIFPosition.UnilateralPositions = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("请填单边持仓量!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtBailScale.Text))
                    {
                        if (InputTest.DecimalTest(this.txtBailScale.Text))
                        {
                            qH_SIFBail.BailScale = Convert.ToDecimal(this.txtBailScale.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                            return;
                        }
                    }
                    else
                    {
                        //qH_SIFBail.BailScale = AppGlobalVariable.INIT_DECIMAL;
                        ShowMessageBox.ShowInformation("请填写保证金!");
                        return;
                    }
                    m_Result = FuturesManageCommon.UpdateQHSIFPositionAndQHSIFBail(qH_SIFPosition, qH_SIFBail);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.ClearAll();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                    this.QueryQHSIFPositionAndBail();
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-6482";
                    string      errMsg    = "修改股指期货持仓限制和品种_股指期货_保证金失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }
                #endregion
            }
        }