public int InsertAccount(Account a) { using (System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction()) { try { dt.Transaction = myTran; if (CheckIfExist(a.username) != null) { return(0); } else { dt.Accounts.InsertOnSubmit(a); dt.SubmitChanges(); dt.Transaction.Commit(); return(1); } } catch (Exception ex) { dt.Transaction.Rollback(); throw new Exception("Error Insert Account" + ex.Message); } } }
public int InsertEquipment(Equipment Equipment) { using (System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction()) { try { dt.Transaction = myTran; if (CheckIfExist(Equipment.id_Equipment) != null) { return(0); } else { dt.Equipments.InsertOnSubmit(Equipment); dt.SubmitChanges(); dt.Transaction.Commit(); return(1); } } catch (Exception ex) { dt.Transaction.Rollback(); throw new Exception("Error Insert!!" + ex.Message); } } }
public int InsertServiceStyle(ServiceStyle ss) { using (System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction()) { try { dt.Transaction = myTran; if (CheckIfExist(ss.id_SeviceStyle) != null) { return(0); } else { dt.ServiceStyles.InsertOnSubmit(ss); dt.SubmitChanges(); dt.Transaction.Commit(); return(1); } }catch (Exception ex) { dt.Transaction.Rollback(); throw new Exception("Error Insert Service" + ex.Message); } } }
public bool Delete(Customer cs) { if (checkIfExist(cs.id_Customer) != null) { using (System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction()) { try { dt.Transaction = myTran; dt.Customers.DeleteOnSubmit(cs); dt.SubmitChanges(); dt.Transaction.Commit(); return(true); } catch (Exception e) { dt.Transaction.Rollback(); throw new Exception(e.Message); } } } else { return(false); } }
public int InsertStaff(Staff staff) { using (System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction()) { try { dt.Transaction = myTran; if (CheckIfExist(staff.id_Staff) != null) { return(0); } else { dt.Staffs.InsertOnSubmit(staff); dt.SubmitChanges(); dt.Transaction.Commit(); return(1); //Phải tạo account rồi mới tạo được Staff -> mai fix } } catch (Exception ex) { dt.Transaction.Rollback(); throw new Exception("Error Insert!!" + ex.Message); } } }
public int insertBookRoom(Room r) { System.Data.Common.DbTransaction br = dt.Connection.BeginTransaction(); try { dt.Transaction = br; dt.Rooms.InsertOnSubmit(r); dt.SubmitChanges(); dt.Transaction.Commit(); return(1); } catch (Exception e) { dt.Transaction.Rollback(); throw new Exception(e.Message); } }
//hoang code public bool SuaThongTinBookRoomCuaKH(BookRoom bRoom, string maKH) { System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction(); try { dt.Transaction = myTran; IQueryable <BookRoom> tam = (from n in dt.BookRooms where n.id_Customer == maKH select n); tam.First().Checkin_Date = bRoom.Checkin_Date; tam.First().Checkout_Date = bRoom.Checkout_Date; tam.First().dateBooking = bRoom.dateBooking; tam.First().peopleCount = bRoom.peopleCount; dt.SubmitChanges(); dt.Transaction.Commit(); return(true); } catch (Exception ex) { dt.Transaction.Rollback(); throw new Exception("Loi khong sửa duoc " + ex.Message); } }
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); } }
//thêm loại phòng public int insertRoomStyle(RoomStyle rs) { System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction(); try { dt.Transaction = myTran; if (chkIfExist(rs.id_RoomStyle) != null) { return(0); } else { dt.RoomStyles.InsertOnSubmit(rs); dt.SubmitChanges(); dt.Transaction.Commit(); return(1); } } catch (Exception ex) { dt.Transaction.Rollback(); throw new Exception("Loi không sửa được " + ex.Message); } }