You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.5 KiB
C#

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
{
/// <summary>
/// 配方查询放大器
/// </summary>
public class RecipeFinderAction : FeedingAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
SimplePmtRecipe selectedRecipe = null;
FrmRecipeFinder recipeFinder = new FrmRecipeFinder(1); //本地检索
recipeFinder.ShowDialog();
if (recipeFinder.DialogResult == System.Windows.Forms.DialogResult.OK)
{
selectedRecipe = recipeFinder.SelectedRecipe;
}
recipeFinder.Dispose();
if (selectedRecipe != null)
{
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)
{
string recipeId = selectedRecipe.ObjID;
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;
}
}
}
}
}
}
}
}
}
}
}