Exemplo n.º 1
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));
            }
        }
Exemplo n.º 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));
        }