コード例 #1
0
        protected void ddlCharacterSelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            int iSkillSetID = 0;

            if (ddlCharacterSelector.SelectedIndex >= 0)
            {
                int.TryParse(ddlCharacterSelector.SelectedValue, out iSkillSetID);
                if (iSkillSetID == -1)
                {
                    // Person choose to add a new character.
                    Response.Redirect("~/Character/CharAdd.aspx", true);
                }

                _CharacterInfo = new cCharacter();
                _CharacterInfo.LoadCharacterBySkillSetID(iSkillSetID);

                _SkillSetID  = iSkillSetID;
                _CharacterID = _CharacterInfo.CharacterID;
                _CampaignID  = _CharacterInfo.CampaignID;

                Session["CharacterSelectGroup"] = "Characters";
                Session["CharSkillSetID"]       = iSkillSetID;
                Session["CharCharacterID"]      = _CharacterInfo.CharacterID;
                Session["CharCampaignID"]       = _CharacterInfo.CampaignID;
                if (this.CharacterChanged != null)
                {
                    CharacterChanged(this, e);
                }
            }
            else
            {
                _CharacterID = null;
            }
        }
コード例 #2
0
        protected void ddlCampaigns_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlCampaigns.SelectedIndex >= 0)
            {
                Session["CharacterSelectCampaign"] = ddlCampaigns.SelectedValue;
                Session["CharacterSelectGroup"]    = "Campaigns";

                int iCampaignID = 0;
                if (int.TryParse(ddlCampaigns.SelectedValue, out iCampaignID))
                {
                    LoadCampaignCharacters();

                    int iCharID;
                    if (int.TryParse(ddlCampCharSelector.SelectedValue, out iCharID))
                    {
                        if (iCharID < 0)
                        {
                            Response.Redirect("~/Character/CharAdd.aspx", true);
                        }

                        WhichSelected  = Selected.CampaignCharacters;
                        _CharacterID   = iCharID;
                        _CharacterInfo = new cCharacter();
                        _CharacterInfo.LoadCharacter(iCharID);
                        Session["CharacterCampaignCharID"] = iCharID;
                        Session["CampaignID"] = _CharacterInfo.CampaignID;
                        if (this.CharacterChanged != null)
                        {
                            this.CharacterChanged(this, e);
                        }
                    }
                }
            }
        }
コード例 #3
0
        protected void btnCampaignSave_Click(object sender, EventArgs e)
        {
            int iCharacterID;

            int.TryParse(Session["PlaceCharacterID"].ToString(), out iCharacterID);

            int iCharacterPlaceID;

            if (int.TryParse(hidCharacterPlaceID.Value, out iCharacterPlaceID))
            {
                Classes.cCharacter cChar = new Classes.cCharacter();
                cChar.LoadCharacter(iCharacterID);

                var CharPlac = cChar.Places.Find(x => x.CharacterPlaceID == iCharacterPlaceID);
                if (CharPlac != null)
                {
                    CharPlac.PlaceName  = lblCampaignPlaceName.Text;
                    CharPlac.Comments   = tbCampaignPlayerComments.Text;
                    CharPlac.LocaleName = lblCampaignLocale.Text;
                    CharPlac.Save(_UserID);
                }
                else
                {
                    int iCampaignPlaceID;
                    Classes.cCharacterPlace cNewPlace = new Classes.cCharacterPlace();

                    if (int.TryParse(hidCampaignPlaceID.Value, out iCampaignPlaceID))
                    {
                        cNewPlace.CampaignPlaceID = iCampaignPlaceID;
                    }
                    else
                    {
                        cNewPlace.CampaignPlaceID = null;
                    }
                    cNewPlace.CharacterID = iCharacterID;

                    cNewPlace.PlaceName = lblCampaignPlaceName.Text;
                    cNewPlace.Comments  = tbCampaignPlayerComments.Text;
                    int iLocaleID;

                    if (int.TryParse(hidCampaignLocaleID.Value, out iLocaleID))
                    {
                        cNewPlace.LocaleID = iLocaleID;
                    }

                    cNewPlace.Save(_UserID);
                }

                BindPlaces();
                mvAddingItems.SetActiveView(vwNewItemButton);
            }
            else
            {
                mvAddingItems.SetActiveView(vwNewItemButton);
            }
        }
コード例 #4
0
        public void BindPlaces()
        {
            int iCharacterID;

            if (int.TryParse(Session["PlaceCharacterID"].ToString(), out iCharacterID))
            {
                Classes.cCharacter cChar = new Classes.cCharacter();
                cChar.LoadCharacter(iCharacterID);
                gvPlaces.DataSource = cChar.Places;
                gvPlaces.DataBind();
            }
        }
コード例 #5
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                MethodBase lmth          = MethodBase.GetCurrentMethod();
                string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

                if (Session["SelectedCharacter"] != null)
                {
                    int iCharID;
                    if (int.TryParse(Session["SelectedCharacter"].ToString(), out iCharID))
                    {
                        Classes.cCharacter cChar = new Classes.cCharacter();
                        cChar.LoadCharacter(iCharID);

                        _dtCharPlaces = Classes.cUtilities.CreateDataTable(cChar.Places);

                        SortedList sParam = new SortedList();
                        sParam.Add("@CampaignID", cChar.CampaignID);
                        _dtPlaces = Classes.cUtilities.LoadDataTable("uspGetCampaignPlaces", sParam, "LARPortal", "", lsRoutineName);

                        Session["Places"] = _dtCharPlaces;

                        DataView dvTopNodes = new DataView(_dtPlaces, "LocaleID = 0", "", DataViewRowState.CurrentRows);
                        foreach (DataRowView dvRow in dvTopNodes)
                        {
                            TreeNode NewNode = new TreeNode();
                            NewNode.Text = dvRow["PlaceName"].ToString();

                            int iNodeID;
                            if (int.TryParse(dvRow["CampaignPlaceID"].ToString(), out iNodeID))
                            {
                                NewNode.Value = iNodeID.ToString();
                                if (_dtCharPlaces != null)
                                {
                                    if (_dtCharPlaces.Select("CampaignPlaceID = " + iNodeID.ToString()).Length > 0)
                                    {
                                        NewNode.Checked = true;
                                    }
                                    NewNode.SelectAction = TreeNodeSelectAction.None;
                                    NewNode.NavigateUrl  = "javascript:void(0);";
                                    PopulateTreeView(iNodeID, NewNode);
                                }
                                NewNode.Expanded = false;
//                                tvPlaces.Nodes.Add(NewNode);
                            }
                            tvPlaces.Nodes.Add(NewNode);
                        }
                    }
                }
            }
        }
コード例 #6
0
        //protected void CharacterHistoryEmailNotificaiton()
        //{
        //    if (hidPlayerEMail.Value.Length > 0)
        //    {
        //        string strSubject = "Character History Approved for Character " + lblCharacter.Text;
        //        string strBody = "Your character history for " + lblCharacter.Text + " has been approved.<br>";
        //        strBody += "You have been awarded " + tbCPAwarded.Text + " CP.<br><br>";
        //        strBody = strBody + "History Text:<br>" + lblHistory.Text;
        //        strBody = strBody.Replace(System.Environment.NewLine, "<br />");

        //        Classes.cEmailMessageService SubmitCharacterHistory = new Classes.cEmailMessageService();
        //        try
        //        {
        //            SubmitCharacterHistory.SendMail(strSubject, strBody, hidPlayerEMail.Value, "", "");
        //        }
        //        catch (Exception)
        //        {

        //        }
        //    }
        //}
        protected void btnApprove_Command(object sender, CommandEventArgs e)
        {
            int iCharID;

            if (int.TryParse(Request["CharID"], out iCharID))
            {
                Classes.cCharacter cChar = new Classes.cCharacter();
                cChar.LoadCharacter(iCharID);

                if (e.CommandName == "APPROVE")
                {
                    cChar.DateHistoryApproved = DateTime.Now;
                    cChar.SaveCharacter(Session["UserName"].ToString(), (int)Session["UserID"]);
                    lblCharApprovedMessage.Text = "The character history for " + cChar.AKA + " has been approved.";

                    Classes.cPoints Points      = new Classes.cPoints();
                    int             UserID      = 0;
                    int             CharacterID = 0;
                    int             CampaignCPOpportunityDefaultID = 0;
                    double          CPAwarded = 0.0;

                    int.TryParse(Session["UserID"].ToString(), out UserID);
                    int.TryParse(hidCampaignCPOpportunityDefaultID.Value, out CampaignCPOpportunityDefaultID);
                    double.TryParse(tbCPAwarded.Text, out CPAwarded);

                    Points.AssignHistoryPoints(UserID, cChar.PlayerID, CharacterID, CampaignCPOpportunityDefaultID, cChar.CampaignID, CPAwarded, DateTime.Now);

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);

                    if (hidPlayerEMail.Value.Length > 0)
                    {
                        string strSubject = "Character History Approved for Character " + lblCharacter.Text;
                        string strBody    = "Your character history for " + lblCharacter.Text + " has been approved.<br>";
                        strBody += "You have been awarded " + tbCPAwarded.Text + " CP.<br><br>";
                        strBody  = strBody + "History Text:<br>" + lblHistory.Text;
                        strBody  = strBody.Replace(System.Environment.NewLine, "<br />");

                        Classes.cEmailMessageService SubmitCharacterHistory = new Classes.cEmailMessageService();
                        try
                        {
                            SubmitCharacterHistory.SendMail(strSubject, strBody, hidPlayerEMail.Value, "", "", "CharacterHistory", Session["Username"].ToString());
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
        }
コード例 #7
0
        public void LoadAndSetCharacter()
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            WhichSelected = Selected.NotSpecified;

            if ((Session ["CampaignsToEdit"] == null) ||
                (Session ["MyCharacters"] == null))
            {
                if (_UserInfo == null)
                {
                    _UserInfo = new cUser(_UserName, "PasswordNotNeeded", Session.SessionID);
                }

//				oLogWriter.AddLogMessage("Done loading user.", lsRoutineName, "", Session.SessionID);
                _CharacterInfo = new cCharacter();
                _CharacterInfo.LoadCharacterBySkillSetID(UserInfo.LastLoggedInSkillSetID);

                _SkillSetID  = UserInfo.LastLoggedInSkillSetID;
                _CharacterID = _CharacterInfo.CharacterID;
                _CampaignID  = _CharacterInfo.CampaignID;

                Session["CharSelectSetID"] = UserInfo.LastLoggedInCharacter;
                if (UserInfo.LastLoggedInMyCharOrCamp == "C")
                {
                    WhichSelected = Selected.CampaignCharacters;
                    Session["CharCampaignSkillSetID"] = _UserInfo.LastLoggedInSkillSetID;
                    Session["CharCampaignCharID"]     = _CharacterInfo.CharacterID;
                    Session["CharCampaignCampaignID"] = _CharacterInfo.CampaignID;
                    Session ["CharacterSelectGroup"]  = "Campaigns";
                }
                else
                {
                    WhichSelected              = Selected.MyCharacters;
                    Session["CharSkillSetID"]  = UserInfo.LastLoggedInSkillSetID;
                    Session["CharCharacterID"] = _CharacterInfo.CharacterID;
                    Session["CharCampaignID"]  = _CharacterInfo.CampaignID;
                }
            }
        }
コード例 #8
0
        protected void ddlCampCharSelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["CharacterSelectGroup"] = "Campaigns";
            int iSkillSetID;

            if (int.TryParse(ddlCampCharSelector.SelectedValue, out iSkillSetID))
            {
                if (iSkillSetID < 0)
                {
                    Response.Redirect("~/Character/CharAdd.aspx", true);
                }

                WhichSelected  = Selected.CampaignCharacters;
                _CharacterInfo = new cCharacter();
                _CharacterInfo.LoadCharacterBySkillSetID(iSkillSetID);
                _SkillSetID  = iSkillSetID;
                _CharacterID = _CharacterInfo.CharacterID;
                _CampaignID  = _CharacterInfo.CampaignID;

                Session["CharCampaignSkillSetID"] = iSkillSetID;
                Session["CharCampaignCharID"]     = _CharacterInfo.CharacterID;
                Session["CharCampaignCampaignID"] = _CharacterInfo.CampaignID;

                Classes.cUser UserInfo = new Classes.cUser(_UserName, "PasswordNotNeeded", Session.SessionID);
                UserInfo.LastLoggedInCampaign     = _CampaignID.Value;
                UserInfo.LastLoggedInCharacter    = _CharacterID.Value;
                UserInfo.LastLoggedInSkillSetID   = _SkillSetID.Value;
                UserInfo.LastLoggedInMyCharOrCamp = "C";
                UserInfo.Save();

//				_CharacterInfo.LoadCharacterBySkillSetID(_SkillSetID.Value);
                if (this.CharacterChanged != null)
                {
                    CharacterChanged(this, e);
                }
            }
            else
            {
                _CharacterID = null;
            }
        }
コード例 #9
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //                LogWriter oLog = new LogWriter();
                //                oLog.AddLogMessage("Starting postback", "CharSkillsFull.Page_PreRender", "", Session.SessionID);

                if (Session["CurrentCharacter"] == null)
                {
                    Session["CurrentCharacter"] = -1;
                }
                if (Session["SelectedCharacter"] == null)
                {
                    Session["SelectedCharacter"] = 7;
                }

                if (Session["SelectedCharacter"] != null)
                {
                    double TotalCP   = 0.0;
                    string sCurrent  = Session["CurrentCharacter"].ToString();
                    string sSelected = Session["SelectedCharacter"].ToString();
                    if ((!IsPostBack) || (Session["CurrentCharacter"].ToString() != Session["SelectedCharacter"].ToString()))
                    {
                        int iCharID;
                        if (int.TryParse(Session["SelectedCharacter"].ToString(), out iCharID))
                        {
                            Classes.cCharacter cChar = new Classes.cCharacter();
                            //                            oLog.AddLogMessage("About to load character", "CharSkillsFull.Page_PreRender", "", Session.SessionID);
                            cChar.LoadCharacter(iCharID);
                            //                            oLog.AddLogMessage("Done loading character", "CharSkillsFull.Page_PreRender", "", Session.SessionID);

                            TotalCP            = cChar.TotalCP;
                            Session["TotalCP"] = TotalCP;

                            dtCharSkills          = Classes.cUtilities.CreateDataTable(cChar.CharacterSkills);
                            Session["CharSkills"] = dtCharSkills;

                            Session["CharacterSkillPools"] = cChar.SkillPools;

                            // Creating a small array of character skills so if the campaign characters are closed you can't sell back a skill.
                            if (ViewState["SkillList"] != null)
                            {
                                ViewState.Remove("SkillList");
                            }

                            if (cChar.CharacterSkills.Count > 0)
                            {
                                List <int> SkillList = new List <int>();
                                foreach (Classes.cCharacterSkill dSkill in cChar.CharacterSkills)
                                {
                                    SkillList.Add(dSkill.CampaignSkillNodeID);
                                }
                                ViewState["SkillList"] = SkillList;
                            }

                            Session["CurrentCharacter"] = Session["SelectedCharacter"];

                            DataSet    dsSkillSets = new DataSet();
                            SortedList sParam      = new SortedList();

                            Classes.cCampaignBase cCampaign = new Classes.cCampaignBase(cChar.CampaignID, Session["LoginName"].ToString(), Convert.ToInt32(Session["UserID"].ToString()));
                            if (cCampaign.AllowCharacterRebuild)
                            {
                                hidAllowCharacterRebuild.Value = "1";
                                lblSkillsLocked.Visible        = false;
                            }
                            else
                            {
                                hidAllowCharacterRebuild.Value = "0";
                                lblSkillsLocked.Visible        = true;
                            }

                            sParam.Add("@CampaignID", cChar.CampaignID);
                            sParam.Add("@CharacterID", Session["CurrentCharacter"].ToString());
                            //                            oLog.AddLogMessage("About to load Campaign Skills", "CharSkillsFull.Page_PreRender", "", Session.SessionID);
                            dsSkillSets = Classes.cUtilities.LoadDataSet("uspGetCampaignSkillsWithNodes", sParam, "LARPortal", Session["LoginName"].ToString(), "");
                            //                            oLog.AddLogMessage("Done loading Campaign Skills", "CharSkillsFull.Page_PreRender", "", Session.SessionID);


                            _dtCampaignSkills            = dsSkillSets.Tables[0];
                            Session["SkillNodes"]        = _dtCampaignSkills;
                            Session["NodePrerequisites"] = dsSkillSets.Tables[1];
                            Session["SkillTypes"]        = dsSkillSets.Tables[2];
                            Session["NodeExclusions"]    = dsSkillSets.Tables[3];
                            //                            Session["CharacterSkillNodes"] = dsSkillSets.Tables[4];

                            DataView dvTopNodes = new DataView(_dtCampaignSkills, "ParentSkillNodeID is null", "DisplayOrder", DataViewRowState.CurrentRows);
                            foreach (DataRowView dvRow in dvTopNodes)
                            {
                                TreeNode NewNode = new TreeNode();
                                NewNode.ShowCheckBox = true;
                                NewNode.Text         = FormatDescString(dvRow);
                                NewNode.SelectAction = TreeNodeSelectAction.None;

                                int iNodeID;
                                if (int.TryParse(dvRow["CampaignSkillNodeID"].ToString(), out iNodeID))
                                {
                                    NewNode.Value = iNodeID.ToString();
                                    if (dvRow["CharacterHasSkill"].ToString() == "1")
                                    {
                                        NewNode.Checked = true;
                                        //                                        NewNode.Expand();
                                    }
                                    NewNode.SelectAction = TreeNodeSelectAction.None;
                                    PopulateTreeView(iNodeID, NewNode);
                                    tvSkills.Nodes.Add(NewNode);
                                }
                            }

                            //                            oLog.AddLogMessage("Done loading the tree", "CharSkillsFull.Page_PreRender", "", Session.SessionID);

                            CheckExclusions();

                            //                            oLog.AddLogMessage("Done checking exclusions", "CharSkillsFull.Page_PreRender", "", Session.SessionID);


                            Session["CurrentSkillTree"] = tvSkills;
                            ListSkills();


                            //                            oLog.AddLogMessage("Done listing skills", "CharSkillsFull.Page_PreRender", "", Session.SessionID);
                        }
                    }
                }
                //                oLog.AddLogMessage("Done with postback session", "CharSkillsfull.Page_PreRender", "", Session.SessionID);
            }
            if (AlertMessage.Length > 0)
            {
                lblPopMessage.Text = AlertMessage;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
            }
        }
コード例 #10
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int iCharID;

            if (Session["SelectedCharacter"] != null)
            {
                if (int.TryParse(Session["SelectedCharacter"].ToString(), out iCharID))
                {
                    DataTable dtCampaignSkills = Session["SkillNodes"] as DataTable;

                    Classes.cCharacter Char = new Classes.cCharacter();
                    Char.LoadCharacter(iCharID);

                    int CharacterSkillsSetID = -1;

                    CharacterSkillsSetID = Char.CharacterSkillSetID;

                    foreach (Classes.cCharacterSkill cSkill in Char.CharacterSkills)
                    {
                        cSkill.RecordStatus  = Classes.RecordStatuses.Delete;
                        CharacterSkillsSetID = cSkill.CharacterSkillSetID;
                    }

                    foreach (TreeNode SkillNode in tvSkills.CheckedNodes)
                    {
                        int iSkillNodeID;
                        if (int.TryParse(SkillNode.Value, out iSkillNodeID))
                        {
                            var FoundRecord = Char.CharacterSkills.Find(x => x.CampaignSkillNodeID == iSkillNodeID);
                            if (FoundRecord != null)
                            {
                                FoundRecord.RecordStatus = Classes.RecordStatuses.Active;
                            }
                            else
                            {
                                Classes.cCharacterSkill Newskill = new Classes.cCharacterSkill();
                                Newskill.CharacterSkillID    = -1;
                                Newskill.CharacterID         = iCharID;
                                Newskill.CampaignSkillNodeID = iSkillNodeID;
                                Newskill.CharacterSkillSetID = CharacterSkillsSetID;
                                Newskill.CPCostPaid          = 0;
                                DataView dvCampaignSkill = new DataView(dtCampaignSkills, "CampaignSkillNodeID = " + iSkillNodeID.ToString(), "", DataViewRowState.CurrentRows);
                                if (dvCampaignSkill.Count > 0)
                                {
                                    double dSkillCPCost = 0;
                                    if (double.TryParse(dvCampaignSkill[0]["SkillCPCost"].ToString(), out dSkillCPCost))
                                    {
                                        Newskill.CPCostPaid = dSkillCPCost;
                                    }
                                }
                                Char.CharacterSkills.Add(Newskill);
                            }
                        }
                    }

                    string Msg = Char.SaveCharacter(Session["UserName"].ToString(), (int)Session["UserID"]);

                    lblPopMessage.Text = "Character " + Char.AKA + " has been saved.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
                }
            }
        }
コード例 #11
0
        protected void LoadMyCharacters()
        {
            SortedList slParameters = new SortedList();

            slParameters.Add("@intUserID", Session["UserID"].ToString());

            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            DataTable dtCharacters = LarpPortal.Classes.cUtilities.LoadDataTable("uspGetCharacterIDsByUserID", slParameters,
                                                                                 "LARPortal", "Character", lsRoutineName);

            DataView dvCharacters = new DataView(dtCharacters, "", "DisplayName", DataViewRowState.CurrentRows);

            ddlCharacterSelector.DataSource     = dvCharacters;
            ddlCharacterSelector.DataTextField  = "DisplayName";
            ddlCharacterSelector.DataValueField = "CharacterSkillSetID";
            ddlCharacterSelector.DataBind();
            ddlCharacterSelector.Visible = true;
            ddlCampCharSelector.Visible  = false;
            lblSelectedCampaign.Visible  = false;
            rbMyCharacters.Checked       = true;

            ddlCharacterSelector.ClearSelection();

            int iSkillSetID;

            if (Session["CharSkillSetID"] != null)
            {
                if (int.TryParse(Session["CharSkillSetID"].ToString(), out iSkillSetID))
                {
                    foreach (ListItem liItem in ddlCharacterSelector.Items)
                    {
                        ddlCharacterSelector.ClearSelection();
                        if (liItem.Value == iSkillSetID.ToString())
                        {
                            liItem.Selected = true;
                        }
                    }
                }
            }

            if (ddlCharacterSelector.SelectedIndex < 0)
            {
                ddlCharacterSelector.Items[0].Selected = true;
            }

            if (int.TryParse(ddlCharacterSelector.SelectedValue, out iSkillSetID))
            {
                if (iSkillSetID == 0)
                {
                    _CharacterID   = null;
                    _CharacterInfo = null;
                    Session.Remove("CharSkillSetID");
                }
                else
                {
                    _SkillSetID    = iSkillSetID;
                    _CharacterInfo = new cCharacter();
                    _CharacterInfo.LoadCharacterBySkillSetID(iSkillSetID);
                    lblSelectedCampaign.Visible = true;
                    lblSelectedCampaign.Text    = _CharacterInfo.CampaignName;
                    ddlCampaigns.Visible        = false;

                    _SkillSetID  = iSkillSetID;
                    _CharacterID = _CharacterInfo.CharacterID;
                    _CampaignID  = _CharacterInfo.CampaignID;

                    Session["CharSkillSetID"]  = iSkillSetID;
                    Session["CharCharacterID"] = _CharacterInfo.CharacterID;
                    Session["CharCampaignID"]  = _CharacterInfo.CampaignID;
                }
            }
        }
コード例 #12
0
        protected void LoadCampaignCharacters()
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            DataTable dtCampaignsToEdit = Session["CampaignsToEdit"] as DataTable;

            ddlCharacterSelector.Visible = false;
            rbCampaignCharacters.Checked = true;
            int iCampaignID = 0;

            if (Session["CharCampaignCampaignID"] != null)
            {
                int.TryParse(Session["CharCampaignCampaignID"].ToString(), out iCampaignID);
            }

            if (dtCampaignsToEdit.Rows.Count == 1)
            {
                ddlCampaigns.Visible              = false;
                lblSelectedCampaign.Visible       = true;
                lblSelectedCampaign.Text          = dtCampaignsToEdit.Rows[0]["CampaignName"].ToString();
                Session["CharCampaignCampaignID"] = dtCampaignsToEdit.Rows[0]["CampaignID"].ToString();
                //--Session.Remove("CharCampaignSkillSetID");
                //--Session.Remove("CharCampaignCharID");

                //int.TryParse(dtCampaignsToEdit.Rows[0]["CampaignID"].ToString(), out iCampaignID);
                //            Session["CharacterID"] = iCampaignID;

                //_CharacterInfo = new cCharacter();
                //_CharacterInfo.LoadCharacterBySkillSetID(iSkillSetID);
                //_SkillSetID = iSkillSetID;
                //_CharacterID = _CharacterInfo.CharacterID;
                //_CampaignID = _CharacterInfo.CamaignID;

                //Session["CampSkillSetID"] = iSkillSetID;
                //Session["CampCharacterID"] = _CharacterInfo.CharacterID;
                //Session["CampCampaignID"] = _CharacterInfo.CampaignID;
            }
            else
            {
                ddlCampaigns.Visible        = true;
                lblSelectedCampaign.Visible = false;

                ddlCampaigns.ClearSelection();

                if (iCampaignID != 0)
                {
                    foreach (ListItem liCamp in ddlCampaigns.Items)
                    {
                        if (liCamp.Value == iCampaignID.ToString())
                        {
                            liCamp.Selected = true;
                        }
                    }
                    //}
                    //if (iCampaignID != 0)       // Campaign is selected.
                    //{
                    //            Session["CharacterSelectCampaign"] = iCampaignID.ToString();
                    //int iCampaignID;
                    //int.TryParse(Session["CharacterSelectCampaign"].ToString(), out iCampaignID);
                }
            }
            SortedList slParameters = new SortedList();

            slParameters.Add("@CampaignID", iCampaignID);
            DataTable dtChars = Classes.cUtilities.LoadDataTable("uspGetCampaignCharactersAll", slParameters, "LARPortal", Session["UserID"].ToString(), lsRoutineName);
            DataView  dvChars = new DataView(dtChars, "", "CharacterType, DisplayName", DataViewRowState.CurrentRows);

            ddlCampCharSelector.DataSource     = dvChars;
            ddlCampCharSelector.DataTextField  = "DisplayName";
            ddlCampCharSelector.DataValueField = "CharacterSkillSetID";
            ddlCampCharSelector.DataBind();
            ddlCampCharSelector.Visible  = true;
            ddlCharacterSelector.Visible = false;

            //if (dvChars.Count == 0)
            //    ddlCampCharSelector.Items.Add(new ListItem("", "0"));

            //ddlCampCharSelector.Items.Add(new ListItem("Add A New Character", "-1"));

            ddlCampCharSelector.ClearSelection();

            if (Session["CharCampaignSkillSetID"] != null)
            {
                int iSkillSetID;
                if (int.TryParse(Session["CharCampaignSkillSetID"].ToString(), out iSkillSetID))
                {
                    foreach (ListItem liItem in ddlCampCharSelector.Items)
                    {
                        if (liItem.Value == iSkillSetID.ToString())
                        {
                            liItem.Selected = true;
                        }
                    }
                }
            }
            if (ddlCampCharSelector.SelectedIndex < 0)
            {
                if (ddlCampCharSelector.Items.Count > 0)
                {
                    ddlCampCharSelector.Items[0].Selected = true;
                }
            }

            if (ddlCampCharSelector.SelectedValue == "0")       // There were no values.
            {
                _CharacterID   = null;
                _CharacterInfo = null;
                Session.Remove("CharCampaignCharID");
                Session.Remove("CharCampaignSkillSetID");
            }
            else
            {
                int iSkillSetID;
                if (int.TryParse(ddlCampCharSelector.SelectedValue, out iSkillSetID))
                {
                    //                    _CharacterID = iTempCharID;
                    _CharacterInfo.LoadCharacterBySkillSetID(iSkillSetID);
                    Session["CharCampaignSkillSetID"] = iSkillSetID;
                    Session["CharCampaignCharID"]     = _CharacterInfo.CharacterID;
                    Session["CharCampaignCampaignID"] = _CharacterInfo.CampaignID;
                }
            }
            //  }
            //}
        }
コード例 #13
0
ファイル: CharInfo.aspx.cs プロジェクト: larportal/portaltest
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int iTemp;

            oCharSelect.LoadInfo();

            if ((oCharSelect.CharacterID != null) && (oCharSelect.CharacterInfo != null))
            {
                if ((tbAKA.Text.Length == 0) &&
                    (tbFirstName.Text.Length == 0))
                {
                    // JBradshaw  7/11/2016    Request #1286     Must have at least first name or last name.
                    lblmodalError.Text = "You must fill in at least the first name or the character AKA.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openError();", true);
                    return;
                }

                Classes.cCharacter cChar = new Classes.cCharacter();
                cChar.LoadCharacter(oCharSelect.CharacterID.Value);

                cChar.FirstName  = tbFirstName.Text;
                cChar.MiddleName = tbMiddleName.Text;
                cChar.LastName   = tbLastName.Text;

                cChar.CurrentHome = tbOrigin.Text;

                cChar.AllowCharacterRebuildToDate = null;

                if (oCharSelect.WhichSelected == controls.CharacterSelect.Selected.CampaignCharacters)
                {
                    cChar.CharacterStatusID = Convert.ToInt32(ddlStatus.SelectedValue);
                    cChar.CharacterType     = Convert.ToInt32(ddlCharType.SelectedValue);

                    if (ddlAllowRebuild.SelectedValue == "Y")
                    {
                        tbRebuildToDate.Style["display"] = "inline";
                        lblExpiresOn.Style["display"]    = "inline";
                        DateTime dtTemp;
                        if (DateTime.TryParse(tbRebuildToDate.Text, out dtTemp))
                        {
                            cChar.AllowCharacterRebuildToDate = dtTemp;
                        }
                    }
                    else
                    {
                        tbRebuildToDate.Style["display"] = "none";
                        lblExpiresOn.Style["display"]    = "none";
                    }
                }

                if (ddlVisible.SelectedValue == "1")
                {
                    cChar.VisibleToPCs = true;
                }
                else
                {
                    cChar.VisibleToPCs = false;
                }

                cChar.AKA         = tbAKA.Text;
                cChar.CurrentHome = tbHome.Text;
                cChar.WhereFrom   = tbOrigin.Text;

                // If the drop down list is visible, it means they belong to multiple teams so we need to check it.
                if (ddlTeamList.Visible)
                {
                    if (int.TryParse(ddlTeamList.SelectedValue, out iTemp))
                    {
                        cChar.TeamID = iTemp;
                    }
                }

                cChar.DateOfBirth = tbDOB.Text;
                if (ViewState["UserIDPicture"] != null)
                {
                    cChar.ProfilePicture = ViewState["UserIDPicture"] as Classes.cPicture;
                    if (ViewState["PictureDeleted"] != null)
                    {
                        cChar.ProfilePicture.RecordStatus = Classes.RecordStatuses.Delete;
                    }
                }
                else
                {
                    cChar.ProfilePicture = null;
                }

                if (ddlRace.SelectedIndex > -1)
                {
                    cChar.Race = new Classes.cRace();
                    int.TryParse(ddlRace.SelectedValue, out iTemp);
                    cChar.Race.CampaignRaceID = iTemp;
                }

                if (ddlAllowRebuild.SelectedValue == "Y")
                {
                    DateTime dtTemp;
                    if (DateTime.TryParse(tbRebuildToDate.Text, out dtTemp))
                    {
                        cChar.AllowCharacterRebuildToDate = dtTemp;
                    }
                }
                else
                {
                    cChar.AllowCharacterRebuildToDate = new DateTime(1900, 1, 1);
                }

                if (cChar.CharacterType != 1)       // Means it's not a PC so we need to check who is the current actor.
                {
                    var LastActor = cChar.Actors.OrderByDescending(x => x.StartDate).ToList();
                    if (LastActor == null)
                    {
                        cChar.CurrentUserID = _UserID;
                    }
                    else
                    {
                        if (LastActor.Count > 0)
                        {
                            cChar.CurrentUserID = LastActor[0].UserID;
                        }
                    }
                }

                cChar.StaffComments = tbStaffComments.Text;

                cChar.SaveCharacter(_UserName, _UserID);
                // JBradshaw  7/11/2016    Request #1286     Changed over to bootstrap popup.
                lblmodalMessage.Text = "Character " + cChar.AKA + " has been saved.";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openMessage();", true);
            }
        }
コード例 #14
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SortedList slParameters = new SortedList();

                if (Request["CharID"] == null)
                {
                    Response.Redirect("CharHistoryApprovalList.aspx", true);
                }

                int iCharID;
                if (!int.TryParse(Request["CharID"], out iCharID))
                {
                    Response.Redirect("CharHistoryApprovalList.aspx", true);
                }

                Classes.cCharacter cChar = new Classes.cCharacter();
                cChar.LoadCharacter(iCharID);

                if (cChar.AKA.Length > 0)
                {
                    hidCharacterName.Value = cChar.AKA;
                }
                else
                {
                    hidCharacterName.Value = cChar.FirstName + " " + cChar.LastName;
                }

                lblCharacter.Text = hidCharacterName.Value;

                hidPlayerName.Value = cChar.PlayerName;
                if (cChar.CharacterEmail.Length > 0)
                {
                    hidPlayerEMail.Value = cChar.CharacterEmail;
                }
                else if (cChar.PlayerEMail.Length > 0)
                {
                    hidPlayerEMail.Value = cChar.PlayerEMail;
                }
                else
                {
                    hidPlayerEMail.Value = "";
                }

                SortedList sParams = new SortedList();
                sParams.Add("@ReasonID", 24);
                sParams.Add("@CampaignID", cChar.CampaignID);
                string    sSQL = "select * from CMCampaignCPOpportunityDefaults where ReasonID = @ReasonID and CampaignID = @CampaignID and DateDeleted is null";
                DataTable dtCampaignDefaults = Classes.cUtilities.LoadDataTable(sSQL, sParams, "LARPortal", Session["UserName"].ToString(),
                                                                                "CharHistoryApproval.Page_Load.LoadDefaults", Classes.cUtilities.LoadDataTableCommandType.Text);

                foreach (DataRow dRow in dtCampaignDefaults.Rows)
                {
                    double dCPValue = 0.0;
                    if (double.TryParse(dRow["CPValue"].ToString(), out dCPValue))
                    {
                        tbCPAwarded.Text = string.Format("{0:0.00}", dCPValue);
                    }
                    hidCampaignCPOpportunityDefaultID.Value = dRow["CampaignCPOpportunityDefaultID"].ToString();
                }
                lblHistory.Text = cChar.CharacterHistory.Replace(Environment.NewLine, "<br>");

                // The have already approved it so change the functionality of the approve button.
                if (cChar.DateHistoryApproved != null)
                {
                    btnApprove.Text            = "Done";
                    btnApprove.CommandArgument = "DONE";
                }
            }
        }
コード例 #15
0
        public void LoadInfo()
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            WhichSelected = Selected.NotSpecified;

            if (UserInfo != null)
            {
                if (UserInfo.LastLoggedInSkillSetID == 0)
                {
                    UserInfo.LastLoggedInCampaign     = 0;
                    UserInfo.LastLoggedInCharacter    = 0;
                    UserInfo.LastLoggedInMyCharOrCamp = "";
                }
            }

//            oLogWriter.AddLogMessage("About to check for session variables.", lsRoutineName, "", Session.SessionID);

            if (Session["CurrentChar"] != null)
            {
                _CharacterInfo = Session["CurrentChar"] as cCharacter;
            }

            if ((Session["CampaignsToEdit"] == null) ||
                (Session["MyCharacters"] == null))
            {
                if (_UserInfo == null)
                {
                    _UserInfo = new cUser(_UserName, "PasswordNotNeeded", Session.SessionID);
                }

                if (UserInfo.LastLoggedInMyCharOrCamp == "C")
                {
                    WhichSelected = Selected.CampaignCharacters;
                    if (UserInfo.LastLoggedInSkillSetID != 0)
                    {
                        Session["CharCampaignCampaignID"] = UserInfo.LastLoggedInCampaign;
                        Session["CharCampaignCharID"]     = UserInfo.LastLoggedInCharacter;
                        Session["CharCampaignSkillSetID"] = UserInfo.LastLoggedInSkillSetID;
                    }
                    else
                    {
                        Session.Remove("CharCampaignCampaignID");
                        Session.Remove("CharCampaignCharID");
                        Session.Remove("CharCampaignSkillSetID");
                    }
                    Session["CharacterSelectGroup"] = "Campaigns";
                }
                else
                {
                    WhichSelected = Selected.MyCharacters;
                    if (UserInfo.LastLoggedInSkillSetID != 0)
                    {
                        Session["CharSkillSetID"]  = UserInfo.LastLoggedInSkillSetID;
                        Session["CharCharacterID"] = UserInfo.LastLoggedInCharacter;
                        Session["CharCampaignID"]  = UserInfo.LastLoggedInCampaign;
                    }
                    else
                    {
                        Session.Remove("CharSkillSetID");
                        Session.Remove("CharCharacterID");
                        Session.Remove("CharCampaignID");
                    }
                    Session["CharacterSelectGroup"] = "Characters";
                }
//                oLogWriter.AddLogMessage("Done loading user.", lsRoutineName, "", Session.SessionID);
            }

            if (Session["CharacterSelectGroup"] != null)
            {
                if (Session["CharacterSelectGroup"].ToString() == "Campaigns")
                {
                    WhichSelected = Selected.CampaignCharacters;
                }
                else if (Session["CharacterSelectGroup"].ToString() == "Characters")
                {
                    WhichSelected = Selected.MyCharacters;
                }
            }

            int iCampaignID = 0;

            // This is a fake out. If it's not defined we define it as a non valid value so it will fall through to the bottom.
            if (Session["CharacterSelectGroup"] == null)
            {
                Session["CharacterSelectGroup"] = "PlaceHolder";
            }

            int iCampSkillSetID = 0;
            int iCharSkillSetID = 0;

            _CharacterID = null;

            if ((WhichSelected == Selected.MyCharacters) &&
                (Session["CharSkillSetID"] != null))
            {
                if (int.TryParse(Session["CharSkillSetID"].ToString(), out iCharSkillSetID))
                {
                    if (iCharSkillSetID != 0)
                    {
                        _SkillSetID = iCharSkillSetID;
                        //                    _CharacterID = iCharID;
                        _CharacterInfo.LoadCharacterBySkillSetID(iCharSkillSetID);
                        _CharacterID = _CharacterInfo.CharacterID;
                        _CampaignID  = _CharacterInfo.CampaignID;
                        Session["CharSkillSetID"]  = iCharSkillSetID;
                        Session["CharCharacterID"] = _CharacterInfo.CharacterID;
                        Session["CharCampaignID"]  = _CharacterInfo.CampaignID;
                        return;
                    }
                }
            }

            if ((WhichSelected == Selected.CampaignCharacters) &&
                (Session["CharCampaignSkillSetID"] != null))
            {
                if (int.TryParse(Session["CharCampaignSkillSetID"].ToString(), out iCampSkillSetID))
                {
                    if (iCampSkillSetID != 0)
                    {
                        _CharacterInfo.LoadCharacterBySkillSetID(iCampSkillSetID);
                        _CharacterID = _CharacterInfo.CharacterID;
                        _CampaignID  = _CharacterInfo.CampaignID;
                        _SkillSetID  = iCampSkillSetID;
                        Session["CharCampaignSkillSetID"]  = iCampSkillSetID;
                        Session["CharCampaignCharacterID"] = _CharacterInfo.CharacterID;
                        Session["CharCampaignCampaignID"]  = _CharacterInfo.CampaignID;
                        return;
                    }
                }
            }

//            oLogWriter.AddLogMessage("About to run uspGetPrivCampaignCharacterEdit", lsRoutineName, "", Session.SessionID);

            SortedList slParameters = new SortedList();

            slParameters.Add("@UserID", _UserID);
            DataTable dtCampaignsToEdit = LarpPortal.Classes.cUtilities.LoadDataTable("uspGetPrivCampaignCharacterEdit", slParameters,
                                                                                      "LARPortal", _UserName, lsRoutineName + ".uspGetPrivCampaignCharacterEdit");

//            oLogWriter.AddLogMessage("Done running uspGetPrivCampaignCharacterEdit", lsRoutineName, "", Session.SessionID);

            if (dtCampaignsToEdit.Rows.Count > 0)
            {
                DataView dvCampaignsToEdit = new DataView(dtCampaignsToEdit, "", "CampaignName", DataViewRowState.CurrentRows);
                if (int.TryParse(dvCampaignsToEdit[0]["CampaignID"].ToString(), out iCampaignID))
                {
//                    oLogWriter.AddLogMessage("About to run uspGetCampaignCharactersAll", lsRoutineName, "", Session.SessionID);

                    slParameters = new SortedList();
                    slParameters.Add("@CampaignID", iCampaignID);
                    DataTable dtCampChars = Classes.cUtilities.LoadDataTable("uspGetCampaignCharactersAll", slParameters, "LARPortal", _UserName, lsRoutineName + ".uspGetCampaignCharactersAll");

//                    oLogWriter.AddLogMessage("Done running uspGetCampaignCharactersAll", lsRoutineName, "", Session.SessionID);

                    DataView dvCampChars = new DataView(dtCampChars, "", "DisplayName", DataViewRowState.CurrentRows);
                    if (dtCampChars.Rows.Count > 0)
                    {
                        int.TryParse(dvCampChars[0]["CharacterSkillSetID"].ToString(), out iCampSkillSetID);
                    }
                }
            }

            // Now get  all characters for user.
            slParameters = new SortedList();
            slParameters.Add("@intUserID", _UserID);

//            oLogWriter.AddLogMessage("About to run uspGetCharacterIDsByUserID", lsRoutineName, "", Session.SessionID);

            DataTable dtCharacters = LarpPortal.Classes.cUtilities.LoadDataTable("uspGetCharacterIDsByUserID", slParameters, "LARPortal", _UserName, lsRoutineName + ".uspGetCharacterIDsByUserID");

//            oLogWriter.AddLogMessage("Done running uspGetCharacterIDsByUserID", lsRoutineName, "", Session.SessionID);

            if (dtCharacters.Rows.Count > 0)
            {
                DataView dvCharacters = new DataView(dtCharacters, "", "DisplayName", DataViewRowState.CurrentRows);
                int.TryParse(dvCharacters[0]["CharacterSkillSetID"].ToString(), out iCharSkillSetID);
            }

            if ((iCharSkillSetID != 0) &&
                ((WhichSelected == Selected.MyCharacters) || (WhichSelected == Selected.NotSpecified)))
            {
//                oLogWriter.AddLogMessage("About to load character in MyCharacters", lsRoutineName, "", Session.SessionID);
                _CharacterInfo.LoadCharacterBySkillSetID(iCharSkillSetID);
//                oLogWriter.AddLogMessage("Done loading character in MyCharacters", lsRoutineName, "", Session.SessionID);
                _CharacterID  = _CharacterInfo.CharacterID;
                _CampaignID   = _CharacterInfo.CampaignID;
                _SkillSetID   = iCharSkillSetID;
                WhichSelected = Selected.MyCharacters;
                Session["CharacterSelectGroup"] = "Characters";
                Session["CharCharacterID"]      = _CharacterInfo.CharacterID;
                Session["CharSkillSetID"]       = iCharSkillSetID;
                Session["CharCampaignID"]       = _CharacterInfo.CampaignID;
                ddlCampCharSelector.Visible     = false;
                ddlCharacterSelector.Visible    = true;
                return;
            }

            if (((iCampSkillSetID != 0) && (iCampaignID != 0)) &&
                ((WhichSelected == Selected.CampaignCharacters) || (WhichSelected == Selected.NotSpecified)))
            {
//                oLogWriter.AddLogMessage("About to load character in CampaignCharacters", lsRoutineName, "", Session.SessionID);
                _CharacterInfo.LoadCharacterBySkillSetID(iCampSkillSetID);
//                oLogWriter.AddLogMessage("Done loading character in CampaignCharacters", lsRoutineName, "", Session.SessionID);
                WhichSelected = Selected.CampaignCharacters;
                Session["CharacterSelectGroup"]    = "Campaigns";
                Session["CharCampaignSkillSetID"]  = iCampSkillSetID;
                Session["CharCampaignCharacterID"] = _CharacterInfo.CharacterID;
                Session["CharCampaignCampaignID"]  = _CharacterInfo.CampaignID;
                _SkillSetID  = iCampSkillSetID;
                _CharacterID = _CharacterInfo.CharacterID;
                _CampaignID  = _CharacterInfo.CampaignID;

                ddlCampCharSelector.Visible  = true;
                ddlCharacterSelector.Visible = false;
                return;
            }

            // If we got this far - there are nocharacters to select.
            ddlCharacterSelector.Visible = false;
            ddlCampCharSelector.Visible  = false;
        }
コード例 #16
0
ファイル: CharCard.aspx.cs プロジェクト: larportal/portaltest
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["CharacterID"] != null)
            {
                Classes.cCharacter cChar = new Classes.cCharacter();
                int iCharID = 0;
                if (int.TryParse(Request.QueryString["CharacterID"], out iCharID))
                {
                    cChar.LoadCharacter(iCharID);
                    lblCharName.Text = cChar.AKA + " - " + cChar.CampaignName;
                    lblAKA.Text      = cChar.AKA;
                    lblFullName.Text = cChar.FirstName;
                    if (cChar.MiddleName.Trim().Length > 0)
                    {
                        lblFullName.Text += " " + cChar.MiddleName;
                    }
                    if (cChar.LastName.Trim().Length > 0)
                    {
                        lblFullName.Text += " " + cChar.LastName;
                    }
                    lblFullName.Text.Trim();

                    lblRace.Text       = cChar.Race.FullRaceName;
                    lblOrigin.Text     = cChar.WhereFrom;
                    lblPlayerName.Text = "";

                    DataTable  dtCharacterSkills = new DataTable();
                    SortedList sParams           = new SortedList();
                    sParams.Add("@CharacterID", cChar.CharacterID);

                    MethodBase lmth          = MethodBase.GetCurrentMethod();
                    string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

                    dtCharacterSkills = Classes.cUtilities.LoadDataTable("uspGetCharCardSkills", sParams, "LARPortal", Session["UserName"].ToString(), lsRoutineName);

                    if (dtCharacterSkills.Columns["FullDescription"] == null)
                    {
                        dtCharacterSkills.Columns.Add(new DataColumn("FullDescription", typeof(string)));
                    }

                    Classes.cSkillPool skDefault = cChar.SkillPools.Find(x => x.DefaultPool == true);
                    object             oCPSpent;
                    double             dCPSpent;
                    oCPSpent = dtCharacterSkills.Compute("sum(cpcostpaid)", "CampaignSkillPoolID = " + skDefault.PoolID.ToString());
                    double.TryParse(oCPSpent.ToString(), out dCPSpent);

                    TableRow  dTotalRow = new TableRow();
                    TableCell dcCell    = new TableCell();
                    dcCell.CssClass = "TableLabel";
                    dcCell.Text     = "Total CP:";
                    dTotalRow.Cells.Add(dcCell);

                    dcCell      = new TableCell();
                    dcCell.Text = cChar.TotalCP.ToString("0.00");
                    dTotalRow.Cells.Add(dcCell);

                    dcCell          = new TableCell();
                    dcCell.CssClass = "TableLabel";
                    dcCell.Text     = "Total Spent:";
                    dTotalRow.Cells.Add(dcCell);

                    dcCell      = new TableCell();
                    dcCell.Text = dCPSpent.ToString("0.00");
                    dTotalRow.Cells.Add(dcCell);

                    dcCell          = new TableCell();
                    dcCell.CssClass = "TableLabel";
                    dcCell.Text     = "Total Avail:";
                    dTotalRow.Cells.Add(dcCell);

                    dcCell      = new TableCell();
                    dcCell.Text = (cChar.TotalCP - dCPSpent).ToString("0.00");
                    dTotalRow.Cells.Add(dcCell);
                    tblCharInfo.Rows.Add(dTotalRow);


                    List <Classes.cSkillPool> skNotDefault = cChar.SkillPools.FindAll(x => x.DefaultPool == false).OrderBy(x => x.PoolDescription).ToList();

                    foreach (Classes.cSkillPool PoolNotDefault in skNotDefault)
                    {
                        oCPSpent = dtCharacterSkills.Compute("sum(cpcostpaid)", "CampaignSkillPoolID = " + PoolNotDefault.PoolID.ToString());
                        double.TryParse(oCPSpent.ToString(), out dCPSpent);
                        double TotalPoints = cChar.SkillPools.Find(x => x.PoolID == PoolNotDefault.PoolID).TotalPoints;

                        dTotalRow           = new TableRow();
                        dTotalRow.ForeColor = System.Drawing.Color.FromName(PoolNotDefault.PoolDisplayColor);

                        dcCell          = new TableCell();
                        dcCell.CssClass = "TableLabel";
                        dcCell.Text     = PoolNotDefault.PoolDescription + " Points:";
                        dTotalRow.Cells.Add(dcCell);

                        dcCell      = new TableCell();
                        dcCell.Text = TotalPoints.ToString("0.00");
                        dTotalRow.Cells.Add(dcCell);

                        dcCell          = new TableCell();
                        dcCell.CssClass = "TableLabel";
                        dcCell.Text     = "Total Spent:";
                        dTotalRow.Cells.Add(dcCell);

                        dcCell      = new TableCell();
                        dcCell.Text = dCPSpent.ToString("0.00");
                        dTotalRow.Cells.Add(dcCell);

                        dcCell          = new TableCell();
                        dcCell.CssClass = "TableLabel";
                        dcCell.Text     = "Total Avail:";
                        dTotalRow.Cells.Add(dcCell);

                        dcCell      = new TableCell();
                        dcCell.Text = (TotalPoints - dCPSpent).ToString("0.00");
                        dTotalRow.Cells.Add(dcCell);
                        tblCharInfo.Rows.Add(dTotalRow);
                    }

                    double CPCost;
                    double CPSpent = 0.0;

                    foreach (DataRow dSkillRow in dtCharacterSkills.Rows)
                    {
                        if (double.TryParse(dSkillRow["CPCostPaid"].ToString(), out CPCost))
                        {
                            CPSpent += CPCost;
                        }

                        string FullDesc = "";
                        bool   bDisplay;
                        if (bool.TryParse(dSkillRow["CardDisplayDescription"].ToString(), out bDisplay))
                        {
                            if (bDisplay)
                            {
                                if (dSkillRow["SkillCardDescription"].ToString().Trim().Length > 0)
                                {
                                    FullDesc += dSkillRow["SkillCardDescription"].ToString().Trim() + "; ";
                                }
                            }
                        }

                        if (dSkillRow["PlayerDescription"].ToString().Trim().Length > 0)
                        {
                            FullDesc += dSkillRow["PlayerDescription"].ToString().Trim() + "; ";
                        }

                        if (bool.TryParse(dSkillRow["CardDisplayIncant"].ToString(), out bDisplay))
                        {
                            if (bDisplay)
                            {
                                if (dSkillRow["SkillIncant"].ToString().Trim().Length > 0)
                                {
                                    FullDesc += "<i>" + dSkillRow["SkillIncant"].ToString().Trim() + "</i>; ";
                                }
                            }
                        }

                        if (dSkillRow["PlayerIncant"].ToString().Trim().Length > 0)
                        {
                            FullDesc += "<b><i>" + dSkillRow["PlayerIncant"].ToString().Trim() + "</b></i>";
                        }

                        FullDesc = FullDesc.Trim();
                        if (FullDesc.EndsWith(";"))
                        {
                            FullDesc = FullDesc.Substring(0, FullDesc.Length - 1);
                        }

                        dSkillRow["FullDescription"] = FullDesc;
                    }

                    Dictionary <string, string> NonCost = new Dictionary <string, string>();

                    foreach (Classes.cDescriptor Desc in cChar.Descriptors)
                    {
                        if (NonCost.ContainsKey(Desc.CharacterDescriptor))
                        {
                            NonCost[Desc.CharacterDescriptor] += Desc.DescriptorValue + ", ";
                        }
                        else
                        {
                            NonCost.Add(Desc.CharacterDescriptor, Desc.DescriptorValue + ", ");
                        }
                    }

                    foreach (string KeyValue in NonCost.Keys.ToList())
                    {
                        if (NonCost[KeyValue].EndsWith(", "))
                        {
                            NonCost[KeyValue] = NonCost[KeyValue].Substring(0, NonCost[KeyValue].Length - 2);
                        }
                    }

                    gvSkills.DataSource = dtCharacterSkills;
                    gvSkills.DataBind();

                    gvNonCost.DataSource = NonCost;
                    gvNonCost.DataBind();

                    Classes.cUser User = new Classes.cUser(Session["Username"].ToString(), "PasswordNotNeeded");
                    lblPlayerName.Text = User.FirstName + " " + User.MiddleName + " " + User.LastName;
                }
            }
        }
コード例 #17
0
        protected void rptrCharacter_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            HiddenField hidID = (HiddenField)e.Item.FindControl("hidCharID");

            if (hidID != null)
            {
                int iCharID;
                if (int.TryParse(hidID.Value, out iCharID))
                {
                    Classes.cCharacter cChar = new Classes.cCharacter();
                    cChar.LoadCharacter(iCharID);

                    Label lblTotalCP = (Label)e.Item.FindControl("lblTotalCP");
                    if (lblTotalCP != null)
                    {
                        lblTotalCP.Text = cChar.TotalCP.ToString("0.00");
                    }

                    DataTable  dtCharacterSkills = new DataTable();
                    SortedList sParams           = new SortedList();
                    sParams.Add("@CharacterID", cChar.CharacterID);

                    MethodBase lmth          = MethodBase.GetCurrentMethod();
                    string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

                    dtCharacterSkills = Classes.cUtilities.LoadDataTable("uspGetCharCardSkills", sParams, "LARPortal", Session["UserName"].ToString(), lsRoutineName);

                    if (dtCharacterSkills.Columns["FullDescription"] == null)
                    {
                        dtCharacterSkills.Columns.Add(new DataColumn("FullDescription", typeof(string)));
                    }

                    double CPCost;
                    double CPSpent = 0.0;

                    foreach (DataRow dSkillRow in dtCharacterSkills.Rows)
                    {
                        if (double.TryParse(dSkillRow["CPCostPaid"].ToString(), out CPCost))
                        {
                            CPSpent += CPCost;
                        }

                        string FullDesc = "";
                        bool   bDisplay;
                        if (bool.TryParse(dSkillRow["CardDisplayDescription"].ToString(), out bDisplay))
                        {
                            if (bDisplay)
                            {
                                if (dSkillRow["SkillCardDescription"].ToString().Trim().Length > 0)
                                {
                                    FullDesc += dSkillRow["SkillCardDescription"].ToString().Trim() + "; ";
                                }
                            }
                        }

                        if (dSkillRow["PlayerDescription"].ToString().Trim().Length > 0)
                        {
                            FullDesc += dSkillRow["PlayerDescription"].ToString().Trim() + "; ";
                        }

                        if (bool.TryParse(dSkillRow["CardDisplayIncant"].ToString(), out bDisplay))
                        {
                            if (bDisplay)
                            {
                                if (dSkillRow["SkillIncant"].ToString().Trim().Length > 0)
                                {
                                    FullDesc += "<i>" + dSkillRow["SkillIncant"].ToString().Trim() + "</i>; ";
                                }
                            }
                        }

                        if (dSkillRow["PlayerIncant"].ToString().Trim().Length > 0)
                        {
                            FullDesc += "<b><i>" + dSkillRow["PlayerIncant"].ToString().Trim() + "</b></i>";
                        }

                        FullDesc = FullDesc.Trim();
                        if (FullDesc.EndsWith(";"))
                        {
                            FullDesc = FullDesc.Substring(0, FullDesc.Length - 1);
                        }

                        dSkillRow["FullDescription"] = FullDesc;
                    }

                    Label lblCPSpent = (Label)e.Item.FindControl("lblCPSpent");
                    if (lblCPSpent != null)
                    {
                        lblCPSpent.Text = CPSpent.ToString("0.00");
                    }

                    Label lblCPAvail = (Label)e.Item.FindControl("lblCPAvail");
                    if (lblCPAvail != null)
                    {
                        lblCPAvail.Text = (cChar.TotalCP - CPSpent).ToString("0.00");
                    }

                    Dictionary <string, string> NonCost = new Dictionary <string, string>();

                    foreach (Classes.cDescriptor Desc in cChar.Descriptors)
                    {
                        if (NonCost.ContainsKey(Desc.CharacterDescriptor))
                        {
                            NonCost[Desc.CharacterDescriptor] += Desc.DescriptorValue + ", ";
                        }
                        else
                        {
                            NonCost.Add(Desc.CharacterDescriptor, Desc.DescriptorValue + ", ");
                        }
                    }

                    foreach (string KeyValue in NonCost.Keys.ToList())
                    {
                        if (NonCost[KeyValue].EndsWith(", "))
                        {
                            NonCost[KeyValue] = NonCost[KeyValue].Substring(0, NonCost[KeyValue].Length - 2);
                        }
                    }

                    DataView dvSkills = new DataView(dtCharacterSkills, "", "DisplayOrder", DataViewRowState.CurrentRows);
                    GridView gvSkills = (GridView)e.Item.FindControl("gvSkills");
                    if (gvSkills != null)
                    {
                        gvSkills.DataSource = dvSkills;
                        gvSkills.DataBind();
                    }

                    GridView gvNonCost = (GridView)e.Item.FindControl("gvNonCost");
                    if (gvNonCost != null)
                    {
                        gvNonCost.DataSource = NonCost;
                        gvNonCost.DataBind();
                    }

                    //Classes.cUser User = new Classes.cUser(Session["Username"].ToString(), "PasswordNotNeeded");

                    //Label lblPlayerName = (Label)e.Item.FindControl("lblPlayerName");
                    //if (lblPlayerName != null)
                    //    lblPlayerName.Text = User.FirstName + " " + User.MiddleName + " " + User.LastName;
                }
            }
        }
コード例 #18
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            if (Session["CharPlaceReadOnly"] != null)
            {
                tdCampaignPlaces.Visible = false;
            }
            else
            {
                tdCampaignPlaces.Visible = true;
            }

            if ((!IsPostBack) || (_Reload))
            {
                if (Session["CurrentCharacter"] == null)
                {
                    Session["CurrentCharacter"] = -1;
                }

                if (Session["PlaceCharacterID"] != null)
                {
                    string sCurrent  = Session["CurrentCharacter"].ToString();
                    string sSelected = Session["PlaceCharacterID"].ToString();
                    if ((!IsPostBack) || (sCurrent != sSelected) || (_Reload))
                    {
                        int iCharID;
                        if (int.TryParse(Session["PlaceCharacterID"].ToString(), out iCharID))
                        {
                            tvCampaignPlaces.Nodes.Clear();

                            Classes.cCharacter cChar = new Classes.cCharacter();
                            cChar.LoadCharacter(iCharID);

                            Session["CurrentCharacter"] = iCharID;
                            Session["CharacterPlaces"]  = cChar.Places;

                            DataSet    dsCampaignPlaces = new DataSet();
                            SortedList sParam           = new SortedList();
                            sParam.Add("@CampaignID", cChar.CampaignID);
                            dsCampaignPlaces = Classes.cUtilities.LoadDataSet("uspGetCampaignPlaces", sParam, "LARPortal", Session["LoginName"].ToString(), lsRoutineName + ".uspGetCampaignPlaces");

                            _dtCampaignPlaces         = dsCampaignPlaces.Tables[0];
                            Session["CampaignPlaces"] = _dtCampaignPlaces;

                            ddlNonCampLocalePlaces.DataTextField  = "PlaceName";
                            ddlNonCampLocalePlaces.DataValueField = "CampaignPlaceID";
                            ddlNonCampLocalePlaces.DataSource     = dsCampaignPlaces.Tables[0];
                            ddlNonCampLocalePlaces.DataBind();

                            gvPlaces.DataSource = cChar.Places;
                            gvPlaces.DataBind();

                            TreeNode MainNode   = new TreeNode("Skills");
                            DataView dvTopNodes = new DataView(_dtCampaignPlaces, "LocaleID = 0", "", DataViewRowState.CurrentRows);
                            foreach (DataRowView dvRow in dvTopNodes)
                            {
                                TreeNode NewNode = new TreeNode();
                                NewNode.Text = dvRow["PlaceName"].ToString();

                                int iNodeID;
                                if (int.TryParse(dvRow["CampaignPlaceID"].ToString(), out iNodeID))
                                {
                                    NewNode.Value = iNodeID.ToString();
                                    PopulateTreeView(iNodeID, NewNode);
                                    NewNode.Expanded = false;
                                    tvCampaignPlaces.Nodes.Add(NewNode);
                                }
                            }
                        }
                    }
                }
            }

            if (Session["CharPlaceReadOnly"] != null)
            {
                btnAddNonCampPlace.Visible = false;
                gvPlaces.Columns[gvPlaces.Columns.Count - 1].Visible = false;
                gvPlaces.Columns[gvPlaces.Columns.Count - 2].Visible = false;
            }
            else
            {
                btnAddNonCampPlace.Visible = true;
                gvPlaces.Columns[gvPlaces.Columns.Count - 1].Visible = true;
                gvPlaces.Columns[gvPlaces.Columns.Count - 2].Visible = true;
            }
        }
コード例 #19
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            if (!IsPostBack)
            {
                double dCPEarned        = 0.0;
                string sCampaignGoingTo = "";

                if (Request.QueryString["RegistrationID"] != null)
                {
                    hidRegistrationID.Value = Request.QueryString["RegistrationID"];
                }
                else
                {
                    Response.Redirect("PELApprovalList.aspx", true);
                }

                Classes.cUser UserInfo = new Classes.cUser(Master.UserName, "NOPASSWORD", Session.SessionID);
                if (UserInfo.NickName.Length > 0)
                {
                    hidAuthorName.Value = UserInfo.NickName + " " + UserInfo.LastName;
                }
                else
                {
                    hidAuthorName.Value = UserInfo.FirstName + " " + UserInfo.LastName;
                }

                SortedList sParams = new SortedList();
                sParams.Add("@RegistrationID", hidRegistrationID.Value);

                int iCharacterID = 0;
                int iUserID      = 0;

                DataSet dsQuestions = Classes.cUtilities.LoadDataSet("uspGetPELQuestionsAndAnswers", sParams, "LARPortal", Master.UserName, lsRoutineName);

                string sEventInfo = "";
                if (dsQuestions.Tables[0].Rows.Count > 0)
                {
                    sEventInfo = "<b>Event: </b> " + dsQuestions.Tables[0].Rows[0]["EventDescription"].ToString();

                    hidEventDesc.Value = dsQuestions.Tables[0].Rows[0]["EventDescription"].ToString();
                    hidEventID.Value   = dsQuestions.Tables[0].Rows[0]["EventID"].ToString();

                    DateTime dtEventDate;
                    if (DateTime.TryParse(dsQuestions.Tables[0].Rows[0]["EventStartDate"].ToString(), out dtEventDate))
                    {
                        sEventInfo        += "&nbsp;&nbsp;<b>Event Date: </b> " + dtEventDate.ToShortDateString();
                        hidEventDate.Value = dtEventDate.ToShortDateString();
                    }

                    int.TryParse(dsQuestions.Tables[0].Rows[0]["CharacterID"].ToString(), out iCharacterID);
                    int.TryParse(dsQuestions.Tables[0].Rows[0]["UserID"].ToString(), out iUserID);

                    sEventInfo += "<br><b>Player: </b> ";
                    if (String.IsNullOrEmpty(dsQuestions.Tables[0].Rows[0]["NickName"].ToString()))
                    {
                        sEventInfo         += dsQuestions.Tables[0].Rows[0]["NickName"].ToString() + " " + dsQuestions.Tables[0].Rows[0]["LastName"].ToString();
                        hidPlayerName.Value = dsQuestions.Tables[0].Rows[0]["NickName"].ToString();
                    }
                    else
                    {
                        sEventInfo         += dsQuestions.Tables[0].Rows[0]["FirstName"].ToString() + " " + dsQuestions.Tables[0].Rows[0]["LastName"].ToString();
                        hidPlayerName.Value = dsQuestions.Tables[0].Rows[0]["FirstName"].ToString() + " " + dsQuestions.Tables[0].Rows[0]["LastName"].ToString();
                    }

                    string sCharAKA = dsQuestions.Tables[0].Rows[0]["CharacterAKA"].ToString().Replace("'", "''");
                    if (sCharAKA.Length > 0)
                    {
                        sCharAKA = "PEL for " + sCharAKA;
                    }
                    else
                    {
                        sCharAKA = "PEL Comments";
                    }

                    sEventInfo += " " + " <a href='mailto:" + dsQuestions.Tables[0].Rows[0]["PlayerEMailAddress"].ToString().Replace(@"""", @"""""") +
                                  "?Subject=" + sCharAKA +
                                  "' class='LinkUnderline' style='text-decoration: underline; color: blue;'>" + dsQuestions.Tables[0].Rows[0]["PlayerEMailAddress"].ToString() + "</a>";

                    hidPELNotificationEMail.Value = dsQuestions.Tables[0].Rows[0]["PELNotificationEMail"].ToString();
                    if (hidPELNotificationEMail.Value.Length == 0)
                    {
                        hidPELNotificationEMail.Value = "*****@*****.**";
                    }

                    int iCampaignPlayerID = 0;
                    if (int.TryParse(dsQuestions.Tables[0].Rows[0]["CampaignPlayerID"].ToString(), out iCampaignPlayerID))
                    {
                        hidCampaignPlayerID.Value = iCampaignPlayerID.ToString();
                    }

                    int.TryParse(dsQuestions.Tables[0].Rows[0]["CharacterID"].ToString(), out iCharacterID);
                    if (iCharacterID != 0)
                    {
                        Classes.cCharacter cChar = new Classes.cCharacter();
                        cChar.LoadCharacterByCharacterID(iCharacterID);
                        sEventInfo           += "&nbsp;&nbsp;<b>Character: </b> " + dsQuestions.Tables[0].Rows[0]["CharacterAKA"].ToString();
                        hidCharacterAKA.Value = dsQuestions.Tables[0].Rows[0]["CharacterAKA"].ToString();
                        imgPicture.ImageUrl   = "../img/BlankProfile.png";  // Default it to this so if it is not set it will display the blank profile picture.
                        if (cChar.ProfilePicture != null)
                        {
                            if (!string.IsNullOrEmpty(cChar.ProfilePicture.PictureURL))
                            {
                                imgPicture.ImageUrl = cChar.ProfilePicture.PictureURL;
                            }
                        }
                        imgPicture.Attributes["onerror"] = "this.src='../img/BlankProfile.png';";
                        hidCharacterID.Value             = iCharacterID.ToString();
                        hidCampaignID.Value = cChar.CampaignID.ToString();
                    }
                    else
                    {
                        string          path         = ResolveUrl(@"~/img/BlankProfile.png");
                        Classes.cPlayer PLDemography = null;
                        PLDemography = new Classes.cPlayer(Master.UserID, Master.UserName);

                        imgPicture.ImageUrl = "../img/BlankProfile.png";    // Default it to this so if it is not set it will display the blank profile picture.
                        if (!string.IsNullOrEmpty(PLDemography.UserPhoto))
                        {
                            imgPicture.ImageUrl = PLDemography.UserPhoto;
                        }
                        imgPicture.Attributes["onerror"] = "this.src='../img/BlankProfile.png';";
                    }

                    lblEventInfo.Text = sEventInfo;

                    int iTemp;
                    if (int.TryParse(dsQuestions.Tables[0].Rows[0]["PELID"].ToString(), out iTemp))
                    {
                        hidPELID.Value = iTemp.ToString();
                    }
                    if (dsQuestions.Tables[0].Rows[0]["PELDateApproved"] != DBNull.Value)
                    {
                        double.TryParse(dsQuestions.Tables[0].Rows[0]["CPAwarded"].ToString(), out dCPEarned);
                        sCampaignGoingTo    = dsQuestions.Tables[0].Rows[0]["CPAwarded"].ToString();
                        btnSave.Text        = "Done";
                        btnSave.CommandName = "Done";
                        DateTime dtTemp;
                        if (DateTime.TryParse(dsQuestions.Tables[0].Rows[0]["PELDateApproved"].ToString(), out dtTemp))
                        {
                            lblEditMessage.Visible = true;
                            lblEditMessage.Text    = "<br>This PEL was approved on " + dtTemp.ToShortDateString() + " and cannot be edited.";
                            TextBoxEnabled         = false;
                            btnCancel.Visible      = false;
                        }
                    }
                    else if (dsQuestions.Tables[0].Rows[0]["PELDateSubmitted"] != DBNull.Value)
                    {
                        btnSave.Text        = "Approve";
                        btnSave.CommandName = "Approve";
                        DateTime dtTemp;
                        divQuestions.Attributes.Add("style", "max-height: 400px; overflow-y: auto; margin-right: 10px;");
                        double.TryParse(dsQuestions.Tables[0].Rows[0]["CPEarn"].ToString(), out dCPEarned);
                        dsQuestions.Tables[0].Rows[0]["CPAwarded"].ToString();
                        int iCampaignCPOpportunityDefaultID = 0;
                        if (int.TryParse(dsQuestions.Tables[0].Rows[0]["CampaignCPOpportunityDefaultID"].ToString(), out iCampaignCPOpportunityDefaultID))
                        {
                            hidCampaignCPOpportunityDefaultID.Value = iCampaignCPOpportunityDefaultID.ToString();
                        }
                        int iReasonID = 0;
                        if (int.TryParse(dsQuestions.Tables[0].Rows[0]["ReasonID"].ToString(), out iReasonID))
                        {
                            hidReasonID.Value = iReasonID.ToString();
                        }

                        if (DateTime.TryParse(dsQuestions.Tables[0].Rows[0]["PELDateSubmitted"].ToString(), out dtTemp))
                        {
                            lblEditMessage.Visible = true;
                            lblEditMessage.Text    = "<br>This PEL was submitted on " + dtTemp.ToShortDateString();
                            TextBoxEnabled         = false;
                            hidSubmitDate.Value    = dtTemp.ToShortDateString();
                        }
                    }
                    if (hidPELID.Value.Length != 0)
                    {
                        // Load the comments for this PEL so we can display them in DataItemBound.
                        SortedList sParamsForComments = new SortedList();
                        sParamsForComments.Add("@PELID", hidPELID.Value);
                        _dtPELComments = Classes.cUtilities.LoadDataTable("uspGetPELStaffComments", sParamsForComments, "LARPortal", Master.UserName, lsRoutineName + ".uspGetPELStaffComments");
                    }
                }

                foreach (DataRow dRow in dsQuestions.Tables[0].Rows)
                {
                    dRow["Answer"] = dRow["Answer"].ToString().Replace("\n", "<br>");
                }

                tbCPAwarded.Text = dCPEarned.ToString("0.0");
                if (sCampaignGoingTo.Length > 0)
                {
                    lblCampaignTo.Text = " to " + sCampaignGoingTo;
                }
                DataView dvQuestions = new DataView(dsQuestions.Tables[0], "", "SortOrder", DataViewRowState.CurrentRows);
                rptQuestions.DataSource = dvQuestions;
                rptQuestions.DataBind();

                if (dsQuestions.Tables[2] != null)
                {
                    _dtAddendumComments = dsQuestions.Tables[2];
                }

                if (dsQuestions.Tables[1] != null)
                {
                    DataTable dtNewAddendum = new DataTable();
                    dtNewAddendum.Columns.Add("Title", typeof(string));
                    dtNewAddendum.Columns.Add("Addendum", typeof(string));
                    dtNewAddendum.Columns.Add("PELsAddendumID", typeof(string));

                    DataView dvAddendum = new DataView(dsQuestions.Tables[1], "", "DateAdded desc", DataViewRowState.CurrentRows);
                    foreach (DataRowView dAdd in dvAddendum)
                    {
                        DataRow  dNewRow = dtNewAddendum.NewRow();
                        DateTime dtDate;
                        dNewRow["Title"] = "Addendum ";
                        if (DateTime.TryParse(dAdd["DateAdded"].ToString(), out dtDate))
                        {
                            dNewRow["Title"] += dtDate.ToString("MM/dd/yyyyy hh:mm:ss tt");
                        }
                        dNewRow["Addendum"]       = dAdd["Addendum"].ToString();
                        dNewRow["PELsAddendumID"] = dAdd["PELsAddendumID"].ToString();
                        dtNewAddendum.Rows.Add(dNewRow);
                    }

                    rptAddendum.DataSource = dtNewAddendum;
                    rptAddendum.DataBind();
                }
            }
        }
コード例 #20
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int iTemp;

            oCharSelect.LoadInfo();

            if ((oCharSelect.SkillSetID.HasValue) && (oCharSelect.CharacterInfo != null))
            {
                int    i = 0;
                string sHiddenSkillList = "";

                foreach (GridViewRow row in gvHiddenSkillAccess.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        CheckBox    cbxHasSkill            = (row.Cells[1].FindControl("cbxHasSkill") as CheckBox);
                        HiddenField hidHadOriginally       = (row.Cells[2].FindControl("hidHadOriginally") as HiddenField);
                        HiddenField hidCampaignSkillNodeID = (row.Cells[2].FindControl("hidCampaignSkillNodeID") as HiddenField);
                        HiddenField hidSkillName           = (row.Cells[2].FindControl("hidSkillName") as HiddenField);

                        if ((cbxHasSkill != null) &&
                            (hidHadOriginally != null) &&
                            (hidCampaignSkillNodeID != null))
                        {
                            bool bHasOriginally = false;
                            if (hidHadOriginally.Value == "1")
                            {
                                bHasOriginally = true;
                            }
                            if (bHasOriginally != cbxHasSkill.Checked)
                            {
                                if (cbxHasSkill.Checked)
                                {
                                    // Since the value has changed, and it's checked, it means we need to add the value;
                                    int iCampaignSkillNodeID;
                                    if (int.TryParse(hidCampaignSkillNodeID.Value, out iCampaignSkillNodeID))
                                    {
                                        SortedList sParams = new SortedList();
                                        sParams.Add("@UserID", Master.UserID);
                                        sParams.Add("@CampaignSkillsStandardID", iCampaignSkillNodeID);
                                        sParams.Add("@SkillSetID", oCharSelect.SkillSetID);
                                        sParams.Add("@Comments", "Skill added by " + Master.UserName);
                                        sParams.Add("@CharacterID", oCharSelect.CharacterID);
                                        Classes.cUtilities.PerformNonQuery("uspInsUpdCHCampaignSkillAccess", sParams, "LARPortal", Master.UserName);

                                        if (hidSkillName != null)
                                        {
                                            sHiddenSkillList += hidSkillName.Value + "<br>";
                                        }
                                    }
                                }
                                else
                                {
                                    // Since the value has changed, and it's not checked, it means we need to delete the value;
                                    HiddenField hidCampaignSkillAccessID = (row.Cells[2].FindControl("hidCampaignSkillAccessID") as HiddenField);
                                    if (hidCampaignSkillAccessID != null)
                                    {
                                        int iCampaignSkillAccessID;
                                        if (int.TryParse(hidCampaignSkillAccessID.Value, out iCampaignSkillAccessID))
                                        {
                                            SortedList sParams = new SortedList();
                                            sParams.Add("@CampaignSkillAccessID", iCampaignSkillAccessID);
                                            sParams.Add("@UserName", Master.UserName);
                                            sParams.Add("@UserID", Master.UserID);
                                            Classes.cUtilities.PerformNonQuery("uspDelCHCampaignSkillAccess", sParams, "LARPortal", Master.UserName);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    i++;
                }

                // If there were any hidden skills given to the character, send them an email.
                if ((sHiddenSkillList.Length > 0) &&
                    (oCharSelect.CharacterInfo.CharacterEmail.ToString().Length > 0))
                {
                    string sSubject = "LARP Portal Notification - " + Master.CampaignName + " staff has given you access to a hidden skill.";
                    string sBody    = "The staff of " + Master.CampaignName + " has given your character " + oCharSelect.CharacterInfo.AKA + " access to the following skill(s):<br>" +
                                      "<br>" +
                                      sHiddenSkillList;

                    Classes.cUser User = new Classes.cUser(Master.UserName, "PasswordNotNeeded", Session.SessionID);
                    Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
                    cEMS.SendMail(sSubject, sBody, oCharSelect.CharacterInfo.CharacterEmail, "", User.PrimaryEmailAddress.EmailAddress, "CharInfo - Hidden Skills", Master.UserName);
                }

                if ((tbAKA.Text.Length == 0) &&
                    (tbFirstName.Text.Length == 0))
                {
                    // JBradshaw  7/11/2016    Request #1286     Must have at least first name or last name.
                    lblmodalError.Text = "You must fill in at least the first name or the character AKA.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openError();", true);
                    return;
                }

                Classes.cCharacter cChar = new Classes.cCharacter();
                cChar.LoadCharacterBySkillSetID(oCharSelect.SkillSetID.Value);

                if (ulFile.HasFile)
                {
                    try
                    {
                        //                        string sUser = Session["LoginName"].ToString();
                        Classes.cPicture NewPicture = new Classes.cPicture();
                        NewPicture.PictureType = Classes.cPicture.PictureTypes.Profile;
                        NewPicture.CreateNewPictureRecord(Master.UserName);
                        string sExtension = Path.GetExtension(ulFile.FileName);
                        NewPicture.PictureFileName = "CP" + NewPicture.PictureID.ToString("D10") + sExtension;

                        NewPicture.CharacterID = oCharSelect.CharacterID.Value;

                        string LocalName = NewPicture.PictureLocalName;

                        if (!Directory.Exists(Path.GetDirectoryName(NewPicture.PictureLocalName)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(NewPicture.PictureLocalName));
                        }

                        ulFile.SaveAs(NewPicture.PictureLocalName);
                        NewPicture.Save(Master.UserName);

                        cChar.ProfilePicture = NewPicture;
                        //                        ViewState["UserIDPicture"] = NewPicture;
                        ViewState.Remove("PictureDeleted");

                        imgCharacterPicture.ImageUrl = NewPicture.PictureURL;
                        imgCharacterPicture.Visible  = true;
                        //                    btnClearPicture.Visible = true;
                    }
                    catch                     //(Exception ex)
                    {
                        //                    lblMessage.Text = ex.Message + "<br>" + ex.StackTrace;
                    }
                }

                cChar.FirstName  = tbFirstName.Text;
                cChar.MiddleName = tbMiddleName.Text;
                cChar.LastName   = tbLastName.Text;

                cChar.CurrentHome = tbBirthPlace.Text;

                cChar.AllowCharacterRebuildToDate = null;

                if (oCharSelect.WhichSelected == LarpPortal.Controls.CharacterSelect.Selected.CampaignCharacters)
                {
                    cChar.CharacterStatusID = Convert.ToInt32(ddlStatus.SelectedValue);
                    cChar.CharacterType     = Convert.ToInt32(ddlCharType.SelectedValue);

                    //if (ddlAllowRebuild.SelectedValue == "Y")
                    //{
                    //    tbRebuildToDate.Style["display"] = "inline";
                    //    lblExpiresOn.Style["display"] = "inline";
                    //    DateTime dtTemp;
                    //    if (DateTime.TryParse(tbRebuildToDate.Text, out dtTemp))
                    //        cChar.AllowCharacterRebuildToDate = dtTemp;
                    //}
                    //else
                    //{
                    //    tbRebuildToDate.Style["display"] = "none";
                    //    lblExpiresOn.Style["display"] = "none";
                    //}
                }

                if (ddlVisible.SelectedValue == "1")
                {
                    cChar.VisibleToPCs = true;
                }
                else
                {
                    cChar.VisibleToPCs = false;
                }

                cChar.AKA         = tbAKA.Text;
                cChar.CurrentHome = tbHome.Text;
                cChar.WhereFrom   = tbBirthPlace.Text;

                // If the drop down list is visible, it means they belong to multiple teams so we need to check it.
                if (ddlTeamList.Visible)
                {
                    if (int.TryParse(ddlTeamList.SelectedValue, out iTemp))
                    {
                        cChar.TeamID = iTemp;
                    }
                }

                cChar.DateOfBirth = tbDOB.Text;
                if (ViewState["UserIDPicture"] != null)
                {
                    cChar.ProfilePicture = ViewState["UserIDPicture"] as Classes.cPicture;
                    if (ViewState["PictureDeleted"] != null)
                    {
                        cChar.ProfilePicture.RecordStatus = Classes.RecordStatuses.Delete;
                    }
                }
                else
                {
                    cChar.ProfilePicture = null;
                }

                if (ddlRace.SelectedIndex > -1)
                {
                    cChar.Race = new Classes.cRace();
                    int.TryParse(ddlRace.SelectedValue, out iTemp);
                    cChar.Race.CampaignRaceID = iTemp;
                }

                if (ddlAllowRebuild.SelectedValue == "Y")
                {
                    DateTime dtTemp;
                    if (DateTime.TryParse(tbRebuildToDate.Text, out dtTemp))
                    {
                        cChar.AllowCharacterRebuildToDate = dtTemp;
                    }
                }
                else
                {
                    cChar.AllowCharacterRebuildToDate = new DateTime(1900, 1, 1);
                }

                if (cChar.CharacterType != 1)                       // Means it's not a PC so we need to check who is the current actor.
                {
                    var LastActor = cChar.Actors.OrderByDescending(x => x.StartDate).ToList();
                    if (LastActor == null)
                    {
                        cChar.CurrentUserID = Master.UserID;
                    }
                    else
                    {
                        if (LastActor.Count > 0)
                        {
                            cChar.CurrentUserID = LastActor[0].UserID;
                        }
                    }
                }

                cChar.StaffComments = tbStaffComments.Text;

                cChar.SaveCharacter(Master.UserName, Master.UserID);
                // JBradshaw  7/11/2016    Request #1286     Changed over to bootstrap popup.
                lblmodalMessage.Text = "Character " + cChar.AKA + " has been saved.";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openMessage();", true);
            }
        }
コード例 #21
0
        private void DisplayCharacter(Classes.cCharacter CharInfo)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            //			oCharSelect.LoadInfo();		JLB Hidden Skills.

            //			Classes.LogWriter oWriter = new Classes.LogWriter();
            //			oWriter.AddLogMessage("Starting Display Character.", lsRoutineName, "", Session.SessionID);

            hidSkillSetID.Value           = CharInfo.SkillSetID.ToString();
            hidCharacterID.Value          = CharInfo.CharacterID.ToString();
            ViewState["ProfilePictureID"] = CharInfo.ProfilePictureID;

            tbFirstName.Text  = CharInfo.FirstName;
            tbMiddleName.Text = CharInfo.MiddleName;
            tbLastName.Text   = CharInfo.LastName;

            tbBirthPlace.Text = CharInfo.CurrentHome;
            tbAKA.Text        = CharInfo.AKA;
            tbHome.Text       = CharInfo.CurrentHome;
            if (CharInfo.LatestEventDate.HasValue)
            {
                tbLastEvent.Text = CharInfo.LatestEventDate.Value.ToString("MM/dd/yyyy");
            }
            else
            {
                tbLastEvent.Text = "";
            }

            tbCharType.Text = CharInfo.CharType.Description;

            divHiddenSkills.Attributes["class"] = "hide";

            // Hidden Skills.
            if (oCharSelect.WhichSelected == LarpPortal.Controls.CharacterSelect.Selected.CampaignCharacters)
            {
                SortedList sParams = new SortedList();
                sParams.Add("@SkillSetID", CharInfo.SkillSetID);
                DataSet dsSkillAccess = Classes.cUtilities.LoadDataSet("uspGetCharacterHiddenSkills", sParams, "LARPortal", Master.UserName, lsRoutineName);
                if (dsSkillAccess.Tables[0].Rows.Count > 0)
                {
                    gvHiddenSkillAccess.DataSource = dsSkillAccess.Tables[0];
                    gvHiddenSkillAccess.DataBind();
                    divHiddenSkills.Attributes["class"] = "show";
                }
            }

            if ((oCharSelect.WhichSelected == LarpPortal.Controls.CharacterSelect.Selected.CampaignCharacters) || (oCharSelect.CharacterInfo.CharacterType == 1))
            {
                //ddlVisible.Visible = true;
                //ddlAllowRebuild.Visible = true;
                //lblAllowSkillRebuild.Visible = true;
                //lblVisibleRelationship.Visible = true;
                //lblExpiresOn.Visible = true;
                tbCharType.Visible        = false;
                ddlCharType.SelectedValue = CharInfo.CharType.CharacterTypeID.ToString();
                ddlCharType.Visible       = true;

                divAddDeath.Attributes["class"] = "hide";
                divAddActor.Attributes["class"] = "show text-right";

                //lblStatus.Visible = false;
                //ddlStatus.Visible = true;
                //ddlAllowRebuild.Visible = true;
                //lblAllowSkillRebuild.Visible = true;

                divAllowRebuild.Visible = false;

                if ((oCharSelect.WhichSelected == LarpPortal.Controls.CharacterSelect.Selected.CampaignCharacters) && (oCharSelect.CharacterInfo.CharacterType == 1))
                {
                    divAddDeath.Attributes["class"] = "show text-right";
                    divAllowRebuild.Visible         = true;

                    if (CharInfo.AllowCharacterRebuild)
                    {
                        ddlAllowRebuild.SelectedValue    = "Y";
                        tbRebuildToDate.Text             = CharInfo.AllowCharacterRebuildToDate.Value.ToShortDateString();
                        tbRebuildToDate.Style["display"] = "inline";
                    }
                    else
                    {
                        ddlAllowRebuild.SelectedValue    = "N";
                        tbRebuildToDate.Text             = "";
                        tbRebuildToDate.Style["display"] = "none";
                    }
                }

                // This is me being overly cautious. If the status is not found I'm not sure what will happen.
                try
                {
                    ddlStatus.SelectedValue = CharInfo.Status.StatusID.ToString();
                }
                catch
                {
                    ddlStatus.ClearSelection();
                    foreach (ListItem litem in ddlStatus.Items)
                    {
                        if (litem.Text.ToUpper() == "ACTIVE")
                        {
                            litem.Selected = true;
                        }
                    }
                }
            }
            else
            {
                divAllowRebuild.Visible = false;
                ddlStatus.Visible       = false;
                lblStatus.Visible       = true;
                tbCharType.Visible      = true;
                ddlCharType.Visible     = false;
                lblStatus.Text          = CharInfo.Status.StatusName;
                //ddlVisible.Visible = false;
                //lblVisibleRelationship.Visible = false;
                //ddlAllowRebuild.Visible = false;
                divAddDeath.Attributes["class"] = "hide";
                divAddActor.Attributes["class"] = "hide";
            }

            divVisibleRelationships.Visible = false;

            if (oCharSelect.CharacterInfo.CharacterType == 1)                     // 1 = PC.
            {
                if (oCharSelect.WhichSelected == LarpPortal.Controls.CharacterSelect.Selected.MyCharacters)
                {
                    divNonCost.Attributes["class"] = "col-sm-6";
                    divDeaths.Attributes["class"]  = "col-sm-6";
                    divPlayer.Attributes["class"]  = "hide";
                    divActors.Attributes["class"]  = "hide";
                }
                else
                {
                    divNonCost.Attributes["class"] = "col-sm-4";
                    divDeaths.Attributes["class"]  = "col-sm-4";
                    divActors.Attributes["class"]  = "hide";
                    divPlayer.Attributes["class"]  = "col-sm-4";
                }
            }
            else
            {
                if (oCharSelect.WhichSelected == LarpPortal.Controls.CharacterSelect.Selected.CampaignCharacters)
                {
                    divVisibleRelationships.Visible = true;
                }

                divNonCost.Attributes["class"] = "col-sm-4";
                divDeaths.Attributes["class"]  = "col-sm-4";
                divActors.Attributes["class"]  = "col-sm-4";
                divPlayer.Attributes["class"]  = "hide";

                SortedList sParams = new SortedList();
                sParams.Add("@CampaignID", oCharSelect.CampaignID.Value);
                DataTable dtPlayers = new DataTable();
                dtPlayers = Classes.cUtilities.LoadDataTable("uspGetCampaignPlayers", sParams, "LARPortal", Master.UserName, lsRoutineName);

                DataView dvPlayers = new DataView(dtPlayers, "", "PlayerFirstLastName", DataViewRowState.CurrentRows);
                ddlActorName.DataSource     = dvPlayers;
                ddlActorName.DataTextField  = "PlayerFirstLastName";
                ddlActorName.DataValueField = "UserID";
                ddlActorName.DataBind();
                ddlActorName.Items.Insert(0, new ListItem("", "-1"));
            }

            if (CharInfo.VisibleToPCs)
            {
                ddlVisible.SelectedValue = "1";
            }
            else
            {
                ddlVisible.SelectedValue = "0";
            }

            if (CharInfo.Teams.Count == 0)
            {
                ddlTeamList.Visible = false;
                tbTeam.Visible      = true;
                tbTeam.Text         = "No Teams";
            }
            else if (CharInfo.Teams.Count == 1)
            {
                ddlTeamList.Visible = false;
                tbTeam.Visible      = true;
                tbTeam.Text         = CharInfo.Teams[0].TeamName;
            }
            else
            {
                ddlTeamList.Visible        = true;
                tbTeam.Visible             = false;
                ddlTeamList.DataSource     = CharInfo.Teams;
                ddlTeamList.DataTextField  = "TeamName";
                ddlTeamList.DataValueField = "TeamID";
                ddlTeamList.DataBind();

                ddlTeamList.ClearSelection();

                foreach (ListItem litem in ddlTeamList.Items)
                {
                    if (litem.Value == CharInfo.TeamID.ToString())
                    {
                        ddlTeamList.ClearSelection();
                        litem.Selected = true;
                    }
                }
                if (ddlTeamList.SelectedIndex < 0)
                {
                    ddlTeamList.SelectedIndex = 0;
                }
            }

            tbDOB.Text = CharInfo.DateOfBirth;

            tbAKA.Text         = CharInfo.AKA;
            tbDOB.Text         = CharInfo.DateOfBirth;
            tbHome.Text        = CharInfo.CurrentHome;
            tbNumOfDeaths.Text = CharInfo.Deaths.Count().ToString();
            tbBirthPlace.Text  = CharInfo.WhereFrom;

            DataTable dtCharDescriptors = new DataTable();

            dtCharDescriptors = Classes.cUtilities.CreateDataTable(CharInfo.Descriptors);
            BindDescriptors();

            if (CharInfo.ProfilePicture != null)
            {
                ViewState["UserIDPicture"]   = CharInfo.ProfilePicture;
                imgCharacterPicture.ImageUrl = CharInfo.ProfilePicture.PictureURL;
                //imgCharacterPicture.Visible = true;
                //                btnClearPicture.Visible = true;
            }
            else
            {
                imgCharacterPicture.ImageUrl = "~/images/profile-photo.png";
                //imgCharacterPicture.Visible = false;
                //                btnClearPicture.Visible = false;
            }

            //			oWriter.AddLogMessage("About to load races.", lsRoutineName, "", Session.SessionID);

            Classes.cCampaignRaces Races = new Classes.cCampaignRaces();
            Races.CampaignID = CharInfo.CampaignID;
            Races.Load(Master.UserName);

            //			oWriter.AddLogMessage("Done loading races.", lsRoutineName, "", Session.SessionID);

            DataTable dtRaces = Classes.cUtilities.CreateDataTable(Races.RaceList);

            ddlRace.DataSource     = dtRaces;
            ddlRace.DataTextField  = "FullRaceName";
            ddlRace.DataValueField = "CampaignRaceID";
            ddlRace.DataBind();
            if (ddlRace.Items.Count > 0)
            {
                ddlRace.SelectedIndex = 0;
                foreach (ListItem dItems in ddlRace.Items)
                {
                    if (dItems.Value == CharInfo.Race.CampaignRaceID.ToString())
                    {
                        dItems.Selected = true;
                        tbRace.Text     = dItems.Text;
                    }
                    else
                    {
                        dItems.Selected = false;
                    }
                }
            }

            //			oWriter.AddLogMessage("About to get Campaign Attributes Standard.", lsRoutineName, "", Session.SessionID);

            SortedList sParam = new SortedList();

            sParam.Add("@CampaignID", CharInfo.CampaignID);
            sParam.Add("@Roles", Master.RoleString);
            DataTable dtDescriptors = Classes.cUtilities.LoadDataTable("uspGetCampaignAttributesStandard",
                                                                       sParam, "LARPortal", Master.UserName, lsRoutineName + ".GetCampaignAttributesStandard");

            //			oWriter.AddLogMessage("Done getting Campaign Attributes Standard.", lsRoutineName, "", Session.SessionID);

            DataView dvDescriptors = new DataView(dtDescriptors, "", "CharacterDescriptor", DataViewRowState.CurrentRows);

            ddlDescriptor.DataTextField  = "CharacterDescriptor";
            ddlDescriptor.DataValueField = "CampaignAttributeStandardID";
            ddlDescriptor.DataSource     = dtDescriptors;
            ddlDescriptor.DataBind();

            //			oWriter.AddLogMessage("About to do Descriptor SelectedIndexChanged.", lsRoutineName, "", Session.SessionID);

            if (dtDescriptors.Rows.Count > 0)
            {
                upDescriptors.Visible       = true;
                gvDescriptors.Visible       = true;
                divCharDev.Visible          = true;
                ddlDescriptor.SelectedIndex = 0;
                ddlDescriptor_SelectedIndexChanged(null, null);
            }

            //			oWriter.AddLogMessage("Done Descriptor SelectedIndexChanged.", lsRoutineName, "", Session.SessionID);

            tbStaffComments.Text = CharInfo.StaffComments;
            if (oCharSelect.WhichSelected == LarpPortal.Controls.CharacterSelect.Selected.MyCharacters)
            {
                divStaffComments.Visible = false;
                divHiddenSkills.Visible  = false;
            }
            else
            {
                divStaffComments.Visible = true;
                divHiddenSkills.Visible  = true;
            }

            BindActors(CharInfo.Actors);

            if (CharInfo.Actors.Count > 0)
            {
                var LatestActor = CharInfo.Actors.OrderByDescending(x => x.StartDate).ToList();
                lblPlayer.Text = "Currently played by " + LatestActor[0].loginUserName + " - ";
                if (LatestActor[0].ActorNickName.Length > 0)
                {
                    lblPlayer.Text += LatestActor[0].ActorNickName;
                }
                else
                {
                    lblPlayer.Text += LatestActor[0].ActorFirstName;
                }
                lblPlayer.Text += " " + LatestActor[0].ActorLastName;
            }

            BindDeaths(CharInfo.Deaths);

            ReadOnlyFields();

            //			oWriter.AddLogMessage("Done DisplayCharacter.", lsRoutineName, "", Session.SessionID);
        }
コード例 #22
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            SortedList slParameters      = new SortedList();
            DataTable  dtCampaignsToEdit = new DataTable();
            DataTable  dtMyCharacters    = new DataTable();

            WhichSelected = Selected.NotSpecified;

            if ((Session["CampaignsToEdit"] == null) ||
                (Session["MyCharacters"] == null))
            {
                Classes.cUser UserInfo = new cUser(_UserName, "PasswordNotNeeded");
                Session["CharacterSelectID"] = UserInfo.LastLoggedInCharacter;
                if (UserInfo.LastLoggedInMyCharOrCamp == "C")
                {
                    WhichSelected = Selected.CampaignCharacters;
                    Session["CharacterSelectCampaign"] = UserInfo.LastLoggedInCampaign;
                    Session["CharacterCampaignCharID"] = UserInfo.LastLoggedInCharacter;
                    Session["CharacterSelectGroup"]    = "Campaigns";
                }
                else
                {
                    WhichSelected = Selected.MyCharacters;
                }
            }

            if (Session["CampaignsToEdit"] == null)
            {
                slParameters.Add("@UserID", _UserID);
                DataTable dtFullCampaignsToEdit = LarpPortal.Classes.cUtilities.LoadDataTable("uspGetPrivCampaignCharacterEdit", slParameters,
                                                                                              "LARPortal", _UserName, lsRoutineName + ".uspGetPrivCampaignCharacterEdit");
                dtCampaignsToEdit          = new DataView(dtFullCampaignsToEdit, "", "CampaignName", DataViewRowState.CurrentRows).ToTable(true, "CampaignID", "CampaignName");
                Session["CampaignsToEdit"] = dtCampaignsToEdit;
                if (dtCampaignsToEdit.Rows.Count == 0)
                {
                    WhichSelected = Selected.MyCharacters;
                }
                //else
                //{
                //    Session["CampaignsToEdit"] = dtCampaignsToEdit;
                //}
            }
            else
            {
                dtCampaignsToEdit = Session["CampaignsToEdit"] as DataTable;
            }

            if (Session["MyCharacters"] == null)
            {
                slParameters = new SortedList();
                slParameters.Add("@intUserID", Session["UserID"].ToString());
                DataTable dtCharacters = LarpPortal.Classes.cUtilities.LoadDataTable("uspGetCharacterIDsByUserID", slParameters,
                                                                                     "LARPortal", _UserName, lsRoutineName + ".uspGetCharacterIDsByUserID");

                // If the person has no characters force it to charadd.
                if (dtCharacters.Rows.Count == 0)
                {
                    Response.Redirect("~/Character/CharAdd.aspx", true);
                }

                dtMyCharacters          = new DataView(dtCharacters, "", "CharacterAKA", DataViewRowState.CurrentRows).ToTable(true, "CharacterAKA", "CharacterID");
                Session["MyCharacters"] = dtMyCharacters;
            }
            else
            {
                dtMyCharacters = Session["MyCharacters"] as DataTable;
            }

            if (dtCampaignsToEdit.Rows.Count == 0)
            {
                ddlCampaigns.Visible         = false;
                rbCampaignCharacters.Visible = false;
                rbMyCharacters.Visible       = false;
                lblNoCharacters.Visible      = false;
            }
            else
            {
                DataView dvCampaigns = new DataView(dtCampaignsToEdit, "", "CampaignName", DataViewRowState.CurrentRows);
                ddlCampaigns.DataSource     = dvCampaigns;
                ddlCampaigns.DataTextField  = "CampaignName";
                ddlCampaigns.DataValueField = "CampaignID";
                ddlCampaigns.DataBind();
            }

            if (WhichSelected == Selected.NotSpecified)
            {
                if (Session["CharacterSelectGroup"] != null)
                {
                    if (Session["CharacterSelectGroup"].ToString() == "Campaigns")
                    {
                        WhichSelected = Selected.CampaignCharacters;
                    }
                    else if (Session["CharacterSelectGroup"].ToString() == "Characters")
                    {
                        WhichSelected = Selected.MyCharacters;
                    }
                }
            }

            if ((dtMyCharacters.Rows.Count >= 1) &&
                (dtCampaignsToEdit.Rows.Count >= 1))
            {
                rbMyCharacters.Visible       = true;
                rbCampaignCharacters.Visible = true;
            }
            else
            {
                rbMyCharacters.Visible       = false;
                rbCampaignCharacters.Visible = false;
            }

            _CharacterID = null;

            if (WhichSelected == Selected.MyCharacters)
            {
                rbMyCharacters.Checked = true;
                DataView dvCharacters = new DataView(dtMyCharacters, "", "CharacterAKA", DataViewRowState.CurrentRows);
                ddlCharacterSelector.DataSource     = dvCharacters;
                ddlCharacterSelector.DataTextField  = "CharacterAKA";
                ddlCharacterSelector.DataValueField = "CharacterID";
                ddlCharacterSelector.DataBind();
                ddlCharacterSelector.Visible = true;
                ddlCampCharSelector.Visible  = false;
                lblSelectedCampaign.Visible  = false;
                rbMyCharacters.Checked       = true;

                ddlCharacterSelector.ClearSelection();

                if (Session["CharacterSelectID"] != null)
                {
                    int iCharID;
                    if (int.TryParse(Session["CharacterSelectID"].ToString(), out iCharID))
                    {
                        foreach (ListItem liItem in ddlCharacterSelector.Items)
                        {
                            if (liItem.Value == iCharID.ToString())
                            {
                                liItem.Selected = true;
                            }
                        }
                    }
                }

                if (ddlCharacterSelector.SelectedIndex < 0)
                {
                    ddlCharacterSelector.Items[0].Selected = true;
                }

                int iTempCharID;
                if (int.TryParse(ddlCharacterSelector.SelectedValue, out iTempCharID))
                {
                    if (iTempCharID == 0)
                    {
                        _CharacterID   = null;
                        _CharacterInfo = null;
                        Session["CharacterSelectID"] = "0";
                    }
                    else
                    {
                        _CharacterID = iTempCharID;
                        _CharacterInfo.LoadCharacter(iTempCharID);
                        lblSelectedCampaign.Visible  = true;
                        lblSelectedCampaign.Text     = _CharacterInfo.CampaignName;
                        ddlCampaigns.Visible         = false;
                        Session["CharacterSelectID"] = iTempCharID;
                        Session["CampaignID"]        = _CharacterInfo.CampaignID;
                    }
                }
            }
            else if (WhichSelected == Selected.CampaignCharacters)
            {
                LoadCampaignCharacters();
            }

            if (!IsPostBack)
            {
                if (this.CharacterChanged != null)
                {
                    this.CharacterChanged(this, e);
                }
            }
        }
コード例 #23
0
        protected void btnApprove_Click(object sender, EventArgs e)
        {
            int iCharacterID = -1;
            int iTemp;

            if (int.TryParse(hidCharacterID.Value, out iTemp))
            {
                iCharacterID = iTemp;
            }

            Classes.cCharacter cChar = new Classes.cCharacter();
            cChar.LoadCharacter(iCharacterID);

            SortedList sParams = new SortedList();

            sParams.Add("@UserID", Session["UserID"].ToString());
            sParams.Add("@CharacterID", iCharacterID);

            sParams.Add("@DateHistoryApproved", DateTime.Now);

            Classes.cUtilities.PerformNonQuery("uspInsUpdCHCharacters", sParams, "LARPortal", Session["UserName"].ToString());
            Session["UpdateHistoryMessage"] = "alert('The character history has been approved.');";

            Classes.cPoints Points           = new Classes.cPoints();
            int             UserID           = 0;
            int             CampaignPlayerID = 0;
            int             CharacterID      = 0;
            int             CampaignCPOpportunityDefaultID = 0;
            int             CampaignID = 0;
            double          CPAwarded  = 0.0;

            int.TryParse(Session["UserID"].ToString(), out UserID);
            int.TryParse(hidCampaignPlayerID.Value, out CampaignPlayerID);
            int.TryParse(hidCharacterID.Value, out CharacterID);
            int.TryParse(hidCampaignCPOpportunityDefaultID.Value, out CampaignCPOpportunityDefaultID);
            int.TryParse(hidCampaignID.Value, out CampaignID);
            double.TryParse(tbCPAwarded.Text, out CPAwarded);

            DateTime dtDateSubmitted;

            if (!DateTime.TryParse(hidSubmitDate.Value, out dtDateSubmitted))
            {
                dtDateSubmitted = DateTime.Now;
            }

            Classes.cUser User     = new Classes.cUser(Session["UserName"].ToString(), "PasswordNotNeeded");
            string        sSubject = "Character history for " + hidCharacterAKA.Value + " had been approved.";

            string sBody = hidCampaignName.Value + " staff has approved the character history for " + hidCharacterAKA.Value + "<br><br>" +
                           "You have been awarded " + CPAwarded.ToString() + " CP.";
            //"<br><br>Character History:<br><br>" + ckHistory.Text;
            string sEmailToSendTo = hidEmail.Value;

            Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
            cEMS.SendMail(sSubject, sBody, sEmailToSendTo, "", "", "CharacterHistory", Session["Username"].ToString());

            //Classes.cSendNotifications SendNot = new Classes.cSendNotifications();
            //SendNot.SubjectText = sSubject;
            //SendNot.EMailBody = sBody;
            //SendNot.NotifyType = Classes.cNotificationTypes.HISTORYAPPROVE;
            //SendNot.SendNotification(cChar.CurrentUserID, _UserName);

            Points.AssignHistoryPoints(UserID, CampaignPlayerID, CharacterID, CampaignCPOpportunityDefaultID, CampaignID, CPAwarded, dtDateSubmitted);

            Response.Redirect("ApprovalList.aspx", true);
        }
コード例 #24
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataSet dsQuestions = new DataSet();

                double dCPEarned = 0.0;
                if (Request.QueryString["RegistrationID"] != null)
                {
                    hidRegistrationID.Value = Request.QueryString["RegistrationID"];
                }
                else
                {
                    Response.Redirect("PELApprovalList.aspx", true);
                }

                Classes.cUser UserInfo = new Classes.cUser(_UserName, "NOPASSWORD");
                if (UserInfo.NickName.Length > 0)
                {
                    hidAuthorName.Value = UserInfo.NickName + " " + UserInfo.LastName;
                }
                else
                {
                    hidAuthorName.Value = UserInfo.FirstName + " " + UserInfo.LastName;
                }

                SortedList sParams = new SortedList();
                sParams.Add("@RegistrationID", hidRegistrationID.Value);

                int iCharacterID = 0;
                int iUserID      = 0;

                dsQuestions = Classes.cUtilities.LoadDataSet("uspGetPELQuestionsAndAnswers", sParams, "LARPortal", Session["UserName"].ToString(), "PELEdit.Page_PreRender");

                DataTable dtQuestions = dsQuestions.Tables[0];

                string sEventInfo = "";
                if (dtQuestions.Rows.Count > 0)
                {
                    sEventInfo = "<b>Event: </b> " + dtQuestions.Rows[0]["EventDescription"].ToString();

                    hidEventDesc.Value = dtQuestions.Rows[0]["EventDescription"].ToString();
                    hidEventID.Value   = dtQuestions.Rows[0]["EventID"].ToString();

                    DateTime dtEventDate;
                    if (DateTime.TryParse(dtQuestions.Rows[0]["EventStartDate"].ToString(), out dtEventDate))
                    {
                        sEventInfo        += "&nbsp;&nbsp;<b>Event Date: </b> " + dtEventDate.ToShortDateString();
                        hidEventDate.Value = dtEventDate.ToShortDateString();
                    }

                    int.TryParse(dtQuestions.Rows[0]["CharacterID"].ToString(), out iCharacterID);
                    int.TryParse(dtQuestions.Rows[0]["UserID"].ToString(), out iUserID);

                    sEventInfo += "&nbsp;&nbsp;<b>Player: </b> ";
                    if (dtQuestions.Rows[0]["NickName"].ToString() != "")
                    {
                        sEventInfo         += dtQuestions.Rows[0]["NickName"].ToString();
                        hidPlayerName.Value = dtQuestions.Rows[0]["NickName"].ToString();
                    }
                    else
                    {
                        sEventInfo         += dtQuestions.Rows[0]["FirstName"].ToString() + " " + dtQuestions.Rows[0]["LastName"].ToString();
                        hidPlayerName.Value = dtQuestions.Rows[0]["FirstName"].ToString() + " " + dtQuestions.Rows[0]["LastName"].ToString();
                    }

                    hidPELNotificationEMail.Value = dtQuestions.Rows[0]["PELNotificationEMail"].ToString();
                    if (hidPELNotificationEMail.Value.Length == 0)
                    {
                        hidPELNotificationEMail.Value = "[email protected],[email protected]";
                    }

                    int iCampaignPlayerID = 0;
                    if (int.TryParse(dtQuestions.Rows[0]["CampaignPlayerID"].ToString(), out iCampaignPlayerID))
                    {
                        hidCampaignPlayerID.Value = iCampaignPlayerID.ToString();
                    }

                    int.TryParse(dtQuestions.Rows[0]["CharacterID"].ToString(), out iCharacterID);
                    if (iCharacterID != 0)
                    {
                        Classes.cCharacter cChar = new Classes.cCharacter();
                        cChar.LoadCharacter(iCharacterID);
                        sEventInfo           += "&nbsp;&nbsp;<b>Character: </b> " + dtQuestions.Rows[0]["CharacterAKA"].ToString();
                        hidCharacterAKA.Value = dtQuestions.Rows[0]["CharacterAKA"].ToString();
                        imgPicture.ImageUrl   = "/img/BlankProfile.png";  // Default it to this so if it is not set it will display the blank profile picture.
                        if (cChar.ProfilePicture != null)
                        {
                            if (!string.IsNullOrEmpty(cChar.ProfilePicture.PictureURL))
                            {
                                imgPicture.ImageUrl = cChar.ProfilePicture.PictureURL;
                            }
                        }
                        imgPicture.Attributes["onerror"] = "this.src='~/img/BlankProfile.png';";
                        hidCharacterID.Value             = iCharacterID.ToString();
                        hidCampaignID.Value = cChar.CampaignID.ToString();
                    }
                    else
                    {
                        Classes.cPlayer PLDemography = null;

                        string uName = "";
                        if (!string.IsNullOrEmpty(Session["Username"].ToString()))
                        {
                            uName = Session["Username"].ToString();
                        }

                        PLDemography = new Classes.cPlayer(iUserID, uName);

                        imgPicture.ImageUrl = "/img/BlankProfile.png";    // Default it to this so if it is not set it will display the blank profile picture.
                        if (!string.IsNullOrEmpty(PLDemography.UserPhoto))
                        {
                            imgPicture.ImageUrl = PLDemography.UserPhoto;
                        }
                        imgPicture.Attributes["onerror"] = "this.src='~/img/BlankProfile.png';";
                    }

                    lblEventInfo.Text = sEventInfo;

                    int iTemp;
                    if (int.TryParse(dtQuestions.Rows[0]["PELID"].ToString(), out iTemp))
                    {
                        hidPELID.Value = iTemp.ToString();
                    }
                    if (dtQuestions.Rows[0]["PELDateApproved"] != DBNull.Value)
                    {
                        double.TryParse(dtQuestions.Rows[0]["CPAwarded"].ToString(), out dCPEarned);
                        //btnSave.Text = "Done";
                        //btnSave.CommandName = "Done";
                        DateTime dtTemp;
                        if (DateTime.TryParse(dtQuestions.Rows[0]["PELDateApproved"].ToString(), out dtTemp))
                        {
                            lblEditMessage.Visible = true;
                            lblEditMessage.Text    = "<br>This PEL was approved on " + dtTemp.ToShortDateString() + ".";
                            TextBoxEnabled         = false;
                            //btnCancel.Visible = false;
                        }
                    }
                    else if (dtQuestions.Rows[0]["PELDateSubmitted"] != DBNull.Value)
                    {
                        //btnSave.Text = "Approve";
                        //btnSave.CommandName = "Approve";
                        DateTime dtTemp;
                        divQuestions.Attributes.Add("style", "max-height: 400px; overflow-y: auto; margin-right: 10px;");
                        double.TryParse(dtQuestions.Rows[0]["CPEarn"].ToString(), out dCPEarned);
                        int iCampaignCPOpportunityDefaultID = 0;
                        if (int.TryParse(dtQuestions.Rows[0]["CampaignCPOpportunityDefaultID"].ToString(), out iCampaignCPOpportunityDefaultID))
                        {
                            hidCampaignCPOpportunityDefaultID.Value = iCampaignCPOpportunityDefaultID.ToString();
                        }
                        int iReasonID = 0;
                        if (int.TryParse(dtQuestions.Rows[0]["ReasonID"].ToString(), out iReasonID))
                        {
                            hidReasonID.Value = iReasonID.ToString();
                        }

                        if (DateTime.TryParse(dtQuestions.Rows[0]["PELDateSubmitted"].ToString(), out dtTemp))
                        {
                            lblEditMessage.Visible = true;
                            lblEditMessage.Text    = "<br>This PEL was submitted on " + dtTemp.ToShortDateString();
                            TextBoxEnabled         = false;
                            hidSubmitDate.Value    = dtTemp.ToShortDateString();
                        }
                    }
                }

                foreach (DataRow dRow in dtQuestions.Rows)
                {
                    dRow["Answer"] = dRow["Answer"].ToString().Replace("\n", "<br>");
                }

                DataView dvQuestions = new DataView(dtQuestions, "", "SortOrder", DataViewRowState.CurrentRows);
                rptQuestions.DataSource = dvQuestions;
                rptQuestions.DataBind();

                if (dsQuestions.Tables[1] != null)
                {
                    DataTable dtNewAddendum = new DataTable();
                    dtNewAddendum.Columns.Add("Title", typeof(string));
                    dtNewAddendum.Columns.Add("Addendum", typeof(string));

                    DataView dvAddendum = new DataView(dsQuestions.Tables[1], "", "DateAdded desc", DataViewRowState.CurrentRows);
                    foreach (DataRowView dAdd in dvAddendum)
                    {
                        DataRow  dNewRow = dtNewAddendum.NewRow();
                        DateTime dtDate;
                        dNewRow["Title"] = "Addendum ";
                        if (DateTime.TryParse(dAdd["DateAdded"].ToString(), out dtDate))
                        {
                            dNewRow["Title"] += dtDate.ToString("MM/dd/yyyy hh:mm:ss tt");
                        }
                        dNewRow["Addendum"] = dAdd["Addendum"].ToString();
                        dtNewAddendum.Rows.Add(dNewRow);
                    }

                    rptAddendum.DataSource = dtNewAddendum;
                    rptAddendum.DataBind();
                }
            }
        }
コード例 #25
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (hidTextBoxEnabled.Value == "1")
            {
                TextBoxEnabled = true;
            }

            if (!IsPostBack)
            {
                DataSet dsQuestions = new DataSet();

                if (Request.QueryString["RegistrationID"] == null)
                {
                    Response.Redirect("PELList.aspx", true);
                }

                hidRegistrationID.Value = Request.QueryString["RegistrationID"];

                SortedList sParams = new SortedList();
                sParams.Add("@RegistrationID", hidRegistrationID.Value);

                dsQuestions = Classes.cUtilities.LoadDataSet("uspGetPELQuestionsAndAnswers", sParams, "LARPortal", Session["UserName"].ToString(), "PELEdit.Page_PreRender");

                int iCharacterID = 0;
                int iUserID      = 0;

                DataTable dtQuestions = dsQuestions.Tables[0];

                string sEventInfo = "";
                if (dtQuestions.Rows.Count > 0)
                {
                    hidPELTemplateID.Value = dtQuestions.Rows[0]["PELTemplateID"].ToString();
                    sEventInfo             = "<b>Event: </b> " + dtQuestions.Rows[0]["EventName"].ToString();

                    DateTime dtEventDate;
                    if (DateTime.TryParse(dtQuestions.Rows[0]["EventStartDate"].ToString(), out dtEventDate))
                    {
                        sEventInfo            += "&nbsp;&nbsp;<b>Event Date: </b> " + dtEventDate.ToShortDateString();
                        ViewState["EventDate"] = dtEventDate.ToShortDateString();
                    }

                    ViewState["EventName"]            = dtQuestions.Rows[0]["EventName"].ToString();
                    ViewState["PELNotificationEMail"] = dtQuestions.Rows[0]["PELNotificationEMail"].ToString();
                    string sPlayerName = dtQuestions.Rows[0]["NickName"].ToString();
                    if (sPlayerName.Length == 0)
                    {
                        sPlayerName = dtQuestions.Rows[0]["FirstName"].ToString();
                    }
                    sPlayerName            += " " + dtQuestions.Rows[0]["LastName"].ToString();
                    ViewState["PlayerName"] = sPlayerName;

                    int.TryParse(dtQuestions.Rows[0]["CharacterID"].ToString(), out iCharacterID);
                    int.TryParse(dtQuestions.Rows[0]["UserID"].ToString(), out iUserID);

                    if (iCharacterID != 0)
                    {
                        // A character.
                        sEventInfo += "&nbsp;&nbsp;<b>Character: </b> " + dtQuestions.Rows[0]["CharacterAKA"].ToString();
                        ViewState["CharacterAKA"] = dtQuestions.Rows[0]["CharacterAKA"].ToString();
                    }
                    else
                    {
                        // Non character.
                        sEventInfo += "&nbsp;&nbsp;<b>Player: </b> " + dtQuestions.Rows[0]["NickName"].ToString();
                        ViewState["CharacterAKA"] = "a non-player.";
                    }

                    int.TryParse(dtQuestions.Rows[0]["CharacterID"].ToString(), out iCharacterID);
                    if (iCharacterID != 0)
                    {
                        Classes.cCharacter cChar = new Classes.cCharacter();
                        cChar.LoadCharacter(iCharacterID);
                        imgPicture.ImageUrl = "/img/BlankProfile.png";    // Default it to this so if it is not set it will display the blank profile picture.
                        if (cChar.ProfilePicture != null)
                        {
                            if (!string.IsNullOrEmpty(cChar.ProfilePicture.PictureURL))
                            {
                                imgPicture.ImageUrl = cChar.ProfilePicture.PictureURL;
                            }
                        }
                        imgPicture.Attributes["onerror"] = "this.src='~/img/BlankProfile.png';";
                    }
                    else
                    {
                        Classes.cPlayer PLDemography = null;

                        string uName = "";
                        int    uID   = 0;
                        if (!string.IsNullOrEmpty(Session["Username"].ToString()))
                        {
                            uName = Session["Username"].ToString();
                        }
                        int.TryParse(Session["UserID"].ToString(), out uID);

                        PLDemography = new Classes.cPlayer(uID, uName);

                        imgPicture.ImageUrl = "/img/BlankProfile.png";    // Default it to this so if it is not set it will display the blank profile picture.
                        if (!string.IsNullOrEmpty(PLDemography.UserPhoto))
                        {
                            imgPicture.ImageUrl = PLDemography.UserPhoto;
                        }
                        imgPicture.Attributes["onerror"] = "this.src='~/img/BlankProfile.png';";
                    }

                    lblEventInfo.Text = sEventInfo;

                    int iTemp;
                    if (int.TryParse(dtQuestions.Rows[0]["PELID"].ToString(), out iTemp))
                    {
                        hidPELID.Value = iTemp.ToString();
                    }
                    if (dtQuestions.Rows[0]["PELDateApproved"] != DBNull.Value)
                    {
                        btnSubmit.Visible       = false;
                        pnlSaveReminder.Visible = false;
                        btnSave.Text            = "Done";
                        btnSave.CommandName     = "Done";
                        DateTime dtTemp;
                        if (DateTime.TryParse(dtQuestions.Rows[0]["PELDateApproved"].ToString(), out dtTemp))
                        {
                            lblEditMessage.Visible  = true;
                            lblEditMessage.Text     = "<br>This PEL was approved on " + dtTemp.ToShortDateString() + " and cannot be edited.";
                            TextBoxEnabled          = false;
                            hidTextBoxEnabled.Value = "0";
                            btnCancel.Visible       = false;
                            foreach (DataRow dRow in dtQuestions.Rows)
                            {
                                dRow["Answer"] = dRow["Answer"].ToString().Replace("\n", "<br>");
                            }
                        }
                    }
                    else if (dtQuestions.Rows[0]["PELDateSubmitted"] != DBNull.Value)
                    {
                        btnSubmit.Visible       = false;
                        pnlSaveReminder.Visible = false;
                        btnSave.Text            = "Done";
                        btnSave.CommandName     = "Done";
                        DateTime dtTemp;
                        if (DateTime.TryParse(dtQuestions.Rows[0]["PELDateSubmitted"].ToString(), out dtTemp))
                        {
                            lblEditMessage.Visible  = true;
                            lblEditMessage.Text     = "<br>This PEL was submitted on " + dtTemp.ToShortDateString() + " and cannot be edited.";
                            TextBoxEnabled          = false;
                            hidTextBoxEnabled.Value = "0";
                            btnCancel.Visible       = false;
                            foreach (DataRow dRow in dtQuestions.Rows)
                            {
                                dRow["Answer"] = dRow["Answer"].ToString().Replace("\n", "<br>");
                            }
                        }
                    }
                }

                DataView dvQuestions = new DataView(dtQuestions, "", "SortOrder", DataViewRowState.CurrentRows);
                rptQuestions.DataSource = dvQuestions;
                rptQuestions.DataBind();

                if (dsQuestions.Tables.Count > 1)
                {
                    DataTable dtNewAddendum = new DataTable();
                    dtNewAddendum.Columns.Add("Title", typeof(string));
                    dtNewAddendum.Columns.Add("Addendum", typeof(string));

                    DataView dvAddendum = new DataView(dsQuestions.Tables[1], "", "DateAdded desc", DataViewRowState.CurrentRows);
                    foreach (DataRowView dAdd in dvAddendum)
                    {
                        DataRow  dNewRow = dtNewAddendum.NewRow();
                        DateTime dtDate;
                        dNewRow["Title"] = "Addendum ";
                        if (DateTime.TryParse(dAdd["DateAdded"].ToString(), out dtDate))
                        {
                            dNewRow["Title"] += dtDate.ToString("MM/dd/yyyy hh:mm:ss tt");
                        }
                        dNewRow["Addendum"] = dAdd["Addendum"].ToString();
                        dtNewAddendum.Rows.Add(dNewRow);
                    }

                    rptAddendum.DataSource = dtNewAddendum;
                    rptAddendum.DataBind();
                }
            }
        }
コード例 #26
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

//            oLogWriter.AddLogMessage("Starting up CharacterSelect.PreRender", lsRoutineName, "", Session.SessionID);

            SortedList slParameters      = new SortedList();
            DataTable  dtCampaignsToEdit = new DataTable();
            DataTable  dtMyCharacters    = new DataTable();

            WhichSelected = Selected.NotSpecified;

            if ((Session["CampaignsToEdit"] == null) ||
                (Session["MyCharacters"] == null))
            {
                if (_UserInfo == null)
                {
                    _UserInfo = new cUser(_UserName, "PasswordNotNeeded", Session.SessionID);
                }

//                oLogWriter.AddLogMessage("Done loading user.", lsRoutineName, "", Session.SessionID);
                //                Session["CharCharacterID"] = UserInfo.LastLoggedInCharacter;
                if (UserInfo.LastLoggedInMyCharOrCamp == "C")
                {
                    WhichSelected = Selected.CampaignCharacters;
                    Session["CharCampaignCampaignID"] = UserInfo.LastLoggedInCampaign;
                    Session["CharCampaignCharID"]     = UserInfo.LastLoggedInCharacter;
                    Session["CharCampaignSkillSetID"] = UserInfo.LastLoggedInSkillSetID;
                    Session["CharacterSelectGroup"]   = "Campaigns";
                }
                else
                {
                    WhichSelected                   = Selected.MyCharacters;
                    Session["CharSkillSetID"]       = UserInfo.LastLoggedInSkillSetID;
                    Session["CharCharacterID"]      = UserInfo.LastLoggedInCharacter;
                    Session["CharCampaignID"]       = UserInfo.LastLoggedInCampaign;
                    Session["CharacterSelectGroup"] = "Characters";
                }
            }

            if (Session["CampaignsToEdit"] == null)
            {
                slParameters.Add("@UserID", _UserID);
//                oLogWriter.AddLogMessage("About to run uspGetPrivCampaignCharacterEdit.", lsRoutineName, "", Session.SessionID);
                DataTable dtFullCampaignsToEdit = LarpPortal.Classes.cUtilities.LoadDataTable("uspGetPrivCampaignCharacterEdit", slParameters,
                                                                                              "LARPortal", _UserName, lsRoutineName + ".uspGetPrivCampaignCharacterEdit");
//                oLogWriter.AddLogMessage("Done running uspGetPrivCampaignCharacterEdit.", lsRoutineName, "", Session.SessionID);
                dtCampaignsToEdit          = new DataView(dtFullCampaignsToEdit, "", "CampaignName", DataViewRowState.CurrentRows).ToTable(true, "CampaignID", "CampaignName");
                Session["CampaignsToEdit"] = dtCampaignsToEdit;
                if (dtCampaignsToEdit.Rows.Count == 0)
                {
                    WhichSelected = Selected.MyCharacters;
                }
                //else
                //{
                //    Session["CampaignsToEdit"] = dtCampaignsToEdit;
                //}
            }
            else
            {
                dtCampaignsToEdit = Session["CampaignsToEdit"] as DataTable;
            }

            if (Session["MyCharacters"] == null)
            {
                slParameters = new SortedList();
                slParameters.Add("@intUserID", Session["UserID"].ToString());
//                oLogWriter.AddLogMessage("About to run uspGetCharacterIDsByUserID", lsRoutineName, "", Session.SessionID);
                DataTable dtCharacters = LarpPortal.Classes.cUtilities.LoadDataTable("uspGetCharacterIDsByUserID", slParameters,
                                                                                     "LARPortal", _UserName, lsRoutineName + ".uspGetCharacterIDsByUserID");
//                oLogWriter.AddLogMessage("Done running uspGetCharacterIDsByUserID", lsRoutineName, "", Session.SessionID);

                // If the person has no characters force it to charadd.
                if (dtCharacters.Rows.Count == 0)
                {
                    if (!HttpContext.Current.Request.Url.AbsoluteUri.ToUpper().Contains("CHARADD.ASPX"))
                    {
                        Response.Redirect("~/Character/CharAdd.aspx", true);
                    }
                    else
                    {
                        return;
                    }
                }
                dtMyCharacters          = new DataView(dtCharacters, "", "DisplayName", DataViewRowState.CurrentRows).ToTable(true, "DisplayName", "CharacterID", "CharacterSkillSetID");
                Session["MyCharacters"] = dtMyCharacters;
            }
            else
            {
                dtMyCharacters = Session["MyCharacters"] as DataTable;
            }

            if (dtCampaignsToEdit.Rows.Count == 0)
            {
                ddlCampaigns.Visible         = false;
                rbCampaignCharacters.Visible = false;
                rbMyCharacters.Visible       = false;
                lblNoCharacters.Visible      = false;
            }
            else
            {
                DataView dvCampaigns = new DataView(dtCampaignsToEdit, "", "CampaignName", DataViewRowState.CurrentRows);
                ddlCampaigns.DataSource     = dvCampaigns;
                ddlCampaigns.DataTextField  = "CampaignName";
                ddlCampaigns.DataValueField = "CampaignID";
                ddlCampaigns.DataBind();
            }

            if (WhichSelected == Selected.NotSpecified)
            {
                if (Session["CharacterSelectGroup"] != null)
                {
                    if (Session["CharacterSelectGroup"].ToString() == "Campaigns")
                    {
                        WhichSelected = Selected.CampaignCharacters;
                    }
                    else if (Session["CharacterSelectGroup"].ToString() == "Characters")
                    {
                        WhichSelected = Selected.MyCharacters;
                    }
                }
            }

            if ((dtMyCharacters.Rows.Count >= 1) &&
                (dtCampaignsToEdit.Rows.Count >= 1))
            {
                rbMyCharacters.Visible       = true;
                rbCampaignCharacters.Visible = true;
            }
            else
            {
                rbMyCharacters.Visible       = false;
                rbCampaignCharacters.Visible = false;
            }

            _CharacterID = null;

//            oLogWriter.AddLogMessage("About to run which selected.", lsRoutineName, "", Session.SessionID);

            if (WhichSelected == Selected.MyCharacters)
            {
                rbMyCharacters.Checked = true;
                DataView dvCharacters = new DataView(dtMyCharacters, "", "DisplayName", DataViewRowState.CurrentRows);
                ddlCharacterSelector.DataSource     = dvCharacters;
                ddlCharacterSelector.DataTextField  = "DisplayName";
                ddlCharacterSelector.DataValueField = "CharacterSkillSetID";
                ddlCharacterSelector.DataBind();
                ddlCharacterSelector.Visible = true;
                ddlCampCharSelector.Visible  = false;
                lblSelectedCampaign.Visible  = false;
                rbMyCharacters.Checked       = true;

                ddlCharacterSelector.ClearSelection();

                if (Session["CharSkillSetID"] != null)
                {
                    int iCharSkillSetID;
                    if (int.TryParse(Session["CharSkillSetID"].ToString(), out iCharSkillSetID))
                    {
                        foreach (ListItem liItem in ddlCharacterSelector.Items)
                        {
                            if (liItem.Value == iCharSkillSetID.ToString())
                            {
                                ddlCharacterSelector.ClearSelection();
                                liItem.Selected = true;
                            }
                        }
                    }
                }

                if (ddlCharacterSelector.SelectedIndex < 0)
                {
                    ddlCharacterSelector.Items[0].Selected = true;
                }

                int iSkillSetID;
                if (int.TryParse(ddlCharacterSelector.SelectedValue, out iSkillSetID))
                {
                    if (iSkillSetID == 0)
                    {
                        _CharacterID   = null;
                        _CharacterInfo = null;
                        _SkillSetID    = null;
                        Session.Remove("CharSkillSetID");
                        Session.Remove("CharCharacterID");
                        Session.Remove("CharCampaignID");
                    }
                    else
                    {
                        _SkillSetID = iSkillSetID;
                        _CharacterInfo.LoadCharacterBySkillSetID(iSkillSetID);
                        _CharacterID = _CharacterInfo.CharacterID;
                        _CampaignID  = _CharacterInfo.CampaignID;
                        lblSelectedCampaign.Visible = true;
                        lblSelectedCampaign.Text    = _CharacterInfo.CampaignName;
                        ddlCampaigns.Visible        = false;
                        Session["CharSkillSetID"]   = iSkillSetID;
                        Session["CharCharacterID"]  = _CharacterInfo.CharacterID;
                        Session["CharCampaignID"]   = _CharacterInfo.CampaignID;
                        Session["CurrentChar"]      = _CharacterInfo;
                    }
                }
//                oLogWriter.AddLogMessage("Done with MyCharacters", lsRoutineName, "", Session.SessionID);
            }
            else if (WhichSelected == Selected.CampaignCharacters)
            {
//                oLogWriter.AddLogMessage("About to load campaign characters.", lsRoutineName, "", Session.SessionID);
                LoadCampaignCharacters();
//                oLogWriter.AddLogMessage("Done loading campaign characters.", lsRoutineName, "", Session.SessionID);
            }

            if (!IsPostBack)
            {
                if (this.CharacterChanged != null)
                {
//                    oLogWriter.AddLogMessage("About to call CharacterChanged", lsRoutineName, "", Session.SessionID);
                    this.CharacterChanged(this, e);
//                    oLogWriter.AddLogMessage("Done calling CharacterChanged", lsRoutineName, "", Session.SessionID);
                }
            }
        }