/// <summary> /// 获取港股的交割制度 /// </summary> /// <param name="code">商品代码</param> /// <param name="fund">资金交割制度</param> /// <param name="stock">股票交割制度</param> /// <param name="strMessage">错误信息</param> /// <returns>是否成功获取</returns> public bool GetHKDeliveryInstitution(string code, out int fund, out int stock, ref string strMessage) { bool result = false; string errCode = "GT-8114"; string errMsg = "无法根据商品编码从管理中心获取对于的交割制度。"; strMessage = errCode + ":" + errMsg; fund = -1; stock = -1; int?breedClassID = GetBreedClassIdByHKCommodityCode(code); if (breedClassID.HasValue) { HK_SpotTradeRules rules = GetSpotTradeRulesByBreedClassID(breedClassID.Value); if (rules != null) { fund = rules.FundDeliveryInstitution.Value; stock = rules.StockDeliveryInstitution.Value; result = true; strMessage = ""; } } return(result); }
/// <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> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { if (m_EditType == 1) { #region 添加操作 try { if ( HKManageCommon.ExistsHKSpotTradeRules( ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex)) { ShowMessageBox.ShowInformation("此品种的交易规则已存在!"); return; } HK_SpotTradeRules hK_SpotTradeRules = new HK_SpotTradeRules(); string _strMess = string.Empty; hK_SpotTradeRules = VerifyHKSpotTradeRules(ref _strMess); if (!string.IsNullOrEmpty(_strMess)) { ShowMessageBox.ShowInformation(_strMess); return; } m_Result = HKManageCommon.AddHKSpotTradeRules(hK_SpotTradeRules); if (m_Result) { ShowMessageBox.ShowInformation("添加成功!"); this.ClearAll(); this.QueryHKTradeRules(); } else { ShowMessageBox.ShowInformation("添加失败!"); } } catch (Exception ex) { string errCode = "GL-7903"; 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_SpotTradeRules hK_SpotTradeRules = new HK_SpotTradeRules(); string _strMess = string.Empty; hK_SpotTradeRules = VerifyHKSpotTradeRules(ref _strMess); if (!string.IsNullOrEmpty(_strMess)) { ShowMessageBox.ShowInformation(_strMess); return; } m_Result = HKManageCommon.UpdateHKSpotTradeRules(hK_SpotTradeRules); if (m_Result) { ShowMessageBox.ShowInformation("修改成功!"); this.ClearAll(); this.QueryHKTradeRules(); } else { ShowMessageBox.ShowInformation("修改失败!"); } } catch (Exception ex) { string errCode = "GL-7904"; string errMsg = "修改港股交易规则失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return; } #endregion 修改操作 } }