public ProductForm(Product product) { isEditing = true; InitializeComponent(); //populate the form IdField.Text = product.ID.ToString(); NameField.Text = product.PRODUCT_NAME; MUField.Text = product.MEASUREMENT_UNIT; PriceField.Text = product.PRICE.ToString(); }
public bool Persist() { FiltrateForm(); if (ValidateForm()) { Product p = new Product() { ID = isEditing ? ulong.Parse(IdField.Text) : 0, PRODUCT_NAME = NameField.Text, MEASUREMENT_UNIT = MUField.Text, PRICE = decimal.Parse(PriceField.Text) }; if (isEditing) return ProductController.Instance.Update(p); else return ProductController.Instance.Create(p); } else { FocusFirstField(); throw new ValidationException("Не сте попълнили валидно всички полета."); } }