Пример #1
0
 public void SetupCreate()
 {
     output_StorageID.Text  = StorageRoom.GetNextID().ToString();
     btn_JustQuit.Click    += delegate { this.Close(); };
     btn_SaveAndQuit.Click += delegate
     {
         if (textBox_Name.Text == "" || textBox_descr.Text == "")
         {
             textBox_Name.BorderBrush  = Brushes.DarkGray;
             textBox_descr.BorderBrush = Brushes.DarkGray;
             if (textBox_Name.Text == "")
             {
                 textBox_Name.BorderBrush = Brushes.Red;
             }
             if (textBox_descr.Text == "")
             {
                 textBox_descr.BorderBrush = Brushes.Red;
             }
         }
         else
         {
             string storageRoomName  = textBox_Name.Text;
             string storageRoomDescr = textBox_descr.Text;
             ControllerSto.CreateStorageRoom(storageRoomName, storageRoomDescr);
             this.Close();
         }
     };
 }
Пример #2
0
 public CreateStorageRoom(StorageController stoController, StorageRoom stoRoom)
 {
     ControllerSto     = stoController;
     storageRoomToEdit = stoRoom;
     InitializeComponent();
     SetupEdit();
 }
Пример #3
0
        public void EditStorageRoom(int id, string name, string description)
        {
            StorageRoom roomToEdit = StorageRoomDictionary[id];

            roomToEdit.Name        = name;
            roomToEdit.Description = description;
            roomToEdit.UpdateInDatabase();
        }
Пример #4
0
        public void CreateStorageRoomStorageControllerTest()
        {
            int old_id = StorageRoom.GetNextID();

            SC.CreateStorageRoom("TestRoom", "Dette TestRum er kun til test");
            int new_id = StorageRoom.GetNextID();

            Assert.IsTrue((new_id > old_id) && SC.StorageRoomDictionary.ContainsKey(old_id));
        }
Пример #5
0
        //Adds new storage room to dictionary, and to all products
        public void CreateStorageRoom(string name, string description)
        {
            StorageRoom newRoom = new StorageRoom(name, description);

            StorageRoomDictionary.Add(newRoom.ID, newRoom);

            foreach (Product product in ProductDictionary.Values)
            {
                product.StorageWithAmount.Add(newRoom, 0);
            }
        }
Пример #6
0
        private void HandleFirstPool()
        {
            Row Data;

            while (!FirstPoolDone())
            {
                while (_serviceProductQueue.TryDequeue(out Data))
                {
                    ServiceProduct NewServiceProduct = new ServiceProduct(Data);
                    ServiceProductDictionary.TryAdd(NewServiceProduct.ID, NewServiceProduct);
                    Interlocked.Increment(ref _doneServiceProductCount);
                }
                while (_tempProductQueue.TryDequeue(out Data))
                {
                    TempProduct NewTempProduct = new TempProduct(Data);
                    TempProductDictionary.TryAdd(NewTempProduct.ID, NewTempProduct);
                    Interlocked.Increment(ref _doneTempProductCount);
                }
                while (_storageRoomQueue.TryDequeue(out Data))
                {
                    StorageRoom NewStorageRoom = new StorageRoom(Data);
                    StorageRoomDictionary.TryAdd(NewStorageRoom.ID, NewStorageRoom);
                    Interlocked.Increment(ref _doneStorageRoomsCount);
                }
                while (_groupsQueue.TryDequeue(out Data))
                {
                    Group NewGroup = new Group(Data);
                    GroupDictionary.TryAdd(NewGroup.ID, NewGroup);
                    Interlocked.Increment(ref _doneGroupsCount);
                }
                while (_productQueue.TryDequeue(out Data))
                {
                    Product NewProduct = new Product(Data);
                    ProductDictionary.TryAdd(NewProduct.ID, NewProduct);
                    Interlocked.Increment(ref _doneProductsCount);
                }

                while (_disabledProductsQueue.TryDequeue(out Data))
                {
                    Product NewProduct = new Product(Data);
                    DisabledProducts.TryAdd(NewProduct.ID, NewProduct);
                    Interlocked.Increment(ref _doneDisabledProductsCount);
                }
                while (_disabledServiceProductsQueue.TryDequeue(out Data))
                {
                    ServiceProduct NewProduct = new ServiceProduct(Data);
                    DisabledServiceProducts.TryAdd(NewProduct.ID, NewProduct);
                    Interlocked.Increment(ref _doneDisabledServiceProductsCount);
                }
            }
        }
Пример #7
0
        public async Task <IActionResult> OnGetAsync(int?idStorageFacilities)
        {
            if (idStorageFacilities == null)
            {
                return(NotFound());
            }

            StorageRoom = await context.TStorageRoom.FindAsync(idStorageFacilities);

            if (StorageRoom == null)
            {
                return(NotFound());
            }

            return(Page());
        }
Пример #8
0
        public void DeleteStorageRoomStorageControllerTest()
        {
            int old_id = StorageRoom.GetNextID();

            SC.CreateStorageRoom("TestRoom", "Dette TestRum er kun til test");
            int  new_id    = StorageRoom.GetNextID();
            bool FirstStep = (new_id > old_id) && SC.StorageRoomDictionary.ContainsKey(old_id);

            if (FirstStep)
            {
                SC.DeleteStorageRoom(old_id);
                Assert.IsTrue(!SC.StorageRoomDictionary.ContainsKey(old_id));
            }
            else
            {
                Assert.Fail();
            }
        }
Пример #9
0
 //Removes storage room from dictionary, and all products
 public void DeleteStorageRoom(int id)
 {
     if (id != 1)
     {
         string      CheckProductsStorageAmount = $"SELECT * FROM `storage_status` WHERE `amount` != '0' AND `storageroom` = '{id}'";
         TableDecode Results = Mysql.RunQueryWithReturn(CheckProductsStorageAmount);
         if (Results.RowCounter != 0)
         {
             MessageBox.Show("Du kan ikke slette lager rum som stadig har varer på lager!");
         }
         else
         {
             if (StorageRoomDictionary.ContainsKey(id))
             {
                 StorageRoomDictionary[id].DeactivateStorageRoom();
                 foreach (Product product in ProductDictionary.Values)
                 {
                     int h = 0;
                     product.StorageWithAmount.TryRemove(id, out h);
                 }
                 StorageRoom outVal = null;
                 StorageRoomDictionary.TryRemove(id, out outVal);
                 string deleteQuery = $"DELETE FROM `storage_status` WHERE `storageroom` = '{id}'";
                 Mysql.RunQuery(deleteQuery);
             }
             else
             {
                 MessageBox.Show("Det lager du forsøger at slette, eksistere ikke...");
             }
         }
     }
     else
     {
         MessageBox.Show("Du kan ikke slette butikken!");
     }
 }
Пример #10
0
        private void HandleSecondPool()
        {
            Row Data;

            if (FirstPoolDone())
            {
                Debug.WriteLine("First Queue is [DONE] going to second queue");
            }
            while (!SecondPoolDone())
            {
                while (_storageStatusQueue.TryDequeue(out Data))
                {
                    int id = Convert.ToInt32(Data.Values[0]);
                    if (ProductDictionary.ContainsKey(id))
                    {
                        ProductDictionary[id].StorageWithAmount.TryAdd(Convert.ToInt32(Data.Values[1]), Convert.ToInt32(Data.Values[2]));
                    }
                    else
                    {
                        DisabledProducts[id].StorageWithAmount.TryAdd(Convert.ToInt32(Data.Values[1]), Convert.ToInt32(Data.Values[2]));
                    }
                    Interlocked.Increment(ref _doneStorageStatusCount);
                }
                while (_storageTransactionsQueue.TryDequeue(out Data))
                {
                    int ProductID     = Convert.ToInt32(Data.Values[1]);
                    int SourceID      = Convert.ToInt32(Data.Values[4]);
                    int DestinationID = Convert.ToInt32(Data.Values[5]);
                    if (StorageRoomDictionary.ContainsKey(SourceID) && StorageRoomDictionary.ContainsKey(DestinationID))
                    {
                        StorageTransaction StorageTrans = new StorageTransaction(Data, true);
                        StorageRoom        Source       = StorageRoomDictionary[SourceID];
                        StorageRoom        Destination  = StorageRoomDictionary[DestinationID];
                        BaseProduct        prod;
                        if (ProductDictionary.ContainsKey(ProductID))
                        {
                            prod = ProductDictionary[ProductID];
                        }
                        else
                        {
                            prod = DisabledProducts[ProductID];
                        }
                        StorageTrans.SetInformation(Source, Destination, prod);
                        StorageTransactionDictionary.TryAdd(StorageTrans.ID, StorageTrans);
                    }
                    Interlocked.Increment(ref _doneStorageTransactionCount);
                }
                while (_orderTransactionsQueue.TryDequeue(out Data))
                {
                    OrderTransaction OrderTrans = new OrderTransaction(Data, true);
                    int ProductID = Convert.ToInt32(Data.Values[1]);
                    if (ProductDictionary.ContainsKey(ProductID))
                    {
                        OrderTrans.SetInformation(ProductDictionary[ProductID]);
                    }
                    else
                    {
                        OrderTrans.SetInformation(DisabledProducts[ProductID]);
                    }
                    OrderTransactionDictionary.TryAdd(OrderTrans.ID, OrderTrans);
                    Interlocked.Increment(ref _doneOrderTransactionCount);
                }
            }
        }