using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data; using ICSharpCode.Core; using Mesnac.Action.Base; using Mesnac.Codd.Session; using Mesnac.Action.Default.Entity; namespace Mesnac.Action.Default.Purview.BasRole { /// /// 查询角色业务 /// public class SelectAction : DatabaseAction, IAction { public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 ICSharpCode.Core.LoggingService.Debug("角色信息-查询..."); FrmInsert frmInsert = new FrmInsert(ActionType.Query); DialogResult result = frmInsert.ShowDialog(); if (result == DialogResult.OK) { DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); dbHelper.ClearParameter(); StringBuilder sbSql = new StringBuilder("select * from BasRole where 1=1"); //StringBuilder sbSql = new StringBuilder("select T1.*,T2.ItemName from BasRole T1 inner join SysCode T2 on T1.DeleteFlag=T2.ItemCode and T2.TypeID='YesNo' where 1=1"); if (!String.IsNullOrEmpty(frmInsert.RoleName)) { //sbSql.Append(" and T1.RoleName like @RoleName"); sbSql.Append(" and RoleName like @RoleName"); dbHelper.AddParameter("@RoleName", "%" + frmInsert.RoleName + "%"); } //sbSql.Append(" ORDER BY CAST(T1.SeqIndex AS INT)"); sbSql.Append(" ORDER BY CAST(SeqIndex AS INT)"); dbHelper.CommandText = sbSql.ToString(); dbHelper.CommandType = System.Data.CommandType.Text; DataTable table = dbHelper.ToDataTable(); //刷新DataGridView数据 DbMCControl dgBasRole = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "BasRole").FirstOrDefault(); if (dgBasRole == null || !(dgBasRole.BaseControl is DataGridView)) { ICSharpCode.Core.LoggingService.Warn("{角色信息-查询} 缺少角色DataGridView控件..."); runtime.IsReturn = false; return; } dgBasRole.BaseControl.BindDataSource = table; } } } }