private void mnu_Add_Click(object sender, EventArgs e) { FrmLR280Detail frm = new FrmLR280Detail(); if (frm.ShowDialog() == DialogResult.OK) { LR280Item item = frm.LR280Item; if (FindRow(item.Comport) >= 0) { MessageBox.Show("串口号为 " + item.Comport + " 的读卡器已经存在"); } else { int row = dataGridView1.Rows.Add(); ShowItemOnRow(dataGridView1.Rows[row], item); } } }
private void mnu_Update_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 1) { FrmLR280Detail frm = new FrmLR280Detail(); frm.LR280Item = dataGridView1.SelectedRows[0].Tag as LR280Item; if (frm.ShowDialog() == DialogResult.OK) { LR280Item item = frm.LR280Item; var row = FindRow(item.Comport); if (row >= 0 && row != dataGridView1.SelectedRows[0].Index) { MessageBox.Show("串口号为 " + item.Comport + " 的读卡器已经存在"); } else { ShowItemOnRow(dataGridView1.SelectedRows[0], item); } } } }