예제 #1
0
 public static void ChangePasword(string Password)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var NewLogin = (from c in context.Logins where c.ID == AccountID select c).FirstOrDefault();
         NewLogin.password = Password;
         context.SaveChanges();
         ClearValues();
     }
 }
예제 #2
0
 public static void UpdateAccess(int ID, int Access)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var NewLogin = (from c in context.Logins where c.ID == ID select c).FirstOrDefault();
         NewLogin.access = Access;
         context.SaveChanges();
         ClearValues();
     }
 }
예제 #3
0
 public static void DeleteAccount(int ID)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var Account = (from c in context.Logins where c.ID == ID select c).SingleOrDefault();
         {
             context.Logins.Remove(Account);
             context.SaveChanges();
             ClearValues();
         }
     }
 }
예제 #4
0
 public static void UpdateBooking(DateTime BookingFrom, DateTime BookingTo, bool CheckedIn)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var booking = (from c in context.Bookings where c.ID == UserID select c).FirstOrDefault();
         booking.Booking_From = BookingFrom;
         booking.Booking_To   = BookingTo;
         booking.Checked_In   = CheckedIn;
         context.SaveChanges();
         ClearValues();
     }
 }
예제 #5
0
 public static void CreateAccount(string Name, string Password, int Access)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var New_Account = new Login();
         New_Account.user     = Name;
         New_Account.password = Password;
         New_Account.access   = Access;
         context.Logins.Add(New_Account);
         context.SaveChanges();
         ClearValues();
     }
 }
예제 #6
0
 public static void UpdateRoom(string RoomName, int SingleBeds, int DoubleBeds, string ExtraInfo)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var Room = (from c in context.Rooms where c.ID == RoomID select c).FirstOrDefault();
         Room.Room_Name   = RoomName;
         Room.Single_Beds = SingleBeds;
         Room.Double_Beds = DoubleBeds;
         Room.Extra_Info  = ExtraInfo;
         context.SaveChanges();
         ClearValues();
     }
 }
예제 #7
0
 public static void UpdateGuest(string Name, string Address, string Mobile, string Home_Phone)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var Guest = (from c in context.Guest_Info where c.ID == UserID select c).FirstOrDefault();
         Guest.Name       = Name;
         Guest.Address    = Address;
         Guest.Mobile     = Mobile;
         Guest.Home_Phone = Home_Phone;
         context.SaveChanges();
         ClearValues();
     }
 }
예제 #8
0
 public static void CreateBooking()
 {
     using (var context = new HotelDatabaseEntities())
     {
         var New_Charge = new Charge();
         New_Charge.Room_Charge = Room_Charge;
         New_Charge.Total       = Room_Charge;
         context.Charges.Add(New_Charge);
         context.SaveChanges();
         var New_Booking = new Booking();
         New_Booking.Room_IDFK    = RoomID;
         New_Booking.Guest_IDFK   = UserID;
         New_Booking.Charges_IDFK = New_Charge.ID;
         New_Booking.Booking_From = DateStart;
         New_Booking.Booking_To   = DateEnd;
         New_Booking.Checked_In   = false;
         context.Bookings.Add(New_Booking);
         context.SaveChanges();
         ClearValues();
         // our basic create a booking function
     }
 }
예제 #9
0
 public static void UpdateRoomPricing(int Single, int Double, int ESingle, int EDouble)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var Room_Prices = (from c in context.Room_Prices select c).FirstOrDefault();
         Room_Prices.Single_Price       = Single;
         Room_Prices.Double_Price       = Double;
         Room_Prices.Extra_Single_Price = ESingle;
         Room_Prices.Extra_Double_Price = EDouble;
         context.SaveChanges();
         ClearValues();
     }
 }
예제 #10
0
 public static void AddRoom(string Name, int Singles, int Doubles, string ExtraInfo)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var New_Room = new Room();
         New_Room.Room_Name   = Name;
         New_Room.Single_Beds = Singles;
         New_Room.Double_Beds = Doubles;
         New_Room.Extra_Info  = ExtraInfo;
         context.Rooms.Add(New_Room);
         context.SaveChanges();
         ClearValues();
     }
 }
 /// <summary>
 /// Invoked when users press OK button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnOKButton(object sender, RoutedEventArgs e)
 {
     if (!Validate())
     {
         MessageBox.Show("Wprowadzono niepoprawne dane, zweryfikuj je!", "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     if (roomObj == null)
     {
         context.room.Add((room)roomGrid.DataContext);
     }
     context.SaveChanges();
     Close();
 }
예제 #12
0
 public static void CreatGuest(string Name, string Address, string Mobile, string Home_Phone)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var New_Guest = new Guest_Info();
         New_Guest.Name       = Name;
         New_Guest.Address    = Address;
         New_Guest.Mobile     = Mobile;
         New_Guest.Home_Phone = Home_Phone;
         context.Guest_Info.Add(New_Guest);
         context.SaveChanges();
         ClearValues();
     }
 }
예제 #13
0
 public void AddEmployee(Employee e)
 {
     try
     {
         using (HotelDatabaseEntities context = new HotelDatabaseEntities())
         {
             context.Employees.Add(e);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception " + ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 public void AddVacationRequest(VacationRequest vr)
 {
     try
     {
         using (HotelDatabaseEntities context = new HotelDatabaseEntities())
         {
             context.VacationRequests.Add(vr);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception " + ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 public void DeleteVacationRequest(int ID)
 {
     try
     {
         using (HotelDatabaseEntities context = new HotelDatabaseEntities())
         {
             context.VacationRequests.Remove((from r in context.VacationRequests where r.RequestID == ID select r).FirstOrDefault());
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception " + ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #16
0
 public void UpdateEmployee(Employee emp)
 {
     try
     {
         using (HotelDatabaseEntities context = new HotelDatabaseEntities())
         {
             Employee employee = (from e in context.Employees where e.EmployeeID == emp.EmployeeID select e).FirstOrDefault();
             employee = emp;
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception " + ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #17
0
 public static void UpdateCharges(int Bar, int Internet, int Phone, int Room, int Additional, string Info)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var Charges = (from c in context.Charges where c.ID == Room_Charge select c).FirstOrDefault();
         Charges.Bar_Charge              = Bar;
         Charges.Internet_Charge         = Internet;
         Charges.Phone_Charge            = Phone;
         Charges.Room_Charge             = Room;
         Charges.Additional_Charges      = Additional;
         Charges.Additional_Charges_Info = Info;
         Charges.Total = Bar + Internet + Phone + Room + Additional; // Work out the total cost so that we can charge them at the end of their stay
         context.SaveChanges();
         ClearValues();
     }
 }
예제 #18
0
 public static bool DeleteRoom(int ID)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var Room = (from c in context.Rooms where c.ID == ID select c).SingleOrDefault();
         try
         {
             context.Rooms.Remove(Room);
             context.SaveChanges();
             ClearValues();
         }
         catch (System.Data.Entity.Infrastructure.DbUpdateException)
         {
             System.Windows.Forms.MessageBox.Show("Booking References Room, Cannot Remove."); // if a room is referenced by a booking, then the room cannot be removed
             return(false);
         }
         return(true);
     }
 }
예제 #19
0
 public static bool DeleteCharges(int ID)
 {
     using (var context = new HotelDatabaseEntities())
     {
         var Charges = (from c in context.Charges where c.ID == ID select c).SingleOrDefault();
         try
         {
             context.Charges.Remove(Charges);
             context.SaveChanges();
             ClearValues();
         }
         catch (System.Data.Entity.Infrastructure.DbUpdateException)
         {
             System.Windows.Forms.MessageBox.Show("Booking References Charges, Cannot Remove.");
             return(false);
         }
         return(true);
     }
 }