예제 #1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //删除记录
            if (GridSelected.SelectedItem != null)
            {
                DXInfo.Models.OrderMenuEx selInv = GridSelected.SelectedItem as DXInfo.Models.OrderMenuEx;

                if (desk != null && order != null)
                {
                    DXInfo.Models.OrderMenus orderMenu = uow.OrderMenus.GetById(selInv.Id);//.Where(w => w.Id == selInv.Id).FirstOrDefault();
                    if (orderMenu != null)
                    {
                        if (orderMenu.Status == 2)
                        {
                            MessageBox.Show("已下单不能删除");
                            return;
                        }
                        uow.OrderMenus.Delete(orderMenu);
                        uow.Commit();
                    }
                }
                ObservableCollection <DXInfo.Models.OrderMenuEx> lsi = GridSelected.ItemsSource as ObservableCollection <DXInfo.Models.OrderMenuEx>;
                lsi.Remove(selInv);

                txtQuantity.Text = lsi.Sum(s => s.Quantity).ToString();
                txtAmount.Text   = lsi.Sum(s => s.Amount).ToString("c");
            }
        }
예제 #2
0
파일: Common.cs 프로젝트: zhenghua75/DXInfo
 public bool OrderDish_DeleteMenu(Guid orderMenuId)
 {
     DXInfo.Models.OrderMenus orderMenu = uow.OrderMenus.GetById(g => g.Id == orderMenuId);
     if (orderMenu == null)
     {
         Helper.ShowErrorMsg("菜品空,已被删除");
         return(false);
     }
     if (orderMenu.Status != (int)DXInfo.Models.OrderMenuStatus.Normal)
     {
         Helper.ShowErrorMsg("正常状态才能删除");
         return(false);
     }
     if (orderMenu.IsPackage)
     {
         List <DXInfo.Models.OrderMenus> lpkg = this.uow.OrderMenus.GetAll().Where(
             w => w.IsPackage &&
             w.PackageId == orderMenu.PackageId &&
             w.PackageSn == orderMenu.PackageSn &&
             w.OrderId == orderMenu.OrderId &&
             w.Id != orderMenu.Id).ToList();
         foreach (DXInfo.Models.OrderMenus pkg in lpkg)
         {
             if (pkg.Status != 0)
             {
                 Helper.ShowErrorMsg("正常状态才能删除");
                 return(false);
             }
             uow.OrderMenus.Delete(pkg);
         }
         DXInfo.Models.OrderPackages orderPackage = uow.OrderPackages.GetById(g => g.Id == orderMenu.PackageId);
         if (orderPackage != null)
         {
             uow.OrderPackages.Delete(orderPackage);
         }
     }
     uow.OrderMenus.Delete(orderMenu);
     uow.Commit();
     return(true);
 }
예제 #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;
        }