private void btnAdd_Click(object sender, EventArgs e) { frmIngredientDetail frmID = new frmIngredientDetail(); frmID.setFunction(1); frmID.ShowDialog(); frmID.setTitle("Thêm Mới Thực Phẩm"); if (frmID.DialogResult == DialogResult.OK) { FillGridControl(); } }
private void btnEdit_Click(object sender, EventArgs e) { frmIngredientDetail frmID = new frmIngredientDetail(); var rowHandle = gridView1.FocusedRowHandle; try { frmID.setIngredient(Convert.ToInt32(gridView1.GetRowCellValue(rowHandle, "IngredientID").ToString())); } catch { var rowChildHand = gridView1.GetChildRowHandle(rowHandle, 0); frmID.setIngredient(Convert.ToInt32(gridView1.GetRowCellValue(rowChildHand, "IngredientID").ToString())); } frmID.setFunction(2); frmID.setTitle("Cập Nhật Thực Phẩm"); frmID.ShowDialog(); if (frmID.DialogResult == DialogResult.OK) { FillGridControl(); } }