/// <summary> /// Create a new Discount object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="guestId">Initial value of the GuestId property.</param> /// <param name="amount">Initial value of the Amount property.</param> public static Discount CreateDiscount(global::System.Int32 id, global::System.Int32 guestId, global::System.Double amount) { Discount discount = new Discount(); discount.Id = id; discount.GuestId = guestId; discount.Amount = amount; return discount; }
/// <summary> /// Handles the Click event of the GrantDiscountButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void GrantDiscountButton_Click(object sender, EventArgs e) { double discountValue; double.TryParse(this.Form.DiscountTextBox.Text, out discountValue); if (discountValue <= 0.0) { MessageBox.Show( "Podane wartości nie są prawidłowe lub pozostawiono niewypełnione pola.", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } var discount = new Discount() { GuestId = this.ClientID, Amount = discountValue }; DataAccess.Instance.Discounts.Add(discount); DataAccess.Instance.UnitOfWork.Commit(); this.RefreshDiscounts(); }
/// <summary> /// Deprecated Method for adding a new object to the Discounts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDiscounts(Discount discount) { base.AddObject("Discounts", discount); }