예제 #1
0
        protected override void CreateInventoryEx(DXInfo.Models.Inventory inv)
        {
            //if (this.SelectedInventory != null)
            //{
            InventoryEx inventoryEx = Mapper.Map <DXInfo.Models.InventoryEx>(inv);

            inventoryEx.IsCupType  = this.IsCupType;
            inventoryEx.IsInvPrice = this.IsInvPrice;
            inventoryEx.lTasteEx   = this.lTasteEx.Clone() as DXInfo.Models.TasteExList;
            inventoryEx.Quantity   = 1;
            inventoryEx.IsDiscount = JudgeIsDiscount(inv.Id);

            inventoryEx.IsInvDynamicPrice = this.IsInvDynamicPrice;
            inventoryEx.Discount          = 100;
            inventoryEx.AgreementPrice    = inventoryEx.SalePrice;
            this.SetCupType(inventoryEx);
            this.SetInvPrice(inventoryEx);
            if (inventoryEx.IsDiscount)
            {
                this.SetInvDynamicPrice(inventoryEx);
            }
            //this.SetCurrentStock(inventoryEx);
            this.SetOCInventoryEx();
            this.OCInventoryEx.Add(inventoryEx);
            //}
        }
예제 #2
0
 private void SetUnitAndQuantity(DXInfo.Models.RdRecords rdRecords, DXInfo.Models.ClientRetailOutStockDetail detail)
 {
     DXInfo.Models.Inventory            inv   = uow.Inventory.GetById(g => g.Id == detail.InvId);
     DXInfo.Models.MeasurementUnitGroup group = uow.MeasurementUnitGroup.GetById(g => g.Id == inv.MeasurementUnitGroup);
     if (group.Category == (int)DXInfo.Models.UnitGroupCategory.No)
     {
         rdRecords.MainUnit = inv.MainUnit;
         rdRecords.STUnit   = inv.MainUnit;
         rdRecords.ExchRate = 1;
         rdRecords.Quantity = rdRecords.Num;
     }
     else
     {
         if (!inv.StockUnit.HasValue)
         {
             throw new DXInfo.Models.BusinessException("请设置库存单位");
         }
         DXInfo.Models.UnitOfMeasures uom = uow.UnitOfMeasures.GetById(g => g.Id == inv.StockUnit);
         rdRecords.MainUnit = inv.MainUnit;
         rdRecords.STUnit   = inv.StockUnit.Value;
         rdRecords.ExchRate = uom.Rate;
         rdRecords.Quantity = rdRecords.Num * uom.Rate;
     }
 }
예제 #3
0
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            #region 菜品入库
            Hashtable htAdd = new Hashtable();
            Hashtable htSub = new Hashtable();
            if (GridSelected.ItemsSource == null)
            {
                ocSelDesks = new ObservableCollection <DXInfo.Models.OrderMenuEx>();
            }
            else
            {
                ocSelDesks = GridSelected.ItemsSource as ObservableCollection <DXInfo.Models.OrderMenuEx>;
            }
            if (desk != null && order != null && ocSelDesks.Count > 0)
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    int addmenu = 0;
                    foreach (DXInfo.Models.OrderMenuEx selDesk in ocSelDesks)
                    {
                        if (selDesk.Id != Guid.Empty)
                        {
                            DXInfo.Models.OrderMenus orderMenu = uow.OrderMenus.GetById(selDesk.Id);//.Where(w => w.Id == selDesk.Id).FirstOrDefault();
                            if (orderMenu != null)
                            {
                                if (orderMenu.Status == 2 && orderMenu.Quantity != selDesk.Quantity)
                                {
                                    DXInfo.Models.Inventory inv = uow.Inventory.GetById(orderMenu.InventoryId);//.Where(w => w.Id == orderMenu.InventoryId).FirstOrDefault();
                                    if (!string.IsNullOrEmpty(inv.Printer))
                                    {
                                        if (orderMenu.Quantity > selDesk.Quantity)
                                        {
                                            if (htSub.Contains(inv.Printer))
                                            {
                                                List <InventoryEx> confirmmenu = htSub[inv.Printer] as List <InventoryEx>;
                                                InventoryEx        si          = new InventoryEx();
                                                si.Category = inv.Category;
                                                //si.Quantity = orderMenu.Quantity - selDesk.Quantity;
                                                si.SalePrice = inv.SalePrice;
                                                //si.Amount = inv.SalePrice * (orderMenu.Quantity - selDesk.Quantity);
                                                si.Quantity = orderMenu.Quantity - selDesk.Quantity;
                                                si.Name     = inv.Name;
                                                si.Comment  = orderMenu.Comment;
                                                confirmmenu.Add(si);
                                                htSub[inv.Printer] = confirmmenu;
                                            }
                                            else
                                            {
                                                List <InventoryEx> confirmmenu = new List <InventoryEx>();
                                                InventoryEx        si          = new InventoryEx();
                                                si.Category = inv.Category;
                                                //si.Amount = inv.SalePrice * (orderMenu.Quantity - selDesk.Quantity);
                                                //si.Quantity = orderMenu.Quantity - selDesk.Quantity;
                                                si.SalePrice = inv.SalePrice;
                                                si.Quantity  = orderMenu.Quantity - selDesk.Quantity;
                                                si.Name      = inv.Name;
                                                si.Comment   = orderMenu.Comment;
                                                confirmmenu.Add(si);
                                                htSub.Add(inv.Printer, confirmmenu);
                                            }
                                        }
                                        else
                                        {
                                            if (htAdd.Contains(inv.Printer))
                                            {
                                                List <InventoryEx> confirmmenu = htAdd[inv.Printer] as List <InventoryEx>;
                                                InventoryEx        si          = new InventoryEx();
                                                si.Category = inv.Category;
                                                //si.Amount = inv.SalePrice*(selDesk.Quantity-orderMenu.Quantity);
                                                //si.Quantity = orderMenu.Quantity - selDesk.Quantity;
                                                si.SalePrice = inv.SalePrice;
                                                si.Quantity  = selDesk.Quantity - orderMenu.Quantity;
                                                si.Name      = inv.Name;
                                                si.Comment   = orderMenu.Comment;
                                                confirmmenu.Add(si);
                                                htAdd[inv.Printer] = confirmmenu;
                                            }
                                            else
                                            {
                                                List <InventoryEx> confirmmenu = new List <InventoryEx>();
                                                InventoryEx        si          = new InventoryEx();
                                                si.Category = inv.Category;
                                                //si.Amount = inv.SalePrice * (selDesk.Quantity - orderMenu.Quantity);
                                                si.SalePrice = inv.SalePrice;
                                                si.Quantity  = selDesk.Quantity - orderMenu.Quantity;
                                                si.Name      = inv.Name;
                                                si.Comment   = orderMenu.Comment;
                                                confirmmenu.Add(si);
                                                htAdd.Add(inv.Printer, confirmmenu);
                                            }
                                        }
                                    }
                                }
                                orderMenu.Quantity = selDesk.Quantity;
                                orderMenu.Amount   = selDesk.Quantity * orderMenu.Price;
                                orderMenu.Comment  = selDesk.Comment;

                                DXInfo.Models.OrderMenusHis menuHis = new DXInfo.Models.OrderMenusHis();
                                menuHis.LinkId      = orderMenu.Id;
                                menuHis.OrderId     = orderMenu.OrderId;
                                menuHis.InventoryId = orderMenu.InventoryId;
                                menuHis.Price       = orderMenu.Price;
                                menuHis.Quantity    = orderMenu.Quantity;
                                menuHis.Amount      = orderMenu.Amount;
                                menuHis.UserId      = App.MyIdentity.oper.UserId;
                                menuHis.CreateDate  = DateTime.Now;
                                menuHis.Status      = orderMenu.Status;
                                menuHis.Comment     = orderMenu.Comment;
                                uow.OrderMenusHis.Add(menuHis);
                            }
                        }
                        else
                        {
                            DXInfo.Models.OrderMenus orderMenu = new DXInfo.Models.OrderMenus();
                            orderMenu.OrderId     = order.Id;
                            orderMenu.InventoryId = selDesk.InventoryId;
                            orderMenu.Price       = selDesk.Price;
                            orderMenu.Quantity    = selDesk.Quantity;
                            orderMenu.Amount      = selDesk.Amount;
                            orderMenu.Comment     = selDesk.Comment;
                            orderMenu.CreateDate  = DateTime.Now;
                            orderMenu.UserId      = App.MyIdentity.user.UserId;
                            uow.OrderMenus.Add(orderMenu);

                            uow.Commit();

                            DXInfo.Models.OrderMenusHis menuHis = new DXInfo.Models.OrderMenusHis();
                            menuHis.LinkId      = orderMenu.Id;
                            menuHis.OrderId     = orderMenu.OrderId;
                            menuHis.InventoryId = orderMenu.InventoryId;
                            menuHis.Price       = orderMenu.Price;
                            menuHis.Quantity    = orderMenu.Quantity;
                            menuHis.Amount      = orderMenu.Amount;
                            menuHis.UserId      = App.MyIdentity.oper.UserId;
                            menuHis.CreateDate  = DateTime.Now;
                            menuHis.Status      = orderMenu.Status;
                            menuHis.Comment     = orderMenu.Comment;
                            uow.OrderMenusHis.Add(menuHis);
                            addmenu++;
                        }
                    }
                    if (addmenu > 0)
                    {
                        DXInfo.Models.OrderDishes odish = uow.OrderDishes.GetById(order.Id);//.Where(w => w.Id == order.Id).FirstOrDefault();
                        odish.Status = 0;
                    }
                    uow.Commit();
                    transaction.Complete();
                }
            }
            #endregion
            string deskCodes = "";
            DXInfo.Restaurant.DeskManageFacade dmf = new DXInfo.Restaurant.DeskManageFacade(uow, Guid.Empty, Guid.Empty);
            deskCodes = dmf.GetOrderDeskCodes(uow, order.Id);

            if (htAdd.Count > 0)
            {
                foreach (DictionaryEntry de in htAdd)
                {
                    List <InventoryEx> confirmmenu = de.Value as List <InventoryEx>;
                    decimal            dsum        = confirmmenu.Sum(s => s.Amount);
                    decimal            dcount      = confirmmenu.Sum(s => s.Quantity);
                    if (confirmmenu.Count > 0)
                    {
                        var ctx = new
                        {
                            DeskNo     = deskCodes + "(加单)",
                            Sum        = dsum,
                            Count      = dcount,
                            lSelInv    = confirmmenu,
                            CreateDate = DateTime.Now,
                            DeptName   = App.MyIdentity.dept.DeptName,
                        };
                        System.Printing.LocalPrintServer lp = new System.Printing.LocalPrintServer();
                        System.Printing.PrintQueue       pq = new System.Printing.PrintQueue(lp, de.Key.ToString());
                        DeskConfirmWindow dcw = new DeskConfirmWindow(ctx, pq);
                        if (dcw.ShowDialog().GetValueOrDefault())
                        {
                        }
                    }
                }
            }
            if (htSub.Count > 0)
            {
                foreach (DictionaryEntry de in htSub)
                {
                    List <InventoryEx> confirmmenu = de.Value as List <InventoryEx>;
                    decimal            dsum        = confirmmenu.Sum(s => s.Amount);
                    decimal            dcount      = confirmmenu.Sum(s => s.Quantity);
                    if (confirmmenu.Count > 0)
                    {
                        var ctx = new
                        {
                            DeskNo     = deskCodes + "(减单)",
                            Sum        = dsum,
                            Count      = dcount,
                            lSelInv    = confirmmenu,
                            CreateDate = DateTime.Now,
                            DeptName   = App.MyIdentity.dept.DeptName,
                        };
                        System.Printing.LocalPrintServer lp = new System.Printing.LocalPrintServer();
                        System.Printing.PrintQueue       pq = new System.Printing.PrintQueue(lp, de.Key.ToString());
                        DeskConfirmWindow dcw = new DeskConfirmWindow(ctx, pq);
                        if (dcw.ShowDialog().GetValueOrDefault())
                        {
                        }
                    }
                }
            }
            this.DialogResult = true;
        }
예제 #4
0
        private void RetailOtherInStock(List <RetailTemp> q2)
        {
            var g2 = (from d in q2
                      group d by new { d.DeptId, d.CurStock.WhId, d.UserId, d.CreateDate.Date } into g
                      select new { g.Key.DeptId, g.Key.WhId, g.Key.UserId, g.Key.Date }).ToList();

            foreach (var rd in g2)
            {
                if (common.IsBalance(rd.Date, rd.WhId))
                {
                    continue;
                }
                var lRdRecord = uow.RdRecord.GetAll().Where(w =>
                                                            w.WhId == rd.WhId &&
                                                            w.DeptId == rd.DeptId &&
                                                            w.Maker == rd.UserId &&
                                                            w.RdDate == rd.Date &&
                                                            w.VouchType == DXInfo.Models.VouchTypeCode.OtherInStock &&
                                                            w.RdCode == "013" &&
                                                            w.BusType == "013").ToList();
                var rdRecord = lRdRecord.Where(w => w.IsVerify).FirstOrDefault();
                if (rdRecord == null)
                {
                    rdRecord = NewOtherInStock(rd.Date, rd.WhId, true);
                    uow.RdRecord.Add(rdRecord);
                    uow.Commit();
                }
                var q3 = (from d in q2
                          where d.DeptId == rd.DeptId && d.CurStock.WhId == rd.WhId && d.UserId == rd.UserId
                          select d).ToList();
                foreach (var rds in q3)
                {
                    decimal exchRate = 1;
                    decimal quantity = 0;
                    Guid    sTUnit   = Guid.Empty;
                    DXInfo.Models.Inventory            inv   = uow.Inventory.GetById(g => g.Id == rds.InvId);
                    DXInfo.Models.MeasurementUnitGroup group = uow.MeasurementUnitGroup.GetById(g => g.Id == inv.MeasurementUnitGroup);
                    if (group.Category == (int)DXInfo.Models.UnitGroupCategory.No)
                    {
                        quantity = rds.Num;
                        sTUnit   = inv.MainUnit;
                    }
                    else
                    {
                        if (!inv.StockUnit.HasValue)
                        {
                            continue;
                        }
                        DXInfo.Models.UnitOfMeasures uom = uow.UnitOfMeasures.GetById(g => g.Id == inv.StockUnit);
                        sTUnit   = inv.StockUnit.Value;
                        exchRate = uom.Rate;
                        quantity = rds.Num * uom.Rate;
                    }
                    bool ret = RetailUpdateCurrent(rds.CurStock, 1, rds.Num, quantity);
                    if (ret)
                    {
                        AddRetailRdRecords(rds.ConsumeListId, rdRecord.Id, 1,
                                           rds.InvId, inv.MainUnit, sTUnit, exchRate, rds.Batch, rds.Num, rds.Price, rds.CurStock);
                    }
                }
                uow.Commit();
            }
        }