private void bestelBtn_Click(object sender, EventArgs e) { orderService = new Order_Service(); tableService = new Table_Service(); order.EmployeeId = employee.Id; billService = new Bill_Service(); try { bill = billService.GetBillByTableId(tafel.Number); } catch (Exception d) { orders = new List <Order>(); bill = new Bill(DateTime.Now, tafel, orders, employee, false); billService.AddBill(bill); MessageBox.Show("Bestelling is geplaatst.", "Attentie", MessageBoxButtons.OK, MessageBoxIcon.Information); orderService.AddOrderWhereBillIdIs(order, bill.Id); tafel.Occupied = true; tableService.ModifyTable(tafel); return; } if (bill.Payed == false) { orderService.AddOrderWhereBillIdIs(order, bill.Id); MessageBox.Show("Bestelling is geplaatst.", "Attentie", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { orders = new List <Order>(); bill = new Bill(DateTime.Now, tafel, orders, employee, false); billService.AddBill(bill); MessageBox.Show("Bestelling is geplaatst.", "Attentie", MessageBoxButtons.OK, MessageBoxIcon.Information); orderService.AddOrderWhereBillIdIs(order, bill.Id); tafel.Occupied = true; tableService.ModifyTable(tafel); } foreach (Dish dish in order.Dishes) { dishService = new Dish_Service(); dishService.ModifyStock(dish.Id, dish.Stock - 1); } foreach (Drink drink in order.Drinks) { drinkService = new Drink_Service(); drinkService.ModifyStock(drink.Id, drink.Stock - 1); } order = new Order(); }
static void Main(string[] args) { Bill_Service bill_Service = new Bill_Service(); try { bill_Service.AddNewBill(new Bill(0)); Bill lastBill = bill_Service.GetLastBill(); Console.WriteLine(lastBill); } catch (Exception e) { Console.WriteLine(e.Message);; } Console.ReadKey(); }
private void btnCapNhat_Click(object sender, EventArgs e) { Room roomUp = ROOM.LayThongTinPhong(_idRoom); roomUp.Note = txtGhiChu.Text; var checkRoom = ROOM.CapNhatTinhTrangPhong(_idRoom, roomUp); BookRoom bRoomUp = BOOKR.GetThongTinBookRoom(_idRoom); bRoomUp.dateBooking = dTimeNgayDat.Value; bRoomUp.Checkin_Date = dTimeNgayNhan.Value; bRoomUp.Checkout_Date = dTimeNgayTra.Value; var checkBRoom = BOOKR.SuaThongTinBookRoomCuaKH(bRoomUp, _idCustomer); var sl = Convert.ToInt32(numUpDown.Value); string idService = listDSDichVu.SelectedValue.ToString(); bool checkBS = false; if (BILLS.checkIfExist(idService, _idBRoom) == null) { Bill_Service bs = new Bill_Service(); bs.id_BookRoom = _idBRoom; bs.id_Service = idService; bs.Service_Count = (int)numUpDown.Value; BILLS.insertBillService(bs); checkBS = true; } else { checkBS = BILLS.CapNhatSoLuong(_idBRoom, idService, sl); checkBS = true; } if (checkBRoom && checkRoom && checkBS) { MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Cập nhật không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public int insertBillService(Bill_Service bs) { System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction(); try { dt.Transaction = myTran; if (checkIfExist(bs.id_Service, bs.id_BookRoom) != null)// thay { return(0); } else { dt.Bill_Services.InsertOnSubmit(bs); dt.SubmitChanges(); dt.Transaction.Commit(); return(1); } } catch (Exception ex) { dt.Transaction.Rollback(); throw new Exception("Loi không thêm được " + ex.Message); } }