public void SaveBadgeExtendedAttributes(Badge obj, GridView gv1, GridView gv2, GridView gv3, GridView gv4)
        {
            var gv = gv1;
            string checkedMembers= string.Empty;
            foreach (GridViewRow row in gv.Rows)
            {
                if (((CheckBox)row.FindControl("isMember")).Checked)
                {
                    checkedMembers = string.Format("{0},{1}", checkedMembers, ((Label)row.FindControl("CID")).Text);
                }
            }
            if (checkedMembers.Length > 0) checkedMembers = checkedMembers.Substring(1, checkedMembers.Length - 1);
            obj.UpdateBadgeCategories(checkedMembers);

            gv = gv2;
            checkedMembers= string.Empty;
            foreach (GridViewRow row in gv.Rows)
            {
                if (((CheckBox)row.FindControl("isMember")).Checked)
                {
                    checkedMembers = string.Format("{0},{1}", checkedMembers, ((Label)row.FindControl("CID")).Text);
                }
            }
            if (checkedMembers.Length > 0) checkedMembers = checkedMembers.Substring(1, checkedMembers.Length - 1);
            obj.UpdateBadgeAgeGroups(checkedMembers);

            gv = gv3;
            checkedMembers= string.Empty;
            foreach (GridViewRow row in gv.Rows)
            {
                if (((CheckBox)row.FindControl("isMember")).Checked)
                {
                    checkedMembers = string.Format("{0},{1}", checkedMembers, ((Label)row.FindControl("CID")).Text);
                }
            }
            if (checkedMembers.Length > 0) checkedMembers = checkedMembers.Substring(1, checkedMembers.Length - 1);
            obj.UpdateBadgeBranches(checkedMembers);

            gv = gv4;
            checkedMembers= string.Empty;
            foreach (GridViewRow row in gv.Rows)
            {
                if (((CheckBox)row.FindControl("isMember")).Checked)
                {
                    checkedMembers = string.Format("{0},{1}", checkedMembers, ((Label)row.FindControl("CID")).Text);
                }
            }
            if (checkedMembers.Length > 0) checkedMembers = checkedMembers.Substring(1, checkedMembers.Length - 1);
            obj.UpdateBadgeLocations(checkedMembers);
        }
        protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Setup/BadgeAddEdit.aspx";
            if (e.CommandName.ToLower() == "addrecord")
            {
                Session["BDD"]= string.Empty;
                Response.Redirect(editpage);
            }
            if (e.CommandName.ToLower() == "editrecord")
            {
                int key = Convert.ToInt32(e.CommandArgument);
                Session["BDD"] = key;
                Response.Redirect(editpage);
            }
            if (e.CommandName.ToLower() == "deleterecord")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                try
                {

                    var obj = new Badge();
                    if (obj.IsValid(BusinessRulesValidationMode.DELETE))
                    {
                        Badge.FetchObject(key).Delete();

                        LoadData();
                        var masterPage = (IControlRoomMaster)Master;
                        if (masterPage != null) masterPage.PageMessage = SRPResources.DeleteOK;
                    }
                    else
                    {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        if (masterPage != null) masterPage.PageError = message;
                    }

                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                        masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
        }
        private Badge LoadBadgeObject()
        {
            var obj = new Badge();
            obj.AdminName = AdminName.Text;
            obj.UserName = UserName.Text;
            obj.CustomEarnedMessage = CustomEarnedMessage.InnerHtml;

            obj.IncludesPhysicalPrizeFlag = IncludesPhysicalPrizeFlag.Checked;
            obj.PhysicalPrizeName = PhysicalPrizeName.Text;

            obj.GenNotificationFlag = GenNotificationFlag.Checked;
            obj.NotificationSubject = NotificationSubject.Text;
            obj.NotificationBody = NotificationBody.InnerHtml;

            obj.AssignProgramPrizeCode = AssignProgramPrizeCode.Checked;
            obj.PCNotificationSubject = PCNotificationSubject.Text;
            obj.PCNotificationBody = PCNotificationBody.InnerHtml;

            obj.AddedDate = DateTime.Now;
            obj.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session
            obj.LastModDate = obj.AddedDate;
            obj.LastModUser = obj.AddedUser;

            return obj;
        }
        // points = 100
        // reason = PointAwardReason.MiniGameCompletion
        // MGID = Mini Game ID, if the reason is MiniGameCompletion, else 0
        //
        //
        // returns: a string based list of the badges they earned, or an empty string
        public string AwardPointsToPatron(int points, PointAwardReason reason,
                // Minigame
                int MGID = 0,
                // reading
                ActivityType readingActivity = ActivityType.Pages, int readingAmount = 0, string author= "", string title= "", string review= "",
                // event
                string eventCode= "", int eventID = 0,
                // book List
                int bookListID = 0,

                DateTime? forceDate = null
            )
        {
            if(forceDate != null)
                now = (DateTime)forceDate;

            string retValue= string.Empty;

            #region Reading - Log to PatronReadingLog
            PatronReadingLog rl = null;
            if(reason == PointAwardReason.Reading) {
                rl = new PatronReadingLog {
                    PID = patron.PID,
                    ReadingType = (int)readingActivity,
                    ReadingTypeLabel = (readingActivity).ToString(),
                    ReadingAmount = readingAmount,
                    ReadingPoints = points,
                    LoggingDate = FormatHelper.ToNormalDate(now),
                    Author = author.Trim(),
                    Title = title.Trim(),
                    HasReview = (review.Trim().Length > 0),
                    ReviewID = 0
                };
                rl.Insert();

                // If there is a review, record the review
                if(review.Trim().Length > 0) {
                    var r = new PatronReview {
                        PID = patron.PID,
                        PRLID = rl.PRLID,
                        Author = rl.Author,
                        Title = rl.Title,
                        Review = review.Trim(),
                        isApproved = false
                    };
                    r.Insert();

                    rl.ReviewID = r.PRID;
                    rl.Update();
                    HttpContext.Current.Session["LastPRID"] = r.PRID;
                }

            }
            #endregion

            #region Award PatronPoints

            var pp = new PatronPoints {
                PID = patron.PID,
                NumPoints = points,
                AwardDate = now,
                AwardReasonCd = (int)reason,
                AwardReason = PatronPoints.PointAwardReasonCdToDescription(reason),
                BadgeAwardedFlag = false,
                isReading = (reason == PointAwardReason.Reading),
                isEvent = (reason == PointAwardReason.EventAttendance),
                isGameLevelActivity = (reason == PointAwardReason.MiniGameCompletion),
                isBookList = (reason == PointAwardReason.BookListCompletion),
                isGame = false,
                GameLevelActivityID = MGID,
                EventCode = eventCode,
                EventID = eventID,
                BookListID = bookListID,
                LogID = (rl == null ? 0 : rl.PRLID)
            };
            pp.Insert();

            var badgeAwarded = false;
            int badgeToAward = 0;               // <===========

            DAL.Minigame mg = null;
            if(reason == PointAwardReason.MiniGameCompletion) {
                mg = DAL.Minigame.FetchObject(MGID);
                badgeAwarded = mg.AwardedBadgeID > 0;
                badgeToAward = mg.AwardedBadgeID;
            }
            if(reason == PointAwardReason.EventAttendance) {
                var evt = Event.GetEvent(eventID);
                badgeAwarded = evt == null ? false : evt.BadgeID > 0;
                badgeToAward = evt == null ? 0 : evt.BadgeID;
            }
            if(reason == PointAwardReason.BookListCompletion) {
                var bl = BookList.FetchObject(bookListID);
                ;
                badgeAwarded = (bl.AwardBadgeID > 0);
                badgeToAward = bl.AwardBadgeID;
            }

            DataSet pbds = null;
            if(badgeAwarded) {
                if(AwardBadgeToPatron(badgeToAward, patron, ref EarnedBadges)) {
                    if(pp.PPID != 0) {
                        pp.BadgeAwardedFlag = true;
                        pp.BadgeID = badgeToAward;
                        pp.Update();
                    }
                }
            }

            #endregion

            #region If jumped level, award another badge(s)

            // since thay just earned points, check if they also advanced a level in the board game (if there is a board game for the program)
            EndingPoints = PatronPoints.GetTotalPatronPoints(patron.PID);
            EarnedBadge = null;

            var earnedBadges2 = new List<Badge>();

            EarnedBadge = TallyPoints(patron, pgm, StartingPoints, EndingPoints, ref earnedBadges2);
            pbds = PatronBadges.GetAll(patron.PID);

            foreach(var badge in earnedBadges2) {
                EarnedBadge = badge;

                if(EarnedBadge != null) {
                    AwardBadgeToPatron(EarnedBadge.BID, patron, ref EarnedBadges);
                }

            }

            #endregion

            #region Check and give awards if any

            AwardBadgeToPatronViaMatchingAwards(patron, ref EarnedBadges);

            #endregion

            #region Prepare return code
            // did they earn one or more badges?
            if(EarnedBadges.Count > 0) {
                retValue = string.Join("|", EarnedBadges.Select(b => b.BID).Distinct());
            }
            #endregion

            return retValue;
        }
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Setup/BadgeList.aspx";
            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "refresh")
            {

                try
                {

                    odsData.DataBind();
                    //Page.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null) masterPage.PageMessage = SRPResources.RefreshOK;

                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }

            if (e.CommandName.ToLower() == "add" || e.CommandName.ToLower() == "addandback")
            {
                try
                {
                    var obj = new Badge();
                    obj.AdminName = ((TextBox)((DetailsView)sender).FindControl("AdminName")).Text;
                    obj.UserName = ((TextBox)((DetailsView)sender).FindControl("UserName")).Text;
                    obj.CustomEarnedMessage = ((HtmlTextArea)((DetailsView)sender).FindControl("CustomEarnedMessage")).InnerHtml;

                    obj.AddedDate = DateTime.Now;
                    obj.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session
                    obj.LastModDate = obj.AddedDate;
                    obj.LastModUser = obj.AddedUser;

                    if (obj.IsValid(BusinessRulesValidationMode.INSERT))
                    {
                        obj.Insert();
                        Cache[CacheKey.BadgesActive] = true;

                        try {
                            var badgePath = string.Format(Server.MapPath("~/images/Badges/"));
                            System.IO.File.Copy(string.Format("{0}no_badge.png", badgePath),
                                                string.Format("{0}{1}.png", badgePath, obj.BID));
                            System.IO.File.Copy(string.Format("{0}no_badge_sm.png", badgePath),
                                                string.Format("{0}sm_{1}.png", badgePath, obj.BID));
                        } catch (Exception ex) {
                            this.Log().Error("Couldn't copy no_badge images into new badge: {0}",
                                             ex.Message);
                        }

                        if(e.CommandName.ToLower() == "addandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        lblPK.Text = obj.BID.ToString();

                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.AddedOK;
                    }
                    else
                    {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }

                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);

                }
            }
            if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback")
            {
                try
                {
                    var obj = new Badge();
                    //int pk = int.Parse(((DetailsView)sender).Rows[0].Cells[1].Text);
                    int pk = int.Parse(lblPK.Text);
                    obj.Fetch(pk);

                    obj.AdminName = ((TextBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel1").FindControl("AdminName")).Text;
                    obj.UserName = ((TextBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel1").FindControl("UserName")).Text;
                    obj.CustomEarnedMessage = ((HtmlTextArea)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel1").FindControl("CustomEarnedMessage")).InnerHtml;
                    obj.IncludesPhysicalPrizeFlag = ((CheckBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel1").FindControl("IncludesPhysicalPrizeFlag")).Checked;
                    obj.PhysicalPrizeName = ((TextBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel1").FindControl("PhysicalPrizeName")).Text;

                    obj.GenNotificationFlag = ((CheckBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2").FindControl("GenNotificationFlag")).Checked;
                    obj.NotificationSubject = ((TextBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2").FindControl("NotificationSubject")).Text;
                    obj.NotificationBody = ((HtmlTextArea)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2").FindControl("NotificationBody")).InnerHtml;

                    obj.AssignProgramPrizeCode = ((CheckBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel3").FindControl("AssignProgramPrizeCode")).Checked;
                    obj.PCNotificationSubject = ((TextBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel3").FindControl("PCNotificationSubject")).Text;
                    obj.PCNotificationBody = ((HtmlTextArea)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel3").FindControl("PCNotificationBody")).InnerHtml;

                    obj.LastModDate = DateTime.Now;
                    obj.LastModUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session

                    if (obj.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        obj.Update();

                        SaveBadgeExtendedAttributes(obj,
                                                    (GridView)
                                                    ((DetailsView) sender).FindControl("TabContainer1").FindControl(
                                                        "TabPanel4").FindControl("gvCat"),
                                                    (GridView)
                                                    ((DetailsView) sender).FindControl("TabContainer1").FindControl(
                                                        "TabPanel4").FindControl("gvAge"),
                                                    (GridView)
                                                    ((DetailsView) sender).FindControl("TabContainer1").FindControl(
                                                        "TabPanel4").FindControl("gvBranch"),
                                                    (GridView)
                                                    ((DetailsView) sender).FindControl("TabContainer1").FindControl(
                                                        "TabPanel4").FindControl("gvLoc"));

                        /*
                        GridView gv = (GridView)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel4").FindControl("gvCat");
                        string checkedMembers= string.Empty;
                        foreach (GridViewRow row in gv.Rows)
                        {
                            if (((CheckBox)row.FindControl("isMember")).Checked)
                            {
                                checkedMembers = string.Format("{0},{1}", checkedMembers, ((Label)row.FindControl("CID")).Text);
                            }
                        }
                        if (checkedMembers.Length > 0) checkedMembers = checkedMembers.Substring(1, checkedMembers.Length - 1);
                        obj.UpdateBadgeBranches(checkedMembers);

                        gv = (GridView)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel4").FindControl("gvAge");
                        checkedMembers= string.Empty;
                        foreach (GridViewRow row in gv.Rows)
                        {
                            if (((CheckBox)row.FindControl("isMember")).Checked)
                            {
                                checkedMembers = string.Format("{0},{1}", checkedMembers, ((Label)row.FindControl("CID")).Text);
                            }
                        }
                        if (checkedMembers.Length > 0) checkedMembers = checkedMembers.Substring(1, checkedMembers.Length - 1);
                        obj.UpdateBadgeAgeGroups(checkedMembers);

                        gv = (GridView)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel4").FindControl("gvBranch");
                        checkedMembers= string.Empty;
                        foreach (GridViewRow row in gv.Rows)
                        {
                            if (((CheckBox)row.FindControl("isMember")).Checked)
                            {
                                checkedMembers = string.Format("{0},{1}", checkedMembers, ((Label)row.FindControl("CID")).Text);
                            }
                        }
                        if (checkedMembers.Length > 0) checkedMembers = checkedMembers.Substring(1, checkedMembers.Length - 1);
                        obj.UpdateBadgeBranches(checkedMembers);

                        gv = (GridView)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel4").FindControl("gvLoc");
                        checkedMembers= string.Empty;
                        foreach (GridViewRow row in gv.Rows)
                        {
                            if (((CheckBox)row.FindControl("isMember")).Checked)
                            {
                                checkedMembers = string.Format("{0},{1}", checkedMembers, ((Label)row.FindControl("CID")).Text);
                            }
                        }
                        if (checkedMembers.Length > 0) checkedMembers = checkedMembers.Substring(1, checkedMembers.Length - 1);
                        obj.UpdateBadgeLocations(checkedMembers);
                        */

                        if (e.CommandName.ToLower() == "saveandback")
                        {
                            Response.Redirect(returnURL);
                        }
                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.SaveOK;
                    }
                    else
                    {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }

                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);

                }

            }
        }
示例#6
0
        public bool Fetch(int BID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@BID", BID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Badge_GetByID", arrParams);

            if (dr.Read())
            {

                // declare return value

                Badge result = new Badge();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["BID"].ToString(), out _int)) this.BID = _int;
                this.AdminName = dr["AdminName"].ToString();
                this.UserName = dr["UserName"].ToString();
                this.GenNotificationFlag = bool.Parse(dr["GenNotificationFlag"].ToString());
                this.NotificationSubject = dr["NotificationSubject"].ToString();
                this.NotificationBody = dr["NotificationBody"].ToString();
                this.CustomEarnedMessage = dr["CustomEarnedMessage"].ToString();
                this.IncludesPhysicalPrizeFlag = bool.Parse(dr["IncludesPhysicalPrizeFlag"].ToString());
                this.PhysicalPrizeName = dr["PhysicalPrizeName"].ToString();
                this.AssignProgramPrizeCode = bool.Parse(dr["AssignProgramPrizeCode"].ToString());
                this.PCNotificationSubject = dr["PCNotificationSubject"].ToString();
                this.PCNotificationBody = dr["PCNotificationBody"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) this.LastModDate = _datetime;
                this.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) this.AddedDate = _datetime;
                this.AddedUser = dr["AddedUser"].ToString();

                if (int.TryParse(dr["TenID"].ToString(), out _int)) this.TenID = _int;
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) this.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) this.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) this.FldInt3 = _int;
                this.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                this.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                this.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                this.FldText1 = dr["FldText1"].ToString();
                this.FldText2 = dr["FldText2"].ToString();
                this.FldText3 = dr["FldText3"].ToString();

                dr.Close();

                return true;

            }

            dr.Close();

            return false;
        }
示例#7
0
        public static int Update(Badge o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[26];

            arrParams[0] = new SqlParameter("@BID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BID, o.BID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@AdminName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode()));
            arrParams[2] = new SqlParameter("@UserName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.UserName, o.UserName.GetTypeCode()));
            arrParams[3] = new SqlParameter("@GenNotificationFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.GenNotificationFlag, o.GenNotificationFlag.GetTypeCode()));
            arrParams[4] = new SqlParameter("@NotificationSubject", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationSubject, o.NotificationSubject.GetTypeCode()));
            arrParams[5] = new SqlParameter("@NotificationBody", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationBody, o.NotificationBody.GetTypeCode()));
            arrParams[6] = new SqlParameter("@CustomEarnedMessage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CustomEarnedMessage, o.CustomEarnedMessage.GetTypeCode()));
            arrParams[7] = new SqlParameter("@IncludesPhysicalPrizeFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IncludesPhysicalPrizeFlag, o.IncludesPhysicalPrizeFlag.GetTypeCode()));
            arrParams[8] = new SqlParameter("@PhysicalPrizeName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PhysicalPrizeName, o.PhysicalPrizeName.GetTypeCode()));
            arrParams[9] = new SqlParameter("@AssignProgramPrizeCode", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AssignProgramPrizeCode, o.AssignProgramPrizeCode.GetTypeCode()));
            arrParams[10] = new SqlParameter("@PCNotificationSubject", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCNotificationSubject, o.PCNotificationSubject.GetTypeCode()));
            arrParams[11] = new SqlParameter("@PCNotificationBody", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCNotificationBody, o.PCNotificationBody.GetTypeCode()));
            arrParams[12] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[13] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[14] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[15] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

            arrParams[16] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[17] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[18] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[19] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[20] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[21] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[22] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[23] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[24] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[25] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Badge_Update", arrParams);

            }

            catch (SqlException exx)
            {

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;
        }
示例#8
0
        public static int Insert(Badge o)
        {
            SqlParameter[] arrParams = new SqlParameter[26];

            arrParams[0] = new SqlParameter("@AdminName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode()));
            arrParams[1] = new SqlParameter("@UserName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.UserName, o.UserName.GetTypeCode()));
            arrParams[2] = new SqlParameter("@GenNotificationFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.GenNotificationFlag, o.GenNotificationFlag.GetTypeCode()));
            arrParams[3] = new SqlParameter("@NotificationSubject", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationSubject, o.NotificationSubject.GetTypeCode()));
            arrParams[4] = new SqlParameter("@NotificationBody", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationBody, o.NotificationBody.GetTypeCode()));
            arrParams[5] = new SqlParameter("@CustomEarnedMessage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CustomEarnedMessage, o.CustomEarnedMessage.GetTypeCode()));
            arrParams[6] = new SqlParameter("@IncludesPhysicalPrizeFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IncludesPhysicalPrizeFlag, o.IncludesPhysicalPrizeFlag.GetTypeCode()));
            arrParams[7] = new SqlParameter("@PhysicalPrizeName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PhysicalPrizeName, o.PhysicalPrizeName.GetTypeCode()));
            arrParams[8] = new SqlParameter("@AssignProgramPrizeCode", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AssignProgramPrizeCode, o.AssignProgramPrizeCode.GetTypeCode()));
            arrParams[9] = new SqlParameter("@PCNotificationSubject", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCNotificationSubject, o.PCNotificationSubject.GetTypeCode()));
            arrParams[10] = new SqlParameter("@PCNotificationBody", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCNotificationBody, o.PCNotificationBody.GetTypeCode()));
            arrParams[11] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[12] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[13] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[14] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

            arrParams[15] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[16] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[17] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[18] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[19] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[20] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[21] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[22] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[23] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[24] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            arrParams[25] = new SqlParameter("@BID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BID, o.BID.GetTypeCode()));
            arrParams[25].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Badge_Insert", arrParams);
            o.BID = int.Parse(arrParams[25].Value.ToString());
            return o.BID;
        }
示例#9
0
        public static int Delete(Badge o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@BID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BID, o.BID.GetTypeCode()));

            try
            {

                var fileName = (HttpContext.Current.Server.MapPath("~/Images/Badges/") + "\\" + o.BID.ToString() + ".png");
                File.Delete(fileName);
                fileName = (HttpContext.Current.Server.MapPath("~/Images/Badges/") + "\\sm_" + o.BID.ToString() + ".png");
                File.Delete(fileName);
                fileName = (HttpContext.Current.Server.MapPath("~/Images/Badges/") + "\\md_" + o.BID.ToString() + ".png");
                File.Delete(fileName);

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Badge_Delete", arrParams);

            }

            catch (SqlException exx)
            {

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;
        }
        public static int Update(Badge o)
        {

            int iReturn = -1; //assume the worst

            var arrParams = new List<SqlParameter>();

            arrParams.Add(new SqlParameter("@BID", GlobalUtilities.DBSafeValue(o.BID, o.BID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AdminName", GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@UserName", GlobalUtilities.DBSafeValue(o.UserName, o.UserName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GenNotificationFlag", GlobalUtilities.DBSafeValue(o.GenNotificationFlag, o.GenNotificationFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@NotificationSubject", GlobalUtilities.DBSafeValue(o.NotificationSubject, o.NotificationSubject.GetTypeCode())));
            arrParams.Add(new SqlParameter("@NotificationBody", GlobalUtilities.DBSafeValue(o.NotificationBody, o.NotificationBody.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HideDefaultDescriptionFlag", GlobalUtilities.DBSafeValue(o.HideDefaultDescriptionFlag, o.HideDefaultDescriptionFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@CustomDescription", GlobalUtilities.DBSafeValue(o.CustomDescription, o.CustomDescription.GetTypeCode())));
            arrParams.Add(new SqlParameter("@CustomEarnedMessage", GlobalUtilities.DBSafeValue(o.CustomEarnedMessage, o.CustomEarnedMessage.GetTypeCode())));
            arrParams.Add(new SqlParameter("@IncludesPhysicalPrizeFlag", GlobalUtilities.DBSafeValue(o.IncludesPhysicalPrizeFlag, o.IncludesPhysicalPrizeFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PhysicalPrizeName", GlobalUtilities.DBSafeValue(o.PhysicalPrizeName, o.PhysicalPrizeName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AssignProgramPrizeCode", GlobalUtilities.DBSafeValue(o.AssignProgramPrizeCode, o.AssignProgramPrizeCode.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PCNotificationSubject", GlobalUtilities.DBSafeValue(o.PCNotificationSubject, o.PCNotificationSubject.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PCNotificationBody", GlobalUtilities.DBSafeValue(o.PCNotificationBody, o.PCNotificationBody.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModDate", GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModUser", GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedDate", GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedUser", GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())));

            arrParams.Add(new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())));

            arrParams.Add(new SqlParameter("@HiddenFromPublic", GlobalUtilities.DBSafeValue(o.HiddenFromPublic, o.HiddenFromPublic.GetTypeCode())));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Badge_Update", arrParams.ToArray());

            }

            catch (SqlException exx)
            {
                "GRA.SRP.DAL.Badge".Log().Error("Error updating Badge: {0} - {1}",
                    exx.Message,
                    exx.StackTrace);

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;

        }
        public static int Insert(Badge o)
        {

            var arrParams = new List<SqlParameter>();

            arrParams.Add(new SqlParameter("@AdminName", GlobalUtilities.DBSafeValue(o.AdminName, o.AdminName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@UserName", GlobalUtilities.DBSafeValue(o.UserName, o.UserName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@GenNotificationFlag", GlobalUtilities.DBSafeValue(o.GenNotificationFlag, o.GenNotificationFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@NotificationSubject", GlobalUtilities.DBSafeValue(o.NotificationSubject, o.NotificationSubject.GetTypeCode())));
            arrParams.Add(new SqlParameter("@NotificationBody", GlobalUtilities.DBSafeValue(o.NotificationBody, o.NotificationBody.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HideDefaultDescriptionFlag", GlobalUtilities.DBSafeValue(o.HideDefaultDescriptionFlag, o.HideDefaultDescriptionFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@CustomDescription", GlobalUtilities.DBSafeValue(o.CustomDescription, o.CustomDescription.GetTypeCode())));
            arrParams.Add(new SqlParameter("@CustomEarnedMessage", GlobalUtilities.DBSafeValue(o.CustomEarnedMessage, o.CustomEarnedMessage.GetTypeCode())));
            arrParams.Add(new SqlParameter("@IncludesPhysicalPrizeFlag", GlobalUtilities.DBSafeValue(o.IncludesPhysicalPrizeFlag, o.IncludesPhysicalPrizeFlag.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PhysicalPrizeName", GlobalUtilities.DBSafeValue(o.PhysicalPrizeName, o.PhysicalPrizeName.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AssignProgramPrizeCode", GlobalUtilities.DBSafeValue(o.AssignProgramPrizeCode, o.AssignProgramPrizeCode.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PCNotificationSubject", GlobalUtilities.DBSafeValue(o.PCNotificationSubject, o.PCNotificationSubject.GetTypeCode())));
            arrParams.Add(new SqlParameter("@PCNotificationBody", GlobalUtilities.DBSafeValue(o.PCNotificationBody, o.PCNotificationBody.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModDate", GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModUser", GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedDate", GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedUser", GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())));

            arrParams.Add(new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())));

            arrParams.Add(new SqlParameter("@HiddenFromPublic", GlobalUtilities.DBSafeValue(o.HiddenFromPublic, o.HiddenFromPublic.GetTypeCode())));

            var param = new SqlParameter("@BID", GlobalUtilities.DBSafeValue(o.BID, o.BID.GetTypeCode()));
            param.Direction = ParameterDirection.Output;
            arrParams.Add(param);

            SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Badge_Insert", arrParams.ToArray());
            o.BID = int.Parse(param.Value.ToString());
            return o.BID;
        }
        public static Badge GetBadge(int BID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@BID", BID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Badge_GetByID", arrParams);

            if (dr.Read())
            {

                // declare return value

                Badge result = new Badge();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["BID"].ToString(), out _int)) result.BID = _int;
                result.AdminName = dr["AdminName"].ToString();
                result.UserName = dr["UserName"].ToString();
                result.GenNotificationFlag = bool.Parse(dr["GenNotificationFlag"].ToString());
                result.NotificationSubject = dr["NotificationSubject"].ToString();
                result.NotificationBody = dr["NotificationBody"].ToString();
                result.CustomEarnedMessage = dr["CustomEarnedMessage"].ToString();
                result.HideDefaultDescriptionFlag = dr["HideDefaultDescriptionFlag"] as bool? ?? false;
                result.CustomDescription = dr["CustomDescription"] as string;
                result.IncludesPhysicalPrizeFlag = bool.Parse(dr["IncludesPhysicalPrizeFlag"].ToString());
                result.PhysicalPrizeName = dr["PhysicalPrizeName"].ToString();
                result.AssignProgramPrizeCode = bool.Parse(dr["AssignProgramPrizeCode"].ToString());
                result.PCNotificationSubject = dr["PCNotificationSubject"].ToString();
                result.PCNotificationBody = dr["PCNotificationBody"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) result.LastModDate = _datetime;
                result.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) result.AddedDate = _datetime;
                result.AddedUser = dr["AddedUser"].ToString();

                if (int.TryParse(dr["TenID"].ToString(), out _int)) result.TenID = _int;
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) result.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) result.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) result.FldInt3 = _int;
                result.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                result.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                result.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                result.FldText1 = dr["FldText1"].ToString();
                result.FldText2 = dr["FldText2"].ToString();
                result.FldText3 = dr["FldText3"].ToString();

                result.HiddenFromPublic = dr["HiddenFromPublic"] as bool? == true;

                dr.Close();

                return result;

            }

            dr.Close();

            return null;

        }
示例#13
0
        public bool Fetch(int BID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@BID", BID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Badge_GetByID", arrParams);

            if (dr.Read())
            {
                // declare return value

                Badge result = new Badge();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["BID"].ToString(), out _int))
                {
                    this.BID = _int;
                }
                this.AdminName                 = dr["AdminName"].ToString();
                this.UserName                  = dr["UserName"].ToString();
                this.GenNotificationFlag       = bool.Parse(dr["GenNotificationFlag"].ToString());
                this.NotificationSubject       = dr["NotificationSubject"].ToString();
                this.NotificationBody          = dr["NotificationBody"].ToString();
                this.CustomEarnedMessage       = dr["CustomEarnedMessage"].ToString();
                this.IncludesPhysicalPrizeFlag = bool.Parse(dr["IncludesPhysicalPrizeFlag"].ToString());
                this.PhysicalPrizeName         = dr["PhysicalPrizeName"].ToString();
                this.AssignProgramPrizeCode    = bool.Parse(dr["AssignProgramPrizeCode"].ToString());
                this.PCNotificationSubject     = dr["PCNotificationSubject"].ToString();
                this.PCNotificationBody        = dr["PCNotificationBody"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime))
                {
                    this.LastModDate = _datetime;
                }
                this.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime))
                {
                    this.AddedDate = _datetime;
                }
                this.AddedUser = dr["AddedUser"].ToString();

                if (int.TryParse(dr["TenID"].ToString(), out _int))
                {
                    this.TenID = _int;
                }
                if (int.TryParse(dr["FldInt1"].ToString(), out _int))
                {
                    this.FldInt1 = _int;
                }
                if (int.TryParse(dr["FldInt2"].ToString(), out _int))
                {
                    this.FldInt2 = _int;
                }
                if (int.TryParse(dr["FldInt3"].ToString(), out _int))
                {
                    this.FldInt3 = _int;
                }
                this.FldBit1  = bool.Parse(dr["FldBit1"].ToString());
                this.FldBit2  = bool.Parse(dr["FldBit2"].ToString());
                this.FldBit3  = bool.Parse(dr["FldBit3"].ToString());
                this.FldText1 = dr["FldText1"].ToString();
                this.FldText2 = dr["FldText2"].ToString();
                this.FldText3 = dr["FldText3"].ToString();

                dr.Close();

                return(true);
            }

            dr.Close();

            return(false);
        }