using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using Mesnac.Action.Base; using Mesnac.Controls.Base; using Mesnac.Controls.Default; using System.Windows.Forms; using Mesnac.Codd.Session; namespace Mesnac.Action.Feeding.Qingquan.Technology { /// /// 为配方列表设置SQL并刷新列表 /// public class SetSelectRecipeSql : FeedingAction, IAction { public void Run(RuntimeParameter runtime) { base.RunIni(runtime); IBaseControl recipeTypeName = base.GetMCControlByKey("RecipeTypeName").FirstOrDefault(); if (recipeTypeName != null) { recipeTypeName.MCValue = runtime.BaseControl.MCValue; } string sqlstr = runtime.Parameters; List controls = base.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[pmt_recipe].[ObjID]"); foreach (DbMCControl control in controls) { control.BaseControl.ActionDataSource = sqlstr; if (control.BaseControl is ComboBox) { DbHelper dbHelper = base.NewDbHelper(control.DesignSource); if (dbHelper == null) { return; } dbHelper.ClearParameter(); dbHelper.CommandType = CommandType.Text; dbHelper.CommandText = sqlstr; DataTable table = dbHelper.ToDataTable(); control.BaseControl.BindDataSource = table; } } //return; //List values = new List(); //foreach (DbMCControl c in base.GetAllDbMCControls()) //{ // if (base.DbOptionTypesIsQuery(c.BaseControl)) // { // values.Add(c); // } //} //StringBuilder sqlsb = new StringBuilder(sqlstr); //foreach (DbMCControl control in values) //{ // if (control.BaseControl.MCValue != null && control.BaseControl.MCValue.ToString().Trim() != string.Empty) // { // sqlsb.Append(" AND [").Append(control.DataTable).Append("].[").Append(control.DataField).Append("]='"); // sqlsb.Append(control.BaseControl.MCValue.ToString().Trim()).Append("'"); // } //} //foreach (DbMCControl control in controls) //{ // control.BaseControl.ActionDataSource = sqlsb.ToString(); //} } } }