using System; using System.Collections.Generic; using System.Linq; using System.Text; using Mesnac.Action.Base; using System.Windows.Forms; namespace Mesnac.Action.Feeding.Technology { /// /// 打开配方管理界面时默认显示当前配方 /// public class InitCurrentRecipeData : FeedingAction, IAction { public void Run(RuntimeParameter runtime) { base.RunIni(runtime); #region 打开配方管理界面时默认显示当前配方 DbMCControl recipeSelect = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[pmt_recipe].[ObjID]").FirstOrDefault(); if (recipeSelect != null) { ComboBox cbRecipeSelect = recipeSelect.BaseControl as ComboBox; if (cbRecipeSelect != null) { BasicInfo.RecipeData recipeData = new BasicInfo.RecipeData(); string recipeId = recipeData.GetCurrentRecipeID(); if (!String.IsNullOrEmpty(recipeId)) { foreach (object item in cbRecipeSelect.Items) { System.Data.DataRowView dataRowView = item as System.Data.DataRowView; object currValue = dataRowView.Row["ObjID"]; if (currValue != null && currValue != System.DBNull.Value) { int currRecipeId = 0; if (int.TryParse(currValue.ToString(), out currRecipeId)) { if (currRecipeId.ToString() == recipeId.Trim()) { cbRecipeSelect.SelectedItem = item; break; } } } } } } } #endregion } } }