public override OPResult Save()
        {
            BillCannibalize cannibalize = VMGlobal.DistributionQuery.LinqOP.Search <BillCannibalize>(o => o.Code == Master.RefrenceBillCode).First();

            cannibalize.Status = true;
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    base.SaveWithNoTran();
                    VMGlobal.DistributionQuery.LinqOP.Update <BillCannibalize>(cannibalize);
                    Details.ForEach(d => BillLogic.AddStock(Master.StorageID, d.ProductID, d.Quantity));
                    scope.Complete();
                }
                catch (Exception e)
                {
                    return(new OPResult {
                        IsSucceed = false, Message = e.Message
                    });
                }
            }
            return(new OPResult {
                IsSucceed = true
            });
        }
 public override OPResult Save()
 {
     if (string.IsNullOrEmpty(Master.Remark))
     {
         var toOrganizationName = OrganizationListVM.CurrentOrganization.ChildrenOrganizations.Find(o => o.ID == Master.ToOrganizationID).Name;
         Master.Remark = "发往" + toOrganizationName;
     }
     Master.Status = (int)BillDeliveryStatusEnum.已装箱未配送;
     using (TransactionScope scope = new TransactionScope())
     {
         try
         {
             base.SaveWithNoTran();
             if (Master.IsWriteDownOrder)
             {
                 //冲减订单
                 Details.ForEach(d => BillLogic.UpdateOrderWhenDelivery(Master.ToOrganizationID, d.ProductID, d.Quantity));
             }
             scope.Complete();
         }
         catch (Exception e)
         {
             return(new OPResult {
                 IsSucceed = false, Message = e.Message
             });
         }
     }
     return(new OPResult {
         IsSucceed = true
     });
 }
Esempio n. 3
0
        public static void CashierMenu()
        {
            Console.WriteLine("Digite el numero de mesa: ");
            int       table_id  = Convert.ToInt16(Console.ReadLine());
            BillLogic billLogic = new BillLogic(table_id);

            foreach (var order in billLogic.OrdersToPayInTheSameTable)
            {
                Console.WriteLine(order.ID + ". Mesa: " + order.Table + ". " + order.Product.Name + "\n");
            }
            int answer;

            do
            {
                Console.WriteLine("Digite la orden que desea agregar: ");
                int orderid = Convert.ToInt16(Console.ReadLine());
                billLogic.AddOrderToABill(orderid);
                Console.WriteLine("Desea agregar otra orden: 1-Si 2-No");
                answer = Convert.ToInt16(Console.ReadLine());
            } while (answer == 1);
            Console.WriteLine("Digite el nombre para la factura: ");
            string nombre = Console.ReadLine();

            Console.WriteLine("Digite el id para la factura: ");
            int  id   = Convert.ToInt16(Console.ReadLine());
            Bill bill = billLogic.CreateBill(id, nombre);

            Console.WriteLine(bill.Name + bill.Orders + bill.Tax + bill.Cost + bill.FinalCost);
        }
Esempio n. 4
0
        public void ABillIsCreated()
        {
            BillLogic logic = new BillLogic(1);
            Bill      bill  = logic.CreateBill(1, "Jeremy Cerdas");

            Assert.IsNotNull(bill);
        }
Esempio n. 5
0
        public override OPResult Save()
        {
            var          lp       = VMGlobal.DistributionQuery.LinqOP;
            BillDelivery delivery = lp.Search <BillDelivery>(o => o.Code == Master.RefrenceBillCode).First();

            delivery.Status = (int)BillDeliveryStatusEnum.已入库;
            //var uniqueCodes = GetSnapshotDetails(delivery.ID);
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    base.SaveWithNoTran();
                    lp.Update <BillDelivery>(delivery);
                    Details.ForEach(d => BillLogic.AddStock(Master.StorageID, d.ProductID, d.Quantity));
                    //SaveUniqueCodes(uniqueCodes);
                    scope.Complete();
                }
                catch (Exception e)
                {
                    return(new OPResult {
                        IsSucceed = false, Message = e.Message
                    });
                }
            }
            return(new OPResult {
                IsSucceed = true
            });
        }
Esempio n. 6
0
        public void AddAnOrderToAnExistingBill()
        {
            BillLogic logic      = new BillLogic(1);
            Bill      bill       = logic.CreateBill(2, "Jeremy Cerdas");
            Order     OrderAdded = logic.AddOrderToABill(1);

            Assert.IsNotNull(OrderAdded);
        }
        public override OPResult Save()
        {
            BillGoodReturn goodreturn = VMGlobal.DistributionQuery.LinqOP.Search <BillGoodReturn>(o => o.Code == Master.RefrenceBillCode).First();

            if (goodreturn.Status == (int)BillGoodReturnStatusEnum.已入库)
            {
                return new OPResult {
                           IsSucceed = false, Message = "该单已入库"
                }
            }
            ;
            //var uniqueCodes = GetSnapshotDetails(goodreturn.ID);
            if (!OrganizationListVM.IsSelfRunShop(goodreturn.OrganizationID))//检查当初发这些货品的时候的发货价.另:非自营店不能退不是发给自己的货物
            {
                //var index = goodreturn.Remark.LastIndexOf(':');
                //if (index != -1)
                //{
                ReturnMoney = goodreturn.TotalPrice;//Convert.ToDecimal(goodreturn.Remark.Substring(index + 1));
                //}
            }
            goodreturn.Status = (int)BillGoodReturnStatusEnum.已入库;
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    base.SaveWithNoTran();
                    VMGlobal.DistributionQuery.LinqOP.Update <BillGoodReturn>(goodreturn);
                    if (ReturnMoney != 0)
                    {
                        VMGlobal.DistributionQuery.LinqOP.Add <OrganizationFundAccount>(
                            new OrganizationFundAccount
                        {
                            BrandID          = Master.BrandID,
                            OrganizationID   = goodreturn.OrganizationID,  //this.Master.OrganizationID,
                            NeedIn           = 0,
                            AlreadyIn        = ReturnMoney,
                            CreatorID        = VMGlobal.CurrentUser.ID,
                            BillKind         = (int)BillTypeEnum.BillGoodReturn,
                            Remark           = "退货入库生成,退货单号" + goodreturn.Code,
                            RefrenceBillCode = this.Master.Code
                        });
                    }
                    Details.ForEach(d => BillLogic.AddStock(Master.StorageID, d.ProductID, d.Quantity));
                    //SaveUniqueCodes(uniqueCodes);
                    scope.Complete();
                }
                catch (Exception e)
                {
                    return(new OPResult {
                        IsSucceed = false, Message = e.Message
                    });
                }
            }
            return(new OPResult {
                IsSucceed = true
            });
        }
        private void btnRevert_Click(object sender, RoutedEventArgs e)
        {
            RadButton             btn    = (RadButton)sender;
            StocktakeSearchEntity entity = (StocktakeSearchEntity)btn.DataContext;
            var result = BillLogic.RevertBill <BillStocktake>(entity.BillID);

            if (result.IsSucceed)
            {
                entity.IsDeleted = false;
            }
            MessageBox.Show(result.Message);
        }
Esempio n. 9
0
        public override OPResult Save()
        {
            var lp   = VMGlobal.DistributionQuery.LinqOP;
            var bill = Master;

            bill.OrganizationID = VMGlobal.CurrentUser.OrganizationID;
            var details = this.Details = new List <BillStoringDetails>();

            this.TraverseGridDataItems(product =>
            {
                details.Add(new BillStoringDetails {
                    ProductID = product.ProductID, Quantity = product.Quantity
                });
            });
            if (details.Count == 0)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "没有需要保存的数据"
                });
            }
            bill.CreatorID = VMGlobal.CurrentUser.ID;
            bill.Code      = this.GenerateBillCode();
            //if (string.IsNullOrEmpty(bill.RefrenceBillCode))
            bill.RefrenceBillCode = bill.Code;//假如没有相关单据号,则相关单据号就是入库单自身单据编号
            bill.BillType         = (int)BillTypeEnum.BillStoring;
            if (string.IsNullOrEmpty(bill.Remark))
            {
                bill.Remark = "成品入库";
            }
            //TransactionOptions transactionOption = new TransactionOptions();
            ////设置事务隔离级别
            //transactionOption.IsolationLevel = System.Transactions.IsolationLevel.Snapshot;
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    bill.ID = lp.Add <BillStoring, int>(bill, b => b.ID);
                    details.ForEach(d => d.BillID = bill.ID);
                    lp.Add <BillStoringDetails>(details);
                    Details.ForEach(d => BillLogic.AddStock(bill.StorageID, d.ProductID, d.Quantity));
                    scope.Complete();
                }
                catch (Exception e)
                {
                    return(new OPResult {
                        IsSucceed = false, Message = e.Message
                    });
                }
            }
            return(new OPResult {
                IsSucceed = true
            });
        }
Esempio n. 10
0
        //private List<OrganizationPriceFloat> _priceFloatCache = new List<OrganizationPriceFloat>();

        ///// <summary>
        ///// [根据发货价]获取下一机构的上浮价
        ///// </summary>
        ///// <param name="toOrganizationID">收货机构</param>
        ///// <param name="price">发货价</param>
        ///// <returns>上浮价</returns>
        //private decimal GetToOrganizationFloatPrice(int toOrganizationID, int byqID, decimal price)
        //{
        //    var pf = _priceFloatCache.FirstOrDefault(o => o.OrganizationID == toOrganizationID && o.BYQID == byqID);
        //    if (pf == null)
        //    {
        //        var temp = VMGlobal.SysProcessQuery.LinqOP.Search<OrganizationPriceFloat>(o => o.OrganizationID == toOrganizationID && o.BYQID == byqID).ToList();
        //        if (temp != null && temp.Count > 0)
        //            pf = temp[0];
        //        else
        //            pf = new OrganizationPriceFloat { BYQID = byqID, OrganizationID = toOrganizationID, FloatRate = 0, LastNumber = -1 };
        //        _priceFloatCache.Add(pf);
        //    }
        //    if (pf.LastNumber != -1)
        //    {
        //        price += pf.FloatRate * price * 0.01M;//上浮
        //        price *= 0.1M;
        //        price = decimal.Truncate(price) * 10 + pf.LastNumber;//尾数
        //    }
        //    return price;
        //}

        private void ActDatasWhenBinding(IEnumerable items)
        {
            var bill = _dataContext.Master;

            foreach (var item in items)
            {
                ProductForDelivery p = (ProductForDelivery)item;
                //p.Discount = _helper.GetDiscount(p.BYQID, bill.ToOrganizationID);
                //p.FloatPrice = this.GetToOrganizationFloatPrice(bill.ToOrganizationID, p.BYQID, p.Price);
                if (ckWriteDownOrder.IsChecked.Value)
                {
                    p.OrderQuantity = BillLogic.GetRemainOrderQuantity(bill.ToOrganizationID, p.ProductID);
                }
            }
        }
Esempio n. 11
0
        private void ckWriteDownOrder_Checked(object sender, RoutedEventArgs e)
        {
            if (gvDatas.RowStyleSelector == null)
            {
                DeliveryRowStyleSelector deliveryRowStyleSelector = (DeliveryRowStyleSelector)gridLayout.Resources["deliveryRowStyleSelector"];
                gvDatas.RowStyleSelector = deliveryRowStyleSelector;
            }
            var context = (BillDeliveryPackageVM)this.DataContext;
            var bill    = context.Master;

            foreach (var item in gvDatas.Items)
            {
                ProductForDelivery p = (ProductForDelivery)item;
                p.OrderQuantity = BillLogic.GetRemainOrderQuantity(bill.ToOrganizationID, p.ProductID);
            }
        }
Esempio n. 12
0
 public override void SaveWithNoTran()
 {
     //加库存
     Details.ForEach(d => BillLogic.AddStock(Master.StorageID, d.ProductID, d.Quantity));
     base.SaveWithNoTran();
 }