从左,向右移动按钮下的代码:
string[] selectedContents = new string[dgvComponentList.SelectedRows.Count];//dgvComponentList为左侧dgv的名字
int index = 0;
Model.ComponentListInfo model = new BT.Assist.Model.ComponentListInfo();
foreach (DataGridViewRow dgvr in dgvComponentList.SelectedRows)//dgvComponentList为左侧dgv的名字
{
model.Projectname = cboProjectName.Text.Trim();
model.ProccessName = dgvr.Cells[2].Value.ToString();
model.Deviceid = dgvr .Cells[3].Value.ToString();
model.DeviceName = dgvr .Cells[4].Value.ToString();
model.DevicePower = dgvr .Cells[5].Value.ToString();
model.Breaker = dgvr .Cells[6].Value.ToString();
model.BreakerAssist = dgvr .Cells[7].Value.ToString();
//此处省略其他字段
index++;
BLL.ComponentList bll = new BT.Assist.BLL.ComponentList();
BLL.DeviceList blldevice = new BT.Assist.BLL.DeviceList();
Model.DeviceListInfo modeldevice = new BT.Assist.Model.DeviceListInfo();
if (bll.addComponentList(model) >= 1)
{
modeldevice.Id = System.Convert.ToInt32(gdvr.Cells[1].Value);
blldevice.UpdateState(modeldevice);
Search();//刷新右侧dgv方法
dgvList();//刷新左侧dgv方法
}
else
{
MessageBox.Show("失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
从右,向左移动的代码一样的写法。
根据自己的数据表和功能来写DAL内的增删改方法。