Beispiel #1
0
        void UpdateQuoteRelationAmount()
        {
            QuoteDetailView view = this._detailView as QuoteDetailView;

            view.PostEditors();
            Quote quote = this.ObjectEntity as Quote;

            var     quoteLineItems      = quote.QuoteLineItems;
            decimal totalLineItemAmount = 0;

            foreach (QuoteLineItem item in quoteLineItems)
            {
                QuoteLineItem currentLineItem = item;
                decimal       unitPrice       = currentLineItem.UnitPrice ?? 0;
                decimal       quantity        = currentLineItem.Quantity ?? 0;

                decimal totalPrice = unitPrice * quantity;
                currentLineItem.TotalPrice = totalPrice;
                currentLineItem.QuoteId    = this.ObjectId;
                totalLineItemAmount       += totalPrice;
            }
            quote.TotalLineItemAmount = totalLineItemAmount;
            decimal totalDiscountAmount = quote.TotalDiscountAmount ?? 0;
            decimal totalTax            = quote.TotalTax ?? 0;

            quote.TotalAmount = totalLineItemAmount - totalDiscountAmount + totalTax;
        }
Beispiel #2
0
        void ViewRemoveQuoteLineItem(object sender, EventArgs e)
        {
            QuoteDetailView view = this._detailView as QuoteDetailView;

            view.DeleteSelectedQuoteLineItem();
            UpdateQuoteRelationAmount();
        }
Beispiel #3
0
        protected override void OnViewSet()
        {
            base.OnViewSet();
            QuoteDetailView view = this._detailView as QuoteDetailView;

            view.NewQuoteLineItem     += View_NewQuoteLineItem;
            view.RemoveQuoteLineItem  += ViewRemoveQuoteLineItem;
            view.CalculateTotalAmount += ViewCalculateTotalAmount;
            view.QuoteLineItemSelectProductChanged += ViewQuoteLineItemSelectProductChanged;

            productList = this._objectSpace.GetObjects("Product");
            view.PoppulateProducts(productList);
        }
Beispiel #4
0
        void ViewQuoteLineItemSelectProductChanged(object sender, EventArgs e)
        {
            QuoteDetailView view            = this._detailView as QuoteDetailView;
            QuoteLineItem   currentLineItem = view.CurrentQuoteLineItem as QuoteLineItem;

            Guid?productId = currentLineItem.ProductId;


            var product = productList.AsQueryable().Where("ProductId = @0", productId)._First();

            if (product != null)
            {
                Product pro = product as Product;
                currentLineItem.UnitPrice = pro.Price;
            }
            UpdateQuoteRelationAmount();
        }
Beispiel #5
0
        void View_NewQuoteLineItem(object sender, EventArgs e)
        {
            QuoteDetailView view = this._detailView as QuoteDetailView;

            view.AddNewQuoteLineItem();
        }