private void btnThemMoi_Click(object sender, EventArgs e) { try { MenuFood menu = new MenuFood(); int MaLH = (cmbTenLTD.SelectedItem as Category).MaLH; menu.GiaBan = (int)cmGia.Value; menu.TenHH = txtTenTD.Text; menu.MaLH = MaLH; if (ThucDonBUS.Insert(menu)) { XtraMessageBox.Show("Thêm thành công", "THÔNG BÁO ", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTenTD.Text = ""; cmGia.Text = ""; cmbTenLTD.Text = ""; } else { XtraMessageBox.Show("Thêm thất bại", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information); } frmDanhSachTD_Load(sender, e); } catch (Exception) { XtraMessageBox.Show("Thêm thất bại", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information); if (string.IsNullOrEmpty(txtTenTD.Text) && string.IsNullOrEmpty(cmGia.Text) && string.IsNullOrEmpty(cmbTenLTD.Text)) { XtraMessageBox.Show("Chưa nhập đầy đủ thông tin", "THÔNG BÁO ", MessageBoxButtons.OK, MessageBoxIcon.Information); labgia.ForeColor = Color.Red; labelx.ForeColor = Color.Red; labelx.Text = "Không được để trống"; labgia.Text = "Không được để trống"; } else if (string.IsNullOrEmpty(txtTenTD.Text)) { XtraMessageBox.Show("Chưa nhập đầy đủ thông tin", "THÔNG BÁO ", MessageBoxButtons.OK, MessageBoxIcon.Information); labgia.ForeColor = Color.Red; labelx.ForeColor = Color.Red; labelx.Text = "Không được để trống"; labgia.Text = ""; } else if (string.IsNullOrEmpty(cmGia.Text)) { XtraMessageBox.Show("Chưa nhập đầy đủ thông tin", "THÔNG BÁO ", MessageBoxButtons.OK, MessageBoxIcon.Information); labgia.ForeColor = Color.Red; labelx.ForeColor = Color.Red; labelx.Text = ""; labgia.Text = "Không được để trống"; } } }