/// <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> /// 确定按钮操作 /// </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 } }