コード例 #1
0
        private int GetFridgeIdByComboboxText(ComboBox combo)
        {
            int id_fr = 0;

            using (hotelDBEntities context = new hotelDBEntities())
            {
                Fridge fridge = context.Fridges.FirstOrDefault(r => r.name == combo.Text);
                id_fr = fridge.id_fr;
            }
            return(id_fr);
        }
コード例 #2
0
        private int GetStorageIdByComboboxText(ComboBox combo)
        {
            int id_st = 0;

            using (hotelDBEntities context = new hotelDBEntities())
            {
                Storage storage = context.Storages.FirstOrDefault(r => r.name == combo.Text);
                id_st = storage.id_st;
            }
            return(id_st);
        }
コード例 #3
0
 private void DeleteProductFromDatabase()
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Product product = context.Products.FirstOrDefault(r => r.name == combo_productnames.Text);
         context.Products.Remove(product);
         context.SaveChanges();
         MessageBox.Show("Produkt odstraněn z databáze !");
     }
     FillCombobox_Productnames();
 }
コード例 #4
0
 public void UpdateFridgeProducts(int id_fridge, int id_product, int amount)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Product_Fridge fridge_product = context.Product_Fridge.FirstOrDefault(r => (r.id_fr == id_fridge) && (r.id_pr == id_product));
         int?           currentamount  = fridge_product.amount;
         currentamount         = currentamount + amount;
         fridge_product.amount = currentamount;
         context.SaveChanges();
     }
 }
コード例 #5
0
 private void DeleteStorageProductAmount(int id_storage, int id_product, int amount)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Storage_Product storage_product = context.Storage_Product.FirstOrDefault(r => (r.id_st == id_storage) && (r.id_pr == id_product));
         int?            currentamount   = storage_product.amount;
         currentamount          = currentamount - amount;
         storage_product.amount = currentamount;
         context.SaveChanges();
     }
 }
コード例 #6
0
 private void DeleteAttributeFromDatabase()
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Attribute attribute = context.Attributes.FirstOrDefault(r => r.name == combo_attributenames.Text);
         context.Attributes.Remove(attribute);
         context.SaveChanges();
         MessageBox.Show("Vlastnost odstraněna z databáze !");
     }
     FillCombobox_Attributenames();
 }
コード例 #7
0
 private void DeleteStorageFromDatabase()
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Storage storage = context.Storages.FirstOrDefault(r => r.name == combo_storagenames.Text);
         context.Storages.Remove(storage);
         context.SaveChanges();
         MessageBox.Show("Sklad odstraněn z databáze !");
     }
     FillCombobox_Storagenames();
 }
コード例 #8
0
        private int GetProductIdByComboboxText(ComboBox combo)
        {
            int id_pr = 0;

            using (hotelDBEntities context = new hotelDBEntities())
            {
                Product product = context.Products.FirstOrDefault(r => r.name == combo.Text);
                id_pr = product.id_pr;
            }
            return(id_pr);
        }
コード例 #9
0
 private void DeleteRoomFromDatabase()
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         int  id_room = Int32.Parse(combo_roomnames.Text);
         Room room    = context.Rooms.FirstOrDefault(r => r.id_ro == id_room);
         context.Rooms.Remove(room);
         context.SaveChanges();
         MessageBox.Show("Pokoj odstraněn z databáze !");
     }
     FillCombobox_Roomnames();
 }
コード例 #10
0
        private decimal CalculateProductAmountPrices(int id_product, int amount)
        {
            decimal money = 0;

            using (hotelDBEntities context = new hotelDBEntities())
            {
                Product product = context.Products.FirstOrDefault(r => r.id_pr == id_product);
                money = product.price * amount;
            }

            return(money);
        }
コード例 #11
0
 private void FillCombobox_Roomnames()
 {
     combo_chooseroom.Items.Clear();
     using (hotelDBEntities context = new hotelDBEntities())
     {
         List <Room> roomlist = context.Rooms.ToList();
         foreach (Room room in roomlist)
         {
             combo_chooseroom.Items.Add("Pokoj č.: " + room.id_ro + ", počet postelí: " + room.beds);
         }
     }
 }
コード例 #12
0
 private void FillCombobox_Storagenames()
 {
     combo_storagenames.Items.Clear();
     using (hotelDBEntities context = new hotelDBEntities())
     {
         List <Storage> storagelist = context.Storages.ToList();
         foreach (Storage storage in storagelist)
         {
             combo_storagenames.Items.Add(storage.name);
         }
     }
     combo_storagenames.SelectedIndex = 0;
 }
コード例 #13
0
 private void FillCombobox_Productnames()
 {
     combo_productnames.Items.Clear();
     using (hotelDBEntities context = new hotelDBEntities())
     {
         List <Product> productlist = context.Products.ToList();
         foreach (Product product in productlist)
         {
             combo_productnames.Items.Add(product.name);
         }
     }
     combo_productnames.SelectedIndex = 0;
 }
コード例 #14
0
 private void DeleteAttributeFromRoom()
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         int       roomid            = Convert.ToInt32(combo_6deleteroomid.Text);
         Room      selectedroom      = context.Rooms.FirstOrDefault(r => r.id_ro == roomid);
         Attribute selectedattribute = context.Attributes.FirstOrDefault(r => r.name == combo_6deleteroomattributes.Text);
         selectedroom.Attributes.Remove(selectedattribute);
         context.SaveChanges();
         MessageBox.Show("Vlastnost odebrána pokoji !");
         FillCombobox_Roomattributes();
     }
 }
コード例 #15
0
 private void AddAttributeToDatabase(string attribute)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         context.Attributes.Add(new Attribute {
             name = attribute
         });
         context.SaveChanges();
         MessageBox.Show("Vlastnost přidána do databáze !");
         txt_attributename.Text = String.Empty;
         FillCombobox_Attributenames();
     }
 }
コード例 #16
0
 private void AddFridgeToDatabase(string name)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         context.Fridges.Add(new Fridge {
             name = txt_fridgename.Text
         });
         context.SaveChanges();
         MessageBox.Show("Lednice přidána do databáze !");
         txt_fridgename.Text = String.Empty;
         FillCombobox_Fridgenames();
     }
 }
コード例 #17
0
 private void AddStorageToDatabase(string name)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         context.Storages.Add(new Storage {
             name = txt_storagename.Text
         });
         context.SaveChanges();
         MessageBox.Show("Sklad přidán do databáze !");
         txt_storagename.Text = String.Empty;
         FillCombobox_Storagenames();
     }
 }
コード例 #18
0
 private void AddProductToDatabase(string name, decimal price)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         context.Products.Add(new Product {
             name = name, price = price
         });
         context.SaveChanges();
         MessageBox.Show("Produkt přidán do databáze !");
         txt_productname.Text  = String.Empty;
         txt_productprice.Text = String.Empty;
         FillCombobox_Productnames();
     }
 }
コード例 #19
0
 private void UpdateStorageProducts(int id_product, int id_storage, int amount)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Storage_Product product_storage = context.Storage_Product.FirstOrDefault(r => (r.id_pr == id_product) && (r.id_st == id_storage));
         int?            currentamount   = product_storage.amount;
         MessageBox.Show("BYLO : " + currentamount.ToString());
         currentamount = currentamount + amount;
         MessageBox.Show("PO PRIDANI : " + currentamount.ToString());
         product_storage.amount = currentamount;
         context.SaveChanges();
         MessageBox.Show("OK PRIDANO");
     }
 }
コード例 #20
0
        private void Btn_addProduct1_Click(object sender, RoutedEventArgs e)
        {
            int    id_room           = 0;
            string s                 = label_room1.Content.ToString();
            var    separetedroomname = s.Split(' '); // Cislo0pokoje1:2CISLO3

            id_room = Convert.ToInt32(separetedroomname[3]);

            int id_fridge  = 0;
            int id_product = 0;
            int amount     = 0;

            using (hotelDBEntities context = new hotelDBEntities())
            {
                Room room = context.Rooms.FirstOrDefault(r => r.id_ro == id_room);
                id_fridge = room.Fridge.id_fr;

                Product product = context.Products.FirstOrDefault(r => r.name == combo_roomproducts1.SelectedItem.ToString());
                id_product = product.id_pr;
            }

            amount = Int32.Parse(txt_productamount1.Text);

            if (storageFunction.IsEnoughAmountInFridge(id_fridge, id_product, amount) == true)
            {
                string name          = combo_choosereservation.SelectedItem.ToString();
                var    nameseparated = name.Split(' ');
                string firstname     = nameseparated[0];
                string lastname      = nameseparated[1];

                using (hotelDBEntities context = new hotelDBEntities())
                {
                    Reservation reservation = context.Reservations.FirstOrDefault(r => r.id_re == id_reservation);
                    reservation.price_total = reservation.price_total + CalculateProductAmountPrices(id_product, amount);
                    context.SaveChanges();
                }

                storageFunction.DeleteFridgeProducts(id_fridge, id_product, amount);

                FillCombobox_reservations();

                MessageBox.Show("Úspěšně odepsáno z lednice a přidáno do zaplacení!");
            }
            else
            {
                MessageBox.Show("V lednici nebylo tolik produktů !");
                return;
            }
        }
コード例 #21
0
 private bool DoesProductInFridgeExists(int id_fridge, int id_product)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Product_Fridge fridge_product = context.Product_Fridge.FirstOrDefault(r => (r.id_fr == id_fridge) && (r.id_pr == id_product));
         if (fridge_product != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
コード例 #22
0
 private bool DoesProductInStorageExists(int id_product, int id_storage)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Storage_Product product_storage = context.Storage_Product.FirstOrDefault(r => (r.id_pr == id_product) && (r.id_st == id_storage));
         if (product_storage != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
コード例 #23
0
        private void AddRoomToDatabase(int beds, decimal price, string fridgename)
        {
            using (hotelDBEntities context = new hotelDBEntities())
            {
                Fridge fridge = context.Fridges.FirstOrDefault(r => r.name == fridgename);

                context.Rooms.Add(new Room {
                    beds = beds, price_per_day = price, id_fr = fridge.id_fr
                });
                context.SaveChanges();
                MessageBox.Show("Pokoj přidán do databáze !");
                txt_roombeds.Text        = String.Empty;
                txt_roompriceperday.Text = String.Empty;
                FillCombobox_Roomnames();
            }
        }
コード例 #24
0
 private void FillCombobox_Fridgenames()
 {
     combo_fridges.Items.Clear();
     combo_gridfridges.Items.Clear();
     using (hotelDBEntities context = new hotelDBEntities())
     {
         List <Fridge> fridgelist = context.Fridges.ToList();
         foreach (Fridge fridge in fridgelist)
         {
             combo_fridges.Items.Add(fridge.name);
             combo_gridfridges.Items.Add(fridge.name);
         }
     }
     combo_fridges.SelectedIndex     = 0;
     combo_gridfridges.SelectedIndex = 0;
 }
コード例 #25
0
 private void FillCombobox_Attributenames()
 {
     combo_attributenames.Items.Clear();
     combo_6roomattributes.Items.Clear();
     using (hotelDBEntities context = new hotelDBEntities())
     {
         List <Attribute> attributelist = context.Attributes.ToList();
         foreach (Attribute attribute in attributelist)
         {
             combo_attributenames.Items.Add(attribute.name);
             combo_6roomattributes.Items.Add(attribute.name);
         }
     }
     combo_attributenames.SelectedIndex  = 0;
     combo_6roomattributes.SelectedIndex = 0;
 }
コード例 #26
0
 private void FillCombobox_reservations()
 {
     combo_choosereservation.Items.Clear();
     // Vyplnit combobox - jméno, příjmení
     using (hotelDBEntities context = new hotelDBEntities())
     {
         List <Reservation> reservationlist = context.Reservations.ToList();
         foreach (Reservation reservation in reservationlist)
         {
             if (reservation.ispayed == false)
             {
                 combo_choosereservation.Items.Add(reservation.firstname + " " + reservation.lastname);
             }
         }
     }
     //combo_choosereservation.SelectedIndex = 0;
 }
コード例 #27
0
        private void FillDatagrid_Roomswithoutreservation()
        {
            if (datagrid_reservationdays.HasItems)
            {
                datagrid_reservationdays.Items.Clear();
            }

            DateTime pickerdate1 = date_reservationfrom.SelectedDate.Value; // Datepicked "Rezervace od" - do DateTime
            DateTime pickerdate2 = date_reservationto.SelectedDate.Value;   // Datepicked "Rezervace do" - do DateTime

            using (hotelDBEntities context = new hotelDBEntities())
            {
                var roomreservationslist = context.view_RoomReservations.ToList();


                foreach (view_RoomReservations roomreservations in roomreservationslist)
                {
                    DateTime datetime1  = roomreservations.date_from ?? DateTime.Now; // Datum rezervace z databáze (date_from)
                    DateTime datetime2  = roomreservations.date_to ?? DateTime.Now;   // Datum rezervace z databáze (date_to)
                    var      datesrooms = DaysBetweenTwoDatesList(datetime1, datetime2);

                    foreach (var date in datesrooms)
                    {
                        if (reserved_id_ro.Contains(roomreservations.id_ro)) // Pokuď pokoj již byl rezervován v jinčí rezervaci na toto datum -> pokračuj
                        {
                            continue;
                        }
                        if ((pickerdate1 <= date) && (date <= pickerdate2)) // Pokuď se datum nachází mezi vybranými datumy rezervace -> přidej do seznamu pokojů, které nechceme
                        {
                            reserved_id_ro.Add(roomreservations.id_ro);
                        }
                    }
                }
                var roomlist = context.Rooms.ToList();
                combo_rooms1.Items.Clear(); // Clearnu a vyplním combobox s výběrem, aby nešlo vybrat pokoj, který je v tento datum zabraný
                foreach (Room room in roomlist)
                {
                    if (!reserved_id_ro.Contains(room.id_ro)) // Pokuď list již rezervovaných pokojů neobsahuje pokoj -> přidej ho do datagridu
                    {
                        datagrid_reservationdays.Items.Add(room);
                        combo_rooms1.Items.Add(room.id_ro);
                    }
                }
            }
        }
コード例 #28
0
 private void FillCombobox_FridgenamesWithoutRoomFridge(int id_fridge)
 {
     combo_4changefridge_choosefridge.Items.Clear();
     using (hotelDBEntities context = new hotelDBEntities())
     {
         List <Fridge> fridgelist = context.Fridges.ToList();
         foreach (Fridge fridge in fridgelist)
         {
             if (fridge.id_fr == id_fridge)
             {
                 label_4currentfridge.Content = "Má : " + fridge.name;
                 continue;
             }
             combo_4changefridge_choosefridge.Items.Add(fridge.name);
         }
     }
     combo_4changefridge_choosefridge.SelectedIndex = 0;
 }
コード例 #29
0
        private void FillDatagrid_Storage()
        {
            datagrid_storage.Items.Clear();
            using (hotelDBEntities context = new hotelDBEntities())
            {
                List <view_StorageProductAmount> storageproductlist = context.view_StorageProductAmount.ToList();

                List <Storage> storagelist = context.Storages.ToList();
                Storage        storage     = storagelist.FirstOrDefault(r => r.name == combo_gridstorages.SelectedItem.ToString());

                foreach (view_StorageProductAmount storageproduct in storageproductlist)
                {
                    if (storageproduct.id_st == storage.id_st)
                    {
                        datagrid_storage.Items.Add(storageproduct);
                    }
                }
            }
        }
コード例 #30
0
        private void FillDatagrid_Fridge()
        {
            datagrid_fridge.Items.Clear();
            using (hotelDBEntities context = new hotelDBEntities())
            {
                List <view_FridgeProductAmount> fridgeproductlist = context.view_FridgeProductAmount.ToList();

                List <Fridge> fridgelist = context.Fridges.ToList();
                Fridge        fridge     = fridgelist.FirstOrDefault(r => r.name == combo_gridfridges.SelectedItem.ToString());

                foreach (view_FridgeProductAmount fridgeproduct in fridgeproductlist)
                {
                    if (fridgeproduct.id_fr == fridge.id_fr)
                    {
                        datagrid_fridge.Items.Add(fridgeproduct);
                    }
                }
            }
        }