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.

73 lines
2.7 KiB
C#

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
{
/// <summary>
/// 为配方列表设置SQL并刷新列表
/// </summary>
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<DbMCControl> 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<DbMCControl> values = new List<DbMCControl>();
//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();
//}
}
}
}