예제 #1
0
        private void GenerateLostMembercardCommandExec()
        {
            Member     selectedUser = this.SelectedUser;
            MemberCard memberCard   = selectedUser != null?selectedUser.MemberCards.Where <MemberCard>((Func <MemberCard, bool>)(m => m.ActiveMember)).OrderByDescending <MemberCard, DateTime>((Func <MemberCard, DateTime>)(m => m.ExpireDate)).FirstOrDefault <MemberCard>() : (MemberCard)null;

            if (memberCard != null)
            {
                this.NewMemberCard.Member       = memberCard.Member;
                this.NewMemberCard.CreationTime = DateTime.Now;
                this.NewMemberCard.ExpireDate   = Pos.Properties.Settings.Default.MemberCardStartDate.Add(Pos.Properties.Settings.Default.MemberCardValidityPeriod);
                this.NewMemberCard.ActiveMember = true;
                if (this.MembercardService.GenerateMembercard(this.NewMemberCard, string.Empty, Resources.PdfMemberCardActiveMember) == string.Empty)
                {
                    int num = (int)WPFMessageBox.Show(Resources.ExceptionMembercard, Resources.ExceptionMembercardTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
                else
                {
                    this.MembercardImage  = ImageHelper.ImageToSource(this.MembercardService.ConvertPdfToImage());
                    this.PrintCardEnabled = true;
                }
            }
            else
            {
                int num = (int)WPFMessageBox.Show(Resources.PageNewMembercardCardLostNonActive, Resources.PageNewMembercardCardLostNonActiveTitle, MessageBoxButton.OK, MessageBoxImage.Asterisk);
                this.MembercardImage = (ImageSource)null;
            }
        }
        public ActionResult Create(MemberCard member, int?id)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", member));
            }

            // Create a memberCard

            var memberCard = new MemberCard()
            {
                CustomerID     = id.Value,
                MemberCardCode = MemberCard.GetMemberCardCode(),
                Type           = MembershipType.Basic,
                CreationDate   = MemberCard.GetCreationDate(),
                Credits        = 0,
                NewsLetter     = member.NewsLetter
            };

            // Send memberCard to DB
            _context.MemberCards.Add(memberCard);
            _context.SaveChanges();

            // where i will send the user
            return(RedirectToAction("Index", "Customers"));
        }
예제 #3
0
        public virtual AjaxResponse GetMoviePlayPathForUser(MovieGetInput input)
        {
            Movie  movie = Repository.Get(input.Id);
            string path  = movie.Path;

            if (movie.MemberLevelId != null || movie.ShouldBeMemberForPlay)
            {
                if (InfrastructureSession.UserId == null)
                {
                    return(new AjaxResponse(new ErrorInfo("you has not login!"), true));
                }
                MemberCard memberCard = _memberCardManager.GetValidMemberCardOfUser(InfrastructureSession.UserId.Value);

                if (memberCard == null)
                {
                    return(new AjaxResponse(new ErrorInfo("you has not member!")));
                }

                if (movie.MemberLevelId != null && memberCard.Level.Id != movie.MemberLevelId)
                {
                    return(new AjaxResponse(new ErrorInfo("you are not !" + movie.MemberLevel.DisplayName)));
                }
                path = QiniuFileHelper.GetAuthorizedDownloadPath(movie.Path);
            }
            return(new AjaxResponse(path));
        }
예제 #4
0
        public List <MemberCard> findAll()
        {
            List <MemberCard> list = null;
            String            sql  = "SELECT * FROM members_cards";

            using (MySqlDataReader rdr = MySqlHelper.ExecuteReader(MySqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sql))
            {
                while (true)
                {
                    if (list == null)
                    {
                        list = new List <MemberCard>();
                    }

                    MemberCard card = fillMemberCard(rdr);
                    if (card == null)
                    {
                        break;
                    }
                    list.Add(card);
                }
            }

            return(list);
        }
        private bool DoValidate()
        {
            if (G_MemberCard == null)
            {
                G_MemberCard = new MemberCard();
            }
            lblError.Text            = "";
            G_MemberCard.Name        = txtName.Text.Trim();
            G_MemberCard.Address     = txtAddress.Text.Trim();
            G_MemberCard.Type        = cbType.Text;
            G_MemberCard.Note        = txtNote.Text.Trim();
            G_MemberCard.DateOfIssue = date_DateOfIssue.Value;
            G_MemberCard.ExpireDate  = date_ExpireDate.Value;
            G_MemberCard.Active      = chkActive.Checked;
            G_MemberCard.Code        = txtCode.Text.Trim();
            if (string.IsNullOrEmpty(G_MemberCard.Code))
            {
                lblError.Text = "Vui lòng chọn mã thẻ";
                return(false);
            }
            else if (string.IsNullOrEmpty(G_MemberCard.Name))
            {
                lblError.Text = "Vui lòng nhập tên chủ thẻ";
                return(false);
            }
            else if (string.IsNullOrEmpty(G_MemberCard.Type))
            {
                lblError.Text = "Vui lòng chọn loại thẻ";
                return(false);
            }

            return(true);
        }
        public async Task <ActionResult <MemberCard> > PostMemberCards(MemberCard MemberCards)
        {
            // Part 1 : Get all previous card for same member
            List <MemberCard> MemberCardsListWithSameMember = _context.MemberCards.ToList().Where(
                c =>
                c.MemberId == MemberCards.MemberId &&
                !c.IsBlacklist &&
                !c.IsDeactivated
                ).ToList();

            // Part 2 : Set previous one to deactivated
            foreach (MemberCard MemberCardsToDeactivate in MemberCardsListWithSameMember)
            {
                // Deactivate account for old one
                MemberCardsToDeactivate.IsDeactivated         = true;
                MemberCardsToDeactivate.ExpiryCardDate        = DateTime.Now;
                _context.Entry(MemberCardsToDeactivate).State = EntityState.Modified;
            }

            // Part 3 : Add new member card
            _context.MemberCards.Add(MemberCards);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMemberCards", new { id = MemberCards.MemberCardId }, MemberCards));
        }
예제 #7
0
        public async Task <Member> CreateMember(CreateMemberCommand command)
        {
            if (command == null)
            {
                throw new CustomBadRequestException(ExceptionMessage.NullCommand);
            }

            if (String.IsNullOrEmpty(command.PhoneNumber) && String.IsNullOrEmpty(command.Email))
            {
                throw new CustomBadRequestException(ExceptionMessage.MemberEmptyEmailAndPhone);
            }

            if (command.IdCard == null)
            {
                throw new CustomBadRequestException(ExceptionMessage.IdCardNull);
            }

            if (!String.IsNullOrEmpty(command.Email))
            {
                if (!IsEmailValid(command.Email))
                {
                    throw new CustomBadRequestException(ExceptionMessage.BadEmailFormat);
                }
            }

            var idCard = new IdentityCard
            {
                Firstname              = command.IdCard.Firstname,
                Lastname               = command.IdCard.Lastname,
                BirthDate              = command.IdCard.BirthDate,
                CardNumber             = command.IdCard.CardNumber,
                ExpirationDate         = command.IdCard.ExpirationDate,
                ValidityDate           = command.IdCard.ValidityDate,
                NationalRegisterNumber = command.IdCard.NationalRegisterNumber
            };

            ValidateIdCard(idCard);

            var memberCard = MemberCard.GenerateMemberCard();

            var member = new Member
            {
                Email         = command.Email,
                PhoneNumber   = command.PhoneNumber,
                IdentityCards = new List <IdentityCard>()
                {
                    idCard
                },
                MemberCards = new List <MemberCard>()
                {
                    memberCard
                },
                IsActive = true
            };

            _context.Members.Add(member);
            await _context.SaveChangesAsync();

            return(member);
        }
예제 #8
0
        public IActionResult SaveEntity(MemberCard entity)
        {
            bool   result    = true;
            string message   = string.Empty;
            var    userEmail = User.GetSpecificClaim("Email");

            if (ModelState.IsValid)
            {
                entity.UserModified = userEmail;

                if (entity.Id == 0)
                {
                    entity.UserCreated = userEmail;
                    _memberCardService.Add(entity, out result, out message);
                }
                else
                {
                    _memberCardService.UpdateChangedProperties(entity, out result, out message);
                }

                return(new OkObjectResult(new GenericResult(result, message)));
            }
            else
            {
                List <string> listErrors  = ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage).ToList();
                string        errorString = String.Join("\n", listErrors.ToArray());
                return(new OkObjectResult(new GenericResult(false, errorString)));
            }
        }
예제 #9
0
 private void AddMemberCard(MemberCard memberCard)
 {
     try
     {
         if (AuthenticationService.Instance.AuthenticatedMember == null)
         {
             return;
         }
         Member byId = this.UnitOfWork.MemberRepository.GetById(AuthenticationService.Instance.AuthenticatedMember.Id);
         if (byId != null)
         {
             this.NewMemberCard.CreatedBy = byId;
         }
         this.UnitOfWork.MemberCardRepository.Add(memberCard);
         this.UnitOfWork.Save();
         int num = (int)WPFMessageBox.Show(Resources.PageNewMembercardUpdateSuccess, Resources.PageNewMembercardUpdateSuccessTitle, MessageBoxButton.OK, MessageBoxImage.Asterisk);
         NewMembercardViewModel.logger.Info("MemberCard added successfully to existing member, card id: " + (object)memberCard.Id + ", member: " + (object)memberCard.Member.Id);
         NavigatorHelper.NavigationService.Refresh();
     }
     catch (SqlException ex)
     {
         SplashScreenHelper.CloseInstant();
         int num = (int)WPFMessageBox.Show(Resources.ExceptionDbWarning + ex.Message, Resources.ExceptionDbWarningTitle, MessageBoxButton.OK, MessageBoxImage.Hand);
         NewMembercardViewModel.logger.Error("Database error: {0}", ex.Message);
         if (NavigatorHelper.NavigationService == null)
         {
             return;
         }
         NavigatorHelper.NavigationService.Refresh();
     }
 }
예제 #10
0
        void IMemberCardMgr.Save(MemberCard memberCard)
        {
            List <ValidationResult> results = new List <ValidationResult>();
            bool isValid = Validator.TryValidateObject(memberCard,
                                                       new ValidationContext(memberCard),
                                                       results);

            if (!isValid)
            {
                throw new ArgumentException("会员卡数据不合法!");
            }

            if (memberCard.Remainder == 0)
            {
                _memberCardRepository.Remove(memberCard);
            }
            else
            {
                if (memberCard.IsTransient())
                {
                    memberCard.GenerateNewIdentity();
                    _memberCardRepository.Add(memberCard);
                }
                else
                {
                    _memberCardRepository.Modify(memberCard);
                }
            }
            _memberCardRepository.UnitOfWork.Commit();
        }
예제 #11
0
        /// <summary>
        /// 创建积分信息
        /// </summary>
        /// <returns></returns>
        public int CreateScore(string weixinID, string userWeiXinID, string orderid)
        {
            MemberInfo Info = MemberHelper.GetMemberInfo(weixinID);

            string cardno = MemberHelper.GetCardNo(userWeiXinID, weixinID);

            if (!string.IsNullOrEmpty(cardno))
            {
                MemberCard MyCard             = MemberHelper.GetMemberCard(cardno, weixinID);
                string     SupermarketOrderId = "";

                var score = GetScore(ref SupermarketOrderId, Info, cardno, weixinID, orderid);

                string sql2 = "insert into jifendetail (weixinid,userweixinid,jifen,addtime,Remark,orderid,night,cardno,userid) values (@weixinid,@userweixinid,@jifen,@addtime,@Remark,@orderid,@night,@cardno,@userid)";
                int    rs   = SQLHelper.Run_SQL(sql2, SQLHelper.GetCon(), new Dictionary <string, DBParam>()
                {
                    { "weixinid", new DBParam()
                      {
                          ParamValue = weixinID
                      } },
                    { "userweixinid", new DBParam()
                      {
                          ParamValue = userWeiXinID
                      } },
                    { "jifen", new DBParam()
                      {
                          ParamValue = score.ToString()
                      } },
                    { "addtime", new DBParam()
                      {
                          ParamValue = DateTime.Now.ToString()
                      } },
                    { "orderid", new DBParam()
                      {
                          ParamValue = SupermarketOrderId
                      } },
                    { "Remark", new DBParam()
                      {
                          ParamValue = "超市返积分"
                      } },
                    { "night", new DBParam()
                      {
                          ParamValue = (0).ToString()
                      } },
                    { "cardno", new DBParam()
                      {
                          ParamValue = cardno
                      } },
                    { "userid", new DBParam()
                      {
                          ParamValue = MyCard.memberid
                      } },
                });
                return(rs);
            }

            return(0);
        }
        public ActionResult Delete(int id)
        {
            MemberCard memberCard = _context.MemberCards.Find(id);

            _context.MemberCards.Remove(memberCard);
            _context.SaveChanges();

            return(RedirectToAction("Index", "Customers"));
        }
 private void gridEX_SelectionChanged(object sender, EventArgs e)
 {
     if (gridEX.SelectedItems.Count > 0)
     {
         GridEXRow row = ((GridEXSelectedItem)gridEX.SelectedItems[0]).GetRow();
         G_MemberCard = (MemberCard)((GridEXSelectedItem)gridEX.SelectedItems[0]).GetRow().DataRow;
         FillDataToForm();
     }
 }
 private void FillDataToForm(MemberCard objMemberCard)
 {
     lblName.Text        = objMemberCard.Name;
     lblNote.Text        = objMemberCard.Note;
     lblAddress.Text     = objMemberCard.Address;
     lblType.Text        = objMemberCard.Type;
     lblDateOfIssue.Text = objMemberCard.DateOfIssue.ToString("hh:mm:ss dd/MM/yyyy");
     lblExpireDate.Text  = objMemberCard.ExpireDate.ToString("hh:mm:ss dd/MM/yyyy");
 }
 private void SmartcardInserted(object o, EventArgs e)
 {
     if (this.SuspendService)
     {
         return;
     }
     this.AuthTimer.Stop();
     try
     {
         using (UnitOfWork unitOfWork = new UnitOfWork())
         {
             if (this.PcscService.CardId == null)
             {
                 this.Deauthenticate();
                 this.PcscService.Acr122BlinkLed();
             }
             else
             {
                 MemberCard smartcardIdNoTracking = unitOfWork.MemberCardRepository.GetBySmartcardIdNoTracking(this.PcscService.CardId);
                 if (smartcardIdNoTracking != null && smartcardIdNoTracking.Member != null && smartcardIdNoTracking.Member?.Roles != null)
                 {
                     Member member = smartcardIdNoTracking.Member;
                     int    num1;
                     if (member == null)
                     {
                         num1 = 0;
                     }
                     else
                     {
                         int?count = member.Roles?.Count;
                         int num2  = 0;
                         num1 = count.GetValueOrDefault() == num2 ? (count.HasValue ? 1 : 0) : 0;
                     }
                     if (num1 == 0)
                     {
                         this.AuthenticatedMember = smartcardIdNoTracking.Member;
                         if (this.AuthenticatedMember == null)
                         {
                             return;
                         }
                         this.OnMemberAuthenticated(new AuthenticationService.AuthenticationEventArgs(this.AuthenticatedMember));
                         return;
                     }
                 }
                 this.Deauthenticate();
                 this.PcscService.Acr122BlinkLed();
             }
         }
     }
     catch (Exception ex)
     {
         this.AuthenticatedMember = (Member)null;
         this.Deauthenticate();
     }
 }
예제 #16
0
        public void LoadSingleMember(Data.Member member)
        {
            MemberCard card = new MemberCard(member.Id);

            card.IsInteractive = Type != MemberSelectionCategory.None;
            card.SetGraphics(ViewType.SelectedIndex == 0 ? MemberCard.MemberGraphics.Chip : MemberCard.MemberGraphics.Card);
            MembersArea.Children.Add(card);
            card.MemberSelected += Card_MemberSelected;
            automatic            = true;
            Card_MemberSelected(card.Member);
        }
예제 #17
0
        public MemberCard find(int id)
        {
            MemberCard card = null;
            String     sql  = String.Format("SELECT * FROM members_cards WHERE id = {0}", id);

            using (SQLiteDataReader rdr = SQLiteHelper.ExecuteReader(SQLiteHelper.ConnectionStringLocalTransaction, CommandType.Text, sql))
            {
                card = fillMemberCard(rdr);
            }
            return(card);
        }
예제 #18
0
        public MemberCard find(string no)
        {
            MemberCard card = null;
            String     sql  = String.Format("SELECT * FROM members_cards WHERE card_no = '{0}'", no);

            using (MySqlDataReader rdr = MySqlHelper.ExecuteReader(MySqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sql))
            {
                card = fillMemberCard(rdr);
            }
            return(card);
        }
예제 #19
0
        public bool AddMemberCard(MemberCard model)
        {
            //验证数据合法性
            if (model.Id != 0)
            {
                throw new ArgumentException("会员ID必须为0");
            }
            this.valid(model);

            //持久化操作
            return(dal.save(model) > 0);
        }
예제 #20
0
 public void Add(MemberCard memberCard, out bool result, out string message)
 {
     _memberCardRepository.Add(memberCard, out result, out message);
     if (result)
     {
         SaveChanges();
     }
     else
     {
         Dispose();
     }
 }
예제 #21
0
 public void UpdateChangedProperties(MemberCard memberCard, out bool result, out string message)
 {
     _memberCardRepository.UpdateChangedProperties(memberCard.Id, memberCard, out result, out message);
     if (result)
     {
         SaveChanges();
     }
     else
     {
         Dispose();
     }
 }
예제 #22
0
        public bool EditMemberCard(MemberCard model)
        {
            //验证数据合法性
            if (model.Id < 1)
            {
                throw new ArgumentException("非法的会员ID");
            }
            this.valid(model);

            //持久化操作
            return(dal.update(model) > 0);
        }
        public ActionResult ConfirmOrder(OrderDetailsFormViewModel viewModel)
        {
            if (viewModel.TotalCost == 0)
            {
                viewModel.CartIsEmpty = true;
                viewModel.OrderDate   = DateTime.Now;
                return(View("OrderReceipt", viewModel));
            }

            var customer = _context.Customers.Find(viewModel.CustomerId);

            Order order = new Order(Order.GetOrderNumber(viewModel.CustomerId, _context)
                                    , Order.CheckpaidOffProperty(viewModel.PaymentType)
                                    , viewModel.TotalCost,
                                    viewModel.PaymentType, customer,
                                    Order.SetOrderStatus(Order.CheckpaidOffProperty(viewModel.PaymentType)),
                                    Order.SetPayDate(Order.CheckpaidOffProperty(viewModel.PaymentType)));

            OrderProducts orderProducts = new OrderProducts();



            _context.Orders.Add(order);



            for (int i = 0; i < viewModel.Count; i++)
            {
                if (viewModel.AddToCarts[i] && viewModel.Quantities[i] != 0)
                {
                    orderProducts.OrderID        = order.OrderID;
                    orderProducts.ProductStockID = viewModel.ProductStockIds[i];
                    orderProducts.Quantity       = viewModel.Quantities[i];

                    _context.OrderProducts.Add(orderProducts);

                    var ProductStockToUpdate = _context.ProductStocks.Single(p => p.ProductStockID == orderProducts.ProductStockID);
                    ProductStockToUpdate = ProductStockToUpdate.SendProductStock(viewModel.Quantities[i], orderProducts.ProductStockID);


                    _context.Set <ProductStock>().AddOrUpdate(ProductStockToUpdate);
                    _context.SaveChanges();
                }
            }


            MemberCard.UpdateCredits(customer, _context, MemberCard.CalculateCredits(order.TotalCost, customer, _context));
            MemberCard.CheckMembershipType(customer.MemberCard, customer.MemberCard.Credits, _context);


            return(RedirectToAction("Index", "Customers"));
        }
        public void ProfileCreatorIsProfileAdmin()
        {
            //TODO 1. FIX THE PROBLM
            //TODO create smarter tubs somehow with calling a general submenu object

            MemberCard CurrentCreator = listProfilesViewPage
                                        .ClickToViewProfile(ExpectedProfileName)
                                        .navigateToProfileMembersPage()
                                        .readCurrentMembers()
                                        .findCurrentCreator();

            Assert.AreEqual(EnvironmentVariables.QALoginName, CurrentCreator.MemberName.Text, "Creator is not admin");
        }
예제 #25
0
        public bool DeleteMemberCard(string no)
        {
            //验证数据合法性
            if (String.IsNullOrEmpty(no))
            {
                throw new ArgumentNullException("无效的会员卡号");
            }

            MemberCard card = dal.find(no);

            //持久化操作
            return(dal.delete(card.Id) > 0);
        }
예제 #26
0
        public ChargeCredit()
        {
            InitializeComponent();



            var card = new MemberCard(-1);

            card.IsInteractive = false;

            MemberHolder.Children.Clear();
            MemberHolder.Children.Add(card);
            this.PreviewKeyUp += Window_PreviewKeyUp;
        }
        public IHttpActionResult GetValidateMembercard(Guid id)
        {
            MemberCard byId = this.UnitOfWork.MemberCardRepository.GetById(id);

            if (byId == null)
            {
                return((IHttpActionResult)this.NotFound());
            }
            if (byId.Blocked)
            {
                return((IHttpActionResult)this.Ok <MembercardStatusResponse>(new MembercardStatusResponse(MembercardStatusResponse.MembercardStatus.Blocked, byId.Member.Fullname)));
            }
            return(byId.ExpireDate < DateTime.Now ? (IHttpActionResult)this.Ok <MembercardStatusResponse>(new MembercardStatusResponse(MembercardStatusResponse.MembercardStatus.Expired, byId.Member.Fullname)) : (IHttpActionResult)this.Ok <MembercardStatusResponse>(new MembercardStatusResponse(MembercardStatusResponse.MembercardStatus.Valid, byId.Member.Fullname)));
        }
예제 #28
0
        public int update(MemberCard model)
        {
            List <MySqlParameter> parameters = this.fillParameters(model);

            parameters.Add(new MySqlParameter("@id", MySqlDbType.Int32, 11)
            {
                Value = model.Id
            });

            MySqlParameter[] param = this.ConvertMySqlParameters(parameters);
            String           sql   = "UPDATE members_cards SET card_no = @card_no, category_id = @category_id, updated_at = @updated_at WHERE id = @id;";

            return(Tools.MySqlHelper.ExecuteNonQuery(Tools.MySqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sql, param));
        }
예제 #29
0
파일: MemberCardDAL.cs 프로젝트: xcloze/ACC
 public int UpdateMemberValueCardInfo(MemberCard value_card)
 {
     return(ExecuteNonQuery(@"update value_card set state=@state,join_dt=@join_dt,passwd=@passwd,
             remain_value=@remain_value,comment=@comment,is_closing=@is_closing,closing_dt=@closing_dt where member_id=@id ",
                            new MySqlParameter("@id", value_card.MemberID),
                            new MySqlParameter("@card_id", value_card.CardID),
                            new MySqlParameter("@state", value_card.CardState),
                            new MySqlParameter("@join_dt", value_card.JoinDate),
                            new MySqlParameter("@passwd", value_card.Password),
                            new MySqlParameter("@remain_value", value_card.CardRemain),
                            new MySqlParameter("@comment", value_card.Comment),
                            new MySqlParameter("@is_closing", value_card.ClosingState),
                            new MySqlParameter("@closing_dt", value_card.ClosingDate)
                            ));
 }
예제 #30
0
        private MemberCard fillMemberCard(MySqlDataReader rdr)
        {
            MemberCard card = null;

            if (rdr.Read())
            {
                card            = new MemberCard();
                card.CardNo     = rdr["card_no"] == DBNull.Value ? "" : rdr["card_no"].ToString();
                card.Id         = rdr["id"] == DBNull.Value ? 0 : Convert.ToInt32(rdr["id"]);
                card.CategoryId = rdr["category_id"] == DBNull.Value ? 0 : Convert.ToInt32(rdr["category_id"]);
                card.CreatedAt  = rdr["created_at"] == DBNull.Value ? 0 : Convert.ToInt32(rdr["created_at"]);
                card.UpdatedAt  = rdr["updated_at"] == DBNull.Value ? 0 : Convert.ToInt32(rdr["updated_at"]);
            }
            return(card);
        }