//public decimal? CalculateCostRoom(NewPaymentEN aNewPaymentEN, int IDBookingRoom, string PriceType) //{ // if (aNewPaymentEN.aListBookingRoomUsed.Where(a => a.ID == IDBookingRoom).ToList().Count > 0) // { // CustomersBO aCustomersBO = new CustomersBO(); // ExtraCostBO aExtraCostBO = new ExtraCostBO(); // RoomsBO aRoomsBO = new RoomsBO(); // BookingRoomUsedEN aTemp = aNewPaymentEN.aListBookingRoomUsed.Where(a => a.ID == IDBookingRoom).ToList()[0]; // List<Customers> aListCustomers = aCustomersBO.SelectListCustomer_ByIDBookingRoom(IDBookingRoom); // if (aListCustomers.Count >0 ) // { // int CustomerType = Convert.ToInt32(aNewPaymentEN.CustomerType); // decimal? CostRoom = 0; // //if (aTemp.Cost != 0) // //{ // // CostRoom = aTemp.Cost - Convert.ToDecimal(aExtraCostBO.Select_BySku_ByPriceType_ByNumberPeople(aTemp.RoomSku, aTemp.PriceType, aTemp.ListCustomer.Count).ExtraValue); // //} // //else // //{ // CostRoom = aRoomsBO.Select_ByIDBookingRoom(IDBookingRoom).CostRef; // //} // string RoomSku = aTemp.RoomSku; // decimal ExtraMoneyRoom = Convert.ToDecimal(aExtraCostBO.Select_BySku_ByPriceType_ByNumberPeople(RoomSku, PriceType, aListCustomers.Count).ExtraValue); // return (CostRoom + ExtraMoneyRoom); // } // else // Neu phong k co ai thi tien =0 // { // return 0; // } // } // else // { // return 0; // } //} public decimal? CalculateCostRoom( int IDBookingRoom, string PriceType , int CustomerType, int NumCustomer ) { BookingRoomsBO aBookingRoomsBO = new BookingRoomsBO(); if (aBookingRoomsBO.Select_ByID(IDBookingRoom) != null) { CustomersBO aCustomersBO = new CustomersBO(); ExtraCostBO aExtraCostBO = new ExtraCostBO(); RoomsBO aRoomsBO = new RoomsBO(); //List<Customers> aListCustomers = aCustomersBO.SelectListCustomer_ByIDBookingRoom(IDBookingRoom); decimal? CostRoom = 0; CostRoom = aRoomsBO.Select_ByIDBookingRoom(IDBookingRoom).CostRef; string RoomSku = aRoomsBO.Select_ByIDBookingRoom(IDBookingRoom).Sku; try { decimal? ExtraMoneyRoom = aExtraCostBO.Select_BySku_ByPriceType_ByNumberPeople(RoomSku, PriceType, NumCustomer).ExtraValue; return (CostRoom + ExtraMoneyRoom); } catch(Exception w) { MessageBox.Show("Trong dữ liệu giá bảng giá " + PriceType + " của phòng " + RoomSku + " chưa có giá dành cho " + NumCustomer + " người "); return 0; } } else { return 0; } }