Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            using (var helper = new DbHelper.SubjectSection())
            {
                var restriction = RestrictionUC1.GetRestriction();
                if (!RestrictionUC1.IsValid)
                {
                    lblError.Visible = true;
                    return;
                }
                var sec = new Academic.DbEntities.Subjects.SubjectSection()
                {
                    Id = SectionId
                    ,
                    Name = txtName.Text
                    ,
                    Summary = txtDesc.Text
                    ,
                    ShowSummary = chkShow.Checked
                    ,
                    SubjectId = SubjectId
                };
                var saved = helper.AddOrUpdateSection(sec, restriction);


                if (saved != null)
                {
                    Response.Redirect("~/Views/Course/Section/?SubId=" + SubjectId + "&edit=1" + "#section_" + saved.Id);
                }
                else
                {
                    lblError.Visible = true;
                }
            }
        }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            using (var helper = new DbHelper.SubjectSection())
            {
                var sec = new Academic.DbEntities.Subjects.SubjectSection()
                {
                    Id            = SectionId
                    , Name        = txtName.Text
                    , Summary     = txtDesc.Text
                    , ShowSummary = chkShow.Checked
                                    //,Restrictions =
                    ,
                    SubjectId = SubjectId
                };
                var saved = helper.AddOrUpdateSection(sec);

                if (OnSaveEvent != null)
                {
                    if (saved)
                    {
                        OnSaveEvent(this, DbHelper.StaticValues.SuccessSaveMessageEventArgs);
                    }
                    else
                    {
                        OnSaveEvent(this, DbHelper.StaticValues.ErrorSaveMessageEventArgs);
                    }
                }
                else if (!String.IsNullOrEmpty(RedirectUrl))
                {
                    ViewState["Saved"] = saved;
                    string url = RedirectUrl + "?SubId=" + SubjectId;
                    Response.Redirect(url);
                }
            }
        }
Esempio n. 3
0
        void LoadSectionDetail()
        {
            var user = Page.User as CustomPrincipal;

            if (user != null)
            {
                using (var ahelper = new DbHelper.ActAndRes())
                    using (var helper = new DbHelper.SubjectSection())
                    {
                        var elligible = ElligibleToView;
                        var section   = helper.Find(SectionId);
                        if (section != null)
                        {
                            if (EditEnabled)
                            {
                                pnlMain.CssClass = "hover-background-change-slight";
                            }


                            lnkAddActOrRes.ID = "lnkAddActOrRes_" + SubjectId + "_" + SectionId;
                            lnkAddActOrRes.Attributes.Add("name", SectionName);
                            lblTitle.Text   = section.Name;
                            lblSummary.Text = section.Summary;

                            var redUrl = "~/Views/All_Resusable_Codes/Delete/DeleteForm.aspx?task=" +
                                         DbHelper.StaticValues.Encode("courseSection") +
                                         "&crsId=" + SubjectId +
                                         "&secId=" + SectionId
                                         + "&showText="
                                         + DbHelper.StaticValues.Encode("Are you sure to delete the section, "
                                                                        + section.Name + "?")
                            ;
                            lnkDelete.NavigateUrl = redUrl;


                            var editUrl = "~/Views/Course/Section/CreateSection.aspx" + "?SecId=" + SectionId +
                                          "&SubId=" + this.SubjectId;
                            lnkEdit.NavigateUrl = editUrl;



                            var ars = ahelper.ListActivitiesAndResourcesOfSection(UserId, SectionId, elligible);
                            foreach (var ar in ars)
                            {
                                //foreach(var cls in ar.)
                                var arUc =
                                    (ActivityAndResourceUc)
                                    Page.LoadControl("~/Views/Course/Section/ActivityAndResourceUc.ascx");

                                arUc.SetData(ar.ActivityOrResource, ar.New, ar.NewSubmission, ar.Name, ar.Description
                                             , ar.ActivityResourceId, ar.Id, ar.ActivityResourceType, ar.IconUrl, ar.NavigateUrl
                                             , SectionId, EditEnabled, SubjectId, ar.CreateUrl, ar.ActivityResourceTypeName, ar.Enable);

                                pnlActAndRes.Controls.Add(arUc);
                            }
                        }
                    }
            }
        }
Esempio n. 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (var helper = new DbHelper.SubjectSection())
         {
             var section = helper.GetSection(SectionId);
             if (section != null)
             {
                 btnDelete.Visible = true;
                 txtName.Text      = section.Name;
                 txtDesc.Text      = section.Summary;
                 chkShow.Checked   = section.ShowSummary ?? false;
             }
         }
     }
 }
Esempio n. 5
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     using (var helper = new DbHelper.SubjectSection())
     {
         bool deleted = helper.MakeSectionVoid(SectionId);
         if (OnSaveEvent != null)
         {
             if (deleted)
             {
                 OnSaveEvent(this, DbHelper.StaticValues.SuccessDeleteMessageEventArgs);
             }
             else
             {
                 OnSaveEvent(this, DbHelper.StaticValues.ErrorDeleteMessageEventArgs);
             }
         }
         else if (!String.IsNullOrEmpty(RedirectUrl))
         {
             ViewState["Saved"] = deleted;
             string url = RedirectUrl + "?SubId=" + SubjectId;
             Response.Redirect(url);
         }
     }
 }
Esempio n. 6
0
        //public Academic.DbEntities.Subjects.SubjectSection Section;


        /// <summary>
        /// Iniital call...
        /// </summary>
        void SetRestriction()
        {
            using (var helper = new DbHelper.ActAndRes())
            {
                var sectionId = SectionId;
                if (sectionId > 0) //then its section
                {
                    using (var secHelper = new DbHelper.SubjectSection())
                    {
                        var section = secHelper.GetSection(sectionId);
                        if (section != null && section.Restriction != null)
                        {
                            EachRestriction1.RestrictionId = section.RestrictionId ?? 0;
                            EachRestriction1.SetConstraints(section.Restriction.MatchMust, section.Restriction.MatchAllAny);
                            var rSession = Session["ControlList_" + hidPageKeyForUniqueSession.Value] as RestrictionIdName;
                            var user     = Page.User as CustomPrincipal;

                            if (user != null)
                            {
                                if (rSession != null)
                                {
                                    var parent = rSession;
                                    SetRestriction(section.Restriction, parent);
                                }
                                else
                                {
                                    Session["ControlList_" + hidPageKeyForUniqueSession.Value] = new RestrictionIdName()
                                    {
                                        AbsoluteId = EachRestriction1.AbsoluteId,
                                        ParentId   = "0",
                                        Name       = "Main",
                                        Children   = new List <RestrictionIdName>(),
                                        RelativeId = "1"
                                    };
                                }
                            }
                        }
                    }
                }
                else//else its activity or resource
                {
                    var restriction = helper.GetRestriction(
                        ActivityOrResource
                        , (byte)(((int)ActivityOrResourceType))
                        , ActivityOrResourceId);
                    if (restriction != null)
                    {
                        EachRestriction1.RestrictionId = restriction.Id;
                        EachRestriction1.SetConstraints(restriction.MatchMust, restriction.MatchAllAny);
                        // populate session..
                        var relativeId = EachRestriction1.RelativeId;
                        var rSession   = Session["ControlList_" + hidPageKeyForUniqueSession.Value] as RestrictionIdName;
                        var user       = Page.User as CustomPrincipal;

                        if (user != null)
                        {
                            if (rSession != null)
                            {
                                var parent = rSession;
                                SetRestriction(restriction, parent);
                            }
                            else
                            {
                                Session["ControlList_" + hidPageKeyForUniqueSession.Value] = new RestrictionIdName()
                                {
                                    AbsoluteId = EachRestriction1.AbsoluteId,
                                    ParentId   = "0",
                                    Name       = "Main",
                                    Children   = new List <RestrictionIdName>(),
                                    RelativeId = "1"
                                };
                            }
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblError.Visible = false;

            var subId = Request.QueryString["SubId"];
            var secId = Request.QueryString["SecId"];

            if (!IsPostBack)
            {
                if (secId != null)
                {
                    try
                    {
                        var sectionId = Convert.ToInt32(secId);
                        SectionId = sectionId;

                        using (var strhelper = new DbHelper.Structure())
                            using (var helper = new DbHelper.SubjectSection())
                            {
                                var section = helper.GetSection(sectionId);
                                if (section != null)
                                {
                                    LoadSitemap(strhelper, section.Subject);
                                    SubjectId = section.SubjectId;
                                    //btnDelete.Visible = true;
                                    txtName.Text    = section.Name;
                                    txtDesc.Text    = section.Summary;
                                    chkShow.Checked = section.ShowSummary ?? false;
                                    //after assigning section datatype , all is taken care in restrictionUC
                                    RestrictionUC1.SectionId = sectionId;
                                }
                            }
                    }
                    catch
                    {
                        Response.Redirect("~/");
                    }
                }
                else if (subId != null)
                {
                    try
                    {
                        var subjectId = Convert.ToInt32(subId);
                        SubjectId = subjectId;
                        using (var strhelper = new DbHelper.Structure())
                            using (var helper = new DbHelper.Subject())
                            {
                                var sub = helper.GetCourse(subjectId);
                                if (sub != null)
                                {
                                    LoadSitemap(strhelper, sub);
                                    lblHeading.Text = "New section in : '" + sub.FullName + "'";
                                }
                                else
                                {
                                    Response.Redirect("~/");
                                }
                            }
                    }
                    catch
                    {
                        Response.Redirect("~/");
                    }
                }
                else
                {
                    Response.Redirect("~/");
                }
            }
        }