private void btn_themNCC_Click(object sender, EventArgs e) { var name = txtB_TenNCC.Text.Trim(); var email = txtB_emailNCC.Text.Trim(); var phone = txtB_SđtNCC.Text.Trim(); var addr = txtB_DiaChiNCC.Text.Trim(); if (name == "" || email == "" || phone == "" || addr == "") { MessageBox.Show("Xin điền đầy đủ thông tin trước khi thực hiện thao tác khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var supplierValueObject = new SupplierValueObject(_isUpdate ? _rowId: 0, name, addr, email, phone); var success = _isUpdate ? _supplierBusinessLogic.UpdateSupplier(supplierValueObject) : _supplierBusinessLogic.CreateSupplier(supplierValueObject); if (success) { MessageBox.Show("Cật nhật thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Có gì đó không đúng, có thể dữ liệu đã có trong cơ sở dữ liệu", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool CreateSupplier(SupplierValueObject supplier) { try { var listSuppliers = GetallSupplier(); if (listSuppliers.Any(el => el.Email == supplier.Email && el.Phone == supplier.Phone)) { return(false); } return(_supplierDataAccessLayer.CreateNewSupplier(supplier.Name, supplier.Address, supplier.Email, supplier.Phone)); } catch (Exception) { return(false); } }
public bool UpdateSupplier(SupplierValueObject supplier) { return(_supplierDataAccessLayer.UpdateSupplier(supplier.Id, supplier.Name, supplier.Address, supplier.Email, supplier.Phone)); }