Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         var bookId          = Request.QueryString["bId"];
         var parentChapterId = Request.QueryString["pcId"];
         //we need to pass 'edit=1' in queryString because when not passed the form inserts new chapter rather than edit
         var edit = Request.QueryString["edit"];
         hidSubjectId.Value = Request.QueryString["SubId"];
         hidSectionId.Value = Request.QueryString["secId"];
         //var secId = Request.QueryString["SecId"];
         try
         {
             if (bookId != null)
             {
                 BookId = Convert.ToInt32(bookId);
             }
             if (parentChapterId != null)
             {
                 if (edit != null)
                 {
                     if (edit.ToString() == "1")
                     {
                         ChapterId = Convert.ToInt32(parentChapterId);
                         using (var helper = new DbHelper.ActAndRes())
                         {
                             var chapter = helper.GetChapter(ChapterId);
                             if (chapter != null)
                             {
                                 txtName.Text          = chapter.Title;
                                 CKEditor1.Text        = chapter.Content;
                                 chkSubChapter.Checked = chapter.ParentChapterId != null;
                                 chkSubChapter.Enabled = false;
                                 ParentChapterId       = chapter.ParentChapterId ?? 0;
                             }
                         }
                     }
                 }
                 else
                 {
                     ParentChapterId = Convert.ToInt32(parentChapterId);
                     if (ParentChapterId > 0 && ChapterId <= 0)
                     {
                         chkSubChapter.Enabled = true;
                         chkSubChapter.Checked = true;
                     }
                 }
             }
         }
         catch
         {
             Response.Redirect("~/ViewsSite/User/Dashboard/Dashboard.aspx");
         }
     }
 }
Example #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var saved = new Academic.DbEntities.ActivityAndResource.BookItems.BookChapter();

            using (var helper = new DbHelper.ActAndRes())
            {
                var chapter = new Academic.DbEntities.ActivityAndResource.BookItems.BookChapter()
                {
                    Id     = ChapterId,
                    BookId = BookId
                    ,
                    Content = CKEditor1.Text
                    ,
                    Title = txtName.Text
                    ,
                };
                if (chkSubChapter.Checked)
                {
                    if (ParentChapterId > 0)
                    {
                        chapter.ParentChapterId = ParentChapterId;
                    }
                }
                else
                {
                    // here we need to assign th parent id of the parentchapterId

                    var parent = helper.GetChapter(ParentChapterId);
                    if (parent != null)
                    {
                        chapter.ParentChapterId = parent.ParentChapterId;
                        chapter.Position        = parent.Position;
                    }
                }


                saved = helper.AddOrUpdateBookChapter(chapter);
            }
            using (var helper = new DbHelper.ActAndRes())
            {
                if (saved != null)
                {
                    helper.UpdateBelowChapters(saved.BookId, saved.Id, saved.ParentChapterId ?? 0, saved.Position);
                    Response.Redirect("~/Views/ActivityResource/Book/BookView.aspx?arId=" + BookId + "&SubId=" + hidSubjectId.Value + "&secId=" + hidSectionId.Value);
                }
            }
        }
Example #3
0
 private void LoadContent(int chapterId, string name)
 {
     using (var helper = new DbHelper.ActAndRes())
     {
         var content = helper.GetChapter(chapterId);
         lblChapterHeading.Text = name;
         if (content != null)
         {
             lblContent.Text            = content.Content;
             lnkChapterEdit.NavigateUrl = "~/Views/ActivityResource/Book/ChapterCreate.aspx?SubId=" + SubjectId +
                                          "&secId=" + SectionId +
                                          "&bId=" + content.BookId + "&pcId=" + content.Id + "&edit=1";
             lnkDelete.NavigateUrl = "~/Views/All_Resusable_Codes/Delete/DeleteForm.aspx" +
                                     "?task=" + DbHelper.StaticValues.Encode("chapsubjectClass") +
                                     "&bcId=" + content.Id +
                                     "&bId=" + content.BookId +
                                     "&SubId=" + SubjectId +
                                     "&secId=" + SectionId;
         }
     }
 }
Example #4
0
        private void LoadCustomText()
        {
            try
            {
                #region Activity Resource

                var actResId = Request.QueryString["actResId"];
                //var actOrRes = Request.QueryString["actOrRes"];
                //var actOrResId = Request.QueryString["actOrResId"];
                //var actResType = Request.QueryString["actResType"];
                if (actResId != null)//actOrRes != null && actOrResId != null && actResType != null)
                {
                    var displayType = "";
                    //var type = Convert.ToByte(actResType);
                    //var aOrRId = Convert.ToInt32(actOrResId);
                    using (var helper = new DbHelper.ActAndRes())
                    {
                        var actRes = helper.GetActivityResource(Convert.ToInt32(actResId));
                        if (actRes != null)
                        {
                            if (Convert.ToBoolean(actRes.ActivityOrResource)) //activity
                            {
                                switch (actRes.ActivityResourceType - 1)
                                {
                                case (int)Enums.Activities.Assignment:     //Assignment
                                    displayType = Enums.Activities.Assignment.ToString().ToLower();
                                    break;

                                case (int)Enums.Activities.Chat:     //chat
                                    displayType = Enums.Activities.Chat.ToString().ToLower();
                                    break;

                                case (int)Enums.Activities.Forum:     //forum
                                    displayType = Enums.Activities.Forum.ToString().ToLower();
                                    break;

                                case (int)Enums.Activities.Choice:
                                    displayType = Enums.Activities.Choice.ToString().ToLower();
                                    break;

                                case (int)Enums.Activities.Lession:     //lession
                                    displayType = Enums.Activities.Lession.ToString().ToLower();
                                    break;

                                case (int)Enums.Activities.Wiki:     //wiki
                                    displayType = Enums.Activities.Wiki.ToString().ToLower();
                                    break;

                                case (int)Enums.Activities.Workshop:     //Workshop
                                    displayType = Enums.Activities.Workshop.ToString().ToLower();
                                    break;
                                }
                            }
                            else //resource
                            {
                                switch (actRes.ActivityResourceType - 1)
                                {
                                case (int)Enums.Resources.Book:     //Book
                                    displayType = Enums.Resources.Book.ToString().ToLower();
                                    break;

                                case (int)Enums.Resources.File:     //file
                                    displayType = Enums.Resources.File.ToString().ToLower();
                                    break;

                                case (int)Enums.Resources.Folder:
                                    displayType = Enums.Resources.Folder.ToString().ToLower();
                                    break;

                                case (int)(Enums.Resources.Label):
                                    displayType = Enums.Resources.Label.ToString().ToLower();
                                    break;

                                case (int)(Enums.Resources.Page):
                                    displayType = Enums.Resources.Page.ToString().ToLower();
                                    break;

                                case (int)(Enums.Resources.Url):
                                    displayType = Enums.Resources.Url.ToString().ToLower();
                                    break;
                                }
                            }
                            lblInfoText.Text = ("Are you sure to delete the " + displayType
                                                + ", " + actRes.Name + "?");
                            //DbHelper.StaticValues.Decode
                        }
                    }
                    return;
                }


                #endregion

                #region Book chapter

                var chapterId = Request.QueryString["bcId"];
                if (chapterId != null)
                {
                    using (var helper = new DbHelper.ActAndRes())
                    {
                        var chapter = helper.GetChapter(Convert.ToInt32(chapterId));
                        if (chapter != null)
                        {
                            lblInfoText.Text = "Are you sure to delete the chapter, " + chapter.Title + "?";
                        }
                        return;
                    }
                }

                #endregion


                #region Grade

                var gradeId = Request.QueryString["grdId"];
                if (gradeId != null)
                {
                    using (var helper = new DbHelper.Grade())
                    {
                        var grade = helper.GetGrade(Convert.ToInt32(gradeId));
                        if (grade != null)
                        {
                            lblInfoText.Text = "Are you sure to delete the grade, " + grade.Name + "?";
                        }
                        return;
                    }
                }

                #endregion

                #region Notice

                var noticeId = Request.QueryString["nId"];
                if (noticeId != null)
                {
                    using (var helper = new DbHelper.Notice())
                    {
                        var notice = helper.GetNotice(Convert.ToInt32(noticeId));
                        if (notice != null)
                        {
                            lblInfoText.Text = "Are you sure to delete the notice, " + notice.Title + "?";
                        }
                    }
                    return;
                }

                #endregion

                #region Academic year and SEssion

                var acaId = Request.QueryString["acaId"];
                if (acaId != null)
                {
                    using (var helper = new DbHelper.AcademicYear())
                    {
                        var academic = helper.GetAcademicYear(Convert.ToInt32(acaId));
                        if (academic != null)
                        {
                            lblInfoText.Text = "Are you sure to delete the academic year, " + academic.Name + "?";
                        }
                        return;
                    }
                }
                var sessId = Request.QueryString["sessId"];
                if (sessId != null)
                {
                    using (var helper = new DbHelper.AcademicYear())
                    {
                        var session = helper.GetSession(Convert.ToInt32(sessId));
                        if (session != null)
                        {
                            lblInfoText.Text = "Are you sure to delete the session, " + session.Name + "?";
                        }
                        return;
                    }
                }
                #endregion

                #region SubjectClass

                var subclsId = Request.QueryString["subclsId"];
                if (subclsId != null)
                {
                    using (var helper = new DbHelper.Classes())
                    {
                        var cls = helper.GetSubjectSession(Convert.ToInt32(subclsId));
                        if (cls != null)
                        {
                            lblInfoText.Text = "Are you sure to delete the class, " + (cls.IsRegular ? cls.GetName : cls.Name) + "?";
                        }
                    }
                    return;
                }

                #endregion

                #region Course and Category

                var catId = Request.QueryString["catId"];
                var crsId = Request.QueryString["crsId"];
                //crsId should be null so it means that its category only
                if (catId != null && crsId == null)
                {
                    using (var helper = new DbHelper.Subject())
                    {
                        var category = helper.GetCategory(Convert.ToInt32(catId));
                        if (category != null)
                        {
                            lblInfoText.Text = "Are you sure to delete the category, " + category.Name + "?";
                        }
                    }
                    return;
                }

                #endregion
            }
            catch { }
        }