コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var book = new Academic.DbEntities.ActivityAndResource.BookResource()
            {
                Id   = BookId,
                Name = txtName.Text
                ,
                Description = CKEditor1.Text
                ,
                ChapterFormatting = (byte)ddlChapterFormatting.SelectedIndex
                ,
                CustomTitles = false
                ,
                StyleOfNavigation = (byte)ddlStyleOfNavigation.SelectedIndex
                ,
                DisplayDescriptionOnCourePage = chkDisplayDescription.Checked
                ,
            };

            var restriction = RestrictionUC.GetRestriction();

            if (!RestrictionUC.IsValid)
            {
                lblError.Visible = true;
                return;
            }
            using (var helper = new DbHelper.ActAndRes())
            {
                var saved = helper.AddOrUpdateBook(book, SectionId, restriction);
                if (saved != null)
                {
                    if (saved.Chapters.Any())
                    {
                        Response.Redirect(DbHelper.StaticValues.WebPagePath.CourseDetailPage(SubjectId, SectionId));
                    }
                    else
                    {
                        Response.Redirect("~/Views/ActivityResource/Book/ChapterCreate.aspx?bId=" + saved.Id +
                                          "&pcId=0&SubId=" + SubjectId
                                          + "&secId=" + SectionId);
                    }
                }
                //Response.Redirect(DbHelper.StaticValues.WebPagePath.CourseDetailPage(SubjectId, SectionId));
                //Response.Redirect("~/Views/Course/Section/?SubId="
                //        + SubjectId + "#section_" + SectionId);//
            }
        }