private void OrderMenuUpdate(Guid orderMenuId, DateTime dCreateDate, Guid userId) { DXInfo.Models.OrderMenus om = uow.OrderMenus.GetById(g => g.Id == orderMenuId); uow.OrderMenus.Delete(om); DXInfo.Models.OrderMenusHis omHis = Mapper.Map <DXInfo.Models.OrderMenusHis>(om); omHis.OperDate = dCreateDate; omHis.Status = (int)DXInfo.Models.OrderMenuStatus.Checkout; omHis.Oper = userId; omHis.LinkId = om.Id; uow.OrderMenusHis.Add(omHis); }
public bool Order(OrderDeskInfo orderDesk, List <OrderMenuInfo> lOrderMenu) { DateTime dtOperDate = DateTime.Now; Guid userId = Guid.Empty; try { using (TransactionScope transaction = new TransactionScope()) { if (!orderDesk.UserId.HasValue) { throw new WebFaultException <string>("无“" + orderDesk.UserName + "”操作员信息", HttpStatusCode.MethodNotAllowed); } userId = orderDesk.UserId.Value; DXInfo.Models.OrderDishes orderDish = uow.OrderDishes.GetById(g => g.Id == orderDesk.OrderDishId); if (orderDish == null) { throw new WebFaultException <string>("无此订单", HttpStatusCode.MethodNotAllowed); } if (orderDish.Status == 1 || orderDish.Status == 2) { throw new WebFaultException <string>("已结账或撤销的不能提交", HttpStatusCode.MethodNotAllowed); } foreach (OrderMenuInfo omi in lOrderMenu) { int lackCount = (from d in uow.MenuStatus.GetAll() where d.Dept == localDeptId && d.Inventory == omi.InvId && d.Status == (int)DXInfo.Models.OrderMenuStatus.Lack select d).Count(); if (lackCount > 0) { throw new WebFaultException <string>(omi.InvName + "缺菜不能提交", HttpStatusCode.MethodNotAllowed); } if (omi.IsAdd && !omi.OrderMenuId.HasValue) { DXInfo.Models.OrderMenus orderMenu = new DXInfo.Models.OrderMenus(); orderMenu.UserId = userId; orderMenu.OrderId = orderDesk.OrderDishId.Value; orderMenu.InventoryId = omi.InvId; orderMenu.Price = omi.SalePrice; orderMenu.Quantity = omi.Quantity; orderMenu.Amount = omi.Amount; orderMenu.Comment = omi.Comment; orderMenu.CreateDate = dtOperDate; orderMenu.IsPackage = omi.IsPackage; orderMenu.PackageId = omi.PackageId; orderMenu.PackageSn = omi.PackageSn; orderMenu.Status = (int)DXInfo.Models.OrderMenuStatus.Normal; uow.OrderMenus.Add(orderMenu); uow.Commit(); DXInfo.Models.OrderMenusHis omHis = Mapper.Map <DXInfo.Models.OrderMenusHis>(orderMenu); omHis.LinkId = orderMenu.Id; uow.OrderMenusHis.Add(omHis); } else { if (omi.OrderMenuId.HasValue) { DXInfo.Models.OrderMenus orderMenu = (from d in uow.OrderMenus.GetAll() where d.Id == omi.OrderMenuId select d) .FirstOrDefault(); if (orderMenu != null && orderMenu.Status == (int)DXInfo.Models.OrderMenuStatus.Normal) { if (omi.IsDelete) { uow.OrderMenus.Delete(orderMenu); } else { orderMenu.Quantity = omi.Quantity; orderMenu.Price = omi.SalePrice; orderMenu.Amount = omi.Amount; orderMenu.Comment = omi.Comment; uow.OrderMenus.Update(orderMenu); } DXInfo.Models.OrderMenusHis omHis = Mapper.Map <DXInfo.Models.OrderMenusHis>(orderMenu); omHis.LinkId = orderMenu.Id; omHis.UserId = userId; omHis.CreateDate = dtOperDate; uow.OrderMenusHis.Add(omHis); } } } } uow.Commit(); transaction.Complete(); } } catch (Exception ex) { throw new WebFaultException <string>(ex.Message, HttpStatusCode.MethodNotAllowed); } return(true); }
private void Button_Click(object sender, RoutedEventArgs e) { if (IsPrint) { PrintDialog pDialog1 = new PrintDialog(); pDialog1.PrintVisual(GridPrint, "会员卡消费打印"); DialogResult = true; this.Close(); return; } dynamic d = GridPrint.DataContext; decimal dCash = Convert.ToDecimal(txtCash.Text); decimal dChange = Convert.ToDecimal(txtChange.Text); if (dCash - dChange < d.Amount) { throw new ArgumentException("收的钱应不小于消费金额"); } using (TransactionScope transaction = new TransactionScope()) { Guid orderId = d.OrderId; DXInfo.Models.OrderDishes orderDish = uow.OrderDishes.GetById(orderId);//.Where(w => w.Id == orderId).FirstOrDefault(); if (orderDish.Status != 3) { MessageBox.Show("确认下单后才可以结账!"); DialogResult = false; this.Close(); return; } orderDish.Status = 1; var q = from o in uow.OrderDeskes.GetAll() where o.OrderId == orderDish.Id select o; foreach (DXInfo.Models.OrderDeskes orderDesk in q) { orderDesk.Status = 1; DXInfo.Models.OrderDeskesHis deskHis = new DXInfo.Models.OrderDeskesHis(); deskHis.DeskId = orderDesk.DeskId; deskHis.LinkId = orderDesk.Id; deskHis.OrderId = orderDesk.OrderId; deskHis.UserId = d.UserId; deskHis.CreateDate = DateTime.Now; deskHis.Status = 1; uow.OrderDeskesHis.Add(deskHis); } DXInfo.Models.Consume consume = new DXInfo.Models.Consume(); consume.OrderId = d.OrderId; consume.Sum = d.Sum; consume.Voucher = d.Voucher; consume.PayVoucher = d.PayVoucher; consume.Discount = d.Discount; consume.Card = d.Id; consume.Amount = d.Amount; consume.CreateDate = d.CreateDate; consume.DeptId = d.DeptId; consume.Point = d.Point; consume.UserId = d.UserId; consume.Point = d.Point; consume.ConsumeType = 3; consume.SourceType = 1; consume.Cash = dCash; consume.Change = dChange; consume.Quantity = d.Count; if (d.PayType != Guid.Empty) { consume.PayType = d.PayType; } uow.Consume.Add(consume); DXInfo.Models.Bills bill = new DXInfo.Models.Bills(); bill.Sum = d.Sum; bill.Voucher = d.Voucher; bill.Discount = d.Discount; bill.Amount = d.Amount; bill.BillType = "WRCardConsume3Window"; bill.CardNo = d.CardNo; bill.CreateDate = d.CreateDate; bill.DeptName = d.DeptName; bill.FullName = d.FullName; bill.MemberName = d.MemberName; bill.PayTypeName = d.PayTypeName; bill.Cash = dCash; bill.Change = dChange; uow.Bills.Add(bill); uow.Commit(); Guid CardId = d.Id; DXInfo.Models.Cards card = uow.Cards.GetById(CardId);//.Where(w => w.Id == CardId).FirstOrDefault(); if (card == null) { throw new ArgumentException("卡信息未找到"); } if (d.CardDonateInventory != null && d.CardDonateInventory.Count > 0) { foreach (var cdi in d.CardDonateInventory) { DXInfo.Models.ConsumeDonateInv cdonate = new DXInfo.Models.ConsumeDonateInv(); cdonate.Consume = consume.Id; cdonate.Inventory = cdi.Id; uow.ConsumeDonateInv.Add(cdonate); Guid gInvId = cdi.Id; var cdi1 = uow.CardDonateInventory.GetAll().Where(w => w.Inventory == gInvId).Where(w => w.CardId == CardId).FirstOrDefault(); if (cdi1 != null) { cdi1.IsValidate = false; } DXInfo.Models.BillDonateInvLists bd = new DXInfo.Models.BillDonateInvLists(); bd.Bill = bill.Id; bd.InvName = cdi.Name; uow.BillDonateInvLists.Add(bd); } } //DXInfo.Restaurant.DeskManageFacade dmf = new DXInfo.Restaurant.DeskManageFacade(); foreach (var si in d.lSelInv) { Guid orderMenuId = si.OrderMenuId; DXInfo.Models.OrderMenus om = uow.OrderMenus.GetById(orderMenuId);//.Where(w => w.Id == orderMenuId).FirstOrDefault(); om.OperDate = DateTime.Now; om.UserId = App.MyIdentity.oper.UserId; om.Status = 8; uow.OrderMenus.Update(om); DXInfo.Models.OrderMenusHis omHis = Mapper.Map <DXInfo.Models.OrderMenusHis>(om);//dmf.CreateOrderMenuHis(om, App.MyIdentity.oper.UserId, DateTime.Now); omHis.LinkId = om.Id; uow.OrderMenusHis.Add(omHis); DXInfo.Models.ConsumeList cl = new DXInfo.Models.ConsumeList(); cl.Amount = si.IsDiscount ? Math.Floor(si.Amount * d.Discount / 100) : si.Amount; cl.Consume = consume.Id; cl.CreateDate = d.CreateDate; cl.DeptId = d.DeptId; cl.Inventory = si.Id; cl.Price = si.Price; cl.Quantity = si.Quantity; cl.UserId = d.UserId; cl.Sum = si.Amount; cl.Discount = si.IsDiscount ? d.Discount : 100; cl.IsPackage = si.IsPackage; cl.PackageId = si.PackageId; uow.ConsumeList.Add(cl); DXInfo.Models.BillInvLists bl = new DXInfo.Models.BillInvLists(); bl.Amount = si.Amount; bl.Bill = bill.Id; bl.CupType = si.EnglishName; bl.Name = si.Name; bl.Quantity = si.Quantity; bl.SalePrice = si.Price; uow.BillInvLists.Add(bl); } if (d.Point > 0) { var cps = uow.CardPoints.GetAll().Where(w => w.Card == CardId).Where(w => w.PointType == 0).FirstOrDefault(); if (cps != null) { cps.Point = cps.Point + d.Point; } else { DXInfo.Models.CardPoints cp = new DXInfo.Models.CardPoints(); cp.Card = d.Id; cp.CreateDate = d.CreateDate; cp.DeptId = d.DeptId; cp.Point = d.Point; cp.PointType = 0; cp.UserId = d.UserId; uow.CardPoints.Add(cp); } } uow.Commit(); transaction.Complete(); } PrintDialog pDialog = new PrintDialog(); pDialog.PageRangeSelection = PageRangeSelection.AllPages; pDialog.UserPageRangeEnabled = true; this.Measure(new Size(pDialog.PrintableAreaWidth, pDialog.PrintableAreaHeight)); this.Arrange(new Rect(new Point(0, 0), this.DesiredSize)); pDialog.PrintVisual(GridPrint, "会员卡消费打印"); DialogResult = true; this.Close(); }
public void Button_Click(object sender, RoutedEventArgs e) { if (IsPrint) { PrintDialog pDialog1 = new PrintDialog(); pDialog1.PrintVisual(GridPrint, "非会员消费打印"); DialogResult = true; this.Close(); return; } dynamic d = GridPrint.DataContext; decimal dCash = Convert.ToDecimal(txtCash.Text); decimal dChange = Convert.ToDecimal(txtChange.Text); if (dCash - dChange < d.Amount) { throw new ArgumentException("收的钱应不小于消费金额"); } Guid orderId = d.OrderId; using (TransactionScope transaction = new TransactionScope()) { DXInfo.Models.OrderDishes orderDish = uow.OrderDishes.GetById(orderId);//.Where(w => w.Id == orderId).FirstOrDefault(); if (orderDish.Status != 3) { MessageBox.Show("确认下单后才可以结账!"); DialogResult = false; this.Close(); return; } orderDish.Status = 1; var q = from o in uow.OrderDeskes.GetAll() where o.OrderId == orderDish.Id select o; foreach (DXInfo.Models.OrderDeskes orderDesk in q) { orderDesk.Status = 1; DXInfo.Models.OrderDeskesHis deskHis = new DXInfo.Models.OrderDeskesHis(); deskHis.DeskId = orderDesk.DeskId; deskHis.LinkId = orderDesk.Id; deskHis.OrderId = orderDesk.OrderId; deskHis.UserId = d.UserId; deskHis.CreateDate = DateTime.Now; deskHis.Status = 1; uow.OrderDeskesHis.Add(deskHis); } DXInfo.Models.Consume consume = new DXInfo.Models.Consume(); consume.OrderId = d.OrderId; consume.Sum = d.Sum; consume.Voucher = d.Voucher; consume.PayVoucher = d.PayVoucher; consume.Amount = d.Amount; consume.CreateDate = d.CreateDate; consume.DeptId = d.DeptId; consume.UserId = d.UserId; consume.Cash = dCash; consume.Change = dChange; consume.ConsumeType = 1; consume.PayType = d.PayType; consume.Discount = 100; consume.Quantity = d.Count; consume.SourceType = 1; uow.Consume.Add(consume); DXInfo.Models.Bills bill = new DXInfo.Models.Bills(); bill.Sum = d.Sum; bill.Voucher = d.Voucher; bill.Amount = d.Amount; bill.BillType = "WRNoMemberConsumeWindow"; bill.CreateDate = d.CreateDate; bill.DeptName = d.DeptName; bill.FullName = d.FullName; bill.PayTypeName = d.PayTypeName; bill.Cash = dCash; bill.Change = dChange; uow.Bills.Add(bill); uow.Commit(); //DXInfo.Restaurant.DeskManageFacade dmf = new DXInfo.Restaurant.DeskManageFacade(); foreach (var si in d.lSelInv) { Guid orderMenuId = si.OrderMenuId; DXInfo.Models.OrderMenus om = uow.OrderMenus.GetById(orderMenuId);//.Where(w => w.Id == orderMenuId).FirstOrDefault(); om.OperDate = DateTime.Now; om.UserId = App.MyIdentity.oper.UserId; om.Status = 8; uow.OrderMenus.Update(om); DXInfo.Models.OrderMenusHis omHis = Mapper.Map <DXInfo.Models.OrderMenusHis>(om);//dmf.CreateOrderMenuHis(om, App.MyIdentity.oper.UserId, DateTime.Now); omHis.LinkId = om.Id; uow.OrderMenusHis.Add(omHis); DXInfo.Models.ConsumeList cl = new DXInfo.Models.ConsumeList(); cl.Amount = si.Amount; cl.Consume = consume.Id; cl.CreateDate = d.CreateDate; cl.DeptId = d.DeptId; cl.Inventory = si.Id; cl.Price = si.Price; cl.Quantity = si.Quantity; cl.UserId = d.UserId; cl.IsPackage = si.IsPackage; cl.PackageId = si.PackageId; cl.Discount = 100; cl.Sum = cl.Amount; uow.ConsumeList.Add(cl); DXInfo.Models.BillInvLists bl = new DXInfo.Models.BillInvLists(); bl.Amount = si.Amount; bl.Bill = bill.Id; bl.CupType = si.EnglishName; bl.Name = si.Name; bl.Quantity = si.Quantity; bl.SalePrice = si.Price; uow.BillInvLists.Add(bl); } uow.Commit(); transaction.Complete(); } PrintDialog pDialog = new PrintDialog(); pDialog.PageRangeSelection = PageRangeSelection.AllPages; pDialog.UserPageRangeEnabled = true; pDialog.PrintVisual(GridPrint, "非会员消费打印"); DialogResult = true; this.Close(); }