/// <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; } }