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