using System; using System.Collections.Generic; using System.Linq; using System.Text; using Mesnac.Action.Base; using Mesnac.Controls.Base; using Mesnac.Controls.Default; using Mesnac.Codd.Session; using System.Data; namespace Mesnac.Action.Default { public class MaterialParaLoad : DatabaseAction, IAction { public void Run(Controls.Base.IBaseControl sender, string design, string runtime) { base.Run(sender); //必须调用 foreach (DbMCControl cgrid in GetAllDbMCControls()) { MCCombobox mccombobox = cgrid.BaseControl as MCCombobox; if (mccombobox != null) { if (string.IsNullOrWhiteSpace(cgrid.DesignSource)) { continue; } if (string.IsNullOrWhiteSpace(cgrid.DataTable.ToString())) { continue; } string source = cgrid.DesignSource; string table = cgrid.DataTable; DbHelper dbHelper; if (!DbHelpers.TryGetValue(source, out dbHelper)) { continue; } dbHelper.ClearParameter(); dbHelper.CommandType = CommandType.Text; string sqlstr = "SELECT * FROM [" + table + "]"; dbHelper.CommandText = sqlstr; DataTable dt = dbHelper.ToDataTable(); mccombobox.DataSource = dt; mccombobox.DisplayMember = mccombobox.DisplayFiled; mccombobox.ValueMember = mccombobox.ValueFiled; } } } } }