Esempio n. 1
0
        protected override long insert(bool forceWrite, bool callSaveMethod)
        {
            var unitPrice = (from item in new QueryableEntity<Items>()
                             where item.ItemID == this.ItemID
                             select item.Price).ToList();
            this.Amount = unitPrice[0] * this.Quantity;
            var order = (from o in new QueryableEntity<Order>()
                         where o.OrderID == this.OrderID
                         select o).ToList();
            order[0].Amount -= this.Amount;
            order[0].update();

            var miscCharge = new OrderMiscCharges();
            miscCharge.OrderID = this.OrderID;
            miscCharge.insert();

            return base.insert(forceWrite, callSaveMethod);
        }
Esempio n. 2
0
        private void computeMiscChargesForItem()
        {
            var deduction = (from d in new QueryableEntity<MiscCharge>()
                             where d.Default == true
                             orderby d.ChargeOrder
                             select d).ToList();
            MiscCharge tempD = null;
            foreach (var d in deduction)
            {
                if (tempD == null)
                    tempD = d;
                if (tempD.ChargeOrder == d.ChargeOrder)
                    TempValue = Amount;
                else if (tempD.ChargeOrder <= d.ChargeOrder)
                {
                    tempD = d;
                    TempValue = Amount + ExtraCharge;
                }

                if (d.DeductionType == DeductionType.Fixed)
                    ExtraCharge = d.Value;
                else if (d.DeductionType == DeductionType.Percentage)
                    ExtraCharge = (TempValue * d.Value) / 100;

                var orderMiscCharge = (from o in new QueryableEntity<OrderMiscCharges>()
                                       where o.OrderID == this.OrderID && o.MiscChargeID == d.DeductionID
                                       select o).AppFirst();
                if (orderMiscCharge == null)
                {
                   orderMiscCharge = new OrderMiscCharges
                    {
                        OrderID = this.OrderID,
                        Amount = ExtraCharge,
                        MiscChargeID = d.DeductionID,
                        ItemID = this.ItemID
                    };
                   orderMiscCharge.insert();
                }                
                else
                {
                    orderMiscCharge.Amount += ExtraCharge;
                    orderMiscCharge.TempMoney = ExtraCharge;
                    orderMiscCharge.update();
                }
            }
        }