private void newlabel(ref RoomPage2 rp2, int?roomtype, string option) { Label label = new Label(); label.SetValue(Grid.RowProperty, 1); label.SetValue(Grid.ColumnProperty, 1); label.Margin = Roommarginnuber; label.HorizontalAlignment = HorizontalAlignment.Left; label.VerticalAlignment = VerticalAlignment.Top; label.Content = "■ " + roomtype + " " + option; rp2.SmallGrid.Children.Add(label); Roommarginnuber.Top += 30; }
public RoomMenu(object tag, DateTime SDatefromHotel, DateTime EDatefromHotel, string People) : this(tag) { this.SDate = SDatefromHotel; //存從Hotel頁面丟過來的時間 this.EDate = EDatefromHotel; //存從Hotel頁面丟過來的時間 this.text = People; //存從Hotel頁面丟過來的人數 //判斷有無重複,來決定要不要產生UserControl // List <string> list = new List <string>(); //ComBeox 數量的產生 // List <string> listQuantity = new List <string>(); HotelIdNumber = (int)tag; _HotelID = HotelIdNumber; //存HotelID值 其他表單才有辦法使用 var q = (from nr in dbContent.RoomInformations where nr.HotelID == HotelIdNumber && nr.RoomType == MainWindow._RoomType select new { nr.RoomID, nr.RoomNameCN, nr.PermitSmoking, nr.OfferBreakfast, nr.CanAddBed, nr.UnitPrice, nr.RoomType, nr.Hotel.HotelNameCN, nr.HotelID }).Except(from x in dbContent.RoomInformations from p in dbContent.Orders from t in dbContent.OrderDetails where x.HotelID == HotelIdNumber && x.RoomID == t.RoomID && p.OrderID == t.OrderID && ((p.StartDate <= MainWindow._StartDate.Date && p.EndDate > MainWindow._StartDate.Date) || (p.StartDate <= MainWindow._EndDate.Date && p.EndDate > MainWindow._EndDate.Date)) select new { x.RoomID, x.RoomNameCN, x.PermitSmoking, x.OfferBreakfast, x.CanAddBed, x.UnitPrice, x.RoomType, x.Hotel.HotelNameCN, x.HotelID }); var q3 = from n in dbContent.Hotels where n.HotelID == HotelIdNumber select new { n.HotelNameCN, n.HotelNameEN, n.AddressEN }; foreach (var n in q3) { titlename.Content = n.HotelNameCN + " ( " + n.HotelNameEN + " ) "; HotelAddress.Content = n.AddressEN; } foreach (var n in q) //ComeBox房間數量用 { listQuantity.Add(n.RoomNameCN); } foreach (var n in q) { bool flag = true; #region 產生房間的UserControls 的RoomPage 不重複 for (int i = 0; i < list.Count(); i++) { if (n.RoomNameCN == list[i]) { flag = false; } } list.Add(n.RoomNameCN); #endregion if (flag) { int Quantity = 1; RoomPage2 rp2 = new RoomPage2(n.HotelNameCN, n.HotelID); rp2.Margin = marginnuber; rp2.RoomName.Content = n.RoomNameCN; rp2.RoomUnitPrice.Content = $"{n.UnitPrice:c0}"; if (minpricetoroompage.ToString() == n.UnitPrice.ToString()) { rp2.Minprice.Content = "最低價房間"; } rp2.RoomUnitPrice.Tag = n.UnitPrice; //暫存UnitPrice rp2.HotelNameRoomPage.Tag = n.HotelNameCN; //暫存HotelNameCN rp2.RoomNameRoomPage.Tag = n.RoomNameCN; //暫存RoomNameCN 丟給RoomInformationDetail rp2.RoomIDRoomPage.Tag = n.HotelID; //暫存HotelID 丟給RoomInformationDetail for (int i = 0; i < listQuantity.Count; i++) //房間數量加入ComeBox中 { if (rp2.RoomName.Content.ToString() == listQuantity[i].ToString()) { rp2.QuantityComeBox.Items.Add(Quantity); Quantity += 1; } } rp2.QuantityComeBox.SelectedIndex = 0; if (n.OfferBreakfast == true) { newlabel(ref rp2, n.RoomType, "人份早餐" /*"OfferBreakfast"*/); } if (n.PermitSmoking == true) { newlabel(ref rp2, "可吸菸" /*"PermitSmoking"*/); } if (n.CanAddBed == true) { newlabel(ref rp2, "可以加床" /*"CanAddBed"*/); } this.StackOfRoom.Children.Add(rp2); Roommarginnuber.Top = 5; SelectCount += 1; } } rb1.IsChecked = true; this.selectcount.Content = SelectCount + " 種 "; }