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.

69 lines
2.0 KiB
C#

1 year ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Mesnac.Action.Base;
using Mesnac.Controls.Base;
using System.Windows.Forms;
using Mesnac.Codd.Session;
namespace Mesnac.Action.Default.SynchroData
{
public class PreRow : DatabaseAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
#region 限定只对相同DataSource的数据表进行操作
string mcDataSourceID = String.Empty;
if (runtime.Sender is Mesnac.Controls.Base.IBaseControl)
{
mcDataSourceID = (runtime.Sender as Mesnac.Controls.Base.IBaseControl).MCDataSourceID;
}
#endregion
foreach (IBaseControl cgrid in GetAllMCControls())
{
if (!String.IsNullOrEmpty(mcDataSourceID) && cgrid.MCDataSourceID != mcDataSourceID)
{
continue;
}
DataGridView grid = runtime.Sender as DataGridView;
if (grid == null)
{
if (cgrid is DataGridView)
{
grid = cgrid as DataGridView;
}
}
if (grid == null)
{
continue;
}
int index = 0;
foreach (DataGridViewRow row in grid.SelectedRows)
{
row.Selected = false;
index = row.Index;
}
if (index > 0)
{
index = index - 1;
}
if (grid.Rows.Count > index)
{
grid.Rows[index].Selected = true;
}
if (runtime.Sender is DataGridView)
{
return;
}
}
}
}
}