示例#1
0
        private bool SaveReservation()
        {
            try
            {
                if (CurrentItemQuantity.QuantityReserved > CurrentItemQuantity.QuantityOnHand)
                {
                    CurrentItemQuantity.QuantityReserved = CurrentItemQuantity.QuantityOnHand;
                }

                CurrentItemQuantity.QuantityOnHand = CurrentItemQuantity.QuantityOnHand -
                                                     CurrentItemQuantity.QuantityReserved;
                var stat = _itemQuantityService.InsertOrUpdate(CurrentItemQuantity, false);

                return(stat == string.Empty);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Got Problem while reserving, try again..." + Environment.NewLine + exception.Message,
                                "Reserve Problem", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return(false);
            }
        }
示例#2
0
        public JsonResult SaveItemReservation(int iqId, int quantityReserved, int soQuantityReserved, string onDate)
        {
            if (ModelState.IsValid)
            {
                var criteria = new SearchCriteria <ItemQuantityDTO>()
                {
                    CurrentUserId = Singleton.User.UserId
                };
                criteria.FiList.Add(b => b.Id == iqId);
                var iq = _itemQuantityService.GetAll(criteria).FirstOrDefault();
                if (iq != null)
                {
                    var prevreserved = iq.QuantityReserved;
                    iq.QuantityReserved = quantityReserved;
                    iq.ReservedOnDate   = Convert.ToDateTime(onDate);

                    if (iq.QuantityReserved > iq.QuantityOnHand)
                    {
                        iq.QuantityReserved = iq.QuantityOnHand;
                    }
                    iq.QuantityOnHand = iq.QuantityOnHand + (prevreserved - quantityReserved);

                    var stat = _itemQuantityService.InsertOrUpdate(iq, false);

                    if (string.IsNullOrEmpty(stat))
                    {
                        return(Json(true));
                    }
                    else
                    {
                        return(Json(false));
                    }
                }
                return(Json(false));
            }
            return(Json(false));
        }
示例#3
0
        private void ExecuteSaveItemViewCommand(object obj)
        {
            try
            {
                SelectedItem.CategoryId      = SelectedCategory.Id;
                SelectedItem.UnitOfMeasureId = SelectedUnitOfMeasure.Id;

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

                    #region Change Item Qty after adding a new PI

                    if (QuantityEditVisibility != null && QuantityEditVisibility == "Visible" && CurrentQuantity != null &&
                        _itemPreviousQty != CurrentQuantity && SelectedWarehouse != null && SelectedWarehouse.Id != -1)
                    {
                        var itemQty = new ItemQuantityDTO
                        {
                            WarehouseId    = SelectedWarehouse.Id,
                            ItemId         = SelectedItem.Id,
                            QuantityOnHand = CurrentQuantity
                        };
                        var stat2 = _itemQuantityService.InsertOrUpdate(itemQty, true);

                        if (stat2 == string.Empty)
                        {
                            CloseWindow(obj);
                        }
                        else
                        {
                            MessageBox.Show(
                                "item detail saved successfully but updating quantity failed, try again..." +
                                Environment.NewLine + stat2, "save error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    else
                    {
                        CloseWindow(obj);
                    }
                    #endregion
                }
                else
                {
                    MessageBox.Show("Got Problem while saving item, try again..." + Environment.NewLine + stat, "save error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Problem saving Item..." +
                                Environment.NewLine + exception.Message +
                                Environment.NewLine + exception.InnerException);
            }
        }