private void bntDel_Click(object sender, RoutedEventArgs e) { if (lvStock.SelectedItem == null) { MessageBox.Show("Stock must be selected to delete! Choose again!"); return; } var delStock = lvStock.SelectedItem as Stock; if (delStock != null) { MessageBoxResult delMess = MessageBox.Show("This action will delete all following stock details! Do you want to delete " + delStock.Name + "(" + delStock.StoId + ")?", "Warning! Are you sure?", MessageBoxButton.YesNo); if (delMess == MessageBoxResult.Yes) { delStock.Deleted = 1; _unitofwork.StockRepository.Update(delStock); _unitofwork.Save(); // refesh data ((APWareHouseWindow)Window.GetWindow(this)).Refresh_Tick(null, new EventArgs()); lvStock.Items.Refresh(); } } else { MessageBox.Show("Please choose stock you want to delete and try again!"); } }
private void bntAdd_Click(object sender, RoutedEventArgs e) { try { if (ErrorDetailsItem.Count != 0) { MessageBox.Show("Something is not correct. Please check all your input again!"); return; } if (_currentStockOut.StockOutDetails.Count == 0) { MessageBox.Show("You have to choose the stock you want to take out"); return; } _currentStockOut.Outtime = DateTime.Now; _unitofwork.StockOutRepository.Insert(_currentStockOut); //ToDo: Update the contain value in Warehouse database UpdateAPWareHouseContain(); _unitofwork.Save(); _stockOutDetailsList = new List <StockOutDetails>(); lvDataStockOut.ItemsSource = _stockOutDetailsList; lvDataStockOut.Items.Refresh(); _currentStockOut = new StockOut() { Adid = (App.Current.Properties["AdLogin"] as AdminRe).AdId, StockOutDetails = _stockOutDetailsList }; LoadStockOutData(); } catch (Exception ex) { MessageBox.Show("Something went wrong when trying to input the new StockOut Receipt! May be you should reload this app or call for support!"); } }