Ejemplo n.º 1
0
        public static bool CardCancelConsume(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.CancelCoolerConsumeCard(sb, value);
            }
            catch (Exception ex)
            {
                throw ex;
            }
//#endif
            if (st != 0)
            {
                MessageBox.Show(CardRef.GetStr(st));
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            //编辑
            dynamic m = MemberList.SelectedItem;

            if (string.IsNullOrWhiteSpace(card.CardNo))
            {
                throw new ArgumentNullException("卡号", "请输入卡号");
            }
            if (card.CardLevel == Guid.Empty || card.CardLevel == null)
            {
                throw new ArgumentNullException("卡级别", "请选择卡级别");
            }

            DXInfo.Models.aspnet_CustomProfile user = App.MyIdentity.oper;
            if (user == null)
            {
                throw new ArgumentException("操作员信息错误");
            }
            Guid userId = user.UserId;

            if (!user.DeptId.HasValue || user.DeptId == Guid.Empty)
            {
                throw new ArgumentException("部门信息错误");
            }

            var c = uow.Cards.GetAll().Where(w => w.CardNo == card.CardNo).FirstOrDefault();

            if (c != null)
            {
                throw new ArgumentException("卡号已存在");
            }
            StringBuilder sb = new StringBuilder(33);

            sb.Append(card.CardNo);
            int st = CardRef.CoolerPutCard(sb);

            if (st == 0)
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    card.Member     = m.Id;
                    card.DeptId     = user.DeptId.Value;
                    card.UserId     = userId;
                    card.CreateDate = DateTime.Now;
                    uow.Cards.Add(card);
                    uow.Commit();
                    Common.AddCardsLog(uow, card);
                    uow.Commit();
                    transaction.Complete();
                }
                card = new DXInfo.Models.Cards();
                MessageBox.Show("发卡成功");
            }
            else
            {
                MessageBox.Show(CardRef.GetStr(st));
            }
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        public bool ReadCard(out string cardNo, out decimal cardBalance)
        {
            StringBuilder sb    = new StringBuilder(33);
            int           value = 0;

            cardNo      = "";
            cardBalance = 0;
            int st = CardRef.CoolerReadCard(sb, ref value);

            if (st != 0)
            {
                MessageBox.Show(CardRef.GetStr(st));
                return(false);
            }
            cardBalance = Convert.ToDecimal(value) / 100;
            cardNo      = sb.ToString();
            return(true);
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
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;

            StringBuilder sb = new StringBuilder(33);

            sb.Append(d.CardNo);
            int value = Convert.ToInt32((d.Amount + d.Donate) * 100);

#if !DEBUG
            int st = CardRef.CoolerRechargeCard(sb, value);
#else
            //string strCardNo = "12347";
            int st = 0;
#endif
            if (st != 0)
            {
                MessageBox.Show(CardRef.GetStr(st));
                DialogResult = false;
                this.Close();
                return;
            }

            DXInfo.Models.Recharges recharge = new DXInfo.Models.Recharges();
            recharge.Amount      = d.Amount;
            recharge.Donate      = d.Donate;
            recharge.LastBalance = d.LastBalance;
            recharge.Balance     = d.Balance;
            recharge.Card        = d.Id;
            recharge.CreateDate  = d.CreateDate;
            recharge.UserId      = d.UserId;
            recharge.DeptId      = d.DeptId;
            recharge.PayType     = d.PayType;
            if (this.IsPutCard)
            {
                recharge.RechargeType = 2;
            }
            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 = recharge.Balance;

            uow.Recharges.Add(recharge);

            //小票
            DXInfo.Models.Bills bill = new DXInfo.Models.Bills();
            bill.Amount      = d.Amount;
            bill.Balance     = d.Balance;
            bill.BillType    = "CardInMoneyWindow";
            bill.CardNo      = d.CardNo;
            bill.CreateDate  = d.CreateDate;
            bill.DeptName    = d.DeptName;
            bill.Donate      = d.Donate;
            bill.FullName    = d.FullName;
            bill.LastBalance = d.LastBalance;
            bill.MemberName  = d.MemberName;
            bill.PayTypeName = d.PayTypeName;

            uow.Bills.Add(bill);

            uow.Commit();

            //PrintDialog pDialog = new PrintDialog();
            //pDialog.PrintVisual(GridPrint, "会员充值打印");
            //MyPrint mp = new MyPrint();
            //mp.CardInMoneyPrint(uow, d);

            DialogResult = true;
            this.Close();
        }
Ejemplo n.º 7
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();
        }