protected void btn_Command(object sender, CommandEventArgs e)
        {
            string listpage = "~/ControlRoom/Modules/Patrons/PatronPrizes.aspx";
            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(listpage);
            }

            if (e.CommandName.ToLower() == "add")
            {

                var pp = new DAL.PatronPrizes();
                pp.PID = ((Patron) Session["Curr_Patron"]).PID;
                pp.PrizeSource = 2;
                pp.PrizeName = PrizeName.Text;
                pp.RedeemedFlag = true;
                pp.LastModUser = pp.AddedUser = ((SRPUser) Session[SessionData.UserProfile.ToString()]).Username;
                pp.AddedDate = pp.LastModDate = DateTime.Now;

                pp.Insert();

                Response.Redirect(listpage);
            }


        }
        protected void btn_Command(object sender, CommandEventArgs e)
        {
            string listpage = "~/ControlRoom/Modules/Patrons/PatronPrizes.aspx";

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(listpage);
            }

            if (e.CommandName.ToLower() == "add")
            {
                var pp = new DAL.PatronPrizes();
                pp.PID          = ((Patron)Session["Curr_Patron"]).PID;
                pp.PrizeSource  = 2;
                pp.PrizeName    = PrizeName.Text;
                pp.RedeemedFlag = true;
                pp.LastModUser  = pp.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;
                pp.AddedDate    = pp.LastModDate = DateTime.Now;

                pp.Insert();

                Response.Redirect(listpage);
            }
        }
예제 #3
0
        public static bool AwardBadgeToPatron(int badgeToAward, Patron patron, ref List<Badge> earnedBadges)
        {
            var now = DateTime.Now;

            // check if badge was already earned...
            var pbds = PatronBadges.GetAll(patron.PID);
            var a = pbds.Tables[0].AsEnumerable().Where(r => r.Field<int>("BadgeID") == badgeToAward);

            var newTable = new DataTable();
            try { newTable = a.CopyToDataTable(); } catch { }

            // badge not found, award it!
            if(newTable.Rows.Count == 0) {
                var pb = new PatronBadges { BadgeID = badgeToAward, DateEarned = now, PID = patron.PID };
                pb.Insert();

                var earnedBadge = Badge.GetBadge(badgeToAward);
                if(earnedBadge != null) {
                    earnedBadges.Add(earnedBadge);

                    //if badge generates notification, then generate the notification
                    if(earnedBadge.GenNotificationFlag) {
                        var not = new Notifications {
                            PID_To = patron.PID,
                            PID_From = 0,  //0 == System Notification
                            Subject = earnedBadge.NotificationSubject,
                            Body = earnedBadge.NotificationBody,
                            isQuestion = false,
                            AddedDate = now,
                            LastModDate = now,
                            AddedUser = patron.Username,
                            LastModUser = "******"
                        };
                        not.Insert();
                    }

                    //if badge generates prize, then generate the prize
                    if(earnedBadge.IncludesPhysicalPrizeFlag) {
                        var ppp = new DAL.PatronPrizes {
                            PID = patron.PID,
                            PrizeSource = 1,
                            BadgeID = badgeToAward,
                            PrizeName = earnedBadge.PhysicalPrizeName,
                            RedeemedFlag = false,
                            AddedUser = patron.Username,
                            LastModUser = "******",
                            AddedDate = now,
                            LastModDate = now
                        };

                        ppp.Insert();
                    }

                    // if badge generates award code, then generate the code
                    if(earnedBadge.AssignProgramPrizeCode) {
                        var rewardCode= string.Empty;
                        // get the Code value
                        // save the code value for the patron
                        rewardCode = ProgramCodes.AssignCodeForPatron(patron.ProgID, patron.ProgID);

                        // generate the notification
                        var not = new Notifications {
                            PID_To = patron.PID,
                            PID_From = 0,  //0 == System Notification
                            Subject = earnedBadge.PCNotificationSubject,
                            Body = earnedBadge.PCNotificationBody.Replace("{ProgramRewardCode}", rewardCode),
                            isQuestion = false,
                            AddedDate = now,
                            LastModDate = now,
                            AddedUser = patron.Username,
                            LastModUser = "******"
                        };
                        not.Insert();
                    }
                }

                return true;
            } else {
                return false;
            }
        }
예제 #4
0
        public static bool AwardBadgeToPatron(int badgeToAward, Patron patron, ref List <Badge> earnedBadges)
        {
            var now = DateTime.Now;

            // check if badge was already earned...
            var pbds = PatronBadges.GetAll(patron.PID);
            var a    = pbds.Tables[0].AsEnumerable().Where(r => r.Field <int>("BadgeID") == badgeToAward);

            var newTable = new DataTable();

            try { newTable = a.CopyToDataTable(); } catch { }

            // badge not found, award it!
            if (newTable.Rows.Count == 0)
            {
                var pb = new PatronBadges {
                    BadgeID = badgeToAward, DateEarned = now, PID = patron.PID
                };
                pb.Insert();

                var earnedBadge = Badge.GetBadge(badgeToAward);
                if (earnedBadge != null)
                {
                    earnedBadges.Add(earnedBadge);

                    //if badge generates notification, then generate the notification
                    if (earnedBadge.GenNotificationFlag)
                    {
                        var not = new Notifications {
                            PID_To      = patron.PID,
                            PID_From    = 0, //0 == System Notification
                            Subject     = earnedBadge.NotificationSubject,
                            Body        = earnedBadge.NotificationBody,
                            isQuestion  = false,
                            AddedDate   = now,
                            LastModDate = now,
                            AddedUser   = patron.Username,
                            LastModUser = "******"
                        };
                        not.Insert();
                    }

                    //if badge generates prize, then generate the prize
                    if (earnedBadge.IncludesPhysicalPrizeFlag)
                    {
                        var ppp = new DAL.PatronPrizes {
                            PID          = patron.PID,
                            PrizeSource  = 1,
                            BadgeID      = badgeToAward,
                            PrizeName    = earnedBadge.PhysicalPrizeName,
                            RedeemedFlag = false,
                            AddedUser    = patron.Username,
                            LastModUser  = "******",
                            AddedDate    = now,
                            LastModDate  = now
                        };

                        ppp.Insert();
                    }



                    // if badge generates award code, then generate the code
                    if (earnedBadge.AssignProgramPrizeCode)
                    {
                        var rewardCode = string.Empty;
                        // get the Code value
                        // save the code value for the patron
                        rewardCode = ProgramCodes.AssignCodeForPatron(patron.ProgID, patron.ProgID);

                        // generate the notification
                        var not = new Notifications {
                            PID_To      = patron.PID,
                            PID_From    = 0, //0 == System Notification
                            Subject     = earnedBadge.PCNotificationSubject,
                            Body        = earnedBadge.PCNotificationBody.Replace("{ProgramRewardCode}", rewardCode),
                            isQuestion  = false,
                            AddedDate   = now,
                            LastModDate = now,
                            AddedUser   = patron.Username,
                            LastModUser = "******"
                        };
                        not.Insert();
                    }
                }


                return(true);
            }
            else
            {
                return(false);
            }
        }