private async void btn_Finished_Click(object sender, EventArgs e) { Station currentstation = (await _repo.GetAssignedStation(user.EmployeeID)); lstbxOpen.Enabled = true; try { //If it gets locked by choosing a PO int pickedPO = getOpenListChoiceInt(); await _repo.SetProcessedOnkPOAsync(pickedPO, true); await _repo.SetLockOnkPOAsync(pickedPO, 0); } catch (IndexOutOfRangeException) { int pickedPO = currentstation.StationID; ProductOrder PO = await _repo.GetLockedPOByStation(currentstation.StationID); await _repo.SetProcessedOnkPOAsync(PO.ProductOrderID, true); await _repo.SetLockOnkPOAsync(PO.ProductOrderID, 0); //RefreshLockStatus(currentstation); } int pickedStation = currentstation.StationID; //inkapsla lstbxOpen.Enabled = true; btn_Finished.Enabled = false; btn_Refresh.Enabled = true; btn_Finished.BackColor = Color.Gray; btn_Finished.Text = ""; btn_Lock.Text = "Press to LOCK"; btn_Lock.BackColor = Color.Beige; btn_Lock.Enabled = true; this.Lockedstate = false; btnUnlocker.Enabled = false; btnUnlocker.Text = "Station is AVAILABLE"; btn_Refresh.Text = "Refresh"; // //inkapsla ProductOrder lockedPOs = await _repo.GetLockedPOByStation(currentstation.StationID); if (lockedPOs is ProductOrder) { Product lockedProduct = await _repo.GetProductInfoFromPO(lockedPOs.ProductOrderID); lblLockedPO.Text = "Order:" + lockedPOs.OrderID + ", PO:" + lockedPOs.ProductOrderID + ", " + lockedProduct.ProductName; } else { lblLockedPO.Text = ""; } // repopulate_POList(currentstation.InBuilding); repopulate_StuffingsList(currentstation.StationID); }