private void btnCapNhat_Click(object sender, EventArgs e) { DoDAL db = new DoDAL(); if (KiemTra()) { int IDLoaiDo = (int)lueLoaiDo.EditValue; if (isUpdate) { db.Update(ID, txtTenDo.Text, IDLoaiDo, float.Parse(txtDonGia.Text)); MessageBox.Show("Cập nhật thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Dispose(); } else { db.Insert(txtTenDo.Text, IDLoaiDo, float.Parse(txtDonGia.Text)); MessageBox.Show("Thêm mới thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTenDo.Text = String.Empty; txtDonGia.Text = String.Empty; } } else { MessageBox.Show("Bạn phải điền đủ thông tin", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void LoadDo() { DoDAL db = new DoDAL(); lueDo.Properties.DataSource = db.Select((int)lueLoaiDo.EditValue); lueDo.Properties.DisplayMember = "TenDo"; lueDo.Properties.ValueMember = "ID"; }
private void LoadDo() { DoDAL db = new DoDAL(); gcDo.DataSource = db.Select(); }