private void Add_button_Click(object sender, EventArgs e) { ChiTietKhoa f = new ChiTietKhoa(_loginForm); this.Close(); f.Show(); }
public BoMonEditAndAdd(ChiTietKhoa A, string maKhoa, string maBM) { InitializeComponent(); _khoaForm = A; _maKhoa = maKhoa; _maBM = maBM; }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0 && senderGrid.Columns[e.ColumnIndex].Name == "ChiTiet") { string MaKhoa = senderGrid.Rows[e.RowIndex].Cells["MaKhoa"].Value.ToString(); ChiTietKhoa f = new ChiTietKhoa(_loginForm, MaKhoa); this.Close(); f.Show(); } else if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0 && senderGrid.Columns[e.ColumnIndex].Name == "Xoa") { try { string MaKhoa = senderGrid.Rows[e.RowIndex].Cells["MaKhoa"].Value.ToString(); List <KHOA> khoas = new List <KHOA>(); khoas.Add(new KHOA() { MaKhoa = MaKhoa }); BLL.Instance.DelDB(khoas); } catch (MySQLException myex) { if (myex.Number == MySQLException.ExcepEnum.Referenced) { MessageBox.Show("Không thể xóa khoa này", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Unknown SQL Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { Khoa_Load(sender, e); } } }