Exemplo n.º 1
0
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            using (var helper = new Academic.DbHelper.DbHelper.AcademicYear())
            {
                var list = new List <Academic.DbEntities.SessionDefault>();

                list.Add(new Academic.DbEntities.SessionDefault()
                {
                    Id       = Session1Id,
                    Name     = txtNameSession1.Text,
                    Position = 1
                });

                list.Add(new Academic.DbEntities.SessionDefault()
                {
                    Id       = Session2Id,
                    Name     = txtNameSession2.Text,
                    Position = 2
                });

                bool saved = helper.AddOrUpdateSessionDefault(list);
                if (saved)
                {
                    Response.Redirect("~/Views/Academy/DefaultSessions.aspx");
                }
            }
        }
Exemplo n.º 2
0
        private void LoadClasses(Academic.DbHelper.DbHelper.AcademicYear helper, CustomPrincipal user, int sessionPosition)
        {
            var dict = helper.ListClassesForNextSession(user.SchoolId, sessionPosition);

            if (dict != null)
            {
                foreach (var program in dict.Keys)
                {
                    var pLabel = new Label()
                    {
                        Font = { Bold = true },
                        Text = program.Name + "<br/>"
                    };
                    pnlListing.Controls.Add(pLabel);
                    foreach (var rc in dict[program])
                    {
                        var rcLabel = new Label()
                        {
                            //Font = { Size = 14, Bold = false },
                            Text = "&nbsp;&nbsp;" + rc.ProgramBatch.Batch.Name + " -- " +
                                   rc.Year.Name + " " + (rc.SubYear == null ? "" : rc.SubYear.Name) +
                                   "<br/>"
                        };
                        pnlListing.Controls.Add(rcLabel);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void LoadData()
        {
            var user = Page.User as CustomPrincipal;

            if (user != null)
            {
                using (var helper = new Academic.DbHelper.DbHelper.AcademicYear())
                {
                    int sessionPosition = LoadTextBoxes(helper, user);

                    if (sessionPosition == 0)
                    {
                        return;
                    }
                    LoadClasses(helper, user, sessionPosition);
                }
            }
        }
Exemplo n.º 4
0
        private void LoadData()
        {
            var user = Page.User as CustomPrincipal;

            if (user != null)
            {
                var roleAccess = user.IsInRole(DbHelper.StaticValues.Roles.Manager);
                var editMode   = Session["editMode"] as string;
                var editM      = editMode == "1";//string.IsNullOrEmpty(editMode)?false:editMode == "1";

                var editQuery = Request.QueryString["edit"];
                var editQ     = editQuery != null && editQuery == "1";
                var edit      = editM && editQ && roleAccess;


                txtNameSession1.Enabled = edit;
                txtNameSession2.Enabled = edit;
                pnlSaveDiv.Visible      = edit;
                lnkEdit.Visible         = editM && !edit && roleAccess;

                using (var helper = new Academic.DbHelper.DbHelper.AcademicYear())
                {
                    var defaultSessions = helper.ListDefaultSessions(user.SchoolId);
                    if (defaultSessions.Count >= 2)
                    {
                        txtNameSession1.Text = defaultSessions[0].Name;
                        Session1Id           = defaultSessions[0].Id;
                        txtNameSession2.Text = defaultSessions[1].Name;
                        Session2Id           = defaultSessions[1].Id;
                    }
                }
            }
            else
            {
                Response.Redirect("~/Views/Academy/");
            }
        }
Exemplo n.º 5
0
        private int LoadTextBoxes(Academic.DbHelper.DbHelper.AcademicYear helper, CustomPrincipal user)
        {
            int sessionPosition = 1;

            Academic.DbEntities.Session currentlyActiveSession = null; // = new Academic.DbEntities.Session();
            Academic.DbEntities.Session nextToActivateSession  = null; // = new Academic.DbEntities.Session();
            var academicYear = helper.GetNextSessionToActivate(user.SchoolId, ref currentlyActiveSession, ref nextToActivateSession);

            if (academicYear == null)
            {
                //we don't have any new academic year
                //then redirect to academic create page
                Response.Redirect("~/Views/Academy/Create.aspx?from=startSession", false);
                return(0);
            }


            //populate data
            var sessions = academicYear.Sessions.OrderBy(x => x.Position).ToList();

            lblAcademicYear.Text        = academicYear.Name;
            lblSemester1.Text           = sessions[0].Name;
            lblSemester2.Text           = sessions[1].Name;
            lblUpcomingSessionName.Text = " (Session : " + nextToActivateSession.Name + ")";

            hidAcademicYearId.Value          = academicYear.Id.ToString();
            hidNextActivatingSessionId.Value = nextToActivateSession.Id.ToString();

            if (currentlyActiveSession != null)
            {
                hidCurrentlyActiveSessionId.Value = currentlyActiveSession.Id.ToString();
                lblCurrentSession.Text            = currentlyActiveSession.AcademicYear.Name + " - " + currentlyActiveSession.Name;
                imgCurrentSession.Visible         = true;
            }

            if (nextToActivateSession.Id == sessions[0].Id)
            {
                imgSem1.Visible = true;
                sessionPosition = 1;
            }
            else if (nextToActivateSession.Id == sessions[1].Id)
            {
                imgSem2.Visible = true;
                sessionPosition = 2;
            }
            return(sessionPosition);


            #region Unused and commented

            //var isAcademicYearAlreadyPresent = academicYear.Id > 0;


            //txtAcademicyear.Text = academicYear.Name;
            //txtSemester1.Text = sessions[0].Name;
            //txtSemester2.Text = sessions[1].Name;

            //lblAcademicYear.Visible = isAcademicYearAlreadyPresent;
            //lblSemester1.Visible = isAcademicYearAlreadyPresent;
            //lblSemester2.Visible = isAcademicYearAlreadyPresent;

            //txtAcademicyear.Visible = !isAcademicYearAlreadyPresent;
            //txtSemester1.Visible = !isAcademicYearAlreadyPresent;
            //txtSemester2.Visible = !isAcademicYearAlreadyPresent;

            //reqValiAcademicyear.Enabled = !isAcademicYearAlreadyPresent;
            //reqValiSem1.Enabled = !isAcademicYearAlreadyPresent;
            //reqValiSem2.Enabled = !isAcademicYearAlreadyPresent;

            //if (isAcademicYearAlreadyPresent)
            //{


            //}
            //else
            //{

            //}
            //else
            //{
            //    txtAcademicyear.Text = academicYear.Name;
            //    txtSemester1.Text = sessions[0].Name;
            //    txtSemester2.Text = sessions[1].Name;
            //}


            #endregion
        }