protected void Button1_Click(object sender, EventArgs e) { List <HotelRoom> availablerooms = bs.AvailableRooms(bs.bookings, bs.rooms, DateFrom, DateTo, NBeds, Size); HotelRoom theRoom = bs.firstValidRoomFromList(availablerooms); MessageBox.Show("This room is available, and suits your preferences: " + showRoom(theRoom)); //Book.Enabled = true; //Book.Visible = true; // if(bs.firstValidRoomFromList(availablebs.rooms) != null) //{ //Create button - Yes it is available, do you want to book? //onmouseclick - makeReservation. MessageBox.Show("Do you want to book a room from: " + DateFrom.Date.ToString() + " to " + DateTo.Date.ToString() + " with " + NBeds + " beds and type: " + Size.ToString()); string name = "yes"; Button showButton = new Button(); showButton.CommandName = name; showButton.Text = "Yes!"; showButton.Visible = true; showButton.Enabled = true; showButton.Click += new EventHandler(this.Button2_Click); Controls.Add(showButton); // } }
public ActionResult AddRoomToHotel(HotelRoom model) { try { Hotel hotel = db.Hotels.Find(model.Hotel.Id); HotelRoom hr = new HotelRoom() { Hotel = hotel, Count = model.Count, NightPrice = model.NightPrice, Room = db.Rooms.Find(int.Parse(Request["Rooms"].ToString())) }; db.HotelRooms.Add(hr); db.SaveChanges(); return(RedirectToAction("HotelRoomsManagement", "Hotel", new { HotelId = hotel.Id })); } catch { } ViewBag.Rooms = new SelectList(db.Rooms.ToList(), "Id", "Name"); return(View(model)); }
public async Task <HotelRoomModel> AddHotelRoom(int hotelId, HotelRoomModel roomInfo) { var hotel = await _dataContext.Hotels.FindAsync(hotelId); if (hotel == null) { throw new ArgumentException(); } var hotelRoom = new HotelRoom { HotelId = hotelId, Adults = roomInfo.Adults, Cost = roomInfo.Cost, Number = roomInfo.Number, IsAvailable = roomInfo.IsAvailable, RoomTypeId = 1, Images = UpdateRoomImages(roomInfo.Id, new List <RoomImage>(), roomInfo.ImageIds) }; await _dataContext.HotelRooms.AddAsync(hotelRoom); await _dataContext.SaveChangesAsync(); return(new HotelRoomModel(hotelRoom)); }
public async Task <HotelRoomDTO> UpdateHotelRoom(int roomId, HotelRoomDTO hotelRoomDTO) { try { if (roomId == hotelRoomDTO.Id) { HotelRoom roomDetails = await _db.HotelRooms.FindAsync(roomId); //매개변수 안에 인자 하나만 넣으면 DTO에 있는 값들은 복사되고, 없는값들은 건들지도 안음. //destination 에 실존하는 object를 넣어주면 dto에 있는 값들은 고대로 복사되고, DTO에 없는 값들은 destination 에 넣어준 object의 값들을 쓰게됨 HotelRoom room = _mapper.Map <HotelRoomDTO, HotelRoom>(hotelRoomDTO, roomDetails); room.UpdatedBy = ""; room.UpdatedDate = DateTime.Now; var updatedRoom = _db.HotelRooms.Update(room); await _db.SaveChangesAsync(); return(_mapper.Map <HotelRoom, HotelRoomDTO>(updatedRoom.Entity)); } else { return(null); } } catch (Exception ex) { return(null); } }
public async Task <IActionResult> Edit(int id, [Bind("HotelID,RoomNumber,RoomID,Rate,PetFriendly")] HotelRoom hotelRoom) { if (id != hotelRoom.HotelID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hotelRoom); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HotelRoomExists(hotelRoom.HotelID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["HotelID"] = new SelectList(_context.Hotels, "ID", "ID", hotelRoom.HotelID); ViewData["RoomID"] = new SelectList(_context.Rooms, "ID", "ID", hotelRoom.RoomID); return(View(hotelRoom)); }
public ActionResult Edit(int id) { HotelRoom ud = context.HotelRooms.Where(x => x.RoomId == id).SingleOrDefault(); ViewBag.hotel = new SelectList(context.Hotels, "HotelId", "HotelName"); return(View(ud)); }
public async void CreateHotelRoomDB() { DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>() .UseInMemoryDatabase("CreateHotelRoom") .Options; using (AsyncInnDbContext context = new AsyncInnDbContext(options)) { //create room, create hotel, create //hotel room Hotel h = new Hotel(); h.Name = "Single"; Room r = new Room(); r.Name = "King"; context.Add(h); context.Add(r); context.SaveChanges(); var hotel = context.Hotels.FirstOrDefaultAsync(x => x.Name == h.Name); var room = context.Rooms.FirstOrDefaultAsync(x => x.Name == r.Name); HotelRoom hr = new HotelRoom(); hr.HotelID = hotel.Id; hr.RoomID = room.Id; hr.PetFriendly = true; context.HotelRooms.Add(hr); context.SaveChanges(); var hotelroom = await context.HotelRooms.FirstOrDefaultAsync(x => x.HotelID == hr.HotelID); //assert db entry Assert.Equal(hotelroom.RoomID, hr.RoomID); } }
public async void CanSaveHotelRoomInDB() { DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>() .UseInMemoryDatabase("SavingHotelRoom") .Options; using (AsyncInnDbContext context = new AsyncInnDbContext(options)) { HotelRoom savehotelroom = new HotelRoom(); savehotelroom.HotelID = 1; savehotelroom.RoomID = 1; savehotelroom.PetFriendly = false; savehotelroom.Rate = 10; savehotelroom.RoomNumber = 100; context.HotelRoom.Add(savehotelroom); await context.SaveChangesAsync(); HotelRoom result = await context.HotelRoom.FirstOrDefaultAsync(x => x.PetFriendly == savehotelroom.PetFriendly); Assert.False(result.PetFriendly); } }
public void CanGetRoomRate() { HotelRoom hotelRoom = new HotelRoom(); hotelRoom.Rate = 2; HotelRoom.Equals(2, hotelRoom.Rate); }
public void CanGetRoomID() { HotelRoom hotelRoom = new HotelRoom(); hotelRoom.RoomID = 3; HotelRoom.Equals(2, hotelRoom.RoomID); }
public async Task<IActionResult> Create(int HotelID, int RoomNumber, [Bind("HotelID,RoomID,RoomNumber,Rate,PetFriendly")] HotelRoom hotelRoom) { if (RoomNumber != hotelRoom.RoomNumber) { var concurrency = _context.HotelRooms.Where(m => m.HotelID == hotelRoom.HotelID && m.RoomNumber == hotelRoom.RoomNumber); if (concurrency != null) { return RedirectToAction(nameof(Index)); } } if (ModelState.IsValid) { try { _context.Add(hotelRoom); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HotelRoomExists(hotelRoom.HotelID, hotelRoom.RoomID)) { return NotFound("Page Not Found"); } throw; } return RedirectToAction(nameof(Index)); } ViewData["HotelID"] = new SelectList(_context.Hotels, "ID", "Name", hotelRoom.HotelID); ViewData["RoomID"] = new SelectList(_context.Rooms, "ID", "Name", hotelRoom.RoomID); return View(hotelRoom); }
/// <summary> /// PUT: Updates a Hotel Room. /// </summary> /// <param name="hotelid"></param> /// <param name="roomid"></param> /// <param name="hotelRoom"></param> /// <returns></returns> public async Task <HotelRoom> UpdateHotelRoom(int hotelid, int roomid, HotelRoom hotelRoom) { _context.Entry(hotelRoom).State = EntityState.Modified; await _context.SaveChangesAsync(); return(hotelRoom); }
public async Task <HotelRoomDTO> UpdateHotelRoom(int roomId, HotelRoomDTO hotelRoomDTO) { try { if (roomId == hotelRoomDTO.Id) { //valid HotelRoom roomDetails = await _db.HotelRooms.FindAsync(roomId); HotelRoom room = _mapper.Map <HotelRoomDTO, HotelRoom>(hotelRoomDTO, roomDetails); room.UpdatedBy = ""; room.UpdatedDate = DateTime.Now; var updatedRoom = _db.HotelRooms.Update(room); await _db.SaveChangesAsync(); return(_mapper.Map <HotelRoom, HotelRoomDTO>(updatedRoom.Entity)); } else { //invalid return(null); } } catch (Exception e) { return(null); } }
//确定 private void BtnOK_Click(object sender, EventArgs e) { BtnOK.Enabled = false; BtnOK.Enabled = true; m_Seat = db.HotelRoom.FirstOrDefault(x => x.text == text.Text || x.oId == text.Text); if (m_Seat == null) { BathClass.printErrorMsg("所选择台位不存在"); return; } if (m_Status != -1) { if (m_Status != m_Seat.status) { BathClass.printErrorMsg("所选择台位不可用"); return; } } else if (!m_StatusList.Contains(m_Seat.status)) { BathClass.printErrorMsg("所选择台位不可用"); return; } this.DialogResult = DialogResult.OK; }
public void GetHRNumber() { HotelRoom hr = new HotelRoom(); hr.RoomNumber = 111; Assert.Equal(111, hr.RoomNumber); }
public void CanGetHotelRoomID() { HotelRoom hotelRoom = new HotelRoom(); hotelRoom.HotelID = 2; HotelRoom.Equals(2, hotelRoom.HotelID); }
public async Task <HotelRoom> UpdateHotelRoom(int hotelId, int roomId, HotelRoom hotelRoom) { _context.Entry(hotelRoom).State = Microsoft.EntityFrameworkCore.EntityState.Modified; await _context.SaveChangesAsync(); return(hotelRoom); }
public async void CanUpdateHotelRoom() { /// Can update an existing hotel room DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("UpdateHotelRoom").Options; using (AsyncInnDbContext context = new AsyncInnDbContext(options)) { HotelRoom hoRoom = new HotelRoom(); hoRoom.HotelID = 90; hoRoom.RoomNumber = 87; hoRoom.RoomID = 81; hoRoom.Rate = 350; hoRoom.PetFriendly = true; HotelRoomController hotController = new HotelRoomController(context); await hotController.Create(hoRoom); HotelRoom upRoom = hoRoom; upRoom.HotelID = 90; upRoom.RoomNumber = 87; upRoom.RoomID = 81; upRoom.Rate = 250; upRoom.PetFriendly = true; await hotController.Edit(90, 87, upRoom); var result = await context.HotelRoom.FirstOrDefaultAsync(ho => ho.HotelID == hoRoom.HotelID && ho.RoomNumber == hoRoom.RoomNumber); Assert.Equal(250, result.Rate); } }
public async Task DeleteHotelRoom(int hotelId, int roomId) { HotelRoom hotelRoom = await GetHotelRoom(hotelId, roomId); _context.Entry(hotelRoom).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; await _context.SaveChangesAsync(); }
public async Task <HotelRoom> Create(HotelRoom hotelRoom) { _context.Entry(hotelRoom).State = Microsoft.EntityFrameworkCore.EntityState.Added; await _context.SaveChangesAsync(); return(hotelRoom); }
void IHotelRoomRepository.SetHotelInavailablity(int id, DateTime dateTime) { var newHotel = hotels.ToList(); var index = newHotel.FindIndex(x => x.ID == id); var oldData = newHotel[index]; var newData = new HotelRoom { ID = oldData.ID, Name = oldData.Name, Description = oldData.Description, Price = oldData.Price, Ratings = oldData.Ratings, Location = oldData.Location, MinGuestCount = oldData.MinGuestCount, MaxGuestCount = oldData.MaxGuestCount, DateUntilAvailable = dateTime, Icon = oldData.Icon, Room = oldData.Room }; newHotel[index] = newData; hotels = newHotel; }
public ActionResult Delete(int id) { HotelRoom hotelroom = context.HotelRooms.Find(id); ViewBag.hotels = new SelectList(context.Hotels, "HotelId", "HotelName", hotelroom.HotelId); return(View(hotelroom)); }
public void GetHRRate() { HotelRoom hr = new HotelRoom(); hr.Rate = 500.50M; Assert.Equal(500.50M, hr.Rate); }
public void CanGetHotelRoomNumber() { HotelRoom hotelRoom = new HotelRoom(); hotelRoom.RoomNumber = 2; HotelRoom.Equals(2, hotelRoom.RoomNumber); }
public void GetHRPet() { HotelRoom hr = new HotelRoom(); hr.PetFriendly = true; Assert.True(hr.PetFriendly); }
void IHotelBookingPresenter.RequestViewHotelBooking(string reference) { try { HotelBook reservation = hotelBookingRepository.FindBookHotel(reference); HotelRoom hotel = hotelRoomRepository.FindHotelByID(reservation.HotelID); // Creates a new Instance of HotelBooDTO, and updates the Control's Value for Hotel Booking Details Form. view.HotelBookDTO = new HotelBookDTO(hotel.ID); view.HotelBookDTO.HotelName = hotel.Name; view.HotelBookDTO.HotelDescription = hotel.Description; view.HotelBookDTO.HotelLocation = hotel.Location.ToString(); view.HotelBookDTO.HotelRoomImage = hotel.Room.ConvertToImage(); view.HotelBookDTO.MinimumGuestCount = hotel.MinGuestCount; view.HotelBookDTO.MaximumGuestCount = hotel.MaxGuestCount; view.HotelBookDTO.GuestCount = reservation.GuestCount; view.HotelBookDTO.CheckIn = reservation.CheckIn; view.HotelBookDTO.CheckOut = reservation.CheckOut; view.HotelBookDTO.TotalCost = reservation.TotalCost; view.DisplayHotelBooking(true); } catch (Exception ex) // Catches any exception and display the error message. { MessageBox.Show("An Error Occured!\r\n" + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async void CanUpdateHotelRoomsFromDb() { // setup our db context // set value DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>() .UseInMemoryDatabase("GetHotelRoomsUpdateFromDb") .Options; HotelRoom hotelRoom = new HotelRoom(); // UPDATE: use a clean context instance for test using (AsyncInnDbContext context = new AsyncInnDbContext(options)) { hotelRoom.RoomNumber = 999; context.Update(hotelRoom); context.SaveChanges(); } using (AsyncInnDbContext context = new AsyncInnDbContext(options)) { var entity = await context.HotelRooms.FirstOrDefaultAsync(x => x.RoomNumber == 999); Assert.Equal(999, entity.RoomNumber); } }
/** * if unique returns null else returns the room object */ public async Task <HotelRoomDTO> IsRoomUnique(string name, int roomId = 0) { try { if (roomId == 0) { HotelRoom hotelRoom = await _db.HotelRooms.FirstOrDefaultAsync(x => x.Name.ToLower() == name.ToLower()); HotelRoomDTO hotelRoomDto = _mapper.Map <HotelRoom, HotelRoomDTO>(hotelRoom); return(hotelRoomDto); } else { // editing HotelRoom hotelRoom = await _db.HotelRooms.FirstOrDefaultAsync(x => x.Name.ToLower() == name.ToLower() && x.Id != roomId); HotelRoomDTO hotelRoomDto = _mapper.Map <HotelRoom, HotelRoomDTO>(hotelRoom); return(hotelRoomDto); } } catch (Exception e) { return(null); } }
public async Task <HotelRoom> CreateHotelRoom(HotelRoom hotelRoom) { _context.HotelRooms.Add(hotelRoom); await _context.SaveChangesAsync(); return(hotelRoom); }
//DETAILS public ViewResult Details(int id) { HotelRoom hotelroom = context.HotelRooms. Where(x => x.RoomId == id).SingleOrDefault(); return(View(hotelroom)); }
public void CanGetPetFriendly() { HotelRoom hotelRoom = new HotelRoom(); hotelRoom.PetFriendly = true; HotelRoom.Equals(true, hotelRoom.PetFriendly); }
public OpenSeatForm(HotelRoom seat, bool open) { m_open = open; db = new BathDBDataContext(LogIn.connectionString); m_Seats.Add(seat); chainId = BathClass.chainId(db, LogIn.connectionString); InitializeComponent(); }
public PMS_Room_Detail_View(HotelRoom hotelRoom) { this.Title = $"Room {hotelRoom.RoomNumber} Details"; Content = new StackLayout { Children = { new Label { Text = hotelRoom.ToString () } } }; }
//构造函数 public SeatExpenseForm(HotelRoom seat) { var db = new BathDBDataContext(LogIn.connectionString); if (MainWindow.seatLock) { m_Seats.Add(db.HotelRoom.FirstOrDefault(x => x.text == seat.text)); } else { var seats = db.HotelRoom.Where(x => (seat.chainId == null && x.text == seat.text) || (seat.chainId != null && x.chainId == seat.chainId)); seats = seats.Where(x => x.status == 2 || x.status == 6 || x.status == 7 || x.status == 8); m_Seats.AddRange(seats); } foreach (var s in m_Seats) { s.paying = true; } db.SubmitChanges(); //m_Seats.AddRange(db.HotelRoom.Where(x => x.chainId == seat.chainId && (x.status == 2 || x.status == 6 || x.status == 7))); InitializeComponent(); }
private void dgvChain_CellClick(object sender, DataGridViewCellEventArgs e) { if (dgvChain.CurrentRow == null) return; string id = dgvChain.CurrentRow.Cells[0].Value.ToString(); m_Seat = m_Seats.FirstOrDefault(x => x.text == id); //if (!use_oyd) //{ // if (dgvChain.CurrentCell.ColumnIndex != 1) // chain = false; // else // chain = true; // setStatus(); // dgvExpense_show(); //} }
private void open_one_seat(HotelRoom seat, bool child, BathDBDataContext dc) { if (seat.status == 3) { BathClass.reset_seat(seat); dc.SubmitChanges(); } seat.openEmployee = LogIn.m_User.id.ToString(); seat.openTime = BathClass.Now(LogIn.connectionString); seat.systemId = BathClass.systemId(db, LogIn.connectionString); seat.status = 2; if (!seatlock) seat.chainId = chainId; HotelRoomType seatType = dc.HotelRoomType.FirstOrDefault(x => x.id == seat.typeId); var menu = dc.Menu.FirstOrDefault(x => x.id == seatType.menuId); if (menu != null) { Orders order = new Orders(); order.menu = menu.name; order.text = seat.text; order.systemId = seat.systemId; order.number = 1; order.money = menu.price; order.inputTime = BathClass.Now(LogIn.connectionString); order.inputEmployee = LogIn.m_User.id.ToString(); order.paid = false; dc.Orders.InsertOnSubmit(order); } if (child) { var child_menu = dc.Menu.FirstOrDefault(x => x.name == "儿童浴资"); if (child_menu != null) { Orders order = new Orders(); order.menu = child_menu.name; order.text = seat.text; order.systemId = seat.systemId; order.number = 1; order.money = child_menu.price; order.inputTime = BathClass.Now(LogIn.connectionString); order.inputEmployee = LogIn.m_User.id.ToString(); order.paid = false; dc.Orders.InsertOnSubmit(order); } } dc.SubmitChanges(); }
//构造函数 public OpenCardForm(HotelRoom seat) { db = new BathDBDataContext(LogIn.connectionString); m_Seat = seat; InitializeComponent(); }
private void print_seat_bill(HotelRoom seat) { DataGridView dgv = new DataGridView(); DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = "手牌号"; dgv.Columns.Add(col); DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn(); col1.HeaderText = "项目名称"; dgv.Columns.Add(col1); DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn(); col2.HeaderText = "技师"; dgv.Columns.Add(col2); DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn(); col3.HeaderText = "单价"; dgv.Columns.Add(col3); DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn(); col4.HeaderText = "数量"; dgv.Columns.Add(col4); DataGridViewTextBoxColumn col5 = new DataGridViewTextBoxColumn(); col5.HeaderText = "金额"; dgv.Columns.Add(col5); double money_pay = 0; var orders = db.Orders.Where(x => x.systemId == seat.systemId && !x.paid && x.deleteEmployee == null); foreach (var order in orders) { string[] row = new string[6]; row[0] = order.text; row[1] = order.menu; row[2] = order.technician; var menu = db.Menu.FirstOrDefault(x => x.name == order.menu); if (menu != null) row[3] = menu.price.ToString(); row[4] = order.number.ToString(); double money_tmp = 0; if (order.priceType == "每小时") { row[3] = order.money.ToString() + "/时"; money_tmp = Math.Ceiling((GeneralClass.Now - order.inputTime).TotalHours) * order.money; } else { money_tmp = order.money; } money_pay += money_tmp; row[5] = money_tmp.ToString(); dgv.Rows.Add(row); } List<string> printCols = new List<string>(); printCols.Add("手牌"); printCols.Add("项目名称"); printCols.Add("技师"); printCols.Add("单价"); printCols.Add("数量"); printCols.Add("金额"); List<HotelRoom> seats = new List<HotelRoom>(); seats.Add(seat); PrintSeatBill.Print_DataGridView(seats, "预打账单", dgv, printCols, money_pay.ToString(), db.Options.ToArray()[0].companyName); }
private void set_one_seat_status(HotelRoom seat, BathDBDataContext dc) { if (seat.status == 3) { BathClass.reset_seat(seat); dc.SubmitChanges(); } seat.openEmployee = LogIn.m_User.id.ToString(); seat.openTime = BathClass.Now(LogIn.connectionString); seat.systemId = BathClass.systemId(dc, LogIn.connectionString); seat.status = 2; dc.SubmitChanges(); }
//创建单个台位按钮 private void createButton(int x, int y, HotelRoom table, Control sp) { Button btn = new Button(); Single bf = 13F; int l = table.text.Length; if (l == 3) bf = 13F; else if (l == 4) bf = 10f; btn.Font = new Font("SimSun", bf); btn.Location = new System.Drawing.Point(x, y); btn.Name = table.id.ToString(); btn.Text = table.text; btn.Size = new System.Drawing.Size(btn_size, btn_size); btn.FlatStyle = FlatStyle.Popup; btn.UseVisualStyleBackColor = true; btn.ContextMenuStrip = seatContext; btn.TabStop = false; btn.Click += new System.EventHandler(btn_Click); btn_status(btn, table.status); sp.Controls.Add(btn); }
//点击台位按钮 private void btn_Click(object sender, EventArgs e) { Button btn = sender as Button; btn.Enabled = false; btn.Enabled = true; BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); var manuInput = BathClass.ToBool(db_new.Options.FirstOrDefault().允许手工输入手牌号结账); m_Seat = db_new.HotelRoom.FirstOrDefault(x => x.text == btn.Text); var mtype = db_new.HotelRoomType.FirstOrDefault(x => x.id == m_Seat.typeId); if (!manuInput && mtype.menuId != null) { BathClass.printErrorMsg("不允许手工输入手牌号结账!"); return; } switch (m_Seat.status) { case 1://可用 case 3://已经结账 break; case 2://正在使用 case 6://警告 case 7://押金离场 case 8://重新结账 if (m_Seat.note != null && m_Seat.note != "") BathClass.printInformation(m_Seat.note); SeatExpenseForm seatExpenseForm = new SeatExpenseForm(m_Seat); seatExpenseForm.ShowDialog(); break; case 4://锁定 break; case 5://停用 BathClass.printErrorMsg("台位已经停用!"); break; default: break; } }
private void lock_unlock(HotelRoom seat, BathDBDataContext db_new, Employee employee) { if (seat.status == 1 || seat.status == 2) seat.status = 4; else if (seat.status == 4) { Operation op = new Operation(); op.employee = employee.name; op.seat = seat.text; op.openEmployee = seat.openEmployee; op.openTime = seat.openTime; op.explain = "解锁手牌"; op.opTime = BathClass.Now(LogIn.connectionString); db_new.Operation.InsertOnSubmit(op); if (seat.systemId == null) seat.status = 1; else seat.status = 2; } db_new.SubmitChanges(); }
private void update_ui(HotelRoom seat, BathDBDataContext dc) { //dgvChain_show(); string t = Convert.ToDateTime(seat.openTime).ToShortTimeString(); dgvChain.Rows.Add(); dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[0].Value = seat.text; dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[1].Value = false; dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[2].Value = t; dgvChain.CurrentCell = null; //chain = true; dgvExpense_show(dc); setStatus(dc); }
public static void Print_DataGridView(HotelRoom seat, string money, string expense, string coName) { PrintPreviewDialog ppvw; try { printer = printDoc.PrinterSettings.PrinterName; // Getting DataGridView object to print companyName = coName; m_Money = money; m_Seat = seat; m_Expense = expense; DashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; printDoc.PrinterSettings.PrinterName = printer; printDoc.DefaultPageSettings.Margins.Left = 10; printDoc.DefaultPageSettings.Margins.Right = 10; printDoc.DefaultPageSettings.Margins.Top = 0; printDoc.DefaultPageSettings.Margins.Bottom = 30; PrintController printController = new StandardPrintController(); printDoc.PrintController = printController; ppvw = new PrintPreviewDialog(); ppvw.Document = printDoc; // Showing the Print Preview Page printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); // Printing the Documnet printDoc.Print(); printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }
//构造函数 public DepositForm(HotelRoom seat) { db = new BathDBDataContext(LogIn.connectionString); m_Seat = db.HotelRoom.FirstOrDefault(x => x.systemId == seat.systemId); InitializeComponent(); }
public RepayActListForm(HotelRoom seat, Employee user) { m_user = user; m_seat_text = seat.text; InitializeComponent(); }
//载入消费 private void btnReload_Click(object sender, EventArgs e) { var dc_new = new BathDBDataContext(LogIn.connectionString); if (seatText.Text != "") { m_Seat = dc_new.HotelRoom.FirstOrDefault(x => x.text == seatText.Text || x.oId == seatText.Text); seatText.Text = ""; if (m_Seat == null || m_Seat.status != 2 && m_Seat.status != 6 && m_Seat.status != 7 && m_Seat.status != 8) { BathClass.printErrorMsg("该手牌不在使用中,不能结账!"); return; } if (m_Seats.FirstOrDefault(x=>x.text==m_Seat.text) == null) { if (m_Seat.note != null) BathClass.printInformation(m_Seat.note); string t = Convert.ToDateTime(m_Seat.openTime).ToShortTimeString(); dgvChain.Rows.Add(); dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[0].Value = m_Seat.text; dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[1].Value = use_oyd; dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[2].Value = t; order_guoye(m_Seat, dc_new); m_Seats.Add(m_Seat); m_Seat.paying = true; dc_new.SubmitChanges(); //dgvChain_show(); dgvChain.CurrentCell = null; //chain = true; dgvExpense_show(dc_new); setStatus(dc_new); } } }
//加收过夜费 private void order_guoye(HotelRoom seat, BathDBDataContext dc) { if (!BathClass.ToBool(m_Options.自动加收过夜费)) return; if (dc.Orders.FirstOrDefault(x=>x.systemId==seat.systemId && x.menu=="过夜费") != null || dc.HisOrders.FirstOrDefault(x => x.systemId == seat.systemId && x.menu == "过夜费") != null) return; var m_OverMenu = dc.Menu.FirstOrDefault(x => x.name == "过夜费"); if (m_OverMenu == null) return; DateTime now = DateTime.Now; string year = now.Year.ToString(); string month = now.Month.ToString(); string day = now.Day.ToString(); string date = year+"-"+month+"-"+day+" "; string time = ":00:00"; DateTime st = DateTime.Parse(date + m_Options.过夜费起点 + time); DateTime et = DateTime.Parse(date + m_Options.过夜费终点 + time); DateTime open_time = seat.openTime.Value; if ((now >= et && open_time >= et) || (open_time <= st && now <= st)) return; Orders order = new Orders(); order.menu = m_OverMenu.name; order.text = seat.text; order.systemId = seat.systemId; order.number = 1; order.money = m_OverMenu.price; order.inputTime = now; order.inputEmployee = "过夜费"; order.departmentId = 1; order.paid = false; dc.Orders.InsertOnSubmit(order); dc.SubmitChanges(); find_combo(dc, order); }
//F6开牌 private void tool_open_seat() { BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); string text = tSeat.Text; tSeat.Text = ""; m_HotelRoom = db_new.HotelRoom.FirstOrDefault(x => x.text == text || x.oId == text); if (m_HotelRoom == null) { BathClass.printErrorMsg("手牌不可用!"); return; } switch (m_HotelRoom.status) { case 1://可用 case 3://已经结账 BathClass.printErrorMsg("手牌未开牌"); break; case 2://正在使用 case 7://押金离场 if (!BathClass.getAuthority(db_new, LogIn.m_User, "完整点单") && !BathClass.getAuthority(db_new, LogIn.m_User, "可见本人点单")) { BathClass.printErrorMsg("权限不够!"); break; } if (m_HotelRoom.paying.HasValue && m_HotelRoom.paying.Value) { BathClass.printErrorMsg("正在结账!"); break; } m_HotelRoom.ordering = true; db_new.SubmitChanges(); HotelRoomOrderForm orderForm = new HotelRoomOrderForm(m_HotelRoom); orderForm.ShowDialog(); m_HotelRoom.ordering = false; db_new.SubmitChanges(); break; case 4://锁定 BathClass.printErrorMsg("手牌已经锁定!"); break; case 5://停用 BathClass.printErrorMsg("手牌已经停用!"); break; case 6://警告 HotelRoomOrderCheckForm orderCheckForm = new HotelRoomOrderCheckForm(m_HotelRoom); orderCheckForm.ShowDialog(); break; case 8: BathClass.printErrorMsg("补救台位不能录单"); break; default: break; } tSeat.Text = ""; }
//点击台位按钮 private void btn_Click(object sender, EventArgs e) { Button btn = sender as Button; btn.Enabled = false; btn.Enabled = true; BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString); m_HotelRoom = db_new.HotelRoom.FirstOrDefault(x => x.text == btn.Text); int status = m_HotelRoom.status; switch (status) { case 1://可用 case 3://已经结账 BathClass.printErrorMsg("手牌未开牌"); break; case 2://正在使用 case 7://押金离场 if (!BathClass.getAuthority(db_new, LogIn.m_User, "完整点单") && !BathClass.getAuthority(db_new, LogIn.m_User, "可见本人点单")) { BathClass.printErrorMsg("权限不够!"); break; } if (m_HotelRoom.paying.HasValue && m_HotelRoom.paying.Value) { BathClass.printErrorMsg("正在结账!"); break; } m_HotelRoom.ordering = true; db_new.SubmitChanges(); var orderForm = new HotelRoomOrderForm(m_HotelRoom); orderForm.ShowDialog(); m_HotelRoom.ordering = false; db_new.SubmitChanges(); break; case 4://锁定 BathClass.printErrorMsg("手牌已经锁定!"); break; case 5://停用 BathClass.printErrorMsg("台位已经停用!"); break; case 6://警告 var orderCheckForm = new HotelRoomOrderCheckForm(m_HotelRoom); orderCheckForm.ShowDialog(); break; case 8: BathClass.printErrorMsg("补救台位不能录单"); break; default: break; } }
//对话框载入 private void SeatExpenseForm_Load(object sender, EventArgs e) { dgvExpense.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 20); dgvExpense.RowsDefaultCellStyle.Font = new Font("宋体", 20); dgvChain.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 17); dgvChain.RowsDefaultCellStyle.Font = new Font("宋体", 17); var db = new BathDBDataContext(LogIn.connectionString); m_Options = db.Options.FirstOrDefault(); printBill = BathClass.ToBool(m_Options.结账打印结账单); printShoe = BathClass.ToBool(m_Options.结账打印取鞋小票); printStubBill = BathClass.ToBool(m_Options.结账打印存根单); inputBillId = BathClass.ToBool(m_Options.录单输入单据编号); companyName = m_Options.companyName; //manul_pay = BathClass.ToBool(ops.允许手工输入手牌号结账); use_oyd = BathClass.ToBool(m_Options.启用手牌锁); if (use_oyd) { dgvChain.ReadOnly = true; btnReload.Text = "留牌"; //btnChain.Visible = false; //seatText.ReadOnly = true; //btnReload.Visible = false; } dgvExpense.Columns[1].Visible = inputBillId; m_Seat = m_Seats[0]; dgvChain_show(); dgvChain.CurrentCell = dgvChain[0, 0]; //chain = true; order_guoye(m_Seat, db); dgvExpense_show(db); setStatus(db); }
public void CreateRoom(HotelRoom room) { roomRep.Create(room); }