示例#1
0
        private void SaveLine()
        {
            try
            {
                SaveItemsMovementHeader();

                if (SelectedItemsMovement == null || SelectedItem == null ||
                    SelectedItemsMovement.Status != TransactionStatus.Draft)
                {
                    MessageBox.Show("Can't add item, try again later....");
                    return;
                }

                var newObject = SelectedItemsMovement.Id;

                if (_isEdit == false)
                {
                    SelectedItemsMovementLine = new ItemsMovementLineDTO
                    {
                        ItemsMovementHeader = SelectedItemsMovement
                    }
                }
                ;


                SelectedItemsMovementLine.ItemId                      = TransactionLine.Item.Id;
                SelectedItemsMovementLine.MovedQuantity               = TransactionLine.ItemMovedQuantity;
                SelectedItemsMovementLine.OriginPreviousQuantity      = TransactionLine.ItemOriginQuantity;
                SelectedItemsMovementLine.DestinationPreviousQuantity = TransactionLine.ItemDestinationQuantity;

                var stat = _imHeaderService.InsertOrUpdateChild(SelectedItemsMovementLine);
                if (stat == string.Empty)
                {
                    if (newObject == 0)
                    {
                        ItemsMovements.Insert(0, SelectedItemsMovement);
                    }

                    _isEdit = false;
                    GetSummary();
                    SelectedItemsMovement = SelectedItemsMovement;
                }
                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);
            }
        }
示例#2
0
        private void SaveItemsMovementHeader()
        {
            try
            {
                if (SelectedFromWarehouse.Id == -1 || SelectedToWarehouse.Id == -1)
                {
                    MessageBox.Show("Choose From and To stores/shops first...");
                    return;
                }
                if (SelectedFromWarehouse.Id == SelectedToWarehouse.Id)
                {
                    MessageBox.Show("From store/shop is same as To store/shop...");
                    return;
                }
                SelectedItemsMovement.FromWarehouseId = SelectedFromWarehouse.Id;
                SelectedItemsMovement.ToWarehouseId   = SelectedToWarehouse.Id;

                var newObject = SelectedItemsMovement.Id;

                var stat = _imHeaderService.InsertOrUpdate(SelectedItemsMovement);
                if (stat != string.Empty)
                {
                    MessageBox.Show("Can't save"
                                    + Environment.NewLine + stat, "Can't save", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }

                else if (newObject == 0)
                {
                    ItemsMovements.Insert(0, SelectedItemsMovement);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Can't save"
                                + Environment.NewLine + exception.Message, "Can't save", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }