コード例 #1
0
ファイル: Common.cs プロジェクト: zhenghua75/DXInfo
        public static bool CardConsume(string cardNo, decimal dAmount)
        {
            StringBuilder sb = new StringBuilder(33);

            sb.Append(cardNo);
            int value = Convert.ToInt32(dAmount * 100);
            int st    = -1;

//#if DEBUG
//            st = 0;
//#else
            try
            {
                st = CardRef.CoolerConsumeCard(sb, value);
            }
            catch (Exception ex)
            {
                throw ex;
            }
//#endif
            if (st != 0)
            {
                MessageBox.Show(CardRef.GetStr(st));
                return(false);
            }
            return(true);
        }
コード例 #2
0
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            //persons.Add(new Person(++index));
            //Person p = (Person)this.listView1.SelectedItems[0];
            //MessageBox.Show(p.Sex.ToString());
            StringBuilder sb = new StringBuilder(33);

            sb.Append("123456");
            int   st    = 0;
            Int32 value = 100;

            st = CardRef.CoolerPutCard(sb);
            st = CardRef.CoolerReadCard(sb, ref value);
            st = CardRef.CoolerRechargeCard(sb, 100);
            st = CardRef.CoolerConsumeCard(sb, 100);
            MessageBox.Show(CardRef.GetStr(st));
        }
コード例 #3
0
        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;

            if (d.Amount > 0)
            {
                StringBuilder sb = new StringBuilder(33);
                sb.Append(d.CardNo);
                int value = Convert.ToInt32(d.Amount * 100);
                int st    = CardRef.CoolerConsumeCard(sb, value);
                if (st != 0)
                {
                    MessageBox.Show(CardRef.GetStr(st));
                    return;
                }
            }
            using (TransactionScope transaction = new TransactionScope())
            {
                DXInfo.Models.Consume consume = new DXInfo.Models.Consume();
                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.Balance     = d.Balance;
                consume.CreateDate  = d.CreateDate;
                consume.DeptId      = d.DeptId;
                consume.LastBalance = d.LastBalance;
                consume.Point       = d.Point;
                consume.UserId      = d.UserId;
                consume.Point       = d.Point;
                consume.ConsumeType = 0;
                consume.DeskNo      = txtDeskNo.Text;
                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.Balance     = d.Balance;
                bill.BillType    = "CardConsumeWindow";
                bill.CardNo      = d.CardNo;
                bill.CreateDate  = d.CreateDate;
                bill.DeptName    = d.DeptName;
                bill.FullName    = d.FullName;
                bill.LastBalance = d.LastBalance;
                bill.MemberName  = d.MemberName;
                bill.DeskNo      = txtDeskNo.Text;
                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("卡信息未找到");
                }
                card.Balance = d.Balance;

                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);
                    }
                }
                foreach (var si in d.lSelInv)
                {
                    DXInfo.Models.ConsumeList cl = new DXInfo.Models.ConsumeList();
                    cl.Amount     = si.Amount;
                    cl.Consume    = consume.Id;
                    cl.CreateDate = d.CreateDate;
                    cl.Cup        = si.Cup;
                    cl.DeptId     = d.DeptId;
                    cl.Inventory  = si.Id;
                    cl.Price      = si.SalePrice;
                    cl.Quantity   = si.Quantity;
                    cl.UserId     = d.UserId;

                    uow.ConsumeList.Add(cl);

                    DXInfo.Models.BillInvLists bl = new DXInfo.Models.BillInvLists();
                    bl.Amount    = si.Amount;
                    bl.Bill      = bill.Id;
                    bl.CupType   = si.CupType;
                    bl.Name      = si.Name;
                    bl.Quantity  = si.Quantity;
                    bl.SalePrice = si.SalePrice;
                    bl.Tastes    = si.Tastes;

                    uow.BillInvLists.Add(bl);



                    if (si.lTastes.Count > 0)
                    {
                        uow.Commit();
                        foreach (var lt in si.lTastes)
                        {
                            DXInfo.Models.ConsumeTastes ct = new DXInfo.Models.ConsumeTastes();
                            ct.ConsumeList = cl.Id;
                            ct.Taste       = lt.Id;
                            uow.ConsumeTastes.Add(ct);
                        }
                    }
                }

                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.PrintVisual(GridPrint, "会员卡消费打印");

            DialogResult = true;
            this.Close();
        }
コード例 #4
0
        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;

            if (d.Amount > 0)
            {
                StringBuilder sb = new StringBuilder(33);
                sb.Append(d.CardNo);
                int value = Convert.ToInt32(d.Amount * 100);
//#if ! DEBUG
                int st = CardRef.CoolerConsumeCard(sb, value);
//#else
//                int st = 0;
//#endif
                if (st != 0)
                {
                    MessageBox.Show(CardRef.GetStr(st));
                    DialogResult = false;
                    this.Close();
                    return;
                }
            }
            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.Balance     = d.Balance;
                consume.CreateDate  = d.CreateDate;
                consume.DeptId      = d.DeptId;
                consume.LastBalance = d.LastBalance;
                consume.Point       = d.Point;
                consume.UserId      = d.UserId;
                consume.Point       = d.Point;
                consume.ConsumeType = 0;
                consume.SourceType  = 1;
                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.Balance     = d.Balance;
                bill.BillType    = "WRCardConsumeWindow";
                bill.CardNo      = d.CardNo;
                bill.CreateDate  = d.CreateDate;
                bill.DeptName    = d.DeptName;
                bill.FullName    = d.FullName;
                bill.LastBalance = d.LastBalance;
                bill.MemberName  = d.MemberName;
                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("卡信息未找到");
                }
                card.Balance = d.Balance;

                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 ? 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();
        }