private void LoadData() { var user = Page.User as CustomPrincipal; var aId = Request.QueryString["aId"]; if (user != null) { using (var bHelper = new DbHelper.Batch()) using (var sHelper = new DbHelper.Structure()) { if (aId != null) { btnSaveAndAddSessions.Visible = false; var batch = bHelper.GetBatchByAcademicYearId(Convert.ToInt32(aId)); if (batch != null) { if (batch.AcademicYear.IsActive || (batch.AcademicYear.Completed ?? false)) { txtEnd.Enabled = false; txtStart.Enabled = false; CheckBoxList1.Enabled = false; chkSelectAll.Enabled = false; if (batch.AcademicYear.Completed ?? false) { txtName.Enabled = false; txtBatchName.Enabled = false; btnSave.Enabled = false; } } BatchId = batch.Id; var acad = batch.AcademicYear; if (acad != null) { //=========================Academic year, batch hidId.Value = aId; txtName.Text = acad.Name; txtStart.Text = acad.StartDate.ToShortDateString(); txtEnd.Text = acad.EndDate.ToShortDateString(); txtBatchName.Text = batch.Name; } } } //============================ Structure SetStructure(sHelper, user); } } }
private void LoadData() { var user = Page.User as CustomPrincipal; var aId = Request.QueryString["aId"]; if (user != null) { using (var aHelper = new DbHelper.AcademicYear()) using (var bHelper = new DbHelper.Batch()) using (var sHelper = new DbHelper.Structure()) { var fromSession = Request.QueryString["from"]; if (fromSession == "startSession") { lblFromSessionNotice.Visible = true; } if (aId == null) { var sessionsDefault = aHelper.ListDefaultSessions(user.SchoolId); if (sessionsDefault.Count >= 2) { txtSession1Name.Text = sessionsDefault[0].Name; txtSession2Name.Text = sessionsDefault[1].Name; } } else { //btnSaveAndAddSessions.Visible = false; var batch = bHelper.GetBatchByAcademicYearId(Convert.ToInt32(aId)); if (batch != null) { BatchId = batch.Id; var acad = batch.AcademicYear; if (acad != null) { //=========================Academic year, batch AcademicYearId = acad.Id; txtName.Text = acad.Name; txtAcademicStart.Text = acad.StartDate.ToShortDateString(); txtAcademicEnd.Text = acad.EndDate.ToShortDateString(); txtBatchName.Text = batch.Name; //========================Sessions var sessions = acad.Sessions.Where(x => !(x.Void ?? false)).ToList(); if (sessions.Count >= 2) { // enable disable session1 txtSession1Name.Text = sessions[0].Name; Session1Id = sessions[0].Id; txtSession1Start.Text = sessions[0].StartDate.ToShortDateString(); txtSession1End.Text = sessions[0].EndDate.ToShortDateString(); var session1Enabled = !(sessions[0].IsActive || (sessions[0].Completed ?? false)); txtSession1Name.Enabled = session1Enabled; txtSession1Start.Enabled = session1Enabled; txtSession1End.Enabled = session1Enabled; //enable , disable session2 txtSession2Name.Text = sessions[1].Name; Session2Id = sessions[1].Id; txtSession2Start.Text = sessions[1].StartDate.ToShortDateString(); txtSession2End.Text = sessions[1].EndDate.ToShortDateString(); var session2Enabled = !(sessions[1].IsActive || (sessions[1].Completed ?? false)); txtSession2Name.Enabled = session2Enabled; txtSession2Start.Enabled = session2Enabled; txtSession2End.Enabled = session2Enabled; //enable , disable -- academic year if (batch.AcademicYear.IsActive || (batch.AcademicYear.Completed ?? false) || !session2Enabled || !session1Enabled) { txtName.Enabled = false; txtAcademicEnd.Enabled = false; txtAcademicStart.Enabled = false; CheckBoxList1.Enabled = false; //earlier working //chkSelectAll.Enabled = false; txtName.Enabled = false; txtBatchName.Enabled = false; btnSave.Enabled = false; CheckBoxList1.Enabled = false; //earlier working //chkSelectAll.Enabled = false; } } } } } //============================ Structure SetStructure(sHelper, user); } } }
public void LoadData() { var edit = Edit; using (var shelper = new DbHelper.Batch()) //using (var helper = new DbHelper.AcademicYear()) { var batch = shelper.GetBatchByAcademicYearId(AcademicYearId); if (batch != null) { lnkBatch.Text = batch.Name + " (click to view programs)"; lnkBatch.NavigateUrl = "~/Views/Student/Batch/?Id=" + batch.Id; var academic = batch.AcademicYear; //var academic = helper.GetAcademicYear(AcademicYearId); if (academic != null) { if (SiteMap.CurrentNode != null) { var list = new List <IdAndName>() { new IdAndName() { Name = SiteMap.RootNode.Title , Value = SiteMap.RootNode.Url , Void = true }, new IdAndName() { Name = SiteMap.CurrentNode.ParentNode.Title , Value = SiteMap.CurrentNode.ParentNode.Url + "?edit=" + (Edit ? "1" : "0") , Void = true }, new IdAndName() { Name = academic.Name } }; SiteMapUc.SetData(list); } lblPageTitle.Text = academic.Name; lblEndDate.Text = academic.EndDate.ToString("D"); lblStartDate.Text = academic.StartDate.ToString("D"); string name = ""; if (academic.Completed ?? false) { name = " (Complete)"; //btnMarkComplete.Visible = false; //btnActivate.Visible = false; //lnkAddClasses.Visible = false; lnknewSession.Visible = false; } else if (academic.IsActive) { name = " (Active)"; //btnActivate.Visible = false; } else { //btnMarkComplete.Visible = false; } lblAcademicYearName.Text = academic.Name + name; foreach (var sess in academic.Sessions.Where(x => !(x.Void ?? false)).ToList()) { var sessUc = (Academy.UserControls.SessionsListingInAYDetailUC) Page.LoadControl("~/Views/Academy/UserControls/SessionsListingInAYDetailUC.ascx"); sessUc.LoadSessionData(academic.Id, sess.Id, sess.Name , sess.StartDate, sess.EndDate , sess.IsActive, sess.Completed ?? false, Edit, false); pnlSessions.Controls.Add(sessUc); } } else { Response.Redirect("~/Views/Academy/List.aspx"); } } } //using (var helper = new DbHelper.AcademicPlacement()) //{ // var classes = helper.ListRunningRunningClasses(AcademicYearId, 0);//.OrderBy(p=>p.ProgramBatch.Program.Name); // if (classes.Any()) // pnlSessionPrograms.Visible = true; // ListView1.DataSource = classes; // ListView1.DataBind(); //} }