private void mnu_Add_Click(object sender, EventArgs e) { FrmZSTDetail frm = new FrmZSTDetail(); if (frm.ShowDialog() == DialogResult.OK) { if (FindRow(frm.ReaderIP) >= 0) { MessageBox.Show("IP 地址为 " + frm.ReaderIP + " 的读卡器已经存在"); } else { int row = dataGridView1.Rows.Add(); ShowItemOnRow(dataGridView1.Rows[row], frm.ReaderIP, frm.EntranceName, frm.EntranceID, frm.Memo); } } }
private void mnu_Update_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 1) { FrmZSTDetail frm = new FrmZSTDetail(); frm.ReaderIP = dataGridView1.SelectedRows[0].Cells["colReaderIP"].Value as string; frm.EntranceID = (int)dataGridView1.SelectedRows[0].Cells["colEntrance"].Tag; if (frm.ShowDialog() == DialogResult.OK) { if (FindRow(frm.ReaderIP) != dataGridView1.SelectedRows[0].Index) { MessageBox.Show("IP 地址为 " + frm.ReaderIP + " 的读卡器已经存在"); } else { ShowItemOnRow(dataGridView1.SelectedRows[0], frm.ReaderIP, frm.EntranceName, frm.EntranceID, frm.Memo); } } } }