void Save()

        {
            HttpClient          client          = new HttpClient();
            var                 requestString   = JsonConvert.SerializeObject(item);
            var                 httpContent     = new StringContent(requestString, Encoding.UTF8, "application/json");
            HttpResponseMessage responseMessage = client.PostAsync("http://localhost:5000/strgv1/new", httpContent).Result;

            if (responseMessage.IsSuccessStatusCode)
            {
                Item lastItem = new Item();
                if (items.Count > 0)
                {
                    lastItem = items.Last();
                }
                else
                {
                    lastItem.Id = 0;
                }
                NotifyView notifyView = new NotifyView();
                notifyView.ShowDialog();
                item.Id = lastItem.Id + 1;
                items.Add(new Item(item.Id, item.ItemName, item.Quantity, item.Unit, item.Min));
                addItem.Close();
            }
        }
Exemple #2
0
 private void AddCommandExecute()
 {
     try
     {
         if (EntryValidation.ValidateProductName(WarehouseItem.ProductName) == false)
         {
             MessageBox.Show("Product name can only contain letters and numbers. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateProductNumber(WarehouseItem.ProductNumber) == false)
         {
             MessageBox.Show("Product number can only contain numbers. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateAmount((int)WarehouseItem.Amount) == false)
         {
             MessageBox.Show("Amount must be greated than 0 and less or equat to 100. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidatePriceFormat(WarehouseItem.Price) == false)
         {
             MessageBox.Show("Price can contain only decimal numbers (numbers, comma and dot is allowed). Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidatePriceAmount(WarehouseItem.Price) == false)
         {
             MessageBox.Show("Price must be a positive number. Please try again", "Invalid input");
             return;
         }
         WarehouseItem.InStock = false;
         dataBaseService.AddWarehouseItem(WarehouseItem);
         IsUpdateWarehouseItem = true;
         string logMessage = string.Format("Warehouse Item: {0}, Item number: {1}, Item amount: {2}, Item price: {3} was added to database.", WarehouseItem.ProductName,
                                           WarehouseItem.ProductNumber, WarehouseItem.Amount, WarehouseItem.Price);
         actionEventObject.OnActionPerformed(logMessage);
         MessageBox.Show("New Warehouse Item Added Successfully!", "Info");
         addItem.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemple #3
0
        public void SubmitItem()
        {
            if (string.IsNullOrEmpty(ItemName) || string.IsNullOrEmpty(ItemCode) ||
                CostPrice <= 0 || SellPrice <= 0 || BaseUnitCount <= 0)
            {
                AddItemErrorVisibility = true;
                ErrorText = StringConstants.AllFieldsAreMandatory;
                return;
            }
            var sellPriceWithProfileMargin = CostPrice + ((CostPrice * Convert.ToInt32(SettingHelpers.CompanyConfigruationObject.ProfitMargin)) / 100);

            if (SellPrice < sellPriceWithProfileMargin)
            {
                AddItemErrorVisibility = true;
                ErrorText = StringConstants.SellPriceValidation;
                return;
            }
            if (CheckForUniqueItemcode(ItemCode))
            {
                AddItemErrorVisibility = false;
                ErrorText = string.Empty;
                ItemProfile itemProfile = new ItemProfile();
                itemProfile.UnitParamTypeId   = ((SystemParameter)_addItem.cbUnitType.SelectedItem).Id;
                itemProfile.CategoryId        = 1;
                itemProfile.ParentItemId      = null;
                itemProfile.IsActive          = true;
                itemProfile.Barcode           = Barcode;
                itemProfile.ItemNameEn        = ItemName;
                itemProfile.ItemNameSl        = ItemName;
                itemProfile.CompanyId         = SettingHelpers.CompanyConfigruationObject.CompanyId;
                itemProfile.BaseUnit          = BaseUnitCount;
                itemProfile.FlavourEn         = null;
                itemProfile.FlavourSl         = null;
                itemProfile.IsDeleted         = false;
                itemProfile.HasOffer          = false;
                itemProfile.IsOfferItem       = false;
                itemProfile.IsParentItem      = true;
                itemProfile.IsAutomaticPO     = false;
                itemProfile.CostPrice         = CostPrice;
                itemProfile.SellPrice         = SellPrice;
                itemProfile.SellPriceA        = SellPrice;
                itemProfile.SellPriceB        = SellPrice;
                itemProfile.SellPriceC        = SellPrice;
                itemProfile.SellPriceD        = SellPrice;
                itemProfile.Code              = ItemCode;
                itemProfile.PreviousCostPrice = CostPrice;
                itemProfile.ProfitMargin      = Convert.ToInt32(SettingHelpers.CompanyConfigruationObject.ProfitMargin);
                itemProfile.CreatedDateTime   = DateTime.UtcNow;

                int id = _posRepository.AddUnregisteredItem(itemProfile);

                BackgroundWorker bgUnRegisteredIncident = new BackgroundWorker();
                bgUnRegisteredIncident.DoWork             += bgUnRegisteredIncident_DoWork;
                bgUnRegisteredIncident.RunWorkerCompleted += bgUnRegisteredIncident_RunWorkerCompleted;
                bgUnRegisteredIncident.RunWorkerAsync(id);

                SettingHelpers.IsUnRegisteredItem = false;
                _addItem.DialogResult             = true;
                _addItem.Close();
            }
            else
            {
                AddItemErrorVisibility = true;
                ErrorText = StringConstants.UniqueItemCode;
                return;
            }
        }