/// <summary> /// Deprecated Method for adding a new object to the RoomTypes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRoomTypes(RoomType roomType) { base.AddObject("RoomTypes", roomType); }
/// <summary> /// Handles the Click event of the OkButton 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 OkButton_Click(object sender, EventArgs e) { string description = this.Form.DescriptionRichTextBox.Text; string typeName = this.Form.NameTextBox.Text; double price = 0; double pricePerPerson = 0; double.TryParse(this.Form.PriceTextBox.Text, out price); double.TryParse(this.Form.PricePerPersonTextBox.Text, out pricePerPerson); if (string.IsNullOrEmpty(description) || string.IsNullOrEmpty(typeName) || price <= 0 || pricePerPerson <= 0) { MessageBox.Show( "Podane wartości nie są prawidłowe lub pozostawiono niewypełnione pola.", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (this.IsEditForm) { var roomType = DataAccess.Instance.RoomTypes.Single(f => f.Id == this.ItemToEditID); roomType.Description = description; roomType.Name = typeName; roomType.Price = price; roomType.PricePerPerson = pricePerPerson; } else { var roomType = new RoomType { Description = description, Name = typeName, Price = price, PricePerPerson = pricePerPerson }; DataAccess.Instance.RoomTypes.Add(roomType); } DataAccess.Instance.UnitOfWork.Commit(); this.Form.Dispose(); }
/// <summary> /// Create a new RoomType object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="price">Initial value of the Price property.</param> /// <param name="name">Initial value of the Name property.</param> public static RoomType CreateRoomType(global::System.Int32 id, global::System.Double price, global::System.String name) { RoomType roomType = new RoomType(); roomType.Id = id; roomType.Price = price; roomType.Name = name; return roomType; }