private void CardUpdate(bool isCardLevelAuto, Guid cardId, decimal dBalance, decimal dPoint)
        {
            DXInfo.Models.Cards newCard = uow.Cards.GetById(g => g.Id == cardId);
            if (newCard == null)
            {
                throw new ArgumentException("卡信息未找到");
            }
            newCard.Balance = dBalance;

            if (isCardLevelAuto)
            {
                DXInfo.Models.CardLevels oldCardLevel = uow.CardLevels.GetById(g => g.Id == newCard.CardLevel);
                if (dPoint > 0)
                {
                    decimal points = uow.CardPoints.GetAll().Where(w => w.Card == cardId).Sum(s => s.Point);
                    DXInfo.Models.CardLevels cardLevel = uow.CardLevels.GetAll().Where(w => w.Point < points + dPoint &&
                                                                                       w.Id != newCard.CardLevel).OrderByDescending(o => o.Point).FirstOrDefault();
                    if (cardLevel != null && cardLevel.Discount < oldCardLevel.Discount)
                    {
                        newCard.CardLevel = cardLevel.Id;
                    }
                }
            }
            uow.Cards.Update(newCard);

            DXInfo.Models.CardsLog cardLog = Mapper.Map <DXInfo.Models.CardsLog>(newCard);
            cardLog.CardId = newCard.Id;
            uow.CardsLog.Add(cardLog);
        }
        /// <summary>
        /// 充值
        /// </summary>
        /// <param name="para"></param>
        public void CardInMoney(CardInMoneyParaObj para)
        {
            if (para.Amount <= 0)
            {
                throw new ArgumentException("请输入充值金额");
            }
            if (para.PayTypeId == null || para.PayTypeId == Guid.Empty)
            {
                throw new ArgumentNullException("请选择支付方式");
            }

            DXInfo.Models.Recharges recharge = new DXInfo.Models.Recharges();
            recharge.Amount          = para.Amount;
            recharge.Donate          = para.Donate;
            recharge.LastBalance     = para.LastBalance;
            recharge.Balance         = para.Balance;
            recharge.Card            = para.CardId;
            recharge.CreateDate      = para.CreateDate;
            recharge.UserId          = para.UserId;
            recharge.DeptId          = para.DeptId;
            recharge.PayType         = para.PayTypeId;
            recharge.RechargeType    = para.RechargeType;
            recharge.OperatorsOnDuty = para.OperatorsOnDuty;
            uow.Recharges.Add(recharge);

            DXInfo.Models.Cards oldCard = uow.Cards.GetById(g => g.Id == para.CardId);
            if (oldCard == null)
            {
                throw new ArgumentException("请先读卡");
            }
            oldCard.Balance = recharge.Balance;
            uow.Cards.Update(oldCard);

            DXInfo.Models.CardsLog cardsLog = Mapper.Map <DXInfo.Models.Cards, DXInfo.Models.CardsLog>(oldCard);
            cardsLog.CardId     = para.CardId;
            cardsLog.CreateDate = para.CreateDate;
            cardsLog.UserId     = para.UserId;
            cardsLog.DeptId     = para.DeptId;
            uow.CardsLog.Add(cardsLog);
            //小票
            DXInfo.Models.Bills bill = new DXInfo.Models.Bills();
            bill.Amount      = para.Amount;
            bill.Balance     = para.Balance;
            bill.BillType    = "CardInMoneyWindow";
            bill.CardNo      = oldCard.CardNo;
            bill.CreateDate  = para.CreateDate;
            bill.DeptName    = para.DeptName;
            bill.Donate      = para.Donate;
            bill.FullName    = para.UserName + "," + para.FullName;
            bill.LastBalance = para.LastBalance;
            bill.MemberName  = para.MemberName;
            bill.PayTypeName = para.PayTypeName;
            uow.Bills.Add(bill);

            uow.Commit();
        }
Beispiel #3
0
        private void cardFound(object sender)
        {
            //解挂
            //DXInfo.Models.aspnet_CustomProfile user = this.Oper;

            //Guid userId = user.UserId;
            if (!ClientCommon.CheckUser(this.Oper))
            {
                return;
            }
            Guid cid = Guid.Parse((sender as Button).Tag.ToString());
            var  c   = Uow.Cards.GetById(g => g.Id == cid);

            if (!ClientCommon.CheckCard(c))
            {
                return;
            }
            MessageBoxResult result = MessageBox.Show("是否解挂此卡?卡号:" + c.CardNo, "解挂", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }
            DateTime dtNow = DateTime.Now;

            c.FoundDate   = dtNow;
            c.FoundUserId = this.Oper.UserId;
            c.FoundDeptId = this.Dept.DeptId;
            c.Status      = 0;
            Uow.Cards.Update(c);

            DXInfo.Models.CardsLog cardsLog = Mapper.Map <DXInfo.Models.Cards, DXInfo.Models.CardsLog>(c);
            cardsLog.CardId     = c.Id;
            cardsLog.CreateDate = dtNow;
            cardsLog.UserId     = this.Oper.UserId;
            cardsLog.DeptId     = this.Dept.DeptId;
            Uow.CardsLog.Add(cardsLog);

            Uow.Commit();

            MessageBox.Show("解挂成功");
            this.query();
        }
        private void ModifyMemberExecute()
        {
            string msg;

            if (!Validate(out msg))
            {
                Helper.ShowErrorMsg(msg);
                return;
            }
            DateTime dtNow = DateTime.Now;

            this.Member.MemberName   = this.MemberName;
            this.Member.ModifyDate   = dtNow;
            this.Member.ModifyDeptId = this.Dept.DeptId;
            this.Member.ModifyUserId = this.Oper.UserId;
            Uow.Members.Update(this.Member);

            DXInfo.Models.MembersLog memberLog = Mapper.Map <DXInfo.Models.Members, DXInfo.Models.MembersLog>(Member);
            memberLog.MemberId   = Member.Id;
            memberLog.UserId     = this.Oper.UserId;
            memberLog.DeptId     = this.Dept.DeptId;
            memberLog.CreateDate = dtNow;
            Uow.MembersLog.Add(memberLog);

            if (!string.IsNullOrEmpty(this.CardPwd) && this.CardPwd != this.Card.CardPwd)
            {
                DXInfo.Models.Cards oldCard = Uow.Cards.GetById(g => g.Id == this.Card.Id);
                if (oldCard != null)
                {
                    oldCard.CardPwd = this.CardPwd;
                    Uow.Cards.Update(oldCard);

                    DXInfo.Models.CardsLog cardsLog = Mapper.Map <DXInfo.Models.Cards, DXInfo.Models.CardsLog>(oldCard);
                    cardsLog.CardId     = oldCard.Id;
                    cardsLog.UserId     = this.Oper.UserId;
                    cardsLog.DeptId     = this.Dept.DeptId;
                    cardsLog.CreateDate = dtNow;
                    Uow.CardsLog.Add(cardsLog);
                }
            }
            Uow.Commit();
            Helper.ShowSuccMsg("修改会员成功");
        }
Beispiel #5
0
        private void cardLoss(object sender)
        {
            //挂失
            if (!ClientCommon.CheckUser(this.Oper))
            {
                return;
            }
            Guid cid = Guid.Parse((sender as Button).Tag.ToString());
            var  c   = Uow.Cards.GetById(g => g.Id == cid);

            if (!ClientCommon.CheckCard(c))
            {
                return;
            }

            MessageBoxResult result = MessageBox.Show("是否挂失此卡?卡号:" + c.CardNo, "挂失", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }
            DateTime dtNow = DateTime.Now;

            c.LossDate   = dtNow;
            c.LossUserId = this.Oper.UserId;
            c.LossDeptId = this.Dept.DeptId;
            c.Status     = 1;
            Uow.Cards.Update(c);

            DXInfo.Models.CardsLog cardsLog = Mapper.Map <DXInfo.Models.Cards, DXInfo.Models.CardsLog>(c);
            cardsLog.CardId     = c.Id;
            cardsLog.CreateDate = dtNow;
            cardsLog.UserId     = this.Oper.UserId;
            cardsLog.DeptId     = this.Dept.DeptId;
            Uow.CardsLog.Add(cardsLog);

            Uow.Commit();
            MessageBox.Show("挂失成功");
            this.query();
        }
Beispiel #6
0
        private void cardAdd()
        {
            //补卡
            if (string.IsNullOrWhiteSpace(Detail.Card.SecondCardNo))
            {
                Helper.ShowErrorMsg("请输入补卡卡号");
                return;
            }
            if (Detail.Card.CardLevel == Guid.Empty || Detail.Card.CardLevel == null)
            {
                Helper.ShowErrorMsg("请选择卡级别");
                return;
            }

            //DXInfo.Models.aspnet_CustomProfile user = this.Oper;
            //Guid userId = user.UserId;
            if (!ClientCommon.CheckUser(this.Oper))
            {
                return;
            }

            var c = Uow.Cards.GetById(g => g.Id == Detail.Card.Id);

            if (!ClientCommon.CheckCard(c))
            {
                return;
            }

            var d = Uow.CardLevels.GetById(g => g.Id == Detail.Card.CardLevel);

            if (d == null)
            {
                Helper.ShowErrorMsg("卡级别信息错误");
                return;
            }
            if (!string.IsNullOrEmpty(d.BeginLetter))
            {
                if (!Detail.Card.SecondCardNo.StartsWith(d.BeginLetter))
                {
                    Helper.ShowErrorMsg("卡号必须以" + d.BeginLetter + "字母开头");
                    return;
                }
            }
            var cardType = Uow.CardTypes.GetById(g => g.Id == Detail.Card.CardType);

            if (cardType == null)
            {
                Helper.ShowErrorMsg("卡型信息错误");
                return;
            }
            string strComment;
            string strCardNoRule = ClientCommon.CardNoRule(cardType, out strComment);

            if (!Regex.IsMatch(Detail.Card.SecondCardNo, strCardNoRule))
            {
                if (!string.IsNullOrEmpty(d.BeginLetter))
                {
                    Helper.ShowErrorMsg(strComment + ",且必须以" + d.BeginLetter + "字母开头");
                    return;
                }
                else
                {
                    Helper.ShowErrorMsg(strComment);
                    return;
                }
            }
            var c1 = Uow.Cards.GetAll().Where(w => w.CardNo == Detail.Card.SecondCardNo).FirstOrDefault();

            if (c1 != null)
            {
                Helper.ShowErrorMsg("卡号已存在");
                return;
            }

            StringBuilder sb = new StringBuilder(33);

            sb.Append(Detail.Card.SecondCardNo);
//#if DEBUG
//            int st = 0;
//#else
            int st = CardRef.CoolerPutCard(sb);

//#endif
            if (st != 0)
            {
                MessageBox.Show(CardRef.GetStr(st));
                return;
            }
            int value = Convert.ToInt32(Detail.Card.Balance * 100);

//#if !DEBUG
            st = CardRef.CoolerRechargeCard(sb, value);
//#endif
            //充值
            if (st != 0)
            {
                MessageBox.Show(CardRef.GetStr(st));
                return;
            }
            DateTime dtNow = DateTime.Now;

            using (TransactionScope transaction = new TransactionScope())
            {
                DXInfo.Models.Cards newcard = new DXInfo.Models.Cards();
                newcard.CardNo     = Detail.Card.SecondCardNo;
                newcard.CardLevel  = Detail.Card.CardLevel;
                newcard.CardType   = Detail.Card.CardType;
                newcard.CreateDate = dtNow;
                newcard.UserId     = this.Oper.UserId;
                newcard.DeptId     = this.Dept.DeptId;
                newcard.Balance    = Detail.Card.Balance;
                newcard.Member     = Detail.Card.Member;
                newcard.CardPwd    = Detail.Card.CardPwd;
                newcard.Comment    = c.Comment;
                Uow.Cards.Add(newcard);
                Uow.Commit();

                DXInfo.Models.CardsLog cardsLog = Mapper.Map <DXInfo.Models.Cards, DXInfo.Models.CardsLog>(newcard);
                cardsLog.CardId     = newcard.Id;
                cardsLog.CreateDate = dtNow;
                cardsLog.UserId     = this.Oper.UserId;
                cardsLog.DeptId     = this.Dept.DeptId;
                Uow.CardsLog.Add(cardsLog);


                c.SecondCardNo = Detail.Card.SecondCardNo;
                c.AddDate      = dtNow;
                c.AddDeptId    = this.Dept.DeptId;
                c.AddUserId    = this.Oper.UserId;
                c.Status       = 2;
                Uow.Cards.Update(c);

                DXInfo.Models.CardsLog cardsLog1 = Mapper.Map <DXInfo.Models.Cards, DXInfo.Models.CardsLog>(c);
                cardsLog1.CardId     = c.Id;
                cardsLog1.CreateDate = dtNow;
                cardsLog1.UserId     = this.Oper.UserId;
                cardsLog1.DeptId     = this.Dept.DeptId;
                Uow.CardsLog.Add(cardsLog1);

                DXInfo.Models.Recharges recharge = new DXInfo.Models.Recharges();
                recharge.Amount       = Detail.Card.Balance;
                recharge.Balance      = Detail.Card.Balance;
                recharge.CreateDate   = DateTime.Now;
                recharge.DeptId       = this.Dept.DeptId;
                recharge.UserId       = this.Oper.UserId;
                recharge.LastBalance  = 0;
                recharge.Donate       = 0;
                recharge.RechargeType = 1;
                recharge.Card         = newcard.Id;
                Uow.Recharges.Add(recharge);

                if (Detail.Cost > 0)
                {
                    recharge              = new DXInfo.Models.Recharges();
                    recharge.Amount       = Detail.Cost;
                    recharge.Balance      = 0;
                    recharge.CreateDate   = DateTime.Now;
                    recharge.DeptId       = this.Dept.DeptId;
                    recharge.UserId       = this.Oper.UserId;
                    recharge.LastBalance  = 0;
                    recharge.Donate       = 0;
                    recharge.RechargeType = 3;
                    recharge.Card         = newcard.Id;

                    Uow.Recharges.Add(recharge);
                }
                var qpt = Uow.CardPoints.GetAll().Where(w => w.Card == Detail.Card.Id);
                if (qpt.Count() > 0)
                {
                    decimal pt = qpt.Sum(s => s.Point);
                    if (pt != 0)
                    {
                        DXInfo.Models.CardPoints cp = new DXInfo.Models.CardPoints();
                        cp.Card       = newcard.Id;
                        cp.CreateDate = dtNow;
                        cp.DeptId     = this.Dept.DeptId;
                        cp.Point      = pt;
                        cp.UserId     = this.Oper.UserId;
                        cp.PointType  = 1;
                        Uow.CardPoints.Add(cp);
                    }
                }
                Uow.Commit();
                transaction.Complete();
            }
            MessageBox.Show("补卡成功");
            this.query();
            Detail = new CardAddPageDetail();
        }
        private void addMember()
        {
            string msg;

            if (!Validate(out msg))
            {
                Helper.ShowErrorMsg(msg);
                return;
            }
            DateTime dtNow = DateTime.Now;

            this.Member.UserId     = this.Oper.UserId;
            this.Member.CreateDate = dtNow;
            this.Member.DeptId     = this.Dept.DeptId;

            int oldcount = Uow.Cards.GetAll().Where(w => w.CardNo == this.CardNo).Count();

            if (oldcount > 0)
            {
                Helper.ShowErrorMsg(this.CardNo + ":卡号已存在");
                return;
            }
            this.Card.CardNo = this.CardNo;
            if (this.IsCardLevelAuto)
            {
                var cardLevel = Uow.CardLevels.GetAll().Where(w => w.IsDefault &&
                                                              (w.DeptId == this.Dept.DeptId || w.DeptId == Guid.Empty)).OrderBy(o => o.Code).FirstOrDefault();
                if (cardLevel == null)
                {
                    Helper.ShowErrorMsg("请设置无积分时的默认卡级别");
                    return;
                }
                this.Card.CardLevel = cardLevel.Id;
            }
            else
            {
                this.Card.CardLevel = this.SelectedCardLevel.Id;
            }
            this.Card.CardType   = this.SelectedCardType.Id;
            this.Card.CreateDate = dtNow;
            this.Card.DeptId     = this.Dept.DeptId;
            this.Card.UserId     = this.Oper.UserId;

            this.Member.MemberName = this.MemberName;

            if (!this.SelectedCardType.IsVirtual)
            {
                StringBuilder sb = new StringBuilder(33);
                sb.Append(this.CardNo);
//#if DEBUG
//                int st = 0;
//#else
                int st = CardRef.CoolerPutCard(sb);
//#endif
                if (st != 0)
                {
                    Helper.ShowErrorMsg(CardRef.GetStr(st));
                    return;
                }
            }
            using (TransactionScope transaction = new TransactionScope())
            {
                Uow.Members.Add(this.Member);
                Uow.Commit();

                this.Card.Member = this.Member.Id;
                Uow.Cards.Add(this.Card);
                Uow.Commit();

                DXInfo.Models.MembersLog memberLog = Mapper.Map <DXInfo.Models.Members, DXInfo.Models.MembersLog>(Member);
                memberLog.MemberId = Member.Id;
                Uow.MembersLog.Add(memberLog);

                DXInfo.Models.CardsLog cardsLog = Mapper.Map <DXInfo.Models.Cards, DXInfo.Models.CardsLog>(Card);
                cardsLog.CardId = Card.Id;
                Uow.CardsLog.Add(cardsLog);

                Uow.Commit();
                transaction.Complete();
            }
            if (this.SelectedCardType.IsMoney)
            {
                MessageBoxResult mr = MessageBox.Show("添加新会员成功,是否充值?", "充值提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (mr == MessageBoxResult.Yes)
                {
                    var cmp = ServiceLocator.Current.GetInstance <PutCardInMondeyUserControl>();
                    this.NavigationUserControl(cmp);
                }
            }
            else
            {
                Helper.ShowSuccMsg("添加新会员成功。");
            }
            this.InitObject();
        }