Example #1
0
        public SaleItem AddNewSaleItem(Product prod, double qty, string lot = "")
        {
            if (!prod.Price1Reference.IsLoaded)
            {
                prod.Price1Reference.Load();
            }
            if (!prod.Price1.WeightReference.IsLoaded)
            {
                prod.Price1.WeightReference.Load();
            }
            double realPrice = prod.ByWeight ? prod.Price1.Value * (qty / prod.Price1.Weight.Quantity) : prod.Price1.Value;
            double tax1Value = realPrice*prod.Tax.Value;
            double tax2Value = !prod.Tax2Code.HasValue ? 0 : realPrice*prod.Tax1.Value;

            SaleItem item = SaleItem.CreateSaleItem(
                SaleItems.Count,
                TerminalCode,
                Code,
                TerminalToCode,
                lot,
                prod.Code,
                prod.MasterCode,
                prod.ByWeight,
                realPrice,
                prod.ByWeight ? qty : 1,
                tax1Value,
                tax2Value,
                realPrice - tax1Value - tax2Value);

            SaleItems.Add(item);
            CalculateValues();

            return item;
        }
        public DeliveryDocumentItem AddNewDeliveryDocumentItem(Product prod, double qty, string lot)
        {
            DeliveryDocumentItem item = DeliveryDocumentItem.CreateDeliveryDocumentItem
                    (DeliveryDocumentItems.Count,
                    TerminalCode,
                    Code,
                    TerminalToCode,
                    lot,
                    prod.Code,
                    prod.MasterCode,
                    prod.ByWeight,
                    prod.Price1 != null ? prod.Price1.Value : 0,
                    prod.ByWeight ? qty : 1);

            DeliveryDocumentItems.Add(item);

            return item;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProducts(Product product)
 {
     base.AddObject("Products", product);
 }
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="code">Initial value of the Code property.</param>
 /// <param name="byWeight">Initial value of the ByWeight property.</param>
 public static Product CreateProduct(global::System.Int32 code, global::System.Boolean byWeight)
 {
     Product product = new Product();
     product.Code = code;
     product.ByWeight = byWeight;
     return product;
 }
Example #5
0
 public StockItem AddNewStockItem(Product prod, double qty, string lot)
 {
     StockItem item = new StockItem(this, prod, qty, lot);
     StockItems.Add(item);
     return item;
 }
        private bool BarcodeValidate(object parameter)
        {
            var e = (BarCodeValidationEventArgs)parameter;

            validProd = BusinessContext.Instance.Model.Products.FirstOrDefault(p => p.MasterCode == e.Code);
            if (validProd == null)
            {
                string strCode = e.Parts[1].Code.ToString();
                validProd = BusinessContext.Instance.Model.Products.FirstOrDefault(p => p.MasterCode.Equals(strCode));
                if (validProd == null)
                {
                    e.Parts[1].IsValid = false;
                    e.Error = string.Format(Resources.UnexistentProduct + " - {0}", e.Parts[1].Code);
                }
                else if (validProd.ByWeight && string.IsNullOrEmpty(_lot))
                {
                    e.Parts[1].IsValid = false;
                    e.Error = "Ingrese un Código de lote para este producto";
                }
            }
            Message = e.Error;
            return true;
        }
        private void AddItem(Product product, int qty, string lot)
        {
            StockItemsCollection.Add(StockHeader.AddNewStockItem(product, qty, lot));

            if (StockHeader.DeliveryDocumentHeader != null)
                StockHeader.DeliveryDocumentHeader.AddNewDeliveryDocumentItem(validProd, qty, lot);

            Message = product.Name ?? validProd.ShortDescription ?? validProd.Description;
            saveCommand.RaiseCanExecuteChanged();
            CancelCommand.RaiseCanExecuteChanged();
        }