private void SavePiHeader() { try { var newObject = SelectedPi.Id; var stat = _piHeaderService.InsertOrUpdate(SelectedPi); if (stat != string.Empty) { MessageBox.Show("Can't save" + Environment.NewLine + stat, "Can't save", MessageBoxButton.OK, MessageBoxImage.Error); } else if (newObject == 0) { PhysicalInventories.Insert(0, SelectedPi); } } catch (Exception exception) { MessageBox.Show("Can't save" + Environment.NewLine + exception.Message, "Can't save", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void SaveLine() { try { if (SelectedPi == null || SelectedItem == null || SelectedPi.Status != PhysicalInventoryStatus.Draft) { MessageBox.Show("Can't add item, try again later...."); return; } var newObject = SelectedPi.Id; if (_isEdit == false) { SelectedPiLine = new PhysicalInventoryLineDTO() { PhysicalInventory = SelectedPi, PhysicalInventoryLineType = PhysicalInventoryLineTypes.AfterPi } } ; SelectedPiLine.ItemId = TransactionLine.Item.Id; SelectedPiLine.CountedQty = TransactionLine.ItemCountedQuantity; SelectedPiLine.ExpectedQty = TransactionLine.ItemCurrentQuantity; var stat = _piHeaderService.InsertOrUpdateChild(SelectedPiLine); if (stat == string.Empty) { if (newObject == 0) { PhysicalInventories.Insert(0, SelectedPi); } _isEdit = false; GetSummary(); SelectedPi = SelectedPi; } else { MessageBox.Show("Problem adding physical Inventory item, please try again..." + Environment.NewLine + stat); } } catch (Exception exception) { MessageBox.Show("Problem adding item, please try again..." + Environment.NewLine + exception.Message + Environment.NewLine + exception.InnerException); } }