public frmAddFlower(hoa obj) { InitializeComponent(); bindingSourceFlower.DataSource = obj; if (chkForest.CheckState == CheckState.Checked)//kiểm tra có đánh dâu vào Foreset không { chkForest.Text = "Forest"; } else if (chkForest.CheckState == CheckState.Checked) { chkForest.Text = "NonForest"; } else { chkForest.Text = "???"; } }
private async void MtEdit_Click(object sender, EventArgs e) { hoa obj = hoaBindingSource.Current as hoa; if (obj != null)// kiểm tra data obj khác nulll thì chạy { using (frmAddFlower frm = new frmAddFlower(obj)) { if (frm.ShowDialog() == DialogResult.OK) { try { hoaBindingSource.EndEdit(); await db.SaveChangesAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }