예제 #1
0
 /// <summary>
 /// Removes orderline from the current order
 /// </summary>
 /// <param name="orderLine"></param>
 public void RemoveOrderLine(OrderLine orderLine)
 {
     if (CanOrderBeChanged())
     {
         OrderLines.Remove(orderLine);
     }
 }
예제 #2
0
파일: Order.cs 프로젝트: adobski/blueprism
        public void RemoveOrderLine(OrderLine orderLine)
        {
            var itemToRemove = OrderLines.Single(o => o.Id == orderLine.Id);

            DefaultPrice -= orderLine.TotalDefaultCost;
            ActualPrice  -= orderLine.TotalActualCost;

            OrderLines.Remove(itemToRemove);
        }
        public void CleanUpOrderLines()
        {
            List <DisplayOrderLine> LinesToRemove = OrderLines.Where(ol => ol.Amount <= 0).ToList();

            foreach (DisplayOrderLine orderLine in LinesToRemove)
            {
                OrderLines.Remove(orderLine);
            }
        }
예제 #4
0
        private void RemoveOrderLine(int id)
        {
            OrderLineViewModel ol = OrderLines.Where(o => o.Product.ID == id).SingleOrDefault();

            if (ol != null)
            {
                OrderLines.Remove(ol);
            }
            UpdateTotal();

            //Refresh the commands
            RaisePropertyChanged(nameof(OnCancelCommand));
            RaisePropertyChanged(nameof(OnOrderCommand));
        }
예제 #5
0
        private void OnQuantityValueChange(object sender, EventArgs e)
        {
            QuantityView quantity = sender as QuantityView;
            OrderLine    line     = quantity.CommandParameter as OrderLine;

            if (string.IsNullOrWhiteSpace(quantity.QuantityText) || Convert.ToDecimal(quantity.QuantityText) <= 0)
            {
                OrderLines.Remove(line);
            }
            else
            {
                line.ItemTotalPrice = line.ItemSellPrice * line.ItemOrderQty;
            }

            CalculateOrderTotalPrice();
        }
예제 #6
0
        public virtual void UpdateAuthorization(bool authorized, Guid productId, float quantity)
        {
            OrderLine toRemove = null;

            foreach (OrderLine line in OrderLines)
            {
                if (line.ProductId == productId)
                {
                    if (authorized)
                    {
                        line.AuthorizedQuantity = quantity;
                    }
                    else
                    {
                        toRemove = line;
                    }
                }
            }

            if (toRemove != null)
            {
                OrderLines.Remove(toRemove);
            }
        }
예제 #7
0
 public void RemoveOrderLine(OrderLine orderLine)
 {
     OrderLines.Remove(orderLine);
 }
예제 #8
0
 public void RemoveProduct(Product product)
 {
     OrderLines.Remove(OrderLines.FirstOrDefault(o => o.Product.Equals(product)));
 }
예제 #9
0
        public void ExpandOrderLines()
        {
            // if there are orderlines with multiple amounts of the same general material type then expand those lines into specific materials
            // raise an exception if there are insufficient materials available
            RentalItemActivityListItem[] OldOrderList = OrderLines.ToArray <RentalItemActivityListItem>();
            bool Success = true;

            LoadOrderLines();

            try
            {
                foreach (RentalItemActivityListItem ria in OrderLines.ToArray <RentalItemActivityListItem>())
                {
                    if (ria.RentalItemId == Guid.Empty)
                    {
                        string            Query = EntityDataSourceMaterials.CommandText;
                        ModelTMSContainer ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session);

                        Query = Query.Substring(0, Query.ToLower().IndexOf("order by"));
                        Query = Query.Substring(Query.ToLower().IndexOf("from"));
                        Query = "select value it " + Query + " order by it.BaseRentalPrice, it.Description";

                        ObjectQuery <RentalItem> oq = new ObjectQuery <RentalItem>(Query, ControlObjectContext);

                        oq.Parameters.Add(new ObjectParameter("StartDate", StartRentDate));
                        oq.Parameters.Add(new ObjectParameter("EndDate", EndRentDate));
                        oq.Parameters.Add(new ObjectParameter("BorderEndDate", Common.ReturnEntitySQLDateTimeString(new DateTime(2099, 12, 31))));
                        oq.Parameters.Add(new ObjectParameter("LocationId", LocationID));
                        oq.Parameters.Add(new ObjectParameter("RentalType", ria.RentalTypeId));

                        RentalItem[] RIs = oq.ToArray <RentalItem>();

                        int AmountToAdd = ria.RentalItemAmount;
                        if (RIs.Count() >= ria.RentalItemAmount)
                        {
                            // remove the orderline and expand with the specific material
                            OrderLines.Remove(ria);

                            foreach (RentalItem ri in RIs)
                            {
                                // and add the line for this item
                                RentalItemActivityListItem NewRia = new RentalItemActivityListItem();
                                NewRia.RentalItemId          = ri.Id;
                                NewRia.RentalItem            = ri.Description;
                                NewRia.RentalItemAmount      = 1;
                                NewRia.RentalType            = ri.RentalType.Description;
                                NewRia.RentalTypeId          = ri.RentalType.Id;
                                NewRia.TreatAsAdvancePayment = ria.TreatAsAdvancePayment;

                                ri.CalculateRentForPeriod(StartRentDate, EndRentDate, out NewRia.RentPrice, out NewRia.Vat, out NewRia.TotalRentPrice);
                                NewRia.BailPrice = ri.BailPrice;

                                OrderLines.Add(NewRia);

                                // need to add more ?
                                AmountToAdd--;
                                if (AmountToAdd <= 0)
                                {
                                    break;
                                }
                            }

                            Success = true;
                        }
                        else
                        {
                            Success = false;
                            throw new Exception(string.Format("Het aantal beschikbare materialen van {0} is onvoldoende om deze verhuring te kunnen uitleveren.", ria.RentalType));
                        }
                    }
                }
            }
            finally
            {
//                if (!Success)
//                {
//                    OrderLines.Clear();
//                    foreach(RentalItemActivityListItem OldRia in OldOrderList)
//                    {
//                        OrderLines.Add(OldRia);
//                    }
//                }
            }

            if (Success)
            {
                SaveOrderLines();
            }
        }