private void EditFormClosed(object sender, FormClosedEventArgs e) { if (MessageBox.Show("Notification !", "You want closed FORM?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int CategoryId = Convert.ToInt32(comboBoxCategory.SelectedValue); dataGridView.DataSource = DAO.GetProductsByCategoryId(CategoryId); } }
private void btnDelete_Click(object sender, EventArgs e) { DialogResult dlr = MessageBox.Show("Do you want to delete?", "Notification !", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlr == DialogResult.Yes) { foreach (DataGridViewRow rowGrid in dataGridView.Rows) { DataGridViewCheckBoxCell checkBoxCell = rowGrid.Cells[0] as DataGridViewCheckBoxCell; DataGridViewCell cell = rowGrid.Cells[1]; if (Convert.ToBoolean(checkBoxCell.Value) == true) { int pid = Convert.ToInt32(cell.Value); DAO.DeleteProductById(pid); } } } int CatID = Convert.ToInt32(comboBoxCategory.SelectedValue); dataGridView.DataSource = DAO.GetProductsByCategoryId(CatID); }
private void comboBoxCategory_SelectedIndexChanged(object sender, EventArgs e) { int CategoryId = Convert.ToInt32(comboBoxCategory.SelectedValue); dataGridView.DataSource = DAO.GetProductsByCategoryId(CategoryId); }