コード例 #1
0
		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();
		}
コード例 #2
0
		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("Не сте попълнили валидно всички полета.");
			}
		}