Ejemplo n.º 1
0
        private void SaveSaleOrder(DataType.SaleOrderStatus saleOrderStatus = DataType.SaleOrderStatus.NotBalanced)
        {
            _saleOrder.HowBalance = RadBanlanceModeCash.IsChecked.HasValue && RadBanlanceModeCash.IsChecked.Value
                    ? (SByte)DataType.SaleOrderBalancedMode.Cash
                    : RadBanlanceModeCard.IsChecked.HasValue && RadBanlanceModeCard.IsChecked.Value
                        ? (SByte)DataType.SaleOrderBalancedMode.MemberCard
                        : (SByte)DataType.SaleOrderBalancedMode.UnitUnionPay;

            _soProduceDomainModels.ForEach(
                x =>
            {
                x.SOProduce.RetailPrice             = x.SOProduce.Produce.RetailPrice;
                x.SOProduce.SOProduceStatusCategory = (sbyte)saleOrderStatus;
            });
            _saleOrder.FavorableCost     = _balanceDomainModel.DiscountPrice;
            _saleOrder.UserRealPrice     = _balanceDomainModel.RealPrice;
            _saleOrder.UserReturnedPrice = _balanceDomainModel.ReturnedPrice;
            _saleOrder.ProduceCost       = _soProduceDomainModels.Sum(x => x.SOProduce.Quantity * x.CostPerUnit);
            _saleOrder.TotalCost         = (_saleOrder.OtherCost ?? 0) + _saleOrder.ProduceCost;
            _saleOrder.SaleOrderStatus   = (sbyte)saleOrderStatus;

            if (_saleOrder.SaleOrderId == 0)
            {
                CommonHelper.AddCreatedOnAndDate(ResourcesHelper.CurrentUser, _saleOrder);
                _soProduceDomainModels.ForEach(x => CommonHelper.AddCreatedOnAndDate(ResourcesHelper.CurrentUser, x.SOProduce));
                _saleOrder.SOProduces = _soProduceDomainModels.Select(x => x.SOProduce).ToList();
                _saleOrderRepository.Create(_saleOrder);
            }
            else
            {
                CommonHelper.UpdateModifiedOnAndDate(ResourcesHelper.CurrentUser, _saleOrder);
                _soProduceDomainModels.ForEach(x => CommonHelper.AddCreatedOnAndDate(ResourcesHelper.CurrentUser, x.SOProduce));
                _saleOrder.SOProduces = _soProduceDomainModels.Select(x => x.SOProduce).ToList();
                _saleOrderRepository.Update(_saleOrder);
            }

            _saleOrder.SaleOrderStatus = (sbyte)saleOrderStatus;
        }
Ejemplo n.º 2
0
        public void CreateAndUpdateSaleOrder(SaleOrderContract saleOrderContract)
        {
            var saleorder = ISaleOrderRepository.Get(saleOrderContract.Id);

            if (saleorder != null)
            {
                saleorder.Code = saleOrderContract.Code;
                //saleorder.CreationDate = saleOrderContract.CreationDate; lazem nist moghe sakht object bevojode amede mesl Id
                saleorder.Title = saleOrderContract.Title;
                for (int i = 0; i < saleOrderContract.SaleOrderItemContracts.Count; i++)
                {
                    var Temp = saleOrderContract.SaleOrderItemContracts[i];
                    if (saleorder.saleOrderItems.Any(s => s.Id == Temp.Id))
                    {
                        var Insaleorderitem = saleorder.saleOrderItems.FirstOrDefault(s => s.Id == Temp.Id);
                        Insaleorderitem.NetPrice   = Temp.NetPrice;
                        Insaleorderitem.Quantity   = Temp.Quantity;
                        Insaleorderitem.TotalPrice = Temp.TotalPrice;
                        Insaleorderitem.UnitPrice  = Temp.UnitPrice;
                        Insaleorderitem.Rack       = IRackRepository.Get(Temp.RackId);
                        Insaleorderitem.Item       = IItemRepository.Get(Temp.ItemId);
                    }
                    else
                    {
                        Insaleorderitem            = new SaleOrderItem();
                        Insaleorderitem.NetPrice   = Temp.NetPrice;
                        Insaleorderitem.Quantity   = Temp.Quantity;
                        Insaleorderitem.TotalPrice = Temp.TotalPrice;
                        Insaleorderitem.UnitPrice  = Temp.UnitPrice;
                        Insaleorderitem.Rack       = IRackRepository.Get(Temp.RackId);
                        Insaleorderitem.Item       = IItemRepository.Get(Temp.ItemId);


                        saleorder.saleOrderItems.Add(Insaleorderitem);
                    }
                }
                //var DeleteOrderItem = saleorder.saleOrderItems.Where(x =>
                //    !saleOrderContract.SaleOrderItemContracts.Any(y => y.Id == x.Id));
                for (int i = 0; i < saleorder.saleOrderItems.Count; i++)
                {
                    var Temp = saleorder.saleOrderItems.ToArray()[i];
                    if (!saleOrderContract.SaleOrderItemContracts.Any(s => s.Id == Temp.Id))
                    {
                        saleorder.saleOrderItems.Remove(Temp);
                        //var temp = ISaleOrderRepository.Get(Temp.Id);
                        //ISaleOrderRepository.Delete(temp);
                    }
                }

                ISaleOrderRepository.Update(saleorder);
            }
            else
            {
                saleorder              = new SaleOrder();
                saleorder.Code         = saleOrderContract.Code;
                saleorder.CreationDate = saleOrderContract.CreationDate;
                saleorder.Title        = saleOrderContract.Title;
                for (int i = 0; i < saleOrderContract.SaleOrderItemContracts.Count; i++)
                {
                    var Temp = saleOrderContract.SaleOrderItemContracts[i];
                    Insaleorderitem            = new SaleOrderItem();
                    Insaleorderitem.NetPrice   = Temp.NetPrice;
                    Insaleorderitem.Quantity   = Temp.Quantity;
                    Insaleorderitem.TotalPrice = Temp.TotalPrice;
                    Insaleorderitem.UnitPrice  = Temp.UnitPrice;
                    Insaleorderitem.Rack       = IRackRepository.Get(Temp.RackId);
                    Insaleorderitem.Item       = IItemRepository.Get(Temp.ItemId);


                    saleorder.saleOrderItems.Add(Insaleorderitem);
                }



                ISaleOrderRepository.Insert(saleorder);
            }
        }
Ejemplo n.º 3
0
        //esmet ke doros nist
        public void CreateAndDelete(SaleOrderContract saleOrderContract)
        {
            var SaleOrder = ISaleOrderRepository.Get(saleOrderContract.Id);

            if (SaleOrder != null)
            {
                SaleOrder.CreationDate = DateTime.Now;
                SaleOrder.Title        = saleOrderContract.Title;
                SaleOrder.Code         = saleOrderContract.Code;

                for (int i = 0; i < saleOrderContract.SaleorderItems.Count; i++)
                {
                    var temp = saleOrderContract.SaleorderItems[i];
                    if (SaleOrder.SaleorderItems.Any(p => p.Id == temp.Id))
                    {
                        var Sorderitem = SaleOrder.SaleorderItems.FirstOrDefault(p => p.Id == temp.Id);

                        Sorderitem.QTY        = temp.QTY;
                        Sorderitem.Name       = temp.Name;
                        Sorderitem.NetPrice   = temp.NetPrice;
                        Sorderitem.TotalPrice = temp.TotalPrice;
                        Sorderitem.UnitPrice  = temp.UnitPrice;
                        Sorderitem.Item1      = iitemRepository.Get(temp.ItemId);
                        Sorderitem.Rack1      = iRackRepository.Get(temp.RackId);
                    }


                    else
                    {
                        var res = new SaleOrderItem();
                        res.QTY        = temp.QTY;
                        res.Name       = temp.Name;
                        res.NetPrice   = temp.NetPrice;
                        res.TotalPrice = temp.TotalPrice;
                        res.UnitPrice  = temp.UnitPrice;
                        res.Item1      = iitemRepository.Get(temp.ItemId);
                        res.Rack1      = iRackRepository.Get(temp.RackId);

                        SaleOrder.SaleorderItems.Add(res);
                    }
                }

                foreach (var item in SaleOrder.SaleorderItems)
                {
                    if (SaleOrder.SaleorderItems.Any(s => s.Id != item.Id))
                    {
                        SaleOrder.SaleorderItems.Remove(item);
                    }
                }
                ISaleOrderRepository.Update(SaleOrder);
            }
            else
            {
                SaleOrder.CreationDate = saleOrderContract.CreationDate;
                SaleOrder.Title        = saleOrderContract.Title;
                SaleOrder.Code         = saleOrderContract.Code;

                for (int i = 0; i < saleOrderContract.SaleorderItems.Count; i++)
                {
                    var temp = saleOrderContract.SaleorderItems[i];
                    if (SaleOrder.SaleorderItems.Any(p => p.Id == temp.Id))
                    {
                        var sorderitem = SaleOrder.SaleorderItems.FirstOrDefault(p => p.Id == temp.Id);

                        sorderitem.QTY        = temp.QTY;
                        sorderitem.Name       = temp.Name;
                        sorderitem.NetPrice   = temp.NetPrice;
                        sorderitem.TotalPrice = temp.TotalPrice;
                        sorderitem.UnitPrice  = temp.UnitPrice;
                        sorderitem.Item1      = iitemRepository.Get(temp.ItemId);
                        sorderitem.Rack1      = iRackRepository.Get(temp.RackId);
                    }
                }

                ISaleOrderRepository.Insert(SaleOrder);
            }
        }
Ejemplo n.º 4
0
        public void CreateOrUpdate(SaleOrderContract saleOrderContract)
        {
            var SaleOrder = ISaleOrderRepository.Get(saleOrderContract.Id);

            if (SaleOrder != null)
            {
                SaleOrder.CreationDate = DateTime.Now;
                SaleOrder.Title        = saleOrderContract.Title;
                SaleOrder.Code         = saleOrderContract.Code;

                for (int i = 0; i < saleOrderContract.SaleOrderItems.Count; i++)
                {
                    var temp = saleOrderContract.SaleOrderItems[i];
                    if (SaleOrder.SaleOrderItems.Any(p => p.Id == temp.Id))
                    {
                        var Sorderitem = SaleOrder.SaleOrderItems.FirstOrDefault(p => p.Id == temp.Id);

                        Sorderitem.Quantity = temp.Quantity;

                        Sorderitem.NetPrice   = temp.NetPrice;
                        Sorderitem.TotalPrice = temp.TotalPrice;
                        Sorderitem.UnitPrice  = temp.UnitPrice;
                        Sorderitem.Item       = IItemRepository.Get(temp.ItemId);
                        Sorderitem.Rack       = IRackRepository.Get(temp.RackId);
                    }


                    else
                    {
                        var Sorderitem = new SaleOrderItem();
                        Sorderitem.Quantity = temp.Quantity;

                        Sorderitem.NetPrice   = temp.NetPrice;
                        Sorderitem.TotalPrice = temp.TotalPrice;
                        Sorderitem.UnitPrice  = temp.UnitPrice;
                        Sorderitem.Item       = IItemRepository.Get(temp.ItemId);
                        Sorderitem.Rack       = IRackRepository.Get(temp.RackId);
                        SaleOrder.SaleOrderItems.Add(Sorderitem);
                    }
                }

                foreach (var item in SaleOrder.SaleOrderItems)
                {
                    if (!saleOrderContract.SaleOrderItems.Any(p => p.Id == item.Id))
                    {
                        SaleOrder.SaleOrderItems.Remove(item);
                    }
                }

                ISaleOrderRepository.Update(SaleOrder);
            }
            else
            {
                SaleOrder = new SaleOrder();
                SaleOrder.CreationDate = saleOrderContract.CreationDate;
                SaleOrder.Title        = saleOrderContract.Title;
                SaleOrder.Code         = saleOrderContract.Code;

                for (int i = 0; i < saleOrderContract.SaleOrderItems.Count; i++)
                {
                    var temp       = saleOrderContract.SaleOrderItems[i];
                    var Sorderitem = new SaleOrderItem();

                    Sorderitem.NetPrice   = temp.NetPrice;
                    Sorderitem.TotalPrice = temp.TotalPrice;
                    Sorderitem.UnitPrice  = temp.UnitPrice;
                    Sorderitem.Item       = IItemRepository.Get(temp.ItemId);
                    Sorderitem.Rack       = IRackRepository.Get(temp.RackId);
                    SaleOrder.SaleOrderItems.Add(Sorderitem);
                }

                ISaleOrderRepository.Insert(SaleOrder);
            }
        }