private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[4] is DataGridViewImageButtonSaveColumn && e.RowIndex >= 0 && senderGrid.Columns[5] is DataGridViewImageButtonDeleteColumn) { switch (e.ColumnIndex) { case 4: TblPhongBan data = new TblPhongBan(); DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; data.MaPhong = row.Cells[0].Value.ToString(); data.TenPhong = row.Cells[1].Value.ToString(); data.GhiChu = row.Cells[2].Value.ToString(); Add.AddPhongBan uc = new Add.AddPhongBan(data, "Cập nhật phòng ban", this); uc.ShowDialog(); break; case 5: TblPhongBan data2 = new TblPhongBan(); DataGridViewRow row2 = dataGridView1.Rows[e.RowIndex]; data2.MaPhong = row2.Cells[0].Value.ToString(); data2.TenPhong = row2.Cells[1].Value.ToString(); data2.GhiChu = row2.Cells[2].Value.ToString(); Delete.DeletePhongBan uc2 = new Delete.DeletePhongBan("Bộ phận này", data2, this); uc2.ShowDialog(); break; } } }
private void ThemPBToolStrip_Click(object sender, EventArgs e) { Add.AddPhongBan uc = new Add.AddPhongBan(null, "Thêm mới phòng ban", this.dspb); uc.ShowDialog(); }