public void createBrand(Brand brand, int userId) { this.brand = brand; if (valid()) { BrandDAL.create(brand.Brandname, brand.Description, userId); } else { throw new Exception("Invalid Brand Data!"); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(view.txtBrandname.Text)) { view.txtBrandname.Focus(); return; } Brand brand = new Brand() { Brandname = view.txtBrandname.Text, Description = view.txtDescription.Text }; brandModel.createBrand(brand, user.UserID); view.Close(); } catch (Exception ex) { MessageBox.Show("พบข้อผิดผลาด: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }