我有一个GridControl,其中包含带有 Checkbox 控件的项目列表。
我正在添加和删除List<int>
包含选中项目列 ID 值的自定义 ID。现在,我想循环List<int>
并从 Table 中选择记录,并通过获取这些选中的项目想要使用Linq插入到其他表中使用C#的WPF中的实体。
List<Infill> infillList = new List<Infill>();
List<int> infillListIDs=new List<int>();
private bool ProcessItem(bool IsChecked)
{
bool result = false;
Infill item = grdInfillInner.FocusedRow as Infill;
if (IsChecked)
{
if (item != null)
{
// DO STUFF HERE EXAMPLE ADD or REMOVE Item to a list, BASED on CHECKED or UNCHECKED!!!
int infillid = item.InfillID;
infillListIDs.Add(infillid);
result = true;
}
}
else
{
if(infillListIDs.Contains(item.InfillID))
{
// if uncheked the checked item then remove from custom list
infillListIDs.Remove(item.InfillID);
}
}
grdInfillInner.FocusedRowHandle = -1;
return result;
}
private void BtnInsert_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Total Items :" + infillListIDs.Count);
//Insert the record in other table (having same table structure)
//here by selecting from infillListIDs custom list of type List<int>
}
private void CheckEdit_Checked(object sender, RoutedEventArgs e)
{
e.Handled = ProcessItem(true);
}
private void CheckEdit_Unchecked(object sender, RoutedEventArgs e)
{
e.Handled = ProcessItem(false);
}
protected void GetAllInfills()
{
List<Infill> infillList = new List<Infill>();
infillList=BLL.GetAllInfills();
if (infillList != null)
{
grdInfill.ItemsSource = infillList;
grdInfill.GroupBy(grdInfill.Columns["Glass.GlassType"], ColumnSortOrder.Ascending);
grdInfill.GroupBy(grdInfill.Columns["Glass.Glass_Description"], ColumnSortOrder.Ascending);
grdInfill.AutoExpandAllGroups = true;
}
}
我想从infill表中获取记录,其中infillListIDs包含来自Infill表的所有检查行的ID ,并且在单击插入按钮时具有相同结构的表!insert into DummyInfill