コード例 #1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Get the materialID for the material that is currently being viewed
            string strMaterialID = Request.Params["materialID"];

            if (strMaterialID != null)
            {
                materialID = int.Parse(Request.Params["materialID"]);
            }

            //Obtain the material that is associated with the materialID and setup the header
            Materials.MaterialInfo mi = Materials.getMaterialInfo(materialID);
            RatingImage.ImageUrl     = mi.RatingImage;
            NumericalRating.Text     = string.Format("{0:0.00}", mi.Rating);
            MaterialLabel.Text       = mi.IdentInfo;
            NumberOfRatings.Text     = "" + Materials.getNumberOfRatings(materialID);
            MaterialLink.NavigateUrl = "Materials/" + Materials.getModuleOfMaterial(materialID) + "/" + mi.Link;

            //Identify the user and their access level
            int role = -1;

            if (Context.User.Identity.IsAuthenticated)
            {
                UserAccounts.UserInfo cui = UserAccounts.getUserInfo(Context.User.Identity.Name);
                role = (int)cui.Role;
            }
            //If the user does not have the needed access level then do not allow them to download the material
            if ((role < mi.AccessFlag) || (role > 5))
            {
                MaterialLink.Enabled = false;
            }

            //Setup the material download link and then display format of it
            int position = mi.Link.LastIndexOf('.');

            if (position == -1)
            {
                MaterialLink.Text = "(" + mi.Link + ")";
            }
            else
            {
                MaterialLink.Text = "(" + mi.Link.Substring((position + 1)) + ")";
            }
            MaterialLink.Text = MaterialLink.Text.ToUpper();

            IList tempComment = MaterialComments.getAll(materialID);

            CommentRepeater.DataSource = tempComment;
            CommentRepeater.DataBind();
        }
コード例 #2
0
        /// <summary>
        /// Handles when the "Submit" button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Submit_Btn(Object sender, EventArgs e)
        {
            int    materialRating  = 0;
            int    numberOfRatings = 0;
            int    locationOfSpace = 0;
            string comments        = null;
            string subject         = null;
            string date            = null;
            string author          = null;
            string selected        = null;

            numberOfRatings = ((Materials.getNumberOfRatings(materialID)) + 1);

            //Get the radio button the user selected for the rating
            selected       = RButtonList.SelectedValue;
            materialRating = int.Parse(selected);

            //If the user added a comment then construct all the comment information and add it to the database
            if ((CommentText.Text != String.Empty) && (SubjectText.Text != String.Empty))
            {
                comments = CommentText.Text;
                subject  = SubjectText.Text;
                date     = "" + DateTime.Today;
                author   = Context.User.Identity.Name;

                locationOfSpace = date.IndexOf(" ");
                date            = date.Substring(0, locationOfSpace);

                MaterialComments.addComment(new MaterialComments.MaterialCommentsInfo(materialID, comments, subject, date, materialRating, "", author));
            }

            Materials.setNumberOfRatings(numberOfRatings, materialID);
            Materials.setMaterialRating(materialRating, materialID);

            //Return to viewing the module
            Response.Redirect("viewModule.aspx?moduleID=" + Materials.getModuleOfMaterial(materialID));
        }