예제 #1
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();
        }
예제 #2
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();
        }
예제 #3
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();
        }